*/
session_name('LetterBox2');
session_start();
require("class_functions.php");
require("class_db.php");
require("class_search.php");
if(file_exists($_SESSION['config']['lang'].'.php'))
{
include($_SESSION['config']['lang'].'.php');
}
else
{
$_SESSION['error'] = "Language file missing...
";
}
$func = new functions();
$the_search = new search();
$fields = "";
$orderby = "";
// define the row of the start
if(isset($_GET['start']))
{
$start = $_GET['start'];
}
else
{
$start = 0;
}
$where_request = "";
if(($_GET['emetteur']) <> "")
{
$s_emetteur = $func->wash($_GET['emetteur'],"no",_SHIPPER,"no");
$_SESSION['emetteur_search']= $s_emetteur;
$where_request .= "AUTHOR LIKE '%".$s_emetteur."%' ";
$where_request .=" and ";
}
else
{
$s_emetteur= "";
$_SESSION['emetteur_search']="";
}
if(($_GET['numcourrier']) <> "")
{
$s_numcourrier = $func->wash($_GET['numcourrier'], "no", _MAIL_IDENTIFIER,"no");
$_SESSION['numcourrier'] = $s_numcourrier;
$where_request .= "IDENTIFIER LIKE '%".$s_numcourrier."%' and ";
}
else
{
$s_numcourrier = "";
$_SESSION['numcourrier'] = "";
}
if(($_GET['numged']) <> "")
{
$s_numged = $func->wash($_GET['numged'], "no", _N_GED,"no");
$_SESSION['numged'] = $s_numged;
$where_request .= "RES_ID = ".$s_numged." and ";
}
else
{
$s_numged = "";
$_SESSION['numged'] = "";
}
if(($_GET['destinataire']) <> "")
{
$s_destinataire = $func->wash($_GET['destinataire'], "no", _RECIPIENT , "no");
$_SESSION['destinataire'] = $s_destinataire;
$where_request .= "DEST_USER LIKE '%".$s_destinataire."%' and ";
}
else
{
$s_destinataire = "";
$_SESSION['destinataire'] = "";
}
if(isset($_GET['objet']) && !empty($_GET['objet']) )
{
$_SESSION['objet'] = $_GET['objet'];
$where_request .= "DESCRIPTION LIKE '%".$_SESSION['objet']."%' and ";
}
else
{
$s_objet = "";
$_SESSION['objet'] = "";
}
if( ($_GET['type']) <> "")
{
$s_type = $func->wash($_GET['type'], "no", _DOCTYPE,"no");
$_SESSION['type'] = $s_type;
$where_request .= "TYPE_ID = '".$s_type."' and ";
}
else
{
$s_type = "";
$_SESSION['type'] = $s_type;
}
if(($_GET['naturesend']) <> "")
{
$s_naturesend = $func->wash($_GET['naturesend'], "no", _INVOICE_TYPE,"no");
$_SESSION['naturesend'] = $s_naturesend;
$where_request .= "CUSTOM_T2 = '".$s_naturesend."' and ";
}
else
{
$s_naturesend = "";
$_SESSION['naturesend'] = $s_naturesend;
}
$_SESSION['enr_from']="";
if($_GET['enr_from']<>'')
{
$tmp = $func->inverse_date($_GET['enr_from']);
if( ereg("^[1-2][0-9][0-9][0-9]-[0-1][0-9]-[0-3][0-9]$",$tmp)==false )
{
$_SESSION['error'] .= _WRONG_DATE_FORMAT.' : '.$_GET['enr_from'];
}
else
{
$enr_from = "";
$enr_from = str_replace('-','',$tmp);
$_SESSION['enr_from'] = $_GET['enr_from'] ;
$where_request .= " (CREATION_DATE > ".$enr_from.") and ";
}
}
$_SESSION['enr_to']="";
if($_GET['enr_to']<>'')
{
$tmp = $func->inverse_date($_GET['enr_to']);
if( ereg("^[1-2][0-9][0-9][0-9]-[0-1][0-9]-[0-3][0-9]$",$tmp )==false )
{
$_SESSION['error'] .= _WRONG_DATE_FORMAT.' : '.$_GET['enr_to'];
}
else
{
$enr_to = "";
$enr_to = str_replace('-','',$tmp);
$_SESSION['enr_to'] = $_GET['enr_to'];
$where_request .= " (CREATION_DATE < ".$enr_to.") and ";
}
}
$_SESSION['trait_from']="";
if($_GET['trait_from']<>'')
{
$tmp = $func->inverse_date($_GET['trait_from']);
if( ereg("^[1-2][0-9][0-9][0-9]-[0-1][0-9]-[0-3][0-9]$",$tmp)==false )
{
$_SESSION['error'] .= _WRONG_DATE_FORMAT.' : '.$_GET['trait_from'];
}
else
{
$trait_from = "";
$trait_from = str_replace('-','',$tmp);
$_SESSION['trait_from'] = $_GET['trait_from'];
$where_request .= " (CUSTOM_D3 > ".$trait_from.") and ";
}
}
$_SESSION['trait_to']="";
if($_GET['trait_to']<>'')
{
$tmp = $func->inverse_date($_GET['trait_to']);
if( ereg("^[1-2][0-9][0-9][0-9]-[0-1][0-9]-[0-3][0-9]$",$tmp)==false )
{
$_SESSION['error'] = _WRONG_DATE_FORMAT.' : '.$_GET['trait_to'];
}
else
{
$trait_to = "";
$trait_to = str_replace('-','',$tmp);
$_SESSION['trait_to'] = $_GET['trait_to'];
$where_request .= " (CUSTOM_D3 < ".$trait_to.") and ";
}
}
if(($_GET['services']))
{
$s_services = $func->wash($_GET['services'], "no", _DEPARTMENT,"no");
$_SESSION['services'] = $s_services;
$where_request .= "DESTINATION = '".$s_services."' and ";
}
else
{
$s_services = "";
$_SESSION['services'] = $s_services;
}
if(($_GET['status']))
{
$s_status = $func->wash($_GET['status'], "no", _STATUS ,"no");
$_SESSION['status'] = $s_status;
if (($_GET['status']=="REL1"))
{
//$datenow=date("Y-m-d") ;
$where_request .="( date(CUSTOM_D4) <= CURDATE() and date(CUSTOM_D5) > CURDATE() and STATUS <> 'END' and STATUS <> 'OUT' ) and ";
}
else
{
if (($_GET['status']=="REL2"))
{
//$datenow=date("d-m-Y") ;
$where_request .="( CURDATE() >= date(CUSTOM_D5) and STATUS <> 'END' and STATUS <> 'OUT' ) and ";
}
else
{
if($_GET['status']<>"OUT")
{
$where_request .= " STATUS = '".$s_status."' and STATUS <> 'OUT' and ";
}
else
{
$where_request .= " STATUS = '".$s_status."' and IS_INGOING = 'N' and";
}
}
}
}
else
{
$s_status = "";
$_SESSION['status'] = $s_status;
}
if($_REQUEST['find_folder'] == true)
{
$where_request .= " IS_FOLDER = 'Y' and";
}
require("load_extensions.php");
if ($_SESSION['tablechoice'] == "")
{
$_SESSION['tablechoice'] = $_SESSION['ressources'][0]['tablename'];
}
if(!empty($_SESSION['error']))
{
$func->echo_error(_ADV_SEARCH_TITLE, "
"._NO_RESULTS."
"._NO_RESULTS."