Example #1
0
 /**
  * 
  */
 public function getTemporalSupplierResultsAction()
 {
     $params = $this->getRequest()->getParams();
     $params['name'] = "%" . $params['name'] . "%";
     $params['contact'] = "%" . $params['contact'] . "%";
     $suppliers = TemporalSupplierQuery::create()->filter($params)->page($params['page'], $this->getMaxPerPage())->find();
     while ($supplier = $suppliers->read()) {
         $supplier->setName(utf8_encode($supplier->getName()));
         $supplier->setContact(utf8_encode($supplier->getContact()));
     }
     die(json_encode($suppliers->toArray()));
 }
 public function addSupplierAction()
 {
     //view information NPD
     $this->view->id = $idNpdSheet = $this->getRequest()->getParam('id');
     $this->view->contentTitle = 'Add Supplier';
     $this->generateUrl('npd', 'create');
     $this->view->setTpl("Add-supplier");
     $this->view->npd = $npdSheet = NpdSheetQuery::create()->findByPKOrThrow($idNpdSheet, $this->i18n->_("It does not exist the NpdSheet with id {$idNpdSheet}"));
     $family = FamilyQuery::create()->findByPK($npdSheet->getIdFamily());
     $this->view->family = $family->getName();
     if ($npdSheet->getIdSubfamily()) {
         $this->view->subfamily = SubfamilyQuery::create()->findByPK($npdSheet->getIdSubfamily())->getName();
     } else {
         $this->view->subfamily = $this->i18n->_("Any");
     }
     $this->view->productGroup = ProductGroupQuery::create()->findByPK($family->getIdProductGroup())->getName();
     $this->view->videos = FileQuery::create()->innerJoinNpdSheet()->whereAdd('File2NpdSheet.id_npd_sheet', $npdSheet->getIdNpdSheet())->whereAdd(File::TYPE, File::$typeFile["typeLink"])->find();
     $this->view->npdColors = ColorQuery::create()->innerJoinNpdSheet()->whereAdd('Color2NpdSheet.id_npd_sheet', $npdSheet->getIdNpdSheet())->find();
     $this->view->country = CountryQuery::create()->find()->toCombo();
     $this->view->npdSheetImages = NpdSheetQuery::getNpdSheetFileObjects($npdSheet->getIdNpdSheet(), File::$typeFile["typeImage"]);
     $this->view->npdSheetFiles = NpdSheetQuery::create()->addColumns(array("File.*"))->innerJoinFile()->whereAdd("NpdSheet." . NpdSheet::ID_NPD_SHEET, $npdSheet->getIdNpdSheet())->fetchAll();
     $this->view->file = $file = FileQuery::create()->innerJoinNpdSheet()->whereAdd('File2NpdSheet.id_npd_sheet', $npdSheet->getIdNpdSheet())->whereAdd(File::TYPE, File::$typeFile["typeFile"])->findOne();
     //Form add supplier
     $npdSuppliers = $npdSuppliers = NpdSheetSupplierQuery::create()->whereAdd(NpdSheetSupplier::ID_NPD_SHEET, $idNpdSheet)->find();
     $allColors = array("" => "**  Select a Color  **") + ColorQuery::create()->actives()->find()->toCombo();
     //Videos from supplier
     foreach ($npdSuppliers as $npdSupplier) {
         //Get File Video for NPDSheetSupplier
         $NPDSheetSupplierFilesQuery = NpdSheetSupplierQuery::create()->addColumns(array("File.*"))->innerJoinFile()->whereAdd("NpdSheetSupplier." . NpdSheetSupplier::ID_NPD_SUPPLIER, $npdSupplier->getIdNpdSupplier())->fetchAll();
         $NPDSheetSupplierFiles[$npdSupplier->getIdNpdSupplier()] = $NPDSheetSupplierFilesQuery;
         $assignedColors = $this->getSupplierColors($npdSupplier->getIdNpdSupplier());
         $i = 0;
         foreach ($assignedColors->toCombo() as $idColor => $colorName) {
             $colors[$npdSupplier->getIdNpdSupplier()][$i]["options"] = $allColors + array($idColor => $colorName);
             $colors[$npdSupplier->getIdNpdSupplier()][$i]["selected"] = $idColor;
             $i++;
         }
         if (count($colors[$npdSupplier->getIdNpdSupplier()]) == 0) {
             $colors[$npdSupplier->getIdNpdSupplier()][0]["options"] = $allColors;
         }
         //Moq and price
         $npdMoqPriceQuery = SupplierBudgetQuery::create();
         $npdMoqPriceQuery->whereAdd(SupplierBudget::ID_NPD_SUPPLIER, $npdSupplier->getIdNpdSupplier());
         $npdMoqPrice[$npdSupplier->getIdNpdSupplier()] = $npdMoqPriceQuery->find();
     }
     if ($npdSuppliers->count() > 0) {
         $this->view->npdSuppliers = $npdSuppliers;
         $this->view->NPDSheetSupplierFiles = $NPDSheetSupplierFiles;
         //die(print_r($colors));
         $this->view->fileTypes = File::$typeFile;
         $this->view->colors = $colors;
         $this->view->npdMoqPrice = $npdMoqPrice;
     } else {
         $npdSuppliers = new stdClass();
         $npdSuppliers->couryard = new NpdSheetSupplier();
         $this->view->npdSuppliers = $npdSuppliers;
         $this->view->defaultColor = $allColors;
     }
     $suppliers = Application\Query\SapSupplierQuery::create()->find();
     $temporalSupplierQuery = TemporalSupplierQuery::create()->find();
     $temporalSupplierArray = array();
     $temporalSupplierNamesArray = array();
     while ($temporalSupplier = $temporalSupplierQuery->read()) {
         $temporalSupplierNamesArray[$temporalSupplier->getIdTemporalSap()] = $temporalSupplier->getIdTemporalSap() . ' - ' . $temporalSupplier->getName();
         $temporalSupplierArray[$temporalSupplier->getIdTemporalSap()] = $temporalSupplier->getName();
     }
     //     	$suppliersToAjax += $temporalSupplierArray;
     $this->view->supplierNames = $suppliers->toAutoCompleteCombo() + $temporalSupplierNamesArray;
     $this->view->supplierTabs = $suppliers->toCombo() + $temporalSupplierArray;
     $this->view->fobPorts = array("" => "Select Fob Port") + Application\Query\PortCustomQuery::create()->actives()->whereAdd('PortCustom.' . PortCustom::IS_DEPARTURE, 1)->find()->toCombo();
     $this->view->incoterms = array("" => "Select Incoterm") + \Application\Query\IncotermQuery::create()->find()->toCombo();
     $this->view->currencies = array("" => "Select Currency") + \Application\Query\CurrencyQuery::create()->find()->toCombo();
     $this->view->actionForm = 'create';
 }
Example #3
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');
 }