* @author Loic Vinet */ session_name('LetterBox2'); session_start(); if(file_exists($_SESSION['config']['lang'].'.php')) { include($_SESSION['config']['lang'].'.php'); } else { $_SESSION['error'] = "Language file missing...
"; } require("class_functions.php"); require_once("class_db.php"); require_once("class_letterbox.php"); $db = new dbquery(); $db->connect(); $connexion = new dbquery(); $connexion->connect(); $func = new functions(); $lb = new letterbox(); $services = array(); $users = array(); if(isset($_REQUEST['cancel'])) { $_SESSION['chosen_doc'] = array(); ?> query("select * from ".$_SESSION['tablename']['services']." where ID in (".$_SESSION['current_basket']['redirect_services'].") and ENABLED = 'Y'"); while($res = $db->fetch_object()) { array_push($services, array( 'ID' => $res->ID, 'LABEL' => $res->SERVICE)); } function cmp($a, $b) { return strcmp($a["LABEL"], $b["LABEL"]); } usort($services, "cmp"); } if(!empty($_SESSION['current_basket']['redirect_users']) && $_SESSION['current_basket']['can_redirect'] == 'Y') { $db2 = new dbquery(); $db2->connect(); $db->query("select DISTINCT uc.USER_ID, u.LASTNAME from ".$_SESSION['tablename']['usergroup_content']." uc, ".$_SESSION['tablename']['users']." u where GROUP_ID in (".$_SESSION['current_basket']['redirect_users'].") and u.USER_ID = uc.USER_ID order by u.LASTNAME asc"); //$db->show(); while($res = $db->fetch_object()) { $db2->query("select LASTNAME, FIRSTNAME from ".$_SESSION['tablename']['users']." where USER_ID = '".$res->USER_ID."' and USER_ID <> ''"); $res2 = $db2->fetch_object(); array_push($users, array( 'ID' => $res->USER_ID, 'NOM' => $res2->LASTNAME, "PRENOM" => $res2->FIRSTNAME, "SERVICE" => $res->DEPARTMENT)); } } if(isset($_REQUEST['valid1'])) { for($i=0;$i < count($_SESSION['chosen_doc']);$i++) { $db->query("update ".$_SESSION['current_basket']['table']." set DEST_USER = 'courrier' where RES_ID = ".$_SESSION['chosen_doc'][$i]); $db->query("update ".$_SESSION['tablename']['listinstance']." set USER_ID = '' where RES_TABLE = '".$_SESSION['current_basket']['table']."' and res_id = '".$_SESSION['chosen_doc'][$i]."' and SEQUENCE = 1 "); if($_SESSION['history']['redirection'] == 'true') { require_once("class_history.php"); $hist = new history(); $hist->add($_SESSION['current_basket']['table'], $_SESSION['chosen_doc'][$i],"RED", "Redirection vers le service courrier"); } } $_SESSION['chosen_doc'] = array(); if($_REQUEST['process'] <> "true" || !isset($_REQUEST['process'])) { ?> query('UPDATE '.$_SESSION['ressources'][0]['tablename'].' SET '.$query.' , DESTINATION = "'.$_REQUEST['service'].'" WHERE RES_ID = '.$_SESSION['chosen_doc'][$i]); $connexion->query("update ".$_SESSION['ressources'][0]['tablename']." set destination = '".$_REQUEST['service']."' where is_folder = 'N' and folder_id = '".$_SESSION['chosen_doc'][$i]."'"); //$connexion->query("DELETE from ".$_SESSION['tablename']['listinstance']." where RES_ID = ".$_SESSION['chosen_doc'][$i]); if($_SESSION['is_diff']) { if($_SESSION['config']['enablechangenotif'] == "true") { $mail_trait = "
"._MAIL_TO_PROCESS.".

"._HELLO.",
"._NEED_PROCESS_LETTER." :


"; $mail_copie = "
"._MAIL_IN_COPY."

"._HELLO.",
"._YOU_HAVE_MAIL_COPY." :


\n\n"; } } $connexion->query("select user_id from ".$_SESSION['tablename']['listinstance']." where res_table = '".$_SESSION['ressources'][0]['tablename']."' and res_id = ".$_SESSION['chosen_doc'][$i]." and sequence = 1"); //$connexion->show(); $line = $connexion->fetch_object(); $old_dest_user = $line->user_id; $conn = new dbquery(); $conn->connect(); $new_dest_user = $_SESSION['diff'][0]['UserID']; //echo $new_dest_user."
"; if($old_dest_user == $new_dest_user) { //nothing to do } else { //4 put new dest user in primary dest user and old dest user in copy $connexion->query("update ".$_SESSION['tablename']['listinstance']." set user_id = '".$new_dest_user."' where res_table = '".$_SESSION['ressources'][0]['tablename']."' and res_id = ".$_SESSION['chosen_doc'][$i]." and sequence = 1"); //$connexion->show(); $connexion->query("select max(sequence) as seq_max from ".$_SESSION['tablename']['listinstance']." where res_table = '".$_SESSION['ressources'][0]['tablename']."' and res_id = ".$_SESSION['chosen_doc'][$i]); //$connexion->show(); $line = $connexion->fetch_object(); $seq_max = $line->seq_max; $new_seq = $seq_max + 1; //echo $seq_max."
"; //echo $new_seq."
"; $connexion->query("insert into ".$_SESSION['tablename']['listinstance']." (res_table, res_id, sequence, user_id) values('".$_SESSION['ressources'][0]['tablename']."','".$_SESSION['chosen_doc'][$i]."',".$new_seq.",'".$old_dest_user."')"); //$connexion->show(); //5 delete the primary dest user in the copy if exists $connexion->query("delete from ".$_SESSION['tablename']['listinstance']." where res_table = '".$_SESSION['ressources'][0]['tablename']."' and res_id = ".$_SESSION['chosen_doc'][$i]." and user_id ='".$new_dest_user."' and sequence > 1"); //$connexion->show(); } //6 retrieve new dest copies and add it if not exists $conn = new dbquery(); $conn->connect(); $conn2 = new dbquery(); $conn2->connect(); $conn3 = new dbquery(); $conn3->connect(); //$connexion->query("select sequence, user_id from ".$_SESSION['tablename']['bask_listmodels']." where id = '".$_POST['service']."' and sequence > 0 order by sequence asc "); $conn2->query("select max(sequence) as seq_max from ".$_SESSION['tablename']['listinstance']." where res_table = '".$_SESSION['ressources'][0]['tablename']."' and res_id = ".$_SESSION['chosen_doc'][$i]); //$conn2->show(); $line = $conn2->fetch_object(); $max_seq_copy = $line->seq_max; if($max_seq_copy < 2) { $max_seq_copy++; } print_r($_SESSION['diff']); for($il=1;$ilquery("select user_id from ".$_SESSION['tablename']['listinstance']." where res_table = '".$_SESSION['ressources'][0]['tablename']."' and res_id = ".$_SESSION['chosen_doc'][$i]." and user_id = '".$_SESSION['diff'][$il]['UserID']."' and sequence > 1"); //$connexion->show(); $line2 = $connexion->fetch_object(); if($line2->user_id <> "") { //nothing to do } else { $max_seq_copy++; $conn->query("insert into ".$_SESSION['tablename']['listinstance']." (res_table, res_id, sequence, user_id) values('".$_SESSION['ressources'][0]['tablename']."','".$_SESSION['chosen_doc'][$i]."',".$max_seq_copy.",'".$_SESSION['diff'][$il]['UserID']."')"); //$conn->show(); } } $tmp_array = array(); $conn2->query("select user_id from ".$_SESSION['tablename']['listinstance']." where sequence > 1 and res_table = '".$_SESSION['ressources'][0]['tablename']."' and res_id = ".$_SESSION['chosen_doc'][$i]); //$conn2->show(); $cpt_copies = 1; while($line = $conn2->fetch_object()) { $tmp_array[$cpt_copies] = $line->user_id; $cpt_copies++; } print_r($tmp_array); $conn2->query("delete from ".$_SESSION['tablename']['listinstance']." where res_table = '".$_SESSION['ressources'][0]['tablename']."' and res_id = ".$_SESSION['chosen_doc'][$i]." and sequence > 1"); //$conn2->show(); for($cpt_copies2=1;$cpt_copies2<=count($tmp_array);$cpt_copies2++) { if($cpt_copies2==1) { $cpt = $cpt_copies2 + 1; } else { $cpt = $cpt + 1; } $conn->query("insert into ".$_SESSION['tablename']['listinstance']." (res_table, res_id, sequence, user_id) values('".$_SESSION['ressources'][0]['tablename']."','".$_SESSION['chosen_doc'][$i]."',".$cpt.",'".$tmp_array[$cpt_copies2]."')"); //$conn->show(); }; //exit; /* for($il=0;$ilquery("INSERT into ".$_SESSION['tablename']['listinstance']." ( RES_TABLE, RES_ID, SEQUENCE, USER_ID) values ( 'res_x', ".$_SESSION['chosen_doc'][$i].", ".$j.", '".$_SESSION['diff'][$il]['UserID']."')"); //$connexion->show(); if($_SESSION['config']['enablechangenotif'] == "true") { $connexion->query("select MAIL from ".$_SESSION['tablename']['users']." where USER_ID = '".$_SESSION['diff'][$il]['UserID']."'"); $res = $connexion->fetch_object(); $mail = $res->MAIL; if( $_SESSION['is_diff'] && $il==0) { mail($mail, _PROCESS_MAIL, $mail_trait , "From: ".$_SESSION['config']['mail']."\r\nReply-To: ".$_SESSION['config']['mail']." \r\nContent-Type: text/html; charset=\"iso-8859-1\"\r\n"); } elseif($_SESSION['is_diff'] && $il > 0) { mail($mail, _FIRST_WARNING_TXT, $mail_copie , "From: ".$_SESSION['config']['mail']."\r\nReply-To: ".$_SESSION['config']['mail']." \r\nContent-Type: text/html; charset=\"iso-8859-1\"\r\n"); } } }*/ $connexion->query("UPDATE ".$_SESSION['ressources'][0]['tablename']." SET FLAG_NOTIF = 'N' WHERE RES_ID = '".$_SESSION['chosen_doc'][$i]."' "); if($_SESSION['history']['redirection'] == 'true') { require_once("class_history.php"); $hist = new history(); $hist->add($_SESSION['current_basket']['table'], $_SESSION['chosen_doc'][$i],"RED",_LETTER_N.$_SESSION['chosen_doc'][$i].' '._REDIRECTED_TO." ".$_REQUEST['service']." "._WITH_DIFFUSION_LIST); } } } $_SESSION['chosen_doc'] = array(); if($_REQUEST['process'] <> "true" || !isset($_REQUEST['process'])) { ?> "; } } /*if($_SESSION['config']['redirect_list'] == 'true') { if(isset($_REQUEST['service']) && !empty($_REQUEST['service'])) { for($i=0;$i < count($_SESSION['chosen_doc']);$i++) { if(empty($_SESSION['error'])) { $query = " DEST_USER = '".$_SESSION['diff'][0]['UserID']."' "; $connexion->query('UPDATE '.$_SESSION['ressources'][0]['tablename'].' SET '.$query.' , DESTINATION = "'.$_REQUEST['service'].'" WHERE RES_ID = '.$_SESSION['chosen_doc'][$i]); $connexion->query("update ".$_SESSION['ressources'][0]['tablename']." set destination = '".$_REQUEST['service']."' where is_folder = 'N' and folder_id = '".$_SESSION['chosen_doc'][$i]."'"); $connexion->query("DELETE from ".$_SESSION['tablename']['listinstance']." where RES_ID = ".$_SESSION['chosen_doc'][$i]); if( $_SESSION['is_diff']) { if($_SESSION['config']['enablechangenotif'] == "true") { $mail_trait = "
"._MAIL_TO_PROCESS.".

"._HELLO.",
"._NEED_PROCESS_LETTER." :


"; $mail_copie = "
"._MAIL_IN_COPY."

"._HELLO.",
"._YOU_HAVE_MAIL_COPY." :


\n\n"; } } for($il=0;$ilquery("INSERT into ".$_SESSION['tablename']['listinstance']." ( RES_TABLE, RES_ID, SEQUENCE, USER_ID) values ( 'res_x', ".$_SESSION['chosen_doc'][$i].", ".$j.", '".$_SESSION['diff'][$il]['UserID']."')"); if($_SESSION['config']['enablechangenotif'] == "true") { $connexion->query("select MAIL from ".$_SESSION['tablename']['users']." where USER_ID = '".$_SESSION['diff'][$il]['UserID']."'"); $res = $connexion->fetch_object(); $mail = $res->MAIL; if( $_SESSION['is_diff'] && $il==0) { mail($mail, _PROCESS_MAIL, $mail_trait , "From: ".$_SESSION['config']['mail']."\r\nReply-To: ".$_SESSION['config']['mail']." \r\nContent-Type: text/html; charset=\"iso-8859-1\"\r\n"); } elseif($_SESSION['is_diff'] && $il > 0) { mail($mail, _FIRST_WARNING_TXT, $mail_copie , "From: ".$_SESSION['config']['mail']."\r\nReply-To: ".$_SESSION['config']['mail']." \r\nContent-Type: text/html; charset=\"iso-8859-1\"\r\n"); } } } $connexion->query("UPDATE ".$_SESSION['ressources'][0]['tablename']." SET FLAG_NOTIF = 'N' WHERE RES_ID = '".$_SESSION['chosen_doc'][$i]."' "); if($_SESSION['history']['redirection'] == 'true') { require_once("class_history.php"); $hist = new history(); $hist->add($_SESSION['current_basket']['table'], $_SESSION['chosen_doc'][$i],"RED",_LETTER_N.$_SESSION['chosen_doc'][$i].' '._REDIRECTED_TO." ".$_REQUEST['service']." "._WITH_DIFFUSION_LIST); } } } $_SESSION['chosen_doc'] = array(); if($_REQUEST['process'] <> "true" || !isset($_REQUEST['process'])) { ?> "; } }*/ else { if(isset($_REQUEST['service']) && !empty($_REQUEST['service'])) { $tmp = array(); for($i=0;$i < count($_SESSION['chosen_doc']);$i++) { $db->query("update ".$_SESSION['current_basket']['table']." set DESTINATION = '".$_REQUEST['service']."', DEST_USER='' where RES_ID = ".$_SESSION['chosen_doc'][$i]); $db->query("update ".$_SESSION['current_basket']['table']." set destination = '".$_REQUEST['service']."' where is_folder = 'N' and folder_id = '".$_SESSION['chosen_doc'][$i]."'"); // $db->query("select RES_ID, IDENTIFIER from ".$_SESSION['current_basket']['table']." where RES_ID = ".$_SESSION['chosen_doc'][$i]); // $res = $db->fetch_object(); // array_push($tmp, $res->RES_ID); $db->query("update ".$_SESSION['tablename']['listinstance']." set USER_ID = '' where RES_TABLE = '".$_SESSION['current_basket']['table']."' and RES_ID = '".$_SESSION['chosen_doc'][$i]."' and SEQUENCE = 1 "); if($_SESSION['history']['redirection'] == 'true') { require_once("class_history.php"); $hist = new history(); $hist->add($_SESSION['current_basket']['table'], $_SESSION['chosen_doc'][$i],"RED",_LETTER_N.$_SESSION['chosen_doc'][$i].' '._REDIRECTED_TO." ".$_REQUEST['service']); } } $_SESSION['chosen_doc'] = array(); if($_REQUEST['process'] <> "true" || !isset($_REQUEST['process'])) { ?> "; } } } if(isset($_REQUEST['valid3']) ) { if(isset($_REQUEST['user']) && !empty($_REQUEST['user'])) { for($i=0;$i < count($_SESSION['chosen_doc']);$i++) { $tmp = array(); //1 update dest user of document $db->query("update ".$_SESSION['current_basket']['table']." set DEST_USER = '".$_REQUEST['user']."' where RES_ID = ".$_SESSION['chosen_doc'][$i]); //2 retrieve old primary dest user $connexion->query("select user_id from ".$_SESSION['tablename']['listinstance']." where res_table = '".$_SESSION['ressources'][0]['tablename']."' and res_id = ".$_SESSION['chosen_doc'][$i]." and sequence = 1"); $line = $connexion->fetch_object(); $old_dest_user = $line->user_id; //echo $old_dest_user."
"; //3 retrieve new primary dest user $conn = new dbquery(); $conn->connect(); $new_dest_user = $_REQUEST['user']; //echo $new_dest_user."
"; if($old_dest_user == $new_dest_user) { //nothing to do } else { //4 put new dest user in primary dest user and old dest user in copy $connexion->query("update ".$_SESSION['tablename']['listinstance']." set user_id = '".$new_dest_user."' where res_table = '".$_SESSION['ressources'][0]['tablename']."' and res_id = ".$_SESSION['chosen_doc'][$i]." and sequence = 1"); //$connexion->show(); $connexion->query("select max(sequence) as seq_max from ".$_SESSION['tablename']['listinstance']." where res_table = '".$_SESSION['ressources'][0]['tablename']."' and res_id = ".$_SESSION['chosen_doc'][$i]); //$connexion->show(); $line = $connexion->fetch_object(); $seq_max = $line->seq_max; $new_seq = $seq_max + 1; //echo $seq_max."
"; //echo $new_seq."
"; $connexion->query("insert into ".$_SESSION['tablename']['listinstance']." (res_table, res_id, sequence, user_id) values('".$_SESSION['ressources'][0]['tablename']."','".$_SESSION['chosen_doc'][$i]."',".$new_seq.",'".$old_dest_user."')"); //$connexion->show(); //5 delete the primary dest user in the copy if exists $connexion->query("delete from ".$_SESSION['tablename']['listinstance']." where res_table = '".$_SESSION['ressources'][0]['tablename']."' and res_id = ".$_SESSION['chosen_doc'][$i]." and user_id ='".$new_dest_user."' and sequence > 1"); //$connexion->show(); } $tmp_array = array(); $conn2 = new dbquery(); $conn2->connect(); $conn2->query("select user_id from ".$_SESSION['tablename']['listinstance']." where sequence > 1 and res_table = '".$_SESSION['ressources'][0]['tablename']."' and res_id = ".$_SESSION['chosen_doc'][$i]); //$connexion->show(); $cpt_copies = 1; while($line = $conn2->fetch_object()) { $tmp_array[$cpt_copies] = $line->user_id; $cpt_copies++; } $conn2->query("delete from ".$_SESSION['tablename']['listinstance']." where res_table = '".$_SESSION['ressources'][0]['tablename']."' and res_id = ".$_SESSION['chosen_doc'][$i]." and sequence > 1"); //$conn2->show(); for($cpt_copies2=1;$cpt_copies2<=count($tmp_array);$cpt_copies2++) { if($cpt_copies2==1) { $cpt = $cpt_copies2 + 1; } else { $cpt = $cpt + 1; } $conn->query("insert into ".$_SESSION['tablename']['listinstance']." (res_table, res_id, sequence, user_id) values('".$_SESSION['ressources'][0]['tablename']."','".$_SESSION['chosen_doc'][$i]."',".$cpt.",'".$tmp_array[$cpt_copies2]."')"); //$conn->show(); } if($_SESSION['history']['redirection'] == 'true') { require_once("class_history.php"); $hist = new history(); $hist->add($_SESSION['current_basket']['table'], $_SESSION['chosen_doc'][$i],"RED",_LETTER_N.$_SESSION['chosen_doc'][$i].' '._REDIRECTED_TO." ".$_REQUEST['user']); } } $_SESSION['chosen_doc'] = array(); if($_REQUEST['process'] <> "true" || !isset($_REQUEST['process'])) { ?> "; } } ?> <?php echo $_SESSION['config']['applicationname']; ?>






.