Ejemplo n.º 1
0
 public function PostValidate()
 {
     $this->setAck($this->validateParams($this->getHeaders()));
     //first step is GEN
     if (!$this->checkDirection()) {
         return "Gen04";
     }
     //HOW TO CHECK Gen05
     //		if (!$this->ValidateDB()) {
     //			return "Gen07";
     //		}
     if (($timer_ack = Np_Timers::validate($this)) !== TRUE) {
         return $timer_ack;
     }
     $tbl = new Application_Model_DbTable_Requests(Np_Db::master());
     $updateArray = array('last_transaction' => $this->getHeaderField("MSG_TYPE"));
     // if we received success return_response and we are not the initiator we need to publish it after (so leave it with status on)
     if ($this->getHeaderField("TO") == Application_Model_General::getSettings('InternalProvider')) {
         $updateArray['status'] = 0;
     } else {
         $updateArray['status'] = 1;
     }
     $whereArray = array('request_id =?' => $this->getHeaderField("REQUEST_ID"));
     if (!$tbl->update($updateArray, $whereArray)) {
         return false;
     }
     return true;
 }
Ejemplo n.º 2
0
 /**
  * overridden from np_method , updates requests table row by 
  * request_id  and last transaction msg_type
  * 
  * 
  * @return int number of affected rows
  */
 public function saveToDB()
 {
     $updateArray = array('last_transaction' => $this->getHeaderField("MSG_TYPE"));
     $whereArray = array('request_id =?' => $this->getHeaderField("REQUEST_ID"));
     $tbl = new Application_Model_DbTable_Requests(Np_Db::master());
     return $tbl->update($updateArray, $whereArray);
 }
Ejemplo n.º 3
0
 /**
  * extended function from parent Np_Method
  * checks if db object exists and last transaction is Cancel
  * 
  * @return bool 
  */
 public function saveToDB()
 {
     if ($this->checkApprove() === TRUE) {
         $updateArray = array('status' => 0, 'last_transaction' => $this->getHeaderField("MSG_TYPE"));
         $whereArray = array('request_id =?' => $this->getHeaderField("REQUEST_ID"));
         $tbl = new Application_Model_DbTable_Requests(Np_Db::master());
         return $tbl->update($updateArray, $whereArray);
     }
     return FALSE;
 }
Ejemplo n.º 4
0
 public function saveToDB()
 {
     if ($this->getHeaderField("TRX_NO")) {
         //this is a request from provider!
         //save a new row in Requests DB
         $tbl = new Application_Model_DbTable_Requests(Np_Db::master());
         $data = array('status' => 1, 'request_id' => $this->getHeaderField("REQUEST_ID"), 'phone_number' => $this->getBodyField("NUMBER"), 'from_provider' => $this->getHeaderField("TO"), 'to_provider' => $this->getHeaderField("FROM"), 'last_transaction' => $this->getHeaderField("MSG_TYPE"));
         return $tbl->insert($data);
     }
     //else //this request is from cron! internal is sending to all providers
     //don't save in Requests DB
 }
Ejemplo n.º 5
0
 public function getRequestIdByNumber($number)
 {
     $tbl = new Application_Model_DbTable_Requests(Np_Db::slave());
     $select = $tbl->select();
     $select->where('number =?', $number)->order('id DESC');
     $result = $select->query()->fetchObject();
     //take the last one
     if ($result) {
         return $result->request_id;
     }
     return FALSE;
 }
Ejemplo n.º 6
0
 /**
  * overridden function from parent Np_Method
  * 
  * inserts row to requests table
  * 
  * @return bool 
  */
 public function saveToDB()
 {
     //INSERT into Requests
     if ($this->getHeaderField("TO") == Application_Model_General::getSettings('InternalProvider')) {
         // if the check received from external provider create request
         // request id already exists
         //else - it's from internal - already INSERT into Requests
         $data = array('request_id' => $this->getHeaderField("REQUEST_ID"), 'from_provider' => $this->getHeaderField("FROM"), 'to_provider' => $this->getHeaderField("TO"), 'status' => 1, 'last_transaction' => $this->getHeaderField("MSG_TYPE"), 'phone_number' => $this->getBodyField("NUMBER"));
         $tbl = new Application_Model_DbTable_Requests(Np_Db::master());
         return $tbl->insert($data);
     }
 }
