Beispiel #1
0
 protected function genericSampleNPDNotification(NPDEvent $event, $notificationTypeId, $status)
 {
     $npd = $event->getNPD();
     $sampleObjects = SampleQuery::create()->whereAdd(Sample::ID_NPD_SHEET, $npd->getIdNpdSheet())->whereAdd(Sample::STATUS, $status)->addAscendingOrderBy(Sample::DEADLINE)->find();
     $npdSupplierIds = NpdSheetSupplierQuery::create()->addColumn(NpdSheetSupplier::ID_SUPPLIER)->whereAdd(NpdSheetSupplier::ID_NPD_SHEET, $npd->getIdNpdSheet())->fetchCol();
     $suppliers = SapSupplierQuery::create()->whereAdd(SapSupplier::CARDCODE, $npdSupplierIds, SupplierQuery::IN)->find()->toCombo();
     $colors = \Application\Query\ColorQuery::create()->find()->toCombo();
     $samples = array();
     foreach ($sampleObjects as $sample) {
         if (!$sample instanceof Sample) {
             $sample = new Sample();
         }
         $samples[] = array('Supplier' => utf8_decode($suppliers[$sample->getIdSupplier()]), 'Quantity' => $sample->getQuantity(), 'Color' => $colors[$sample->getIdColor()], 'Remarks' => utf8_decode($sample->getNotes()), 'Deadline' => $sample->getDeadline(), 'Cost' => $sample->getCost(), 'ShippedQuantity' => $sample->getShippedQuantity());
     }
     $vars = array('id_npd_sheet' => $npd->getIdNpdSheet(), 'creation_date' => $npd->getCreationDateAsZendDate()->get("dd-MM-yyyy HH:mm"), 'name' => utf8_decode($npd->getName()), 'description' => utf8_decode($npd->getDescription()), 'samples' => $samples);
     $this->createNotification($notificationTypeId, $vars);
 }
 /**
  *
  * @return array
  */
 public function editAction()
 {
     $this->view->contentTitle = $this->i18n->_('Edit Participant');
     $id = $this->getRequest()->getParam('id');
     $respondent = RespondentQuery::create()->findByPKOrThrow($id, $this->i18n->_("It does not exist the Respondent with id {$id}"));
     $customerNumber = $respondent->getCustomerNumber() ? $respondent->getCustomerNumber() : '000';
     // die(print_r($customerNumber));
     $customerQuery = SapSupplierQuery::create()->findByPKOrElse($customerNumber, new SapSupplier());
     if ($customerQuery->getCardCode()) {
         $customer = $customerQuery->getCardCode() . "-" . $customerQuery->getCardname();
     } else {
         $customer = $this->i18n->_("Invalid Customer Number");
     }
     $this->view->setTpl("Form");
     $this->view->respondent = $respondent;
     $this->view->customer = $customer;
     $this->view->profile = $profile = $customerQuery->getPerfil();
     $this->view->profileName = $customerQuery->getPerfil() ? $customerQuery->getPerfilName() : $this->i18n->_("No Profile");
     // die(print_r(gettype($customerQuery->getPerfil())));
     $this->view->genders = array("" => "Select Gender") + Respondent::$GenderCombo;
     $this->view->action = 'update';
 }
 public function rateSupplierAction()
 {
     $params = $this->getRequest()->getParams();
     $array = array();
     $contacts = new SapSupplierContactEmployeeCollection($array);
     $addresses = new SapSupplierAddressCollection($array);
     $supplier = SapSupplierQuery::create()->findByPK($params['idSupplier']);
     $supplier->setContacts($contacts);
     $supplier->setAddresses($addresses);
     $supplier->setQuality($params['quality']);
     $sapConnector = new SAPConnectorClient();
     $result = $sapConnector->rateSupplier($supplier);
     $response = array(message => $result->rateSupplierResult->message, success => $result->rateSupplierResult->success);
     die(json_encode($response));
 }
