示例#1
0
 /**
  *
  * @return array
  */
 public function newAction()
 {
     $this->view->contentTitle = $this->i18n->_('New Participant');
     $this->view->respondent = new Respondent();
     $this->view->setTpl('Form');
     $this->view->action = 'create';
     $this->view->profiles = SapSupplier::getCustomerProfilesCombo($this->i18n->_('Customer Profiles'));
     $this->view->genders = array("" => "Select Gender") + Respondent::$GenderCombo;
 }
示例#2
0
 /**
  *
  * @return array
  */
 public function updateAction()
 {
     $params = $this->getRequest()->getParams();
     //die("<pre>".print_r($params, true)."</pre>");
     $baseProduct = ProductQuery::create()->findByPK($params['id']);
     $products = ProductQuery::create()->whereAdd(Product::ITEM_CODE, substr($params['id'], 0, 9), ProductQuery::LIKE)->find();
     $brand = BrandQuery::create()->findByPKOrThrow($params["idBrand"], $this->i18n->_("The Brand with id {$params["idBrand"]} does not exist."));
     if ($params["supplier_id"] != '') {
         $supplier = SapSupplierQuery::create()->findByPKOrThrow($params["supplier_id"], $this->i18n->_("The Supplier with id {$params["supplier_id"]} does not exist."));
     } else {
         $supplier = new SapSupplier();
     }
     $path = 'product/' . $params["keyMother"] . '/';
     $savedFile = $this->saveFile('importationPermission', $path);
     if ($savedFile instanceof File) {
         $this->getFileCatalog()->beginTransaction();
         try {
             $this->getFileCatalog()->create($savedFile);
             $this->getFileCatalog()->commit();
         } catch (Exception $e) {
             $this->getFileCatalog()->rollBack();
             throw new \InvalidArgumentException($this->i18n->_("The Import Permit File can't be saved."));
         }
     } else {
         $savedFile = new File();
         $savedFile->setIdFile(0);
     }
     $colors = ColorQuery::create()->find();
     $test = 1;
     $responses = array();
     foreach ($params["colors"] as $item) {
         $error = false;
         $new = false;
         if (!empty($item["idItem"])) {
             $itemcode = $item["idItem"];
             $codPro = $params["keyMother"] . $brand->getName();
             $color = new Color();
         } else {
             $new = true;
             $color = $colors->getByPkOrElse($item["idColor"], new Color());
             $itemcode = ($codPro = $baseProduct->getKeyMother() . $brand->getName()) . $color->getCode();
             if (ProductGroupQuery::create()->whereAdd(ProductGroup::ID_PRODUCT_GROUP, $params["idProductGroup"])->count()) {
                 $productGroup = ProductGroupQuery::create()->findByPK($params["idProductGroup"]);
             } else {
                 $error = true;
                 $response[0] = false;
                 $response[1] = $itemcode;
                 $responses[] = $response;
             }
             if (FamilyQuery::create()->whereAdd(Family::ID_FAMILY, $params["IdCategory"])->count()) {
                 $family = FamilyQuery::create()->findByPK($params["IdCategory"]);
             } else {
                 $family = new Family();
                 $family->setName(0);
                 $family->setIdFamily(0);
             }
             if (SubfamilyQuery::create()->whereAdd(Subfamily::ID_SUBFAMILY, $params['idSubfamily'])->count()) {
                 $subfamily = SubfamilyQuery::create()->findByPK($params["idSubfamily"]);
             } else {
                 $subfamily = new Subfamily();
                 $subfamily->setCode(0);
             }
         }
         if (!empty($params["goodTrough"])) {
             $date = new Zend_Date(strtolower($params["goodTrough"]), "MMM dd yyyy");
         }
         if (!$error) {
             $productArray = array('CstGrpCode' => $params["idCustomsTariffCode"], 'FirmCode' => $brand->getCode(), 'U_Color' => $color->getCode(), 'U_Categoria' => 0, 'U_PCS_Id_Categoria' => 0, 'ItmsGrpCod' => 0, 'U_Id_Familia' => 0, 'U_Familia' => 0, 'U_id_subcategoria' => 0, 'U_PCS_Impor_per_id' => $savedFile ? $savedFile->getIdFile() : $products->current()->getImportPermit(), 'CardCode' => $supplier->getCardCode(), 'U_PCSid_npd_sheet' => $params["idNpd"] > 0 ? $params["idNpd"] : -1, 'ItemCode' => $itemcode, 'ItemName' => $item["itemName"], 'SWW' => $item["status"], 'Invntitem' => 1, 'PrchseItem' => 1, 'U_id_marca' => $brand->getName(), 'U_Marca' => $brand->getName(), 'SellItem' => 1, 'U_Madre_09' => $params["keyMother"], 'U_CODPRO' => $codPro, 'BuyUnitMsr' => "PZA", 'NumInBuy' => 1, 'SalUnitMsr' => "PZA", 'NumInSale' => 1, 'InvntryUom' => "PZA", 'U_MCFrente' => $params["mcFront"], 'U_MCAltura' => $params["mcHeight"], 'U_MCProfundida' => $params["mcDepth"], 'U_MCPeso' => $params["mcWeight"], 'U_PzasXCaja' => $params["mcParts"], 'U_PCS_Pieces_per_inn' => $params["piecesPerInner"], 'U_pzafrente' => $params["pzaFront"], 'U_pzaaltura' => $params["pzaHeight"], 'U_pzaprofu' => $params["pzaDepth"], 'U_PesoxPza' => $params["pzaWeight"], 'U_pzadiametro' => $params["pzaDiameter"], 'U_PCS_Individual_Pac' => $params["individualPackage"], 'U_PCS_Packing_Front' => $params["packingFront"], 'U_PCS_Packing_Height' => $params["packingHeight"], 'U_PCS_Packing_Depth' => $params["packingDepth"], 'U_PCS_Packing_Weight' => $params["packingWeight"], 'U_PCS_Packing_Diamet' => $params["packingDiameter"], 'U_PCS_Def_Freight_Fa' => $params["defaultFreightFare"], 'U_PCS_Important' => $params["important"] ? 1 : 0, 'U_PCS_Rescue' => $params["rescue"] ? 1 : 0, 'U_PCS_VIM' => $params["vim"], 'U_PCS_Individual_VIM' => $item["vim"], 'U_PCS_import_permit' => $params["remarks"], 'U_PCS_Put_trougth' => $date instanceof Zend_Date ? $date->get("yyyy-MM-dd") : "", 'U_PCS_Catalog_Year' => $params["catalogYear"], 'LeadTime' => $params["lead_time"], 'U_PCS_id_incoterm' => $params["incoterm"], 'U_PCS_manual_restock' => $params["manual_restock"] ? 1 : 0, 'Price' => $params["price"], 'Currency' => $params["currency"], 'U_ShortName' => $params['U_ShortName']);
             if ($new) {
                 $productArray['U_Categoria'] = $family->getName();
                 $productArray['U_PCS_Id_Categoria'] = $family->getIdFamily();
                 $productArray['ItmsGrpCod'] = $productGroup->getIdProductGroup();
                 $productArray['U_Id_Familia'] = $productGroup->getCode();
                 $productArray['U_Familia'] = $productGroup->getName();
                 $productArray['U_id_subcategoria'] = $subfamily->getCode();
             }
             if ($products->containsIndex($itemcode)) {
                 $product = $products->getByPK($itemcode);
                 ProductFactory::populate($product, $productArray);
             } else {
                 $product = ProductFactory::createFromArray($productArray);
             }
             $test++;
             $products->append($product);
         }
     }
     // 		die("<pre>".print_r($products, true)."</pre>");
     $SAPProductManager = new SapProductSaveManager();
     $responses += $SAPProductManager->save($products, $this->getUser()->getBean());
     foreach ($responses as $response) {
         if ($response[0] == 200) {
             $success .= "<br>" . $this->i18n->_("The Product with id {$response[1]} was updated correctly.");
         } else {
             $error .= "<br>" . $this->i18n->_("The Product with id {$response[1]} can't be updated.");
         }
     }
     if (strlen($success) > 0) {
         $this->setFlash('ok', $success);
     }
     if (strlen($error) > 0) {
         $this->setFlash('error', $error);
     }
     $this->_redirect('product/list');
 }
 public function exportToExcelByDateAction()
 {
     $filters = $this->getRequest()->getParams();
     $programmedPaymentManager = new ProgrammedPaymentManager();
     $payments = $programmedPaymentManager->getProgrammedPayments($filters);
     $condensedProgrammedPayments = $programmedPaymentManager->getCondensedProgrammedPayments($payments);
     $suppliers = $programmedPaymentManager->getSuppliers($payments);
     $dates = $condensedProgrammedPayments->getDatesAndIndex("asc");
     foreach ($dates as $date) {
         $pay = $condensedProgrammedPayments->getByPK($date["index"]);
         $supplier = $suppliers->getByPK($pay->getIdSupplier());
         if (!$supplier instanceof SapSupplier) {
             $supplier = new SapSupplier();
         }
         $data[$i] = array(0 => $paymentArray[$pay->getIdSupplier()][$pay->getCurrency()][0] = $pay->getDueDateAsZendDate() instanceof \Zend_Date ? $pay->getDueDateAsZendDate()->get("yyyy-MM-dd") : $pay->getDueDate(), 1 => $paymentArray[$pay->getIdSupplier()][$pay->getCurrency()][1] = $pay->getTypeName(), 2 => $paymentArray[$pay->getIdSupplier()][$pay->getCurrency()][2] = $pay->getSapDocnum(), 3 => $paymentArray[$pay->getIdSupplier()][$pay->getCurrency()][3] = $supplier->getIndex(), 4 => $paymentArray[$pay->getIdSupplier()][$pay->getCurrency()][4] = $supplier->getName(), 5 => $paymentArray[$pay->getIdSupplier()][$pay->getCurrency()][5] = $pay->getCurrency(), 6 => $paymentArray[$pay->getIdSupplier()][$pay->getCurrency()][6] = $pay->getAmmount(), 7 => $paymentArray[$pay->getIdSupplier()][$pay->getCurrency()][7] = $pay->getCredits(), 8 => $paymentArray[$pay->getIdSupplier()][$pay->getCurrency()][8] = $pay->getPendingBalance());
         $i++;
     }
     $header = array($this->i18n->_('Due Date'), $this->i18n->_('Document'), $this->i18n->_('Document Number'), $this->i18n->_('Card Code'), $this->i18n->_('Name'), $this->i18n->_('Currency'), $this->i18n->_('Debits'), $this->i18n->_('Credits'), $this->i18n->_('Pending Balance'));
     $title = $this->i18n->_('Programmed Payment Report (by Date)');
     $fileName = $this->i18n->_('programmed_payment_report');
     $report = new SimpleListReport();
     $report->setTableTitle($title);
     $report->setTableHeaders($header);
     $report->setTableContent($data);
     $report->setFilename($fileName);
     $report->createSpreadsheet();
 }
 /**
  * 
  * 
  * @author Erick Guevara Martínez
  * @param SapSupplier $sapSupplier
  * @return \Application\Model\Collection\CondensedProgrammedPaymentCollection|boolean
  */
 public function filterBySapSupplier(SapSupplier $sapSupplier)
 {
     return $this->filter(function (CondensedProgrammedPayment $condensedProgrammedPayment) use($sapSupplier) {
         return $condensedProgrammedPayment->getIdSupplier() == $sapSupplier->getCardCode();
     });
 }
 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'];
 }
