Exemple #1
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 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));
 }
 /**
  * 
  * @param int $folio
  * @param int $idEvent
  */
 private function getFolioInformation($folio)
 {
     $folioImport = FolioImportQuery::create()->whereAdd(FolioImport::FOLIO, $folio)->findOneOrThrow($this->i18n->_("Transit Document with folio {$folio} not found."));
     $programmedPayments = FolioImportProgrammedPaymentQuery::create()->whereAdd(FolioImportProgrammedPayment::FOLIO, $folioImport->getFolio())->find();
     $purchaseOrders = PurchaseOrderQuery::create()->whereAdd(PurchaseOrder::ID_PURCHASE_ORDER, $programmedPayments->getPurchaseOrderIds())->find();
     $purchaseOrderEntries = PurchaseOrderEntryQuery::create()->whereAdd(PurchaseOrderEntry::ID_PURCHASE_ORDER, $purchaseOrders->getPrimaryKeys())->find();
     $suppliers = SapSupplierQuery::create()->whereAdd(SapSupplier::CARDCODE, $purchaseOrders->getDistinctSuppliers())->find();
     $response = array("transitNumber" => $folioImport->getFolio(), "status" => $folioImport->getStatusName());
     while ($purchaseOrderEntries->valid()) {
         $purchaseOrderEntry = $purchaseOrderEntries->read();
         $purchaseOrder = $purchaseOrders->getByPK($purchaseOrderEntry->getIdPurchaseOrder());
         $supplier = $suppliers->getByPK($purchaseOrder->getIdSupplier());
         $response["entries"][] = array("PO" => $purchaseOrder->getIdPurchaseOrder(), "line" => $purchaseOrderEntry->getLine(), "product" => $purchaseOrderEntry->getIdProduct(), "price" => $purchaseOrderEntry->getPrice(), "currency" => $purchaseOrderEntry->getCurrency(), "supplier" => $supplier->getCardCode(), "supplierName" => $supplier->getCardname());
     }
     return $response;
 }
 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'];
 }
 /**
  *
  * @param WarehouseEntrance $warehouseEntrance
  * @return \stdClass
  */
 public function createWarehouseEntry(WarehouseEntrance $warehouseEntrance)
 {
     $lines = array();
     $warehouseEntryLines = $warehouseEntrance->getLines();
     $folioImport = FolioImportQuery::create()->findByPK($warehouseEntrance->getIdFolioImport());
     while ($warehouseEntryLine = $warehouseEntryLines->read()) {
         $lines[] = self::createWarehouseEntryLine($warehouseEntryLine, $warehouseEntrance->getImportLicense(), $folioImport->getCustoms(), $folioImport->getInDate());
     }
     $parameters['warehouseEntry'] = array('DocEntry' => 0, 'DocNum' => 0, 'Cardcode' => utf8_encode($warehouseEntrance->getIdSupplier()), 'DocCur' => utf8_encode($warehouseEntrance->getCurrency()), 'NumAtCard' => utf8_encode($warehouseEntrance->getNumAtCard()), 'Comments' => utf8_encode($warehouseEntrance->getComments()), 'status' => $warehouseEntrance->getStatus(), 'samplingType' => $warehouseEntrance->getSamplingType(), 'inspectionResult' => utf8_encode($warehouseEntrance->getQuarantine()), 'idFolioImport' => $warehouseEntrance->getIdFolioImport(), 'idCourtYard' => 0, 'folioWarehouse' => utf8_encode($warehouseEntrance->getImportLicense()), 'courtyardArrivalDate' => $warehouseEntrance->getArrivalDate(), 'Lines' => $lines);
     $this->createLogrequest($parameters);
     $result = $this->soapClient->createWarehouseEntry($parameters);
     return $result;
 }
 public function receiveEntriesAction()
 {
     $id = $this->getRequest()->getParam('id');
     $folioImport = FolioImportQuery::create()->findByPK($id);
     $folioImport->setStatus(FolioImport::$Status['Received']);
     $redirect = 'folio-import/details/id/' . $id;
     $this->getPurchaseOrderEntryCatalog()->beginTransaction();
     try {
         $this->getCatalog('FolioImportCatalog')->update($folioImport);
     } catch (Exception $e) {
         $this->setFlash('error', $e->getMessage());
         die;
         //     		$this->_redirect($redirect);
     }
     $purchaseOrderEntries = $this->getRequest()->getParam('purchaseOrderEntries');
     foreach ($purchaseOrderEntries as $purchaseOrderEntryValues) {
         $purchaseOrderEntry = PurchaseOrderEntryQuery::create()->findByPK($purchaseOrderEntryValues['idPurchaseOrderEntry']);
         $purchaseOrderEntry->setCartons($purchaseOrderEntryValues['cartons']);
         $purchaseOrderEntry->setCartonParts($purchaseOrderEntryValues['cartonParts']);
         $purchaseOrderEntry->setLoosePieces($purchaseOrderEntryValues['loosePieces']);
         $purchaseOrderEntry->setTotal($purchaseOrderEntryValues['total']);
         $purchaseOrderEntry->setInvoiceTotal($purchaseOrderEntryValues['invoiceTotal']);
         $purchaseOrderEntry->setDiference($purchaseOrderEntryValues['diference']);
         $purchaseOrderEntry->setQuantityByWarehouse($purchaseOrderEntryValues['quantityByWarehouse']);
         $purchaseOrderEntry->setDocumentNumber($purchaseOrderEntryValues['documentNumber']);
         $purchaseOrderEntry->setStatus(PurchaseOrderEntry::$Status['Received']);
         $purchaseOrder = new PurchaseOrder();
         $purchaseOrder->setIdPurchaseOrder($purchaseOrderEntry->getIdPurchaseOrder());
         $purchaseOrder->setComments($this->getRequest()->getParam('commentaries'));
         $purchaseOrder->setStatus(PurchaseOrder::$Status['Received']);
         try {
             $this->getPurchaseOrderCatalog()->update($purchaseOrder);
         } catch (Exception $e) {
             $this->setFlash('error', $e->getMessage());
             die;
             //     		$this->_redirect($redirect);
         }
         try {
             $this->getPurchaseOrderEntryCatalog()->update($purchaseOrderEntry);
         } catch (Exception $e) {
             print_r($e->getMessage());
             $this->setFlash('error', $e->getMessage());
             die;
             //     			$this->_redirect($redirect);
         }
     }
     $this->getPurchaseOrderEntryCatalog()->commit();
     $this->setFlash('ok', $this->i18n->_('The Purchase Order has been updated.'));
     $this->_redirect($redirect);
 }
 /**
  * 
  * @param int $idFolioImport
  */
 public function __construct($idFolioImport, $USDToMXN, $EURtoUSD)
 {
     $this->folioImport = FolioImportQuery::create()->findByPK($idFolioImport);
     if ($USDToMXN) {
         $this->USDToMXN = $USDToMXN;
     }
     if ($EURtoUSD) {
         $this->EURtoUSD = $EURtoUSD;
     }
     $this->purchaseOrders = PurchaseOrderQuery::create()->whereAdd(PurchaseOrder::ID_FOLIO_IMPORT, $idFolioImport)->find();
     $this->purchaseOrdersEntries = PurchaseOrderEntryQuery::create()->whereAdd(PurchaseOrderEntry::ID_PURCHASE_ORDER, $this->getPurchaseOrders()->getPrimaryKeys())->find();
     $this->products = $products = ProductQuery::create()->whereAdd(Product::ITEM_CODE, $this->getPurchaseOrdersEntries()->getProducts())->find();
     $this->productAntidumpingDuties = ProductAntidumpingDutyQuery::create()->whereAdd(ProductAntidumpingDuty::PARENT_KEY, $products->getKeyMother())->find();
 }
