Example #1
0
 /**
  *
  * @return array
  */
 public function editAction()
 {
     $params = $this->getRequest()->getParams();
     $id = $this->view->id = $params['id'];
     $portQuery = PortCustomQuery::create()->addColumn(PortCustom::NAME)->actives()->fetchAll();
     $warehouseQuery = WarehouseQuery::create()->addColumn(Warehouse::NAME)->actives()->fetchAll();
     $transportCount = TransportQuery::create()->whereAdd(Transport::ID_BOOKING, $id)->count();
     $transportQuery = TransportQuery::create()->whereAdd(Transport::ID_BOOKING, $id)->fetchAll();
     foreach ($portQuery as $port) {
         $ports[$port['name']] = $port['name'];
     }
     foreach ($warehouseQuery as $warehouse) {
         $warehouses[$warehouse['name']] = $warehouse['name'];
     }
     $places[''] = $this->i18n->_('Select a source');
     $places[$this->i18n->_('Ports')] = $ports;
     $places[$this->i18n->_('Warehouses')] = $warehouses;
     $this->view->sources = $places;
     $places[''] = $this->i18n->_('Select a destination');
     $this->view->destinations = $places;
     $this->view->transportCount = $transportCount;
     $this->view->transports = $transportQuery;
     $this->view->contentTitle = "New Transportation";
     $this->view->onSubmit = 'update';
     $this->view->setTpl('Form');
 }
Example #2
0
 /**
  *
  * @return array
  */
 public function listAction()
 {
     $this->view->page = $page = $this->getRequest()->getParam('page') ?: 1;
     if ($this->getRequest()->isPost()) {
         $this->view->post = $post = $this->getRequest()->getParams();
     }
     $total = CourtyardQuery::create()->filter($post)->count();
     $this->view->courtyards = $courtyards = CourtyardQuery::create()->filter($post)->page($page, $this->getMaxPerPage())->find();
     $this->view->paginator = $this->createPaginator($total, $page);
     $this->view->addresses = \Application\Query\AddressQuery::create()->find()->toCombo();
     $this->view->portCustoms = \Application\Query\PortCustomQuery::create()->find()->toCombo();
 }
 /**
  *
  * @author Jose Luis Suarez Nieto
  * @return array
  */
 public function editAction()
 {
     $id = $this->getRequest()->getParam('id');
     $customsBroker = CustomsBrokerQuery::create()->findByPKOrThrow($id, $this->i18n->_("The Customs Agent with id {$id} doesn't exist"));
     $this->view->selectedPorts = CustomsBrokerQuery::create()->addColumn('CustomsBroker2PortCustom.id_port_custom')->innerJoinPortCustom()->whereAdd('CustomsBroker2PortCustom.id_customs_broker', $id)->fetchCol();
     $this->view->departurePorts = $departurePorts = PortCustomQuery::create()->actives()->find()->toCombo();
     $myIdAddress = CompanyQuery::create()->addColumn('Company2Address.id_address')->innerJoinAddress()->whereAdd('Company2Address.id_company', $customsBroker->getIdCompany())->fetchCol();
     $this->view->file = $file = FileQuery::create()->whereAdd('File.' . File::ID_FILE, $customsBroker->getIdLastFeeFile())->findOne();
     $this->view->address = AddressQuery::create()->findByPK($myIdAddress[0])->toArray();
     $this->view->customsBroker = $customsBroker;
     $this->view->countries = array("" => "Select Country") + Application\Query\CountryQuery::create()->find()->toCombo();
     $this->view->contentTitle = 'Edit Customs Broker';
     $this->view->id = $id;
     $this->view->sapIdBussinessAssociate = $customsBroker->getSapIdBussinessAssociate();
     $this->view->name = $customsBroker->getName();
     $this->view->payment = $customsBroker->getPayment();
     $this->view->idCompany = $customsBroker->getIdCompany();
     $this->view->idAddress = $myIdAddress[0];
     $this->view->edition = 1;
     $this->view->action = 'update';
     $this->view->setTpl('Form');
 }
