public function addDiscount($sDiscountId)
 {
     $oModel = new LivePos_Db_Model();
     $aDiscount = $oModel->getDiscounts(array($sDiscountId));
     $oModel = null;
     $discount = LivePos_Maps_MapFactory::create('discount', $aDiscount);
     $this->_discountList[$iDiscountId] = $discount;
 }
 private function _logReceipt()
 {
     foreach ($this->_pool->workers as $worker) {
         $aResults = $worker->getData();
         $aReceipts[] = array(':receipt_id' => $aResults['receiptId'], ':receipt_type' => $aResults['receiptType'], ':response_code' => $aResults['code'], ':receipt_string' => $aResults['data'], ':location_id' => $aResults['locationId'], ':transaction_date' => $this->_transactionDate, ':error_message' => $aResults['error']);
     }
     $model = new LivePos_Db_Model();
     $model->insertReceipts($aReceipts);
     $model = null;
 }
 public function run()
 {
     spl_autoload_register(function ($sClass) {
         $sClass = str_replace("_", "/", $sClass);
         include $sClass . '.php';
     });
     try {
         $this->worker->addData(array('receiptId' => $this->_receiptId));
         $this->worker->addData(array('locationId' => $this->_locationId));
         $call = new LivePos_Job_GetRecord(false);
         $call->sendRequest('GetReceiptDetails', $this->_sessionId, array('intReceiptNumber' => $this->_receiptId));
         if ($call->isOk()) {
             $aResponse = $call->getResponse();
             $this->_getReceiptType($aResponse);
             $this->worker->addData(array('code' => $aResponse['code']));
             $this->worker->addData(array('data' => $aResponse['data']));
         } else {
             $aResponse = $call->getResponse();
             $this->worker->addData(array('code' => $aResponse['code']));
             $this->worker->addData(array('data' => $aResponse['data']));
             $this->worker->addData(array('error' => implode(',', $call->getErrors())));
         }
     } catch (Exception $e) {
         LivePos_Db_Model::logError($e->getMessage());
         $this->worker->addData(array('receiptId' => $this->_receiptId));
         $this->worker->addData(array('code' => $aResponse['code']));
         $this->worker->addData(array('data' => $call->getResponse()));
         $this->worker->addData(array('error' => $e->getMessage()));
     }
 }
 public function run()
 {
     spl_autoload_register(function ($sClass) {
         $sClass = str_replace("_", "/", $sClass);
         include $sClass . '.php';
     });
     try {
         $call = new LivePos_Job_GetRecord(false);
         $call->sendRequest('GetProductDetails', $this->_sessionId, array('strProductSKU' => $this->_productId));
         if ($call->isOk()) {
             $aResponse = $call->getResponse();
             $product = LivePos_Maps_MapFactory::create('product', json_decode($aResponse['data'], true));
             $this->worker->addData(array('code' => $aResponse['code']));
             $this->worker->addData(array('product' => $product->getPublicVars()));
             $this->worker->addData(array('error' => implode(',', $this->_errors)));
         } else {
             $aResponse = $call->getResponse();
             $this->worker->addData(array('productId' => $this->_productId));
             $this->worker->addData(array('code' => $aResponse['code']));
             $this->worker->addData(array('error' => implode(',', $call->getErrors())));
         }
     } catch (Exception $e) {
         LivePos_Db_Model::logError($e->getMessage());
         $this->worker->addData(array('productId' => $this->_productId));
         $this->_errors[] = $e->getMessage();
         $this->worker->addData(array('error' => implode(',', $this->_errors)));
     }
 }
 private function _logProductInventory()
 {
     $hasResults = false;
     foreach ($this->_pool->workers as $worker) {
         $aResults = $worker->getData();
         if (isset($aResults['product'])) {
             $aProducts[] = array(':product_id' => $aResults['product']['productid'], ':product_price' => $aResults['product']['productprice'] != null ? $aResults['product']['productprice'] : 0.0, ':product_sku' => $aResults['product']['productsku'], ':product_description' => $aResults['product']['description']);
             $hasResults = true;
         } else {
             #############################
             ###  ADD ERROR LOGIC HERE
             var_dump($aResults);
         }
     }
     if ($hasResults == true) {
         $model = new LivePos_Db_Model();
         $model->insertProducts($aProducts);
         $model = null;
     }
 }
