src/Entity/Slave/TicketSuspension.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Slave;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use App\Service\TicketService;
  8. /**
  9.  * @ORM\Table(name="eposm_s_ticket_suspension")
  10.  * @ORM\Entity(repositoryClass="App\Repository\Slave\TicketSuspensionRepository")
  11.  */
  12. class TicketSuspension
  13. {    
  14.     public function displaySuspensionTable(){
  15.         $html '<table class="table table-sm m_b_none responsive_font_size"><tr><th class="td_w_50p"></th><th class="txt_a_c">Data</th><th class="td_w_150p">Ora</th></tr><tr><th class="txt_a_r">Dal</th><td class="txt_a_c">'.$this->getDatetimeFrom()->format('d-m-Y').'</td><td>'.$this->getDatetimeFrom()->format('H:i').'</td></tr><tr><th class="txt_a_r">Al</th><td class="txt_a_c">';
  16.         if($this->getDatetimeTo() != null)
  17.             $html.= $this->getDatetimeTo()->format('d-m-Y').'</td><td>'.$this->getDatetimeTo()->format('H:i');
  18.         else
  19.             $html.= '---</td><td>---';
  20.         $html.= '</td></tr></table>';
  21.         return $html;
  22.     }
  23.     public function unlock($unlockCausal$unlockDatetime$em){
  24.         if($unlockDatetime == null)
  25.             $unlockDatetime = new \DateTime();
  26.         // NON POSSO SBLOCCARE PRIMA DELLA DATA DI INIZIO SOSPENSIONE
  27.         if($unlockDatetime->format("YmdHis") < $this->datetimeFrom->format("YmdHis"))
  28.             $unlockDatetime $this->datetimeFrom;
  29.         $this->datetimeTo $unlockDatetime;
  30.         
  31.         $settingUnlockSameTech $em->getRepository('App\Entity\Slave\Setting')->findOneBy(array('slug' => 'ticket_suspension_unlock_same_technician'));
  32.         $statusAssigned $em->getRepository('App\Entity\Slave\TicketStatus')->findOneBySlug('assigned');
  33.         $statusToAssign $em->getRepository('App\Entity\Slave\TicketStatus')->findOneBySlug('to_assign');
  34.         // SE IMPOSTAZIONE SBLOCCA SU STESSO TECNICO ATTIVA, ESISTE UN TECNICO, E' ATTIVO L'ACCOUNT E NON E' IN FERIE -> STATO ASSEGNATO
  35.         // ALTRIMENTI -> STATO DA ASSEGNARE E TOLGO TECNICO DA TICKET
  36.         if($settingUnlockSameTech->getValue() && $this->getTicket()->getTechnician() != null && $this->getTicket()->getTechnician()->isCompanyActive() && $this->getTicket()->getTechnician()->getActualHoliday() == false){
  37.             TicketService::createTicketLog($em$this->getUser(), $this->getTicket(), "cs"$this->getTicket()->getStatus(), $statusAssigned->getValue());
  38.             $this->getTicket()->setStatus($statusAssigned);
  39.         }
  40.         else{
  41.             TicketService::createTicketLog($em$this->getUser(), $this->getTicket(), "cs"$this->getTicket()->getStatus(), $statusToAssign->getValue());
  42.             $this->getTicket()->setStatus($statusToAssign);
  43.             TicketService::createTicketLog($em$this->getUser(), $this->getTicket(), "ct"$this->getTicket()->getTechnician(), null);
  44.             $this->getTicket()->setTechnician(null);
  45.         }
  46.         $this->setUnlockCausal($unlockCausal);
  47.         $this->setUnlocked(1);
  48.     }
  49.     /**
  50.      * @ORM\Column(name="id", type="bigint")
  51.      * @ORM\Id
  52.      * @ORM\GeneratedValue(strategy="AUTO")
  53.      */
  54.     protected $id;
  55.     /**
  56.      * @ORM\Column(name="datetime_from", type="datetime")
  57.      */
  58.     protected $datetimeFrom;
  59.     /**
  60.      * @ORM\Column(name="datetime_to", type="datetime", nullable=true)
  61.      */
  62.     protected $datetimeTo;
  63.     
  64.     /**
  65.      * @ORM\Column(name="is_approved", type="boolean", nullable=true)
  66.      */
  67.     protected $approved;
  68.     
  69.     /**
  70.      * @ORM\Column(name="is_managed", type="boolean")
  71.      */
  72.     protected $managed false;
  73.     
  74.     /**
  75.      * @ORM\Column(name="is_unlocked", type="boolean")
  76.      */
  77.     protected $unlocked false;
  78.     
  79.     /**
  80.      * @ORM\Column(name="unlock_causal", type="text", nullable=true)
  81.      */
  82.     protected $unlockCausal;
  83.     
  84.     /**
  85.      * @ORM\Column(name="refuse_motivation", type="text", nullable=true)
  86.      */
  87.     protected $refuseMotivation;
  88.     // OneToOne
  89.         /**
  90.          * @ORM\OneToOne(targetEntity="App\Entity\Slave\Intervention", inversedBy="suspension")
  91.          * @ORM\JoinColumn(name="intervention_id", referencedColumnName="id")
  92.          */
  93.         private $intervention;
  94.     //
  95.     // ManyToOne
  96.         /**
  97.          * @ORM\ManyToOne(targetEntity="App\Entity\Slave\Ticket", inversedBy="suspensions")
  98.          * @ORM\JoinColumn(name="ticket_id", referencedColumnName="id")
  99.          */
  100.         private $ticket;
  101.         public function getId(): ?string
  102.         {
  103.             return $this->id;
  104.         }
  105.         public function getDatetimeFrom(): ?\DateTimeInterface
  106.         {
  107.             return $this->datetimeFrom;
  108.         }
  109.         public function setDatetimeFrom(\DateTimeInterface $datetimeFrom): static
  110.         {
  111.             $this->datetimeFrom $datetimeFrom;
  112.             return $this;
  113.         }
  114.         public function getDatetimeTo(): ?\DateTimeInterface
  115.         {
  116.             return $this->datetimeTo;
  117.         }
  118.         public function setDatetimeTo(?\DateTimeInterface $datetimeTo): static
  119.         {
  120.             $this->datetimeTo $datetimeTo;
  121.             return $this;
  122.         }
  123.         public function isApproved(): ?bool
  124.         {
  125.             return $this->approved;
  126.         }
  127.         public function setApproved(?bool $approved): static
  128.         {
  129.             $this->approved $approved;
  130.             return $this;
  131.         }
  132.         public function isManaged(): ?bool
  133.         {
  134.             return $this->managed;
  135.         }
  136.         public function setManaged(bool $managed): static
  137.         {
  138.             $this->managed $managed;
  139.             return $this;
  140.         }
  141.         public function getUnlockCausal(): ?string
  142.         {
  143.             return $this->unlockCausal;
  144.         }
  145.         public function setUnlockCausal(?string $unlockCausal): static
  146.         {
  147.             $this->unlockCausal $unlockCausal;
  148.             return $this;
  149.         }
  150.         public function getRefuseMotivation(): ?string
  151.         {
  152.             return $this->refuseMotivation;
  153.         }
  154.         public function setRefuseMotivation(?string $refuseMotivation): static
  155.         {
  156.             $this->refuseMotivation $refuseMotivation;
  157.             return $this;
  158.         }
  159.         public function getIntervention(): ?Intervention
  160.         {
  161.             return $this->intervention;
  162.         }
  163.         public function setIntervention(?Intervention $intervention): static
  164.         {
  165.             $this->intervention $intervention;
  166.             return $this;
  167.         }
  168.         public function getTicket(): ?Ticket
  169.         {
  170.             return $this->ticket;
  171.         }
  172.         public function setTicket(?Ticket $ticket): static
  173.         {
  174.             $this->ticket $ticket;
  175.             return $this;
  176.         }
  177.     public function isUnlocked(): ?bool
  178.     {
  179.         return $this->unlocked;
  180.     }
  181.     public function setUnlocked(bool $unlocked): static
  182.     {
  183.         $this->unlocked $unlocked;
  184.         return $this;
  185.     }
  186. }