Esempio n. 1
0
 public function getGantt(Etude $etude, $type)
 {
     // Chart
     $series = array();
     $data = array();
     $cats = array();
     $naissance = new \DateTime();
     $mort = new \DateTime();
     //Contacts Client
     if ($etude->getClientContacts()->count() != 0 && $type == 'suivi') {
         foreach ($etude->getClientContacts() as $contact) {
             $date = $contact->getDate();
             if ($naissance >= $date) {
                 $naissance = clone $date;
             }
             if ($mort <= $date) {
                 $mort = clone $date;
             }
             $data[] = array('x' => count($cats), 'y' => $date->getTimestamp() * 1000, 'titre' => $contact->getObjet(), 'detail' => 'fait par ' . $contact->getFaitPar()->getPrenomNom() . ' le ' . $date->format('d/m/Y'));
         }
         $series[] = array('type' => 'scatter', 'data' => $data);
         $cats[] = 'Contact client';
     }
     //Documents
     if ($type == 'suivi') {
         $data = array();
         $count_cats = count($cats);
         for ($j = 0; $j < $count_cats; ++$j) {
             $data[] = array();
         }
         $dataSauv = $data;
         if ($etude->getAp() && $etude->getAp()->getDateSignature()) {
             $date = $etude->getAp()->getDateSignature();
             if ($naissance >= $date) {
                 $naissance = clone $date;
             }
             if ($mort <= $date) {
                 $mort = clone $date;
             }
             $data[] = array('x' => count($cats), 'y' => $date->getTimestamp() * 1000, 'titre' => 'Avant-Projet', 'detail' => 'signé le ' . $date->format('d/m/Y'));
             $series[] = array('type' => 'scatter', 'data' => $data, 'marker' => array('symbol' => 'square', 'fillColor' => 'blue'));
             $naissance = clone $etude->getAp()->getDateSignature();
         }
         $data = $dataSauv;
         if ($etude->getCc() && $etude->getCc()->getDateSignature()) {
             $date = $etude->getCc()->getDateSignature();
             if ($naissance >= $date) {
                 $naissance = clone $date;
             }
             if ($mort <= $date) {
                 $mort = clone $date;
             }
             $data[] = array('x' => count($cats), 'y' => $date->getTimestamp() * 1000, 'titre' => 'Convention Client', 'detail' => 'signé le ' . $date->format('d/m/Y'));
             $series[] = array('type' => 'scatter', 'data' => $data, 'marker' => array('symbol' => 'triangle', 'fillColor' => 'red'));
         }
         $data = $dataSauv;
         if ($etude->getPvr() && $etude->getPvr()->getDateSignature()) {
             $date = $etude->getPvr()->getDateSignature();
             if ($naissance >= $date) {
                 $naissance = clone $date;
             }
             if ($mort <= $date) {
                 $mort = clone $date;
             }
             $data[] = array('x' => count($cats), 'y' => $date->getTimestamp() * 1000, 'name' => 'Procès Verbal de Recette', 'detail' => 'signé le ' . $date->format('d/m/Y'));
             $series[] = array('type' => 'scatter', 'data' => $data, 'marker' => array('symbol' => 'circle'));
         }
         $cats[] = 'Documents';
     }
     //Etude
     if ($type == 'suivi') {
         $data = array();
         $count_cats = count($cats);
         for ($j = 0; $j < $count_cats; ++$j) {
             $data[] = array();
         }
         if ($etude->getDateLancement() && $etude->getDateFin(true)) {
             $debut = $etude->getDateLancement();
             $fin = $etude->getDateFin(true);
             $data[] = array('low' => $debut->getTimestamp() * 1000, 'y' => $fin->getTimestamp() * 1000, 'color' => '#005CA4', 'titre' => 'Durée de déroulement des phases', 'detail' => 'du ' . $debut->format('d/m/Y') . ' au ' . $fin->format('d/m/Y'));
             $cats[] = 'Etude';
         }
     }
     foreach ($etude->getPhases() as $phase) {
         if ($phase->getDateDebut() && $phase->getDelai()) {
             $debut = $phase->getDateDebut();
             if ($naissance >= $debut) {
                 $naissance = clone $debut;
             }
             $fin = clone $debut;
             $fin->add(new \DateInterval('P' . $phase->getDelai() . 'D'));
             if ($mort <= $fin) {
                 $mort = clone $fin;
             }
             $func = new Expr('function() {return this.point.titre;}');
             $data[] = array('low' => $fin->getTimestamp() * 1000, 'y' => $debut->getTimestamp() * 1000, 'titre' => $phase->getTitre(), 'detail' => 'du ' . $debut->format('d/m/Y') . ' au ' . $fin->format('d/m/Y'), 'color' => '#F26729', 'dataLabels' => array('enabled' => true, 'align' => 'left', 'inside' => true, 'verticalAlign' => 'bottom', 'formatter' => $func, 'y' => -5));
         } else {
             $data[] = array();
         }
         $cats[] = 'Phase n°' . ($phase->getPosition() + 1);
     }
     $series[] = array('type' => 'bar', 'data' => $data);
     //Today, à faire à la fin
     $data = array();
     if ($type == 'suivi') {
         $now = new \DateTime('NOW');
         $data[] = array('x' => 0, 'y' => $now->getTimestamp() * 1000, 'titre' => "aujourd'hui", 'detail' => 'le ' . $now->format('d/m/Y'));
         $data[] = array('x' => count($cats) - 1, 'y' => $now->getTimestamp() * 1000, 'titre' => "aujourd'hui", 'detail' => 'le ' . $now->format('d/m/Y'));
         $series[] = array('type' => 'spline', 'data' => $data, 'marker' => array('radius' => 1, 'color' => '#545454'), 'color' => '#545454', 'lineWidth' => 1, 'pointWidth' => 5);
     }
     $ob = $this->ganttChartFactory($series, $cats);
     $ob->yAxis->min($naissance->sub(new \DateInterval('P1D'))->getTimestamp() * 1000);
     $ob->yAxis->max($mort->add(new \DateInterval('P1D'))->getTimestamp() * 1000);
     return $ob;
 }