Example #4
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();
 }
 /**
  *
  * @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');
     }
 }
Example #6
0
 /**
  * 
  * @param unknown_type $idFolioImport
  */
 private function getFolioImportDestinationPort($idFolioImport)
 {
     $idPort = FolioImportQuery::create()->findByPK($idFolioImport)->getIdPortDestination();
     $value = PortCustomQuery::create()->findByPK($idPort)->getName();
     return $value;
 }
Example #7
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();
 }
Example #8
0
 /**
  *
  * @param int $id
  * @return array
  */
 private function getFreightInformation($idFreightFare)
 {
     $freightFareQuery = $idFreightFare ? FreightFareQuery::create()->findByPKOrElse($idFreightFare, new FreightFare()) : new FreightFare();
     $origin = $freightFareQuery->getFobPort() ? PortCustomQuery::create()->findByPKOrElse($freightFareQuery->getFobPort(), new PortCustom()) : new PortCustom();
     $destination = $freightFareQuery->getDestinationPort() ? PortCustomQuery::create()->findByPKOrElse($freightFareQuery->getDestinationPort(), new FreightFare()) : new PortCustom();
     $freightFare['id_freight_fare'] = $idFreightFare;
     $freightFare['origin'] = $origin->getName();
     $freightFare['destination'] = $destination->getName();
     $freightFare['good_trough'] = $freightFareQuery->getGoodThrough();
     $freightFare['unit_cost'] = $freightFareQuery->getUnitCost();
     $freightFare['transit_time'] = $freightFareQuery->getTt();
     $goodTrough = new DateTime($freightFareQuery->getGoodThrough());
     $today = new DateTime("now");
     $interval = $today->diff($goodTrough);
     $difference = $interval->format('%r%a');
     if ($difference <= 0) {
         $status = 'error';
     } else {
         if ($difference < 30) {
             $status = 'warning';
         } else {
             $status = 'ok';
         }
     }
     $freightFare['difference'] = $difference;
     $freightFare['status'] = $status;
     return $freightFare;
 }
