コード例 #1
0
ファイル: Door.php プロジェクト: jlm-entreprise/daily-bundle
 private function _header(ModelDoor $door)
 {
     $this->setFont('Arial', 'B', 18);
     $this->multicell(0, 12, $door->toString(), 1, 1, 'C', true);
     $this->ln(5);
     $this->setFont('Arial', 'B', 11);
     $this->setWidths(array(24, 34, 24, 8, 79, 79, 29));
     $this->row(array('Date', 'Contact', 'Type', 'Ctr', 'Raison', 'Rapport', 'Technicien'), 6, 1, true);
     $this->setFont('Arial', '', 10);
 }
コード例 #2
0
 public function hasRide(Door $door, Door $dest)
 {
     if (!isset($this->dests)) {
         $this->dests = array();
     }
     if (!isset($this->dests[$door->getId()])) {
         $this->dests[$door->getId()] = array();
         $qb = $this->createQueryBuilder('a')->select('b.id')->leftJoin('a.destination', 'b')->where('a.departure = ?1')->setParameter(1, $door);
         $dests = $qb->getQuery()->getArrayResult();
         foreach ($dests as $destid) {
             $this->dests[$door->getId()][] = $destid['id'];
         }
     }
     return in_array($dest->getId(), $this->dests[$door->getId()]);
 }
コード例 #3
0
 /**
  * Cherche les entretiens les plus proche d'une adresse
  *
  * @Template()
  */
 public function neighborAction(Door $door)
 {
     $em = $this->getDoctrine()->getManager();
     // Choper les entretiens à faire
     $repo = $em->getRepository('JLMDailyBundle:Maintenance');
     $maints = $repo->getOpened();
     $repo = $em->getRepository('JLMDailyBundle:Ride');
     $baseUrl = 'http://maps.googleapis.com/maps/api/distancematrix/json?sensor=false&language=fr-FR&origins=' . $door->getCoordinates() . '&destinations=';
     foreach ($maints as $maint) {
         $dest = $maint->getDoor();
         if (!$repo->hasRide($door, $dest)) {
             $url = $baseUrl . $dest->getCoordinates();
             $string = file_get_contents($url);
             $json = json_decode($string);
             if ($json->status == 'OK' && isset($json->rows[0]->elements[0]->duration->value) && isset($json->rows[0]->elements[0]->duration->value)) {
                 $ride = new Ride();
                 $ride->setDeparture($door);
                 $ride->setDestination($dest);
                 $ride->setDuration($json->rows[0]->elements[0]->duration->value);
                 $ride->setDistance($json->rows[0]->elements[0]->distance->value);
                 $em->persist($ride);
             }
         }
     }
     $em->flush();
     $entities = $repo->getMaintenanceNeighbor($door, 30);
     $forms = array();
     foreach ($entities as $entity) {
         $shift = new ShiftTechnician();
         $shift->setBegin(new \DateTime());
         $forms[] = $this->get('form.factory')->createNamed('shiftTechNew' . $entity->getDestination()->getNextMaintenance()->getId(), new AddTechnicianType(), $shift)->createView();
     }
     return array('door' => $door, 'entities' => $entities, 'forms_addTech' => $forms);
 }
コード例 #4
0
 /**
  * Deletes a Door entity.
  *
  * @Secure(roles="ROLE_USER")
  */
 public function deleteAction(Door $entity)
 {
     $form = $this->createDeleteForm($entity->getId());
     $request = $this->getRequest();
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->remove($entity);
         $em->flush();
     }
     return $this->redirect($this->generateUrl('door'));
 }
コード例 #5
0
 /**
  * 
  * @param Door $door
  * @return Ambigous <multitype:, \Doctrine\ORM\mixed, \Doctrine\ORM\Internal\Hydration\mixed, \Doctrine\DBAL\Driver\Statement, \Doctrine\Common\Cache\mixed>
  */
 public function getByDoor(Door $door)
 {
     $qb = $this->createQueryBuilder('a')->select('a')->leftJoin('a.door', 'b')->where('b.id = ?1')->orderBy('a.creation', 'desc')->setParameter(1, $door->getId());
     return $qb->getQuery()->getResult();
 }
コード例 #6
0
 /**
  * Unstop door
  *
  * @Template("JLMDailyBundle:Door:show.html.twig")
  * @Secure(roles="ROLE_USER")
  */
 public function unstopAction(Door $entity)
 {
     $em = $this->getDoctrine()->getManager();
     $stop = $entity->getLastStop();
     if ($stop === null) {
         return $this->showAction($entity);
     }
     $stop->setEnd(new \DateTime());
     $em->persist($stop);
     $em->flush();
     return $this->showAction($entity);
 }