Beispiel #4
0
 public function getAvailableSuppliersAction()
 {
     $string = "%" . $this->getRequest()->getParam("searchString") . "%";
     $accessRole = $this->getUser()->getAccessRole();
     $countries = AccessRoleQuery::create()->innerJoinAccesRoleCountry()->addColumn("AccessRole2Country.id_country")->whereAdd("AccessRole2Country.id_access_role", $accessRole->getIdAccessRole())->fetchCol();
     $sapSupplierQuery = SapSupplierQuery::create()->innerJoinSapSupplierAddress()->whereAdd("CRD1." . SapSupplierAddress::COUNTRY, $countries);
     $sapSupplierQuery->where()->setOR();
     $suppliers = $sapSupplierQuery->whereAdd("OCRD." . SapSupplier::CARDCODE, $string)->whereAdd("OCRD." . SapSupplier::CARDNAME, $string)->find();
     die(json_encode($suppliers->toArray()));
 }
 public function claimControlAction()
 {
     $id = $this->getRequest()->getParam('id');
     $claimReport = WarehouseEntranceClaimReportQuery::create()->findByPK($id);
     $idWarehouseEntrance = $claimReport->getIdWarehouseEntrance();
     $line = $claimReport->getIdWarehouseEntranceProduct();
     if (!empty($idWarehouseEntrance)) {
         $redirect = "warehouse-entrance/claim-control/line/{$line}/id/{$idWarehouseEntrance}";
         $this->_redirect($redirect);
     }
     $quantity = $claimReport->getGood() + $claimReport->getRejected() + $claimReport->getMissing();
     $freight = $claimReport->getLandedCost();
     $totalRejected = ($claimReport->getRejected() + $claimReport->getMissing()) * $claimReport->getPrice() + ($claimReport->getRejected() + $claimReport->getMissing()) * $freight;
     $claimReportArray = $claimReport->toArray();
     $claimReportArray['total_rejected'] = $totalRejected;
     if (SapSupplierQuery::create()->whereAdd(SapSupplier::ID_SUPPLIER, $claimReport->getIdSupplier())->find()->count()) {
         $supplier = SapSupplierQuery::create()->findByPK($claimReport->getIdSupplier());
     } else {
         $supplier = new SapSupplier();
     }
     $claimReportArray['supplier'] = $supplier->getSupplierCardCodeWithCardName();
     if (ClaimReportFileQuery::create()->whereAdd(ClaimReportFile::ID_WAREHOUSE_ENTRANCE_CLAIM_REPORT, $id)->find()->count()) {
         $this->view->claimReportDocument = ClaimReportFileQuery::create()->whereAdd(ClaimReportFile::ID_WAREHOUSE_ENTRANCE_CLAIM_REPORT, $id)->findOne()->getIdWarehouseEntranceClaimReport();
     }
     $this->view->contentTitle = $this->i18n->_('Claim Control');
     $this->view->onsubmit = "warehouse-entrance-claim-report/save-claim-control";
     $this->view->status = $this->getClaimControlStatus();
     $this->view->claimReport = $claimReportArray;
     $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'];
 }
 public function exportToExcelAction()
 {
     $params = $this->getRequest()->getParams();
     $requisitions = RequisitionQuery::create()->filter($params)->whereAdd(Requisition::STATUS, Requisition::$Status["Inactive"], BaseQuery::NOT_EQUAL)->find();
     $requisitionIds = RequisitionQuery::create()->filter($params)->whereAdd(Requisition::STATUS, Requisition::$Status["Inactive"], BaseQuery::NOT_EQUAL)->fetchCol();
     $allRequisitionEntries = RequisitionEntryQuery::create()->whereAdd(RequisitionEntry::ID_REQUISITION, $requisitionIds, RequisitionEntryQuery::IN)->find();
     $currencies = CurrencyQuery::create()->find();
     $products = ProductQuery::create()->whereAdd(Product::ITEM_CODE, $allRequisitionEntries->getDistinctProducts(), ProductQuery::IN)->find();
     $countries = CountryQuery::create()->find();
     $suppliers = SapSupplierQuery::create()->whereAdd(SapSupplier::CARDCODE, $allRequisitionEntries->getDistinctSuppliers(), SupplierQuery::IN)->find();
     require_once 'PHPExcel.php';
     $objPHPExcel = new PHPExcel();
     $activeSheet = $objPHPExcel->setActiveSheetIndex(0);
     $activeSheet->setCellValue('A1', $this->i18n->_('Requisition Folio'))->setCellValue('B1', $this->i18n->_('Requisition Status'))->setCellValue('C1', $this->i18n->_('Reference'))->setCellValue('D1', $this->i18n->_('Creation Date'))->setCellValue('E1', $this->i18n->_('Destination'))->setCellValue('F1', $this->i18n->_('Parent Key'))->setCellValue('G1', $this->i18n->_('Product Status'))->setCellValue('H1', $this->i18n->_('Product Code'))->setCellValue('I1', $this->i18n->_('Product Description'))->setCellValue('J1', $this->i18n->_('Line Status'))->setCellValue('K1', $this->i18n->_('Supplier Default Code'))->setCellValue('L1', $this->i18n->_('Supplier Default Name'))->setCellValue('M1', $this->i18n->_('Ammount'))->setCellValue('N1', $this->i18n->_('Target Price'))->setCellValue('O1', $this->i18n->_('Price'))->setCellValue('P1', $this->i18n->_('Import'))->setCellValue('Q1', $this->i18n->_('currency'));
     $i = 2;
     while ($requisitions->valid()) {
         $requisition = $requisitions->read();
         $requisitionEntries = $allRequisitionEntries->filterByIdRequisition($requisition->getIdRequisition());
         $country = $countries->getByPK($requisition->getIdDestinationCountry());
         $entriesCount = $i;
         while ($requisitionEntries->valid()) {
             $requisitionEntry = $requisitionEntries->read();
             $product = $products->containsIndex($requisitionEntry->getIdProduct()) ? $products->getByPK($requisitionEntry->getIdProduct()) : new Product();
             $supplier = $requisitionEntry->getIdSupplierDefault() > 0 ? $suppliers->getByPkOrElse($requisitionEntry->getIdSupplierDefault(), new SapSupplier()) : new SapSupplier();
             $currency = $currencies->getByPK($requisitionEntry->getIdCurrency());
             $activeSheet->setCellValue("F" . $entriesCount, $product->getKeyMother())->setCellValue("G" . $entriesCount, $product->getStatus())->setCellValue("H" . $entriesCount, $product->getItemCode())->setCellValue("I" . $entriesCount, $product->getItemName())->setCellValue("J" . $entriesCount, $requisitionEntry->getStatusName())->setCellValue("K" . $entriesCount, $supplier->getCardCode())->setCellValue("L" . $entriesCount, $supplier->getCardname())->setCellValue("M" . $entriesCount, $requisitionEntry->getQuantity())->setCellValue("N" . $entriesCount, $product->getCost())->setCellValue("O" . $entriesCount, $requisitionEntry->getPrice())->setCellValue("P" . $entriesCount, $requisitionEntry->getImport())->setCellValue("Q" . $entriesCount, $currency->getCurrCode());
             $entriesCount++;
         }
         $activeSheet->mergeCells('A' . $i . ':A' . ($entriesCount - 1))->setCellValue('A' . $i, $requisition->getIdRequisition())->mergeCells('B' . $i . ':B' . ($entriesCount - 1))->setCellValue('B' . $i, $requisition->getStatusName())->mergeCells('C' . $i . ':C' . ($entriesCount - 1))->setCellValue('C' . $i, $requisition->getNumRequisition())->mergeCells('D' . $i . ':D' . ($entriesCount - 1))->setCellValue('D' . $i, $requisition->getDate())->mergeCells('E' . $i . ':E' . ($entriesCount - 1))->setCellValue('E' . $i, utf8_encode($country->getName()));
         $i = $entriesCount;
     }
     header("Content-Type: application/vnd.ms-excel");
     $date = \Zend_Date::now();
     $fileName = $this->i18n->_("Requisitions_report") . $date->get("ddMMyyyy");
     header("Content-Disposition: attachment; filename=\"{$fileName}.xlsx\"");
     header("Cache-Control: max-age=0");
     $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
     $objWriter->save("php://output");
     exit;
 }
