Exemple #1
0
 protected function sendYourTurn()
 {
     if ($this->getSource() != 'app') {
         return;
     }
     /*
      * Hack: cannot pass $this to closures.
      * They are objects and define their
      * own $this.
      */
     $ref = $this;
     $call = function () use($ref) {
         $sender = new AppPushSender($ref->getSourceId());
         $sender->sendYourTurn($ref);
     };
     $jobs = JobQueue::getInstance();
     $jobs->addJob($call);
 }
Exemple #2
0
 public static function newFromTicket($ticket, $ts_time_out = null)
 {
     if (!$ts_time_out) {
         $ts_time_out = time();
     }
     $ret = self::newRecord();
     $ret->setCode($ticket->getCode());
     $ret->setTimeIn($ticket->getTimeIn());
     $ret->setSource($ticket->getSource());
     if ($ticket->getTable() == 'ticket_in') {
         $ret->setTimeExec(null);
         $ret->setIsTrash(false);
         $ret->setTimeOut($ts_time_out);
     } else {
         global $gvTrashThreshold, $gvSessionTimeout;
         $ret->setOpCode($ticket->getOpCode());
         $ret->setDeskNumber($ticket->getDeskNumber());
         $ret->setTimeExec($ticket->getTimeExec());
         if ($ts_time_out - $ticket->getTimeExec() > $gvSessionTimeout) {
             // Never set exec duration beyond sessionTimeout
             $ts_time_out = $ticket->getTimeExec() + $gvSessionTimeout;
         }
         $ret->setTimeOut($ts_time_out);
         if (in_array($ret->ts_source, array('app', 'web')) && $ret->ts_time_out - $ret->ts_time_exec < $gvTrashThreshold) {
             // This ticket is trash
             $ret->setIsTrash(true);
             Ban::recordTicketTrash($ticket);
             // Send trash notice (only for app)
             if ($ticket->getSource() == 'app') {
                 $call = function () use($ticket) {
                     $sender = new AppPushSender($ticket->getSourceId());
                     $sender->sendTrashNotice();
                 };
                 $jobs = JobQueue::getInstance();
                 $jobs->addJob($call);
             }
         }
     }
     return $ret;
 }