Exemplo n.º 1
0
 /**
  *  Cria um campo texto com validador de data e datepicker
  *
  * @param  string $id
  * @param  string $value
  * @param  array  $params jQuery Widget Parameters
  * @param  array  $attribs HTML Element Attributes
  * @return string
  */
 public function dateMulti($id, $value = null, array $attribs = array())
 {
     $data = date('dmy');
     #$this->view->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/scripts/jquery/widget/TCursor.js?'.$data);
     $this->view->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/scripts/jquery/widget/TDateMulti.js?' . $data);
     $this->jquery->addOnLoad('jQuery("#' . $id . '").TDateMulti();');
     #$button = new ZendT_View_Button('bt-calend-'.$id,'');
     #$button->setIcon('ui-icon-calculator');
     $attribs['style'] .= ';float:left;';
     $_toolbar = new ZendT_View_Toolbar('calend-toolbar-' . $id);
     $_toolbar->addStyle('width', '390px');
     $_toolbar->addStyle('height', '34px');
     $_toolbar->addStyle('display', 'none');
     $_toolbar->setAttr('align', 'center');
     $padrao = explode(' ', $value);
     $hoje = new ZendT_Type_Date('SYSDATE', 'Date');
     $ultimoMes[0] = clone $hoje;
     $ultimoMes[0]->addMonth(-1)->firstDayMonth();
     $ultimoMes[1] = clone $hoje;
     $ultimoMes[1]->addMonth(-1)->lastDayMonth();
     $mesCorrente[0] = clone $hoje;
     $mesCorrente[0]->firstDayMonth();
     $mesCorrente[1] = clone $hoje;
     $mesCorrente[1]->lastDayMonth();
     $ultimaSemana[0] = clone $hoje;
     $ultimaSemana[0]->addWeek(-1)->firstDayWeek();
     $ultimaSemana[1] = clone $hoje;
     $ultimaSemana[1]->addWeek(-1)->lastDayWeek();
     $semanaCorrente[0] = clone $hoje;
     $semanaCorrente[0]->firstDayWeek();
     $semanaCorrente[1] = clone $hoje;
     $semanaCorrente[1]->lastDayWeek();
     $options = "var option = jQuery('#calend_select_" . $id . "').val();\n\n                        if(option != ''){\n                            var data1 = '', data2 = '';\n                            if(option == '0'){\n                                data1 = '" . $padrao[0] . "';\n                                data2 = '" . $padrao[1] . "';\n                            }\n                            else if(option == '1'){\n                                data1 = '" . $hoje . "';\n                                data2 = '" . $hoje . "';\n                            } else if(option == 2){\n                                data1 = '" . $ultimoMes[0] . "';\n                                data2 = '" . $ultimoMes[1] . "';\n                            } else if(option == 3){\n                                data1 = '" . $mesCorrente[0] . "';\n                                data2 = '" . $mesCorrente[1] . "';\n                            } else if(option == 4){\n                                data1 = '" . $ultimaSemana[0] . "';\n                                data2 = '" . $ultimaSemana[1] . "';\n                            } else if(option == 5){\n                                data1 = '" . $semanaCorrente[0] . "';\n                                data2 = '" . $semanaCorrente[1] . "';\n                            }\n                            jQuery('#calend-" . $id . "-1').datepicker('setDate', data1);\n                            jQuery('#calend-" . $id . "-2').datepicker('setDate', data2);\n\n                            jQuery('#" . $id . "').val(\n                                jQuery('#calend-" . $id . "-1').datepicker({ dateFormat: 'yy-mm-dd' }).val() + ' ' +\n                                jQuery('#calend-" . $id . "-2').datepicker({ dateFormat: 'yy-mm-dd' }).val()\n                            );\n                        }\n                        ";
     $close = "  jQuery('#calend-" . $id . "-1').hide('fast');\n                        jQuery('#calend-" . $id . "-2').hide('fast');\n                        jQuery('#calend-toolbar-" . $id . "').hide('fast');";
     $element = new ZendT_Form_Element_Select("calend_select_" . $id);
     #$element->setLabel('Seleção');
     $element->addMultiOption('', '');
     $element->addMultiOption('1', 'Hoje');
     $element->addMultiOption('2', 'Último Mês');
     $element->addMultiOption('3', 'Mês corrente');
     $element->addMultiOption('4', 'Última Semana');
     $element->addMultiOption('5', 'Semana corrente');
     $element->addAttr('breakline', 'none');
     $element->setAttrib('onClick', $options);
     $element->addStyle('float', 'left');
     $element->addStyle('height', '25px');
     $element->addStyle('margin', '3px');
     $_toolbar->add($element);
     $_button = new ZendT_View_Button('bt_ok' . $id, 'OK', $close);
     $_button->setIcon('ui-icon-check');
     $_button->addStyle('float', 'right');
     $_button->addStyle('height', '25px');
     $_button->addStyle('margin', '3px');
     $_toolbar->addButton($_button);
     return $this->view->formText($id, $value, $attribs) . '<span id="bt-calend-' . $id . '" style="margem:0px; float:left; height: 18px; width: 20px;" class="ui-button ui-state-default ui-corner-right ui-button-icon-only"><span id="icon-bt-calend-' . $id . '" class="ui-button-icon-primary ui-icon ui-icon-calculator"></span></span>' . '<br style="clear:both;" /><table><tr><td><div id="calend-' . $id . '-1" style="display:none"></div></td><td><div id="calend-' . $id . '-2" style="display:none"></div></td></tr></table>' . $_toolbar->render() . '<label class="error" for="dt_emissao_ctrc" generated="true" style="display:none"></label>' . '<div id="hour-' . $id . '" style="display:none"></div>';
 }