Ejemplo n.º 6
0
 private function _getDiscountedItems()
 {
     $model = new LivePos_Db_Model();
     $this->_discounteditems = $model->getDiscountedItems($this->getId());
     $model = null;
 }
 public function run()
 {
     spl_autoload_register(function ($sClass) {
         $sClass = str_replace("_", "/", $sClass);
         include $sClass . '.php';
     });
     $fDiscountTotal = 0;
     $errors = array();
     $this->worker->addData(array('receiptId' => $this->receiptId));
     try {
         switch ($this->orderType) {
             case null:
                 // Error
                 $this->worker->addData(array('ignore' => true));
                 $errors[] = 'Order Type was NULL';
                 break;
             case 999:
                 // Error
                 $this->worker->addData(array('ignore' => true));
                 $errors[] = 'Error Code 999';
                 break;
             case 2:
                 // EXCHANGE - Swap for Different Item
                 $this->worker->addData(array('ignore' => true));
                 $errors[] = 'Exchange';
                 break;
             case 3:
                 // EXCHANGE - One for One Exchange
                 $this->worker->addData(array('ignore' => true));
                 $errors[] = 'Exchange';
                 break;
             case 1:
                 // REFUND
                 $items = LivePos_Maps_MapFactory::create('itemlist', $this->_raworder['enumProductsSold'], $this->_locationData);
                 $refund = LivePos_Maps_MapFactory::create('refund', $this->_raworder, $this->_locationData, $items);
                 $this->worker->addData(array('encrypted' => $this->_getEncryptedRefundJson($refund)));
                 $this->worker->addData(array('entityId' => $this->_locationData['location_entity']));
                 $this->worker->addData(array('order_id' => $this->_orderId));
                 break;
             case 0:
                 // Sale
                 $items = LivePos_Maps_MapFactory::create('itemlist', $this->_raworder['enumProductsSold'], $this->_locationData);
                 $customer = LivePos_Maps_MapFactory::create('customer', $this->_raworder, $this->_locationData);
                 $order = LivePos_Maps_MapFactory::create('order', $this->_raworder, $this->_locationData, $this->_orderId);
                 $discounts = LivePos_Maps_MapFactory::create('discountlist', $this->_raworder['enumCouponDiscounts']);
                 $payments = LivePos_Maps_MapFactory::create('paymentlist', $this->_raworder['enumPayments']);
                 $this->_processPayments($order, $payments, $discounts);
                 if ($discounts->hasDiscounts()) {
                     $items->popPreDiscountPrices();
                 }
                 // Process InStore/Shipped Orders
                 if ($this->_orderToMerge != null) {
                     $sPosOriginalId = $this->_orderId;
                     $aOrderToMerge = json_decode($this->_orderToMerge, true);
                     $order->setMultiShipTo(true);
                     $customer->mergeCustomer($aOrderToMerge['customer']);
                     // Reset ID to Activa ID, TEMP until exposeure in receipt
                     $order->setOrderId($aOrderToMerge['order']['custbody_order_source_id']);
                     $this->_orderId = $aOrderToMerge['order']['custbody_order_source_id'];
                     array_walk($aOrderToMerge['order']['item'], function ($aItem, $sKey) use(&$items) {
                         $item = LivePos_Maps_MapFactory::create('item', $aItem, $this->_locationData, true);
                         switch ($items->isOldStyle()) {
                             case true:
                                 // OLD STYLE WEBORDER ENTRY
                                 $items->addItem($item);
                                 break;
                             case false:
                                 // New Style... replace item with web order item
                                 $items->mergeItem($item);
                                 break;
                         }
                     });
                     // Catch Non Payed For Items per George 3/15/15
                     if ($items->hasMergerErrors()) {
                         $mergerErrorItems = $items->getNonMergedItems();
                         $order->setFulFillmentTo('A');
                         Utils_Email::sendMergeEmail($this->_orderId, $sPosOriginalId, $mergerErrorItems);
                     }
                 }
                 $order->addItems($items->getItemsArray());
                 $order->setShippedTax($items->getShippingTax());
                 $order->setShippingCharge($items->getShippingCharge());
                 $this->_processDiscounts($order, $items, $discounts);
                 $this->worker->addData(array('order_id' => $this->_orderId));
                 // DEBUG STUFF
                 $this->worker->addData(array('posTotal' => $order->getPosTotal()));
                 $this->worker->addData(array('orderTotal' => $order->getTotal()));
                 $this->worker->addData(array('webItems' => $items->getWebItemsTotal()));
                 $this->worker->addData(array('invoiceId' => $order->getInvoiceId()));
                 // END DEBUG
                 $this->worker->addData(array('encrypted' => $this->_getEncryptedJson($customer, $order)));
                 $this->worker->addData(array('entityId' => $this->_locationData['location_entity']));
                 $this->worker->addData(array('web_items' => $items->hasWebItems));
                 break;
             default:
                 $errors[] = 'Did Not Recognize Transaction Type: ' . $this->orderType;
                 break;
         }
         $sFlatErrors = implode(',', $errors);
         $this->worker->addData(array('error' => $sFlatErrors));
     } catch (Exception $e) {
         LivePos_Db_Model::logError($e);
         $this->worker->addData(array('error' => $e->getMessage()));
         $this->worker->addData(array('ignore' => true));
     }
 }
Ejemplo n.º 8
0
 private function _skusToNsIds()
 {
     if ($this->hasItems()) {
         $aSkusArray = array();
         // Create Array of Item Skus
         array_walk($this->_itemList, function ($oData, $sKey) use(&$aSkusArray) {
             $aSkusArray[] = $oData->item;
         });
         $model = new LivePos_Db_Model();
         $aNsData = $model->skusToNsId(array_values(array_unique($aSkusArray)));
         // Replace Skus
         array_walk($this->_itemList, function (&$oData, $sKey) use(&$aNsData) {
             $this->_listSkus[] = $oData->item;
             $oData->item = $aNsData[$oData->item]['id'] == null ? $oData->item : $aNsData[$oData->item]['id'];
         });
         $model = null;
     }
 }