Example #9
0
 public function editAction()
 {
     $this->view->action = "update";
     $this->view->contentTitle = 'Edit Supplier';
     $this->view->setTpl('Form');
     $cardcode = $this->getRequest()->getParam('id');
     $supplier = SapSupplierQuery::create()->findByPK($cardcode);
     // 		echo '<pre>';
     // 		print_r($supplier->toArray());
     // 		die;
     if (SapSupplierAddressQuery::create()->whereAdd(SapSupplierAddress::TABLENAME . '.' . SapSupplierAddress::CARDCODE, $cardcode)->count()) {
         $address = SapSupplierAddressQuery::create()->whereAdd(SapSupplierAddress::TABLENAME . '.' . SapSupplierAddress::CARDCODE, $cardcode)->findOne();
     } else {
         $address = new SapSupplierAddress();
     }
     $contacts = SapSupplierContactEmployeeQuery::create()->whereAdd(SapSupplierContactEmployee::CARDCODE, $cardcode)->orderBy(SapSupplierContactEmployee::ID_CONTACT_EMPLOYEE, SapSupplierContactEmployeeQuery::ASC)->find();
     $this->view->setupForm = SupplierFileQuery::create()->whereAdd(SupplierFile::ID_SUPPLIER, $cardcode)->whereAdd(SupplierFile::DOCUMENT_TYPE, SapSupplier::$FileTypes['SetupForm'])->count();
     $this->view->profileForm = SupplierFileQuery::create()->whereAdd(SupplierFile::ID_SUPPLIER, $cardcode)->whereAdd(SupplierFile::DOCUMENT_TYPE, SapSupplier::$FileTypes['ProfileForm'])->count();
     $this->view->auditReport = SupplierFileQuery::create()->whereAdd(SupplierFile::ID_SUPPLIER, $cardcode)->whereAdd(SupplierFile::DOCUMENT_TYPE, SapSupplier::$FileTypes['AuditReport'])->count();
     $this->view->supplier = $supplier->toArray();
     $this->view->address = $address->toArray();
     $this->view->contacts = $contacts->toArray();
     $this->view->CardCode = $cardcode;
     $this->view->portCustom = $portCustom = array('' => $this->i18n->_("Select Port")) + PortCustomQuery::create()->find()->toCombo();
     $this->view->paymentTerm = $paymentTerm = array('' => $this->i18n->_("Select Payment Term")) + PaymentTermQuery::create()->find()->toCombo();
     $this->view->selectOption = self::$AprovalStatus;
     $this->view->finalOption = self::$FinalGrandRisk;
     $this->view->currencies = self::getCurrencies();
     $this->view->typePersons = self::getTypePersons();
     $this->view->country = self::getCountries();
     if ($supplier->getCurrency() == '##') {
         $this->view->editCurrency = false;
     } else {
         $this->view->editCurrency = true;
     }
     $this->view->groupCodes = $this->getGroupCodeCombo();
 }
 public function addSupplierAction()
 {
     //view information NPD
     $this->view->id = $idNpdSheet = $this->getRequest()->getParam('id');
     $this->view->contentTitle = 'Add Supplier';
     $this->generateUrl('npd', 'create');
     $this->view->setTpl("Add-supplier");
     $this->view->npd = $npdSheet = NpdSheetQuery::create()->findByPKOrThrow($idNpdSheet, $this->i18n->_("It does not exist the NpdSheet with id {$idNpdSheet}"));
     $family = FamilyQuery::create()->findByPK($npdSheet->getIdFamily());
     $this->view->family = $family->getName();
     if ($npdSheet->getIdSubfamily()) {
         $this->view->subfamily = SubfamilyQuery::create()->findByPK($npdSheet->getIdSubfamily())->getName();
     } else {
         $this->view->subfamily = $this->i18n->_("Any");
     }
     $this->view->productGroup = ProductGroupQuery::create()->findByPK($family->getIdProductGroup())->getName();
     $this->view->videos = FileQuery::create()->innerJoinNpdSheet()->whereAdd('File2NpdSheet.id_npd_sheet', $npdSheet->getIdNpdSheet())->whereAdd(File::TYPE, File::$typeFile["typeLink"])->find();
     $this->view->npdColors = ColorQuery::create()->innerJoinNpdSheet()->whereAdd('Color2NpdSheet.id_npd_sheet', $npdSheet->getIdNpdSheet())->find();
     $this->view->country = CountryQuery::create()->find()->toCombo();
     $this->view->npdSheetImages = NpdSheetQuery::getNpdSheetFileObjects($npdSheet->getIdNpdSheet(), File::$typeFile["typeImage"]);
     $this->view->npdSheetFiles = NpdSheetQuery::create()->addColumns(array("File.*"))->innerJoinFile()->whereAdd("NpdSheet." . NpdSheet::ID_NPD_SHEET, $npdSheet->getIdNpdSheet())->fetchAll();
     $this->view->file = $file = FileQuery::create()->innerJoinNpdSheet()->whereAdd('File2NpdSheet.id_npd_sheet', $npdSheet->getIdNpdSheet())->whereAdd(File::TYPE, File::$typeFile["typeFile"])->findOne();
     //Form add supplier
     $npdSuppliers = $npdSuppliers = NpdSheetSupplierQuery::create()->whereAdd(NpdSheetSupplier::ID_NPD_SHEET, $idNpdSheet)->find();
     $allColors = array("" => "**  Select a Color  **") + ColorQuery::create()->actives()->find()->toCombo();
     //Videos from supplier
     foreach ($npdSuppliers as $npdSupplier) {
         //Get File Video for NPDSheetSupplier
         $NPDSheetSupplierFilesQuery = NpdSheetSupplierQuery::create()->addColumns(array("File.*"))->innerJoinFile()->whereAdd("NpdSheetSupplier." . NpdSheetSupplier::ID_NPD_SUPPLIER, $npdSupplier->getIdNpdSupplier())->fetchAll();
         $NPDSheetSupplierFiles[$npdSupplier->getIdNpdSupplier()] = $NPDSheetSupplierFilesQuery;
         $assignedColors = $this->getSupplierColors($npdSupplier->getIdNpdSupplier());
         $i = 0;
         foreach ($assignedColors->toCombo() as $idColor => $colorName) {
             $colors[$npdSupplier->getIdNpdSupplier()][$i]["options"] = $allColors + array($idColor => $colorName);
             $colors[$npdSupplier->getIdNpdSupplier()][$i]["selected"] = $idColor;
             $i++;
         }
         if (count($colors[$npdSupplier->getIdNpdSupplier()]) == 0) {
             $colors[$npdSupplier->getIdNpdSupplier()][0]["options"] = $allColors;
         }
         //Moq and price
         $npdMoqPriceQuery = SupplierBudgetQuery::create();
         $npdMoqPriceQuery->whereAdd(SupplierBudget::ID_NPD_SUPPLIER, $npdSupplier->getIdNpdSupplier());
         $npdMoqPrice[$npdSupplier->getIdNpdSupplier()] = $npdMoqPriceQuery->find();
     }
     if ($npdSuppliers->count() > 0) {
         $this->view->npdSuppliers = $npdSuppliers;
         $this->view->NPDSheetSupplierFiles = $NPDSheetSupplierFiles;
         //die(print_r($colors));
         $this->view->fileTypes = File::$typeFile;
         $this->view->colors = $colors;
         $this->view->npdMoqPrice = $npdMoqPrice;
     } else {
         $npdSuppliers = new stdClass();
         $npdSuppliers->couryard = new NpdSheetSupplier();
         $this->view->npdSuppliers = $npdSuppliers;
         $this->view->defaultColor = $allColors;
     }
     $suppliers = Application\Query\SapSupplierQuery::create()->find();
     $temporalSupplierQuery = TemporalSupplierQuery::create()->find();
     $temporalSupplierArray = array();
     $temporalSupplierNamesArray = array();
     while ($temporalSupplier = $temporalSupplierQuery->read()) {
         $temporalSupplierNamesArray[$temporalSupplier->getIdTemporalSap()] = $temporalSupplier->getIdTemporalSap() . ' - ' . $temporalSupplier->getName();
         $temporalSupplierArray[$temporalSupplier->getIdTemporalSap()] = $temporalSupplier->getName();
     }
     //     	$suppliersToAjax += $temporalSupplierArray;
     $this->view->supplierNames = $suppliers->toAutoCompleteCombo() + $temporalSupplierNamesArray;
     $this->view->supplierTabs = $suppliers->toCombo() + $temporalSupplierArray;
     $this->view->fobPorts = array("" => "Select Fob Port") + Application\Query\PortCustomQuery::create()->actives()->whereAdd('PortCustom.' . PortCustom::IS_DEPARTURE, 1)->find()->toCombo();
     $this->view->incoterms = array("" => "Select Incoterm") + \Application\Query\IncotermQuery::create()->find()->toCombo();
     $this->view->currencies = array("" => "Select Currency") + \Application\Query\CurrencyQuery::create()->find()->toCombo();
     $this->view->actionForm = 'create';
 }
