protected function _getPropertyArray() { $pipelinePropertyMapper = new Pipeline_Model_Mapper_PipelineProperty(); $select = $pipelinePropertyMapper->getDbTable()->select(); $select->where('deleted != ?', 1)->where('active != ?', 0)->order('sorting ASC'); $pipelinePropertyArray = array(); $pipelinePropertyArray[] = '...'; $pipelineProperty = $pipelinePropertyMapper->fetchAll($select); if (!empty($pipelineProperty)) { foreach ($pipelineProperty as $property) { $pipelinePropertyArray[$property->getId()] = $property->getName(); } } return $pipelinePropertyArray; }
public function indexAction() { $request = $this->getRequest(); $pipelinePropertyMapper = new Pipeline_Model_Mapper_PipelineProperty(); $select = $pipelinePropertyMapper->getDbTable()->select(); $select->order('sorting ASC'); $pipelineProperties = $pipelinePropertyMapper->fetchAll($select); if (!empty($pipelineProperties)) { if (count($pipelineProperties) > $this->getCountItemOnPage()) { $pages = array_chunk($pipelineProperties, $this->getCountItemOnPage()); $currentPage = 0; if ($request->getParam('page') && $request->getParam('page') > 0) { $currentPage = $request->getParam('page') - 1; } if ($request->getParam('page') && $request->getParam('page') > count($pages)) { $currentPage = count($pages) - 1; } $pipelineProperties = $pages[$currentPage]; $this->view->countPage = count($pages); $this->view->currentPage = $currentPage + 1; } } $this->view->pages = $pipelineProperties; }
/** * @param $itemId * @return array * */ protected function _getPropertyArray($itemId) { $pipelinePropertyMapper = new Pipeline_Model_Mapper_PipelineProperty(); $select = $pipelinePropertyMapper->getDbTable()->select(); $select->where('deleted != ?', 1)->where('active != ?', 0)->order('sorting ASC'); $pipelinePropertyArray = array(); $pipelinePropertyArray[] = '...'; $pipelineProperty = $pipelinePropertyMapper->fetchAll($select); $pipelinePropertyValuesMapper = new Pipeline_Model_Mapper_PipelinePropertyValues(); $select = $pipelinePropertyValuesMapper->getDbTable()->select(); $select->where('pipeline_id = ?', $itemId); $pipelinePropertyValuesArray = $pipelinePropertyValuesMapper->fetchAll($select); $itemIdArray = array(); if (!empty($pipelinePropertyValuesArray)) { foreach ($pipelinePropertyValuesArray as $pipelinePropertyValue) { $itemIdArray[] = $pipelinePropertyValue->getPropertyId(); } } if (!empty($pipelineProperty)) { foreach ($pipelineProperty as $property) { if (!in_array($property->getId(), $itemIdArray)) { $pipelinePropertyArray[$property->getId()] = $property->getName(); } } } $pipelinePropertyArray['new'] = 'Новое'; return $pipelinePropertyArray; }