Beispiel #7
0
 /**
  * @author Jose luis
  */
 public function getCurrencyAction()
 {
     $id = $this->getRequest()->getParam('id');
     $idCurrency = SapSupplierQuery::create()->findByPK($id)->getCurrency();
     if (CurrencyQuery::create()->whereAdd(Currency::CURRCODE, $idCurrency)->find()->count()) {
         $currency = CurrencyQuery::create()->findByPK($idCurrency)->getCurrName();
     } else {
         $currency = '';
     }
     die(json_encode($currency));
 }
 public function rateAction()
 {
     $this->view->action = 'update';
     $this->view->address = new Address();
     $idLine = $this->getRequest()->getParam('idLine');
     $idProformaInvoice = $this->getRequest()->getParam('id');
     $ratings = self::$ratings;
     $this->view->ratings = array('' => '**' . $this->i18n->_('Select') . '**') + $ratings;
     $inspectionsQuery = InspectionQuery::create()->whereAdd(Inspection::ID_PROFORMA_INVOICE, $idProformaInvoice)->whereAdd(Inspection::ID_PROFORMA_INVOICE_ENTRY, $idLine)->whereAdd(Inspection::STATUS, Inspection::$Status['Innactive'], baseQuery::NOT_EQUAL)->find();
     $proformaInvoice = ProformaInvoiceQuery::create()->findByPK($idProformaInvoice);
     //$idS = PurchaseOrderQuery::create()->findByPK($idPo)->getIdSupplier();
     $supplier = SapSupplierQuery::create()->findByPK($proformaInvoice->getIdSupplier());
     //die(print_r($supplier));
     $this->view->supplier = $supplier;
     $rate = $supplier->getQuality();
     $requiredInspection = array();
     if ($rate == 2) {
         $requiredInspection[3] = self::$inspectionsArray[3];
         $requiredInspection[4] = self::$inspectionsArray[4];
     }
     if ($rate == 3) {
         $requiredInspection[4] = self::$inspectionsArray[4];
     }
     $inspects = $inspectionsQuery->toArray();
     foreach ($inspects as $inspect) {
         $idInspections[] = $inspect['id_inspection'];
     }
     $files = FileQuery::create()->innerJoinInspection()->addColumns(array('Inspection.' . Inspection::ID_INSPECTION, 'File.*'))->whereAdd('Inspection.' . Inspection::ID_INSPECTION, $idInspections, BaseQuery::IN)->fetchAll();
     $inspectors = \Application\Query\InspectorQuery::create()->innerJoinPerson()->addColumns(array('Inspector.*', 'Person.*'))->find();
     $inspectors = $inspectors->map(function (Inspector $inspector) {
         return array($inspector->getIdInspector() => $inspector->getFullName());
     });
     $this->view->inspectors = array('' => 'Select Inspector') + $inspectors;
     $this->view->requiredInspections = $requiredInspection;
     $this->view->inspections = $inspectionsQuery;
     $this->view->inspectionsTypes = self::$inspectionsTypes;
     $this->view->idEntry = $idLine;
     $this->view->idProformaInvoice = $idProformaInvoice;
     $this->view->files = $files;
 }
 /**
  *
  * Gets all Suppliers from SAP, searches the DB for the cardcode, then updates or creates
  */
 public function syncSuppliersAction()
 {
     $r = SapSupplierQuery::create()->whereAdd(SapSupplier::CARDTYPE, "s", SapSupplierQuery::EQUAL)->find();
     echo "<pre>";
     $errors = 0;
     $new = 0;
     $updated = 0;
     while ($r->valid()) {
         $save = 0;
         $sapSupplier = $r->read();
         echo "Name: " . $sapSupplier->getCardname() . " Code: " . $sapSupplier->getCardcode() . "\n";
         $supplier = SupplierQuery::create()->whereAdd(Supplier::SAP_ID_BUSSINESS_ASSOCIATE, $sapSupplier->getCardcode(), SupplierQuery::EQUAL)->findOne();
         if (!$supplier instanceof Supplier) {
             $supplier = new Supplier();
             $save = 1;
         }
         $currency = CurrencyQuery::create()->whereAdd(Currency::CODE, substr($sapSupplier->getCardcode(), 0, 3))->findOne();
         if (!$currency instanceof Currency) {
             echo " Error! No Currency: " . substr($sapSupplier->getCardcode(), 0, 3) . "\n";
             $errors++;
             continue;
         }
         $supplier->setIdCurrency($currency->getIdCurrency());
         $supplier->setCardName($sapSupplier->getCardname());
         $supplier->setConsistency(0);
         $supplier->setIdApprovalStatus(1);
         $supplier->setIdPaymentTerm(1);
         $supplier->setName($sapSupplier->getCardname());
         $supplier->setQuality(0);
         $supplier->setRfc($sapSupplier->getLicTradNum());
         $supplier->setSapIdBussinessAssociate($sapSupplier->getCardcode());
         $supplier->setStatus(1);
         $supplier->setTime(0);
         $supplier->setIdDefaultPort(1);
         $supplier->setTypePerson($sapSupplier->getCmpPrivate());
         try {
             $this->getSupplierCatalog()->beginTransaction();
             if ($save) {
                 $this->getSupplierCatalog()->create($supplier);
                 $new++;
             } else {
                 $this->getSupplierCatalog()->update($supplier);
                 $updated++;
             }
             $this->getSupplierCatalog()->commit();
         } catch (Exception $e) {
             $this->getSupplierCatalog()->rollBack();
             echo "\nError al intentar guardar el proveedor: " . $e->getMessage();
         }
     }
     echo "\n\nTotals:\nErrors: " . $errors . "\nNew: " . $new . "\nUpdated: " . $updated;
     die;
 }
