コード例 #1
0
 /**
  * 
  * 
  */
 public function createLandedCostAction()
 {
     $params = $this->getRequest()->getParams();
     $SAPConnector = new SAPConnectorClient();
     $landedCost = new LandedCost();
     $landedCostCosts = new LandedCostCostCollection();
     foreach ($params['landed_cost_costs'] as $landedCostCostParams) {
         $landedCostCost = LandedCostCostFactory::createFromArray($landedCostCostParams);
         $landedCostCosts->append($landedCostCost);
     }
     $landedCost->setDocEntry(1);
     $landedCost->setLandedCostCosts($landedCostCosts);
     $warehouseEntries = WarehouseEntranceQuery::create()->whereAdd(WarehouseEntrance::ID_FOLIO_IMPORT, $params['id'])->find();
     $result = $SAPConnector->createLandedCost($warehouseEntries, $landedCost);
     try {
         if ($result->createLandedCostResult->success) {
             $this->getCatalog('FolioImportlandedCostCatalog')->beginTransaction();
             $folioImportLandedCost = new FolioImportLandedCost();
             $folioImportLandedCost->setIdFolioImport($params['id']);
             $folioImportLandedCost->setIdLandedCost($result->createLandedCostResult->id);
             $this->getCatalog('FolioImportlandedCostCatalog')->create($folioImportLandedCost);
             $folioImport = FolioImportQuery::create()->findByPK($params['id']);
             $this->newLogForCreateLandedCost($folioImport);
             $this->getCatalog('FolioImportlandedCostCatalog')->commit();
             $this->setFlash('ok', $this->i18n->_('The landed cost has been set'));
         } else {
             throw new Exception($this->i18n->_('It cannot be set a Landed Cost for Folio Import ' . $idFolioImport) . $result->createLandedCostResult->message);
         }
     } catch (Exception $e) {
         $this->setFlash('error', $e->getMessage());
     }
     $this->_redirect('folio-import/list');
 }
コード例 #2
0
 /**
  * (non-PHPdoc)
  * @see Application\Cron.Cronable::run()
  */
 public function run()
 {
     $now = new \DateTime(date("Y-m-d", mktime(0, 0, 0, date("m"), date("d"), date("Y"))));
     $bookings = BookingQuery::create()->whereAdd(Booking::ETA, \Zend_Date::now()->get('YYYY-MM-dd'), BookingQuery::GREATER_OR_EQUAL)->find();
     $eventDispatcher = $this->getEventDispatcherService();
     while ($booking = $bookings->read()) {
         $eta = new \DateTime($booking->getEta());
         $interval = date_diff($eta, $now);
         switch ($interval->format('%r%d')) {
             case self::FIFTEEN_DAYS_BEFORE:
                 $eventDispatcher->createBookingNotification($booking, BookingEvent::BOOKING_15_DAYS_NOTIFICATION);
                 break;
             case self::SEVEN_DAYS_BEFORE:
                 $eventDispatcher->createBookingNotification($booking, BookingEvent::BOOKING_7_DAYS_NOTIFICATION);
                 break;
             case self::THREE_DAYS_BEFORE:
                 $eventDispatcher->createBookingNotification($booking, BookingEvent::BOOKING_3_DAYS_NOTIFICATION);
                 break;
             case self::TWO_DAYS_BEFORE:
                 $eventDispatcher->createBookingNotification($booking, BookingEvent::BOOKING_2_DAYS_NOTIFICATION);
                 break;
             case self::TODAY:
                 $purchaseOrders = PurchaseOrderQuery::create()->whereAdd(PurchaseOrder::ID_FOLIO_IMPORT, $booking->getIdFolioImport())->find();
                 while ($purchaseOrder = $purchaseOrders->read()) {
                     $purchaseOrderEntries = PurchaseOrderEntryQuery::create()->whereAdd(PurchaseOrderEntry::ID_PURCHASE_ORDER, $purchaseOrder->getIdPurchaseOrder())->find();
                     $eventDispatcher->dispatchPurchaseOrderEvent($purchaseOrder, PurchaseOrderEvent::PURCHASEORDER_ARRIVED, $purchaseOrderEntries);
                 }
                 break;
         }
     }
     $quarantineRecoveryDeadlines = WarehouseEntranceQuarantineRecoveryDeadlineQuery::create()->whereAdd(WarehouseEntranceQuarantineRecoveryDeadline::RECOVERY_DEADLINE, \Zend_Date::now()->get('YYYY-MM-dd'), WarehouseEntranceQuarantineRecoveryDeadlineQuery::GREATER_OR_EQUAL)->find();
     while ($quarantineRecoveryDeadline = $quarantineRecoveryDeadlines->read()) {
         $deadline = new \DateTime($quarantineRecoveryDeadline->getRecoveryDeadline());
         $interval = date_diff($deadline, $now);
         switch ($interval->format('%r%d')) {
             case self::TODAY:
                 if (WarehouseEntranceQuery::create()->whereAdd(WarehouseEntrance::ID_WAREHOUSE_ENTRANCE, $quarantineRecoveryDeadline->getIdWarehouseEntrance())->count()) {
                     $warehouseEntry = WarehouseEntranceQuery::create()->whereAdd(WarehouseEntrance::ID_WAREHOUSE_ENTRANCE, $quarantineRecoveryDeadline->getIdWarehouseEntrance())->findOne();
                     $eventDispatcher->createWarehouseEntranceNotification($warehouseEntry, WarehouseEntranceEvent::WAREHOUSE_ENTRIES_QUARANTIES_DEADLINE, $quarantineRecoveryDeadline->getRecoveryDeadline());
                 }
         }
     }
 }
コード例 #3
0
 /**
  * 
  * 
  */
 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));
 }