Ejemplo n.º 7
0
 protected function checkApprove()
 {
     // reset request id if check response not succeed
     if (!parent::checkApprove()) {
         $updateArray = array('status' => 0);
         $whereArray = array('request_id =?' => $this->getHeaderField("REQUEST_ID"));
         $tbl = new Application_Model_DbTable_Requests(Np_Db::master());
         $tbl->update($updateArray, $whereArray);
         return false;
     }
     return true;
 }
Ejemplo n.º 8
0
 public function saveToDB()
 {
     //		if ($this->checkApprove() === FALSE) {
     //			return FALSE;
     //		}
     //        $transfer_time = $this->getBodyField("PORT_TIME");
     $msg_type = $this->getHeaderField("MSG_TYPE");
     $updateArray = array('status' => 1, 'last_transaction' => $msg_type);
     $whereArray = array('request_id =?' => $this->getHeaderField("REQUEST_ID"));
     $tbl = new Application_Model_DbTable_Requests(Np_Db::master());
     $ret = $tbl->update($updateArray, $whereArray);
     return $ret;
 }
Ejemplo n.º 9
0
 /**
  * overridden from parent
  * 
  * update status,last_transaction and transfer_time in requests table by 
  * request_id
  * 
  * @return bool
  */
 public function saveToDB()
 {
     if ($this->checkApprove() === FALSE) {
         return FALSE;
     }
     $trxno = $this->getBodyField("REQUEST_TRX_NO");
     $msg_type = $this->getHeaderField("MSG_TYPE");
     $updateArray = array('status' => 1, 'last_transaction' => $msg_type, 'transfer_time' => application_model_general::getTrxPortTime($trxno));
     $whereArray = array('request_id =?' => $this->getHeaderField("REQUEST_ID"));
     $tbl = new Application_Model_DbTable_Requests(Np_Db::master());
     $ret = $tbl->update($updateArray, $whereArray);
     return $ret;
 }
Ejemplo n.º 10
0
 /**
  * overridden from parent Np_Method
  * updates status and last transaction in requests table 
  * where request_id 
  * 
  * 
  * @return bool 
  */
 public function saveToDB()
 {
     if ($this->getHeaderField("FROM") == Application_Model_General::getSettings('InternalProvider')) {
         try {
             //send request response from internal to provider - update DB
             $tbl = new Application_Model_DbTable_Requests(Np_Db::master());
             $updateArray = array('status' => 0, 'last_transaction' => $this->getHeaderField("MSG_TYPE"));
             $whereArray = array('request_id =?' => $this->getHeaderField("REQUEST_ID"));
             return $tbl->update($updateArray, $whereArray);
         } catch (Exception $e) {
             error_log("Error on update record in requests table: " . $e->getMessage());
         }
     }
     //else //cron will take care of it. save only in transaction
 }
Ejemplo n.º 11
0
 public function saveToDB()
 {
     if (parent::saveToDB()) {
         //this is a request from provider!
         //save a new row in Requests DB
         $flags = new stdClass();
         $flags->inquire = $this->getBodyField("CURRENT_OPERATOR");
         $data = array('last_transaction' => $this->getHeaderField("MSG_TYPE"), 'status' => 0, 'flags' => json_encode($flags));
         $whereArray = array('request_id =?' => $this->getHeaderField("REQUEST_ID"));
         $tbl = new Application_Model_DbTable_Requests(Np_Db::master());
         $ret = $tbl->update($data, $whereArray);
         return $ret;
     }
     return false;
     //else //this request is from cron! internal is sending to all providers
     //don't save in Requests DB
 }
Ejemplo n.º 12
0
 public function updateGoodPublish($reqId, $provider)
 {
     $tbl = new Application_Model_DbTable_Requests(Np_Db::master());
     $where[] = "request_id ='" . $reqId . "' AND from_provider='" . $provider . "'";
     $res = $tbl->update(array('last_transaction' => 'Publish_response'), $where);
     return $res;
 }