Beispiel #10
0
 public function exportToExcelPendingProductAction()
 {
     $post['id_product_group'] = urldecode($this->getRequest()->getParam('id_product_group'));
     $post['reference'] = urldecode($this->getRequest()->getParam('reference'));
     $post['status'] = $this->getRequest()->getParam('status');
     $npdsheets = NpdSheetQuery::create()->filter($post)->addDescendingOrderBy(NpdSheet::ID_NPD_SHEET)->whereAdd(NpdSheet::STATUS, NpdSheet::$Status['Pending Product'])->find();
     if (!$npdsheets->isEmpty()) {
         $i = 1;
         while ($npdsheet = $npdsheets->read()) {
             $productGroup = ProductGroupQuery::create()->whereAdd(ProductGroup::ID_PRODUCT_GROUP, $npdsheet->getIdProductGroup())->findOne();
             $family = FamilyQuery::create()->whereAdd(Family::ID_FAMILY, $npdsheet->getIdFamily())->findOne();
             $subfamily = SubfamilyQuery::create()->whereAdd(Subfamily::ID_SUBFAMILY, $npdsheet->getIdSubfamily())->findOne();
             $npdSupplier = NpdSheetSupplierQuery::create()->innerJoinNpdSheet()->whereAdd('NpdSheetSupplier.id_npd_sheet', $npdsheet->getIdNpdSheet())->find()->getPrimaryKeys();
             if ($npdSupplier) {
                 $authorizedPrice = SupplierBudgetQuery::create()->innerJoinNpdSheetSupplier()->whereAdd('SupplierBudget.id_npd_supplier', $npdSupplier, Criteria::IN)->whereAdd('SupplierBudget.is_authorized', 1)->findOne();
             }
             if (!$authorizedPrice) {
                 $authorizedPrice = new SupplierBudget();
             }
             if (NpdSheetSupplierQuery::create()->whereAdd(NpdSheetSupplier::ID_NPD_SUPPLIER, $authorizedPrice->getIdNpdSupplier())->count()) {
                 $npdSupplier = NpdSheetSupplierQuery::create()->whereAdd(NpdSheetSupplier::ID_NPD_SUPPLIER, $authorizedPrice->getIdNpdSupplier())->findOne();
             } else {
                 $npdSupplier = null;
             }
             if ($npdSupplier) {
                 if (SapSupplierQuery::create()->whereAdd(SapSupplier::ID_SUPPLIER, $npdSupplier->getIdSupplier())->count()) {
                     $supplier = SapSupplierQuery::create()->whereAdd(SapSupplier::ID_SUPPLIER, $npdSupplier->getIdSupplier())->findOne()->getSupplierCardCodeWithCardName();
                 }
             }
             $data[$i] = array($npdsheet->getIdNpdSheet(), $npdsheet->getStatusName(), $npdsheet->getReference(), $npdsheet->getCreationDateAsZendDate()->get('YYYY-MM-dd'), $productGroup->getCode() . '-' . $productGroup->getName(), $family->getCode() . '-' . $family->getName(), $subfamily ? $subfamily->getCode() . '-' . $subfamily->getName() : $this->i18n->_('Not Available'), $npdsheet->getName(), $npdsheet->getPrice(), $authorizedPrice->getPrice(), $supplier ? $supplier : null);
             $i++;
         }
         $header = array($this->i18n->_('ID'), $this->i18n->_('Status'), $this->i18n->_('Reference'), $this->i18n->_('Creation date'), $this->i18n->_('Product Group'), $this->i18n->_('Family'), $this->i18n->_('Subfamily'), $this->i18n->_('Product'), $this->i18n->_('Target Price'), $this->i18n->_('Authorized Price'), $this->i18n->_('Prefered Supplier'));
         $title = $this->i18n->_('NPDs Report');
         $fileName = $this->i18n->_('Npds_report');
         $tableColumnsWidth = array('mini');
         $report = new SimpleListReport();
         $report->setTableTitle($title);
         $report->setTableHeaders($header);
         $report->setTableContent($data);
         $report->setFilename($fileName);
         $report->setTableColumnsWidth($tableColumnsWidth);
         $report->createSpreadsheet();
     } else {
         $filter = $this->createFilterForUrl($post);
         $this->setFlash("warning", $this->i18n->_('No records found'));
         $this->_redirect('npd-sheet/pending-product');
     }
 }
Beispiel #11
0
 public function exportToExcelAction()
 {
     $params = $this->getRequest()->getParams();
     $samples = SampleQuery::create()->addDescendingOrderBy("Sample." . Sample::ID_SAMPLE)->addAscendingOrderBy("Sample." . Sample::STATUS)->filter($params)->find();
     // 		$samples = SampleShipmentQuery::create()
     // 		->innerJoinSample()
     // 		->filter($post)
     // 		->page($page, $this->getMaxPerPage())
     // 		->find();
     $NPDSheets = NpdSheetQuery::create()->whereAdd(NpdSheet::ID_NPD_SHEET, $samples->getDistinctNPDSheets(), NpdSheetQuery::IN)->find();
     $suppliers = SapSupplierQuery::create()->whereAdd(SapSupplier::ID_SUPPLIER, $samples->getDistinctSuppliers(), SapSupplierQuery::IN)->find();
     $colors = ColorQuery::create()->find();
     $i = 1;
     while ($samples->valid()) {
         $sample = $samples->read();
         $NPDSheet = $NPDSheets->getByPK($sample->getIdNpdSheet());
         $supplier = $suppliers->getByPkOrEmpty($sample->getIdSupplier());
         $color = $colors->getByPkOrElse($sample->getIdColor(), new Color());
         $data[$i] = array($sample->getIdSample(), $sample->getStatusName(), $NPDSheet->getIdNpdSheet(), $NPDSheet->getName(), $NPDSheet->getReference(), $NPDSheet->getStatusName(), $supplier->getIdSupplier() ? $supplier->getSupplierCardCodeWithCardName() : "-", $sample->getQuantity(), $color->getIdColor() > 0 ? $color->getName() : $this->i18n->_("Any"), $sample->getNotes(), $sample->getDeadline(), $sample->getShippedQuantity());
         $i++;
     }
     $header = array($this->i18n->_('Folio Sample'), $this->i18n->_('Status Sample'), $this->i18n->_('NPD ID'), $this->i18n->_('NPD Name'), $this->i18n->_('NPD Reference'), $this->i18n->_('NPD Status'), $this->i18n->_('Supplier'), $this->i18n->_('Quantity'), $this->i18n->_('Color'), $this->i18n->_('Remarks'), $this->i18n->_('Deadline'), $this->i18n->_('Shipped Quantity'));
     $title = $this->i18n->_('Samples Report');
     $fileName = $this->i18n->_('Samples_report');
     $report = new SimpleListReport();
     $report->setTableTitle($title);
     $report->setTableHeaders($header);
     $report->setTableContent($data);
     $report->setFilename($fileName);
     $report->createSpreadsheet();
 }
Beispiel #12
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)));
     }
 }
