Ejemplo n.º 1
0
 /**
  *  
  */
 public function filterAction()
 {
     $typeModal = $this->getRequest()->getParam('typeModal');
     if ($typeModal == 'AJAX') {
         Zend_Layout::getMvcInstance()->setLayout('ajax');
     } else {
         if ($typeModal == 'WINDOW') {
             Zend_Layout::getMvcInstance()->setLayout('window');
         } else {
             if ($typeModal == 'IFRAME') {
                 Zend_Layout::getMvcInstance()->setLayout('iframe');
             }
         }
     }
     $params = $this->getRequest()->getParams();
     //var_dump($params);
     $profileId = $this->getRequest()->getParam('profile');
     $arquivo = $this->getRequest()->getParam('arquivo');
     $profileKey = $this->getRequest()->getParam('profile_key');
     $disableSidebar = $this->getRequest()->getParam('disable_sidebar');
     $objectName = get_class($this->_mapper);
     $columns = $this->_mapper->getColumns()->toArray();
     $this->view->profiles = ZendT_Profile::listProfile($objectName, array('C', 'D'));
     $profile = ZendT_Profile::get($objectName, '');
     $this->view->profileId = $profile['id'];
     $this->view->profileType = $profile['tipo'];
     $this->view->objectName = $objectName;
     $this->view->profileKey = $profileKey;
     $this->view->dynamic = false;
     $this->view->disableSidebar = $disableSidebar;
     $action = 'dynamic';
     $title = $profile['title'];
     $this->title = $profile['title'];
     if ($profile['tipo'] == 'B') {
         foreach ($profile['cols-filter']['fields'] as $name => $config) {
             list($view, $id, $desc) = explode('-', $name);
             break;
         }
         $profile = ZendT_Profile::get($objectName, '', $id);
         $action = 'panel';
     }
     $fields = $profile['cols-filter']['fields'];
     if (count($fields)) {
         foreach ($fields as $columnName => &$value) {
             $value['column'] = $columns[$columnName]['column'];
             $value['type'] = $columns[$columnName]['type'];
             $value['required'] = $columns[$columnName]['required'];
             $value['auto-complete'] = $columns[$columnName]['auto-complete'];
             $value['seeker'] = $columns[$columnName]['seeker'];
         }
     }
     $form = new ZendT_Form();
     $form->loadProfileFilter($fields, $params);
     if (isset($params['toolbar'])) {
         $element = new ZendT_Form_Element_Hidden('toolbar');
         $element->setValue($params['toolbar']);
         $form->addElement($element);
     }
     if (isset($params['width'])) {
         $element = new ZendT_Form_Element_Hidden('width');
         $element->setValue($params['width']);
         $form->addElement($element);
     }
     if (isset($params['height'])) {
         $element = new ZendT_Form_Element_Hidden('height');
         $element->setValue($params['height']);
         $form->addElement($element);
     }
     if (isset($params['typeModal'])) {
         $element = new ZendT_Form_Element_Hidden('typeModal');
         $element->setValue($params['typeModal']);
         $form->addElement($element);
     }
     if (isset($disableSidebar)) {
         $element = new ZendT_Form_Element_Hidden('disable_sidebar');
         $element->setValue($disableSidebar);
         $form->addElement($element);
     }
     $form->setAction(ZendT_Url::getBaseUrl() . '/' . $params['module'] . '/' . $params['controller'] . '/' . $action . '?profile=' . $profileId . '&profile_key=' . $profileKey);
     $button = new ZendT_View_Button('btSearch', 'Pesquisar', new ZendT_JS_Command("function(){\n\t\t\t\t//jQuery('#btSearch').attr('disabled',true);\n\t\t\t\tvar form = jQuery('#" . $form->getId() . "');\n\t\t\t\tif (form.valid()){\n\t\t\t\t\tvar data = form.serialize();\n\t\t\t\t\tjQuery.AjaxT.json({\n\t\t\t\t\t\turl: '" . ZendT_Url::getBaseUrl() . '/' . $params['module'] . '/' . $params['controller'] . '/filter-valid?profile=' . $profile['id'] . "',\n\t\t\t\t\t\tdata: data,\n\t\t\t\t\t\tsuccess: function(result){\n\t\t\t\t\t\t\tif (result){\n\t\t\t\t\t\t\t\tjQuery('#btSearch').attr('disabled',true);\n\t\t\t\t\t\t\t\tjQuery('#pAguarde').show();\n\t\t\t\t\t\t\t\tform.submit();\n\t\t\t\t\t\t\t\tdocument.body.style.cursor = 'wait';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}/*,\n\t\t\t\t\t\texception: function(ex){\n\t\t\t\t\t\t\tjQuery('#btSearch').attr('disabled',false);\n\t\t\t\t\t\t}*/\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}"));
     $button->setIcon('ui-icon-search');
     $_toolbar = new ZendT_View_Toolbar('toolChart');
     if (ZendT_Acl::getInstance()->isAllowed('object-view', 'profile')) {
         $onClick = "\$.WindowT.open({id:'win-{$objectName}', type: 'WINDOW', url: '/Mais/index.php/profile/object-view/list-config', param: 'objeto={$objectName}&tipo={$profile['tipo']}&id={$profileId}', method: 'GET', title: 'Configuração da Visão', height: 580, width: 1370, modal: false });";
         $buttonConfig = new ZendT_View_Button('bt-' . $objectName, 'Configurar Visão', $onClick);
         $buttonConfig->setIcon('ui-icon-gear');
         $_toolbar->addButton($buttonConfig);
     }
     if (ZendT_Acl::getInstance()->isAllowed('relatorio', 'log')) {
         $buttonLog = new ZendT_View_Button('btLogViews', 'Log de Acesso', new ZendT_JS_Command("function(){\n                    document.location.href = '" . ZendT_Url::getBaseUrl() . "/log/relatorio?arquivo=" . $objectName . "';\n                }"));
         $buttonLog->setIcon('ui-icon-comment');
         $_toolbar->addButton($buttonLog);
     }
     if (ZendT_Acl::getInstance()->isAllowed('object-view', 'profile')) {
         $onClick = "\$.WindowT.open({id:'win-users-access', type: 'WINDOW', url: '/Mais/index.php/profile/object-view-users/dynamic', param: 'profile=813&id_visao={$profileId}', method: 'GET', title: 'Usuários com Acesso a Visão', height: 580, width: 1370, modal: false });";
         $buttonConfig = new ZendT_View_Button('bt-users-access', 'Usuários com Acesso', $onClick);
         $buttonConfig->setIcon('ui-icon-person');
         $_toolbar->addButton($buttonConfig);
     }
     $buttonViews = new ZendT_View_Button('btMyViews', 'Minhas Visões', new ZendT_JS_Command("function(){\n                document.location.href = '" . ZendT_Url::getUri(true) . "?arquivo=" . $arquivo . "&profile_key=" . $profileKey . "';\n            }"));
     $buttonViews->setIcon('ui-icon-newwin');
     $_toolbar->addButton($buttonViews);
     //$_toolbar->setFloat('right');
     $this->view->placeholder('title')->set('');
     $this->view->toolbar = $_toolbar;
     $this->view->title = $title;
     $this->view->content = $form->render();
     if (count($fields)) {
         $this->view->content .= $button->render();
     }
     $this->view->addScriptPath(APPLICATION_PATH . '/views/scripts/index/');
     $this->renderScript('profile-report.phtml');
 }