Пример #1
0
 public function load()
 {
     $searchText = $this->initFilters();
     $searchWhereFilter = [];
     if ($searchText !== false) {
         $searchWhereFilter = ['serial_number', 'like', "'%{$searchText}%'"];
     }
     $sol_searial_numbers = SaleOrderLineSerialNumberManager::getInstance()->selectAdvance('*', $searchWhereFilter, null, null, 0, 1000);
     $saleOrdersDateMappedBySN = $this->getSaleOrdersDatesMappedBySN($sol_searial_numbers);
     $pol_searial_numbers = PurchaseOrderLineSerialNumberManager::getInstance()->selectAdvance('*', $searchWhereFilter, null, null, 0, 1000);
     $purchaseOrdersDateMappedBySN = $this->getPurchaseOrdersDatesMappedBySN($pol_searial_numbers);
     $combinePolAndSolSerialNumbers = $this->combinePolAndSolSerialNumbers($sol_searial_numbers, $pol_searial_numbers);
     $this->addParam('searial_numbers', $combinePolAndSolSerialNumbers);
     $this->addParam('saleOrdersDateMappedBySN', $saleOrdersDateMappedBySN);
     $this->addParam('purchaseOrdersDateMappedBySN', $purchaseOrdersDateMappedBySN);
 }
Пример #2
0
 public function load()
 {
     $this->initErrorMessages();
     $this->initSuccessMessages();
     $this->addParam('products', ProductManager::getInstance()->selectAdvance('*', [], ['name']));
     $this->addParam('currencies', CurrencyManager::getInstance()->selectAdvance('*', ['active', '=', 1], ['name']));
     $paymentId = NGS()->args()->id;
     $saleOrders = SaleOrderManager::getInstance()->getSaleOrdersFull(['id', '=', $paymentId]);
     if (!empty($saleOrders)) {
         $saleOrder = $saleOrders[0];
         $this->addParam('saleOrder', $saleOrder);
     }
     $polSerialNumbersDtos = [];
     $saleOrderLineIds = $this->getSaleOrderLineIds($saleOrders);
     if (!empty($saleOrderLineIds)) {
         $saleOrderLineIdsSql = '(' . implode(',', $saleOrderLineIds) . ')';
         $polSerialNumbersDtos = SaleOrderLineSerialNumberManager::getInstance()->selectAdvance('*', ['line_id', 'IN', $saleOrderLineIdsSql]);
         $polSerialNumbersDtos = $this->mapDtosByLineId($polSerialNumbersDtos);
     }
     $this->addParam("polSerialNumbersDtos", $polSerialNumbersDtos);
 }
 public function service()
 {
     if (!isset(NGS()->args()->sale_order_id)) {
         $_SESSION['error_message'] = 'Sale Order ID is missing';
         $this->redirect('sale/list');
     }
     $saleOrderId = intval(NGS()->args()->sale_order_id);
     if (!isset(NGS()->args()->pols_serial_numbers)) {
         $_SESSION['error_message'] = 'Serial Numbers parameter is missing';
         $this->redirect('sale/warranty/' . $saleOrderId);
     }
     $pols_serial_numbers_json = NGS()->args()->pols_serial_numbers;
     $pols_serial_numbers = json_decode($pols_serial_numbers_json);
     foreach ($pols_serial_numbers as $obj) {
         $pol_id = $obj->pol_id;
         $serial_numbers = $obj->serial_numbers;
         $warranty_months = $obj->warranty_months;
         SaleOrderLineSerialNumberManager::getInstance()->setSaleOrderListSerialNumbers($pol_id, $serial_numbers, $warranty_months);
     }
     $_SESSION['success_message'] = 'Serial Numbers successfully saved.';
     $this->redirect('sale/warranty/' . $saleOrderId);
 }