示例#6
0
 public function rateSupplier(SapSupplier $supplier)
 {
     $addresses = array();
     $contactEmployees = array();
     $sapSupplierAddresses = $supplier->getAddresses();
     $sapSupplierContactEmployees = $supplier->getContacts();
     while ($sapSupplierAddress = $sapSupplierAddresses->read()) {
         $addresses[] = self::createSapSupplierAddress($sapSupplierAddress);
     }
     while ($sapSupplierContactEmployee = $sapSupplierContactEmployees->read()) {
         $contactEmployees[] = self::createSapSupplierContactEmployee($sapSupplierContactEmployee);
     }
     $parameters['sapBusinessPartner'] = array("Cardcode" => $supplier->getCardcode(), "Cardname" => utf8_encode($supplier->getCardname()), "Currency" => $supplier->getCurrency(), "GroupNum" => $supplier->getGroupnum(), "GroupCode" => $supplier->getGroupCode(), "LicTradNum" => utf8_encode($supplier->getRfc()), "CmpRegistrationNumber" => 123, "concistency" => $supplier->getConsistency(), "idApprovalStatus" => $supplier->getIdApprovalStatus(), "idDefinedPort" => $supplier->getIdDefaultPort(), "idFinalGrandRisk" => $supplier->getIdFinalRisk(), "idPaymentTerms" => $supplier->getIdPaymentTerm(), "quality" => $supplier->getQuality(), "time" => $supplier->getTime(), "remarks" => utf8_encode($supplier->getNotes()), "paydays" => $supplier->getPayDays(), "typeCompany" => $supplier->getCmpPrivate(), "SupplierAddresses" => $addresses, "contactPersons" => $contactEmployees);
     $result = $this->soapClient->rateSupplier($parameters);
     return $result;
 }