Beispiel #13
0
 public function toExcelAction()
 {
     $id = $this->getRequest()->getParam("id");
     $focusGroup = FocusGroupQuery::create()->findByPKOrThrow($id, $this->i18n->_("The FocusGroup with id {$id} wasn't found"));
     $poll = PollQuery::create()->findByPKOrThrow($focusGroup->getIdPoll(), $this->i18n->_("The Poll with id {$focusGroup->getIdPoll()} wasn't found"));
     $participants = RespondentQuery::create()->innerJoinFocusGroup()->whereAdd('FocusGroup.' . FocusGroup::ID_FOCUS_GROUPS, $focusGroup->getIdFocusGroups())->find();
     $npds = NpdSheetQuery::create()->innerJoinFocusGroup()->whereAdd('FocusGroup.' . FocusGroup::ID_FOCUS_GROUPS, $focusGroup->getIdFocusGroups(), BaseQuery::EQUAL)->find()->toObjectArray();
     $images = array();
     $suppliers = array();
     foreach ($npds as $npd) {
         $npdSupplier = NpdSheetSupplierQuery::create()->whereAdd(NpdSheetSupplier::ID_NPD_SHEET, $npd->getIdNpdSheet())->findOne();
         if ($npdSupplier) {
             $supplier = SapSupplierQuery::create()->findByPK($npdSupplier->getIdSupplier());
         }
         $query = FileQuery::create()->addColumns(array("File.*"))->innerJoinNpdSheetSupplier()->whereAdd("File." . File::TYPE, $type, FileQuery::EQUAL)->whereAdd("NpdSheetSupplier." . NpdSheetSupplier::ID_NPD_SHEET, $npd->getIdNpdSheet());
         if ($supplier) {
             $query->whereAdd("NpdSheetSupplier." . NpdSheetSupplier::ID_SUPPLIER, $supplier->getIdSupplier());
             $suppliers[$npd->getIdNpdSheet()] = $supplier;
         }
         $images[$npd->getIdNpdSheet()] = $query->findOne();
         if (!$images[$npd->getIdNpdSheet()]) {
             if (null != ($npdImages = NpdSheetQuery::getNpdSheetFileObjects($npd->getIdNpdSheet(), File::$typeFile["typeImage"]))) {
                 $images[$npd->getIdNpdSheet()] = $npdImages->getOne();
             }
         }
     }
     $questions = QuestionQuery::create()->innerJoinPoll()->whereAdd("PollQuestions.id_poll", $poll->getIdPoll(), BaseQuery::EQUAL)->orderBy("PollQuestions.order")->find();
     $colors = ColorQuery::create()->find()->toCombo();
     require_once 'PHPExcel.php';
     $objPHPExcel = new PHPExcel();
     $activeSheet = $objPHPExcel->setActiveSheetIndex(0);
     $activeSheet->mergeCells('A1:A2')->setCellValue('A1', $this->i18n->_('NPD ID'))->mergeCells('B1:B2')->setCellValue('B1', $this->i18n->_('Supplier'))->mergeCells('C1:C2')->setCellValue('C1', $this->i18n->_('Image'))->mergeCells('D1:D2')->setCellValue('D1', $this->i18n->_('Description'))->mergeCells('E1:E2')->setCellValue('E1', $this->i18n->_('MX Price'));
     $i = 5;
     foreach ($participants as $participant) {
         $last = $i + $questions->count() - 1;
         $activeSheet->mergeCells($this->getExcelColumn($i) . '1:' . $this->getExcelColumn($last) . '1');
         $activeSheet->setCellValue($this->getExcelColumn($i) . '1', $participant->getName());
         foreach ($questions as $question) {
             $activeSheet->setCellValue($this->getExcelColumn($i) . '2', $question->getDescription());
             $i++;
         }
     }
     $i = 3;
     foreach ($npds as $npd) {
         $activeSheet->setCellValue("A{$i}", $npd->getIdNpdSheet());
         if ($suppliers[$npd->getIdNpdSheet()]) {
             $activeSheet->setCellValue("B{$i}", $suppliers[$npd->getIdNpdSheet()]->getName());
         }
         if ($images[$npd->getIdNpdSheet()]) {
             $link = new PHPExcel_Cell_Hyperlink();
             $link->setUrl($this->getFullBaseUrl() . '/' . $images[$npd->getIdNpdSheet()]->getContent());
             $activeSheet->setCellValue("C{$i}", $this->getFullBaseUrl() . '/' . $images[$npd->getIdNpdSheet()]->getContent())->setHyperlink("C{$i}", $link);
         }
         $activeSheet->setCellValue("D{$i}", $npd->getDescription());
         $activeSheet->setCellValue("E{$i}", $npd->getPrice());
         $j = 5;
         foreach ($participants as $participant) {
             $questions->rewind();
             while ($question = $questions->read()) {
                 if ($pollResponse = PollResponseQuery::create()->whereAdd(PollResponse::ID_FOCUS_GROUP, $focusGroup->getIdFocusGroups())->whereAdd(PollResponse::ID_POLL, $focusGroup->getIdPoll())->whereAdd(PollResponse::ID_NPD_SHEET, $npd->getIdNpdSheet())->whereAdd(PollResponse::ID_RESPONDENT, $participant->getIdRespondent())->whereAdd(PollResponse::ID_QUESTION, $question->getIdQuestion())->findOne()) {
                     $q = new Question();
                     if ($question->getIdType() == Question::$Type['Yes/No']) {
                         switch ($pollResponse->getResponse()) {
                             case "true":
                                 $pollResponse->setResponse('Si');
                                 break;
                             case "false":
                                 $pollResponse->setResponse('No');
                                 break;
                         }
                     }
                     if ($question->getIdType() == Question::$Type['Multiple']) {
                         $multipleResponseQuery = QuestionMultipleResponseQuery::create()->whereAdd(QuestionMultipleResponse::ID_QUESTION, $question->getIdQuestion())->find();
                         while ($multipleResponse = $multipleResponseQuery->read()) {
                             if ($pollResponse->getResponse() == $multipleResponse->getIdResponse()) {
                                 $pollResponse->setResponse($multipleResponse->getDescription());
                             }
                         }
                     }
                     $activeSheet->setCellValue($this->getExcelColumn($j) . $i, $pollResponse->getResponse());
                 }
                 $j++;
             }
         }
         $i++;
     }
     header("Content-Type: application/vnd.ms-excel");
     header("Content-Disposition: attachment; filename=\"{$focusGroup->getName()}.xlsx\"");
     header("Cache-Control: max-age=0");
     $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
     $objWriter->save("php://output");
     exit;
 }
 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';
 }
