Esempio n. 1
0
 /**
  *
  * @return array
  */
 public function listAction()
 {
     $this->view->page = $page = $this->getRequest()->getParam('page') ?: 1;
     if ($this->getRequest()->isPost()) {
         $this->view->post = $post = $this->getRequest()->getParams();
     }
     $total = QuarantineQuery::create()->filter($post)->count();
     $this->view->quarantines = $quarantines = QuarantineQuery::create()->filter($post)->page($page, $this->getMaxPerPage())->find();
     $this->view->paginator = $this->createPaginator($total, $page);
     $this->view->warehouseEntranceProducts = \Application\Query\WarehouseEntranceProductQuery::create()->find()->toCombo();
 }
Esempio n. 2
0
 /**
  *
  * @param WarehouseEntranceEvent $event
  */
 public function createQuarantineRecoveryDeadlineNotification(WarehouseEntranceEvent $event)
 {
     $warehouseEntrance = $event->getWarehouseEntrance();
     $folio = FolioImportQuery::create()->findByPK($warehouseEntrance->getIdFolioImport())->getFolio();
     $entranceProduct = WarehouseEntranceProductQuery::create()->whereAdd(WarehouseEntranceProduct::ID_WAREHOUSE_ENTRANCE, $warehouseEntrance->getIdWarehouseEntrance())->findOne();
     $description = ProductQuery::create()->findByPK($entranceProduct->getIdProduct())->getItemName();
     $purchaseOrder = $entranceProduct->getIdPurchaseOrder();
     $vars = array('recoveryDeadline' => $event->getRecoveryDeadline(), 'description' => $description, 'purchaseOrder' => $purchaseOrder, 'folio' => $folio, 'idWarehouseEntrance' => $warehouseEntrance->getIdWarehouseEntrance());
     $this->createNotification(NotificationType::$id['WAREHOUSE_ENTRIES_QUARANTIES_DEADLINE'], $vars);
 }
 /**
  * 
  * 
  */
 public function getQuarantineListResultsAction()
 {
     $page = $this->getRequest()->getParam('page') ?: 1;
     $warehouseEntries = WarehouseEntranceQuery::create()->whereAdd(WarehouseEntrance::ID_FOLIO_IMPORT, null, WarehouseEntranceQuery::NOT_EQUAL)->whereAdd(WarehouseEntrance::ID_FOLIO_IMPORT, '0', WarehouseEntranceQuery::NOT_EQUAL)->find();
     $params = $this->getRequest()->getParams();
     $params['id_purchase_order'] = PurchaseOrderQuery::create()->whereAdd(PurchaseOrder::SAP_DOCUMENT_NUMBER, $params['sap_document_number'])->fetchOne();
     if (empty($params['id_purchase_order']) && !empty($params['sap_document_number'])) {
         $params['id_purchase_order'] = -1;
     }
     $warehouseEntryProductQuery = WarehouseEntranceProductQuery::create()->whereAdd(WarehouseEntranceProduct::ID_PURCHASE_ORDER, null, WarehouseEntranceProductQuery::NOT_EQUAL)->whereAdd(WarehouseEntranceProduct::STATUS, WarehouseEntranceProduct::$Status['Quarantine'], WarehouseEntranceProductQuery::EQUAL)->whereAdd(WarehouseEntranceProduct::ID_WAREHOUSE_ENTRANCE, $warehouseEntries->getPrimaryKeys(), WarehouseEntranceProductQuery::IN)->filter($params)->orderBy(WarehouseEntranceProduct::ID_WAREHOUSE_ENTRANCE, 'DESC')->findByPage($page, $this->getMaxPerPage());
     $purchaseOrderCollection = PurchaseOrderQuery::create()->whereAdd(PurchaseOrder::ID_PURCHASE_ORDER, $warehouseEntryProductQuery->getPurchaseOrderIds(), PurchaseOrderQuery::IN)->find();
     $purchaseOrderEntryCollection = PurchaseOrderEntryQuery::create()->whereAdd(PurchaseOrderEntry::ID_PURCHASE_ORDER, $purchaseOrderCollection->getPrimaryKeys(), PurchaseOrderEntryQuery::IN)->find();
     $i = 0;
     $this->getCatalog('QuarantineCatalog')->beginTransaction();
     while ($warehouseEntryLine = $warehouseEntryProductQuery->read()) {
         $warehouseEntry = WarehouseEntranceQuery::create()->whereAdd(WarehouseEntrance::ID_WAREHOUSE_ENTRANCE, $warehouseEntryLine->getIdWarehouseEntrance())->findOne();
         if (TransferLineLogQuery::create()->whereAdd(TransferLineLog::BASEENTRY, $warehouseEntryLine->getIdWarehouseEntrance())->whereAdd(TransferLineLog::BASELINE, $warehouseEntryLine->getIdWarehouseEntranceProduct())->count()) {
             $transferLine = TransferLineLogQuery::create()->whereAdd(TransferLineLog::BASEENTRY, $warehouseEntryLine->getIdWarehouseEntrance())->whereAdd(TransferLineLog::BASELINE, $warehouseEntryLine->getIdWarehouseEntranceProduct())->findOne();
             $warehouseEntryLines[$i]['warehouse'] = WarehouseStoreQuery::create()->whereAdd(WarehouseStore::CODE, $transferLine->getWhsCode())->findOne()->getName();
         } else {
             $warehouseEntryLines[$i]['warehouse'] = $this->i18n->_('Not Available');
         }
         $claimReport = $this->getClaimReport($warehouseEntryLine->getIdWarehouseEntrance(), $warehouseEntryLine->getIdWarehouseEntranceProduct());
         $folioImport = $this->getWarehouseEntryFolioImport($warehouseEntry->getIdFolioImport());
         $quarantine = $this->getQuarantine($warehouseEntryLine->getIdWarehouseEntrance(), $warehouseEntryLine->getIdWarehouseEntranceProduct());
         $product = ProductQuery::create()->findByPK($warehouseEntryLine->getIdProduct());
         $warehouseEntryLines[$i]['id_warehouse_entrance_product'] = $warehouseEntryLine->getIdWarehouseEntranceProduct();
         $warehouseEntryLines[$i]['id_warehouse_entrance'] = $warehouseEntry->getIdWarehouseEntrance();
         $warehouseEntryLines[$i]['id_folio_import'] = $folioImport->getIdFolioImport();
         $warehouseEntryLines[$i]['folio_import'] = $folioImport->getFolio();
         if (PurchaseOrderQuery::create()->whereAdd(PurchaseOrder::ID_PURCHASE_ORDER, $warehouseEntryLine->getIdPurchaseOrder())->find()->count()) {
             $purchaseOrder = PurchaseOrderQuery::create()->findByPK($warehouseEntryLine->getIdPurchaseOrder());
         } else {
             $purchaseOrder = new PurchaseOrder();
         }
         $purchaseOrderEntry = PurchaseOrderEntryQuery::create()->whereAdd(PurchaseOrderEntry::ID_PURCHASE_ORDER, $purchaseOrder->getIdPurchaseOrder())->whereAdd(PurchaseOrderEntry::LINE, (string) $warehouseEntryLine->getBaseLine())->findOneOrElse(new PurchaseOrderEntry());
         $proformaInvoice = ProformaInvoiceQuery::create()->whereAdd(ProformaInvoice::ID_PROFORMA_INVOICE, $purchaseOrderEntry->getBaseEntry())->findOneOrElse(new ProformaInvoice());
         $warehouseEntryLines[$i]['proforma_invoice'] = $proformaInvoice->getSapDocumentNumber();
         $warehouseEntryLines[$i]['purchase_order'] = $purchaseOrder->getSapDocumentNumber();
         $warehouseEntryLines[$i]['item_code'] = $product->getItemCode();
         $warehouseEntryLines[$i]['item_name'] = $product->getItemName();
         $warehouseEntryLines[$i]['original_quantity'] = $warehouseEntryLine->getQuantity();
         $warehouseEntryLines[$i]['current_quantity'] = $currentQuantity = $quarantine->getQuantity();
         if ($warehouseEntryLine->getLineStatus() == 'C') {
             // 				$warehouseEntryLines[$i]['cancelled'] = true;
             // 				$warehouseEntryLines[$i]['status'] = 'Cancelled';
             // 				$warehouseEntryLines[$i]['statusRow'] = ' ';
         } else {
             $warehouseEntryLines[$i]['cancelled'] = false;
             if (!$currentQuantity) {
                 $warehouseEntryLines[$i]['status'] = 'Debugged';
                 $warehouseEntryLines[$i]['statusRow'] = 'success';
             } else {
                 $warehouseEntryLines[$i]['status'] = $warehouseEntryLine->getStatusName();
                 $warehouseEntryLines[$i]['statusRow'] = 'warning';
             }
         }
         $warehouseEntryLines[$i]['quarantine'] = $warehouseEntryLine->getStatusName();
         $warehouseEntryLines[$i]['claimed_amount'] = $claimReport->getClaimedAmount();
         $warehouseEntryLines[$i]['final_amount'] = $claimReport->getFinalAmount();
         $warehouseEntryLines[$i]['claim_report_status'] = $claimReport->getStatusName();
         $warehouseEntryLines[$i]['allow_debug'] = TransferLineLogQuery::create()->whereAdd(TransferLineLog::BASEENTRY, $warehouseEntryLine->getIdWarehouseEntrance())->whereAdd(TransferLineLog::BASELINE, $warehouseEntryLine->getIdWarehouseEntranceProduct())->count();
         if ($warehouseEntryLine->getStatus() == WarehouseEntranceProduct::$Status['Quarantine']) {
             $quarantineProduct = $this->getQuarantine($warehouseEntryLine->getIdWarehouseEntrance(), $warehouseEntryLine->getIdWarehouseEntranceProduct());
             $warehouseEntryLines[$i]['initial_quantity'] = $quarantineProduct->getQuantity();
         }
         $i++;
     }
     $this->getCatalog('QuarantineCatalog')->commit();
     die(json_encode($warehouseEntryLines));
 }
