コード例 #1
0
 /**
  *
  * Converts Single itemList Entry into Array of Arrays if Not Already One
  *
  * @access protected
  * @return void
  */
 public function __construct($aItemListData, $iLocationId, $sActivaId, $iEntityId, $ismultishipto = false)
 {
     $this->_activa_id = $sActivaId;
     $this->_entity_id = $iEntityId;
     $this->_ismultishipto = $ismultishipto;
     $this->_discountExceptions = Netsuite_Db_Model::getExceptionItems('discount');
     $iCount = count(array_filter($aItemListData, 'is_array'));
     $this->_itemListArray = $iCount == count($aItemListData) ? $aItemListData : array($aItemListData);
     $this->_validate($iLocationId);
 }
コード例 #2
0
 /**
  * Set sources, department, location based on activa_source (as per George)
  * @return void
  */
 protected function _setSources()
 {
     $oDb = new Netsuite_Db_Model();
     $aSources = $oDb->getSources($this->_record['_source']);
     switch ($this->_record['recordtype']) {
         case 'customer':
             $this->_record['custentitycustomer_department'] = (int) $aSources['department'];
             $this->_record['custentity_customer_source'] = (int) $aSources['cust_source'];
             $this->_record['leadsource'] = (int) $aSources['lead'];
             break;
         case 'salesorder':
             $this->_record['custbody_order_source'] = (int) $aSources['order_source'];
             $this->_record['location'] = (int) $aSources['location'];
             $this->_record['department'] = (int) $aSources['department'];
             $this->_record['leadsource'] = (int) $aSources['lead'];
             $this->_record['ccprocessor'] = (int) $aSources['cc_processor'];
             break;
     }
 }
コード例 #3
0
function processOrders($bResetOrders = false)
{
    try {
        $processOrder = new Thread_Server();
        switch (true) {
            case $processOrder->hasOrders() === true:
                Netsuite_Db_Model::setPoolQueueLog(sizeof($processOrder->orders));
                $processOrder->poolOrders();
                processOrders(true);
                break;
            case $bResetOrders === true:
                //sleep(5);
                //Netsuite_Db_Model::resetStalledOrders();
                //processOrders( false );
                break;
        }
    } catch (Exception $e) {
        Netsuite_Db_Model::logError($e);
    }
}
コード例 #4
0
 public static function hasBeenProcessed(array $aNewOrders)
 {
     $oDb = new Netsuite_Db_Model();
     $aBeenProcessed = $oDb->hasBeenProcessed($aNewOrders);
     return $aBeenProcessed;
 }
コード例 #5
0
 protected function _logResults()
 {
     $sSystemError = '';
     $aResults = $this->worker->getData();
     $sIsSuccess = $aResults['customer']['success'] == true && $aResults['order']['success'] == true ? 'complete' : 'error';
     $sCustomerStatus = $aResults['customer']['success'] == true ? 'success' : 'fail';
     $sOrderStatus = $aResults['order']['success'] == true ? 'success' : 'fail';
     $sRefundStatus = $aResults['refund']['success'] == true ? 'success' : 'fail';
     switch (true) {
         case !empty($aResults['customer']['system']['error']):
             $sSystemError .= $aResults['customer']['system']['error'] . ' ';
         case !empty($aResults['order']['system']['error']):
             $sSystemError .= $aResults['order']['system']['error'];
             break;
     }
     $aUpdateData = array(':status' => $sIsSuccess, ':order_activa_id' => $this->_orderId, ':system_error' => $sSystemError, ':process_date' => date("Y-m-d H:i:s"), ':customer_status' => $sCustomerStatus, ':customer_id' => $aResults['customer']['netsuite']['record_id'], ':customer_warnings' => is_array($aResults['customer']['warn']) ? implode(',', $aResults['customer']['warn']) : $aResults['customer']['warn'], ':customer_errors' => $aResults['customer']['error'], ':customer_json' => $aResults['customer']['json'], ':order_status' => $sOrderStatus, ':order_id' => $aResults['order']['netsuite']['record_id'], ':order_warnings' => is_array($aResults['order']['warn']) ? implode(',', $aResults['order']['warn']) : $aResults['order']['warn'], ':order_errors' => $aResults['order']['error'], ':order_json' => $this->_maskCcNumber($aResults['order']['json']));
     $sOutcome = $sCustomerStatus == 'fail' || $sOrderStatus == 'fail' ? 'error' : 'complete';
     $model = new Netsuite_Db_Model();
     $activa = new Netsuite_Db_Activa();
     $model->updateOrderQueue($aResults['queue_id'], $sOutcome);
     $model->logProcess($aUpdateData);
     $activa->logProcess($aUpdateData);
     $activa = $model = null;
 }
コード例 #6
0
 /**
  * Set Current Batches Orders to a Status of Working
  *
  * @param array $aOrders - Array of Batched Orders
  * @access public
  * @return int|null $_dbResults
  * @throws Exception
  */
 public function setOrderWorking($aOrders)
 {
     try {
         $sth = $this->prepare(Netsuite_Db_Query::getQuery('SET_ACTIVA_ORDER_WORKING', null, count($aOrders)));
         if (!$sth) {
             throw new Exception(explode(',', $sth->errorInfo()));
         }
         $aBindArgs = array();
         array_walk($aOrders, function ($aOrder, $iKey) use(&$aBindArgs) {
             $aBindArgs[':arg' . $iKey] = (int) preg_replace("/[^0-9]/", "", $aOrder['order_activa_id']);
         });
         $sth->execute($aBindArgs);
         return true;
     } catch (Exception $e) {
         Netsuite_Db_Model::logError($e);
         throw new Exception('Could NOT Set Orders to Working Status in the Activa DB');
     }
 }
コード例 #7
0
 /**
  * Returns Orders From the Queue
  *
  *
  *
  */
 public function getProcessLogView()
 {
     try {
         $sth = $this->prepare(Panel_Query::getQuery('GET_PROCESS_LOG_VIEW'));
         $sth->bindValue(':limit', (int) PANEL_MAX_RESULTS, PDO::PARAM_INT);
         if (!$sth) {
             throw new Exception(explode(',', $sth->errorInfo()));
         }
         $sth->execute();
         $this->_dbResults = $sth->fetchAll(PDO::FETCH_ASSOC);
         return $this->_dbResults;
     } catch (Exception $e) {
         Netsuite_Db_Model::logError($e);
         throw new Exception('Could NOT Get Orders From the Queue DB for the Control Panel');
     }
 }