");
}
else
{?>
connect();
if($copies == "true")
{
if($where_request <> "")
{
$where_request = " and ".$where_request;
}
$where_request = trim($where_request);
//$where_request = ereg_replace("and$", "", $where_request);
$where_request = ereg_replace('(and|AND)$', '', $where_request);
$connexion->query("select count(*) as TOTAL from ".$_SESSION['tablechoice']." r, ".$_SESSION['tablename']['listinstance']." l where l.res_table = '".$_SESSION['tablechoice']."' and l.user_id = '".$_SESSION['user']['UserId']."' and l.res_id = r.res_id and l.sequence > 1 and r.status <> 'DEL' and r.status <> 'REP' and status <> 'VAL' and status <> 'RSV' and status <> 'ATT' ".$where_request." limit 0,".$_SESSION['config']['search_max_size'] );
}
else
{
$connexion->query("select count(res_id) as TOTAL from ".$_SESSION['tablechoice']." r where ".$where_request." ".$where2." and r.status <> 'DEL' and r. status <> 'REP' and status <> 'VAL' and status <> 'RSV' and status <> 'ATT' and r.IS_FOLDER = 'Y' limit 0,".$_SESSION['config']['search_max_size'] );
//$connexion->show();
}
$res = $connexion->fetch_object();
$nb_total = $res->TOTAL;
$label_nb_total = $res->TOTAL;
if($nb_total > $_SESSION['config']['search_max_size'] )
{
$nb_total = $_SESSION['config']['search_max_size'] ;
$label_nb_total = '> à '.$_SESSION['config']['search_max_size'] ;
}
$orderby = $the_search->define_order();
if($copies == "true")
{
$connexion->query("select ".$fields." from ".$_SESSION['tablechoice']." r, ".$_SESSION['tablename']['listinstance']." l where l.res_table = '".$_SESSION['tablechoice']."' and l.user_id = '".$_SESSION['user']['UserId']."' and l.res_id = r.res_id and l.sequence > 1 and r.status <> 'DEL' and r.status <> 'REP' and status <> 'RSV' and status <> 'ATT' and status <> 'VAL' and IS_FOLDER = 'Y' ".$where_request." ".$orderby." limit ".$start.",".$_SESSION['config']['nblinetoshow']);
//$connexion->show();
$_SESSION['print_list']['current_request'] = "select r.RES_ID, DESCRIPTION, AUTHOR, DEST_USER, TYPE_ID, date(CREATION_DATE), SOCIETE from ".$_SESSION['tablechoice']." r, ".$_SESSION['tablename']['listinstance']." l where l.res_table = '".$_SESSION['tablechoice']."' and l.user_id = '".$_SESSION['user']['UserId']."' and l.res_id = r.res_id and l.sequence > 1 and r.status <> 'DEL' and r.status <> 'REP' and status <> 'VAL' and status <> 'RSV' and status <> 'ATT' and IS_FOLDER = 'Y' ".$where_request." ".$orderby;
$_SESSION['export_where_request'] = " l.res_table = '".$_SESSION['tablechoice']."' and l.user_id = '".$_SESSION['user']['UserId']."' and l.res_id = r.res_id and l.sequence > 1 and r.status <> 'DEL' and r.status <> 'REP' and status <> 'VAL' and status <> 'RSV' and status <> 'ATT' and IS_FOLDER = 'Y' ".$where_request;
}
else
{
$connexion->query("select ".$fields." from ".$_SESSION['tablechoice']." r where ".$where_request." ".$where2." and r.status <> 'DEL' and r.status <> 'REP' and status <> 'VAL' and status <> 'RSV' and status <> 'ATT' and r.IS_FOLDER = 'Y' ".$orderby." limit ".$start.",".$_SESSION['config']['nblinetoshow']);
$_SESSION['print_list']['current_request'] = "select RES_ID, DESCRIPTION, AUTHOR, DEST_USER, TYPE_ID, date(CREATION_DATE), SOCIETE from ".$_SESSION['tablechoice']." r where ".$where_request." ".$where2." and r.status <> 'DEL' and r.status <> 'REP' and status <> 'VAL' and status <> 'RSV' and status <> 'ATT' and r.IS_FOLDER = 'Y' ".$orderby;
$_SESSION['export_where_request'] = $where_request." ".$where2." and r.status <> 'DEL' and r.status <> 'REP' and status <> 'VAL' and status <> 'RSV' and status <> 'ATT' and r.IS_FOLDER = 'Y' ";
}
//$_SESSION['export_where_request'] = $where_request." r.status <> 'DEL' and r.status <> 'REP' and r.status <> 'VAL' and status <> 'RSV' and status <> 'ATT' and r.IS_FOLDER = 'Y'";
//$connexion->show();
if($connexion->nb_result() > 0)
{
$tab=array();
$val=array();
$i=0;
while ($value = $connexion->fetch_array())
{
$val[$i]=array("RES_ID" => $value[0],"TITLE" => $value[1],"DESCRIPTION" => $value[2],"CUSTOM_D1" => $value[3],"FORMAT" => $value[4],"AUTHOR" => $value[5],"DEST_USER" => $value[7],"STATUS" => $value[8], "LIB_TYPE" => $value[9], "DESTINATION" => $value[10], "PRIORITY" => $value[11] , "SOCIETE" => $value[12], "CREATION_DATE" => $value[13], "IS_INGOING" => $value[14]);
if($_SESSION['config']['gdi_index'] == "true")
{
$val[$i]['GID_ID'] = $value[15];
}
array_push($tab,$val[$i]);
$i++;
}
$table ="";
for($i=0; $i < count($_SESSION['ressources']); $i++)
{
if($_SESSION['tablechoice'] == $_SESSION['ressources'][$i]['tablename'])
{
$table = $_SESSION['ressources'][$i]['comment'];
break;
}
}
$title = _SEARCH_RESULTS ;
if($nb_total > 1)
{
$title .= " (".$label_nb_total." "._DOCUMENTS.")";
}
$the_search->list_doc($tab,$nb_total,$title,$s_search,"search_adv_result");
}
else
{
$func->echo_error(_ADV_SEARCH_TITLE,'