public function modificationsAction() { $id = $this->_request->getParam('id'); $select = $this->_subproductsModelMapper->getDbTable()->select()->where('deleted != ?', 1)->order('order ASC'); $jsonData = array('parentId' => $id, 'columns' => array(), 'rows' => array()); $modifications = $this->_modelMapper->findSubproductsRel($id, $select, true); if (!empty($modifications)) { $selectSubproductParams = $this->_subproductsParamsMapper->getDbTable()->select()->order('order ASC'); $subproductProperty = $this->_modelMapper->findSubproductParams($id, $selectSubproductParams, true); $jsonData['columns'] = $subproductProperty; $modificationsTableValues = array(); foreach ($modifications as $modification) { $modificationPropertyValues = $this->_subproductsModelMapper->findSubProductParamValue($modification['id']); $values['item'] = $modification; $values['values'] = array(); foreach ($modificationPropertyValues as $modificationPropertyValue) { $values['values'][] = $modificationPropertyValue->getOptions(); } $modificationsTableValues[] = $values; } $jsonData['rows'] = $modificationsTableValues; //Zend_Debug::dump($jsonData); } $this->_helper->json->sendJson($jsonData); }
public function productModificationTableTitle(Catalog_Model_Products $product, $toWin = false) { $select = $this->_subproductsParamsMapper->getDbTable()->select()->order('order ASC'); $subproductProperty = $this->_productsModelMapper->findSubproductParams($product->getId(), $select); $modificationTableTitle = array(); if (!empty($subproductProperty)) { $modificationTableTitle[] = !$toWin ? 'Название' : $this->_toWindow('Название'); foreach ($subproductProperty as $name) { $modificationTableTitle[] = !$toWin ? $name->getName() : $this->_toWindow($name->getName()); } } return $modificationTableTitle; }
/** * @param SimpleXMLElement $element * @param Catalog_Model_Products $product */ public function addModificationTableXml(SimpleXMLElement $element, Catalog_Model_Products $product) { $selectModification = $this->_subproductsModelMapper->getDbTable()->select()->order('order ASC'); $cache = Zend_Cache::factory('Core', 'File', array('lifetime' => 3600 * 24 * 2, 'automatic_serialization' => true), array('cache_dir' => '../cache/modifications/')); if (!($modifications = $cache->load('modifications' . $product->getId()))) { $modifications = $this->_productsModelMapper->findSubproductsRel($product->getId(), $selectModification); $cache->save($modifications, 'modifications' . $product->getId(), array('modificationsTable')); } if ($modifications && !empty($modifications)) { $selectSubproductParams = $this->_subproductsParamsMapper->getDbTable()->select()->order('order ASC'); $subproductProperty = $this->_productsModelMapper->findSubproductParams($product->getId(), $selectSubproductParams); foreach ($modifications as $modification) { /* @var $modification Catalog_Model_Subproducts */ $row = $element->addChild('tr'); $row->addAttribute('id', $modification->getId()); $row->addChild('td', $modification->getSku())->addAttribute('title', 'Наименование'); foreach ($subproductProperty as $property) { /* @var $property Catalog_Model_SubproductParams */ $row->addChild('td', $this->_getModificationParamValue($modification->getId(), $property->getId()))->addAttribute('title', $property->getName()); } } } }
public function passportAction() { //Zend_Debug::dump($this->_request->getParams()); $product = $this->_modelMapper->find($this->_request->getParam('id'), $this->_model); if (!$product) { throw new Zend_Exception("Такого товара нет", 404); } $modificationsId = $this->_request->getParam('modifications'); $modifications = array(); if ($modificationsId && !empty($modificationsId)) { $select = $this->_subproductsModelMapper->getDbTable()->select(); $select->where('id IN (?)', $modificationsId)->order('order ASC'); $modifications = $this->_subproductsModelMapper->fetchAll($select); } $propertiesProduct = $this->_modelMapper->findProductParams($this->_request->getParam('id')); $select = $this->_subproductsParamsMapper->getDbTable()->select()->order('order ASC'); $modificationsProperty = $this->_modelMapper->findSubproductParams($product->getId(), $select); $modificationsTableHead = ''; $modificationsTableBody = ''; if (!empty($modificationsProperty)) { $modificationsTableHead .= '<tr>'; $modificationsTableHead .= '<th align="center" width="20%" style="font-weight: bolder">Название</th>'; /**@var $value Catalog_Model_SubproductParams*/ foreach ($modificationsProperty as $value) { $modificationsTableHead .= '<th align="center" style="font-weight: bolder">' . $value->getName() . '</th>'; } $modificationsTableHead .= '</tr>'; foreach ($modifications as $modification) { $modificationsTableBody .= '<tr>'; $modificationsTableBody .= '<td width="20%" nowrap="nowrap">' . $modification->getSku() . '</td>'; $modificationPropertyValues = $this->_subproductsModelMapper->findSubProductParamValue($modification->getId()); /**@var $value Catalog_Model_SubproductParamsValues*/ foreach ($modificationPropertyValues as $value) { $modificationsTableBody .= '<td>' . $value->getValue() . '</td>'; } $modificationsTableBody .= '</tr>'; } } //Zend_Debug::dump($modificationsProperty); $pdf = new Admin_Model_PassportPdf(); // set document information $pdf->SetAuthor('Альфа Гидро'); $pdf->SetTitle('Паспорт'); $pdf->SetSubject('Паспорт'); $pdf->SetKeywords('Паспорт, PDF'); $pdf->SetFont('', '', 12, '', true); // Set Product $pdf->setProduct($product); // Set Modifications $pdf->setAModificationsProduct($modifications); // Set PropertiesProduct $pdf->setPropertiesProduct($propertiesProduct); // Set Modification Table $pdf->setModificationTableHead($modificationsTableHead); $pdf->setModificationTableBody($modificationsTableBody); $pdf->AddPage(); $pdf->showName()->showModificationsList()->showImages()->showProperty()->showModificatonTable()->showGarant('ГАРАНТИЙНЫЕ ОБЯЗАТЕЛЬСТВА', 'Компания гарантирует работоспособность указанных изделий в течение 1 (года) с момента изготовления. При обнаружении скрытого дефекта в период гарантийного срока фирма обязуется безвозмездно заменить изделие. Организация не несет ответственности за убытки, причиненные неисправностью установленного изделия. Гарантия не распространяется на изделия неправильно установленные или поврежденные механическими и химическими воздействиями, а так же, эксплуатируемыми в условиях не соответствующих указанным в настоящем паспорте.'); $pdf->Output(); $this->getResponse()->setHeader('Content-Type', 'application/pdf'); $this->_helper->layout()->disableLayout(); }
public function printAction() { $fullPath = $this->getFullPath(); $products = new Catalog_Model_Mapper_Products(); $product = new Catalog_Model_Products(); $product = $products->findByFulPath($fullPath, $product); if (is_null($product)) { throw new Zend_Controller_Action_Exception("Страница не найдена", 404); } $subproducts = new Catalog_Model_Mapper_Subproducts(); $select = $subproducts->getDbTable()->select()->where('deleted != ?', 1)->order('order ASC'); $modifications = $products->findSubproductsRel($product->getId(), $select); $tableModifications = array(); $headTable = array(); if (!empty($modifications)) { $subproductParams = new Catalog_Model_Mapper_SubproductParams(); $select = $subproductParams->getDbTable()->select()->order('order ASC'); $subproductProperty = $products->findSubproductParams($product->getId(), $select); $headTable[] = 'Название'; foreach ($subproductProperty as $property) { $headTable[] = $property->name; } $tableModifications = $this->modificationsTableValues($modifications); array_unshift($tableModifications, $headTable); } //print_r(count(array_shift($tableModifications))-1); $pdf = new Catalog_Model_PrintPdf(); // set document information $pdf->SetAuthor('Альфа Гидро'); $pdf->SetTitle($this->transformSku($product->getSku()) . '. ' . $product->getName()); $pdf->SetSubject($this->transformSku($product->getSku()) . '. ' . $product->getName()); $pdf->SetKeywords($this->transformSku($product->getSku()) . ', ' . $product->getName()); $pdf->SetFont('', '', 12, '', true); $pdf->setProduct($product); // Add a page $pdf->AddPage(); $pdf->showImages()->showProperty()->showDescription()->showModificatonTable($tableModifications); $pdf->Output(); $this->getResponse()->setHeader('Content-Type', 'application/pdf'); $this->_helper->layout()->disableLayout(); }