MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mlookupgrid.class
Ir para a documentação deste ficheiro.
1<?php
2
3class MLookupGrid extends MDataGrid
4{
5 protected $filterColumns = 0;
6
18 {
19 parent::__construct($query, $columns, $href, $pageLength, $index, '', true, true, false, false, false);
20 $this->emptyMsg = _M('No records found!');
21 $this->SetFiltered(true);
22 $this->filterColumns = $filterColumns;
23
24 $filtered = $this->GetFiltered();
25 $this->pn = new GridNavigator($this->pageLength, $this->rowCount,
26 $this->GetURL($filtered, $this->ordered), $this);
27 }
28
29 public function generate()
30 {
31 $this->generateData();
32 $header = $this->painter->generateToString($this->generateHeader());
33 $title = $this->painter->generateToString($this->generateTitle());
34 $body = $this->painter->generateToString($this->generateBody());
35 $footer = $this->painter->generateToString($this->generateFooter());
36
37 $f = new MDiv('', array( $title, $header, $body, $footer, $this->hiddenControls ), 'm-grid-box panel card panel-default m-lookup-panel');
38
39 if ( $this->width != '' )
40 {
41 $f->addStyle('width', $this->width);
42 }
43
44 return $f->generate();
45 }
46
47 function generateData()
48 {
49 if ( $this->query )
50 {
51 $this->data = $this->query->result;
52 $this->rowCount = $this->query->GetRowCount();
53
54 if ($this->pageLength)
55 {
56 $filtered = $this->GetFiltered();
57
58 $this->pn->SetGridParameters($this->pageLength, $this->rowCount, $this->GetURL($filtered, $this->ordered), $this);
59
60 $this->query->SetpageLength($this->pageLength);
61 $this->data = $this->query->GetPage($this->pn->GetPageNumber());
62 }
63 else
64 {
65 $this->pn = null;
66 }
67 }
68 }
69
70 function GenerateTitle()
71 {
72 $t = new BoxTitle('boxTitle', $this->title, 'javascript:MIOLO_Close();');
73 $t->setBoxClass('m-box-title panel-heading card-header');
74 return $t;
75 }
76
77 function generateFilter()
78 {
80 if ( ! $this->filter )
81 {
82 return null;
83 }
84
85 if ( $this->filterColumns > 0 )
86 {
87 $table = new MSimpleTable('filterTable', "cellspacing=0 cellpadding=2 align=left border=0 width=100%", 3, $this->filterColumns);
88 $lin = (int) 0;
89 $col = (int) 0;
90
91 foreach ( $this->filters as $k => $f )
92 {
93 // Hidden fields should not be included
94 if ( in_array(get_class($f->control), array('SHiddenField', 'MHiddenField')) )
95 {
96 $array[] = $f->control;
97 continue;
98 }
99
100 // Ajusta label dos campos
101 if ( strpos(MIOLO::getInstance()->getTheme()->id, "sbootstrap") !== false )
102 {
103 $f->control->addAttribute('placeHolder', $f->control->label);
104 $f->control->addAttribute('title', $f->control->label);
105
106 if ( get_class($f->control) == 'MSelection' )
107 {
108 $f->control->options[''] = ' --' . $f->control->label . '-- ';
109 }
110
111 $this->page->onload('
112 $( document ).ready(function() {
113 $("body").css("background", "none");
114 });
115 ');
116 }
117
118 if ( $col > $this->filterColumns-1 )
119 {
120 $lin++;
121 $col = 0;
122 }
123
124 $table->setCell( $lin, $col, $f->generate() );
125 $table->setCellAttribute($lin,$col,'style','border: 1px dashed #ddd; text-align:left;');
126 $col++;
127 }
128
129 $array[] = $table;
130 }
131 else
132 {
133 foreach ($this->filters as $k => $f)
134 {
135 $array[] = $f->generate();
136 }
137 }
138
139 $filterButton = new MButton( '', _M('Filter'), 'submit');
140 $filterButton->addBoxStyle('text-align', 'center');
141 $array[] = $filterButton;
142
143 $array[] = new MSeparator;
144 return new MDiv('', $array, 'm-grid-filter');
145 }
146
147 function GenerateHeader()
148 {
150 $header[] = $this->GenerateFilter();
151 return $header;
152 }
153
154 function GenerateFooter()
155 {
157 if (!$this->data)
158 $footer[] = $this->GenerateEmptyMsg();
159
160 $footer[] = new Separator();
161 $footer[] = $this->GenerateNavigationFooter();
162 return $footer;
163 }
164}
165
166?>
generateBody($data=null)
static getInstance()
Definição miolo.class:134
__construct(&$query, $columns, $href, $pageLength=15, $index=0, $filterColumns=0)