114 include_once (
'Class.Out.php');
115 include_once (
'Class.Table.php');
116 include_once (
'Class.Log.php');
117 include_once (
'Class.QueryDb.php');
131 $this->
init(
"string",
"");
132 $this->
init(
"operator",
"none");
133 $this->
init(
"criteria",
"");
134 $this->
init(
"case",
"");
135 $this->
init(
"order_by",
"");
136 $this->
init(
"casse",
"NON");
137 $this->
init(
"alpha_criteria",
"");
138 $this->
init(
"desc",
"down");
139 $this->
init(
"start", 0);
140 $this->
init(
"slice", 20);
142 $this->table =
new Table();
151 if (($this->display_alpha ==
"TRUE") && ($this->alpha !=
"ALL") && ($this->alpha !=
"NONE")) {
152 $out =
" upper({$this->alpha_criteria}) like upper('{$this->alpha}%') ";
164 function GenPage($url, $nores, $complete =
"FALSE", $display_form =
"YES")
167 $this->
init(
"alpha", $this->alpha_default);
174 $o->cat($this->
GenForm($url, $display_form));
176 if (($this->display_alpha ==
"TRUE") && ($this->alpha ==
"NONE")) {
177 return (
$o->flush());
180 if ($complete ==
"FALSE") {
181 $this->table->array = $this->
Query($this->
start, $this->
slice,
"TABLE");
183 $this->table->array = $this->
Query($this->
start, $this->
slice,
"LISTC");
184 $this->table->arrayobj =
"TRUE";
187 $this->table->sort_link =
"javascript:void(0)\\\" onClick=\\\"SortPage(
188 document.QueryObj,'%s');return false";
189 $this->table->page_link =
"javascript:void(0)\\\" onclick=\\\"GoPage(
190 document.QueryObj,%s,%s);return false";
192 if (!isset($this->table->headcontent[
"$this->order_by"])) {
196 $this->table->headcontent[
"$this->order_by"].= $this->$desc;
198 if ($this->nb == 0) {
201 $o->cat($this->table->get());
204 $o->cat(
'<table border=0 cellspacing=0 cellpadding=0 width="100%">
205 <tr><td class="textinv2">Total : ' . $this->nb .
'</td></tr>
208 return (
$o->flush());
214 if (
sizeof($this->basic_elem->criterias) == 0)
return (
"");
215 $this->log->debug(
"Nouvelle forme");
220 <script language="javascript">
221 function selFiltre(form_cour, champ) {
222 var oper_sel=form_cour.p_operator[form_cour.p_operator.selectedIndex].value;
223 var crit_sel=form_cour.p_criteria[form_cour.p_criteria.selectedIndex].value;
224 var crit_idx=form_cour.p_criteria.selectedIndex;
225 tab_types = new Array();');
229 reset($this->basic_elem->criterias);
230 while (list($k, $v) = each($this->basic_elem->criterias)) {
231 $o->cat(
"tab_types[{$ind}]=\"" . $v[
"type"] .
"\";");
236 if ((tab_types[crit_idx]=="NUM") && (oper_sel=="nlike")) {
237 alert ("Un champ numérique ne peut-être recherché avec \'Ne Contient Pas\'!!");
238 form_cour.p_operator.options[0].selected=true;
240 if ((tab_types[crit_idx]=="NUM") && (oper_sel=="like")) {
241 alert ("Un champ numérique ne peut-être recherché avec \'Contient\'!!");
242 form_cour.p_operator.options[0].selected=true;
244 if ((crit_sel=="") && (champ.name=="p_criteria")) {
245 form_cour.p_string.value = "";
246 form_cour.p_operator.options[0].selected=true;
251 function checkFiltre(form_cour) {
253 if ($display_form ==
'YES') {
256 var oper_sel=form_cour.p_operator[form_cour.p_operator.selectedIndex].value;
257 var crit_sel=form_cour.p_criteria[form_cour.p_criteria.selectedIndex].value;
258 var casse=form_cour.chk_casse.checked;
260 form_cour.p_casse.value="NON";
262 form_cour.p_casse.value="OUI";
264 if ((crit_sel=="") && (oper_sel!="")) {
266 alert ("Vous devez choisir un critere!!"); }
267 if ((crit_sel!="") && (oper_sel=="")) {
269 alert ("Vous devez choisir un operator!!"); }
274 $o->cat(
' var ok=true; return(ok); }');
278 function queryFiltre(form_cour) {
280 ok = checkFiltre(form_cour);
282 form_cour.p_start.value=0;
287 function resetFiltre(form_cour) {
288 form_cour.p_criteria.selectedIndex=0;
289 form_cour.p_operator.selectedIndex=0;
290 form_cour.p_start.value=0;
291 form_cour.p_string.value="";
295 function GoPage(form_cour,start,slice) {
296 form_cour.p_start.value = start;
297 form_cour.p_slice.value = slice;
298 ok=checkFiltre(form_cour);
299 if (ok) {form_cour.submit();}
302 function SortPage(form_cour,order) {
303 if (form_cour.p_order_by.value == order) {
304 if (form_cour.p_desc.value == "down") {
305 form_cour.p_desc.value = "up";
307 form_cour.p_desc.value = "down";
310 form_cour.p_order_by.value = order;
311 form_cour.p_desc.value = "down";
313 ok=checkFiltre(form_cour);
314 if (ok) {form_cour.submit();}
317 function setAlpha(form_cour,car) {
318 form_cour.p_alpha.value = car;
319 form_cour.p_start.value = 0;
320 ok=checkFiltre(form_cour);
321 if (ok) {form_cour.submit();}
327 <form name="QueryObj" method="POST" action="' . $url .
'">');
328 if ($display_form ==
"YES") {
329 $o->cat(
'<table bgcolor="#F2F2F2" border="0" cellspacing="0" cellpadding="2" >
332 if ($this->display_alpha ==
"TRUE") {
333 $o->cat(
'<td><small><select name="p_alpha_criteria">\n');
334 reset($this->basic_elem->criterias);
335 while (list($k, $v) = each($this->basic_elem->criterias)) {
336 if ($v[
"type"] ==
"TXT") {
337 if ($this->alpha_criteria == $k) {
338 $o->cat(
"<OPTION SELECTED VALUE=\"{$k}\">" . $v[
"libelle"] .
"\n");
340 $o->cat(
"<OPTION VALUE=\"{$k}\">" . $v[
"libelle"] .
"\n");
344 $o->cat(
'</select></small></td>');
345 $o->cat(
'<td nowrap colspan="3">');
346 for ($i = ord(
"A"); $i <= ord(
"Z"); $i++) {
349 if ($this->alpha ==
$c) {
352 $o->cat(
"<a href=\"javascript:void(0)\"
353 onClick=\"setAlpha(document.QueryObj,'" .
$c .
"');return false\">");
354 $o->cat(
'<font size="-1">' .
$c .
'</font></a>');
355 if ($this->alpha ==
$c) {
359 $o->cat(
"</td><td align=\"center\">");
360 if ($this->alpha ==
"ALL")
$o->cat(
'<b>[');
361 $o->cat(
"<a href=\"javascript:void(0)\"
362 onClick=\"setAlpha(document.QueryObj,'ALL');return false\">");
363 $o->cat(
'<font size="-1">Tout</font></a>');
364 if ($this->alpha ==
"ALL")
$o->cat(
']</b>');
366 if ($this->alpha ==
"NONE") {
369 $o->cat(
"<a href=\"javascript:void(0)\"
370 onClick=\"setAlpha(document.QueryObj,'NONE');return false\">");
371 $o->cat(
"<font size=\"-1\">Rien</font></a>");
372 if ($this->alpha ==
"NONE") {
379 <TD><SMALL><SELECT NAME=\"p_criteria\"
380 onChange=\"selFiltre(document.QueryObj,this);\">\n");
381 reset($this->basic_elem->criterias);
382 while (list($k, $v) = each($this->basic_elem->criterias)) {
383 if ($this->criteria == $k) {
384 $o->cat(
"<OPTION SELECTED VALUE=\"{$k}\">" . $v[
"libelle"] .
"\n");
386 $o->cat(
"<OPTION VALUE=\"{$k}\">" . $v[
"libelle"] .
"\n");
389 $o->cat(
"</SELECT></SMALL></TD>\n");
392 <TD><SMALL><SELECT NAME=\"p_operator\"
393 onChange=\"selFiltre(document.QueryObj,this);\">\n");
394 while (list($k, $v) = each($this->operators)) {
395 if ($this->
operator == $k) {
396 $o->cat(
"<OPTION SELECTED VALUE=\"{$k}\">" . $v[
"lib"] .
"\n");
398 $o->cat(
"<OPTION VALUE=\"{$k}\">" . $v[
"lib"] .
"\n");
401 $o->cat(
"</SELECT></SMALL></TD>\n");
404 <td><small><input name="p_string" maxlength=15 size=10 class="finput"
405 value="' . $this->
string .
'">
409 <td><a href="javascript:void(0)"
410 onClick="queryFiltre(document.QueryObj);return false">
411 <font size="-1">Recherche</font></a>
412 <a href="javascript:void(0)"
413 onClick="resetFiltre(document.QueryObj);return false">
414 <font size="-1">Réinitialiser</font></a>
418 <td nowrap><input type="checkbox"');
419 if ($this->casse ==
"OUI") {
420 $o->cat(
' checked ');
422 $o->cat(
'name="chk_casse"><font size="-1">Respecter la casse</font></td>');
428 $o->cat(
'<input type="hidden" name="p_slice" value="' . $this->
slice .
'">
429 <input type="hidden" name="p_start" value="' . $this->
start .
'">
430 <input type="hidden" name="p_order_by" value="' . $this->
order_by .
'">
431 <input type="hidden" name="p_casse" value="' . $this->casse .
'">
432 <input type="hidden" name="p_desc" value="' . $this->desc .
'">
433 <input type="hidden" name="p_alpha" value="' . $this->alpha .
'">
436 return (
$o->flush());
442 if (is_array($_POST) && isset($_POST[
"p_$attr"])) {
443 $this->$attr = $_POST[
"p_$attr"];
445 if (isset($this->basic_elem->def[$attr])) {
446 $this->$attr = $this->basic_elem->def[$attr];
448 $this->$attr = $default;