RatiosSecteur->item)>0){ foreach($ratios->RatiosSecteur->item as $item){ foreach($item->liste->item as $ratiosItem){ $this->ratiosSecteur[$item->annee][$ratiosItem->id] = $ratiosItem->val; } } } //Orgnaisation des informations des ratios foreach($ratios->RatiosInfos->item as $item){ $this->ratiosInfos[$item->id] = $item; } //Orgnaisation RatiosEntrep et RatiosEntrepEvol if (count($ratios->BilansInfos->item)>0){ foreach($ratios->BilansInfos->item as $item) { $this->bilansInfo[$item->typeBilan][$item->dateCloture] = $item; foreach($item->RatiosEntrep->item as $ratiosItem){ $this->ratiosEntrep[$item->typeBilan][$item->dateCloture][$ratiosItem->id] = $ratiosItem->val; } foreach($item->RatiosEntrepEvol->item as $ratiosItem){ $this->ratiosEntrepEvol[$item->typeBilan][$item->dateCloture][$ratiosItem->id] = $ratiosItem->val; } //Comptage de bilans $this->{'nbBilan'.$item->typeBilan}++; } } } public function getNbBilan($type) { return $this->{'nbBilan'.$type}; } /** * Renvoi le ratio de l'entité * @param string $type * @param string $dateCloture * @param string $id */ function dRatio($type, $dateCloture, $id){ $ratio = $this->ratiosEntrep[$type][$dateCloture][$id]; $return = ''; $formatRatio = TRUE; if ($ratio=='NS' || $ratio==0) { $return.= 'NS'; $formatRatio = FALSE; }elseif(substr($ratio,0,1)=='<' ){ $return.= '< '; $ratio = substr($ratio,1)*1; }elseif(substr($ratio,0,1)=='>'){ $return.= '> '; $ratio = substr($ratio,1)*1; }elseif($ratio==NULL){ $return.= '-'; $formatRatio = FALSE; } if($formatRatio == TRUE) { if ( ($this->ratiosInfos[$id]->unite=='EUR') && ((abs($ratio)/1000)>0) ){ $return.= number_format($ratio/1000, 0, '', ' ').' K€'; }elseif (($this->ratiosInfos[$id]->unite=='EUR') && ((abs($ratio)/1000)<0)) { $return.= number_format($ratio, 0, '', ' ').' €'; }elseif (($this->ratiosInfos[$id]->unite=='Jours')) { $return.= number_format($ratio, 0, '', ' ').' '.$this->ratiosInfos[$id]->unite; }elseif (($this->ratiosInfos[$id]->unite=='AN')) { $return.= round($ratio, 2).' '.$this->ratiosInfos[$id]->unite; }elseif (($ratiosInfos[$nRatio]['unite']=='%')) { $return.= round($ratio).' '.$this->ratiosInfos[$id]->unite; }else{ $return.= $ratio.' '.$this->ratiosInfos[$id]->unite; } } return $return; } /** * Renvoi le ratio secteur * @param string $dateCloture * @param string $id */ function dSecteur($dateCloture, $id){ $ratio = $this->ratiosSecteur[substr($dateCloture,0,4)][$id]; $return = ''; $formatRatio = TRUE; if ($ratio=='NS') { $return.= 'NS'; $formatRatio = FALSE; }elseif(substr($ratio,0,1)=='<' ){ $return.= '< '; $ratio = substr($ratio,1)*1; }elseif(substr($ratio,0,1)=='>'){ $return.= '> '; $ratio = substr($ratio,1)*1; }elseif($ratio==NULL){ $return.= '-'; $formatRatio = FALSE; } if($formatRatio == TRUE) { if ( ($this->ratiosInfos[$id]->unite=='EUR') && ((abs($ratio)/1000)>0) ){ $return.= number_format($ratio/1000, 0, '', ' ').' K€'; }elseif (($this->ratiosInfos[$id]->unite=='EUR') && ((abs($ratio)/1000)<0)) { $return.= number_format($ratio, 0, '', ' ').' €'; }elseif (($this->ratiosInfos[$id]->unite=='Jours')) { $return.= number_format($ratio, 0, '', ' ').' '.$this->ratiosInfos[$id]->unite; }elseif (($this->ratiosInfos[$id]->unite=='AN')) { $return.= round($ratio, 2).' '.$this->ratiosInfos[$id]->unite; }elseif (($ratiosInfos[$nRatio]['unite']=='%')) { $return.= round($ratio).' '.$this->ratiosInfos[$id]->unite; }else{ $return.= $ratio.' '.$this->ratiosInfos[$id]->unite; } } return $return; } /** * Renvoi la position de l'entité en comparant son ratio avec le ratio secteur * Enter description here ... * @param string $type * @param string $dateCloture * @param string $id * @param string $compare * @return string */ function dPosition($type, $dateCloture, $id, $compare) { $ratioS = $this->ratiosSecteur[substr($dateCloture,0,4)][$id]; $ratioE = $this->ratiosEntrep[$type][$dateCloture][$id]; $ecart = 1/100; if( $ratioS=='NS' || $ratioE=='NS' || $ratioS==NULL || $ratioE==NULL){ $return = '-'; }elseif($compare=='>'){ if( $ratioE+$ecart > $ratioS ){ $return = ''; }elseif( ($ratioS-($ratioS*$ecart))<$ratioE && ($ratioS+($ratioS*$ecart))>$ratioE){ $return = '-'; }else{ $return = ''; } }elseif($compare=='<'){ if($ratioE < $ratioS){ $return = ''; }elseif( ($ratioS-($ratioS*$ecart))<$ratioE && ($ratioS+($ratioS*$ecart))>$ratioE){ $return = '-'; }else{ $return = ''; } } return $return; } /** * Affiche l'évolution d'un ratio. * @param string $type * @param string $dateCloture * @param string $id */ function dEvol($type, $dateCloture, $id){ $ratio = $this->ratiosEntrepEvol[$type][$dateCloture][$id]; if ($ratio=='NS') { return 'NS'; }elseif($ratio==NULL){ return '-'; }else{ return $ratio.' %'; } } /** * Enter description here ... * @param unknown_type $type * @param unknown_type $dateCloture * @param unknown_type $id * @param unknown_type $totalRatio * @return string */ function dTotal($type, $dateCloture, $id, $totalRatio) { $ratio = isset($this->ratiosEntrep[$type][$dateCloture][$id]) ? $this->ratiosEntrep[$type][$dateCloture][$id] : 0; $total = isset($this->ratiosEntrep[$type][$dateCloture][$totalRatio]) ? $this->ratiosEntrep[$type][$dateCloture][$totalRatio] : 0; if($total!=0){ return number_format($ratio*100/$total, 2); }else{ return '-'; } } /** * Retourne le tableau pour l'affichage des graphiques d'évolution * @param string $type * @param string $id */ function dGraph($type, $id) { $evol = array(); $bilansInfo = $this->bilansInfo[$type]; ksort($bilansInfo); foreach($bilansInfo as $item) { $dateCloture = $item->dateCloture; $div = 1; $ratioE = $this->ratiosEntrep[$type][$dateCloture][$id]; $ratioS = $this->ratiosSecteur[substr($dateCloture,0,4)][$id]; if ( ($ratiosInfos[$nRatio]['unite']=='EUR') && ((abs($ratioE)/1000)>0) ){ $unite = 'KEURO'; $div = 1000; }else{ $unite = $this->ratiosInfos[$id]->unite; } //Données pour les graphiques évolutions $data[] = array( 'date' => $dateCloture, 'entreprise' => (($ratioE!='NS') ? $ratioE/$div : 0 ), 'secteur' => (($ratioS!='NS') ? $ratioS/$div : 0 ), ); } $evol = array('data' => $data, 'unite' => $unite); return $evol; } /** * Affiche le pourcentage d'un ratio par rapport au total. * @param string $type * @param string $dateCloture * @param string $id * @param string $totalRatio * @return mixed */ function dPercent($type, $dateCloture, $id, $totalRatio){ $ratio = $this->ratiosEntrep[$type][$dateCloture][$id]; $totalRatio = $this->ratiosEntrep[$type][$dateCloture][$totalRatio]; if ($ratio=='NS') { $return = 'NS'; }elseif($ratio==NULL){ $return = '-'; }else { if ($totalRatio!=0 || $totalRatio!='NS'){ $percent = $ratio*100/$totalRatio; }else{ $percent = 0; } $return = round($percent, 2); } return $return; } /** * Retourne le pourcentage d'un ratio par rapport au total pour les graphiques * @param string $type * @param string $dateCloture * @param string $id * @param string $totalRatio */ function graphPercent($type, $dateCloture, $id, $totalRatio){ $ratio = isset($this->ratiosEntrep[$type][$dateCloture][$id]) ? $this->ratiosEntrep[$type][$dateCloture][$id] : 0; $totalRatio = $this->ratiosEntrep[$type][$dateCloture][$totalRatio]; if ( ($ratio!='NS' || $ratio!=NULL) && ($totalRatio!=0 || $totalRatio!='NS')){ return $ratio*100/$totalRatio; }else{ return 0; } } /** * Formatte le commentaire pour l'afficher dans l'infobulle. * @param string $nRatios * Identifiant du ratio * @return string */ function wrapComment($nRatio){ $text = $this->ratiosInfos[$nRatio]->commentaires; $newtext = htmlentities($text, null, 'utf-8'); $newtext = nl2br($newtext); return $newtext; } public function getBilansInfo($type) { return $this->bilansInfo[$type]; } public function getRatiosInfos($id) { return $this->ratiosInfos[$id]; } public function getRatiosEntrep($type, $dateCloture, $id) { return $this->ratiosEntrep[$type][$dateCloture][$id]; } public function getRatiosEntrepEvol($type, $dateCloture, $id) { return $this->ratiosEntrepEvol[$type][$dateCloture][$id]; } public function getRatiosSecteur($annee, $id) { return $this->ratiosSecteur[substr($annee,0,4)][$id]; } public function getTableRatiosInfos() { return $this->ratiosInfos; } public function getTableRatiosSecteur() { return $this->ratiosSecteur; } public function getTableRatiosEntrep($type) { if (array_key_exists($type, $this->ratiosEntrep)){ return $this->ratiosEntrep[$type]; } return false; } public function getTableRatiosEntrepEvol($type) { if (array_key_exists($type, $this->ratiosEntrepEvol)){ return $this->ratiosEntrepEvol[$type]; } return false; } private function ignoreType($type, $typeDelete) { foreach ($typeDelete as $t) { if ($t == $type) return (false); } return (true); } }