Beispiel #1
0
 /**
  * Carrega os elementos no formulário para serem renderizado
  * @return void
  */
 public function loadElements($action = 'insert')
 {
     parent::loadElements($action);
     $filterJson = Zend_Controller_Front::getInstance()->getRequest()->getParam('filter_json');
     if ($filterJson) {
         $where = ZendT_Db_Where::fromJson($filterJson);
         $filter = $where->getFilter('profile_job.id');
         $_mapper = new Profile_Model_Job_Mapper();
         $_mapper->setId($filter['value'])->retrive();
         $row = $_mapper->getData();
         $this->getElement('id_profile_job')->setValue($row);
     }
 }
Beispiel #2
0
 /**
  * Carrega os elementos no formulário para serem renderizado
  * @return void
  */
 public function loadElements($action = 'insert')
 {
     parent::loadElements($action);
     $filterJson = Zend_Controller_Front::getInstance()->getRequest()->getParam('filter_json');
     if ($filterJson) {
         $where = ZendT_Db_Where::fromJson($filterJson);
         $filter = $where->getFilter('profile_object_view_priv.id_profile_object_view');
         $_mapper = new Profile_Model_ObjectView_Mapper();
         $_mapper->setId($filter['value'])->retrive();
         $row = $_mapper->getData();
         $this->getElement('id_profile_object_view')->setValue($row);
         $tipo = $filter = $where->getFilter('profile_object_view_priv.tipo');
         if ($tipo) {
             $this->getElement('tipo')->setValue($tipo);
             //->setDecorators(array(new ZendT_Form_Decorator_Hidden()));
         }
     }
 }
Beispiel #3
0
 /**
  * Carrega os elementos no formulário para serem renderizado
  * @return void
  */
 public function loadElements($action = 'insert', $newAction = '')
 {
     parent::loadElements($action);
     $this->setName($this->_formNome);
     if ($newAction) {
         $this->setAction(ZendT_Url::getUri(true) . "/" . $newAction);
     }
     $filterJson = Zend_Controller_Front::getInstance()->getRequest()->getParam('filter_json');
     if ($filterJson) {
         $where = ZendT_Db_Where::fromJson($filterJson);
         $filter = $where->getFilter('id');
         $_mapper = new Cms_Model_Conteudo_Mapper();
         $_mapper->setId($filter['value'][0])->retrive();
         $row = $_mapper->getData();
         unset($row['thumbnail']);
         unset($row['banner']);
         unset($row['arquivo']);
         $this->populate($row);
     }
     $this->loadButtons();
 }
Beispiel #4
0
 public function getWhere($params = array())
 {
     if (count($this->_columns) == 0) {
         throw new ZendT_Exception_Error('Favor adicionar as colunas!');
     }
     if ($params['filter_json']) {
         if (!is_array($this->_profileDefault['value'])) {
             $this->_profileDefault['value'] = array();
         }
         $whereJson = ZendT_Db_Where::fromJson(stripslashes($params['filter_json']));
         foreach ($whereJson->getFilters() as $key => $val) {
             $valueFilter = $val['value'];
             if (is_array($valueFilter)) {
                 $valueFilter = implode(";", $valueFilter);
             }
             $this->_profileDefault['value'][$val['field']] = $val['operation'] . $valueFilter;
         }
     }
     if (is_array($this->_profileDefault['value'])) {
         foreach ($this->_profileDefault['value'] as $aliasColumn => $value) {
             if (isset($params[$aliasColumn]) && $params[$aliasColumn]) {
                 $value = $params[$aliasColumn];
             }
             if ($value) {
                 $arrayNull = array('NULO', 'NULL', 'VAZIO');
                 /* Alterar também em: library\ZendT\Db\Where.php */
                 if (!in_array(strtoupper($value), $arrayNull) && !in_array(strtoupper(substr($value, 1)), $arrayNull) && !in_array(strtoupper(substr($value, 2)), $arrayNull)) {
                     $value = $this->_parseValue($value, $this->_columns[$aliasColumn]['type']);
                 }
                 if (isset($this->_columns[$aliasColumn]['expression'])) {
                     $params['expression-' . $aliasColumn] = $value;
                 } else {
                     $params[$this->_columns[$aliasColumn]['aliasTable'] . '-' . $this->_columns[$aliasColumn]['columnName']] = $value;
                 }
             }
         }
     }
     if (count($params) > 0) {
         $columns = $this->getColumnsMapper();
         $where = ZendT_Db_Where::fromAutoFilter($params, $columns);
     } else {
         $where = false;
     }
     return $where;
 }