Exemplo n.º 2
0
 /**
  *
  * @throws ZendT_Exception_Alert 
  */
 public function dynamicAction()
 {
     $typeModal = $this->getRequest()->getParam('typeModal');
     $iframeDownload = $this->getRequest()->getParam('iframeDownload');
     $driver = $this->getRequest()->getParam('driver');
     $download = $this->getRequest()->getParam('download');
     $arquivo = $this->getRequest()->getParam('arquivo');
     $profileKey = $this->getRequest()->getParam('profile_key');
     $noToolbar = $this->getRequest()->getParam('noToolbar');
     $toolbar = $this->getRequest()->getParam('toolbar');
     $width = $this->getRequest()->getParam('width');
     $height = $this->getRequest()->getParam('height');
     $disableSidebar = $this->getRequest()->getParam('disable_sidebar');
     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');
             } else {
                 if ($typeModal == 'PDF') {
                     Zend_Layout::getMvcInstance()->setLayout('pdf');
                 }
             }
         }
     }
     try {
         $this->view->disableSidebar = $disableSidebar;
         $objectName = get_class($this->_mapper);
         $config = ZendT_Profile::get($objectName, 'C');
         $this->view->profiles = ZendT_Profile::listProfile($objectName, array('C', 'D'));
         $this->view->profileId = $config['id'];
         $this->view->profileKey = $profileKey;
         $this->view->dynamic = true;
         $this->view->objectName = $objectName;
         $this->view->profileType = $config['tipo'];
         if ($config['id']) {
             //$listProfile = ZendT_Profile::listProfile($objectName, array('C', 'D'));
             //$_profile = new ZendT_View_Profile('selProfile', $config['id'], $listProfile, 'C', $objectName);
             $_toolbar = new ZendT_View_Toolbar('toolChart');
             //$_toolbar->add($_profile);
             if ($toolbar == 'simple' && $config['tipo'] == 'C') {
                 // quando for gráfico não mostra botões de exportação
             } else {
                 $button = new ZendT_View_Button('btExportPDF', 'Download em PDF', new ZendT_JS_Command("function(){\n                             jQuery('#driver').val('PDF');\n                             jQuery('#download').val(1);                        \n                             jQuery('#formChart').attr('action','" . ZendT_Url::getUri() . "').submit();\n                         }"));
                 $button->setIcon('ui-icon-document');
                 //$button->addStyle('float', 'left');
                 $_toolbar->add($button, 'btExportPDF');
                 $button = new ZendT_View_Button('btExportXLS', 'Download em XLS', new ZendT_JS_Command("function(){\n                             jQuery('#driver').val('XLS');\n                             jQuery('#download').val(1);\n                             jQuery('#formChart').attr('action','" . ZendT_Url::getUri() . "').submit();\n                         }"));
                 $button->setIcon('ui-icon-calculator');
                 //$button->addStyle('float', 'left');
                 $_toolbar->add($button, 'btExportXLS');
                 $buttonMail = new ZendT_View_Button('btMail', 'Enviar e-mail', new ZendT_JS_Command(" function(){\n                             var form = jQuery('#formChart');\n                             form.attr('action','" . ZendT_Url::getUri(true) . "/mail');\n                             jQuery.AjaxT.submitJson({selector:form});\n                         }"));
                 $buttonMail->setIcon('ui-icon-mail-closed');
                 $_toolbar->add($buttonMail);
             }
             $button = new ZendT_View_Button('btFilterChart', 'Filtrar', new ZendT_JS_Command("function(){\n                        jQuery('#formChart').attr('action','" . ZendT_Url::getUri(true) . "/filter').submit();\n                    }"));
             $button->setIcon('ui-icon-search');
             $_toolbar->addButton($button);
             $button = new ZendT_View_Button('btRefreshChart', 'Atualizar', new ZendT_JS_Command("function(){\n                        jQuery('#formChart').attr('action','" . ZendT_Url::getUri() . "').submit();\n                    }"));
             $button->setIcon('ui-icon-refresh');
             $_toolbar->addButton($button);
             if ($toolbar != 'simple') {
                 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={$config['tipo']}&id={$config['id']}', 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                             window.open('" . ZendT_Url::getBaseUrl() . "/log/relatorio?arquivo=" . $objectName . "','_BLANK');\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={$config['id']}', 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');
             $form = new ZendT_Form();
             $form->setName('formChart');
             $form->setAction(ZendT_Url::getUri());
             $element = new ZendT_Form_Element_Hidden('profile');
             $element->setValue($config['id']);
             $form->addElement($element);
             $element = new ZendT_Form_Element_Hidden('profile_key');
             $element->setValue($profileKey);
             $form->addElement($element);
             $element = new ZendT_Form_Element_Hidden('toolbar');
             $element->setValue($toolbar);
             $form->addElement($element);
             $element = new ZendT_Form_Element_Hidden('width');
             $element->setValue($width);
             $form->addElement($element);
             $element = new ZendT_Form_Element_Hidden('height');
             $element->setValue($height);
             $form->addElement($element);
             $element = new ZendT_Form_Element_Hidden('driver');
             $element->setValue($driver);
             $form->addElement($element);
             $element = new ZendT_Form_Element_Hidden('download');
             $element->setValue($download);
             $form->addElement($element);
             $element = new ZendT_Form_Element_Hidden('typeModal');
             $element->setValue($typeModal);
             $form->addElement($element);
             $element = new ZendT_Form_Element_Hidden('disable_sidebar');
             $element->setValue($disableSidebar);
             $form->addElement($element);
             if ($width) {
                 $config['width'] = $width;
             }
             if ($height) {
                 $config['height'] = $height - 58;
             }
             #$config['iframeDownload'] = $iframeDownload;
             if ($config['tipo'] == 'C' && $driver == '') {
                 if ($toolbar == 'simple') {
                     $config['show_parameters'] = false;
                     $config['show_title'] = false;
                     $_label = new ZendT_View_Html('span');
                     $_label->setId('spn_filter');
                     $_label->addStyle('float', 'left');
                     $_label->addStyle('margin-top', '9px');
                     $_label->addAttr('title', 'Visualizar parâmetros');
                     $_label->addClass('ui-icon ui-icon-pin-w');
                     $_label->setAttr('value', ' ');
                     $_toolbar->addObject($_label);
                     $_label = new ZendT_View_Html('label');
                     $_label->addStyle('float', 'left');
                     $_label->addStyle('padding', '10px');
                     $_label->addStyle('font-weight', 'bold');
                     $_label->addClass('ui-widget');
                     $_label->setAttr('value', $config['title']);
                     $_toolbar->addObject($_label, 'lbl_title');
                     $_toolbar->addStyle('margin-bottom', '0px');
                 } else {
                     $config['show_parameters'] = true;
                     $config['show_title'] = true;
                 }
                 $view = new ZendT_Report_View_Chart('Chart', $this->_mapper, $config);
             } else {
                 if ($config['tipo'] == 'I') {
                     $view = new ZendT_Report_View_Dynamic_Form($driver, $this->_mapper, $config);
                 } else {
                     $view = new ZendT_Report_View_Dynamic($driver, $this->_mapper, $config);
                 }
             }
             $viewRendered = $view->render($typeModal);
             $params = $view->getParams();
             if ($params) {
                 foreach ($params as $name => $value) {
                     $element = new ZendT_Form_Element_Hidden($name);
                     $element->setValue($value);
                     $form->addElement($element);
                 }
             }
             if ($iframeDownload) {
                 $this->_helper->layout->disableLayout();
                 #$this->_helper->viewRenderer->setNoRender(true);
                 $this->view->content = $viewRendered;
             } else {
                 if ($typeModal == 'PDF') {
                     $this->view->content = $viewRendered;
                 } else {
                     $this->view->placeholder('title')->set('');
                     $this->view->title = $config['title'];
                     $this->view->typeModal = $typeModal;
                     $this->view->content = '';
                     /* if (!$noToolbar) {
                        $this->view->content = $_toolbar->render();
                        } */
                     $this->view->content .= $form->render() . $viewRendered;
                 }
             }
         } else {
             throw new ZendT_Exception_Alert('Nenhuma análise configurada para essa visão!');
         }
     } catch (Exception $ex) {
         $this->view->content = '';
         if ($_toolbar instanceof ZendT_View_Toolbar) {
             $this->view->content .= $_toolbar->render();
         }
         if ($form instanceof ZendT_Form) {
             $this->view->content .= $form->render();
         }
         $this->view->content .= $this->view->exception($ex);
     }
     $this->view->addScriptPath(APPLICATION_PATH . '/views/scripts/index/');
     $this->renderScript('profile-report.phtml');
 }