*/
include("session.php");
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;
}
$_SESSION['attach_doc'] = array();
$where_request = "";
/*
* Recherche suivant le champ emetteur
*
*/
if(($_GET['emetteur']) <> "")
{
$s_emetteur = $func->wash($_GET['emetteur'],"no",_SHIPPER,"no");
$_SESSION['attach_doc']['emetteur_search']= $s_emetteur;
$where_request .= "AUTHOR LIKE '%".$s_emetteur."%' ";
$where_request .=" and ";
}
elseif(isset($_SESSION['attach_doc']['emetteur_search']) && !empty($_SESSION['attach_doc']['emetteur_search']))
{
$where_request .= "AUTHOR LIKE '%".$_SESSION['attach_doc']['emetteur_search']."%' ";
$where_request .=" and ";
}
else
{
$s_emetteur= "";
$_SESSION['attach_doc']['emetteur_search']="";
}
/*
* Recherche suivant l'affaire
*
*/
if(($_GET['numcourrier']) <> "")
{
$s_numcourrier = $func->wash($_GET['numcourrier'], "no", _MAIL_IDENTIFIER,"no");
$_SESSION['attach_doc']['numcourrier'] = $s_numcourrier;
$where_request .= "IDENTIFIER LIKE '%".$s_numcourrier."%' and ";
}
elseif(isset($_SESSION['attach_doc']['numcourrier']) && !empty($_SESSION['attach_doc']['numcourrier']))
{
$where_request .= "IDENTIFIER LIKE '%".$_SESSION['attach_doc']['numcourrier']."%' and ";
}
else
{
$s_numcourrier = "";
$_SESSION['attach_doc']['numcourrier'] = "";
}
/*
* Recherche suivant le numéro de l'affaire
*
*/
if(($_GET['numged']) <> "")
{
$s_numged = $func->wash($_GET['numged'], "no", _N_GED,"no");
$_SESSION['attach_doc']['numged'] = $s_numged;
$where_request .= "RES_ID = ".$s_numged." and ";
}
elseif(isset($_SESSION['attach_doc']['numged']) && !empty($_SESSION['attach_doc']['numged']))
{
$where_request .= "RES_ID = ".$_SESSION['attach_doc']['numged']." and ";
}
else
{
$s_numged = "";
$_SESSION['attach_doc']['numged'] = "";
}
/*
* Recherche suivant le destinataire
*
*/
if(($_GET['destinataire']) <> "")
{
$s_destinataire = $func->wash($_GET['destinataire'], "no", _RECIPIENT , "no");
$_SESSION['attach_doc']['destinataire'] = $s_destinataire;
$where_request .= "DEST_USER LIKE '%".$s_destinataire."%' and ";
}
elseif(isset($_SESSION['attach_doc']['destinataire']) && !empty($_SESSION['attach_doc']['destinataire']))
{
$where_request .= "DEST_USER LIKE '%".$_SESSION['attach_doc']['destinataire']."%' and ";
}
else
{
$s_destinataire = "";
$_SESSION['attach_doc']['destinataire'] = "";
}
/*
* Recherche suivant l'objet de l'affaire
*
*/
if(isset($_GET['objet']) && !empty($_GET['objet']) )
{
$_SESSION['attach_doc']['objet'] = $_GET['objet'];
$where_request .= "DESCRIPTION LIKE '%".$_SESSION['attach_doc']['objet']."%' and ";
}
elseif(isset($_SESSION['attach_doc']['objet']) && !empty($_SESSION['attach_doc']['objet']))
{
$where_request .= "DESCRIPTION LIKE '%".$_SESSION['attach_doc']['objet']."%' and ";
}
else
{
$s_objet = "";
$_SESSION['attach_doc']['objet'] = "";
}
/*
* Recherche suivant le type de l'affaire
*
*/
if( ($_GET['type']) <> "")
{
$s_type = $func->wash($_GET['type'], "no", _DOCTYPE,"no");
$_SESSION['attach_doc']['type'] = $s_type;
$where_request .= "TYPE_ID = '".$s_type."' and ";
}
elseif(isset($_SESSION['attach_doc']['type']) && !empty($_SESSION['attach_doc']['type']))
{
$where_request .= "TYPE_ID = '".$_SESSION['attach_doc']['type']."' and ";
}
else
{
$s_type = "";
$_SESSION['attach_doc']['type'] = $s_type;
}
/*
* Recherche suivant la nature de l'envoi
*
*/
if(($_GET['naturesend']) <> "")
{
$s_naturesend = $func->wash($_GET['naturesend'], "no", _INVOICE_TYPE,"no");
$_SESSION['attach_doc']['naturesend'] = $s_naturesend;
$where_request .= "CUSTOM_T2 = '".$s_naturesend."' and ";
}
elseif(isset($_SESSION['attach_doc']['naturesend']) && !empty($_SESSION['attach_doc']['naturesend']))
{
$where_request .= "CUSTOM_T2 = '".$_SESSION['attach_doc']['naturesend']."' and ";
}
else
{
$s_naturesend = "";
$_SESSION['attach_doc']['naturesend'] = $s_naturesend;
}
$_SESSION['attach_doc']['enr_from']="";
/*
* Recherche suivant la date de début d'enregistrement
*
*/
if($_GET['enr_from']<>'')
{
$tmp = $func->inverse_date($_GET['enr_from']);
if( preg_match("/^[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['attach_doc']['enr_from'] = $_GET['enr_from'] ;
$where_request .= " (CREATION_DATE > ".$enr_from.") and ";
}
}
elseif(isset($_SESSION['attach_doc']['enr_from']) && !empty($_SESSION['attach_doc']['enr_from']))
{
$tmp = $func->inverse_date($_SESSION['attach_doc']['enr_from']);
$enr_from = "";
$enr_from = str_replace('-','',$tmp);
$where_request .= " (CREATION_DATE > ".$enr_from.") and ";
}
else
{
$_SESSION['attach_doc']['enr_from']= "";
}
$_SESSION['attach_doc']['enr_to']="";
/*
* Recherche suivant la date de fin d'enregistrement
*
*/
if($_GET['enr_to']<>'')
{
$tmp = $func->inverse_date($_GET['enr_to']);
if( preg_match("/^[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['attach_doc']['enr_to'] = $_GET['enr_to'];
$where_request .= " (CREATION_DATE < ".$enr_to.") and ";
}
}
elseif(isset($_SESSION['attach_doc']['enr_to']) && !empty($_SESSION['attach_doc']['enr_to']))
{
$tmp = $func->inverse_date($_SESSION['attach_doc']['enr_to']);
$enr_to = "";
$enr_to = str_replace('-','',$tmp);
$where_request .= " (CREATION_DATE < ".$enr_to.") and ";
}
else
{
$_SESSION['attach_doc']['enr_to']= "";
}
$_SESSION['attach_doc']['trait_from']="";
/*
* Recherche suivant la date de début de traitement
*
*/
if($_GET['trait_from']<>'')
{
$tmp = $func->inverse_date($_GET['trait_from']);
if( preg_match("/^[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['attach_doc']['trait_from'] = $_GET['trait_from'];
$where_request .= " (CUSTOM_D3 > ".$trait_from.") and ";
}
}
elseif(isset($_SESSION['attach_doc']['trait_from']) && !empty($_SESSION['attach_doc']['trait_from']))
{
$tmp = $func->inverse_date($_SESSION['attach_doc']['trait_from']);
$trait_from = "";
$trait_from = str_replace('-','',$tmp);
$where_request .= " (CUSTOM_D3 > ".$trait_from.") and ";
}
else
{
$_SESSION['attach_doc']['trait_from']= "";
}
$_SESSION['attach_doc']['trait_to']="";
/*
* Recherche suivant le numéro de gid
*
*/
if(($_GET['gid_id']) <> "")
{
$s_gid_id = $_GET['gid_id'];
$_SESSION['search_gid_id'] = $s_gid_id;
$where_request .= "r.GID_ID LIKE '%".$s_gid_id."%' and ";
}
else
{
$s_gid_id = "";
$_SESSION['search_gid_id'] = "";
}
/*
* Recherche suivant la date de fin de traitement
*
*/
if($_GET['trait_to']<>'')
{
$tmp = $func->inverse_date($_GET['trait_to']);
if( preg_match("/^[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['attach_doc']['trait_to'] = $_GET['trait_to'];
$where_request .= " (CUSTOM_D3 < ".$trait_to.") and ";
}
}
elseif(isset($_SESSION['attach_doc']['trait_to']) && !empty($_SESSION['attach_doc']['trait_to']))
{
$tmp = $func->inverse_date($_SESSION['attach_doc']['trait_to']);
$trait_from = "";
$trait_to = str_replace('-','',$tmp);
$where_request .= " (CUSTOM_D3 < ".$trait_to.") and ";
}
else
{
$_SESSION['attach_doc']['trait_to']= "";
}
/*
* Traitement suivant le service traitant
*
*/
if(($_GET['services']))
{
$s_services = $func->wash($_GET['services'], "no", _DEPARTMENT,"no");
$_SESSION['attach_doc']['services'] = $s_services;
$where_request .= "DESTINATION = '".$s_services."' and ";
}
elseif(isset($_SESSION['attach_doc']['services']) && !empty($_SESSION['attach_doc']['services']))
{
$where_request .= "DESTINATION = '".$_SESSION['services']."' and ";
}
else
{
$s_services = "";
$_SESSION['attach_doc']['services'] = $s_services;
}
/*
* Traitement suivant le statut
*
*/
if(($_GET['status']))
{
$s_status = $func->wash($_GET['status'], "no", _STATUS ,"no");
$_SESSION['attach_doc']['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";
$where_request .= " IS_INGOING = 'N' and";
}
}
}
}
elseif(isset($_SESSION['attach_doc']['status']) && !empty($_SESSION['attach_doc']['status']))
{
if (($_SESSION['attach_doc']['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 (($_SESSION['attach_doc']['status']=="REL2"))
{
//$datenow=date("d-m-Y") ;
$where_request .="( CURDATE() >= date(CUSTOM_D5) and STATUS <> 'END' and STATUS <> 'OUT' ) and ";
}
else
{
if($_SESSION['attach_doc']['status']<>"OUT")
{
$where_request .= " STATUS = '".$_SESSION['attach_doc']['status']."' and STATUS <> 'OUT' and ";
}
else
{
//$where_request .= " STATUS = '".$s_status."' and IS_INGOING = 'N' and";
$where_request .= " IS_INGOING = 'N' and";
}
}
}
}
else
{
$s_status = "";
$_SESSION['attach_doc']['status'] = $s_status;
}
if($_REQUEST['find_folder'] == true)
{
$where_request .= " IS_FOLDER = 'Y' and";
}
if($_REQUEST['find_folder'] == true)
{
$where_request .= " IS_FOLDER = 'Y' and";
}
$redirect_page = '';
if(isset($_REQUEST['redirect_page']) && !empty($_REQUEST['redirect_page']))
{
$redirect_page = $_REQUEST['redirect_page'];
}
$_SESSION['doc_to_attach'] = '';
if(isset($_REQUEST['doc_to_attach']) && !empty($_REQUEST['doc_to_attach']))
{
$_SESSION['doc_to_attach'] = $_REQUEST['doc_to_attach'];
$where_request .= " r.RES_ID <> '".$_SESSION['doc_to_attach']."' 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.'