Beispiel #15
0
 public function getCompanyName()
 {
     if (SapSupplierQuery::create()->whereAdd(SapSupplier::ID_SUPPLIER, $this->getCustomerNumber())->find()->count()) {
         $supplier = SapSupplierQuery::create()->findByPK($this->getCustomerNumber());
     } else {
         $supplier = new SapSupplier();
     }
     return $supplier->getSupplierCardCodeWithCardName();
 }
 public function saveProgrammedPaymentAction()
 {
     $id = $this->getRequest()->getParam('id');
     $paymentStatus = $this->getRequest()->getParam('payment_status');
     $folioImport = FolioImportQuery::create()->findByPK($id);
     $sapConnector = new SAPConnectorClient();
     $redir = $this->getBaseUrl() . '/' . $this->getRequest()->getParam('controller') . '/list';
     $programmedPayments = $this->getRequest()->getParam('payment-term');
     $date = \Zend_Date::now();
     $results = array();
     $this->getCatalog('ProgrammedPaymentCatalog')->beginTransaction();
     foreach ($programmedPayments as $programmedPayment) {
         if (empty($programmedPayment['id_folios_import_programmed_payment'])) {
             $supplier = SapSupplierQuery::create()->findByPK($programmedPayment['id_company']);
             $servicePurchaseOrder = PurchaseOrderFactory::createFromArray(array('id_purchase_order' => "0", 'id_supplier' => $supplier->getCardCode(), 'purchase_order_date' => $date->get("yyyy-MM-dd"), 'delivery_estimate_date' => $date->get("yyyy-MM-dd"), 'invoice_number' => 'Pending', 'id_currency' => $programmedPayment['id_currency'], 'comments' => "Folio Import Service Purchase Order", 'groupnum' => $supplier->getGroupnum(), 'status' => PurchaseOrder::$Status["NewService"], 'id_courtyard' => -1, 'id_folio_import' => $programmedPayment['id_folio_import']));
             $purchaseOrderEntries = new PurchaseOrderEntryCollection();
             $linesCount = 0;
             $purchaseOrderEntry = PurchaseOrderEntryFactory::createFromArray(array('line' => $linesCount, "vis_order" => $linesCount, "id_product" => $programmedPayment['concept'], "quantity" => 1, "price" => $programmedPayment['ammount'], "id_warehouse_store" => '9999', "tax_code" => 'W3', 'lead_time' => -1, 'status' => PurchaseOrderEntry::$Status["ServiceEntry"], 'base_line' => -1, 'base_entry' => -1));
             $purchaseOrderEntries->append($purchaseOrderEntry);
             $result = $sapConnector->servicePurchaseOrder($servicePurchaseOrder, $purchaseOrderEntries);
             $results[] = array('success' => $result->purchaseOrderResult->success, 'id_purchase_order' => $result->purchaseOrderResult->id, 'id_folio_import' => $id, 'message' => $result->purchaseOrderResult->message);
             if ($result->purchaseOrderResult->success) {
                 $programmedPayment['doc_entry'] = $result->purchaseOrderResult->id;
                 $idFolioImportProgrammedPayment = $programmedPayment['id_folios_import_programmed_payment'];
                 if ($idFolioImportProgrammedPayment) {
                     if ($programmedPayment['status']) {
                         unset($programmedPayment['status']);
                         $folioImportProgrammedPayment = FolioImportProgrammedPaymentFactory::createFromArray($programmedPayment);
                         $folioImportProgrammedPayment->setType(ProgrammedPayment::$TypePayment['Folio']);
                         $this->getCatalog('FolioImportProgrammedPaymentCatalog')->update($folioImportProgrammedPayment);
                     }
                 } else {
                     $folioImportProgrammedPayment = FolioImportProgrammedPaymentFactory::createFromArray($programmedPayment);
                     $folioImportProgrammedPayment->setType(ProgrammedPayment::$TypePayment['Folio']);
                     $folioImportProgrammedPayment->setStatus(ProgrammedPayment::$TypeStatus['Pending']);
                     $folioImportProgrammedPayment->setIdFolioImport($id);
                     $folioImportProgrammedPayment->setFolio($folioImport->getFolio());
                     $this->getCatalog('FolioImportProgrammedPaymentCatalog')->create($folioImportProgrammedPayment);
                 }
             }
         }
     }
     try {
         if ($this->setResponseMessage($results) && $paymentStatus == FolioImport::$PaymentStatus['Inactive']) {
             $this->setFlash('warning', 'The payments were closed');
             $purchaseOrderQuery = PurchaseOrderQuery::create();
             $purchaseOrders = $purchaseOrderQuery->whereAdd(PurchaseOrder::ID_FOLIO_IMPORT, $id)->whereAdd(PurchaseOrder::STATUS, PurchaseOrder::$Status['NewService'], PurchaseOrderQuery::NOT_EQUAL)->find();
             $result = $sapConnector->createLandedCost($purchaseOrders);
         } else {
             $this->setFlash('warning', 'The payments were NOT closed');
         }
     } catch (Exception $e) {
         $this->getCatalog("ProgrammedPaymentCatalog")->rollBack();
         $this->setFlash('error', $this->i18n->_($e->getMessage()));
     }
     $this->newLogForPaymentAdded($folioImport);
     $this->getCatalog('ProgrammedPaymentCatalog')->commit();
     $this->_redirect('folio-import/list');
 }
