112 include_once (
'Class.Out.php');
113 include_once (
'Class.Table.php');
114 include_once (
'Class.Log.php');
115 include_once (
'Class.QueryDb.php');
129 $this->
init(
"string",
"");
130 $this->
init(
"operator",
"none");
131 $this->
init(
"criteria",
"");
132 $this->
init(
"case",
"");
133 $this->
init(
"order_by",
"");
134 $this->
init(
"casse",
"NON");
135 $this->
init(
"alpha_criteria",
"");
136 $this->
init(
"desc",
"down");
137 $this->
init(
"start", 0);
138 $this->
init(
"slice", 20);
140 $this->table =
new Table();
149 if (($this->display_alpha ==
"TRUE") && ($this->alpha !=
"ALL") && ($this->alpha !=
"NONE")) {
150 $out =
" upper({$this->alpha_criteria}) like upper('{$this->alpha}%') ";
162 function GenPage($url, $nores, $complete =
"FALSE", $display_form =
"YES")
165 $this->
init(
"alpha", $this->alpha_default);
172 $o->cat($this->
GenForm($url, $display_form));
174 if (($this->display_alpha ==
"TRUE") && ($this->alpha ==
"NONE")) {
175 return (
$o->flush());
178 if ($complete ==
"FALSE") {
179 $this->table->array = $this->
Query($this->
start, $this->
slice,
"TABLE");
181 $this->table->array = $this->
Query($this->
start, $this->
slice,
"LISTC");
182 $this->table->arrayobj =
"TRUE";
185 $this->table->sort_link =
"javascript:void(0)\\\" onClick=\\\"SortPage(
186 document.QueryObj,'%s');return false";
187 $this->table->page_link =
"javascript:void(0)\\\" onclick=\\\"GoPage(
188 document.QueryObj,%s,%s);return false";
190 if (!isset($this->table->headcontent[
"$this->order_by"])) {
194 $this->table->headcontent[
"$this->order_by"].= $this->$desc;
196 if ($this->nb == 0) {
199 $o->cat($this->table->get());
202 $o->cat(
'<table border=0 cellspacing=0 cellpadding=0 width="100%">
203 <tr><td class="textinv2">Total : ' . $this->nb .
'</td></tr>
206 return (
$o->flush());
212 if (
sizeof($this->basic_elem->criterias) == 0)
return (
"");
213 $this->log->debug(
"Nouvelle forme");
218 <script language="javascript">
219 function selFiltre(form_cour, champ) {
220 var oper_sel=form_cour.p_operator[form_cour.p_operator.selectedIndex].value;
221 var crit_sel=form_cour.p_criteria[form_cour.p_criteria.selectedIndex].value;
222 var crit_idx=form_cour.p_criteria.selectedIndex;
223 tab_types = new Array();');
227 reset($this->basic_elem->criterias);
228 foreach ($this->basic_elem->criterias as $k => $v) {
229 $o->cat(
"tab_types[{$ind}]=\"" . $v[
"type"] .
"\";");
234 if ((tab_types[crit_idx]=="NUM") && (oper_sel=="nlike")) {
235 alert ("Un champ numérique ne peut-être recherché avec \'Ne Contient Pas\'!!");
236 form_cour.p_operator.options[0].selected=true;
238 if ((tab_types[crit_idx]=="NUM") && (oper_sel=="like")) {
239 alert ("Un champ numérique ne peut-être recherché avec \'Contient\'!!");
240 form_cour.p_operator.options[0].selected=true;
242 if ((crit_sel=="") && (champ.name=="p_criteria")) {
243 form_cour.p_string.value = "";
244 form_cour.p_operator.options[0].selected=true;
249 function checkFiltre(form_cour) {
251 if ($display_form ==
'YES') {
254 var oper_sel=form_cour.p_operator[form_cour.p_operator.selectedIndex].value;
255 var crit_sel=form_cour.p_criteria[form_cour.p_criteria.selectedIndex].value;
256 var casse=form_cour.chk_casse.checked;
258 form_cour.p_casse.value="NON";
260 form_cour.p_casse.value="OUI";
262 if ((crit_sel=="") && (oper_sel!="")) {
264 alert ("Vous devez choisir un critere!!"); }
265 if ((crit_sel!="") && (oper_sel=="")) {
267 alert ("Vous devez choisir un operator!!"); }
272 $o->cat(
' var ok=true; return(ok); }');
276 function queryFiltre(form_cour) {
278 ok = checkFiltre(form_cour);
280 form_cour.p_start.value=0;
285 function resetFiltre(form_cour) {
286 form_cour.p_criteria.selectedIndex=0;
287 form_cour.p_operator.selectedIndex=0;
288 form_cour.p_start.value=0;
289 form_cour.p_string.value="";
293 function GoPage(form_cour,start,slice) {
294 form_cour.p_start.value = start;
295 form_cour.p_slice.value = slice;
296 ok=checkFiltre(form_cour);
297 if (ok) {form_cour.submit();}
300 function SortPage(form_cour,order) {
301 if (form_cour.p_order_by.value == order) {
302 if (form_cour.p_desc.value == "down") {
303 form_cour.p_desc.value = "up";
305 form_cour.p_desc.value = "down";
308 form_cour.p_order_by.value = order;
309 form_cour.p_desc.value = "down";
311 ok=checkFiltre(form_cour);
312 if (ok) {form_cour.submit();}
315 function setAlpha(form_cour,car) {
316 form_cour.p_alpha.value = car;
317 form_cour.p_start.value = 0;
318 ok=checkFiltre(form_cour);
319 if (ok) {form_cour.submit();}
325 <form name="QueryObj" method="POST" action="' . $url .
'">');
326 if ($display_form ==
"YES") {
327 $o->cat(
'<table bgcolor="#F2F2F2" border="0" cellspacing="0" cellpadding="2" >
330 if ($this->display_alpha ==
"TRUE") {
331 $o->cat(
'<td><small><select name="p_alpha_criteria">\n');
332 reset($this->basic_elem->criterias);
333 foreach ($this->basic_elem->criterias as $k => $v) {
334 if ($v[
"type"] ==
"TXT") {
335 if ($this->alpha_criteria == $k) {
336 $o->cat(
"<OPTION SELECTED VALUE=\"{$k}\">" . $v[
"libelle"] .
"\n");
338 $o->cat(
"<OPTION VALUE=\"{$k}\">" . $v[
"libelle"] .
"\n");
342 $o->cat(
'</select></small></td>');
343 $o->cat(
'<td nowrap colspan="3">');
344 for ($i = ord(
"A"); $i <= ord(
"Z"); $i++) {
347 if ($this->alpha ==
$c) {
350 $o->cat(
"<a href=\"javascript:void(0)\"
351 onClick=\"setAlpha(document.QueryObj,'" .
$c .
"');return false\">");
352 $o->cat(
'<font size="-1">' .
$c .
'</font></a>');
353 if ($this->alpha ==
$c) {
357 $o->cat(
"</td><td align=\"center\">");
358 if ($this->alpha ==
"ALL")
$o->cat(
'<b>[');
359 $o->cat(
"<a href=\"javascript:void(0)\"
360 onClick=\"setAlpha(document.QueryObj,'ALL');return false\">");
361 $o->cat(
'<font size="-1">Tout</font></a>');
362 if ($this->alpha ==
"ALL")
$o->cat(
']</b>');
364 if ($this->alpha ==
"NONE") {
367 $o->cat(
"<a href=\"javascript:void(0)\"
368 onClick=\"setAlpha(document.QueryObj,'NONE');return false\">");
369 $o->cat(
"<font size=\"-1\">Rien</font></a>");
370 if ($this->alpha ==
"NONE") {
377 <TD><SMALL><SELECT NAME=\"p_criteria\"
378 onChange=\"selFiltre(document.QueryObj,this);\">\n");
379 reset($this->basic_elem->criterias);
380 foreach ($this->basic_elem->criterias as $k => $v) {
381 if ($this->criteria == $k) {
382 $o->cat(
"<OPTION SELECTED VALUE=\"{$k}\">" . $v[
"libelle"] .
"\n");
384 $o->cat(
"<OPTION VALUE=\"{$k}\">" . $v[
"libelle"] .
"\n");
387 $o->cat(
"</SELECT></SMALL></TD>\n");
390 <TD><SMALL><SELECT NAME=\"p_operator\"
391 onChange=\"selFiltre(document.QueryObj,this);\">\n");
392 foreach ($this->operators as $k => $v) {
393 if ($this->
operator == $k) {
394 $o->cat(
"<OPTION SELECTED VALUE=\"{$k}\">" . $v[
"lib"] .
"\n");
396 $o->cat(
"<OPTION VALUE=\"{$k}\">" . $v[
"lib"] .
"\n");
399 $o->cat(
"</SELECT></SMALL></TD>\n");
402 <td><small><input name="p_string" maxlength=15 size=10 class="finput"
403 value="' . $this->
string .
'">
407 <td><a href="javascript:void(0)"
408 onClick="queryFiltre(document.QueryObj);return false">
409 <font size="-1">Recherche</font></a>
410 <a href="javascript:void(0)"
411 onClick="resetFiltre(document.QueryObj);return false">
412 <font size="-1">Réinitialiser</font></a>
416 <td nowrap><input type="checkbox"');
417 if ($this->casse ==
"OUI") {
418 $o->cat(
' checked ');
420 $o->cat(
'name="chk_casse"><font size="-1">Respecter la casse</font></td>');
426 $o->cat(
'<input type="hidden" name="p_slice" value="' . $this->
slice .
'">
427 <input type="hidden" name="p_start" value="' . $this->
start .
'">
428 <input type="hidden" name="p_order_by" value="' . $this->
order_by .
'">
429 <input type="hidden" name="p_casse" value="' . $this->casse .
'">
430 <input type="hidden" name="p_desc" value="' . $this->desc .
'">
431 <input type="hidden" name="p_alpha" value="' . $this->alpha .
'">
434 return (
$o->flush());
440 if (is_array($_POST) && isset($_POST[
"p_$attr"])) {
441 $this->$attr = $_POST[
"p_$attr"];
443 if (isset($this->basic_elem->def[$attr])) {
444 $this->$attr = $this->basic_elem->def[$attr];
446 $this->$attr = $default;
Query($start=0, $slice=0, $res_type="LIST", $p_query="")
GenForm($url, $display_form="YES")
GenPage($url, $nores, $complete="FALSE", $display_form="YES")
QueryObj($dbaccess, $class)