Beispiel #5
0
 /**
  * Ação para buscar os dados para uma Seeker
  * Pode retornar o dado para preenchimento ou
  * retornar um PostData com os dados usados
  * para pesquisa
  */
 public function seekerSearchAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $json = new ZendT_Json_Result();
     try {
         $value = ltrim($this->getRequest()->getParam('value'));
         $field = $this->getRequest()->getParam('field');
         if ($value) {
             if (method_exists($this->getMapper(), 'getWhereSeekerSearch')) {
                 $where = $this->getMapper()->getWhereSeekerSearch($value, $field);
             } else {
                 $where = $this->getModel()->getWhereSeekerSearch($value, $field);
             }
         } else {
             $where = new ZendT_Db_Where();
         }
         $whereGroup = new ZendT_Db_Where_Group('AND');
         $whereGroup->addWhere($where);
         /**
          * Pega o filtro usado usado em json
          */
         $filterJson = $this->getRequest()->getParam('filter_json');
         if ($filterJson) {
             $whereFilter = ZendT_Db_Where::fromJson($filterJson);
             $whereGroup->addWhere($whereFilter);
         }
         if ($this->_mapper instanceof ZendT_Db_View) {
             $dataGrid = $this->getMapper()->getDataGrid($whereGroup, array());
         } else {
             $dataGrid = $this->getModel()->getDataGrid($whereGroup, array());
         }
         $data = true;
         if ($dataGrid->getNumRows() == 1 && $this->getRequest()->getParam('makePostData') != '1') {
             $data = array();
             if ($dataGrid->isRowFormated()) {
                 $data['row'] = $dataGrid->getRow();
                 foreach ($data['row'] as $key => $row) {
                     if ($row instanceof ZendT_Type) {
                         $data['row'][$key] = $row->get();
                     }
                 }
             } else {
                 $row = $dataGrid->getRow();
                 foreach ($this->getColumns() as $column) {
                     $data['row'][strtolower($column->getName())] = $column->format($row[strtolower($column->getName())]);
                 }
             }
             $this->_prepareRetrieveRow($data['row']);
         } else {
             $data = array('postData' => $where->toJsonPostData(), 'numRows' => $dataGrid->getNumRows());
         }
         $json->setResult($data);
     } catch (Exception $Ex) {
         $json->setException($Ex);
     }
     echo $json->render();
 }
Beispiel #6
0
 /**
  * Converte o comando Where em uma string PostData em formato json
  * será usado a pesquisa do seeker, quando encontrar mais de um registro
  * ou não encontrar nenhum registro.
  * Com esse PostData será passado para o Grid gerar os dados e 
  * também ser utilizado na tela de pesquisa do Grid, com os dados
  * sugeridos como pesquisa pelo objeto seeker
  * 
  * @return string
  */
 public function toJsonPostData($postData = '')
 {
     $data['filter_groupop'] = $this->_groupOp;
     foreach ($this->_filter as $filter) {
         $field = $filter['field'];
         if ($field instanceof Zend_Db_Expr) {
             $field = $filter['name'];
         }
         $pos = strpos($field, '.');
         if ($pos !== false) {
             $columnName = substr($field, $pos + 1);
         } else {
             $columnName = $field;
         }
         if ($filter['operation'] == '=') {
             $filter['operation'] = '';
         }
         $data['filter'][$columnName]['op'][$columnName . 'op'] = $filter['operation'];
         $data['filter'][$columnName]['field'][$columnName . 'field'] = $field;
         $data['filter'][$columnName]['mapper'][$columnName . 'mapper'] = $filter['mapper'];
         /* foreach($filter['value'] as $key => $val){
            $filter['value'][$key] = $filter['operation'] . $val;
            } */
         $data['filter'][$columnName]['value'][$columnName] = $filter['value'];
     }
     $data['isSearch'] = 'true';
     if ($postData) {
         $postData = ZendT_Db_Where::fromJson($postData);
         if ($postData instanceof ZendT_Db_Where) {
             $filters = $postData->getFilters();
             foreach ($filters as $columnName => $filter) {
                 $data['filter'][$columnName] = $filter;
             }
         }
     }
     /* echo "<pre>";
        print_r($data['filter']);
        echo "</pre>";die; */
     return Zend_Json::encode($data);
 }