Example #11
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 {
         }
     }
 }
 /**
  *
  * @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');
     }
 }
Example #13
0
 public function portsCourtyardAction()
 {
     // Get the forwarder and courtyard ids
     $idPort = $this->getRequest()->getParam("idPort");
     $idContact = $this->getRequest()->getParam("idContact");
     // Get the forwarder info
     $port = \Application\Query\PortCustomQuery::create()->findByPKOrThrow($idPort, $this->i18n->_("The Port with id {$idPort} does not exist"));
     if (!($idContact > 0)) {
         $idContact == null;
     }
     // Get all ports courtyard
     $courtyards = CourtyardQuery::create()->whereAdd(Courtyard::ID_PORT_CUSTOM, $port->getIdPortCustom())->find()->toCombo();
     // Get all courtyards with forwarder's contact assign and exclude the courtyard param id
     //     	$courtyards = CourtyardQuery::create()
     //     	->whereAdd(Courtyard::ID_FORWARDER, $forwarder->getIdForwarder())
     //     	->whereAdd(Courtyard::ID_COURTYARD, $idCourtyard, "<>")
     //     	->find();
     //     	// Unset the forwarder's contacts with courtyard assign
     //     	foreach ($courtyards as $courtyard) {
     //     		unset($contacts[$courtyard->getIdContact()]);
     //     	}
     die(Zend_Json::encode(array("response" => $courtyards)));
 }
Example #14
0
 /**
  * @author Pablo
  */
 public function benchmarkingAction()
 {
     $npd = NpdSheetQuery::create()->findByPKOrThrow($npdId = $this->getRequest()->getParam('id'), $this->i18n->_("The NPD Sheet with ID {$npdId} wasn't found"));
     $npdSuppliers = NpdSheetSupplierQuery::create()->whereAdd(NpdSheetSupplier::ID_NPD_SHEET, $npd->getIdNpdSheet())->find();
     $npdSuppliersIds = NpdSheetSupplierQuery::create()->whereAdd(NpdSheetSupplier::ID_NPD_SHEET, $npd->getIdNpdSheet())->addColumn(NpdSheetSupplier::ID_SUPPLIER)->fetchCol();
     $supplierBudgets = SupplierBudgetQuery::create()->whereAdd(SupplierBudget::ID_NPD_SUPPLIER, $npdSuppliers->getPrimaryKeys(), SupplierBudgetQuery::IN)->find();
     $benchmarking = array();
     foreach ($supplierBudgets as $supplierBudget) {
         $moq = $supplierBudget->getMoq();
         $npdSupplierId = $supplierBudget->getIdNpdSupplier();
         $leadTime = $supplierBudget->getLeadTime();
         if (!is_array($benchmarking[$moq])) {
             $benchmarking[$moq] = array();
         }
         $benchmarking[$moq][$npdSupplierId] = array('price' => $supplierBudget->getPrice(), 'leadTime' => $supplierBudget->getLeadTime(), 'percent' => $supplierBudget->getPrice() / $npd->getPrice() * 100 - 100 . '%', 'favorite' => $supplierBudget->getFavorite(), 'isAuthorized' => $supplierBudget->getIsAuthorized(), 'supplierBudgetId' => $supplierBudget->getIdSupplierBudget());
         ksort($benchmarking);
     }
     //die(print_r($benchmarking));
     // 		echo '<pre>';
     $supplierImages = array();
     foreach ($npdSuppliers as $npdSupplier) {
         $supplierImages[$npdSupplier->getIdNpdSheet()] = FileQuery::create()->innerJoinNpdSheetSupplier()->whereAdd('NpdSheetSupplier.' . NpdSheetSupplier::ID_NPD_SHEET, $npd->getIdNpdSheet())->whereAdd('NpdSheetSupplier.' . NpdSheetSupplier::ID_NPD_SUPPLIER, $npdSupplier->getIdNpdSupplier())->whereAdd(File::TYPE, File::$typeFile['typeImage'])->find();
         $NPDSheetSupplierFilesQuery = NpdSheetSupplierQuery::create()->addColumns(array("File.*"))->innerJoinFile()->whereAdd("NpdSheetSupplier." . NpdSheetSupplier::ID_NPD_SUPPLIER, $npdSupplier->getIdNpdSupplier())->fetchAll();
         $supplierImages2[$npdSupplier->getIdNpdSheet()] = $NPDSheetSupplierFilesQuery;
     }
     // 		print_r($supplierImages);
     // 		print_r($supplierImages2);
     // 		die;
     $files = FileQuery::create()->innerJoinNpdSheet()->whereAdd('NpdSheet.' . NpdSheet::ID_NPD_SHEET, $npd->getIdNpdSheet())->find();
     $npdImages = array();
     $npdFiles = array();
     $npdLinks = array();
     foreach ($files as $file) {
         switch ($file->getType()) {
             case File::$typeFile['typeImage']:
                 $npdImages[] = $file;
                 break;
             case File::$typeFile['typeFile']:
                 $npdFiles[] = $file;
                 break;
             case File::$typeFile['typeLink']:
                 $npdLinks[] = $file;
                 break;
         }
     }
     if ($npd->getIdSubfamily()) {
         $subFamily = SubFamilyQuery::create()->findByPK($npd->getIdSubfamily())->getName();
     } else {
         $subFamily = $this->i18n->_("Any");
     }
     $suppliers = SapSupplierQuery::create()->whereAdd(SapSupplier::ID_SUPPLIER, $npdSuppliersIds, SapSupplierQuery::IN)->find();
     $temporalSuppliers = array();
     $temporalSuppliersQuery = TemporalSupplierQuery::create()->whereAdd(TemporalSupplier::ID_TEMPORAL_SAP, $npdSuppliersIds, TemporalSupplierQuery::IN)->find();
     while ($temporalSupplier = $temporalSuppliersQuery->read()) {
         $supplier = new SapSupplier();
         $supplier->setCardCode($temporalSupplier->getIdTemporalSap());
         $supplier->setCardname($temporalSupplier->getName());
         $suppliers->append($supplier);
     }
     // 		echo '<pre>';
     // 		print_r($suppliers);
     // 		die;
     $this->view->subFamily = $subFamily;
     $this->view->family = $family = FamilyQuery::create()->findByPK($npd->getIdFamily());
     $this->view->productGroup = ProductGroupQuery::create()->findByPK($family->getIdProductGroup());
     $this->view->suppliers = $suppliers->toObjectArray();
     $this->view->npd = $npd;
     $this->view->benchmarking = $benchmarking;
     $this->view->npdSuppliers = $npdSuppliers;
     $this->view->supplierBudgets = $supplierBudgets;
     $this->view->supplierImages = $supplierImages;
     $this->view->npdImages = $npdImages;
     $this->view->npdFiles = $npdFiles;
     $this->view->npdLinks = $npdLinks;
     $this->view->incoterms = \Application\Query\IncotermQuery::create()->find()->toCombo();
     $this->view->ports = \Application\Query\PortCustomQuery::create()->find()->toCombo();
     $this->view->contentTitle = $this->i18n->_('NPD Benchmarking');
 }