Ejemplo n.º 13
0
 /**
  * method triggered after internal response to NPG
  * 
  * @param object $internalResponseObject
  */
 public function postInternalRequest($internalResponseObject)
 {
     if ($this->getHeaderField("TO") == Application_Model_General::getSettings('InternalProvider')) {
         if (isset($internalResponseObject->connect_time)) {
             $connect_time = $internalResponseObject->connect_time;
         } else {
             $connect_time = time();
         }
         $updateArray = array('connect_time' => Application_Model_General::getDateTimeInSqlFormat($connect_time));
         $whereArray = array('request_id =?' => $this->getHeaderField("REQUEST_ID"));
         $tbl = new Application_Model_DbTable_Requests(Np_Db::master());
         return $tbl->update($updateArray, $whereArray);
     }
     return true;
 }
Ejemplo n.º 14
0
 /**
  *
  * @return String transfer date of autocheck if it's autocheck else false
  */
 protected function isAutoCheck()
 {
     $tbl = new Application_Model_DbTable_Requests(Np_Db::slave());
     $select = $tbl->select()->where('request_id=?', $this->params['REQUEST_ID'])->order('id DESC');
     $result = $select->query()->fetchObject();
     if ($result && $result->auto_check) {
         return Application_Model_General::getDateTimeInTimeStamp($result->transfer_time);
     }
     return false;
 }
Ejemplo n.º 15
0
 /**
  * overridden function from parent Np_Method
  * 
  * inserts row to requests table
  * 
  * @return bool 
  */
 public function saveToDB()
 {
     if ($this->ValidateDB() === FALSE) {
         return FALSE;
     }
     if ($this->getHeaderField("FROM") != Application_Model_General::getSettings('InternalProvider')) {
         // if the check received from external provider create request
         // request id already exists
         //else - it's from internal - already INSERT into Requests
         try {
             $data = array('request_id' => $this->getHeaderField("REQUEST_ID"), 'from_provider' => $this->getHeaderField("TO"), 'to_provider' => $this->getHeaderField("FROM"), 'status' => 1, 'last_transaction' => $this->getHeaderField("MSG_TYPE"), 'phone_number' => $this->getBodyField("NUMBER"));
             $tbl = new Application_Model_DbTable_Requests(Np_Db::master());
             return $tbl->insert($data);
         } catch (Exception $e) {
             error_log("Error on create record in transactions table: " . $e->getMessage());
         }
     }
 }
Ejemplo n.º 16
0
 /**
  * overridden from parent
  * 
  * inserts row to database
  * 
  * @return type 
  */
 public function saveToDB()
 {
     //this is a request from provider!
     //save a new row in Requests DB
     if ($this->getHeaderField("FROM") != Application_Model_General::getSettings('InternalProvider')) {
         try {
             $flags = new stdClass();
             $flags->publish_type = $this->getBodyField("PUBLISH_TYPE");
             $tbl = new Application_Model_DbTable_Requests(Np_Db::master());
             $data = array('request_id' => $this->getHeaderField("REQUEST_ID"), 'from_provider' => $this->getHeaderField("TO"), 'to_provider' => $this->getHeaderField("FROM"), 'status' => 1, 'last_transaction' => $this->getHeaderField("MSG_TYPE"), 'phone_number' => $this->getBodyField("NUMBER"), 'disconnect_time' => Application_Model_General::getDateTimeInSqlFormat($this->getBodyField("DISCONNECT_TIME")), 'connect_time' => Application_Model_General::getDateTimeInSqlFormat($this->getBodyField("CONNECT_TIME")), 'transfer_time' => Application_Model_General::getDateTimeInSqlFormat(), 'flags' => json_encode($flags));
             return $tbl->insert($data);
         } catch (Exception $e) {
             error_log("Error on create record in transactions table: " . $e->getMessage());
         }
     }
     return TRUE;
 }
Ejemplo n.º 17
0
 /**
  * check if we sent check already
  * 
  * @param long $phone_number phone number to check
  * 
  * @return true if we sent already check
  */
 public static function previousCheck($phone_number)
 {
     $tbl = new Application_Model_DbTable_Requests(Np_Db::slave());
     $select = $tbl->select()->where('phone_number=?', $phone_number)->where('status=?', "1")->order('id DESC');
     $result = $select->query()->fetch();
     if (!empty($result) && $result !== FALSE) {
         return false;
     }
     return true;
 }