Exemplo n.º 1
0
 public function requestAction()
 {
     $searchValue = $this->getRequest()->getParam('request_id');
     if (!empty($searchValue)) {
         $searchColumn = 'request_id';
         $searchValue = $searchValue;
     } else {
         $searchColumn = 'phone_number';
         $searchValue = $this->getPhoneNumber();
     }
     if (empty($searchValue)) {
         $status = 0;
         $results = array();
     } else {
         $status = 1;
         $limit = $this->getRequest()->getParam('limit');
         $results = Application_Model_General::getRequests($searchValue, $searchColumn, array(), array(), 'id DESC', $limit);
         if ($this->getRequest()->getParam('include_transactions')) {
             $filterStage = $this->getRequest()->getParam('transaction_filter_stage') ? $this->getRequest()->getParam('transaction_filter_stage') : null;
             $filterReject = $this->getRequest()->getParam('transaction_filter_reject') ? $this->getRequest()->getParam('transaction_filter_reject') : null;
             foreach ($results as &$result) {
                 $result['transactions'] = Application_Model_General::getTransactions($result['request_id'], $filterStage, $filterReject);
             }
         }
     }
     $output = array('status' => $status, 'results' => $results);
     $this->view->response = $this->encodeResponse($output);
 }
Exemplo n.º 2
0
 /**
  * Constructor
  * 
  * Checks if message is soap or not 
  * 
  * @param array $params
  * @return void 
  */
 public function __construct($params)
 {
     //check if this is a soap request
     if (is_object($params) && isset($params->NP_MESSAGE)) {
         $this->request = Np_Method::getInstance($params);
         $this->data = $params;
         if (!isset($this->data['PHONE_NUMBER'])) {
             $this->data['PHONE_NUMBER'] = Application_Model_General::getFieldFromRequests("phone_number", $params['REQUEST_ID']);
         }
     } else {
         if (is_array($params)) {
             // this is internal and not external (soap)
             if (isset($params['MANUAL']) && $params['MANUAL']) {
                 $fields = array('last_transaction', 'from_provider', 'to_provider');
                 $values = Application_Model_General::getFieldFromRequests($fields, $params['REQUEST_ID'], 'request_id');
                 if ($values['last_transaction'] != $params['MSG_TYPE'] && $values['last_transaction'] != $params['MSG_TYPE'] . '_response') {
                     $response = array('success' => 0, 'error' => 1, 'manual' => 1, 'desc' => 'The request is not at the right stage');
                     die(json_encode($response));
                 }
                 if (!isset($params['FROM']) || !isset($params['TO'])) {
                     $params['FROM'] = $values['to_provider'];
                     $params['TO'] = $values['from_provider'];
                 }
                 if (!isset($params['TRX_NO'])) {
                     $transaction = Application_Model_General::getTransactions($params['REQUEST_ID'], $params['MSG_TYPE']);
                     $params['TRX_NO'] = $transaction[0]['trx_no'];
                     $params['RETRY_DATE'] = Application_Model_General::getDateTimeIso($transaction[0]['last_transaction_time']);
                 }
                 $this->data = $params;
             } else {
                 if (is_array($params)) {
                     // we are receiving data => need to send to provider
                     if (!isset($params['REQUEST_ID']) && $params['MSG_TYPE'] != "Check" && isset($params['PHONE_NUMBER'])) {
                         //CALL FROM INTERNAL WITH NO REQUEST ID
                         //if the type is check the request id will be added later- on insert to DB
                         $params['REQUEST_ID'] = Application_Model_General::getFieldFromRequests("request_id", $params['PHONE_NUMBER']);
                     }
                     $this->data = $params;
                 } else {
                     //no parameters
                     $this->data = NULL;
                     $this->request = NULL;
                     return;
                 }
             }
             $this->request = Np_Method::getInstance($this->data);
         }
     }
 }
Exemplo n.º 3
0
 /**
  * send publish to specific provider
  * 
  * @param array $request 
  * @return void
  */
 public function executePublish($request)
 {
     $params = Application_Model_General::getParamsArray($request);
     // let's check if it's port (means we have execute response before)
     $execute_exists = Application_Model_General::getTransactions($request['request_id'], 'Execute_response', 'null');
     if (empty($execute_exists) || !is_array($execute_exists) || !count($execute_exists)) {
         $publish_type = "Rtrn";
     } else {
         $publish_type = "Port";
     }
     $params['PROCESS_TYPE'] = "PORT";
     $params['MSG_TYPE'] = "Publish";
     $params['FROM'] = Application_Model_General::getSettings('InternalProvider');
     $params['DONOR'] = $params['FROM_PROVIDER'];
     //$row['DONOR'] = $provider;
     $params['PUBLISH_TYPE'] = $publish_type;
     $params["RETRY_DATE"] = Application_Model_General::getDateTimeIso();
     $params["RETRY_NO"] = $this->get_retry_no($params);
     $params["VERSION_NO"] = Application_Model_General::getSettings("VersionNo");
     $reqModel = new Application_Model_Request($params);
     // make sure the request is ok.
     // can use $reqModel->RequestValidate() but maybe there is no need becuse i'm building it
     // TODO.oc666: why we execute from internal?
     $reqModel->ExecuteFromInternal();
     //what with the ack in the DB - status 1 for each?
 }