Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
76.92% covered (success)
76.92%
30 / 39
CRAP
64.20% covered (warning)
64.20%
156 / 243
TFormCreate
0.00% covered (danger)
0.00%
0 / 1
76.92% covered (success)
76.92%
30 / 39
302.34
64.20% covered (warning)
64.20%
156 / 243
 __construct
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
6 / 6
 setFormTitle
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
3 / 3
 getFormTitle
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 setFormPath
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
3 / 3
 getFormPath
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 setFormFileName
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
3 / 3
 getFormFileName
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 setPrimaryKeyTable
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
3 / 3
 getPrimaryKeyTable
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 setTableRef
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 setListColunnsName
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
3 / 3
 validateListColumnsName
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 setGridType
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
3 / 3
 getGridType
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getLinesArray
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getLinesString
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 addLine
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
3 / 3
 addBlankLine
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 addBasicaFields
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 5
 addBasicaViewController_salvar
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 14
 addBasicaViewController_buscar
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 6
 addBasicaViewController_limpar
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 5
 addBasicaViewController_gdExcluir
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 13
 addBasicaViewController
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 10
 getMixUpdateFields
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
7 / 7
 addColumnsGrid
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
5 / 5
 addGetWhereGridParameters_fied
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
4 / 4
 addGetWhereGridParametersFields
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
3 / 3
 addGetWhereGridParametersArray
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
5 / 5
 addGetWhereGridParameters
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
10 / 10
 addBasicaGrid
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
14 / 14
 addGridPagination_jsScript_init_parameter
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
5 / 5
 addGridPagination_jsScript_init_allparameters
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
9 / 9
 addGridPagination_jsScript_init
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
5 / 5
 addGridPagination_jsScript_buscar
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
5 / 5
 addGridPagination_jsScript
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
5 / 5
 addGrid
100.00% covered (success)
100.00%
1 / 1
5
100.00% covered (success)
100.00%
41 / 41
 addButtons
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 6
 showForm
0.00% covered (danger)
0.00%
0 / 1
20
0.00% covered (danger)
0.00%
0 / 25
 saveForm