示例#7
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();
 }
示例#8
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');
 }
示例#9
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)));
     }
 }
示例#10
0
 /**
  * This function prepare all info to can save a proforma invoice
  *
  * @author Erick Guevara Martinez
  * @return Json
  */
 public function consolidateEntriesAction()
 {
     if ($this->getRequest()->isPost()) {
         // Get the id entries to consolidate in a proforma invoice
         $idRequisitionEntries = $this->getRequest()->getParam("idEntries", array());
         // Set the consolidate status in true (This will help us see if the consolidation is ok or fail)
         $success = true;
         // Search all currencies to get your codes, ids and symbols
         $currencies = CurrencyQuery::create()->find();
         // If the entries greater than zero then continue
         if (count($idRequisitionEntries) > 0) {
             // Search the requisition Entries to will consolidate
             $requisitionEntries = RequisitionEntryQuery::create()->whereAdd(RequisitionEntry::ID_REQUISITION_ENTRY, $idRequisitionEntries, RequisitionEntryQuery::IN)->find();
             // If the requisition entries are found then continue
             if ($requisitionEntries->count() > 0) {
                 // Search the requisition entries products
                 $products = ProductQuery::create()->whereAdd(Product::ITEM_CODE, $requisitionEntries->getDistinctProducts(), ProductQuery::IN)->find();
                 // Get the id destination country (all requisition entries must have the same id country)
                 $idDestinationCountry = RequisitionQuery::create()->findByPK($requisitionEntries->current()->getIdRequisition())->getIdDestinationCountry();
                 // Search the destination country
                 $country = CountryQuery::create()->findByPK($idDestinationCountry);
                 $countryLocations = WarehouseStoreQuery::create()->addColumns(array(WarehouseStore::LOCATION))->distinct()->whereAdd(WarehouseStore::COUNTRY, $idDestinationCountry)->fetchCol();
                 $locations = WarehouseQuery::create()->whereAdd(WareHouse::CODE, $countryLocations, WarehouseQuery::IN)->find()->toCombo($this->i18n->_("Select a Warehouse"));
                 $warehouseStores = WarehouseStoreQuery::create()->whereAdd(WarehouseStore::LOCATION, Warehouse::$defaultLocation)->whereAdd(WarehouseStore::TYPE, WarehouseStore::$Type["ppv"])->find()->toCombo($this->i18n->_("Select a Warehouse Store"));
                 // Check if the selected requisition entries have budgets autorized (one by key mother only)
                 $budgets = KeyMotherSupplierBudgetQuery::create()->innerJoinRequisitionEntry()->whereAdd("RequisitionEntry." . RequisitionEntry::ID_REQUISITION_ENTRY, $requisitionEntries->getPrimaryKeys(), BaseQuery::IN)->actives()->autorized()->find();
                 $defaultCurrency = !$budgets->isEmpty() ? $budgets->current()->getIdCurrency() : "";
                 $currencies = CurrencyQuery::create()->find();
                 // Get the products key mother to group by key mother
                 $parentKeys = $products->getKeyMother();
                 $exhangeRateConversor = new ExchangeRateConversorManager();
                 // Proccess the info searched to get the ajax response
                 foreach ($parentKeys as $parentKey) {
                     // Filter the products by key mother to consolide the entries by product
                     $parentKeyProducts = $products->filterByKeyMother($parentKey);
                     // Filter the requisition entries by product
                     $parentKeyRequisitionEntries = $requisitionEntries->filterByIdProduct($parentKeyProducts->getPrimaryKeys());
                     // Get the currency of key mother (all the requisition entries must have the same currency)
                     $parentKeyCurrency = $currencies->getByPK($parentKeyRequisitionEntries->current()->getIdCurrency());
                     // Get the specific data to create the proforma invoice
                     $response[$parentKey]["parentKey"] = $parentKey;
                     // Get the budgets of the current key mother
                     $KeyMotherBudget = $budgets->filterByKeyMother($parentKey);
                     // One budget autorized only by key mother
                     // If key mother have a autorized budget the set the budget info
                     if ($KeyMotherBudget->count() == 1) {
                         // Set the budget min price
                         $originalMinPrice = $minPrice = $KeyMotherBudget->current()->getPrice();
                         // Set the id budget
                         $response[$parentKey]["idBudget"] = $KeyMotherBudget->current()->getIdKeyMotherSupplierBudget();
                         // Set the currency budget
                         $originalCurrency = $currency = $currencies->getByPkOrEmpty($KeyMotherBudget->current()->getIdCurrency());
                         // Search the supplier to autoselect him
                         $supplier = SapSupplierQuery::create()->findByPKOrThrow($KeyMotherBudget->current()->getIdSupplier(), $this->i18n->_("The Supplier with CardCode {$KeyMotherBudget->current()->getIdSupplier()} does not exist."));
                         // Set the pieces quantity in the budget
                         $totalAmount = $KeyMotherBudget->current()->getQuantity();
                         // if does not have a autorized budget then compare the min price and set the id budget to empty
                     } else {
                         // Check if the min open price and the target price and return the less to define the max price can be the products of this key mother
                         if ($parentKeyProducts->current()->getCost() > 0) {
                             $originalMinPrice = $parentKeyRequisitionEntries->getMinOpenPrice() < $parentKeyProducts->current()->getCost() ? $parentKeyRequisitionEntries->getMinOpenPrice() : $parentKeyProducts->current()->getCost();
                         } else {
                             $originalMinPrice = $parentKeyRequisitionEntries->getMinOpenPrice();
                         }
                         $minPrice = $originalMinPrice;
                         $currency = $originalCurrency = $currencies->getByPkOrEmpty($parentKeyCurrency->getCurrCode());
                         $supplier = new Supplier();
                         // If exist a defaultCurrency then convert all min prices to exchange rate default currency
                         if ($defaultCurrency != "") {
                             $minPrice = $exhangeRateConversor->converter($originalCurrency->getCurrCode(), $defaultCurrency, $originalMinPrice);
                             $currency = $currencies->getByPkOrEmpty($defaultCurrency);
                         }
                         $response[$parentKey]["idBudget"] = "";
                         $totalAmount = $parentKeyRequisitionEntries->getTotalQuantity();
                         $supplier = new SapSupplier();
                     }
                     $response[$parentKey]["minPrice"] = $minPrice;
                     $response[$parentKey]["originalMinPrice"] = $originalMinPrice;
                     $response[$parentKey]["totalAmount"] = $totalAmount;
                     $response[$parentKey]["originalCurrency"] = $originalCurrency->getCurrCode();
                     $response[$parentKey]["currency"] = $currency->getCurrCode();
                     $response[$parentKey]["currencyCode"] = $currency->getCurrCode();
                     $response[$parentKey]["currencySymbol"] = str_replace("&#8364;", "€", $currency->getDocCurrCode());
                     // Group the requisitoion entry info by product to get the total by product
                     while ($parentKeyProduct = $parentKeyProducts->read()) {
                         $productRequisitionEntries = $parentKeyRequisitionEntries->filterByIdProduct($parentKeyProduct->getItemCode());
                         $response[$parentKey]["products"][$parentKeyProduct->getItemCode()]["productKey"] = $parentKeyProduct->getItemCode();
                         $response[$parentKey]["products"][$parentKeyProduct->getItemCode()]["description"] = $parentKeyProduct->getItemName();
                         $response[$parentKey]["products"][$parentKeyProduct->getItemCode()]["totalAmount"] = $productRequisitionEntries->getTotalQuantity();
                         // Need the ids of requisition entries to create the proforma invoice and make a link to requisition
                         $response[$parentKey]["products"][$parentKeyProduct->getItemCode()]["requisitionEntries"] = $productRequisitionEntries->getPrimaryKeys();
                     }
                 }
                 // If the requisition entries not found then the consolidation fail
             } else {
                 $success = false;
             }
             // if does not have id requisition entries the consolidation fail
         } else {
             $success = false;
         }
         die(Zend_Json::encode(array("success" => $success, "parentKeys" => $response, "idDestinationCountry" => $country->getCode(), "destinationCountryName" => utf8_encode($country->getName()), "supplierName" => $supplier->getCardCode() . "-" . utf8_encode($supplier->getCardname()), "supplierId" => $supplier->getCardCode(), "defaultCurrency" => $defaultCurrency, "warehouses" => $locations, "warehouseStores" => $warehouseStores, "defaultWarehouse" => Warehouse::$defaultLocation, "defaultWarehouseStore" => WarehouseStore::$defaultWarehouseStore)));
     }
 }
示例#11
0
文件: Sample.php 项目: Eximagen/sochi
 /**
  * 
  * @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());
 }