Beispiel #17
0
 /**
  * @return \Application\Model\Collection\SapSupplierCollection
  */
 public function setSupplierCollection()
 {
     $this->suppliers = SapSupplierQuery::create()->whereAdd(SapSupplier::ID_SUPPLIER, $this->getDistinctSuppliers(), SupplierQuery::IN)->find();
 }
 /**
  * 
  * @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;
 }
Beispiel #19
0
 /**
  * this function search SapSuppliers associates with the access role  
  * 
  * @author Erick Guevara Martínez
  * @param AccessRole $accessRole
  * @return SapSupplieCollection
  */
 public function getAssociateSuppliers(AccessRole $accessRole)
 {
     $countries = AccessRoleQuery::create()->innerJoinAccesRoleCountry()->addColumn("AccessRole2Country.id_country")->whereAdd("AccessRole2Country.id_access_role", $accessRole->getIdAccessRole())->fetchCol();
     $suppliers = SapSupplierQuery::create()->innerJoinSapSupplierAddress()->whereAdd("CRD1.Country", $countries)->onlySuppliers()->find();
     return $suppliers;
 }
 /**
  *
  */
 public function exportToExcelAction()
 {
     $params = $this->getRequest()->getParams();
     $proformasInvoice = ProformaInvoiceQuery::create()->filter($params)->find();
     $proformasInvoiceEntries = ProformaInvoiceEntryQuery::create()->whereAdd(ProformaInvoiceEntry::ID_PROFORMA_INVOICE, $proformasInvoice->getPrimaryKeys(), ProformaInvoiceEntryQuery::IN)->find();
     $suppliers = SapSupplierQuery::create()->whereAdd(SapSupplier::CARDCODE, $proformasInvoice->getDistinctSuppliers(), SupplierQuery::IN)->find();
     $products = ProductQuery::create()->whereAdd(Product::ITEM_CODE, $proformasInvoiceEntries->getIdProducts(), ProductQuery::IN)->find();
     $currencies = CurrencyQuery::create()->find();
     $countries = CountryQuery::create()->find();
     require_once 'PHPExcel.php';
     $objPHPExcel = new PHPExcel();
     $activeSheet = $objPHPExcel->setActiveSheetIndex(0);
     $activeSheet->setCellValue('A1', $this->i18n->_('Proforma Invoice Folio'))->setCellValue('B1', $this->i18n->_('Proforma Invoice Number'))->setCellValue('C1', $this->i18n->_('Proforma Invoice Status'))->setCellValue('D1', $this->i18n->_('Supplier Code'))->setCellValue('E1', $this->i18n->_('Supplier Name'))->setCellValue('F1', $this->i18n->_('Destination Country'))->setCellValue('G1', $this->i18n->_('Creation Date'))->setCellValue('H1', $this->i18n->_('Line Number'))->setCellValue('I1', $this->i18n->_('Line Status'))->setCellValue('J1', $this->i18n->_('Parent Key'))->setCellValue('K1', $this->i18n->_('Product Key'))->setCellValue('L1', $this->i18n->_('Description'))->setCellValue('M1', $this->i18n->_('Quantity'))->setCellValue('N1', $this->i18n->_('Open Price'))->setCellValue('O1', $this->i18n->_('Import'))->setCellValue('P1', $this->i18n->_('Currency'));
     $i = 2;
     while ($proformasInvoice->valid()) {
         $proformaInvoice = $proformasInvoice->read();
         $supplier = $suppliers->getByPK($proformaInvoice->getIdSupplier());
         $country = $countries->getByPK($proformaInvoice->getIdDestinationCountry());
         $proformaInvoiceEntries = $proformasInvoiceEntries->getByIdProformaInvoice($proformaInvoice->getIdProformaInvoice());
         $currency = $currencies->getByPkOrEmpty($proformaInvoice->getIdCurrency());
         $entriesCount = $i;
         while ($proformaInvoiceEntries->valid()) {
             $proformaInvoiceEntry = $proformaInvoiceEntries->read();
             $product = $products->getByPK($proformaInvoiceEntry->getIdProduct());
             $activeSheet->setCellValue('A' . $entriesCount, $proformaInvoice->getIdProformaInvoice())->setCellValue('B' . $entriesCount, $proformaInvoice->getFolio())->setCellValue('C' . $entriesCount, $proformaInvoice->getStatusName())->setCellValue('D' . $entriesCount, $supplier->getCardCode())->setCellValue('E' . $entriesCount, $supplier->getCardname())->setCellValue('F' . $entriesCount, utf8_encode($country->getName()))->setCellValue('G' . $entriesCount, $proformaInvoice->getDocDate())->setCellValue("H" . $entriesCount, $proformaInvoiceEntry->getLine())->setCellValue("I" . $entriesCount, $proformaInvoiceEntry->getStatusName())->setCellValue("J" . $entriesCount, $product->getKeyMother())->setCellValue("K" . $entriesCount, $product->getItemCode())->setCellValue("L" . $entriesCount, $product->getItemName())->setCellValue("M" . $entriesCount, $proformaInvoiceEntry->getQuantity())->setCellValue("N" . $entriesCount, $proformaInvoiceEntry->getPrice())->setCellValue("O" . $entriesCount, $proformaInvoiceEntry->getQuantity() * $proformaInvoiceEntry->getPrice())->setCellValue("P" . $entriesCount, $currency->getCurrCode());
             $entriesCount++;
         }
         $i = $entriesCount;
     }
     header("Content-Type: application/vnd.ms-excel");
     $date = \Zend_Date::now();
     $fileName = $this->i18n->_("Proforma_invoice_report") . $date->get("ddMMyyyy");
     header("Content-Disposition: attachment; filename=\"{$fileName}.xlsx\"");
     header("Cache-Control: max-age=0");
     $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
     $objWriter->save("php://output");
     exit;
 }
 public function exportToExcelAction()
 {
     $params = $this->getRequest()->getParams();
     $allPurchaseOrderEntries = PurchaseOrderEntryQuery::create()->find();
     $purchaseOrders = PurchaseOrderQuery::create()->filter($params)->addDescendingOrderBy(PurchaseOrder::PURCHASE_ORDER_DATE)->whereAdd("PurchaseOrder.DocType", "I")->whereAdd("PurchaseOrderEntry.ItemCode", "TR%", 'NOT LIKE')->whereAdd("PurchaseOrderEntry.WhsCode", "9999", PurchaseOrderQuery::NOT_LIKE)->whereAdd(PurchaseOrder::ID_PURCHASE_ORDER, $allPurchaseOrderEntries->getDistinctPurchaseOrder(), PurchaseOrderQuery::IN)->find();
     $products = ProductQuery::create()->whereAdd(Product::ITEM_CODE, $allPurchaseOrderEntries->getProducts(), ProductQuery::IN)->find();
     $suppliers = SapSupplierQuery::create()->whereAdd(SapSupplier::ID_SUPPLIER, $purchaseOrders->getDistinctSuppliers(), SapSupplierQuery::IN)->find();
     $warehousesStores = WarehouseStoreQuery::create()->whereAdd(WarehouseStore::CODE, $allPurchaseOrderEntries->getDistinctIdWarehouseStore(), WarehouseStoreQuery::IN)->find();
     $warehouses = WarehouseQuery::create()->whereAdd(Warehouse::CODE, $warehousesStores->getDistinctWarehouses(), WarehouseQuery::IN)->find();
     $currencies = CurrencyQuery::create()->find();
     $countries = CountryQuery::create()->find();
     require_once 'PHPExcel.php';
     $objPHPExcel = new PHPExcel();
     $activeSheet = $objPHPExcel->setActiveSheetIndex(0);
     $activeSheet->setCellValue('A1', $this->i18n->_('Purchase Order Folio'))->setCellValue('B1', $this->i18n->_('Destination Country'))->setCellValue('C1', $this->i18n->_('Supplier Code'))->setCellValue('D1', $this->i18n->_('Supplier Name'))->setCellValue('E1', $this->i18n->_('Creation Date'))->setCellValue('F1', $this->i18n->_('Status'))->setCellValue('G1', $this->i18n->_('Entry Line'))->setCellValue('H1', $this->i18n->_('Product Code'))->setCellValue('I1', $this->i18n->_('Product Description'))->setCellValue('J1', $this->i18n->_('Amount'))->setCellValue('K1', $this->i18n->_('Price'))->setCellValue('L1', $this->i18n->_('Import'))->setCellValue('M1', $this->i18n->_('Currency'))->setCellValue('N1', $this->i18n->_('Location'))->setCellValue('O1', $this->i18n->_('Warehouse'));
     $activeSheet->getDefaultStyle()->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
     $i = 2;
     while ($purchaseOrders->valid()) {
         $purchaseOrder = $purchaseOrders->read();
         $currency = $currencies->getByPkOrEmpty($purchaseOrder->getIdCurrency());
         $supplier = $suppliers->getByPkOrElse($purchaseOrder->getIdSupplier(), new SapSupplier());
         $country = $countries->getByPK($purchaseOrder->getIdDestinationCountry());
         $purchaseOrderEntries = $allPurchaseOrderEntries->filterByPurchaseOrderPk($purchaseOrder->getIdPurchaseOrder());
         $entriesCount = $i;
         while ($purchaseOrderEntries->valid()) {
             $purchaseOrderEntry = $purchaseOrderEntries->read();
             $product = $products->getByPK($purchaseOrderEntry->getIdProduct()) ? $products->getByPK($purchaseOrderEntry->getIdProduct()) : new Product();
             $warehouseStore = $warehousesStores->getByPkOrElse($purchaseOrderEntry->getIdWarehouseStore(), new WarehouseStore());
             $warehouse = $warehouseStore->getLocation() > 0 ? $warehouses->getByPK($warehouseStore->getLocation()) : new WarehouseStore();
             $activeSheet->setCellValue('A' . $entriesCount, $purchaseOrder->getSapDocumentNumber())->setCellValue('B' . $entriesCount, utf8_encode($country->getName()))->setCellValue('C' . $entriesCount, $supplier->getCardCode())->setCellValue('D' . $entriesCount, $supplier->getCardname())->setCellValue('E' . $entriesCount, $purchaseOrder->getPurchaseOrderDate())->setCellValue('F' . $entriesCount, $purchaseOrder->getStatusName())->setCellValue("G" . $entriesCount, $purchaseOrderEntry->getLine())->setCellValue("H" . $entriesCount, $product->getItemCode())->setCellValue("I" . $entriesCount, $product->getItemName())->setCellValue("J" . $entriesCount, $purchaseOrderEntry->getAmount())->setCellValue("K" . $entriesCount, $purchaseOrderEntry->getPrice())->setCellValue("L" . $entriesCount, $purchaseOrderEntry->getImport())->setCellValue("M" . $entriesCount, $currency->getCurrCode())->setCellValue("N" . $entriesCount, $warehouse->getName())->setCellValue("O" . $entriesCount, $warehouseStore->getName());
             $entriesCount++;
         }
         $i = $entriesCount;
     }
     $columns = range('A', 'O');
     foreach ($columns as $column) {
         $activeSheet->getColumnDimension($column)->setAutoSize(true);
     }
     header("Content-Type: application/vnd.ms-excel");
     $date = \Zend_Date::now();
     $fileName = $this->i18n->_("Purchase_orders_report") . $date->get("ddMMyyyy");
     header("Content-Disposition: attachment; filename=\"{$fileName}.xlsx\"");
     header("Cache-Control: max-age=0");
     $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
     $objWriter->save("php://output");
     exit;
 }
 /**
  *
  * @author Erick Guevara Martínez
  * @param ProgrammedPaymentCollection $payments
  * @return SapSupplierCollection
  */
 public function getSuppliers(ProgrammedPaymentCollection $payments)
 {
     $payments->merge($this->getVirtualProgrammedPaymentCollection());
     $supplierIds = $payments->getCompanyIds();
     $supplierIds += $this->getProformaInvoiceCollection() ? $this->getProformaInvoiceCollection()->getDistinctSuppliers() : array();
     $supplierIds += $this->getPurchaseOrderCollection() ? $this->getPurchaseOrderCollection()->getDistinctSuppliers() : array();
     return SapSupplierQuery::create()->whereAdd(SapSupplier::CARDCODE, $supplierIds)->find();
 }