Exemple #8
0
 /**
  * @author joseluis
  */
 public function detailsAction()
 {
     $params = $this->getRequest()->getParams();
     $id = $params['id'];
     $this->view->contentTitle = $this->i18n->_('Booking Details');
     $booking = BookingQuery::create()->findByPK($id)->toArray();
     $booking['folio'] = FolioImportQuery::create()->findByPK($booking['id_folio_import'])->getFolio();
     $freightForwarder = BookingFileQuery::create()->whereAdd(BookingFile::ID_BOOKING, $booking['id_booking'])->whereAdd(BookingFile::DOCUMENT_TYPE, $this->setDocumentType('FreightForwarder'))->count();
     if ($freightForwarder) {
         $freightForwarder = BookingFileQuery::create()->whereAdd(BookingFile::ID_BOOKING, $booking['id_booking'])->whereAdd(BookingFile::DOCUMENT_TYPE, $this->setDocumentType('FreightForwarder'))->findOne()->getContent();
         $booking['freight_forwarder'] = basename($freightForwarder);
     }
     $BlMaster = BookingFileQuery::create()->whereAdd(BookingFile::ID_BOOKING, $booking['id_booking'])->whereAdd(BookingFile::DOCUMENT_TYPE, $this->setDocumentType('BlMaster'))->count();
     if ($BlMaster) {
         $BlMaster = BookingFileQuery::create()->whereAdd(BookingFile::ID_BOOKING, $booking['id_booking'])->whereAdd(BookingFile::DOCUMENT_TYPE, $this->setDocumentType('BlMaster'))->findOne()->getContent();
         $booking['bl_master'] = basename($BlMaster);
     }
     $myItinerary = ItineraryQuery::create()->whereAdd(Itinerary::ID_BOOKING, $id)->count();
     if ($myItinerary) {
         $myItinerary = ItineraryQuery::create()->whereAdd(Itinerary::ID_BOOKING, $id)->fetchAll();
         $booking['myItinerary'] = $myItinerary;
     }
     $this->view->booking = $booking;
     $this->view->setTpl('Details');
 }