backoffice/html/gestion/list.php

729 lines
37 KiB
PHP
Raw Permalink Normal View History

2011-06-21 15:28:10 +02:00
<?php
//print_r($_POST);die();
if (!isset($page))
$page=str_replace('.php', '', basename(__FILE__));
include_once('tables.php');
require_once('qs_functions.php');
require_once('default.php');
echo "<!--\n_SESSION\n";
print_r($_SESSION);
echo "_SERVER\n";
print_r($_SERVER);
echo "_REQUEST\n";
print_r($_REQUEST);
echo "-->\n";
if (!isset($titre))
$titre='Liste des '.$table;
$nbLignesParPage = 30;
mysql_query('SET CHARACTER SET utf8;');
$query="$sql $sql_ext limit 0,1";
//echo $query.'<br/>';
if(!$result = @mysql_query($query)){
$err_string .= "<strong>Error:</strong>while connecting to database<br>" . mysql_error();
}
if ($err_string != "") {
print "<Center><Table Border=\"0\" Cellspacing=\"1\" bgcolor=\"#CCCCCC\" >";
print "<tr>";
print "<td height=\"80\" align=\"Default\" bgcolor=\"#FFFFFF\">";
print "<font color=\"#000099\" size=\"2\">";
print $err_string;
print "</font>";
print "</td>";
print "</tr>";
print "</Table></Center>";
exit;
} //==end if $err_string != ""
if (qsrequest("clearsession") == '1') {
$_SESSION[$sessionPage."_page"] = '';
$_SESSION[$sessionPage."_sortfield"] = '';
$_SESSION[$sessionPage."_sortby"] = '';
} //==end if clearsession
$filter_string = '';
$filter_stringmaster = '';
$qry_string = '';
$i = 0;
$searchendkey ='';
$searchstartkey = '';
while ($i < mysql_num_fields($result)) {
$meta = mysql_fetch_field($result);
$field_name = $meta->name;
$field_table = $meta->table;
$field_type = $meta->type;
$type_field = "";
$type_field = returntype($field_type);
if (($searchmode[$i])==0) { # 0 = Std, 1 = Advance
if (($stdsearchopt[$i])==0) { //==0=Contain , 1 = Equal : for standard mode
$searchstartkey = "%";
$searchendkey = "%";
} else {
$searchstartkey = "";
$searchendkey = "";
}
} else { //==end if searchmode = 0
$searchstartkey= "";
$searchendkey = "";
} //==end if searchmode <> 0
if (qsrequest("clearsession") == "1") {
$_SESSION[$sessionPage."_search_fd" . $i] = "";
$_SESSION[$sessionPage."_multisearch_fd" . $i] = "";
$_SESSION[$sessionPage."_search_fd_" . $i] = "";
} //==end if clearsession
if (qsrequest("search_fd" . $i) != "") {
$_SESSION[$sessionPage."_search_fd" . $i] = qsrequest("search_fd" . $i);
}
if (qsrequest("search_fd" . $i) != "") {
$_SESSION[$sessionPage."_multisearch_fd" . $i] = qsrequest("multisearch_fd" . $i);
}
if (qsrequest("search_fd" . $i) != "") {
$_SESSION[$sessionPage."_search_fd_" . $i] = qsrequest("search_fd_" . $i);
}
if ((qssession($sessionPage."_search_fd" . $i) != "") && (qssession($sessionPage."_search_fd" . $i) != "*")) {
$idata = qssession($sessionPage."_search_fd" . $i);
$icon = " AND ";
$ioldcon = "";
if (substr($idata, 0, 2) == "||") {
$icon = " Or ";
$ioldcon = "||";
$iopt = substr($idata, 2, 2);
$idata = substr($idata, 2);
}else{
$iopt = substr($idata, 0, 2);
}
$idata = str_replace("*", "%", $idata);
$irealdata = $idata;
$iopt = substr($idata, 0, 2);
if (($iopt == "<=") || ($iopt == "=<")) {
$iopt = "<=";
$irealdata = substr($idata, 2);
} elseif (($iopt == ">=") || ($iopt == "=>")) {
$iopt = ">=";
$irealdata = substr($idata, 2);
} elseif ($iopt == "==") {
$iopt = "=";
$irealdata = substr($idata, 2);
} elseif ($iopt == "<>") {
$irealdata = substr($idata, 2);
} else {
$iopt = substr($idata, 0, 1);
if (($iopt == "<") || ($iopt == ">") || ($iopt == "=")) {
$irealdata = substr($idata,1);
} else {
$iopt = "=";
}
}
if (!strcasecmp($idata,"{current date and time}")) {
$idata = time();
} elseif (!strcasecmp($idata,"{current date}")) {
$idata = time();
} elseif (!strcasecmp($idata,"{current time}")) {
$idata = time();
}
if ($meta) {
if ($type_field == "type_datetime") {
/** @todo ne g<>re pas les dates anglaises ainsi que les heures minutes sec **/
$tmp=explode('/',$idata);//12/08/1977
$idata=$tmp[2].'-'.$tmp[1].'-'.$tmp[0];
$irealdata=$idata;
if ((($timestamp = strtotime($irealdata)) !== -1)) {
if (($iopt)=="="){
$conditionstr = " = ";
$istrdata = str_replace("=", "", $istrdata);
} else {
$conditionstr = $iopt;
$istrdata = $irealdata;
$searchstartkey = "";
$searchendkey = "";
}
if ((qssession($sessionPage."_multisearch_fd" . $i) != "")) {
$multisearch = qssession($sessionPage."_multisearch_fd" . $i);
$searcharray = split(",",$multisearch);
if ($qry_string == "") {
$qry_string = "search_fd" . $i . "=" . $ioldcon . urlencode(stripslashes($idata));
$qry_string .= "&multisearch_fd" . $i . "=" . qssession($sessionPage."_multisearch_fd" . $i);
$filter_string = '(DATE_FORMAT(' . $fields[$i] .", '%Y-%m-%d')". $conditionstr . " ". $quotedate . $irealdata . $quotedate;
$j = 0;
for ($j = 0; $j < count($searcharray); $j++) {
$searchindex = $searcharray[$j];
$filter_string .= " OR " . $fields[$searchindex] . $conditionstr . " ". $quotedate . $irealdata . $quotedate;
}
$filter_string .= ")";
} else {
$qry_string .= "&search_fd" . $i . "=" . $ioldcon . urlencode(stripslashes($idata));
$qry_string .= "&multisearch_fd" . $i . "=" . qssession($sessionPage."_multisearch_fd" . $i);
$filter_string .= ' AND (DATE_FORMAT(' . $fields[$i] .", '%Y-%m-%d')". $conditionstr .' '. $quotedate . $irealdata . $quotedate;
$j = 0;
for ($j = 0; $j < count($searcharray); $j++) {
$searchindex = $searcharray[$j];
$filter_string .= " OR " . $fields[$searchindex] . $conditionstr . " " . $quotedate . $irealdata . $quotedate;
}
$filter_string .= ")";
}
} else {
echo 'ici';
if ($qry_string == "") {
$qry_string = "search_fd" . $i . "=" . $ioldcon . urlencode(stripslashes($idata));
$filter_string = 'DATE_FORMAT(' . $fields[$i] .", '%Y-%m-%d')". $conditionstr . " " . $quotedate . $irealdata . $quotedate;
if ($parammaster[$i] != ""){
$filter_stringmaster = $parammaster[$i] . $conditionstr . " " . $quotedate . $irealdata . $quotedate;
}
} else {
$qry_string .= "&search_fd" . $i . "=" . $ioldcon . urlencode(stripslashes($idata));
$filter_string .= $icon .'DATE_FORMAT('. $fields[$i] .", '%Y-%m-%d')". $conditionstr . " " . $quotedate . $irealdata . $quotedate;
if ($parammaster[$i] != ""){
$filter_stringmaster .= $icon . $parammaster[$i] . $conditionstr . " " . $quotedate . $irealdata . $quotedate;
}
}
}
} else {
$err_string .= "<strong>Error:</strong>while searching.<strong>" . $field_name . "</strong>.<br>";
$err_string .= "Description: Invalid DateTime.<br>";
}
//==end $type_field == "type_datetime"
} elseif ($type_field == "type_integer") {
$irealdata = str_replace("%", "", $irealdata);
if (is_numeric($irealdata)) {
if ((qssession($sessionPage."_multisearch_fd" . $i) != "")) {
$multisearch = qssession($sessionPage."_multisearch_fd" . $i);
$searcharray = split(",",$multisearch);
if ($qry_string == "") {
$qry_string = "search_fd" . $i . "=" . $ioldcon . $idata;
$qry_string .= "&multisearch_fd" . $i . "=" . qssession($sessionPage."_multisearch_fd" . $i);
$filter_string = "(" . $fields[$i] . " " . $iopt . " " . $irealdata;
$j = 0;
for ($j = 0; $j < count($searcharray); $j++) {
$searchindex = $searcharray[$j];
$filter_string .= " OR " . $fields[$searchindex] . " " . $iopt . " " . $irealdata;
}
$filter_string .= ")";
} else {
$qry_string .= "&search_fd" . $i . "=" . $ioldcon . $idata;
$qry_string .= "&multisearch_fd" . $i . "=" . qssession($sessionPage."_multisearch_fd" . $i);
$filter_string .= " AND (" . $fields[$i] . " " . $iopt . " " . $irealdata;
$j = 0;
for ($j = 0; $j < count($searcharray); $j++) {
$searchindex = $searcharray[$j];
$filter_string .= " OR " . $fields[$searchindex] . " " . $iopt . " " . $irealdata;
}
$filter_string .= ")";
}
} else {
if ($qry_string == "") {
$qry_string = "search_fd" . $i . "=" . $ioldcon . $idata;
$filter_string = $fields[$i] . " " . $iopt . " " . $irealdata;
if ($parammaster[$i] != ""){
$filter_stringmaster = $parammaster[$i] . " " . $iopt . " " . $irealdata;
}
} else {
$qry_string .= "&search_fd" . $i . "=" . $ioldcon . $idata;
$filter_string .= $icon . $fields[$i] . " " . $iopt . " " . $irealdata;
if ($parammaster[$i] != ""){
$filter_stringmaster .= $icon . $parammaster[$i] . " " . $iopt . " " . $irealdata;
}
}
}
} else {
$err_string .= "<strong>Error:</strong>while searching.<strong>" . $field_name . "</strong>.<br>";
$err_string .= "Description: Type mismatch.<br>";
}
//==end $type_field == "type_integer"
} elseif ($type_field == "type_string") {
if (($iopt)=="="){
$conditionstr = " LIKE ";
$istrdata = str_replace("=", "", $istrdata);
} else {
$conditionstr = $iopt;
$istrdata = $irealdata;
$searchstartkey = "";
$searchendkey = "";
}
if ((qssession($sessionPage."_multisearch_fd" . $i) != "")) {
$multisearch = qssession($sessionPage."_multisearch_fd" . $i);
$searcharray = split(",",$multisearch);
if ($qry_string == "") {
$qry_string = "search_fd" . $i . "=" . $ioldcon . urlencode(stripslashes($idata));
$qry_string .= "&multisearch_fd" . $i . "=" . qssession($sessionPage."_multisearch_fd" . $i);
$filter_string = "(" . $fields[$i] . $conditionstr . " '" .$searchstartkey. ereg_replace("'","''",stripslashes($irealdata)). $searchendkey . "'";
$j = 0;
for ($j = 0; $j < count($searcharray); $j++) {
$searchindex = $searcharray[$j];
$filter_string .= " OR " . $fields[$searchindex] . $conditionstr . " '" .$searchstartkey. ereg_replace("'","''",stripslashes($irealdata)). $searchendkey . "'";
}
$filter_string .= ")";
} else {
$qry_string .= "&search_fd" . $i . "=" . $ioldcon . urlencode(stripslashes($idata));
$qry_string .= "&multisearch_fd" . $i . "=" . qssession($sessionPage."_multisearch_fd" . $i);
$filter_string .= " AND (" . $fields[$i] . $conditionstr . " '" .$searchstartkey. ereg_replace("'","''",stripslashes($irealdata)) . $searchendkey . "'";
$j = 0;
for ($j = 0; $j < count($searcharray); $j++) {
$searchindex = $searcharray[$j];
$filter_string .= " OR " . $fields[$searchindex] . $conditionstr . " '" .$searchstartkey. ereg_replace("'","''",stripslashes($irealdata)) . $searchendkey . "'";
}
$filter_string .= ")";
}
} else {
if ($qry_string == "") {
$qry_string = "search_fd" . $i . "=" . $ioldcon . urlencode(stripslashes($idata));
$filter_string = $fields[$i] . $conditionstr . " '" .$searchstartkey. ereg_replace("'","''",stripslashes($irealdata)) . $searchendkey . "'";
if ($parammaster[$i] != ""){
$filter_stringmaster = $parammaster[$i] . $conditionstr . " '" .$searchstartkey. ereg_replace("'","''",stripslashes($irealdata)) . $searchendkey . "'";
}
} else {
$qry_string .= "&search_fd" . $i . "=" . $ioldcon . urlencode(stripslashes($idata));
$filter_string .= $icon . $fields[$i] . $conditionstr . " '" .$searchstartkey. ereg_replace("'","''",stripslashes($irealdata)) . $searchendkey . "'";
if ($parammaster[$i] != ""){
$filter_stringmaster .= $icon . $parammaster[$i] . $conditionstr . " '" .$searchstartkey. ereg_replace("'","''",stripslashes($irealdata)) . $searchendkey . "'";
}
}
}
//==end $type_field == "type_string"
} else {
if ((qssession($sessionPage."_multisearch_fd" . $i) != "")) {
$multisearch = qssession($sessionPage."_multisearch_fd" . $i);
$searcharray = split(",",$multisearch);
$irealdata = str_replace("%", "", $irealdata);
if ($qry_string == "") {
$qry_string = "search_fd" . $i . "=" . $ioldcon . urlencode(stripslashes($idata));
$qry_string .= "&multisearch_fd" . $i . "=" . qssession($sessionPage."_multisearch_fd" . $i);
$filter_string = "(" . $fields[$i] . " = '" . ereg_replace("'","''",stripslashes($irealdata)) . "'";
$j = 0;
for ($j = 0; $j < count($searcharray); $j++) {
$searchindex = $searcharray[$j];
$filter_string .= " OR " . $fields[$searchindex] . " = '" . ereg_replace("'","''",stripslashes($irealdata)) . "'";
}
$filter_string .= ")";
} else {
$qry_string .= "&search_fd" . $i . "=" . $ioldcon . urlencode(stripslashes($idata));
$qry_string .= "&multisearch_fd" . $i . "=" . qssession($sessionPage."_multisearch_fd" . $i);
$filter_string .= " AND (" . $fields[$i] . " = '" . ereg_replace("'","''",stripslashes($irealdata)) . "'";
$j = 0;
for ($j = 0; $j < count($searcharray); $j++) {
$searchindex = $searcharray[$j];
$filter_string .= " OR " . $fields[$searchindex] . " = '" . ereg_replace("'","''",stripslashes($irealdata)) . "'";
}
$filter_string .= ")";
}
} else {
if ($qry_string == "") {
$qry_string = "search_fd" . $i . "=" . $ioldcon . urlencode(stripslashes($idata));
$filter_string = $fields[$i] . " like '" . ereg_replace("'","''",stripslashes($irealdata)) . "'";
if ($parammaster[$i] != ""){
$filter_stringmaster = $parammaster[$i] . " like '" . ereg_replace("'","''",stripslashes($irealdata)) . "'";
}
} else {
$qry_string .= "&search_fd" . $i . "=" . $ioldcon . urlencode(stripslashes($idata));
$filter_string .= $icon . $fields[$i] . " like '" . ereg_replace("'","''",stripslashes($irealdata)) . "'";
if ($parammaster[$i] != ""){
$filter_stringmaster .= $icon . $parammaster[$i] . " like '" . ereg_replace("'","''",stripslashes($irealdata)) . "'";
}
}
}
} //==end $type_field == "type_unknown
} //==end if ($meta)
} //==end if search_fd(n) <> ""
//==Begin Search between
if (qssession($sessionPage."_search_fd_" . $i)) {
$idata = qssession($sessionPage."_search_fd_" . $i);
$idata = str_replace("*", "%", $idata);
$irealdata = $idata;
$iopt = substr($idata, 0, 2);
if (($iopt == "<=") || ($iopt == "=<")) {
$iopt = "<=";
$irealdata = substr($idata, 2);
} elseif (($iopt == ">=") || ($iopt == "=>")) {
$iopt = ">=";
$irealdata = substr($idata, 2);
} elseif ($iopt == "==") {
$iopt = "=";
$irealdata = substr($idata, 2);
} elseif ($iopt == "<>") {
$irealdata = substr($idata, 2);
} else {
$iopt = substr($idata, 0, 1);
if (($iopt == "<") || ($iopt == ">") || ($iopt == "=")) {
$irealdata = substr($idata,1);
} else {
$iopt = "=";
}
}
if ($meta) {
if ($type_field == "type_datetime") {
if ((($timestamp = strtotime($irealdata)) !== -1)) {
if (($iopt)=="="){
$conditionstr = " = ";
$istrdata = str_replace("=", "", $istrdata);
} else {
$conditionstr = $iopt;
$istrdata = $irealdata;
$searchstartkey = "";
$searchendkey = "";
}
}
if ($qry_string == "") {
$qry_string = "search_fd_" . $i . "=" . $iopt . urlencode(stripslashes($irealdata));
$filter_string = $fields[$i] . $conditionstr . " " . $quotedate .$searchstartkey . $irealdata . $searchendkey . $quotedate;
} else {
$qry_string .= "&search_fd_" . $i . "=" . $iopt . urlencode(stripslashes($irealdata));
$filter_string .= " AND " . $fields[$i] . $conditionstr . " " . $quotedate . $searchstartkey . $irealdata . $searchendkey . $quotedate;
}
//==end $type_field == "type_datetime"
} elseif ($type_field == "type_integer") {
$irealdata = str_replace("%", "", $irealdata);
if (is_numeric($irealdata)) {
if ($qry_string == "") {
$qry_string = "search_fd_" . $i . "=" . $iopt . $irealdata;
$filter_string = $fields[$i] . " " . $iopt . " " . $irealdata;
} else {
$qry_string .= "&search_fd_" . $i . "=" . $iopt . $irealdata;
$filter_string .= " AND " . $fields[$i] . " " . $iopt . " " . $irealdata;
}
} else {
$err_string .= "<strong>Error:</strong>while searching.<strong>" . $field_name . "</strong>.<br>";
$err_string .= "Description: Type mismatch.<br>";
}
} //==end $type_field == "type_integer"
} //==end if ($meta)
} //==end if search_fd_(n) <> "" for between search
$i++;
} //==end while loop field index
if ($result > 0) {mysql_free_result($result);}
if ($filter_string != "") {
$filter_string = "(" . $filter_string . ")";
if (strpos(strtoupper($sql), "WHERE")) {
$sql .= " AND " . $filter_string;
}else{
$sql .= " WHERE " . $filter_string;
}
}
$n = 0;
if (qssession($sessionPage."_page") != "") {
$parampage = explode("||", qssession($sessionPage."_page"));
$n = count($parampage);
}
$current_page = 1;
if ($n > 0) {
if ($parampage[0] != "") {
$current_page = $parampage[0];
}
if ($parampage[1] != "") {
$nbLignesParPage = $parampage[1];
}
}
if (qsrequest("page")<>"") {
$current_page = qsrequest("page");
}
if (qsrequest("page_size")<>"") {
if(qsrequest("page_size") != $nbLignesParPage) {
$current_page = 1;
}
$nbLignesParPage = qsrequest("page_size");
}
$sessionPage=$database.'_'.$table;
$_SESSION[$sessionPage."_page"] = $current_page . "||" . $nbLignesParPage;
if (qsrequest("sortfield") != "") {
$_SESSION[$sessionPage."_sortfield"] = qsrequest("sortfield");
}
if (qsrequest("sortby") != "") {
$_SESSION[$sessionPage."_sortby"] = qsrequest("sortby");
}
if (qssession($sessionPage."_sortfield")) {
//print_r($_SESSION);die();
$sql = $sql . " ORDER BY " . stripslashes(qssession($sessionPage."_sortfield")) . " " . stripslashes(qssession($sessionPage."_sortby"));
$sortstring = "&sortfield=" . qssession($sessionPage."_sortfield") . "&sortby=" . qssession($sessionPage."_sortby");
} else {
$sql = $sql . " " . $sql_ext;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr" dir="ltr">
<head>
<!--<link rel="icon" href="./favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />-->
<title><?=htmlentities($titre)?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../nonimg/gestion.css">
</head>
<body>
<SCRIPT language=JavaScript>
function cell_over(cell, classname) {
if (document.all || document.getElementById) {
cell.classBackup = cell.className;
cell.className = classname;
}
}
function cell_out(cell)
{
if (document.all || document.getElementById) {
cell.className = cell.classBackup;
}
}
</SCRIPT>
<Center>
<center><strong><font size="5"><?=htmlentities($titre)?></font></strong></center><br>
<a name="top"></a>
<?php
echo '<!--'.EOL.'$sql="'.$sql.'"-->'.EOL;
$sql_count=preg_replace('/^SELECT (.*) FROM /', 'SELECT COUNT(*) FROM ', $sql);
//echo '$sql_count="'.$sql_count.'"<br/>';
$result = mysql_query($sql_count)
or die("Invalid query : $sql_count\n" . mysql_error() );
$row = mysql_fetch_row($result);
$num_rows = $row[0];
//die($num_rows);
$page_count = ceil($num_rows/$nbLignesParPage);
if ($current_page > $page_count) { $current_page = 1; }
if ($current_page < 1) { $current_page = 1; }
if ($page_count < 1) { $page_count = 1; }
if ($filter_string !=""){
echo '<b>Recherche : </b>';
foreach ($fields as $k=>$searchFd) {
if (qsrequest('search_fd'.$k))
echo htmlentities($champ[$k]['libelleColonne']).' = '.qsrequest('search_fd'.$k).', ';
}
print '<h4>Nombre d\'enregistrements correspondants &agrave; votre recherche : '.$num_rows.'</h4>';//.$filter_string;
// echo '<br/>';
}
if ($qry_string != "") {
$navqry_string = "&" . $qry_string;
} else {
$navqry_string = "";
}
$limDeb=($current_page-1)*$nbLignesParPage;
$sql_select_limit=$sql . " LIMIT $limDeb,$nbLignesParPage";
$result = mysql_query($sql_select_limit)
or die("Invalid query $sql_select_limit<br/>\n" . mysql_error() );
?>
<table height="30" border="0" align="center" cellpadding="0" cellspacing="0">
<tr align="center" valign="middle">
<td width="35" align="center"><A HREF="index.php"><img src="../images/bt_controlpanel.gif" border="0" align="absmiddle" title="Retour &agrave; la gestion"></a></td><td width="12" align="center"><img src="../images/bt_qsbetween.gif" border="0"></td>
<td width="35" align="center"><A HREF="mandataires_control_panel.html"><img src="../images/bt_controlpanelgroup.gif" border="0" align="absmiddle" title="Retour au panneau de contr&ocirc;le"></a></td><td width="12" align="center"><img src="../images/bt_qsbetween.gif" border="0"></td>
<form action="list.php" method="post" name="QSSelectPage">
<td width="35" align="center"><A HREF="list.php?clearsession=1"><img src="../images/bt_qsshowall.gif" border="0" align="absmiddle" title="Supprimer le(s) filtre(s)"></a></td><td width="8"></td>
<td width="35" align="center"><A HREF="search.php?<?=$qry_string?>"><img src="../images/bt_qssearch.gif" border="0" align="absmiddle" title="Rechercher"></a></td><td width="8"></td>
<td width="35" align="center"><A HREF="add.php?<?=$qry_string?>"><img src="../images/bt_qsadd_new.gif" border="0" align="absmiddle" title="Ajouter"></a></td><td width="12" align="center"><img src="../images/bt_qsbetween.gif" border="0"></td>
<?php
if ($current_page > 1) {
print '<td width="35" align="center"><a href="list.php?page=1"><img src="../images/bt_qsfirst.gif" border="0" align="absmiddle" title="Premi&egrave;re page"></a></td><td width="8"></td>';
print '<td width="35" align="center"><a href="list.php?page='.($current_page-1).'"><img src="../images/bt_qsback.gif" border="0" align="absmiddle" title="Page pr&eacute;c&eacute;dente"></a></td><td width="8"></td>';
} else {
print '<td width="35" align="center"><img src="../images/bt_qsfirst_inact.gif" border="0" align="absmiddle" title="Premi&egrave;re page"></a></td><td width="8"></td>';
print '<td width="35" align="center"><img src="../images/bt_qsback_inact.gif" border="0" align="absmiddle" title="Page pr&eacute;c&eacute;dente"></a></td><td width="8"></td>';
}
print "<td width=\"35\" align=\"center\"><select name=\"page\" onChange=\"window.location='list.php?page=' + this.value; \">";
for ($i=1; $i<=$page_count; $i++) {
$iDeb=$current_page-10;
$iFin=$current_page+10;
if ($i==1 || ($i>$iDeb && $i<$iFin)) {
?>
<option value="<?=$i?>" <?if($i==$current_page) echo 'selected';?>><?=$i?></option>
<?php
}
}
print '</select></td><td width="8"></td>';
if ($current_page < $page_count) {
print '<td width="35" align="center"><a href="list.php?page='.($current_page+1).'"><img src="../images/bt_qsnext.gif" border="0" align="absmiddle" title="Page suivante"></a></td><td width="8"></td>';
print '<td width="35" align="center"><a href="list.php?page='.$page_count.'"><img src="../images/bt_qslast.gif" border="0" align="absmiddle" title="Derni&egrave;re page"></a></td><td width="8"></td>';
} else {
print '<td width="35" align="center"><img src="../images/bt_qsnext_inact.gif" border="0" align="absmiddle" title="Page suivante"></td><td width="8"></td>';
print '<td width="35" align="center"><img src="../images/bt_qslast_inact.gif" border="0" align="absmiddle" title="Derni&egrave;re page"></td><td width="8"></td>';
}
?>
<td width="35" align="center"><a href="#bottom"><img src="../images/bt_qsbottom.gif" border="0" align="absmiddle" title="Atteindre le bas de la page"></a></td><td width="8"></td>
</form>
</tr>
</table>
<br/>
<?php
if ($num_rows > 0) {
?>
<table border="0" cellpadding="2" cellspacing="1" bgcolor="#177AE9">
<tr>
<td class="ThRows">&nbsp;</td>
<?php
foreach ($champ as $i=>$field) {
if (!$field['hidden'])
{
$nextsortasc = qssortasc(qssession($sessionPage."_sortfield"), $fields[$i], qssession($sessionPage."_sortby"), "Tri croissant");
$nextsortdesc = qssortdesc(qssession($sessionPage."_sortfield"), $fields[$i], qssession($sessionPage."_sortby"), "Tri d<>croissant");
?>
<td class="ThRows" NOWRAP ><a href="list.php?sortfield=<?php print urlencode(stripslashes($fields[$i]));?>&sortby=ASC<?php print $navqry_string; ?>"><?php print $nextsortasc; ?></a>
&nbsp;<?=htmlentities($field['libelleColonne'])?>&nbsp;
<a href="list.php?sortfield=<?php print urlencode(stripslashes($fields[$i]));?>&sortby=DESC<?php print $navqry_string; ?>"><?php print $nextsortdesc; ?></a></td>
<?php
}
}
// Bouton SUPPRIMER
if (isset($tablesInfo[$dbtable]['table_readOnly']) && !$tablesInfo[$dbtable]['table_readOnly'])
echo '<td class="ThRows" >Delete</td>';
?>
</tr>
<?php
$rowcount = 0;
/*$current_row = ($current_page - 1)*$nbLignesParPage+1;
if (($num_rows >= $limDeb) && ($current_row < $limDeb+$nbLignesParPage)) {
mysql_data_seek($result, $current_row);
}*/
while (($row = mysql_fetch_array($result)) && ($rowcount < $nbLignesParPage)) {
if (($rowcount%2) == 0) {
$css_class = 'TrOdd';
} else {
$css_class = 'TrRows';
}
// D<>but de la ligne
print '<tr class="'.$css_class.'" onmouseover="cell_over(this, \'TrHover\')" onmouseout="cell_out(this)">';
$cellvalue = '<img src="../images/bt_edit.gif" border="0" title="D&eacute;tail" onerror="this.onerror=null;this.src=\'../images/qs_nopicture.gif\';">';
// Bouton EDITER
print '<td align="center">';
// On g<>n<EFBFBD>re l'URL d'acc<63>s <20> la visu en r<>cup<75>rant les ck<63>s primaires de la table !
$strKeys='';
foreach ($primary_keys as $nomKey=>$numKey) {
$strKeys.='currentrow_fd'.$numKey.'='.urlencode($row[$numKey]).'&';
}
print '<a name="row'.$rowcount.'" href="./view.php?'.$strKeys.'referer=list.'.$current_page.'.'.$rowcount.'">'.$cellvalue.'</a>';
print '</td>';
// Boucle sur les zones
foreach ($champ as $i=>$field) {
if (!$field['hidden'])
{
$align=$field['align'];
if ($formatdate[$i]<>'')
$cellvalue = qsconvertdate($row[$i],"dd/mm/yyyy");
else
$cellvalue = $row[$i];
if ($cellvalue != "") {
if (isset($champ[$i]['libs']['table'])){
$libs=$champ[$i]['libs'];
$tmp=str_replace(';',',',"'$cellvalue'");
if (substr($tmp,-1)==',') $tmp=substr($tmp,0, -1);
$cellvalue =str_replace(array("\n\r","\r\n","\n","\r"),"<br>",qsmysqlgen_listvisu('SELECT '.$libs['key'].', '.$libs['lib'].' FROM '.$libs['table'].' WHERE '.$libs['key'].' IN ('.$tmp.')',
'edit_fd'.$i, $libs['key'], $libs['lib'],$cellvalue));
}
else
$cellvalue = str_replace(array("\n\r","\r\n","\n","\r"),"<br>",$cellvalue);
}
else {
$cellvalue = "&nbsp;";
}
print "<td align=$align>";
print $cellvalue;
print "</td>";
}
}
// Bouton SUPPRIMER
if (isset($tablesInfo[$dbtable]['table_readOnly']) && !$tablesInfo[$dbtable]['table_readOnly'])
{
$cellvalue = "<img src=\"" . "../images/bt_delete.gif" . "\" border=\"0\" title=\"Delete\" onerror=\"this.onerror=null;this.src='../images/qs_nopicture.gif';\" >";
if ($cellvalue != "") {
$cellvalue = str_replace(array("\n\r","\r\n","\n","\r"),"<br>",$cellvalue);
}
else {
$cellvalue = "&nbsp;";
}
print "<td align=Center >";
print "<a href=\"" . "./supprime.php?" . ""."currentrow_fd0=" . urlencode($row[0]) . "" . "\" >" . $cellvalue . "</a>";
print "</td>";
}
print "</tr>";
$rowcount = $rowcount + 1;
//$cellvalue = "" . number_format($row[8],0,".",",") . "";
// print "<td align=Right >";
// $cellvalue = "" . qsconvertdate($row[21],"mm/dd/yyyy") . "";
}//end while
?>
</Table><br>
<?
}else{
?>
<?php
if ($filter_string != ""){
?><Table Border="0" Cellspacing="1" bgcolor="#CCCCCC" >
<tr>
<td height="80" align="Default" bgcolor="#FFFFFF">
<font color="#000099" size="2">Pas de r&eacute;ponse pour cette recherche !</font>
</td>
</tr>
</Table><br>
<?php
}else{
?><Table Border="0" Cellspacing="1" bgcolor="#CCCCCC" >
<tr>
<td height="80" align="Default" bgcolor="#FFFFFF">
<font color="#000099" size="2">Aucune donn&eacute;e n'est pr&eacute;sente en base !</font>
</font>
</td>
</tr>
</Table><br>
<?php
}
}
if ($qry_string != "") {
$navqry_string = "&" . $qry_string;
} else {
$navqry_string = "";
}
?>
<table height="30" border="0" align="center" cellpadding="0" cellspacing="0">
<tr align="center" valign="middle">
<td width="35" align="center"><A HREF="index.php"><img src="../images/bt_controlpanel.gif" border="0" align="absmiddle" title="Retour &agrave; la gestion"></a></td><td width="12" align="center"><img src="../images/bt_qsbetween.gif" border="0"></td>
<td width="35" align="center"><A HREF="mandataires_control_panel.html"><img src="../images/bt_controlpanelgroup.gif" border="0" align="absmiddle" title="Retour au panneau de contr&ocirc;le"></a></td><td width="12" align="center"><img src="../images/bt_qsbetween.gif" border="0"></td>
<form action="list.php" method="post" name="QSSelectPage">
<td width="35" align="center"><A HREF="list.php?clearsession=1"><img src="../images/bt_qsshowall.gif" border="0" align="absmiddle" title="Supprimer le(s) filtre(s)"></a></td><td width="8"></td>
<td width="35" align="center"><A HREF="search.php?<?=$qry_string?>"><img src="../images/bt_qssearch.gif" border="0" align="absmiddle" title="Rechercher"></a></td><td width="8"></td>
<td width="35" align="center"><A HREF="add.php?<?=$qry_string?>"><img src="../images/bt_qsadd_new.gif" border="0" align="absmiddle" title="Ajouter"></a></td><td width="12" align="center"><img src="../images/bt_qsbetween.gif" border="0"></td>
<?php
if ($current_page > 1) {
print '<td width="35" align="center"><a href="list.php?page=1"><img src="../images/bt_qsfirst.gif" border="0" align="absmiddle" title="Premi&egrave;re page"></a></td><td width="8"></td>';
print '<td width="35" align="center"><a href="list.php?page='.($current_page-1).'"><img src="../images/bt_qsback.gif" border="0" align="absmiddle" title="Page pr&eacute;c&eacute;dente"></a></td><td width="8"></td>';
} else {
print '<td width="35" align="center"><img src="../images/bt_qsfirst_inact.gif" border="0" align="absmiddle" title="Premi&egrave;re page"></a></td><td width="8"></td>';
print '<td width="35" align="center"><img src="../images/bt_qsback_inact.gif" border="0" align="absmiddle" title="Page pr&eacute;c&eacute;dente"></a></td><td width="8"></td>';
}
print "<td width=\"35\" align=\"center\"><select name=\"page\" onChange=\"window.location='list.php?page=' + this.value; \">";
for ($i=1; $i<=$page_count; $i++) {
$iDeb=$current_page-10;
$iFin=$current_page+10;
if ($i==1 || ($i>$iDeb && $i<$iFin)) {
?>
<option value="<?=$i?>" <?if($i==$current_page) echo 'selected';?>><?=$i?></option>
<?php
}
}
print '</select></td><td width="8"></td>';
if ($current_page < $page_count) {
print '<td width="35" align="center"><a href="list.php?page='.($current_page+1).'"><img src="../images/bt_qsnext.gif" border="0" align="absmiddle" title="Page suivante"></a></td><td width="8"></td>';
print '<td width="35" align="center"><a href="list.php?page='.$page_count.'"><img src="../images/bt_qslast.gif" border="0" align="absmiddle" title="Derni&egrave;re page"></a></td><td width="8"></td>';
} else {
print '<td width="35" align="center"><img src="../images/bt_qsnext_inact.gif" border="0" align="absmiddle" title="Page suivante"></td><td width="8"></td>';
print '<td width="35" align="center"><img src="../images/bt_qslast_inact.gif" border="0" align="absmiddle" title="Derni&egrave;re page"></td><td width="8"></td>';
}
if ($result > 0) {mysql_free_result($result);}
if ($link > 0) {mysql_close($link);}
?>
<td width="35" align="center"><a href="#top"><img src="../images/bt_qstop.gif" border="0" align="absmiddle" title="Atteindre le haut de la page"></a></td><td width="8"></td>
</form>
</tr>
</table>
<a name="bottom"></a>
</center>
</body>>
</html>