MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mlookup.class
Ir para a documentação deste ficheiro.
1
<?php
2
class
MLookup
3
{
4
var
$listingTitle
;
5
var
$dbconf
;
6
var
$sql
;
7
var
$labels
;
8
var
$formName
;
9
var
$module
;
10
var
$item
;
11
var
$lheight
;
12
var
$lwidth
;
13
var
$function
;
14
var
$event
;
15
var
$filterValue
=
''
;
16
var
$filterFields
;
17
var
$form
;
18
var
$pageLength
= 20;
19
var
$keyColumn
;
20
var
$title
;
21
var
$grid
;
22
var
$related
;
23
var
$baseModule
;
24
var
$gridClass
=
'LookupGrid'
;
25
var
$lookupType
=
'grid'
;
26
protected
$filterColumns
= 0;
27
28
function
__construct
(
$baseModule
=
'admin'
)
29
{
30
global
$MIOLO
;
31
32
$this->baseModule =
$baseModule
;
33
$this->formName = $_GET[
'name'
];
34
$this->module = $_GET[
'lmodule'
];
35
$this->item = $_GET[
'item'
];
36
$this->
function
= $_GET[
'function'
];
37
$this->
event
= $_GET[
'event'
];
38
$this->lheight = $_GET[
'lheight'
];
39
$this->lwidth = $_GET[
'lwidth'
];
40
$this->related = $_GET[
'related'
];
41
$this->filterValue = $_GET[
'filter'
];
42
$url
=
$MIOLO
->GetActionURL($this->baseModule,
43
'lookup'
, urlencode($this->item), array(
'name'
=> urlencode($this->formName),
'lmodule'
=> urlencode($this->module),
'function'
=> urlencode($this->
function
),
'event'
=> urlencode($this->event)), NULL,
false
);
44
$this->href =
$url
;
45
$this->listingTitle = _M(
'Search Result'
);
46
}
47
48
public
function
setListingTitle
(
$title
)
49
{
50
$this->listingTitle =
$title
;
51
}
52
53
function
GetFilterValue
($name =
''
)
54
{
55
global $page;
56
57
$value = ($name !=
''
) ? $page->Request($name) :
$this->filterValue
;
58
$value = str_replace(
"'"
,
''
, $value);
59
$value = str_replace(
"\""
,
''
, $value);
60
$value = str_replace(
"#"
,
''
, $value);
61
return
$value;
62
}
63
64
function
setLookupType
( $type=
'grid'
)
65
{
66
$this->lookupType = $type;
67
}
68
69
function
generate
( )
70
{
71
if
( $this->lookupType ==
'form'
)
72
{
73
return
$this->form
;
74
}
75
return
$this->grid
;
76
}
77
78
function
setLookupForm
(
$title
)
79
{
80
$this->
setLookupType
(
'form'
);
81
$this->form =
new
mForm(
$title
,
''
,
'javascript:MIOLO_Close( )'
);
82
83
$idx = MIOLO::_Request(
'idx'
);
84
$related
= explode(
','
, MIOLO::_Request(
'related'
));
85
if
( is_array($idx) )
86
{
87
$info = array( );
88
foreach
(
$related
as $r)
89
{
90
if
( $idx[$r] )
91
{
92
$info[] =
"document.forms[0]['$campoAqui'].value"
;
93
}
94
else
95
{
96
$info[] =
'null'
;
97
}
98
}
99
$info = implode(
','
, $info);
100
$related
= implode(
','
,
$related
);
101
}
102
else
103
{
104
$info =
"''"
;
105
}
106
107
if
(
$related
)
108
{
109
$this->form->page->onLoad(
"eval('MIOLO_getWindow( true ).' + '$this->formName').related = '$related';"
);
110
}
111
$this->form->addButton(
new
FormButton
(
'submit'
, _M(
'Send'
),
"MIOLO_Deliver( '$this->formName', 0, $info);"
));
112
}
113
114
function
addField
( $field )
115
{
116
$this->form->addField( $field );
117
}
118
119
function
setFields
( $fields )
120
{
121
$this->form->setFields( $fields );
122
}
123
124
public
function
setFilterColumns
($countColumns)
125
{
126
$this->filterColumns = $countColumns;
127
}
128
129
function
GetHRef
()
130
{
131
return
$this->href;
132
}
133
134
function
&
GetQuery
(
$dbconf
,
$sql
)
135
{
136
global
$MIOLO
;
137
$db =
$MIOLO
->GetDatabase(
$dbconf
);
138
return
$db->GetQuery(
$sql
);
139
}
140
141
function
AddFilterField
($field)
142
{
143
$this->filterFields[] = &$field;
144
}
145
146
function
SetGridClass
($class,
$module
, $classFile)
147
{
148
global
$MIOLO
;
149
150
$MIOLO
->Uses($classFile,
$module
);
151
$this->gridClass = $class;
152
}
153
154
function
getGrid
($query, $columns, $href,
$pageLength
, $indexColumn)
155
{
156
return
new
$this->gridClass($query, $columns, $href,
$pageLength
, $indexColumn, $this->filterColumns);
157
}
158
159
function
setLookupGrid
(
$dbconf
,
$sql
, $columns,
$title
=
'Search'
,
$pageLength
= 15, $indexColumn = 0)
160
{
161
// if $sql is an array, we create a MGrid and put the data
162
if
( ! is_object(
$sql
) )
163
{
164
$this->grid =
new
MGrid
(
$sql
, $columns, $this->href,
$pageLength
, $indexColumn,
''
,
true
,
true
,
false
,
false
,
false
);
165
}
166
else
167
{
168
try
169
{
170
$query = $this->getQuery(
$dbconf
,
$sql
);
171
}
172
catch
(
EDatabaseException
$e )
173
{
174
$query = NULL;
175
}
176
177
$this->grid = $this->
getGrid
($query, $columns, $this->href,
$pageLength
, $indexColumn);
178
}
179
180
$this->grid->setFilter(
true
);
181
$this->grid->setLinkType(
'hyperlink'
);
182
$this->grid->setTitle(
$title
);
183
184
for
($i = 0; $i < count($this->filterFields); $i++)
185
{
186
$this->grid->addFilterControl($i, $this->filterFields[$i]);
187
}
188
189
if
( ! is_object(
$sql
) )
190
{
191
for
($i = 0; $i < count($columns); $i++)
192
{
193
if
($i)
194
{
195
$args .=
','
;
196
}
197
198
$args .=
""#$i#""
;
199
}
200
}
201
else
202
{
203
for
($i = 0; $i < count($query->result[0]); $i++)
204
{
205
if
($i)
206
{
207
$args .=
','
;
208
}
209
210
$args .=
""#$i#""
;
211
}
212
}
213
214
$actionIcon =
"javascript:MIOLO_Deliver('$this->formName', {$indexColumn}, $args)"
;
215
216
if
(strpos(
MIOLO::getInstance
()->getTheme()->
id
,
"sbootstrap"
) !==
false
)
217
{
218
MIOLO::getInstance
()->getPage()->addAJAXJsCode(
"
219
// Modal title, não tenho esse título antes
220
window.parent.document.getElementById('lookupTitle_"
.$_GET[
'field'
].
"').innerHTML = '"
.$this->grid->title.
"';
221
222
// ESC para fechar
223
window.onkeydown = function(e) {
224
var e = e || window.event;
225
if (e.keyCode === 27) {
226
window.parent.closeLookupModals();
227
}
228
}
229
230
// Stop no loading
231
let stateCheck = setInterval(() => {
232
if (document.readyState === 'complete') {
233
clearInterval(stateCheck);
234
document.getElementsByTagName('BODY')[0].style = 'min-height: 0;';
235
window.parent.stopShowLoading();
236
}
237
}, 100);
238
239
"
);
240
241
$actionIcon .=
";window.parent.closeLookupModals();"
;
242
}
243
244
$this->grid->addActionIcon(
'ID'
,
'select'
, $actionIcon);
245
}
246
247
function
SetMActiveLookupGrid
(
$dbconf
,
$sql
, $columns,
$title
=
'Search'
,
$pageLength
= 15, $indexColumn = 0)
248
{
249
$query = $this->
GetQuery
($dbconf,
$sql
);
250
$this->grid = $this->GetGrid($query, $columns, $this->href,
$pageLength
, $indexColumn);
251
$this->grid->SetLinkType(
'hyperlink'
);
252
$this->grid->SetFullWidth($this->lwidth);
253
$this->grid->SetFullHeight($this->lheight);
254
for
($i = 0; $i < count($query->result[0]); $i++)
255
{
256
if
($i)
257
{
258
$args .=
','
;
259
}
260
261
$args .=
""#$i#""
;
262
}
263
$this->grid->AddActionIcon(
'ID'
,
'select'
,
"javascript:MIOLO_ActiveDeliver('$this->formName', {$indexColumn}, '{$this->event}','{$this->related}', $args)"
);
264
}
265
266
function
SetGrid
(
$dbconf
,
$sql
, $columns,
$title
=
'Search'
,
$pageLength
= 15, $indexColumn = 0)
267
{
268
$method =
"Set"
.
$this->gridClass
;
269
$this->$method(
$dbconf
,
$sql
, $columns,
$title
,
$pageLength
, $indexColumn);
270
}
271
}
272
?>
EDatabaseException
Definição
mexception.class:43
FormButton
Definição
compatibility.class:72
MGrid
Definição
gridcontrols.class:739
MIOLO\getInstance
static getInstance()
Definição
miolo.class:134
MLookup
Definição
mlookup.class:3
MLookup\$labels
$labels
Definição
mlookup.class:7
MLookup\$sql
$sql
Definição
mlookup.class:6
MLookup\setLookupGrid
setLookupGrid($dbconf, $sql, $columns, $title='Search', $pageLength=15, $indexColumn=0)
Definição
mlookup.class:159
MLookup\$formName
$formName
Definição
mlookup.class:8
MLookup\GetFilterValue
GetFilterValue($name='')
Definição
mlookup.class:53
MLookup\$form
$form
Definição
mlookup.class:17
MLookup\$filterValue
$filterValue
Definição
mlookup.class:15
MLookup\setLookupForm
setLookupForm( $title)
Definição
mlookup.class:78
MLookup\SetGrid
SetGrid($dbconf, $sql, $columns, $title='Search', $pageLength=15, $indexColumn=0)
Definição
mlookup.class:266
MLookup\SetMActiveLookupGrid
SetMActiveLookupGrid($dbconf, $sql, $columns, $title='Search', $pageLength=15, $indexColumn=0)
Definição
mlookup.class:247
MLookup\setLookupType
setLookupType( $type='grid')
Definição
mlookup.class:64
MLookup\SetGridClass
SetGridClass($class, $module, $classFile)
Definição
mlookup.class:146
MLookup\addField
addField( $field)
Definição
mlookup.class:114
MLookup\$baseModule
$baseModule
Definição
mlookup.class:23
MLookup\__construct
__construct($baseModule='admin')
Definição
mlookup.class:28
MLookup\$filterColumns
$filterColumns
Definição
mlookup.class:26
MLookup\$grid
$grid
Definição
mlookup.class:21
MLookup\AddFilterField
AddFilterField($field)
Definição
mlookup.class:141
MLookup\$lwidth
$lwidth
Definição
mlookup.class:12
MLookup\setListingTitle
setListingTitle($title)
Definição
mlookup.class:48
MLookup\$pageLength
$pageLength
Definição
mlookup.class:18
MLookup\$lheight
$lheight
Definição
mlookup.class:11
MLookup\setFields
setFields( $fields)
Definição
mlookup.class:119
MLookup\$event
$event
Definição
mlookup.class:14
MLookup\GetQuery
& GetQuery($dbconf, $sql)
Definição
mlookup.class:134
MLookup\$listingTitle
$listingTitle
Definição
mlookup.class:4
MLookup\generate
generate()
Definição
mlookup.class:69
MLookup\$lookupType
$lookupType
Definição
mlookup.class:25
MLookup\$related
$related
Definição
mlookup.class:22
MLookup\$item
$item
Definição
mlookup.class:10
MLookup\$keyColumn
$keyColumn
Definição
mlookup.class:19
MLookup\setFilterColumns
setFilterColumns($countColumns)
Definição
mlookup.class:124
MLookup\GetHRef
GetHRef()
Definição
mlookup.class:129
MLookup\getGrid
getGrid($query, $columns, $href, $pageLength, $indexColumn)
Definição
mlookup.class:154
MLookup\$dbconf
$dbconf
Definição
mlookup.class:5
MLookup\$module
$module
Definição
mlookup.class:9
MLookup\$filterFields
$filterFields
Definição
mlookup.class:16
MLookup\$gridClass
$gridClass
Definição
mlookup.class:24
MLookup\$title
$title
Definição
mlookup.class:20
MLookup\$function
$function
Definição
mlookup.class:13
$MIOLO
$MIOLO
Definição
mdatetimefield.class:25
$url
$url
Definição
base.php:2
classes
ui
mlookup.class
Gerado por
1.10.0