Ejemplo n.º 1
0
 public function startTicket(Ticket $ticket, User $user)
 {
     $this->om->startFlushSuite();
     $ticket->setLevel(1);
     $startStatus = $this->getStatusByType(Status::STATUS_MANDATORY_START);
     $now = new \DateTime();
     foreach ($startStatus as $status) {
         $intervention = new Intervention();
         $intervention->setTicket($ticket);
         $intervention->setUser($user);
         $intervention->setStatus($status);
         $intervention->setStartDate($now);
         $intervention->setEndDate($now);
         $intervention->setDuration(0);
         $this->persistIntervention($intervention);
         $ticket->setStatus($status);
     }
     $this->persistTicket($ticket);
     $this->om->endFlushSuite();
 }
 /**
  * @EXT\Route(
  *     "/admin/ticket/intervention/{intervention}/edit",
  *     name="formalibre_admin_ticket_intervention_edit",
  *     options={"expose"=true}
  * )
  * @EXT\ParamConverter("authenticatedUser", options={"authenticatedUser" = true})
  * @EXT\Template("FormaLibreSupportBundle:AdminSupport:adminTicketInterventionEditForm.html.twig")
  */
 public function adminTicketInterventionEditAction(Intervention $intervention)
 {
     $ticket = $intervention->getTicket();
     $form = $this->formFactory->create(new InterventionType($intervention->getUser()), $intervention);
     $form->handleRequest($this->request);
     $timeType = $form->get('computeTimeMode')->getData();
     $startDate = $intervention->getStartDate();
     if (!is_null($timeType) && !is_null($startDate)) {
         $startDateTimestamp = $startDate->format('U');
         if ($timeType === 0) {
             $endDate = $intervention->getEndDate();
             if (!is_null($endDate)) {
                 $endDateTimestamp = $endDate->format('U');
                 $duration = ceil(($endDateTimestamp - $startDateTimestamp) / 60);
                 $intervention->setDuration($duration);
             } else {
                 $form->addError(new FormError($this->translator->trans('end_date_is_required', array(), 'support')));
             }
         } elseif ($timeType === 1) {
             $duration = $intervention->getDuration();
             if (!is_null($duration)) {
                 $endDateTimestamp = $startDateTimestamp + $duration * 60;
                 $endDate = new \DateTime();
                 $endDate->setTimestamp($endDateTimestamp);
                 $intervention->setEndDate($endDate);
             } else {
                 $form->addError(new FormError($this->translator->trans('duration_is_required', array(), 'support')));
             }
         }
     }
     if ($form->isValid()) {
         $this->supportManager->persistIntervention($intervention);
         return new RedirectResponse($this->router->generate('formalibre_admin_ticket_open_interventions', array('ticket' => $ticket->getId())));
     } else {
         return array('form' => $form->createView(), 'intervention' => $intervention, 'ticket' => $ticket);
     }
 }