protected function build() { if ($_REQUEST['ajax'] == 'excel' && !empty($this->param['sql-query-excel'])) { $this->__excel_build__($this->param['sql-query-excel']); } if ($_REQUEST['ajax'] == 'excel-import' && !empty($this->param['field-list-data-import'])) { $this->__excel_import__($this->param['field-list-data-import']); } $this->form->add(new HiddenBox('osy[rid]')); $this->param['default_component_parent'] = 1; $this->viewToolbar = new toolbar('toolbar'); $this->form->put($this->viewToolbar, '', 'toolbar', 1, 1); //$this->form->add($this->viewToolbar); $this->buildFieldSearch(); //Costruisco il tab se necessario; $parameters = ['name' => 'data-view', 'phpClass' => 'DataGrid', 'attribute' => ['class' => 'dataview-2-body osy-datagrid-2 osy-maximize'], 'cell-attribute' => ['colspan' => 100], 'parameter' => ['datasource-sql' => $this->getParam('sql-query'), 'row-num' => $this->getParam('row-num'), 'record-add' => false, 'form-related' => $this->getParam('form-related'), 'form-related-ins' => $this->getParam('form-related-insert')]]; $this->viewBody = ComponentFactory::create($parameters); $this->viewBody->appendRequired($this->response); if (!$this->buildTab()) { //$this->viewBody = new DataGrid('data-view'); $this->form->put($this->viewBody, '', '', 100, 10); if (!empty($_REQUEST['osy']) && !empty($_REQUEST['osy']['layout'])) { $this->viewBody->par('layout', $_REQUEST['osy']['layout']); } } /* $this->viewBody->setDboHandler($this->model->dba); $this->viewBody->appendRequired($this->response); $this->viewBody->par('colspan','100',function($key,$val,$self){ $self->man('onbuild','colspan',function($key, $val,$self) { $cel = $self->closest('td,th'); if (!is_object($cel)) return; $cel->att('colspan',$val); }); }); $this->viewBody->par('datasource-sql',$this->getParam('sql-query')); $this->viewBody->par('row-num',$this->getParam('row-num')); $this->viewBody->par('record-add',false); $this->viewBody->par('form-related',$this->getParam('form-related')); $this->viewBody->par('form-related-ins',$this->getParam('form-related-insert')); $this->viewBody->att('class',''); */ if (!empty($_POST['filter'])) { foreach ($_POST['filter'] as $field => $value) { $this->viewBody->add_filter($field, '%' . str_replace("'", "''", $value) . '%', 'like'); } } if ($this->getParam('button-insert') == '1') { /*$this->viewToolbar->add(new tag('img'))->att(Array('src' => '../img/rec_new.gif', 'class' => 'toolbar insert', 'alt' => 'Aggiungi un nuovo record'));*/ $this->viewToolbar->add(new Tag('span'))->att('class', 'insert fa fa-plus-square fa-lg'); } //Aggiungo icona modifica record /*$this->viewToolbar->add(new tag('img'))->att(Array('src' => '../img/rec_upd.gif', 'pk' => 'req', 'class' => 'toolbar update', 'alt' => 'Modifica il record selezionato'));*/ //Aggiungo eventuali comandi if ($this->getParam('FRMCMD')) { $this->viewToolbar->add($this->param['FRMCMD']); } if ($this->getParam('TYP') != 'DTS') { /*$this->viewToolbar->add(new tag('img'))->att(Array('src' => '../img/rec_src.gif', 'alt' => 'Ricerca dati', 'class' => 'toolbar search', 'id' => 'button_show_search'));*/ $this->viewToolbar->add(tag::create('span'))->att('class', 'search fa fa-filter fa-lg'); } if ($this->getParam('FRMPDF')) { $this->viewToolbar->Add(new tag('img'))->att(array('src' => '../img/ico.pdf.gif', 'alt' => 'Modifica il record selezionato', 'class' => 'toolbar', 'onclick' => "OpenPage('" . $this->Properties['FrmPdf'] . "',800,600)")); } if (!empty($this->param['field-list-data-import'])) { $this->viewToolbar->Add(new tag('img'))->att(array('src' => '../img/ico.xls.import.png', 'alt' => 'Importa dati da excel', 'class' => 'toolbar', 'onclick' => "oform.main.excel_import()")); $this->form->att('enctype', 'multipart/form-data'); } if (!empty($this->param['sql-query-excel'])) { $this->viewToolbar->Add(new tag('img'))->att(array('src' => '../img/ico.xls.png', 'alt' => 'Esporta in excel', 'class' => 'toolbar', 'onclick' => "oform.main.excel_export()")); } }
/** ** @abstract Metodo che si occupa di caricare i parametri dei diversi campi prelevati dal db ** all'interno dell'oggetto form al fine di instanziarli e visualizzarli. ** @private ** @return void **/ private static function buildForm() { foreach (self::$model->field as $id => $f) { /*Istanzio il componente attraverso la ComponentFactory*/ self::$model->field[$id]['object'] = ComponentFactory::create($f); //If ComponentFactory don't return a valid component obscure visibility if (!is_object(self::$model->field[$id]['object'])) { self::$model->field[$id]['visible'] = false; continue; } //Define visible the component (model will work on the visible component) self::$model->field[$id]['visible'] = true; if (array_key_exists('ajax', $_REQUEST) && $_REQUEST['ajax'] == $f['name']) { //Da migliorare creando metodo separato di gestione self::$form->put(self::$model->field[$id]['object'], 'dummy', 'dummy', 1, 1, 0); return; } self::$model->field[$id]['object']->appendRequired(self::$page); //If component is displayed on foot add is to command array if (!empty($f['in-command-panel'])) { self::$model->field[$id]['object']->att('class', 'extra wmin80'); self::$param['command'][] = self::$model->field[$id]['object']; continue; } //Add component on the form self::$form->put(self::$model->field[$id]['object'], $f['label'], $f['name'], HelperOsy::nvl($f['position-row'], -1), HelperOsy::nvl($f['position-column'], 0), HelperOsy::nvl($f['position-panel-parent'], 0)); } }
/** * Exec action ajax request from the view * * @return bool */ public function ajaxAction($action) { //se il dispatch dell'evento "form-ajax + action" da risultato positivo (almeno 1 listener eseguito) rispondo. $response = new JsonResponse(); $this->dispatcher->setResponse($response); if ($this->dispatcher->dispatch('form-ajax', $action) > 0) { return $response; } //se non è stato richiamato un trigger allora controllo se è stato richiamato l'aggiornamento di un componente foreach ($this->model->field as $fieldId => $fieldProp) { if ($fieldProp['name'] == $action) { ComponentFactory::init('ajax', $this->model); ComponentFactory::create($fieldProp)->ajaxResponse($this, $response); return $response; } } }