public function viewAction()
 {
     $fullPath = $this->getFullPath();
     $pipelineMapper = new Pipeline_Model_Mapper_Pipeline();
     $pipeline = $pipelineMapper->findByFulPath($fullPath, new Pipeline_Model_Pipeline());
     if (is_null($pipeline)) {
         throw new Zend_Controller_Action_Exception("Страница не найдена", 404);
     }
     $this->getJson($pipeline);
     $this->setParamsDataItem($pipeline);
     $this->checkDeleted($pipeline);
     $categoriesMapper = new Pipeline_Model_Mapper_PipelineCategories();
     $category = $categoriesMapper->find($pipeline->getCategoryId(), new Pipeline_Model_PipelineCategories());
     $pipelineProperties = $pipelineMapper->fetchPropertyRel($pipeline->getId());
     if (!empty($pipelineProperties)) {
         $propertyValuesMapper = new Pipeline_Model_Mapper_PipelinePropertyValues();
         $viewProperties = array();
         foreach ($pipelineProperties as $property) {
             $propertyValues = $propertyValuesMapper->findByKey($pipeline->getId(), $property->getId(), new Pipeline_Model_PipelinePropertyValues());
             $viewProperties[$property->getName()] = $propertyValues;
         }
         $this->view->assign('properties', $viewProperties);
     }
     $this->view->assign(array('pipeline' => $pipeline, 'category' => $category, 'title' => $pipeline->getTitle(), 'adminPath' => 'pipeline/edit/' . $pipeline->getId()));
     $this->checkActive($pipeline);
 }
 /**
  * @param $pipeline_id
  * @return array
  */
 function GetPipelineProperties($pipeline_id)
 {
     $pipelineMapper = new Pipeline_Model_Mapper_Pipeline();
     $pipelineProperties = $pipelineMapper->fetchPropertyRel($pipeline_id);
     $properties = array();
     if (!empty($pipelineProperties)) {
         $propertyValuesMapper = new Pipeline_Model_Mapper_PipelinePropertyValues();
         foreach ($pipelineProperties as $property) {
             $propertyValues = $propertyValuesMapper->findByKey($pipeline_id, $property->getId(), new Pipeline_Model_PipelinePropertyValues());
             $properties[$property->getName()] = $propertyValues;
         }
     }
     return $properties;
 }
 /**
  * @param $pipelineId
  * @param $propertyId
  * @param $value
  * @return null|Pipeline_Model_PipelinePropertyValues
  *
  */
 protected function _createPropertyValue($pipelineId, $propertyId, $value)
 {
     $pipelinePropertyValueMapper = new Pipeline_Model_Mapper_PipelinePropertyValues();
     $pipelinePropertyValue = new Pipeline_Model_PipelinePropertyValues();
     $pipelinePropertyValue->setOptions(array('pipelineId' => $pipelineId, 'propertyId' => $propertyId, 'value' => $value));
     $pipelinePropertyValueMapper->save($pipelinePropertyValue);
     $newPropertyValue = $pipelinePropertyValueMapper->findByKey($pipelinePropertyValue->getPipelineId(), $pipelinePropertyValue->getPropertyId(), new Pipeline_Model_PipelinePropertyValues());
     return $newPropertyValue;
 }
 /**
  * @param $propertyId
  * @return null|Pipeline_Model_PipelinePropertyValues
  */
 protected function _createNewPropertyValue($propertyId)
 {
     $request = $this->getRequest();
     $pipelinePropertyValueMapper = new Pipeline_Model_Mapper_PipelinePropertyValues();
     $pipelinePropertyValue = new Pipeline_Model_PipelinePropertyValues();
     $pipelinePropertyValue->setOptions(array('pipelineId' => $request->getParam('pipelineId'), 'propertyId' => $propertyId, 'value' => $request->getParam('newPropertyValue')));
     $pipelinePropertyValueMapper->save($pipelinePropertyValue);
     $newPropertyValue = $pipelinePropertyValueMapper->findByKey($pipelinePropertyValue->getPipelineId(), $pipelinePropertyValue->getPropertyId(), new Pipeline_Model_PipelinePropertyValues());
     return $newPropertyValue;
 }
 /**
  * @return $this
  */
 public function setViewPipelineProperties()
 {
     $itemId = $this->_request->getParam('id');
     $propertyMapper = new Pipeline_Model_Mapper_PipelineProperty();
     $select = $propertyMapper->getDbTable()->select();
     $select->where('active != ?', 0)->where('deleted != ?', 1)->order('sorting ASC');
     $pipelineProperties = $this->_modelMapper->fetchPropertyRel($itemId, $select);
     if (!empty($pipelineProperties)) {
         $propertyValuesMapper = new Pipeline_Model_Mapper_PipelinePropertyValues();
         $viewProperties = array();
         /**@var $property Pipeline_Model_PipelineProperty*/
         foreach ($pipelineProperties as $property) {
             $propertyValues = $propertyValuesMapper->findByKey($itemId, $property->getId(), new Pipeline_Model_PipelinePropertyValues());
             $viewProperties[$property->getName()] = $propertyValues;
         }
         $this->view->properties = $viewProperties;
     }
     $propertyArray = $this->_getPropertyArray($itemId);
     if (0 != count($propertyArray)) {
         $formValue = new Admin_Form_PipelinePropertyValue();
         $formValue->setDefaults(array('pipelineId' => $itemId, 'propertyId' => 0, 'sorting' => 0));
         $formValue->getElement('propertyId')->setMultiOptions($propertyArray);
         $this->view->formValue = $formValue;
     }
     return $this;
 }