IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

MkFramework Discussion :

Division par zéro


Sujet :

MkFramework

  1. #1
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2017
    Messages
    162
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 26
    Localisation : Dom-Tom

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Décembre 2017
    Messages : 162
    Points : 48
    Points
    48
    Par défaut Division par zéro
    Bonjour Mika,

    Je voudrais savoir pourquoi j'ai cette erreur :

    Division by zero
    #0 C:\wamp\www\mkframework\data\genere\HyperInterim\plugin\plugin_chart.php(334): exception_error_handler(2, 'Division by zer...', 'C:\\wamp\\www\\mkf...', 334, Array)
    #1 C:\wamp\www\mkframework\data\genere\HyperInterim\plugin\plugin_chart.php(66): plugin_chartPie->show()
    #2 C:\wamp\www\mkframework\data\genere\HyperInterim\module\statistiques\view\statistiquecomplex.php(53): plugin_chart->show()
    #3 C:\wamp\www\mkframework\lib\framework\class_view.php(85): include('C:\\wamp\\www\\mkf...')
    #4 C:\wamp\www\mkframework\lib\framework\class_layout.php(158): _view->show()
    #5 C:\wamp\www\mkframework\data\genere\HyperInterim\layout\bootstrap.php(32): _layout->load('main')
    #6 C:\wamp\www\mkframework\lib\framework\class_layout.php(122): include('C:\\wamp\\www\\mkf...')
    #7 C:\wamp\www\mkframework\data\genere\HyperInterim\module\statistiques\main.php(217): _layout->show()
    #8 C:\wamp\www\mkframework\lib\framework\class_root.php(276): module_statistiques->after()
    #9 C:\wamp\www\mkframework\data\genere\HyperInterim\public\index.php(47): _root->run()
    #10 {main}
    Je te met mon code a disposition :

    Ma vue:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
     <?php 
    $oForm=new plugin_form();
    ?>
     
    <h2><center>Statistique</center></h2><br><br>
     
    <form action="" method="POST">
     
    Rayon Affectation <?php echo $oForm->getSelect('rayonaffects',$this->tstatistique,array('onChange'=>'this.parentNode.submit()'))?><br><br>
     
    		<center><div class="col-sm-offset-2 col-sm-10">
    		<input type="submit" name="Trans" class="btn btn-success" value="Transféré les données" /> 
    		</center></div><br>
     
    		<center><div class="col-sm-offset-2 col-sm-10">
    		<input type="submit" name="Eff" class="btn btn-success" value="Vider la table" /> 
    		</center></div><br><br><br>
     
    		<center><div class="col-sm-offset-2 col-sm-10">
    		<input type="submit" name="Raf" class="btn btn-success" value="Rafraichir" /><br><br> 
    		</center></div>
     
    		</form>
     
    <p>&nbsp;</p>
     
    <?php if(isset($this->oChartPie) ):?>
     
    <h1><center>Total heures par Rayon </center></h1><br><br>
     
    <table class="table">
     
    		<tr>
    			<th>Rayon</th>
    			<th>Total Heure</th>
    		</tr>
     
    		<?php foreach($this->tData as $data):?>
     
    		<?php list($rayonaffects,$nbheuremissiontotal)=$data;?>
     
    		<tr>
    				<td><?php echo $rayonaffects?></td>
    				<td><?php echo $nbheuremissiontotal?></td>
    			</tr>
     
    			<?php endforeach;?>
    	</table>
     
    	<p>&nbsp;</p>
     
     
    <center><?php echo $this->oChartPie->show()?></center>
     
    <?php endif;?>
    Mon main (la partie concerné):
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    public function _statistiquecomplex(){
     
    		if(_root::getParam('Trans') ){
     
    			$tStatistique=model_mission::getInstance()->transmission(_root::getAuth()->getAccount()->magasin_id, _root::getAuth()->getAccount()->magasin_id, 
    			_root::getAuth()->getAccount()->magasin_id, _root::getAuth()->getAccount()->magasin_id, _root::getAuth()->getAccount()->magasin_id,  _root::getAuth()->getAccount()->magasin_id, _root::getAuth()->getAccount()->magasin_id, _root::getAuth()->getAccount()->magasin_id, _root::getAuth()->getAccount()->magasin_id, _root::getAuth()->getAccount()->magasin_id);
     
    		}
     
    		if(_root::getParam('Eff') ){
     
    			$tStatistique=model_mission::getInstance()->effmission();
     
    		}
     
    		if(_root::getParam('Raf') ){
     
    		$tStatistique=model_statistique::getInstance()->missioncalcul();
    		$tStatistique=model_statistique::getInstance()->missioncalcul2();
    		}
     
    		$oView=new _view('statistiques::statistiquecomplex');
     
    		$tstatistique=model_statistique::getInstance()->getSelect();
     
    		$oView->tstatistique=$tstatistique;
     
    		$sRayAffects= _root::getParam('rayonaffects');
     
    		$tjours=$this->getResultat( _root::getAuth()->getAccount()->magasin_id, $sRayAffects);
     
    		if($tjours){
    			$tData=array();
    			foreach($tjours as $ojour){
    				$tData[]=array($ojour->rayonaffects, $ojour->heuretotal);
    		}
     
    		$oChartPie=new plugin_chart('PIE',400,200);
    		$oChartPie->setTextSizeLegend('12px arial');
    		$oChartPie->setData($tData);
     
    		//coordonnees de la legende
    	    $oChartPie->setCoordLegend(220,60);
     
    		$oView->oChartPie=$oChartPie;
     
    		$oView->tData=$tData;
    		}
     
    		$this->oLayout->add('main',$oView);
     
    	}
    Mon modele
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    <?php
    class model_statistique extends abstract_model{
     
    	protected $sClassRow='row_statistique';
     
    	protected $sTable='statistique';
    	protected $sConfig='hyperinterim';
     
    	protected $tId=array('idstatistique');
     
    	public static function getInstance(){
    		return self::_getInstance(__CLASS__);
    	}
     
    	public function findById($uId){
    		return $this->findOne('SELECT * FROM '.$this->sTable.' WHERE idstatistique=?',$uId );
    	}
    	public function findAll(){
    		return $this->findMany('SELECT * FROM '.$this->sTable);
    	}
     
    	public function missioncalcul(){
    		return $this->execute('
    		
    		UPDATE statistique
    		
    		SET nbheuremoisrayon = SEC_TO_TIME( TIME_TO_SEC(nbheurejourmission) * pourcentages / 100),
    			montantmoisrayon = cast( TIME_TO_SEC(nbheuremoisrayon)/3600 * prixdeagence * pourcentages / 100 as decimal(10,2)) 
    		
    		WHERE MONTH(datedebs) = MONTH(datefins)
    		');
     
    	}
     
    	public function missioncalcul2(){
    		return $this->execute('
    		
    		UPDATE statistique
    		
    		SET
    			nbjourmission = DATEDIFF(datedebs, datefins),
    			nbheuremoisrayon = SEC_TO_TIME( TIME_TO_SEC(nbheurejourmission) * pourcentages / 100),
    			montantmoisrayon = cast( TIME_TO_SEC(nbheuremoisrayon)/3600 * prixdeagence * pourcentages / 100 as decimal(10,2)) 
    		
    		WHERE MONTH(datedebs) != MONTH(datefins)
    		');
     
    	}
     
    	public function findbyRay($magId){
    		return $this->findManySimple('SELECT DISTINCT rayonaffects FROM '.$this->sTable.'');
    	}
     
    	public function getSelect(){
    		$tab=$this->findbyRay(_root::getAuth()->getAccount()->magasin_id);
    		$tSelect=array(null);
    		if($tab){
    		foreach($tab as $oRow){
    			$tSelect[ $oRow->rayonaffects ]=$oRow->rayonaffects;
    		}
    		}
    		return $tSelect;
    	}
     
    	public function listrayon($magId, $rayonaffects){
    		return $this->findMany('
    		SELECT DISTINCT
    		rayonaffects,
    		IF(rayonaffects=rayonaffects, SEC_TO_TIME(SUM(DISTINCT TIME_TO_SEC(nbheuremoisrayon))),nbheuremoisrayon) AS heuretotal
    
    		FROM statistique
    
    		INNER JOIN user
    				ON statistique.magasin_ids=user.magasin_id
    
    		WHERE
    		magasin_ids=?
    		AND 
    		rayonaffects=?
    		
    			',$magId, $rayonaffects);
    	}

  2. #2
    Rédacteur
    Avatar de imikado
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    5 239
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Finance

    Informations forums :
    Inscription : Décembre 2006
    Messages : 5 239
    Points : 19 100
    Points
    19 100
    Billets dans le blog
    17
    Par défaut
    Bonjour,

    Il semble y avoir un soucis sur $tData, vous pourriez l'afifhcer, verifier que heuretotal est bien renseigné ?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    if($tjours){
    			$tData=array();
    			foreach($tjours as $ojour){
    				$tData[]=array($ojour->rayonaffects, $ojour->heuretotal);
    		}
    Dans l'idee: dans le plugin camembert, on boucle sur tData, et on somme les valeurs pour avoir la valeur total du camembert

    ensuite, data par data, on divise la valeur de celle-ci par ce total

    Ici ce total semble etre à 0 ou indefini, je soupçonne donc un soucis du $tData
    Framework php sécurisé et simple à prendre en main avec générateur web http://mkframework.com/ (hebergé sur developpez.com)
    Mes cours/tutoriaux

  3. #3
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2017
    Messages
    162
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 26
    Localisation : Dom-Tom

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Décembre 2017
    Messages : 162
    Points : 48
    Points
    48
    Par défaut
    Pourtant heurTotal est bien defini je comprend pas

  4. #4
    Rédacteur
    Avatar de imikado
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    5 239
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Finance

    Informations forums :
    Inscription : Décembre 2006
    Messages : 5 239
    Points : 19 100
    Points
    19 100
    Billets dans le blog
    17
    Par défaut
    afficher $tData: si le tableau est vide, vous aurez le meme soucis
    Framework php sécurisé et simple à prendre en main avec générateur web http://mkframework.com/ (hebergé sur developpez.com)
    Mes cours/tutoriaux

  5. #5
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2017
    Messages
    162
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 26
    Localisation : Dom-Tom

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Décembre 2017
    Messages : 162
    Points : 48
    Points
    48
    Par défaut
    Donc je dois faire quoi pour régler le problème ?

  6. #6
    Rédacteur
    Avatar de imikado
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    5 239
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Finance

    Informations forums :
    Inscription : Décembre 2006
    Messages : 5 239
    Points : 19 100
    Points
    19 100
    Billets dans le blog
    17
    Par défaut
    D'abord verifier le contenu de $tData avec un var_dump

    par exemple
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    var_dump($tData);exit;
    Framework php sécurisé et simple à prendre en main avec générateur web http://mkframework.com/ (hebergé sur developpez.com)
    Mes cours/tutoriaux

  7. #7
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2017
    Messages
    162
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 26
    Localisation : Dom-Tom

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Décembre 2017
    Messages : 162
    Points : 48
    Points
    48
    Par défaut
    Voici ce que j'ai donc je comprend pas pourquoi il m'affiche le message d'erreur "Division By Zero"

    Mais pourquoi dès que c'est "null" sa met la même erreur ?

    array (size=2)
    0 => string '12 - D.P.H' (length=10)
    1 => string '04:32:00' (length=8)
    array (size=2)
    0 => null
    1 => null

  8. #8
    Rédacteur
    Avatar de imikado
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    5 239
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Finance

    Informations forums :
    Inscription : Décembre 2006
    Messages : 5 239
    Points : 19 100
    Points
    19 100
    Billets dans le blog
    17
    Par défaut
    null = 0

    mais une chose m'echape: le champ heuretotal n'est pas un simple nombre ? pour que le plugin camembert fonctionne il lui faut des valeurs numeriques simple

    je rappelle le fonctionnement:

    on lui passe un tableau cle/valeur, il parcoure, additionne les valeurs pour avoir le total puis l'utilise pour connaitre les portions à decouper dans le camembert, par exemple

    Pour une salade de fruit, ça donnerai

    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    $tData=array(
     array('Pomme',40),
     array('Poire',20),
     array('Ananas',10),
    );

    Il va parcourir en additionnant les valeurs 40+20+10 = 70

    et ainsi il va faire un camembert en faisant taille de la Pomme = 40/70, Pour la poire 20/70 ...

    vous voyez l'idée et aussi le probleme posé ici
    Framework php sécurisé et simple à prendre en main avec générateur web http://mkframework.com/ (hebergé sur developpez.com)
    Mes cours/tutoriaux

  9. #9
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2017
    Messages
    162
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 26
    Localisation : Dom-Tom

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Décembre 2017
    Messages : 162
    Points : 48
    Points
    48
    Par défaut
    Enfaîte j'ai une donnée qui a : 00:52:00 pour cella qu'il me met une erreur

Discussions similaires

  1. Division par zéro
    Par soltani1 dans le forum MS SQL Server
    Réponses: 4
    Dernier message: 18/05/2006, 09h42
  2. [Tableaux] Pb de division par zéro...
    Par blueice dans le forum Langage
    Réponses: 8
    Dernier message: 16/12/2005, 15h52
  3. [CR][VS.NET]Division par zéro
    Par San Soussy dans le forum SDK
    Réponses: 2
    Dernier message: 31/08/2005, 14h40
  4. [CR8.5] Problème de division par zéro sur formule
    Par franck.cvitrans dans le forum Formules
    Réponses: 3
    Dernier message: 10/06/2004, 13h41
  5. probleme avec une division par zéro
    Par jcharleszoxi dans le forum Langage SQL
    Réponses: 2
    Dernier message: 26/03/2003, 18h14

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo