Ejemplo n.º 1
0
 /**
  *
  * @return array
  */
 public function editAction()
 {
     try {
         $id = $this->getRequest()->getParam('id');
         $this->view->proformaInvoice = $proformaInvoice = ProformaInvoiceQuery::create()->findByPKOrThrow($id, $this->i18n->_("ProformaInvoice with id {$id} not found"));
         $accessRole = $this->getUser()->getAccessRole();
         $accessRoleManager = new AccessRoleManager();
         $suppliers = $accessRoleManager->getAssociateSuppliers($accessRole);
         if (!$suppliers->containsIndex($proformaInvoice->getIdSupplier())) {
             throw new ProformaInvoiceException($this->i18n->_("You don't have permission to edit this Proforma Invoice."));
         }
         $this->view->proformaInvoiceEntries = $proformaInvoiceEntries = ProformaInvoiceEntryQuery::create()->whereAdd(ProformaInvoiceEntry::ID_PROFORMA_INVOICE, $proformaInvoice->getIdProformaInvoice())->find();
         $this->view->locations = WarehouseQuery::create()->find()->toCombo($this->i18n->_("Select Warehouse Location"));
         if (!$proformaInvoiceEntries->isEmpty()) {
             $this->view->warehouseStore = $warehouseStore = WarehouseStoreQuery::create()->findByPKOrThrow($proformaInvoiceEntries->current()->getIdWarehouseStore(), $this->i18n->_("WarehouseStore with id {$proformaInvoiceEntries->current()->getIdWarehouseStore()} not found"));
             $this->view->warehouseStores = WarehouseStoreQuery::create()->whereAdd(WarehouseStore::LOCATION, $warehouseStore->getLocation())->find()->toCombo($this->i18n->_("Select Warehouse Store"));
             $this->view->products = ProductQuery::create()->whereAdd(Product::ITEM_CODE, $proformaInvoiceEntries->getIdProducts(), ProductQuery::IN)->find();
         } else {
             $this->view->warehouseStore = new Warehouse();
             $this->view->warehouseStores = array("" => $this->i18n->_("Select Warehouse Store"));
         }
         $this->view->forwarders = array("" => $this->i18n->_("Select Forwarder")) + ForwarderQuery::create()->find()->toCombo();
         if ($proformaInvoice->getIdCourtyard() > 0) {
             $this->view->courtyard = $courtyard = CourtyardQuery::create()->findByPKOrThrow($proformaInvoice->getIdCourtyard(), $this->i18n->_("Courtyard with id {$proformaInvoice->getIdCourtyard()} not found"));
             $this->view->portsCustom = array("" => $this->i18n->_("Select Port Custom")) + PortCustomQuery::create()->innerJoinForwarder()->whereAdd("Forwarder." . Forwarder::ID_FORWARDER, $courtyard->getIdForwarder())->find()->toCombo();
             $this->view->courtyards = array("" => $this->i18n->_("Select Courtyard")) + CourtyardQuery::create()->whereAdd(Courtyard::ID_PORT_CUSTOM, $courtyard->getIdPortCustom())->whereAdd(Courtyard::ID_FORWARDER, $courtyard->getIdForwarder())->find()->toCombo();
         } else {
             $this->view->courtyard = new Courtyard();
             $this->view->portCustoms = array("" => $this->i18n->_("Select Port Custom"));
             $this->view->courtyards = array("" => $this->i18n->_("Select Courtyard"));
         }
         $this->view->currencies = CurrencyQuery::create()->find();
         $this->view->events = EventQuery::create()->find();
         $paymentTerms = ProformaInvoicePaymentTermQuery::create()->whereAdd(ProformaInvoicePaymentTerm::ID_PROFORMA_INVOICE, $proformaInvoice->getIdProformaInvoice())->find();
         $proformaInvoiceProgrammedPayment = ProformaInvoiceProgrammedPaymentQuery::create()->whereAdd(ProformaInvoiceProgrammedPayment::ID_PROFORMA_INVOICE, $proformaInvoice->getIdProformaInvoice())->find();
         $purchaseOrderProgrammedPayment = PurchaseOrderProgrammedPaymentQuery::create()->whereAdd(PurchaseOrderProgrammedPayment::ID_PROFORMA_INVOICE_PAYMENT_TERM, $paymentTerms->getPrimaryKeys());
         $this->view->proformaInvoiceProgrammedPayment = $proformaInvoiceProgrammedPayment;
         $this->view->purchaseOrderProgrammedPayment = $purchaseOrderProgrammedPayment;
         $this->view->paymentTerms = $paymentTerms;
         $this->view->contentTitle = $this->i18n->_("Edit Proforma Invoice DocNum ") . $proformaInvoice->getSapDocumentNumber();
         $this->view->setTpl("Edit");
     } catch (Exception $e) {
         $this->setFlash('error', $this->i18n->_($e->getMessage()));
         $this->_redirect('proforma-invoice/list');
     }
 }
Ejemplo n.º 2
0
 /**
  *
  */
 public function exportToExcelAction()
 {
     $post = $this->getRequest()->getParams();
     $post['id_transit'] = "%" . $post['id_transit'] . "%";
     $freightFares = FreightFareQuery::create()->filter($post)->find();
     $i = 1;
     while ($freightFare = $freightFares->read()) {
         $port = \Application\Query\PortCustomQuery::create()->whereAdd(PortCustom::ID_PORT_CUSTOM, $freightFare->getFobPort())->findOne();
         $destination = \Application\Query\PortCustomQuery::create()->whereAdd(PortCustom::ID_PORT_CUSTOM, $freightFare->getDestinationPort())->findOne();
         $freightTYpe = FreightTypeQuery::create()->whereAdd(FreightType::ID_FREIGHT_TYPE, $freightFare->getIdFreightType())->findOne();
         $forwarder = ForwarderQuery::create()->whereAdd(Forwarder::ID_FORWARDER, $freightFare->getIdForwarder())->findOne();
         $currency = \Application\Query\CurrencyQuery::create()->whereAdd(\Application\Model\Bean\Currency::CURRCODE, $freightFare->getIdCurrency())->findOne();
         $data[$i] = array($freightFare->getIdFreightFare(), $freightFare->getIdTransit(), $port->getName(), $destination->getName(), $freightTYpe->getName(), $freightFare->getNotes(), $freightFare->getTt(), $freightFare->getFrecuency(), $forwarder->getName(), $freightFare->getGoodThrough(), $freightFare->getUnitName(), $freightFare->getUNitCost(), $freightFare->getPeak(), $freightFare->getStatusName());
         $i++;
     }
     $header = array($this->i18n->_('ID'), $this->i18n->_('ID-Transit'), $this->i18n->_('FOB Port'), $this->i18n->_('Destination Port'), $this->i18n->_('Freight Type'), $this->i18n->_('Notes'), $this->i18n->_('Transit Time'), $this->i18n->_('Frecuency'), $this->i18n->_('Forwarder'), $this->i18n->_('Good Through'), $this->i18n->_('Unit'), $this->i18n->_('Unit Cost'), $this->i18n->_('Peak/Unit'), $this->i18n->_('Status'));
     $title = $this->i18n->_('Freight Fares Report');
     $fileName = $this->i18n->_('Freight_fares_report');
     $tableColumnsWidth = array('mini', 'medium', 'medium', 'medium', 'medium', 'medium', 'medium', 'medium', 'medium', 'medium', 'mini', 'mini', 'mini');
     $report = new SimpleListReport();
     $report->setTableTitle($title);
     $report->setTableHeaders($header);
     $report->setTableContent($data);
     $report->setFilename($fileName);
     $report->setTableColumnsWidth($tableColumnsWidth);
     $report->createSpreadsheet();
 }
Ejemplo n.º 3
0
 /**
  *
  * @return array
  */
 public function editAction()
 {
     try {
         $this->view->contentTitle = $this->i18n->_("Purchase Order Edit");
         $idPurchaseOrder = $this->getRequest()->getParam('id');
         $this->view->purchaseOrder = $purchaseOrder = PurchaseOrderQuery::create()->findByPKOrThrow($idPurchaseOrder, $this->i18n->_("The Purchase Order width id {$idPurchaseOrder} does not exist"));
         $accessRole = $this->getUser()->getAccessRole();
         $accessRoleManager = new AccessRoleManager();
         $availableSuppliers = $accessRoleManager->getAssociateSuppliers($accessRole);
         if (!$availableSuppliers->containsIndex($purchaseOrder->getIdSupplier())) {
             throw new PurchaseOrderException($this->i18n->_("You don't have permission to edit this Purchase Order."));
         }
         $this->view->supplier = $supplier = $availableSuppliers->getByPK($purchaseOrder->getIdSupplier());
         // Search Purchase Order Entries by id purchase order
         $purchaseOrderEntryManager = new PurchaseOrderEntryManager();
         $purchaseOrderEntries = $purchaseOrderEntryManager->getPurchaseOrderEntries($purchaseOrder);
         $this->view->entries = Zend_Json::encode($purchaseOrderEntryManager->getEntriesToCompleteInfoArray($purchaseOrderEntries));
         // Search the courtyards by id
         if ($purchaseOrder->getIdCourtyard()) {
             $courtyard = CourtyardQuery::create()->findByPKOrElse($purchaseOrder->getIdCourtyard(), new Courtyard());
             if ($courtyard->getIdForwarder()) {
                 $ports = PortCustomQuery::create()->innerJoinForwarder()->whereAdd("Forwarder." . Forwarder::ID_FORWARDER, $courtyard->getIdForwarder())->find()->toCombo();
                 $portCombo = array("" => "Select a Port") + $ports;
                 $courtyards = CourtyardQuery::create()->whereAdd(Courtyard::ID_PORT_CUSTOM, $courtyard->getIdPortCustom())->whereAdd(Courtyard::ID_FORWARDER, $courtyard->getIdForwarder())->find()->toCombo();
                 $courtyardCombo = array("" => "Select Courtyard") + $courtyards;
             } else {
                 $portCombo = array("" => "Select a Port");
                 $courtyardCombo = array("" => "Select Courtyard");
             }
         } else {
             $courtyard = new Courtyard();
             $portCombo = array("" => "Select a Port");
             $courtyardCombo = array("" => "Select a Courtyard");
         }
         $this->view->forwarders = array("" => "Select Forwarder") + ForwarderQuery::create()->find()->toCombo();
         $this->view->portsCustom = $portCombo;
         $this->view->courtyards = $courtyardCombo;
         $this->view->courtyard = $courtyard;
         $this->view->currencies = CurrencyQuery::create()->find();
         $this->view->warehouses = WarehouseQuery::create()->find()->toCombo($this->i18n->_("Select a Warehouse"));
         $this->view->warehouseStore = $warehouseStore = WarehouseStoreQuery::create()->findByPKOrThrow($purchaseOrderEntries->getOne()->getIdWarehouseStore(), $this->i18n->_("The Warehouse Store with Code {$purchaseOrderEntries->current()->getIdWarehouseStore()} does not exist."));
         $this->view->warehouseStores = WarehouseStoreQuery::create()->whereAdd(WarehouseStore::LOCATION, $warehouseStore->getLocation())->whereAdd(WarehouseStore::TYPE, WarehouseStore::$Type["ppv"])->find()->toCombo($this->i18n->_("Select a Warehouse Store"));
         $this->view->status = array("" => $this->i18n->_("Select a Status"), PurchaseOrder::$Status["New"] => PurchaseOrder::$StatusNames[PurchaseOrder::$Status["New"]], PurchaseOrder::$Status["Ready"] => PurchaseOrder::$StatusNames[PurchaseOrder::$Status["Ready"]]);
         $this->view->uploadBLHouseStatus = PurchaseOrder::$Status["Ready"];
         $this->view->purchaseOrderCommercialInvoice = PurchaseOrderCommercialInvoiceQuery::create()->whereAdd(PurchaseOrderCommercialInvoice::ID_PURCHASE_ORDER, $purchaseOrder->getIdPurchaseOrder())->findOneOrElse(new PurchaseOrderCommercialInvoice());
         $purchaseOrderPaymentsManager = new PurchaseOrderPaymentsManager();
         $this->view->payments = Zend_Json::encode($purchaseOrderPaymentsManager->getCondensedPayments($purchaseOrder));
     } catch (Exception $e) {
         $this->setFlash('error', $e->getMessage());
         $this->_redirect('purchase-order/list');
     }
 }
Ejemplo n.º 4
0
 /**
  *
  */
 public function exportToExcelAction()
 {
     $params = $this->getRequest()->getParams();
     $query = FolioImportQuery::create()->filter($params)->find();
     $report = new SimpleListReport();
     $headers = array('ID', 'Folio', 'Departure Port', 'Forwarder', 'Destination Port', 'Customs Broker', 'Status');
     $i = 0;
     while ($folioImport = $query->read()) {
         $content[$i][] = $folioImport->getIdFolioImport();
         $content[$i][] = $folioImport->getFolio();
         $content[$i][] = PortCustomQuery::create()->findByPK($folioImport->getIdPortDestination())->getName();
         $content[$i][] = ForwarderQuery::create()->findByPK($folioImport->getIdForwarder())->getName();
         $content[$i][] = PortCustomQuery::create()->findByPK($folioImport->getIdPortCustom())->getName();
         $idCustomsBroker = $folioImport->getIdCustomsBroker();
         if (!empty($idCustomsBroker)) {
             $content[$i][] = CustomsBrokerQuery::create()->findByPK($folioImport->getIdCustomsBroker())->getName();
         } else {
             $content[$i][] = 'Not Available';
         }
         $content[$i][] = $folioImport->getStatusName();
         $i++;
     }
     $title = $this->i18n->_('Folio Import Report');
     $filename = 'folio_import_report';
     $report->setTableHeaders($headers);
     $report->setTableContent($content);
     $report->setTableTitle($title);
     $report->setFilename($filename);
     $report->createSpreadsheet();
 }
Ejemplo n.º 5
0
 /**
  * This action create a new forwarder's contact
  *
  * @author Erick Guevara Martínez
  * @return json
  */
 public function createnewforwardercontactAction()
 {
     if ($this->getRequest()->isPost()) {
         $params = $this->getRequest()->getParams();
         try {
             $contact = ContactFactory::createFromArray($params["contact"]);
             if ($params["contact"]["id_forwarder"] != "") {
                 $forwarder = ForwarderQuery::create()->findByPK($params["contact"]["id_forwarder"]);
                 $contact->setIdCompany($forwarder->getIdCompany());
             } else {
                 $forwarder = new Forwarder();
             }
             $this->getCatalog("ContactCatalog")->create($contact);
             foreach ($params["contact"]["phones"] as $phone) {
                 if (strlen($phone["number"]) > 0) {
                     $phoneNumbers = Application\Model\Factory\PhoneNumberFactory::createFromArray($phone);
                     $this->getCatalog("PhoneNumberCatalog")->create($phoneNumbers);
                 }
             }
             if (strlen($params["contact"]["email"]) > 0) {
                 $email = Application\Model\Factory\EmailFactory::createFromArray($params["contact"]);
                 $this->getCatalog("EmailCatalog")->create($email);
                 $this->getCatalog("ContactCatalog")->linkToEmail($contact->getIdPerson(), $email->getIdEmail(), $type);
             }
             $address = AddressFactory::createFromArray($params["contact"]);
             $this->getCatalog("AddressCatalog")->create($address);
             $this->getCatalog("ContactCatalog")->linkToAddress($contact->getIdPerson(), $address->getIdAddress(), $type);
             //$this->getCatalog("ContactCatalog")->commit();
             $response = array("result" => "ok", "contactId" => $contact->getIdContact(), "contactName" => $contact->getName(), "forwarderId" => $forwarder->getIdForwarder());
         } catch (Exception $e) {
             $response = array("result" => "error", "message" => $e->getMessage());
         }
         die(Zend_Json::encode($response));
     }
 }
Ejemplo n.º 6
0
 /**
  * 
  */
 public function getListResultsAction()
 {
     $params = $this->getRequest()->getParams();
     $params['name'] = "%" . $params['name'] . "%";
     $forwarders = ForwarderQuery::create()->filter($params)->page($params['page'], $this->getMaxPerPage())->find();
     die(json_encode($forwarders->toArray()));
 }
Ejemplo n.º 7
0
 /**
  * 
  * @return string
  */
 public function getForwarderName()
 {
     $forwarderName = null;
     if (ForwarderQuery::create()->whereAdd(Forwarder::ID_FORWARDER, $this->idForwarder)->count()) {
         $forwarderName = ForwarderQuery::create()->findByPK($this->idForwarder)->getName();
     }
     return $forwarderName;
 }
Ejemplo n.º 8
0
 /**
  *
  * @param unknown_type $idFolioImport
  */
 private function getFolioImportForwarder($idFolioImport)
 {
     $idForwarder = FolioImportQuery::create()->findByPK($idFolioImport)->getIdForwarder();
     $value = ForwarderQuery::create()->findByPK($idForwarder)->getName();
     return $value;
 }
Ejemplo n.º 9
0
 /**
  * This action display the view to china agents
  *
  * @author Erick Guevara Martínez
  */
 public function entriesAction()
 {
     // Get criteria to filter requisition entries
     if ($this->getRequest()->isPost()) {
         $post[RequisitionEntry::ID_REQUISITION] = $this->getRequest()->getParam(RequisitionEntry::ID_REQUISITION);
         $post[RequisitionEntry::STATUS] = $this->getRequest()->getParam(RequisitionEntry::STATUS);
         $post["id_supplier"] = $this->getRequest()->getParam("id_supplier", "");
         $post["id_destination_country"] = $this->getRequest()->getParam("id_destination_country", "");
         $post["startDate"] = $this->getRequest()->getParam("startDate", "");
         $post["endDate"] = $this->getRequest()->getParam("endDate", "");
         $post["key_mother"] = $this->getRequest()->getParam("key_mother", "");
         $post["order"] = $this->getRequest()->getParam("order", "");
     }
     $accessRole = $this->getUser()->getAccessRole();
     $accessRoleManager = new AccessRoleManager();
     $suppliers = $accessRoleManager->getAssociateSuppliers($accessRole);
     $products = ProductQuery::create()->whereAdd(Product::ID_SUPPLIER, $suppliers->getPrimaryKeys())->find();
     // Creates an array with the status can be displayed in this view
     $allowedStatus = array("Pending Price" => RequisitionEntry::$Status["Pending Price"], "Pending Price Auth" => RequisitionEntry::$Status["Pending Price Auth"], "PI Requested" => RequisitionEntry::$Status["PI Requested"]);
     // If don't have a status filter then search by allowed status
     $requisitionEntriesQuery = RequisitionEntryQuery::create()->filter($post)->whereAdd(RequisitionEntry::ID_PRODUCT, $products->getPrimaryKeys());
     if ($post[RequisitionEntry::STATUS] == "") {
         $requisitionEntriesQuery->whereAdd("RequisitionEntry." . RequisitionEntry::STATUS, $allowedStatus, BaseQuery::IN);
     }
     // Filter all requisition entries belonging to a requisition with the same
     if ($post["id_destination_country"] != "") {
         $requisitionEntriesQuery->innerJoinRequisition()->whereAdd("Requisition." . Requisition::ID_DESTINATION_COUNTRY, $post["id_destination_country"]);
     }
     // Filter all requisition entries with a supplier default or a bentchmarcking that equal to id_supplier filter param
     if ($post["id_supplier"] != "") {
         $requisitionEntriesQuery->innerJoinKeyMotherSupplierBudget()->whereAdd("KeyMotherSupplierBudget." . KeyMotherSupplierBudget::ID_SUPPLIER, $post["id_supplier"]);
     }
     // Filter all requisition entries with a supplier default or a bentchmarcking that equal to id_supplier filter param
     if ($post["key_mother"] != "") {
         $requisitionEntriesQuery->whereAdd("RequisitionEntry." . RequisitionEntry::ID_PRODUCT, $post["key_mother"], RequisitionEntryQuery::LIKE);
     }
     if ($post["order"] == "date_asc" || $post["order"] == "date_desc") {
         $requisitionEntriesQuery->addAscendingOrderBy("RequisitionEntry." . RequisitionEntry::CREATION_DATE);
     } else {
         $requisitionEntriesQuery->addAscendingOrderBy("RequisitionEntry." . RequisitionEntry::ID_PRODUCT);
     }
     $requisitionEntries = $requisitionEntriesQuery->find();
     // If have more than 1 requisition entry then get extra info to requisition
     $parentKeys = array();
     $requisitions = new RequisitionCollection();
     $budgets = new KeyMotherSupplierBudgetCollection();
     if ($requisitionEntries->count() > 0) {
         $products = $products->filterByPks($requisitionEntries->getDistinctProducts())->orderByArrayPks($requisitionEntries->getDistinctProducts());
         $parentKeys = $products->getKeyMother();
         $requisitions = RequisitionQuery::create()->whereAdd(Requisition::ID_REQUISITION, $requisitionEntries->getDistinctRequisitions(), RequisitionQuery::IN)->find();
         if (count($parentKeys) > 0) {
             $budgets = KeyMotherSupplierBudgetQuery::create()->whereAdd(KeyMotherSupplierBudget::KEY_MOTHER, $parentKeys, KeyMotherSupplierBudgetQuery::IN)->actives()->find();
         }
     }
     // Proccess and group all requisition entries by parent key
     $requisitionEntriesGroupByParentKey = array();
     foreach ($parentKeys as $parentKey) {
         // Get all products belonging to current parent key
         $parentKeyProducts = $products->filterByKeyMother($parentKey);
         // Get all requisition entries belonging to products of a current parent key
         $parentKeyRequisitionEntries = $requisitionEntries->filterByIdProduct($parentKeyProducts->getPrimaryKeys());
         // Set Headers to group
         $requisitionEntriesGroupByParentKey[$parentKey]["header"]["parentKey"] = $parentKey;
         $requisitionEntriesGroupByParentKey[$parentKey]["header"]["description"] = $parentKeyProducts->current()->getItemName();
         $requisitionEntriesGroupByParentKey[$parentKey]["header"]["idDefaultProduct"] = $parentKeyProducts->current()->getItemCode();
         $requisitionEntriesGroupByParentKey[$parentKey]["header"]["firstRequisitionDate"] = $parentKeyRequisitionEntries->getFirstCreationDate();
         // Set a current supplier default name, in case of this don't have suppliers then set "-"
         if ($parentKeyRequisitionEntries->getRecurrentSupplierDefault() == null) {
             $requisitionEntriesGroupByParentKey[$parentKey]["header"]["supplierSapBussinessCode"] = "-";
         } else {
             $supplier = $suppliers->getByPK($parentKeyRequisitionEntries->getRecurrentSupplierDefault());
             if (!$supplier) {
                 $supplier = new SapSupplier();
             }
             $requisitionEntriesGroupByParentKey[$parentKey]["header"]["supplierSapBussinessCode"] = $supplier ? $supplier->getCardCode() : 'Error';
             $requisitionEntriesGroupByParentKey[$parentKey]["header"]["supplierName"] = $supplier->getName();
         }
         $requisitionEntriesGroupByParentKey[$parentKey]["header"]["totalQuantity"] = $parentKeyRequisitionEntries->getTotalQuantity();
         $requisitionEntriesGroupByParentKey[$parentKey]["header"]["targetPrice"] = $parentKeyProducts->current()->getCost();
         // Check if the min open price is less than target price, then set the lower of two
         if ($parentKeyProducts->current()->getCost() > 0) {
             $minPrice = $parentKeyProducts->current()->getCost() < $parentKeyRequisitionEntries->getMinOpenPrice() ? $parentKeyProducts->current()->getCost() : $parentKeyRequisitionEntries->getMinOpenPrice();
         } else {
             $minPrice = $parentKeyRequisitionEntries->getMinOpenPrice();
         }
         $requisitionEntriesGroupByParentKey[$parentKey]["header"]["minOpenPrice"] = $minPrice;
         $requisitionEntriesGroupByParentKey[$parentKey]["header"]["MOPTotalImport"] = $parentKeyRequisitionEntries->getTotalQuantity() * $minPrice;
         // Check if the parent key have budgets then set true or if it don't have budgets then set false
         $parentKeyBudgets = $budgets->filterByKeyMother($parentKey);
         $requisitionEntriesGroupByParentKey[$parentKey]["header"]["hasBudgets"] = $parentKeyBudgets->count() > 0 ? true : false;
         // Check if a key mother budget is autorized (prevent to no save more budgets when one key mother budget is autoprized)
         $requisitionEntriesGroupByParentKey[$parentKey]["header"]["hasAutorizedBudget"] = $parentKeyBudgets->checkAutorized();
         // Set all requisition entries of the parent key
         $requisitionEntriesGroupByParentKey[$parentKey]["requisitionEntries"] = $parentKeyRequisitionEntries;
         $requisitionEntriesGroupByParentKey[$parentKey]["autorizedBudget"] = $parentKeyBudgets->getAutorizedOrElse(new KeyMotherSupplierBudget());
     }
     if ($post["order"] == "date_desc") {
         $requisitionEntriesGroupByParentKey = array_reverse($requisitionEntriesGroupByParentKey);
     }
     // Assign all information to view
     $this->view->requisitions = $requisitions;
     $this->view->contentTitle = $this->i18n->_("Open Requisition by Item");
     $this->view->emptySupplier = new SapSupplier();
     $this->view->requisitionEntriesGroupByParentKey = $requisitionEntriesGroupByParentKey;
     $this->view->products = $products;
     $this->view->suppliers = $suppliers;
     $this->view->incoterms = array("" => $this->i18n->_("Select a Incoterm")) + IncotermQuery::create()->find()->toCombo();
     $this->view->currencies = $currencies = CurrencyQuery::create()->find();
     $this->view->currenciesToCombo = array("" => $this->i18n->_("Select a Currency")) + $currencies->toCombo();
     $this->view->status = array("" => $this->i18n->_("All")) + array_flip($allowedStatus);
     $this->view->allowedStatus = $allowedStatus;
     $this->view->countries = array("" => $this->i18n->_("All")) + CountryQuery::create()->find()->toCombo();
     $this->view->forwarders = array("" => $this->i18n->_("Select a Forwarder")) + ForwarderQuery::create()->actives()->find()->toCombo();
     $this->view->special = Requisition::$Type['Quick'];
     $this->view->portsCustom = array("" => $this->i18n->_("Select a Port Custom"));
     $this->view->courtyards = array("" => $this->i18n->_("Select a Courtyard"));
     $this->view->order = array("" => $this->i18n->_("Select a Order"), "date_asc" => $this->i18n->_("By First Date"), "date_desc" => $this->i18n->_("By Last Date"), "product" => $this->i18n->_("By Product"));
     $this->view->setTpl("Entries");
 }
Ejemplo n.º 10
0
 /**
  * 
  * @throws \Exception
  */
 public function updateData()
 {
     $phpExcel = $this->getPhpExcel();
     $activeSheet = $phpExcel->getActiveSheet();
     $highestColumn = $activeSheet->getHighestColumn();
     $highestRow = $activeSheet->getHighestRow();
     $modifiedFreightFareCollection = new FreightFareCollection();
     $modifiedFreightFareArray = array();
     $originalFreightFaresArray = array();
     if ($highestRow > 1000) {
         throw new \Exception('The file is very big');
     }
     $headers = $activeSheet->rangeToArray('A3:' . $highestColumn . '3');
     if (!$this->validateFile($headers[2])) {
         throw new \Exception('This file does not contain valid content to update the data');
     }
     for ($row = 4; $row <= $highestRow; $row++) {
         $rowArray = $activeSheet->rangeToArray('A' . $row . ':' . $highestColumn . $row);
         $fields = $this->setRowArrayKeys($rowArray[$row - 1]);
         $modifiedFreightFaresArray[] = $fields;
         $originalFreightFaresArray[$fields['ID']] = $fields['ID'];
     }
     $forwarderCollection = ForwarderQuery::create()->find();
     $customPortCollection = PortCustomQuery::create()->find();
     $freightTypeCollection = FreightTypeQuery::create()->find();
     $originalFreightFareCollection = FreightFareQuery::create()->whereAdd(FreightFare::ID_FREIGHT_FARE, $originalFreightFaresArray)->find();
     $modified = 0;
     $created = 0;
     foreach ($modifiedFreightFaresArray as $modifiedFreightFare) {
         $destinationPort = $customPortCollection->getByName($modifiedFreightFare['Destination Port']);
         $fobPort = $customPortCollection->getByName($modifiedFreightFare['FOB Port']);
         $forwarder = $forwarderCollection->getByName($modifiedFreightFare['Forwarder']);
         $freightType = $freightTypeCollection->getByName($modifiedFreightFare['Freight Type']);
         $freightFare = $originalFreightFareCollection->getByPK($modifiedFreightFare['ID']);
         $freightFare->setIdFreightFare($modifiedFreightFare['ID']);
         if ($freightFare instanceof FreightFare) {
             if ($fobPort) {
                 $freightFare->setFobPort($fobPort->getIdPortCustom());
             }
             if ($destinationPort) {
                 $freightFare->setDestinationPort($destinationPort->getIdPortCustom());
             }
             if ($freightType) {
                 $freightFare->setIdFreightType($freightType->getIdFreightType());
             }
             if ($forwarder) {
                 $freightFare->setIdForwarder($forwarder->getIdForwarder());
             }
             $freightFare->setIdTransit($modifiedFreightFare['ID-Transit']);
             $freightFare->setNotes($modifiedFreightFare['Notes']);
             $freightFare->setTt($modifiedFreightFare['Transit Time']);
             $freightFare->setFrecuency($modifiedFreightFare['Frecuency']);
             $freightFare->setGoodThrough($modifiedFreightFare['Good Through']);
             $freightFare->setUnit(FreightFare::$Units[$modifiedFreightFare['Unit']]);
             $freightFare->setUnitCost($modifiedFreightFare['Fare']);
             $freightFare->setPeak($modifiedFreightFare['Peak/Unit']);
             $freightFare->setStatus(FreightFare::$Status[$modifiedFreightFare['Status']]);
             $this->getFreightFareCatalog()->beginTransaction();
             try {
                 $this->getFreightFareCatalog()->update($freightFare);
             } catch (\Exception $e) {
                 throw e;
                 $this->getFreightFareCatalog()->rollBack();
             }
             $this->getFreightFareCatalog()->commit();
             return true;
         } else {
         }
     }
 }
