Exemplo n.º 1
0
 /**
  * 
  * @param type $period
  * @param type $idService
  * @param type $idClient
  * @param type $serviceSetId
  * @param type $serviceGroupId
  * @return Base_Db_Table_Row
  * @throws Exception
  */
 protected function _getCount($period, $idService = null, $idClient = null, $serviceSetId = null, $serviceGroupId = null)
 {
     $countModel = new WsServiceCounter();
     $select = $countModel->select()->from("ws.service_counter", array("sum(count_value)"));
     switch ($period) {
         case self::SC_DAILY:
         case self::SC_MONTHLY:
         case self::SC_YEARLY:
             $select->where("date_trunc('?', day) = date_trunc('?', current_date)", $period, $period);
             break;
         case self::SC_OVERALL:
             break;
         default:
             throw new Exception("Wrong period parameter!");
     }
     if (null !== $idService) {
         $select->where('ws_service_id=?', $idService);
     }
     if (null !== $idClient) {
         $select->where('ws_client_id=?', $idClient);
     }
     if (null !== $serviceSetId) {
         $select->where('ws_service_set_id=?', $serviceSetId);
     }
     if (null !== $serviceGroupId) {
         $select->where('ws_service_group_id=?', $serviceGroupId);
     }
     $countRow = $countModel->fetchAll($select)->current();
     if (null === $countRow) {
         return 0;
     }
     return $countModel->fetchRow($select)->sum;
 }
Exemplo n.º 2
0
 /**
  * Metoda inkrementuje wartości licznika wysłanych wiadomości
  * @param type $name Description
  * @throws Logic_Ws_Exception
  */
 protected function _incrementCounterToMany(array &$idRecipients, $wsServiceSetId = null)
 {
     $model = new WsServiceCounter();
     try {
         foreach ($idRecipients as $idRecipient) {
             $model->serviceCounterInc($idRecipient['sms_recipient_id'], $this->_serviceInstance->getServiceId(), Logic_Client::getInstance()->getClient()->id, Logic_Client::getInstance()->getCurrentServiceGroup()->id, intval($wsServiceSetId));
         }
     } catch (Exception $exc) {
         throw new Logic_Ws_Exception("Nie udało się inkrementować licznika wiadomości!", null, $exc);
     }
 }