* @author Loic Vinet
*/
require("test_page.php");
require("class_search.php"); session_name('LetterBox2');
session_start();
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 = "";
$copies = "";
$_SESSION['copies'] = "false";
// 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']= addslashes(addslashes(trim($_GET['emetteur'])));
// echo $_SESSION['emetteur_search'];
$where_request .= "r.AUTHOR LIKE '%".$_SESSION['emetteur_search']."%' ";
$where_request .=" and ";
}
else
{
$s_emetteur= "";
$_SESSION['emetteur_search']="";
}
if(($_GET['societe']) <> "")
{
$s_emetteur = $func->wash($_GET['societe'],"no",_SOCIETY,"no");
$_SESSION['societe_search']= addslashes(addslashes(trim($_GET['societe'])));
$where_request .= "r.SOCIETE LIKE '%".$_SESSION['societe_search']."%' ";
$where_request .=" and ";
}
else
{
$s_societe= "";
$_SESSION['societe_search']="";
}
if(($_GET['priority']) <> "")
{
$priority = $func->wash($_GET['priority'],"num",_THE_PRIORITY,"no");
$_SESSION['priority_search']= $priority;
$where_request .= " r.PRIORITY = ".$priority." ";
$where_request .=" and ";
}
else
{
$priority= 0;
$_SESSION['priority_search']="";
}
if(($_GET['numcourrier']) <> "")
{
$s_numcourrier = $func->wash($_GET['numcourrier'], "no", _MAIL_IDENTIFIER,"no");
$_SESSION['numcourrier'] = $s_numcourrier;
$where_request .= "r.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 .= "r.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 .= "r.DEST_USER LIKE '%".$s_destinataire."%' and ";
}
else
{
$s_destinataire = "";
$_SESSION['destinataire'] = "";
}
if(isset($_GET['objet']) && !empty($_GET['objet']) )
{
$_SESSION['objet'] = addslashes(addslashes(trim($_GET['objet'])));
$where_request .= "r.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 .= "r.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'] = addslashes(addslashes(trim($s_naturesend)));
$where_request .= "r.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 .= " (r.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 .= " (r.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 .= " (r.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 .= " (r.CUSTOM_D3 < ".$trait_to.") and ";
}
}
if(($_GET['services']))
{
$s_services = $func->wash($_GET['services'], "no", _DEPARTMENT,"no");
$_SESSION['services'] = $s_services;
$where_request .= "r.DESTINATION = '".$s_services."' and ";
}
else
{
$s_services = "";
$_SESSION['services'] = $s_services;
}
if(($_GET['quartier']))
{
//$s_quartier = $func->wash($_GET['quartier'], "no", _THE_DISTRICT,"no");
$_SESSION['quartier'] = addslashes(addslashes(trim($_GET['quartier'])));
$where_request .= "r.CUSTOM_T14 like '".$_SESSION['quartier']."%' and ";
}
else
{
$s_quartier = "";
$_SESSION['quartier'] = $s_quartier;
}
if(($_GET['num']))
{
//$s_num = $func->wash($_GET['num'], "no", _THE_ROAD_NUM,"no");
$_SESSION['num'] = addslashes(addslashes(trim($s_num)));
$where_request .= "r.CUSTOM_T10 like '".$s_num."%' and ";
}
else
{
$s_num = "";
$_SESSION['num'] = $s_num;
}
if(($_GET['rue']))
{
//$s_rue = $func->wash($_GET['rue'], "no",_THE_ROAD,"no");
$_SESSION['rue'] = addslashes(addslashes(trim($s_rue)));
$where_request .= "r.CUSTOM_T11 like '".$s_rue."%' and ";
}
else
{
$s_rue = "";
$_SESSION['rue'] = $s_rue;
}
if(($_GET['Cp']))
{
if(ereg('^[0-9][0-9][0-9][0-9][0-9]$',$_GET['Cp']))
{
$_SESSION['Cp'] = $s_Cp;
$where_request .= "r.CUSTOM_T13 = '".$s_Cp."' and ";
}
else
{
$_SESSION['error'] .= _WRONG_CP.".
";
}
}
else
{
$s_Cp = "";
$_SESSION['Cp'] = $s_Cp;
}
if(($_GET['ville']))
{
//$s_ville = $func->wash($_GET['ville'], "no", _THE_CITY,"no");
$_SESSION['ville'] = addslashes(addslashes(trim($s_ville)));
$where_request .= "r.CUSTOM_T12 like '".$s_ville."%' and ";
}
else
{
$s_ville = "";
$_SESSION['ville'] = $s_ville;
}
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(r.CUSTOM_D4) <= CURDATE() and date(r.CUSTOM_D5) > CURDATE() and r.STATUS <> 'END' and r.STATUS <> 'OUT' ) and ";
}
else
{
if (($_GET['status']=="REL2"))
{
//$datenow=date("d-m-Y") ;
$where_request .="( CURDATE() >= date(r.CUSTOM_D5) and r.STATUS <> 'END' and r.STATUS <> 'OUT' ) and ";
}
else
{
if($_GET['status']<>"OUT")
{
$where_request .= "r.STATUS = '".$s_status."' and r.STATUS <> 'OUT' and ";
}
else
{
$where_request .= "r.STATUS = '".$s_status."' and r.IS_INGOING = 'N' and";
}
}
}
}
else
{
$s_status = "";
$_SESSION['status'] = $s_status;
}
if(($_GET['courrier']) == "true")
{
$s_courrier = ($_GET['courrier']);
$_SESSION['courrier_search'] = $s_courrier;
$where_request .= "r.CUSTOM_T5 <> 'false' AND r.CUSTOM_T5 <> '' AND ";
}
else
{
$s_courrier = "";
$_SESSION['courrier_search'] = $s_courrier;
}
if(($_GET['AR']) == "true")
{
$s_ar = ($_GET['AR']);
$_SESSION['AR'] = $s_ar;
$where_request .= "r.CUSTOM_T15 <> 'false' AND r.CUSTOM_T15 <> '' AND ";
}
else
{
$s_ar = "";
$_SESSION['AR'] = $s_ar;
}
if(($_GET['fax']) == "true")
{
$s_fax = ($_GET['fax']);
$_SESSION['fax'] = $s_fax;
$where_request .= "r.CUSTOM_T16 <> 'false' AND r.CUSTOM_T16 <> '' AND ";
}
else
{
$s_fax = "";
$_SESSION['fax'] = $s_fax;
}
if(($_GET['courriel']) == "true")
{
$s_courriel = ($_GET['courriel']);
$_SESSION['courriel'] = $s_courriel;
$where_request .= "r.CUSTOM_T7 <> 'false' AND r.CUSTOM_T7 <> '' AND ";
}
else
{
$s_courriel = "";
$_SESSION['courriel'] = $s_courriel;
}
if(($_GET['autre']) == "true")
{
$s_autre = ($_GET['autre']);
$_SESSION['autre'] = $s_autre;
$where_request .= "r.CUSTOM_T8 <> 'false' AND r.CUSTOM_T8 <> '' AND ";
}
else
{
$s_autre = "";
$_SESSION['autre'] = $s_autre;
}
if(($_GET['direct']) == "true")
{
$s_direct = ($_GET['direct']);
$_SESSION['autre'] = $s_direct;
$where_request .= "r.CUSTOM_T6 <> 'false' AND r.CUSTOM_T6 <> '' AND ";
}
else
{
$s_direct = "";
$_SESSION['direct'] = $s_direct;
}
if(($_GET['norep']) == "true")
{
$s_norep = ($_GET['norep']);
$_SESSION['norep'] = $s_norep;
$where_request .= "r.CUSTOM_T17 <> 'false' AND r.CUSTOM_T17 <> '' AND ";
}
else
{
$s_norep = "";
$_SESSION['norep'] = $s_norep;
}
if(($_GET['copies']) == "true")
{
$copies = ($_GET['copies']);
$_SESSION['copies'] = $copies;
}
else
{
$copies = "false";
$_SESSION['copies'] = "false";
}
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."