コード例 #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());
                 }
         }
     }
 }
コード例 #2
0
 /**
  *
  *
  */
 public function saveQuarantineRecoveryControlAction()
 {
     $deadline = $this->getRequest()->getParam('deadline');
     $notes = $this->getRequest()->getParam('commentaries');
     $id = $this->getRequest()->getParam('idWarehouseEntrance');
     $line = $this->getRequest()->getParam('idWarehouseEntranceProducts');
     $SapConnection = new SAPConnectorClient();
     $warehouseEntry = WarehouseEntranceQuery::create()->findByPK($id);
     $warehouseEntry->setComments($notes);
     $SapConnection->updateWarehouseEntry($warehouseEntry);
     $warehouseEntranceLine = WarehouseEntranceProductQuery::create()->whereAdd(WarehouseEntranceProduct::ID_WAREHOUSE_ENTRANCE, $id)->whereAdd(WarehouseEntranceProduct::ID_WAREHOUSE_ENTRANCE_PRODUCT, $line)->findOne();
     $recoveryDeadlineQuery = WarehouseEntranceQuarantineRecoveryDeadlineQuery::create()->whereAdd(WarehouseEntranceQuarantineRecoveryDeadline::ID_WAREHOUSE_ENTRANCE, $warehouseEntranceLine->getIdWarehouseEntrance())->whereAdd(WarehouseEntranceQuarantineRecoveryDeadline::ID_WAREHOUSE_ENTRANCE_LINE, $warehouseEntranceLine->getIdWarehouseEntranceProduct())->find();
     $this->getCatalog('WarehouseEntranceQuarantineRecoveryDeadlineCatalog')->beginTransaction();
     while ($recoveryDeadline = $recoveryDeadlineQuery->read()) {
         try {
             $this->getCatalog('WarehouseEntranceQuarantineRecoveryDeadlineCatalog')->deleteById($recoveryDeadline->getIdWarehouseEntranceQuarantineRecoveryDeadline());
         } catch (Exception $e) {
             $this->setFlash('error', $e->getMessage());
             $this->_redirect('warehouse-entrance/quarantine-list');
         }
     }
     foreach ($deadline as $value) {
         if (!empty($value)) {
             $recoveryDeadline = new WarehouseEntranceQuarantineRecoveryDeadline();
             $recoveryDeadline->setIdWarehouseEntrance($warehouseEntranceLine->getIdWarehouseEntrance());
             $recoveryDeadline->setIdWarehouseEntranceLine($warehouseEntranceLine->getIdWarehouseEntranceProduct());
             $recoveryDeadline->setRecoveryDeadline($value);
             try {
                 $this->getCatalog('WarehouseEntranceQuarantineRecoveryDeadlineCatalog')->create($recoveryDeadline);
             } catch (Exception $e) {
                 echo $e->getMessage();
                 die;
                 $this->setFlash('error', $e->getMessage());
                 $this->_redirect('warehouse-entrance/quarantine-list');
             }
         }
     }
     $this->setFlash('ok', $this->i18n->_('The Quarantine Recovery Deadline has been saved.'));
     $this->getCatalog('WarehouseEntranceQuarantineRecoveryDeadlineCatalog')->commit();
     $this->_redirect('warehouse-entrance/quarantine-list');
 }