n/a
0 / 0
3
n/a
0 / 0
1<?php
2/*
3 * Formdin Framework
4 * Copyright (C) 2012 Ministério do Planejamento
5 * Criado por Luís Eugênio Barbosa
6 * Essa versão é um Fork https://github.com/bjverde/formDin
7 *
8 * ----------------------------------------------------------------------------
9 * This file is part of Formdin Framework.
10 *
11 * Formdin Framework is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public License version 3
13 * as published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License version 3
21 * along with this program; if not,  see <http://www.gnu.org/licenses/>
22 * or write to the Free Software Foundation, Inc., 51 Franklin Street,
23 * Fifth Floor, Boston, MA  02110-1301, USA.
24 * ----------------------------------------------------------------------------
25 * Este arquivo é parte do Framework Formdin.
26 *
27 * O Framework Formdin é um software livre; você pode redistribuí-lo e/ou
28 * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
29 * do Software Livre (FSF).
30 *
31 * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
32 * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
33 * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
34 * para maiores detalhes.
35 *
36 * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
37 * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
38 * ou escreva para a Fundação do Software Livre (FSF) Inc.,
39 * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
40 */
41
42class TFormCreate {
43    private $formTitle;
44    private $formPath;
45    private $formFileName;
46    private $primaryKeyTable;
47    private $tableRef;
48    private $daoTableRef;
49    private $voTableRef;
50    private $listColumnsName;
51    private $lines;
52    private $gridType;
53
54    public function __construct(){
55        $this->setFormTitle(null);
56        $this->setFormPath(null);
57        $this->setFormFileName(null);
58        $this->setPrimaryKeyTable(null);
59        $this->setGridType(null);
60    }
61    //--------------------------------------------------------------------------------------
62    public function setFormTitle($formTitle) {
63        $formTitle = ( !empty($formTitle) ) ? $formTitle : "titulo";
64        $this->formTitle    = $formTitle;
65    }
66    //--------------------------------------------------------------------------------------
67    public function getFormTitle() {
68        return $this->formTitle;
69    }
70    //--------------------------------------------------------------------------------------
71    public function setFormPath($formPath) {
72        $formPath = ( !empty($formPath) ) ?$formPath : "/modulos";
73        $this->formPath    = $formPath;
74    }
75    //--------------------------------------------------------------------------------------
76    public function getFormPath() {
77        return $this->formPath;
78    }
79    //--------------------------------------------------------------------------------------
80    public function setFormFileName($formFileName) {
81        $formFileName = ( !empty($formFileName) ) ?$formFileName : "form-".date('Ymd-Gis');
82        $this->formFileName    = $formFileName.'.php';
83    }
84    //--------------------------------------------------------------------------------------
85    public function getFormFileName() {
86        return $this->formFileName;
87    }
88    //--------------------------------------------------------------------------------------
89    public function setPrimaryKeyTable($primaryKeyTable) {
90        $primaryKeyTable = ( !empty($primaryKeyTable) ) ?$primaryKeyTable : "id";
91        $this->primaryKeyTable    = strtoupper($primaryKeyTable);
92    }
93    //--------------------------------------------------------------------------------------
94    public function getPrimaryKeyTable() {
95        return $this->primaryKeyTable;
96    }
97    //--------------------------------------------------------------------------------------
98    public function setTableRef($tableRef) {
99        $this->daoTableRef= ucfirst($tableRef).'DAO';
100        $this->voTableRef = ucfirst($tableRef).'VO';
101    }
102    //--------------------------------------------------------------------------------------
103    public function setListColunnsName($listColumnsName) {
104        array_shift($listColumnsName);
105        $this->listColumnsName = array_map('strtoupper', $listColumnsName);
106    }
107    //--------------------------------------------------------------------------------------
108    public function validateListColumnsName() {
109     return isset($this->listColumnsName) && !empty($this->listColumnsName);
110    }
111    //--------------------------------------------------------------------------------------
112    public function setGridType($gridType) {
113        $gridType = ( !empty($gridType) ) ?$gridType : GRID_SIMPLE;
114        $this->gridType = $gridType;
115    }
116    //--------------------------------------------------------------------------------------
117    public function getGridType() {
118        return $this->gridType;
119    }
120    //------------------------------------------------------------------------------------
121    public function getLinesArray(){
122        return $this->lines;
123    }
124    //------------------------------------------------------------------------------------
125    public function getLinesString(){
126        $string = implode($this->lines);
127        return trim($string);
128    }
129    //--------------------------------------------------------------------------------------    
130    private function addLine($strNewValue=null,$boolNewLine=true){
131        $strNewValue = is_null( $strNewValue ) ? TAB.'//' . str_repeat( '-', 80 ) : $strNewValue;
132        $this->lines[] = $strNewValue.( $boolNewLine ? EOL : '');
133    }
134    //--------------------------------------------------------------------------------------    
135    private function addBlankLine(){
136        $this->addLine('');
137    }    
138    //--------------------------------------------------------------------------------------
139    private function addBasicaFields() {
140        $this->addLine('$frm->addHiddenField( $primaryKey );   // coluna chave da tabela');
141        if( $this->validateListColumnsName() ){
142            foreach($this->listColumnsName as $key=>$value){
143                $this->addLine('$frm->addTextField(\''.$value.'\', \''.$value.'\',50,true);');
144            }
145        }        
146    }
147    //--------------------------------------------------------------------------------------
148    private function addBasicaViewController_salvar() {
149        $this->addLine(TAB.'case \'Salvar\':');
150        $this->addLine(TAB.TAB.'if ( $frm->validate() ) {');
151        $this->addLine(TAB.TAB.TAB.'$vo = new '.$this->voTableRef.'();');
152        $this->addLine(TAB.TAB.TAB.'$frm->setVo( $vo );');
153        $this->addLine(TAB.TAB.TAB.'$resultado = '.$this->daoTableRef.'::insert( $vo );');
154        $this->addLine(TAB.TAB.TAB.'if($resultado==1) {');
155        $this->addLine(TAB.TAB.TAB.TAB.'$frm->setMessage(\'Registro gravado com sucesso!!!\');');
156        $this->addLine(TAB.TAB.TAB.TAB.'$frm->clearFields();');
157        $this->addLine(TAB.TAB.TAB.'}else{');
158        $this->addLine(TAB.TAB.TAB.TAB.'$frm->setMessage($resultado);');
159        $this->addLine(TAB.TAB.TAB.'}');
160        $this->addLine(TAB.TAB.'}');
161        $this->addLine(TAB.'break;');
162    }
163    //--------------------------------------------------------------------------------------
164    private function addBasicaViewController_buscar() {
165        $this->addLine();
166        $this->addLine(TAB.'case \'Buscar\':');
167        $this->addGetWhereGridParametersArray( TAB.TAB );
168        $this->addLine(TAB.TAB.'$whereGrid = $retorno;');
169        $this->addLine(TAB.'break;');
170    }
171    //--------------------------------------------------------------------------------------
172    private function addBasicaViewController_limpar() {
173        $this->addLine();
174        $this->addLine(TAB.'case \'Limpar\':');
175        $this->addLine(TAB.TAB.'$frm->clearFields();');
176        $this->addLine(TAB.'break;');
177    }
178    //--------------------------------------------------------------------------------------
179    private function addBasicaViewController_gdExcluir() {
180        $this->addLine();
181        $this->addLine(TAB.'case \'gd_excluir\':');
182        $this->addLine(TAB.TAB.'$id = $frm->get( $primaryKey ) ;');
183        $this->addLine(TAB.TAB.'$resultado = '.$this->daoTableRef.'::delete( $id );;');
184        $this->addLine(TAB.TAB.'if($resultado==1) {');
185        $this->addLine(TAB.TAB.TAB.'$frm->setMessage(\'Registro excluido com sucesso!!!\');');
186        $this->addLine(TAB.TAB.TAB.'$frm->clearFields();');
187        $this->addLine(TAB.TAB.'}else{');
188        $this->addLine(TAB.TAB.TAB.'$frm->clearFields();');
189        $this->addLine(TAB.TAB.TAB.'$frm->setMessage($resultado);');
190        $this->addLine(TAB.TAB.'}');
191        $this->addLine(TAB.'break;');
192    }
193    //--------------------------------------------------------------------------------------
194    private function addBasicaViewController() {
195        $this->addBlankLine();
196        $this->addLine('$acao = isset($acao) ? $acao : null;');
197        $this->addLine('switch( $acao ) {');
198        $this->addBasicaViewController_salvar();
199        if($this->gridType == GRID_SIMPLE){
200            $this->addBasicaViewController_buscar();
201        }
202        $this->addBasicaViewController_limpar();
203        $this->addBasicaViewController_gdExcluir();
204        $this->addLine('}');
205    }
206    //--------------------------------------------------------------------------------------
207    public function getMixUpdateFields() {
208        if( $this->validateListColumnsName() ){
209            $mixUpdateFields = '$primaryKey.\'|\'.$primaryKey.\'';
210            foreach($this->listColumnsName as $key=>$value){
211                $mixUpdateFields = $mixUpdateFields.','.$value.'|'.$value;
212            }
213            $mixUpdateFields = $mixUpdateFields.'\';';
214            $mixUpdateFields = '$mixUpdateFields = '.$mixUpdateFields;
215        }
216        return $mixUpdateFields;
217    }
218    //--------------------------------------------------------------------------------------
219    public function addColumnsGrid($qtdTab) {
220        $this->addLine($qtdTab.'$gride->addColumn($primaryKey,\'id\',50,\'center\');');
221        if( $this->validateListColumnsName() ){
222            foreach($this->listColumnsName as $key=>$value){
223                $this->addLine($qtdTab.'$gride->addColumn(\''.$value.'\',\''.$value.'\',50,\'center\');');
224            }
225        }
226    }
227    //--------------------------------------------------------------------------------------
228    public function addGetWhereGridParameters_fied($primeira, $campo, $qtdTabs) {
229        if( $primeira == TRUE ){
230            $this->addLine($qtdTabs.'\''.$campo.'\'=>$frm->get(\''.$campo.'\')');
231        } else {
232            $this->addLine($qtdTabs.',\''.$campo.'\'=>$frm->get(\''.$campo.'\')');
233        }
234    }
235    //--------------------------------------------------------------------------------------
236    public function addGetWhereGridParametersFields( $qtdTabs ) {
237        foreach($this->listColumnsName as $key=>$value){
238            $this->addGetWhereGridParameters_fied(false, $value, $qtdTabs);
239        }
240    }
241    //--------------------------------------------------------------------------------------
242    public function addGetWhereGridParametersArray( $qtdTabs ) {
243        $this->addLine($qtdTabs.'$retorno = array(');
244        $this->addGetWhereGridParameters_fied(true, $this->getPrimaryKeyTable(), $qtdTabs.TAB.TAB);
245        $this->addgetWhereGridParametersFields($qtdTabs.TAB.TAB);
246        $this->addLine($qtdTabs.');');
247    }
248    //--------------------------------------------------------------------------------------
249    public function addGetWhereGridParameters() {
250        if( $this->validateListColumnsName() ){
251            $this->addBlankLine();
252            $this->addLine('function getWhereGridParameters(&$frm){');
253            $this->addLine(TAB.'$retorno = null;');
254            $this->addLine(TAB.'if($frm->get(\'BUSCAR\') == 1 ){');
255            $this->addGetWhereGridParametersArray( TAB.TAB );
256            $this->addLine(TAB.'}');
257            $this->addLine(TAB.'return $retorno;');
258            $this->addLine('}');
259        }
260    }
261    //--------------------------------------------------------------------------------------
262    private function addBasicaGrid() {
263        $this->addBlankLine();
264        $this->addLine('$dados = '.$this->daoTableRef.'::selectAll($primaryKey,$whereGrid);');
265        $this->addLine($this->getMixUpdateFields());
266        $this->addLine('$gride = new TGrid( \'gd\'        // id do gride');
267        $this->addLine('                   ,\'Gride\'     // titulo do gride');
268        $this->addLine('                   ,$dados           // array de dados');
269        $this->addLine('                   ,null          // altura do gride');
270        $this->addLine('                   ,null          // largura do gride');
271        $this->addLine('                   ,$primaryKey   // chave primaria');
272        $this->addLine('                   ,$mixUpdateFields');
273        $this->addLine('                   );');
274        $this->addColumnsGrid(null);
275        $this->addLine('$frm->addHtmlField(\'gride\',$gride);');
276    }
277    //--------------------------------------------------------------------------------------
278    public function addGridPagination_jsScript_init_parameter($frist, $parameter) {
279        $result = null;
280        if( $frist == TRUE ){
281            $result = '"'.$parameter.'":""';
282        } else {
283            $result = ',"'.$parameter.'":""';
284        }
285        return $result;
286    }    
287    //--------------------------------------------------------------------------------------
288    public function addGridPagination_jsScript_init_allparameters($qtdTab) {
289        if( $this->validateListColumnsName() ){
290            $line = null;
291            $line = $line.$this->addGridPagination_jsScript_init_parameter(true,'BUSCAR');
292            $line = $line.$this->addGridPagination_jsScript_init_parameter(false,$this->getPrimaryKeyTable());
293            foreach($this->listColumnsName as $key=>$value){
294                $line = $line.$this->addGridPagination_jsScript_init_parameter(false,$value);
295            }
296            $line = $qtdTab.'var Parameters = {'.$line.'};';
297            $this->addLine($line);
298        }
299    }
300    //--------------------------------------------------------------------------------------
301    public function addGridPagination_jsScript_init() {
302        $this->addLine('function init() {');
303        $this->addGridPagination_jsScript_init_allparameters(TAB);
304        $this->addLine(TAB.'fwGetGrid(\''.$this->formFileName.'\',\'gride\',Parameters,true);');
305        $this->addLine('}');
306    }
307    //--------------------------------------------------------------------------------------
308    public function addGridPagination_jsScript_buscar() {
309        $this->addLine('function buscar() {');
310        $this->addLine(TAB.'jQuery("#BUSCAR").val(1);');
311        $this->addLine(TAB.'init();');
312        $this->addLine('}');
313    }
314    //--------------------------------------------------------------------------------------
315    public function addGridPagination_jsScript() {
316        $this->addLine('<script>');
317        $this->addGridPagination_jsScript_init();
318        $this->addGridPagination_jsScript_buscar();
319        $this->addLine('</script>');
320    }
321    //--------------------------------------------------------------------------------------
322    public function addGrid() {
323        
324        if($this->gridType == GRID_SIMPLE){
325            $this->addBasicaGrid();
326            $this->addBlankLine();
327            $this->addLine('$frm->show();');
328            $this->addLine("?>");
329        }else{
330            $this->addGetWhereGridParameters();
331            $this->addBlankLine();
332            $this->addLine('if( isset( $_REQUEST[\'ajax\'] )  && $_REQUEST[\'ajax\'] ) {');
333            $this->addLine(TAB.'$maxRows = ROWS_PER_PAGE;');
334            $this->addLine(TAB.'$whereGrid = getWhereGridParameters($frm);');
335            if($this->gridType == GRID_SQL_PAGINATION){                
336                $this->addLine(TAB.'$page = PostHelper::get(\'page\');');
337                $this->addLine(TAB.'$dados = '.$this->daoTableRef.'::selectAllPagination( $primaryKey, $whereGrid, $page,  $maxRows);');
338                $this->addLine(TAB.'$realTotalRowsSqlPaginator = '.$this->daoTableRef.'::selectCount( $whereGrid );');
339            }else if($this->gridType == GRID_SCREEN_PAGINATION){
340                $this->addLine(TAB.'$dados = '.$this->daoTableRef.'::selectAll( $primaryKey, $whereGrid );');
341            }
342            $this->addLine(TAB.$this->getMixUpdateFields());
343            $this->addLine(TAB.'$gride = new TGrid( \'gd\'                        // id do gride');
344            $this->addLine(TAB.'                   ,\'Gride with SQL Pagination\' // titulo do gride');
345            $this->addLine(TAB.'                   );');
346            $this->addLine(TAB.'$gride->addKeyField( $primaryKey ); // chave primaria');
347            $this->addLine(TAB.'$gride->setData( $dados ); // array de dados');
348            if($this->gridType == GRID_SQL_PAGINATION){
349                $this->addLine(TAB.'$gride->setRealTotalRowsSqlPaginator( $realTotalRowsSqlPaginator );');
350            }
351            $this->addLine(TAB.'$gride->setMaxRows( $maxRows );');
352            $this->addLine(TAB.'$gride->setUpdateFields($mixUpdateFields);');
353            $this->addLine(TAB.'$gride->setUrl( \''.$this->getFormFileName().'\' );');
354            $this->addBlankLine();
355            $this->addColumnsGrid(TAB);
356            $this->addBlankLine();
357            $this->addLine(TAB.'$gride->show();');
358            $this->addLine(TAB.'die();');
359            $this->addLine('}');
360            $this->addBlankLine();
361            $this->addLine('$frm->addHtmlField(\'gride\');');
362            $this->addLine('$frm->addJavascript(\'init()\');');
363            $this->addLine('$frm->show();');
364            $this->addBlankLine();
365            $this->addLine("?>");
366            $this->addGridPagination_jsScript();
367        }
368    }
369    //--------------------------------------------------------------------------------------
370    public function addButtons() {
371        if($this->gridType == GRID_SIMPLE){
372            $this->addLine('$frm->addButton(\'Buscar\', null, \'Buscar\', null, null, true, false);');
373        }else{
374            $this->addLine('$frm->addButton(\'Buscar\', null, \'btnBuscar\', \'buscar()\', null, true, false);');
375        }
376        $this->addLine('$frm->addButton(\'Salvar\', null, \'Salvar\', null, null, false, false);');
377        $this->addLine('$frm->addButton(\'Limpar\', null, \'Limpar\', null, null, false, false);');
378    }
379    //--------------------------------------------------------------------------------------
380    public function showForm($print=false) {
381        $this->lines=null;
382        $this->addLine('<?php');
383        $this->addLine('defined(\'APLICATIVO\') or die();');
384        $this->addBlankLine();
385        if($this->gridType == GRID_SIMPLE){
386            $this->addLine('$whereGrid = \' 1=1 \';');
387        }
388        $this->addLine('$primaryKey = \''.$this->getPrimaryKeyTable().'\';');
389        $this->addLine('$frm = new TForm(\''.$this->formTitle.'\',600);');
390        $this->addLine('$frm->setFlat(true);');
391        $this->addLine('$frm->setMaximize(true);');
392        $this->addBlankLine();
393        $this->addBlankLine();
394        if($this->gridType != GRID_SIMPLE){
395            $this->addLine('$frm->addHiddenField( \'BUSCAR\' ); //Campo oculto para buscas');
396        }
397        $this->addBasicaFields();
398        $this->addBlankLine();
399        $this->addButtons();
400        $this->addBlankLine();
401        $this->addBasicaViewController();
402        $this->addBlankLine();
403        $this->addGrid();
404        
405        if( $print){
406            echo $this->getLinesString();
407        }else{
408            return $this->getLinesString();
409        }
410    }    
411    //---------------------------------------------------------------------------------------
412    /**
413     * @codeCoverageIgnore
414     */
415    public function saveForm(){
416        $fileName = $this->formPath.DS.$this->formFileName;
417        if($fileName){
418            if( file_exists($fileName)){
419                unlink($fileName);
420            }
421            $payload = $this->showForm(false);
422            file_put_contents($fileName,$payload);
423        }
424    }
425}
426?>