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 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();
 }
 /**
  * @param Catalog_Model_Products $product
  * @param bool $toWin
  * @return array
  */
 public function productModificationTableValues(Catalog_Model_Products $product, $toWin = false)
 {
     $productMapper = new Catalog_Model_Mapper_Products();
     $subproducts = new Catalog_Model_Mapper_Subproducts();
     $select = $subproducts->getDbTable()->select()->order('order ASC');
     $modifications = $productMapper->findSubproductsRel($product->getId(), $select);
     $modificationsTableValues = array();
     if (!empty($modifications)) {
         $modificationsTableValues['headTable'] = $this->productModificationTableTitle($product, $toWin);
         foreach ($modifications as $modification) {
             $modificationPropertyValues = $subproducts->findSubProductParamValue($modification->getId());
             $values = array();
             $values[] = $modification->getSku();
             foreach ($modificationPropertyValues as $modificationPropertyValue) {
                 $values[] = !$toWin ? $modificationPropertyValue->getValue() : $this->_toWindow($modificationPropertyValue->getValue());
             }
             $modificationsTableValues[] = $values;
         }
     }
     return $modificationsTableValues;
 }
 /**
  * @param array $modifications
  * @return array
  */
 public function modificationsTableValues($modifications)
 {
     $subproducts = new Catalog_Model_Mapper_Subproducts();
     $modificationsTableValues = array();
     if (!empty($modifications)) {
         foreach ($modifications as $modification) {
             $modificationPropertyValues = $subproducts->findSubProductParamValue($modification->getId());
             $values = array();
             $values[] = $this->transformSku($modification->getSku());
             foreach ($modificationPropertyValues as $modificationPropertyValue) {
                 $values[] = $modificationPropertyValue->getValue();
             }
             $modificationsTableValues[] = $values;
         }
     }
     return $modificationsTableValues;
 }