예제 #1
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());
                 }
         }
     }
 }
 public function claimControlAction()
 {
     $id = $this->getRequest()->getParam('id');
     $line = $this->getRequest()->getParam('line');
     $warehouseEntry = WarehouseEntranceQuery::create()->findByPK($id);
     $warehouseEntryProduct = WarehouseEntranceProductQuery::create()->whereAdd(WarehouseEntranceProduct::ID_WAREHOUSE_ENTRANCE, $id)->whereAdd(WarehouseEntranceProduct::ID_WAREHOUSE_ENTRANCE_PRODUCT, $line)->findOne();
     $purchaseOrder = PurchaseOrderQuery::create()->findByPK($warehouseEntryProduct->getIdPurchaseOrder());
     $product = ProductQuery::create()->findByPK($warehouseEntryProduct->getIdProduct());
     $folioImport = FolioImportQuery::create()->findByPK($warehouseEntry->getIdFolioImport());
     $booking = BookingQuery::create()->whereAdd(Booking::ID_FOLIO_IMPORT, $folioImport->getIdFolioImport())->findOne();
     $freight = $booking->getIncreasableFreight() + $booking->getIncreasableInsurance();
     $quarantine = QuarantineQuery::create()->whereAdd(Quarantine::ID_WAREHOUSE_ENTRANCE_PRODUCT, $warehouseEntryProduct->getIndex())->find()->count();
     if ($quarantine) {
         $quarantineQuery = QuarantineQuery::create()->whereAdd(Quarantine::ID_WAREHOUSE_ENTRANCE_PRODUCT, $warehouseEntryProduct->getIndex())->findOne();
         $items = $quarantineQuery->getDestruction() + $quarantineQuery->getOtherCode() + $quarantineQuery->getSecond();
         $total = $items + $quarantineQuery->getPpv() + $quarantineQuery->getMissing();
         $freight = $freight / $total;
         $totalRejected = $items * $warehouseEntryProduct->getPrice() + $items * $freight;
     } else {
     }
     $warehouseEntryInfo['total_rejected'] = $totalRejected;
     $warehouseEntryInfo['id_warehouse_entrance'] = $warehouseEntry->getIdWarehouseEntrance();
     $warehouseEntryInfo['id_warehouse_entrance_product'] = $line;
     $warehouseEntryInfo['folio'] = $warehouseEntryProduct->getFolioWarehouse();
     $warehouseEntryInfo['reception_date'] = $warehouseEntry->getArrivalDate();
     $warehouseEntryInfo['supplier'] = $purchaseOrder->getIdSupplier();
     $warehouseEntryInfo['folio_import'] = $folioImport->getFolio();
     $warehouseEntryInfo['purchase_order'] = $purchaseOrder->getIdPurchaseOrder();
     $warehouseEntryInfo['doc_num'] = $purchaseOrder->getSapDocumentNumber();
     $warehouseEntryInfo['code'] = 'pendiente';
     $warehouseEntryInfo['item_code'] = $product->getItemCode();
     $warehouseEntryInfo['item_name'] = $product->getItemName();
     $warehouseEntryInfo['commentaries'] = $warehouseEntry->getComments();
     $warehouseEntryInfo['currency'] = $purchaseOrder->getIdCurrency();
     if (WarehouseEntranceFileQuery::create()->whereAdd(WarehouseEntranceFile::ID_WAREHOUSE_ENTRANCE, $id)->count()) {
         $this->view->claimReportDocument = true;
     }
     $this->view->contentTitle = $this->i18n->_('Claim Control');
     $this->view->onsubmit = "warehouse-entrance/save-claim-control";
     $this->getCatalog('FolioimportCatalog')->beginTransaction();
     $claimReport = $this->getClaimReport($warehouseEntryProduct->getIdWarehouseEntrance(), $warehouseEntryProduct->getIdWarehouseEntranceProduct());
     $this->getCatalog('FolioimportCatalog')->commit();
     $warehouseEntryInfo['status'] = $claimReport->getStatus();
     $this->view->status = $this->getClaimControlStatus();
     $this->view->claimReport = $claimReport->toArray();
     $this->view->warehouseEntranceInfo = $warehouseEntryInfo;
     $this->view->open = WarehouseEntranceClaimReport::$Status['Open'];
     $this->view->accept = WarehouseEntranceClaimReport::$Status['Accepted'];
     $this->view->partiallyAccept = WarehouseEntranceClaimReport::$Status['Partially Accepted'];
     $this->view->reject = WarehouseEntranceClaimReport::$Status['Rejected'];
     $this->view->cancel = WarehouseEntranceClaimReport::$Status['Cancelled'];
 }