Esempio n. 4
0
 protected function getCostLogByIdProducts()
 {
     $productEntranceListQuery = WarehouseEntranceProductQuery::create()->addColumns(array('id_product' => "WarehouseEntranceProduct.ItemCode", 'price' => "WarehouseEntranceProduct.Price", 'currency' => "WarehouseEntranceProduct.Currency", 'line' => 'ROW_NUMBER()OVER( PARTITION BY ItemCode ORDER BY DocEntry DESC)'));
     $productCostHistory = WarehouseEntranceProductQuery::create()->addColumns(array('id_product', 'price', 'currency'))->removeFrom()->from("(" . $productEntranceListQuery->createSql() . ")", "entranceList")->whereAdd("line", 1, WarehouseEntranceProductQuery::EQUAL)->whereAdd("id_product", null, WarehouseEntranceProductQuery::IS_NOT_NULL)->find();
     $idsProducts = $productCostHistory->getIdsProducts();
     $productCostsQuery = ProductCostLogQuery::create()->whereAdd(ProductCostLog::ID_PRODUCT, $idsProducts, BaseQuery::NOT_IN)->addAscendingOrderBy(ProductCostLog::ID_PRODUCT)->addDescendingOrderBy(ProductCostLog::DATE);
     $productCosts = ProductCostLogQuery::create()->addColumn("*")->removeFrom()->from($productCostsQuery, "myGroup")->addGroupBy(ProductCostLog::ID_PRODUCT)->find();
     $costLogArray = array_merge($productCosts->toCostLogArray(), $productCostHistory->toCostLogArray());
     return $costLogArray;
 }