Ejemplo n.º 11
0
 private function getFolioInformation()
 {
     $this->Ln();
     $border = false;
     $this->SetLineWidth(0.1);
     $this->SetFillColor(225, 225, 225);
     $fill = false;
     $cellHeight = $this->regularSize / 1.5;
     //encabezado de las tablas
     $this->SetFont($this->FontType, $this->titleStyle, $this->titleSize);
     $this->Cell(self::CellXXLarge, $cellHeight, 'Folio Import Information', $border, 0, 'L');
     $this->Cell(self::CellSmall, $cellHeight, ' ', false, 0, 'L');
     $this->Cell(self::CellXXLarge, $cellHeight, 'Increasable Freight', $border, 0, 'L');
     $this->Cell(self::CellSmall, $cellHeight, ' ', false, 0, 'L');
     $this->Cell(self::CellXXLarge, $cellHeight, 'Import License Information', $border, 'L', false, 0);
     $this->Cell(self::CellSmall, $cellHeight, ' ', false, 0, 'L');
     $this->Ln();
     //Contenido
     $this->SetFont($this->FontType, $this->FontStyle, $this->regularSize);
     //folio
     $this->Cell(self::CellMedium, $cellHeight, 'Folio', $border, 0, 'L');
     $this->Cell(self::CellLarge, $cellHeight, $this->folioImport->getFolio(), $border, 0, 'R');
     $this->Cell(self::CellSmall, $cellHeight, ' ', false, 0, 'L');
     //Increasable Freight
     $this->Cell(self::CellMedium, $cellHeight, 'Increasable Freight', $border, 0, 'L');
     $this->Cell(self::CellLarge, $cellHeight, '$' . number_format($this->booking->getIncreasableFreight(), 4) . 'USD', $border, 0, 'R');
     $this->Cell(self::CellSmall, $cellHeight, ' ', false, 0, 'L');
     //Import Licence Number
     $this->Cell(self::CellMedium, $cellHeight, 'Import Licence Number', $border, 0, 'L', $fill);
     $this->Cell(self::CellLarge, $cellHeight, $this->folioImport->getImportLicence(), $border, 0, 'R');
     $this->Cell(self::CellSmall, $cellHeight, ' ', false, 0, 'L');
     $this->Ln();
     $forwarder = ForwarderQuery::create()->findByPK($this->folioImport->getIdForwarder())->getName();
     //forwarder
     $this->Cell(self::CellMedium, $cellHeight, 'Forwarder', $border, 0, 'L');
     $this->Cell(self::CellLarge, $cellHeight, $forwarder, $border, 0, 'R');
     $this->Cell(self::CellSmall, $cellHeight, ' ', false, 0, 'L');
     //Increasable Insurance
     $this->Cell(self::CellMedium, $cellHeight, 'Increasable Insurance', $border, 0, 'L');
     $this->Cell(self::CellLarge, $cellHeight, '$' . number_format($this->booking->getIncreasableInsurance(), 4) . 'USD', $border, 0, 'R');
     $this->Cell(self::CellSmall, $cellHeight, ' ', false, 0, 'L');
     //origin seal
     $this->Cell(self::CellMedium, $cellHeight, 'Origin Seal', $border, 0, 'L');
     $this->Cell(self::CellLarge, $cellHeight, $this->folioImport->getOrigenSell(), $border, 0, 'R');
     $this->Cell(self::CellSmall, $cellHeight, ' ', false, 0, 'L');
     $this->Ln();
     //folio
     $this->Cell(self::CellMedium, $cellHeight, 'ETD', $border, 0, 'L');
     $this->Cell(self::CellLarge, $cellHeight, $this->booking->getEtd(), $border, 0, 'R');
     $this->Cell(self::CellSmall, $cellHeight, ' ', false, 0, 'L');
     //Increasable Freight
     $this->Cell(self::CellMedium, $cellHeight, 'Total', $border, 0, 'L');
     $this->Cell(self::CellLarge, $cellHeight, '$' . number_format($this->booking->getTotalIncreasable(), 4) . 'USD', $border, 0, 'R');
     $this->Cell(self::CellSmall, $cellHeight, ' ', false, 0, 'L');
     //Import Licence Number
     $this->Cell(self::CellMedium, $cellHeight, 'Customs Seal', $border, 0, 'L');
     $this->Cell(self::CellLarge, $cellHeight, $this->folioImport->getCustomsSell(), $border, 0, 'R');
     $this->Cell(self::CellSmall, $cellHeight, ' ', false, 0, 'L');
     $this->Ln();
     //folio
     $this->Cell(self::CellMedium, $cellHeight, 'ETA', $border, 0, 'L');
     $this->Cell(self::CellLarge, $cellHeight, $this->booking->getEta(), $border, 0, 'R');
     $this->Cell(self::CellSmall, $cellHeight, ' ', false, 0, 'L');
     //Increasable Freight
     $this->SetFont($this->FontType, $this->titleStyle, $this->titleSize);
     $this->Cell(self::CellXXLarge, $cellHeight, 'Not Increasable Freight', $border, 'L', false, 0);
     $this->Cell(self::CellSmall, $cellHeight, ' ', false, 0, 'L');
     $this->Ln();
     $this->SetFont($this->FontType, $this->FontStyle, $this->regularSize);
     //Pieces - Cartons
     $this->Cell(self::CellMedium, $cellHeight, 'Pieces - Cartons', $border, 0, 'L');
     $this->Cell(self::CellLarge, $cellHeight, $this->totalPieces . ' - ' . $this->totalCartons, $border, 0, 'R');
     $this->Cell(self::CellSmall, $cellHeight, ' ', false, 0, 'L');
     //Not Increasable Freight
     $this->Cell(self::CellMedium, $cellHeight, 'Not Increasable Freight', $border, 0, 'L');
     $this->Cell(self::CellLarge, $cellHeight, '$' . number_format($this->booking->getNotIncreasableFreight(), 4) . 'USD', $border, 0, 'R');
     $this->Cell(self::CellSmall, $cellHeight, ' ', false, 0, 'L');
     $this->Ln();
     //Pieces - Cartons
     $this->Cell(self::CellMedium, $cellHeight, 'Weight', $border, 0, 'L');
     $this->Cell(self::CellLarge, $cellHeight, number_format($this->totalWeight, 4) . 'kg', $border, 0, 'R');
     $this->Cell(self::CellSmall, $cellHeight, ' ', false, 0, 'L');
     //Not Increasable Freight
     $this->Cell(self::CellMedium, $cellHeight, 'Total', $border, 0, 'L');
     $this->Cell(self::CellLarge, $cellHeight, '$' . number_format($this->booking->getTotalNotIncreasable(), 4) . 'USD', $border, 0, 'R');
     $this->Cell(self::CellSmall, $cellHeight, ' ', false, 0, 'L');
     // 		$this->Cell(self::CellMedium, $cellHeight, 'Not Increasable Insurance', $border, 0, 'L');
     // 		$this->Cell(self::CellLarge, $cellHeight, '$'.number_format($this->booking->getNotIncreasableInsurance(),4).'USD', $border, 0, 'R');
     // 		$this->Cell(self::CellSmall, $cellHeight, ' ', false, 0, 'L');
     $this->Ln();
     //Pieces - Cartons
     $this->Cell(self::CellMedium, $cellHeight, 'Volume', $border, 0, 'L');
     // 		$this->Cell(self::CellLarge, $cellHeight, $this->totalVolume.'cbm' , $border, 0, 'R');
     $this->Cell(self::CellLarge, $cellHeight, number_format($this->totalVolume, 4) . 'cbm', $border, 0, 'R');
     $this->Cell(self::CellSmall, $cellHeight, ' ', false, 0, 'L');
     //Not Increasable Freight
     $this->Ln();
     //Load Cost
     $this->Cell(self::CellMedium, $cellHeight, 'Load Cost', $border, 0, 'L');
     $this->Cell(self::CellLarge, $cellHeight, '$' . number_format($this->loadCost, 4) . 'USD', $border, 0, 'R');
     $this->Cell(self::CellSmall, $cellHeight, ' ', false, 0, 'L');
     $this->Ln();
     //Exchange rate
     $this->SetFont($this->FontType, $this->titleStyle, $this->titleSize);
     $this->Cell(self::CellXXLarge, $cellHeight, 'Exchange Rate', $border, 0, 'L');
     $this->Ln();
     $this->SetFont($this->FontType, $this->FontStyle, $this->regularSize);
     //Pieces - Cartons
     $this->Cell(self::CellMedium, $cellHeight, 'EUR => USD', $border, 0, 'L');
     $this->Cell(self::CellLarge, $cellHeight, number_format($this->folioImport->getExchangeEuroToDollar(), 4), $border, 0, 'R');
     $this->Cell(self::CellSmall, $cellHeight, ' ', false, 0, 'L');
     $this->Ln();
     //Pieces - Cartons
     $this->Cell(self::CellMedium, $cellHeight, 'USD => MXP', $border, 0, 'L');
     $this->Cell(self::CellLarge, $cellHeight, number_format($this->folioImport->getExchangeDollarToPeso(), 4), $border, 0, 'R');
     $this->Cell(self::CellSmall, $cellHeight, ' ', false, 0, 'L');
     $this->Ln();
     $this->Ln();
     $this->Ln();
 }