예제 #3
0
 /**
  * 
  * 
  */
 public function getListResultsAction()
 {
     $page = $this->getRequest()->getParam('page') ?: 1;
     $params = $this->getRequest()->getParams();
     $total = FolioImportQuery::create()->filter($params)->count();
     $folioImportQuery = FolioImportQuery::create()->find();
     $myFolioImportQuery = FolioImportQuery::create()->filter($params)->page($page, $this->getMaxPerPage())->orderBy(FolioImport::ID_FOLIO_IMPORT, 'DESC')->find();
     $bookings = BookingQuery::create()->whereAdd(Booking::ID_FOLIO_IMPORT, $myFolioImportQuery->getPrimaryKeys(), BookingQuery::IN)->find();
     $landedCosts = FolioImportLandedCostQuery::create()->whereAdd(FolioImportLandedCost::ID_FOLIO_IMPORT, $folioImportQuery->getPrimaryKeys())->find();
     $i = 0;
     while ($folioImport = $myFolioImportQuery->read()) {
         $frontpageStatus = array_flip(FolioImport::$FrontpageStatus);
         $folioImports[$i] = $folioImport->toArray();
         $folioImports[$i]['payment_status'] = $folioImport->getPaymentStatus();
         $folioImports[$i]['frontpage_status'] = $frontpageStatus[$folioImport->getFrontpageStatus()];
         $folioImports[$i]['status'] = $folioImport->getStatusName();
         if ($bookings->getByFolioImportIds($folioImport->getIdFolioImport())->count()) {
             $boooking = $bookings->getByFolioImportIds($folioImport->getIdFolioImport())->getOne();
             $folioImports[$i]['id_booking'] = $boooking->getIdBooking();
             $folioImports[$i]['arrival_date'] = $boooking->getEta();
         }
         $folioImports[$i]['landed_cost'] = $landedCosts->getByFolioImportIds($folioImport->getIdFolioImport())->count();
         $i++;
     }
     die(json_encode($folioImports));
 }
예제 #4
0
 /**
  * @author joseluis
  * @return boolean
  */
 private function blMasterCallBack($idBooking)
 {
     $booking = BookingQuery::create()->findByPK($idBooking);
     try {
         $this->getEventDispatcherService()->createBookingNotification($booking, BookingEvent::BOOKING_CONFIRMED_MISSING_INVOICE);
         $this->getEventDispatcherService()->createBookingNotification($booking, BookingEvent::BOOKING_CHINA_NOTIFICATION);
         //     		$this->getEventDispatcherService()->createBookingNotification($booking, BookingEvent::BOOKING_15_DAYS_NOTIFICATION);
         //     		$this->getEventDispatcherService()->createBookingNotification($booking, BookingEvent::BOOKING_7_DAYS_NOTIFICATION);
         //     		$this->getEventDispatcherService()->createBookingNotification($booking, BookingEvent::BOOKING_5_DAYS_NOTIFICATION);
         //     		$this->getEventDispatcherService()->createBookingNotification($booking, BookingEvent::BOOKING_3_DAYS_NOTIFICATION);
         //     		$this->getEventDispatcherService()->createBookingNotification($booking, BookingEvent::BOOKING_2_DAYS_NOTIFICATION);
         return true;
     } catch (Exception $e) {
         $this->setFlash('error', $e);
         return false;
     }
 }