Ejemplo n.º 1
0
 public function includeService(TechnicianService $service)
 {
     if (isset($this->user)) {
         $isTechnician = $service->getTechnician()->getUser()->getId() == $this->user->getId();
         $isSeller = $service->getSeller()->getId() == $this->user->getId();
         $technician = 0;
         $seller = 0;
         $transportation = 0;
         $details = array();
         foreach ($service->getDetails() as $detail) {
             $addService = false;
             if ($isTechnician && ($detail->getTechnicianWin() > 0 || $detail->getTransportationCost() > 0)) {
                 $technician += $detail->getTechnicianWin();
                 $transportation += $detail->getTransportationCost();
                 $addService = true;
             }
             if ($isSeller && $detail->getSellerWin() > 0) {
                 $seller += $detail->getSellerWin();
                 $addService = true;
             }
             if ($addService) {
                 $serv = array("id" => $detail->getId(), "name" => "" . $detail->getProductSaleType(), "saleDate" => date_format($detail->getTechnicianService()->getCreationDate(), "d/m/Y"), "serviceDate" => date_format($detail->getTechnicianService()->getScheduleDate(), "d/m/Y"), "seller" => $detail->getSellerWin(), "technician" => $detail->getTechnicianWin(), "transportation" => $detail->getTransportationCost());
                 array_push($details, $serv);
             }
         }
         $this->totalForSales += $seller;
         $this->totalForTechnicianService += $technician;
         $this->totalForTransportation += $transportation;
         $serviceData = array("id" => $service->getId(), "sale" => $seller, "technician" => $technician, "transportation" => $transportation, "details" => $details);
         array_push($this->listOfServices, $serviceData);
     } else {
         // Cannot add if the user is not defined
     }
 }
Ejemplo n.º 2
0
 private function generateTechService($client, $invoice, $call, $request)
 {
     $service = new TechnicianService();
     $service->setClient($client);
     $service->setInvoice($invoice);
     $service->setCall($call);
     $service->setState($request->get('state'));
     $service->setReferencePoint($request->get('referencePoint'));
     $service->setAddress($request->get('serviceAddress'));
     $service->setObservations($request->get('observations'));
     $service->setAddressDetail($request->get('addressDetail'));
     $service->setSecurityCode($request->get('securityCode'));
     $scheduleDate = $request->get('scheduleDate');
     if (isset($scheduleDate)) {
         $service->setScheduleDate(\DateTime::createFromFormat('d/m/Y', $scheduleDate));
     } else {
         $service->setScheduleDate(null);
     }
     $service->setHour($request->get('scheduleHour'));
     $this->em->persist($service);
 }