Example #15
0
 /**
  * 
  */
 public function getListResultsAction()
 {
     $params = $this->getRequest()->getParams();
     $params['name'] = "%" . $params['name'] . "%";
     $portCustoms = PortCustomQuery::create()->filter($params)->page($params['page'], $this->getMaxPerPage())->find();
     die(json_encode($portCustoms->toArray()));
 }
Example #16
0
 public function zoomInAction()
 {
     if ($this->getRequest()->isPost()) {
         $keyMother = $this->getRequest()->getParam("key_mother");
         $itemCode = $this->getRequest()->getParam("item_code");
         $products = ProductQuery::create()->find();
         $keyMotherProducts = $products->filterByKeyMother($keyMother);
         $restock = RestockQuery::create()->findOne();
         $allRestockEntries = RestockEntryQuery::create()->find();
         $restockEntries = $allRestockEntries->filterByArrayIdProduct($keyMotherProducts->getPrimaryKeys());
         $freightTypes = FreightTypeQuery::create()->actives()->find();
         $restockFinalResultsManager = new RestockFinalResultsManager($allRestockEntries, $products);
         $product = $products->getByPK($itemCode);
         $restockAbcClass = RestockAbcClassQuery::create()->find();
         $freightFares = FreightFareQuery::create()->find();
         $freightFare = $freightFares->getByPK($product->getDefaultFreightFare());
         $fobPort = PortCustomQuery::create()->findByPKOrElse($freightFare->getFobPort(), new PortCustom());
         $fobPortFreightFares = $freightFares->filterByFobPort($fobPort);
         $freightTypeList = $freightTypes->containsIndex($freightFare->getIdFreightType()) ? $freightTypes->getByPK($freightFare->getIdFreightType()) : new FreightType();
         if ($product->getIdSupplier() != "") {
             $supplier = SapSupplierQuery::create()->findByPK($product->getIdSupplier());
         } else {
             $supplier = new SapSupplier();
         }
         $keyMotherInfo["keyMother"] = $product->getKeyMother();
         $keyMotherInfo["PurchaseKeyMother"] = $restockFinalResultsManager->getTotalPurchaseByKeyMother($keyMother);
         $keyMotherInfo["catalog"] = $product->getCodPro();
         $keyMotherInfo["port"] = $fobPort->getName();
         $keyMotherInfo["freightList"] = $freightTypeList->getName();
         $keyMotherInfo["supplier"] = $supplier->getCardCode() . " - " . $supplier->getCardname();
         $keyMotherInfo["supplierPurchase"] = $restockFinalResultsManager->getTotalPurchaseByIdSupplier($supplier->getIdSupplier());
         $keyMotherInfo["fobPortPurchase"] = $restockFinalResultsManager->getTotalByIdFreigthFare($fobPortFreightFares->getPrimaryKeys());
         while ($restockEntries->valid()) {
             $restockEntry = $restockEntries->read();
             $product = $products->getByPK($restockEntry->getIdProduct());
             $restockInfo[$restockEntry->getIndex()]["idRestockEntry"] = $restockEntry->getIdRestockEntry();
             $restockInfo[$restockEntry->getIndex()]["mcParts"] = $product->getMcParts();
             $restockInfo[$restockEntry->getIndex()]["volume"] = $product->getVolume();
             $restockInfo[$restockEntry->getIndex()]["status"] = $product->getStatus();
             $restockInfo[$restockEntry->getIndex()]["itemCode"] = $product->getItemCode();
             $restockInfo[$restockEntry->getIndex()]["name"] = $product->getItemName();
             $restockInfo[$restockEntry->getIndex()]["onStock"] = $restockEntry->getInvRelat();
             $restockInfo[$restockEntry->getIndex()]["VIM"] = $product->getIndividualVim();
             $restockInfo[$restockEntry->getIndex()]["VIMMin"] = $restockEntry->getVimMin();
             $restockInfo[$restockEntry->getIndex()]["VIMMax"] = $restockEntry->getVimMax();
             $restockInfo[$restockEntry->getIndex()]["newQuantityMin"] = $restockEntry->getNewQuantityMin();
             $restockInfo[$restockEntry->getIndex()]["newImportMin"] = $restockEntry->getPriceMin();
             $restockInfo[$restockEntry->getIndex()]["newQuantityMax"] = $restockEntry->getNewQuantityMax();
             $restockInfo[$restockEntry->getIndex()]["newImportMax"] = $restockEntry->getPriceMax();
             $restockInfo[$restockEntry->getIndex()]["coverMin"] = $restockEntry->getMinCoverPercent();
             $restockInfo[$restockEntry->getIndex()]["coverMax"] = $restockEntry->getMaxCoverPercent();
             $restockInfo[$restockEntry->getIndex()]["ABCMin"] = $restockAbcClass->getByPK($restockEntry->getAbcMix())->getName();
             $restockInfo[$restockEntry->getIndex()]["desition"] = $restockEntry->getDesitionName();
             $restockInfo[$restockEntry->getIndex()]["lastFOB"] = $product->getCost();
             $restockInfo[$restockEntry->getIndex()]["targetFOB"] = $restockEntry->getMinTargetPrice();
             $restockInfo[$restockEntry->getIndex()]["quantityPurchase"] = $restockEntry->getPurchaseQuantity();
             $restockInfo[$restockEntry->getIndex()]["importPurchase"] = $restockEntry->getPurchasePrice();
             $restockInfo[$restockEntry->getIndex()]["quantityPercent"] = $restockEntry->getPurchaseQuantityPercernt();
             $restockInfo[$restockEntry->getIndex()]["importPercent"] = $restockEntry->getPurchasePricePercent();
             $restockInfo[$restockEntry->getIndex()]["quantitySetted"] = $restockEntry->getQuantity();
             $restockInfo[$restockEntry->getIndex()]["purchaseSetted"] = $restockFinalResultsManager->getTotalCartonsByIdRestockEntry($restockEntry->getIdRestockEntry());
             $restockInfo[$restockEntry->getIndex()]["importPurchaseSetted"] = $restockFinalResultsManager->getPurchaseSettedByIdRestockEntry($restockEntry->getIdRestockEntry());
             $restockInfo[$restockEntry->getIndex()]["isManual"] = $product->isManual();
             $restockInfo[$restockEntry->getIndex()]["cbm"] = $totalVolume = $restockFinalResultsManager->getTotalVolumeByIdRestockEntry($restockEntry->getIdRestockEntry());
             $restockInfo[$restockEntry->getIndex()]["suggestedFreight"] = implode(" / ", $freightTypes->getSuggestedFreights($totalVolume)->toCombo());
             $restockInfo[$restockEntry->getIndex()]["checked"] = $restockEntry->getChecked();
         }
         $requisitionEntries = RequisitionEntryQuery::create()->whereAdd(RequisitionEntry::ID_PRODUCT, $keyMotherProducts->getPrimaryKeys(), RequisitionEntryQuery::IN)->whereAdd(RequisitionEntry::STATUS, array(RequisitionEntry::$Status["Closed"], RequisitionEntry::$Status["Canceled"], RequisitionEntry::$Status["Inactive"]), RequisitionEntryQuery::NOT_IN)->find()->toArrayForZoomIn();
         $proformaInvoiceEntries = ProformaInvoiceEntryQuery::create()->whereAdd(ProformaInvoiceEntry::ID_PRODUCT, $keyMotherProducts->getPrimaryKeys(), ProformaInvoiceEntryQuery::IN)->whereAdd(ProformaInvoiceEntry::LINE_STATUS, ProformaInvoiceEntry::$LineStatus["Open"])->find()->toArrayForZoomIn();
         $purchaseOrderEntries = PurchaseOrderEntryQuery::create()->whereAdd(PurchaseOrderEntry::ID_PRODUCT, $keyMotherProducts->getPrimaryKeys(), PurchaseOrderEntryQuery::IN)->whereAdd(PurchaseOrderEntry::LINE_STATUS, PurchaseOrderEntry::$LineStatus["Open"])->find()->toArrayForZoomIn();
         $documents = array_merge(array_merge($requisitionEntries, $proformaInvoiceEntries), $purchaseOrderEntries);
         $currencies = CurrencyQuery::create()->find()->toArray();
         die(Zend_Json::encode(array("keyMother" => $keyMotherInfo, "restock" => $restockInfo, "documents" => $documents, "currecies" => $currencies)));
     }
 }
Example #17
0
 /**
  * @return string
  */
 public function getDestinationPortName()
 {
     $destinationPortName = null;
     if (PortCustomQuery::create()->whereAdd(PortCustom::ID_PORT_CUSTOM, $this->destinationPort)->count()) {
         $destinationPortName = PortCustomQuery::create()->findByPK($this->destinationPort)->getName();
     }
     return $destinationPortName;
 }