Esempio n. 1
0
 /**
  * Calculate the current progress (what percentage done are we with this session?)
  * 
  * @param string $ticket
  * @return integer
  */
 protected function _calculateProgress($ticket)
 {
     if ($this->_driver->authCheck($ticket)) {
         $user = $this->_driver->authResolve($ticket);
         $current = $this->_driver->queueLeft($user);
         // Number of items currently in the queue
         $processed = $this->_driver->queueProcessed($ticket);
         // Number of items we've processed during this session
         $percentage = 100;
         if ($current) {
             $percentage = min(99, floor(100 * ($processed / ($processed + $current))));
         }
         // Call the percentage done hook
         $hookerr = null;
         $hookdata = array('user' => $user, 'percentage' => $percentage, 'items_left' => $current, 'items_processed' => $processed);
         $this->_callHook($ticket, QUICKBOOKS_HANDLERS_HOOK_PERCENT, null, null, null, null, $hookerr, null, array(), $hookdata);
         if ($current) {
             return $percentage;
         } else {
             return 100;
         }
     }
     return -1;
 }