Beispiel #23
0
 /**
  * 
  * @param NpdSheet $npd
  * @param SapSupplier $supplier
  * @param Color $color
  * @return array
  */
 public function toArrayForList()
 {
     if (!empty($this->idNpdSheet)) {
         $npd = NpdSheetQuery::create()->findByPK($this->getIdNpdSheet());
     }
     if (!$npd instanceof NpdSheet) {
         $npd = new NpdSheet();
     }
     if (!empty($this->idSupplier)) {
         $supplier = SapSupplierQuery::create()->findByPK($this->getIdSupplier());
     }
     if (!$supplier instanceof SapSupplier) {
         $supplier = new SapSupplier();
     }
     if (!empty($this->idColor)) {
         $color = ColorQuery::create()->findByPK($this->getIdColor());
     }
     if (!$color instanceof Color) {
         $color = new Color();
     }
     return array('npd_status' => $npd->getStatusName(), 'name' => utf8_encode($npd->getName()), 'reference' => utf8_encode($npd->getReference()), 'supplier' => utf8_encode($supplier->getName()), 'color' => utf8_encode($color->getName()), 'id_sample' => $this->getIdSample(), 'id_npd_sheet' => $this->getIdNpdSheet(), 'quantity' => $this->getQuantity(), 'folio' => $this->getFolio(), 'notes' => utf8_encode($this->getNotes()), 'status' => $this->getStatus(), 'status_name' => $this->getStatusName(), 'deadline' => $this->getDeadline(), 'shipped_quantity' => $this->getShippedQuantity(), 'is_ordered' => $this->isOrdered(), 'is_requested_to_supplier' => $this->isRequestedToSupplier(), 'is_sent' => $this->isSent());
 }