*/ require("test_page.php"); require("class_search.php"); include("session.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 = ""; $copies = ""; $_SESSION['copies'] = "false"; // define the row of the start if(isset($_GET['start'])) { $start = $_GET['start']; } else { $start = 0; } $where_request = ""; $_SESSION['s_services_chosen']=array(); $s_societe= ""; $_SESSION['societe_search']=""; $s_multifield= ""; $_SESSION['multifield_search']=""; $priority= 0; $_SESSION['priority_search']=""; $s_numcourrier = ""; $_SESSION['numcourrier'] = ""; $s_doc_notes = ""; $_SESSION['doc_notes'] = ""; $s_process_notes = ""; $_SESSION['process_notes'] = ""; $s_numged = ""; $_SESSION['numged'] = ""; $s_gid_id = ""; $_SESSION['search_gid_id'] = ""; //$s_destinataire = ""; //$_SESSION['destinataire'] = ""; $_SESSION['s_destinataire_chosen'] = array(); $s_objet = ""; $_SESSION['objet'] = ""; $_SESSION['s_doctypes_chosen'] = array(); $destinataire_chosen_tmp = ''; $_SESSION['civilities_chosen'] = array(); $doctypes_chosen_tmp = ''; $s_invoice_type = ""; $_SESSION['invoice_type'] = $s_invoice_type; $_SESSION['enr_from']=""; $_SESSION['enr_to']=""; $_SESSION['trait_from']=""; $_SESSION['trait_to']=""; $s_quartier = ""; $_SESSION['quartier'] = $s_quartier; $s_num = ""; $_SESSION['num'] = $s_num; $s_rue = ""; $_SESSION['rue'] = $s_rue; $s_Cp = ""; $_SESSION['Cp'] = $s_Cp; $s_ville = ""; $_SESSION['ville'] = $s_ville; $_SESSION['s_status_chosen'] = array(); $s_courrier = ""; $_SESSION['courrier_search'] = $s_courrier; $s_ar = ""; $_SESSION['AR'] = $s_ar; $s_fax = ""; $_SESSION['fax'] = $s_fax; $s_autre = ""; $_SESSION['autre'] = $s_autre; $s_direct = ""; $_SESSION['direct'] = $s_direct; $s_norep = ""; $s_simple_mail = ''; $_SESSION['simple_mail'] = $s_simple_mail; $_SESSION['norep'] = $s_norep; $s_is_ingoing = ""; $_SESSION['is_ingoing'] = $s_is_ingoing; $s_shipper = ""; $_SESSION['search_shipper'] = $s_shipper; $s_sender = ""; $_SESSION['search_shipper'] = $s_sender; $copies = "false"; $_SESSION['copies'] = "false"; $_SESSION['meta_search'] = array(); $lim_date_from = ''; $_SESSION['lim_date_from'] = ''; $lim_date_to = ''; $_SESSION['lim_date_to'] = ''; $_SESSION['sender_firstname'] = ''; $_SESSION['shipper_firstname'] = ''; $_SESSION['sender_lastname'] = ''; $_SESSION['shipper_lastname'] = ''; $_SESSION['sender_society'] = ''; $_SESSION['shipper_society'] = ''; $sender_firstname = ''; $sender_lastname = ''; $sender_society = ''; $shipper_firstname = ''; $shipper_lastname = ''; $shipper_society = ''; $_SESSION['shipper_function'] = ''; $shipper_function = ''; $_SESSION['sender_function'] = ''; $sender_function = ''; $_SESSION['date_start_to'] = ''; $_SESSION['date_start_from'] = ''; $date_start_to = ''; $date_start_from = ''; $_SESSION['doc_date_to'] = ''; $_SESSION['doc_date_from'] = ''; $doc_date_to = ''; $doc_date_from = ''; $json_txt = '{'; if(count($_REQUEST['meta']) > 0) { $_SESSION['meta_search'] = $_REQUEST['meta']; for($i=0; $i 0 || !empty($_REQUEST[$tab_id_fields[$j]))) if($tab_id_fields[$j] == 'services_chosen' && isset($_REQUEST['services_chosen'])) { $json_txt .= " 'services_chosen' : ["; $_SESSION['s_services_chosen'] = $_GET['services_chosen']; $srv_chosen_tmp = " ("; for ($get_i = 0; $get_i 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 "; $json_txt .= "'societe' : ['".addslashes(trim($_GET['societe']))."'],"; } else if($tab_id_fields[$j] == 'multifield' && !empty($_REQUEST['multifield'])) { $s_multifield = $func->wash($_GET['multifield'],"no",_MULTI_FIELD,"no"); $_SESSION['multifield_search']= addslashes(addslashes(trim($_GET['multifield']))); $where_request .= "r.DESCRIPTION LIKE '%".$_SESSION['multifield_search']."%' or r.IDENTIFIER LIKE '%".$_SESSION['multifield_search']."%' or r.TITLE LIKE '%".$_SESSION['multifield_search']."%' or r.CUSTOM_T1 LIKE '%".$_SESSION['multifield_search']."%' "; $where_request .=" and "; $json_txt .= "'multifield' : ['".addslashes(trim($_GET['multifield']))."'],"; } else if($tab_id_fields[$j] == 'priority' && !empty($_REQUEST['priority'])) { $json_txt .= " 'priority' : ['".addslashes(trim($_GET['priority']))."'],"; $priority = $func->wash($_GET['priority'],"num",_THE_PRIORITY,"no"); $_SESSION['priority_search']= $priority; $where_request .= " r.PRIORITY = ".$priority." "; $where_request .=" and "; } else if($tab_id_fields[$j] == 'numcourrier' && !empty($_REQUEST['numcourrier'])) { $json_txt .= " 'numcourrier' : ['".addslashes(trim($_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 if($tab_id_fields[$j] == 'process_notes' && !empty($_REQUEST['process_notes'])) { $json_txt .= " 'process_notes' : ['".addslashes(trim($_GET['process_notes']))."'],"; $s_process_notes = $func->wash($_GET['process_notes'], "no", _PROCESS_NOTES,"no"); $_SESSION['process_notes'] = $s_process_notes; $where_request .= "r.CUSTOM_T1 LIKE '%".$s_process_notes."%' and "; } else if($tab_id_fields[$j] == 'doc_notes' && !empty($_REQUEST['doc_notes'])) { $json_txt .= " 'doc_notes' : ['".addslashes(trim($_GET['doc_notes']))."'],"; $s_doc_notes = $func->wash($_GET['doc_notes'], "no", _NOTES,"no"); $_SESSION['doc_notes'] = $s_process_notes; $where_request .= "r.res_id in(select record_id from ".$_SESSION['tablename']['notes']." where info LIKE '%".$s_doc_notes."%') and "; } else if($tab_id_fields[$j] == 'numged' && !empty($_REQUEST['numged'])) { $json_txt .= " 'numged' : ['".addslashes(trim($_GET['numged']))."'],"; $s_numged = $func->wash($_GET['numged'], "num", _N_GED,"no"); $_SESSION['numged'] = $s_numged; $where_request .= "r.RES_ID = ".$s_numged." and "; } else if($tab_id_fields[$j] == 'gid_id' && !empty($_REQUEST['gid_id'])) { $json_txt .= " 'gid_id' : ['".addslashes(trim($_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 if($tab_id_fields[$j] == 'destinataire_chosen' && !empty($_REQUEST['destinataire_chosen'])) { $json_txt .= " 'destinataire_chosen' : ["; $_SESSION['s_destinataire_chosen'] = $_GET['destinataire_chosen']; $destinataire_chosen_tmp = " ("; for ($get_i = 0; $get_i wash($_GET['destinataire'], "no", _RECIPIENT , "no"); $_SESSION['destinataire'] = $s_destinataire; $where_request .= "r.DEST_USER LIKE '%".$s_destinataire."%' and ";*/ } else if($tab_id_fields[$j] == 'objet' && !empty($_REQUEST['objet'])) { $json_txt .= " 'objet' : ['".addslashes(trim($_GET['objet']))."'],"; $_SESSION['objet'] = addslashes(addslashes(trim($_GET['objet']))); //$where_request .= "r.DESCRIPTION LIKE '%".$_SESSION['objet']."%' or r.CUSTOM_T1 LIKE '%".$_SESSION['multifield_search']."%' and "; $where_request .= "r.DESCRIPTION LIKE '%".$_SESSION['objet']."%' and "; } else if($tab_id_fields[$j] == 'doctypes_chosen' && !empty($_REQUEST['doctypes_chosen'])) { $json_txt .= " 'doctypes_chosen' : ["; $_SESSION['s_doctypes_chosen'] = $_GET['doctypes_chosen']; $doctypes_chosen_tmp = " ("; for ($get_i = 0; $get_i wash($_GET['invoice_type'], "no", _INVOICE_TYPE,"no"); $_SESSION['invoice_type'] = addslashes(addslashes(trim($s_invoice_type))); $where_request .= "r.CUSTOM_T2 = '".$s_invoice_type."' and "; } else if($tab_id_fields[$j] == 'enr_from' && !empty($_REQUEST['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 "; $json_txt .= " 'enr_from' : ['".trim($_GET['enr_from'])."'],"; } } else if($tab_id_fields[$j] == 'enr_to' && !empty($_REQUEST['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 = ""; //$tmp = $func->add_days_in_date($tmp,1); $enr_to = str_replace('-','',$tmp); $_SESSION['enr_to'] = $_GET['enr_to']; $where_request .= " (r.CREATION_DATE <= ".$enr_to.") and "; $json_txt .= " 'enr_to' : ['".trim($_GET['enr_to'])."'],"; } } else if($tab_id_fields[$j] == 'trait_from' && !empty($_REQUEST['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 "; $json_txt .= "'trait_from' : ['".trim($_GET['trait_from'])."'],"; } } else if($tab_id_fields[$j] == 'trait_to' && !empty($_REQUEST['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 = ""; //$tmp = $func->add_days_in_date($tmp,1); $trait_to = str_replace('-','',$tmp); $_SESSION['trait_to'] = $_GET['trait_to']; $where_request .= " (r.CUSTOM_D3 <= ".$trait_to.") and "; $json_txt .= "'trait_to' : ['".trim($_GET['trait_to'])."'],"; } } else if($tab_id_fields[$j] == 'lim_date_from' && !empty($_REQUEST['lim_date_from'])) { $tmp = $func->inverse_date($_GET['lim_date_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['lim_date_from']; } else { $lim_date_from = ""; //$tmp = $func->add_days_in_date($tmp,1); $lim_date_from = str_replace('-','',$tmp); $_SESSION['lim_date_from'] = $_GET['lim_date_from']; $where_request .= " (r.CUSTOM_D2 >= ".$lim_date_from.") and "; $json_txt .= "'lim_date_from' : ['".trim($_GET['lim_date_from'])."'],"; } } else if($tab_id_fields[$j] == 'lim_date_to' && !empty($_REQUEST['lim_date_to'])) { $tmp = $func->inverse_date($_GET['lim_date_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['lim_date_to']; } else { $lim_date_to = ""; //$tmp = $func->add_days_in_date($tmp,1); $lim_date_to = str_replace('-','',$tmp); $_SESSION['lim_date_to'] = $_GET['lim_date_to']; $where_request .= " (r.CUSTOM_D2 <= ".$lim_date_to.") and "; $json_txt .= "'lim_date_to' : ['".trim($_GET['lim_date_to'])."'],"; } } else if($tab_id_fields[$j] == 'quartier' && !empty($_REQUEST['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 "; $json_txt .= "'quartier' : ['".addslashes(trim($_GET['quartier']))."'],"; } else if($tab_id_fields[$j] == 'num' && !empty($_REQUEST['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 "; $json_txt .= " 'num' : ['".addslashes(trim($_GET['num']))."'],"; } else if($tab_id_fields[$j] == 'rue' && !empty($_REQUEST['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 "; $json_txt .= " 'rue' : ['".addslashes(trim($_GET['rue']))."'],"; } else if($tab_id_fields[$j] == 'Cp' && !empty($_REQUEST['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 "; $json_txt .= " 'Cp' : ['".$_GET['Cp']."'],"; } else { $_SESSION['error'] .= _WRONG_CP.".
"; } } else if($tab_id_fields[$j] == 'ville' && !empty($_REQUEST['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 "; $json_txt .= " 'ville' : ['".addslashes(trim($_GET['ville']))."'],"; } else if($tab_id_fields[$j] == 'status_chosen' && isset($_REQUEST['status_chosen'])) { $json_txt .= " 'status_chosen' : ["; $_SESSION['s_status_chosen'] = $_REQUEST['status_chosen']; $where_request .="( "; for ($get_i = 0; $get_i "OUT") { $where_request .= " (r.STATUS = '".$_GET['status_chosen'][$get_i]."' and r.STATUS <> 'OUT') or "; } } } } $where_request = ereg_replace("or $", "", $where_request); $json_txt = substr($json_txt, 0, -1); $where_request .=") and "; $json_txt .= '],'; } else if($tab_id_fields[$j] == 'courrier' && !empty($_REQUEST['courrier'])) { $s_courrier = ($_GET['courrier']); $_SESSION['courrier_search'] = $s_courrier; $where_request .= "r.CUSTOM_T5 <> 'false' AND r.CUSTOM_T5 <> '' AND "; $json_txt .= "'courrier' : ['".addslashes(trim($_GET['courrier']))."'],"; } else if($tab_id_fields[$j] == 'AR' && !empty($_REQUEST['AR'])) { $s_ar = ($_GET['AR']); $_SESSION['AR'] = $s_ar; $where_request .= "r.CUSTOM_T15 <> 'false' AND r.CUSTOM_T15 <> '' AND "; $json_txt .= " 'AR' : ['".addslashes(trim($_GET['AR']))."'],"; } else if($tab_id_fields[$j] == 'fax' && !empty($_REQUEST['fax'])) { $s_fax = ($_GET['fax']); $_SESSION['fax'] = $s_fax; $where_request .= "r.CUSTOM_T16 <> 'false' AND r.CUSTOM_T16 <> '' AND "; $json_txt .= " 'fax' : ['".addslashes(trim($_GET['fax']))."'],"; } else if($tab_id_fields[$j] == 'courriel' && !empty($_REQUEST['courriel'])) { $s_courriel = ($_GET['courriel']); $_SESSION['courriel'] = $s_courriel; $where_request .= "r.CUSTOM_T7 <> 'false' AND r.CUSTOM_T7 <> '' AND "; $json_txt .= " 'courriel' : ['".addslashes(trim($_GET['courriel']))."'],"; } else if($tab_id_fields[$j] == 'autre' && !empty($_REQUEST['autre'])) { $s_autre = ($_GET['autre']); $_SESSION['autre'] = $s_autre; $where_request .= "r.CUSTOM_T8 <> 'false' AND r.CUSTOM_T8 <> '' AND "; $json_txt .= " 'autre' : ['".addslashes(trim($_GET['autre']))."'],"; } else if($tab_id_fields[$j] == 'direct' && !empty($_REQUEST['direct'])) { $s_direct = ($_GET['direct']); $_SESSION['direct'] = $s_direct; $where_request .= "r.CUSTOM_T6 <> 'false' AND r.CUSTOM_T6 <> '' AND "; $json_txt .= " 'direct' : ['".addslashes(trim($_GET['direct']))."'],"; } else if($tab_id_fields[$j] == 'simple_mail' && !empty($_REQUEST['simple_mail'])) { $s_simple_mail = ($_GET['simple_mail']); $_SESSION['simple_mail'] = $s_simple_mail; $where_request .= "r.CUSTOM_T5 <> 'false' AND r.CUSTOM_T5 <> '' AND "; $json_txt .= " 'simple_mail' : ['".addslashes(trim($_GET['simple_mail']))."'],"; } else if($tab_id_fields[$j] == 'norep' && !empty($_REQUEST['norep'])) { $s_norep = ($_GET['norep']); $_SESSION['norep'] = $s_norep; $where_request .= "r.CUSTOM_T17 <> 'false' AND r.CUSTOM_T17 <> '' AND "; $json_txt .= " 'norep' : ['".addslashes(trim($_GET['norep']))."'],"; } else if($tab_id_fields[$j] == 'is_ingoing' && !empty($_REQUEST['is_ingoing']) && ($_REQUEST['is_ingoing'] == "in" || $_REQUEST['is_ingoing'] == "out" )) { $s_is_ingoing = ($_GET['is_ingoing']); $_SESSION['is_ingoing'] = $s_is_ingoing; if($_REQUEST['is_ingoing'] == "in" ) { $where_request .= "r.IS_INGOING = 'Y' AND "; $json_txt .= "'is_ingoing' : ['in'],"; } elseif($_REQUEST['is_ingoing'] == "out") { $where_request .= "r.IS_INGOING = 'N' AND "; $json_txt .= "'is_ingoing' : ['out'],"; } } else if($tab_id_fields[$j] == 'copies_true' && $_REQUEST['copies'] == "true" ) { $copies = ($_GET['copies']); $_SESSION['copies'] = $copies; $json_txt .= " 'copies_true' : ['true'],"; } else if( $tab_id_fields[$j] == 'copies_false' && $_REQUEST['copies'] == "false" ) { $copies = "false"; $_SESSION['copies'] = "false"; $json_txt .= "'copies_false' : ['false'],"; } else if($tab_id_fields[$j] == 'select_shipper' && !empty($_REQUEST['select_shipper'])) { $s_shipper = $func->wash($func->show($_GET['select_shipper']), "no", _SHIPPER,"no"); $_SESSION['search_shipper'] = $s_shipper; if ($_GET['select_shipper'] <> 'SHOW_DATA') { $where_request .= "r.AUTHOR LIKE '%".addslashes($_SESSION['search_shipper'])."%' "; $where_request .=" and "; } $json_txt .= " 'select_shipper' : ['".addslashes(trim($_GET['select_shipper']))."'],"; } else if($tab_id_fields[$j] == 'shipper_lastname' && !empty($_REQUEST['shipper_lastname'])) { $shipper_lastname = $func->wash($func->show($_GET['shipper_lastname']), "no", _SHIPPER,"no"); $_SESSION['shipper_lastname'] = $shipper_lastname; $where_request .= "r.AUTHOR LIKE '%".addslashes($_SESSION['shipper_lastname'])."%' "; $where_request .=" and "; $json_txt .= " 'shipper_lastname' : ['".addslashes(trim($_GET['shipper_lastname']))."'],"; } else if($tab_id_fields[$j] == 'shipper_firstname' && !empty($_REQUEST['shipper_firstname'])) { $shipper_firstname = $func->wash($func->show($_GET['shipper_firstname']), "no", _SHIPPER,"no"); $_SESSION['shipper_firstname'] = $shipper_firstname; $where_request .= "r.CUSTOM_T5 LIKE '%".addslashes($_SESSION['shipper_firstname'])."%' "; $where_request .=" and "; $json_txt .= " 'shipper_firstname' : ['".addslashes(trim($_GET['shipper_firstname']))."'],"; } else if($tab_id_fields[$j] == 'shipper_society' && !empty($_REQUEST['shipper_society'])) { $shipper_society = $func->wash($func->show($_GET['shipper_society']), "no", _SHIPPER,"no"); $_SESSION['shipper_society'] = $shipper_society; $where_request .= "r.SOCIETE LIKE '%".addslashes($_SESSION['shipper_society'])."%' "; $where_request .=" and "; $json_txt .= " 'shipper_society' : ['".addslashes(trim($_GET['shipper_society']))."'],"; } else if($tab_id_fields[$j] == 'select_sender' && !empty($_REQUEST['select_sender'])) { $s_sender = $func->wash($func->show($_GET['select_sender']), "no", _SENDER,"no"); $_SESSION['search_sender'] = $s_sender; if ($_GET['select_sender'] <> 'SHOW_DATA') { $where_request .= "r.AUTHOR LIKE '%".addslashes($_SESSION['search_sender'])."%' "; $where_request .=" and "; } $json_txt .= " 'select_sender' : ['".addslashes(trim($_GET['select_sender']))."'],"; } else if($tab_id_fields[$j] == 'sender_lastname' && !empty($_REQUEST['sender_lastname'])) { $sender_lastname = $func->wash($func->show($_GET['sender_lastname']), "no", _SENDER,"no"); $_SESSION['sender_lastname'] = $sender_lastname; $where_request .= "r.AUTHOR LIKE '%".addslashes($_SESSION['sender_lastname'])."%' "; $where_request .=" and "; $json_txt .= " 'sender_lastname' : ['".addslashes(trim($_GET['sender_lastname']))."'],"; } else if($tab_id_fields[$j] == 'sender_firstname' && !empty($_REQUEST['sender_firstname'])) { $sender_firstname = $func->wash($func->show($_GET['sender_firstname']), "no", _SENDER,"no"); $_SESSION['sender_firstname'] = $sender_firstname; $where_request .= "r.CUSTOM_T5 LIKE '%".addslashes($_SESSION['sender_firstname'])."%' "; $where_request .=" and "; $json_txt .= " 'sender_firstname' : ['".addslashes(trim($_GET['sender_firstname']))."'],"; } else if($tab_id_fields[$j] == 'sender_society' && !empty($_REQUEST['sender_society'])) { $sender_society = $func->wash($func->show($_GET['sender_society']), "no", _SENDER,"no"); $_SESSION['sender_society'] = $sender_society; $where_request .= "r.SOCIETE LIKE '%".addslashes($_SESSION['sender_society'])."%' "; $where_request .=" and "; $json_txt .= " 'sender_society' : ['".addslashes(trim($_GET['sender_society']))."'],"; } else if($tab_id_fields[$j] == 'sender_function' && !empty($_REQUEST['sender_function'])) { $sender_function = $func->wash($func->show($_GET['sender_function']), "no", _SENDER,"no"); $_SESSION['sender_function'] = $sender_function; $where_request .= "r.CUSTOM_T9 LIKE '%".addslashes($_SESSION['sender_function'])."%' "; $where_request .=" and "; $json_txt .= " 'sender_function' : ['".addslashes(trim($_GET['sender_function']))."'],"; } else if($tab_id_fields[$j] == 'shipper_function' && !empty($_REQUEST['shipper_function'])) { $shipper_function = $func->wash($func->show($_GET['shipper_function']), "no", _SENDER,"no"); $_SESSION['shipper_function'] = $shipper_function; $where_request .= "r.CUSTOM_T9 LIKE '%".addslashes($_SESSION['shipper_function'])."%' "; $where_request .=" and "; $json_txt .= " 'shipper_function' : ['".addslashes(trim($_GET['shipper_function']))."'],"; } else if($tab_id_fields[$j] == 'civilities_chosen' && !empty($_REQUEST['civilities_chosen'])) { $json_txt .= " 'civilities_chosen' : ["; $_SESSION['civilities_chosen'] = $_GET['civilities_chosen']; $civilities_chosen_tmp = " ("; for ($get_i = 0; $get_i inverse_date($_GET['date_start_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['date_start_from']; } else { $date_start_from = ""; $date_start_from = str_replace('-','',$tmp); $_SESSION['date_start_from'] = $_GET['date_start_from'] ; $where_request .= " (r.CUSTOM_D1 >= ".$date_start_from.") and "; $json_txt .= " 'date_start_from' : ['".trim($_GET['date_start_from'])."'],"; } } else if($tab_id_fields[$j] == 'date_start_to' && !empty($_REQUEST['date_start_to'])) { $tmp = $func->inverse_date($_GET['date_start_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['date_start_to']; } else { $date_start_to = ""; //$tmp = $func->add_days_in_date($tmp,1); $date_start_to = str_replace('-','',$tmp); $_SESSION['date_start_to'] = $_GET['date_start_to']; $where_request .= " (r.CUSTOM_D1 <= ".$date_start_to.") and "; $json_txt .= " 'date_start_to' : ['".trim($_GET['date_start_to'])."'],"; } } else if($tab_id_fields[$j] == 'doc_date_from' && !empty($_REQUEST['doc_date_from'])) { $tmp = $func->inverse_date($_GET['doc_date_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['doc_date_from']; } else { $doc_date_from = ""; $doc_date_from = str_replace('-','',$tmp); $_SESSION['doc_date_from'] = $_GET['doc_date_from'] ; $where_request .= " (r.DOC_DATE >= ".$doc_date_from.") and "; $json_txt .= " 'doc_date_from' : ['".trim($_GET['doc_date_from'])."'],"; } } else if($tab_id_fields[$j] == 'doc_date_to' && !empty($_REQUEST['doc_date_to'])) { $tmp = $func->inverse_date($_GET['doc_date_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['doc_date_to']; } else { $doc_date_to = ""; //$tmp = $func->add_days_in_date($tmp,1); $doc_date_to = str_replace('-','',$tmp); $_SESSION['doc_date_to'] = $_GET['doc_date_to']; $where_request .= " (r.DOC_DATE <= ".$doc_date_to.") and "; $json_txt .= " 'doc_date_to' : ['".trim($_GET['doc_date_to'])."'],"; } } } $json_txt = ereg_replace(',$', '', $json_txt); $json_txt .= "}},"; } $json_txt = ereg_replace(',$', '', $json_txt); } $json_txt = ereg_replace(",$", "", $json_txt); $json_txt .= '}'; //echo "
".$json_txt."
"; require("load_extensions.php"); if ($_SESSION['tablechoice'] == "") { $_SESSION['tablechoice'] = $_SESSION['ressources'][0]['tablename']; } $_SESSION['current_search_query'] = $json_txt; if(!empty($_SESSION['error'])) { $func->echo_error(_ADV_SEARCH_TITLE, "
"._MUST_CORRECT_ERRORS." :

".$_SESSION['error']."
"._CLICK_HERE_TO_CORRECT."
"); } 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' ".$where_request." limit 0,".$_SESSION['config']['search_max_size'] ); } else { $connexion->query("select count(res_id) as TOTAL from ".$_SESSION['tablechoice']." r where r.status <> 'DEL' and r. status <> 'REP' and status <> 'VAL' and r.IS_FOLDER = 'Y' and ".$where_request." ".$where2." limit 0,".$_SESSION['config']['search_max_size'] ); } $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 <> '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 IS_FOLDER = 'Y' ".$where_request." ".$orderby; } 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 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 r.IS_FOLDER = 'Y' ".$orderby; } $_SESSION['export_where_request'] = $where_request." r.status <> 'DEL' and r.status <> 'REP' and r.status <> 'VAL' 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,'


'._NO_RESULTS.'

'); } } ?>