query("INSERT INTO ".$_SESSION['tablename']['listinstance']." (RES_TABLE, RES_ID, SEQUENCE,USER_ID,BY_USER_ID)
VALUES ('".$_SESSION['ressources'][0]['tablename']."', ".$res_id.", ".$k.", '".$_SESSION['diff'][$i]['UserID']."', '".$_SESSION['user']['UserId']."')");
}
if($_SESSION['history']['resadd'] == true)
{
require("class_history.php");
$hist = new history();
$mes = _DOC_QUALIFIED." (".$res_id.") ";
$hist->add($_SESSION['tablechoice'], $res_id ,"ADD", $mes);
if($is_folder =='N')
{
if($_SESSION['courrier']["is_ingoing"])
{
$mes = _NEW_INGOING_DOC." (".$res_id.") "._ADDED_TO_FOLDER.$folder_id;
}
else
{
$mes = _NEW_ONGOING_DOC." (".$type.") "._ADDED_TO_FOLDER.$folder_id;
}
$hist->add($_SESSION['tablechoice'], $folder_id ,"ADD", $mes);
}
}
if($_SESSION['courrier']["is_ingoing"])
{
$conn = new dbquery();
$conn->connect();
$conn->query("select date(creation_date) as date from ".$_SESSION['tablechoice']." where res_id = ".$res_id );
$res = $conn->fetch_object();
$dateenr = $res->date;
$conn->query("select TYPE_ID, ADDDATE('".$dateenr."', INTERVAL DELAI_RELANCE1 DAY) as RELANCE1, ADDDATE(".$date_limite.", INTERVAL DELAI_RELANCE2 DAY) as RELANCE2 from ".$_SESSION['tablename']['doctypes']." where TYPE_ID = '".$_SESSION['courrier']['type_courrier']."' and RES_TABLE = '".$_SESSION['tablechoice']."'");
//$conn->show();
if($conn->nb_result() == 0)
{
$_SESSION['error']= _DOCTYPE." "._UNKNOWN;
header("location: qualif_frame.php?id=".$_SESSION['courrier']['res_id']);
exit;
}
else
{
$res = $conn->fetch_object();
if( $res->RELANCE1 != NULL)
$relance1 = "'".$res->RELANCE1."'";
if( $res->RELANCE2 != NULL)
$relance2 = "'".$res->RELANCE2."'";
}
$conn->query("UPDATE ".$_SESSION['tablechoice']." SET CUSTOM_D4 = ".$relance1.", CUSTOM_D5 = ".$relance2." WHERE RES_ID = ".$res_id);
}
if($action == "diff " && $_SESSION['history']['qualification'])
{
$hist->add($_SESSION['tablename']['listinstance'], $res_id , 'DIF', _DOC." n° ".$res_id." "._SEND." : ".$_SESSION['diff'][0]['UserID']." ("._RECIPIENT.")");
for($i=1; $i < count($_SESSION['diff']); $i++)
{
$hist->add($_SESSION['tablename']['listinstance'], $res_id, 'DIF', _DOC." n° ".$res_id." "._SEND." : ".$_SESSION['diff'][$i]['UserID']." ("._TO_CC.")");
}
}
$_SESSION['indexation'] = true;
$_SESSION['diff'] = array();
if($is_folder == 'N')
{
$id = $folder_id;
}
$_SESSION['indexation_id'] = $id;
if ($_SESSION['courrier']['chk_date_limite'] == 'N')
{
$conn->query("UPDATE ".$_SESSION['tablechoice']." SET CUSTOM_D2=NULL, CUSTOM_D4=NULL, CUSTOM_D5=NULL WHERE RES_ID = ".$res_id);
}
$_SESSION['courrier'] = array();
?>
query("select DESCRIPTION, DOC_DATE, TYPE_ID, CUSTOM_T3, CUSTOM_T4, AUTHOR, CUSTOM_D1, CUSTOM_D2, DESTINATION, DEST_USER, IDENTIFIER, COLL_ID from ".$_SESSION['tablechoice']." where RES_ID = ".$_SESSION['courrier']['attach_num']);
$res = $conn->fetch_object();
$desc = $res->DESCRIPTION;
$date = $res->DOC_DATE;
$type = $res->TYPE_ID;
$civ = $res->CUSTOM_T3;
$prenom = $res->CUSTOM_T4;
$author = $res->AUTHOR;
$date_ar = $res->CUSTOM_D1;
$date_lim = $res->CUSTOM_D2;
$dest = $res->DESTINATION;
$dest_user = $res->DEST_USER;
$identifier = $res->IDENTIFIER;
$coll_id = $res->COLL_ID;
if($is_folder == 'Y')
{
$conn->query("update ".$_SESSION['tablechoice']." set title = '".addslashes($_SESSION['courrier']['title'] )."', relation = '".$_SESSION['courrier']['attach_num']."' , description = '".addslashes($desc)."', doc_date = '".$date."', identifier = '".$identifier."', status = 'REP', typist = '".$_SESSION['user']['UserId']."', type_id = '".addslashes($type)."', custom_t3 = '".addslashes($civ)."', custom_t4 = '".addslashes($prenom)."', author = '".addslashes($author)."', custom_d1 = '".$date_ar."', custom_d2 ='".$date_lim."' , destination = '".$dest."', coll_id = '".$coll_id."', dest_user = '".$dest."', is_ingoing = 'N', is_folder = '".$is_folder."', gid_id = 'E".date('Y').$_SESSION['gid_id']."', source = 'Local File' where res_id = ".$res_id );
update_gid($_SESSION['gid_id']);
}
else
{
$conn->query("update ".$_SESSION['tablechoice']." set title = '".addslashes($_SESSION['courrier']['title'] )."', relation = '".$_SESSION['courrier']['attach_num']."' , description = '".addslashes($desc)."', doc_date = '".$date."', identifier = '".$identifier."', status = 'REP', typist = '".$_SESSION['user']['UserId']."', type_id = '".addslashes($type)."', custom_t3 = '".addslashes($civ)."', custom_t4 = '".addslashes($prenom)."', author = '".addslashes($author)."', custom_d1 = '".$date_ar."', custom_d2 ='".$date_lim."' , destination = '".$dest."', coll_id = '".$coll_id."', dest_user = '".$dest."', is_ingoing = 'N', is_folder = '".$is_folder."', gid_id = 'E".date('Y').$_SESSION['gid_id']."', source = 'Local File', folder_id = '".$folder_id."' where res_id = ".$res_id );
update_gid($_SESSION['gid_id']);
if($_SESSION['courrier']["is_ingoing"])
{
// SI XML Permet la modification de la date limite de traitement et SI La date limite peut être modifiée
if($_SESSION['config']['update_limit_date'] == true) // update_limit_date_in xml
{
//Modification du document parent pour les dates limites de traitement CUSTOM D2, CUSTOM_D4, CUSTOM_D5
module_update_limit_date($folder_id, $new_limit_date);
}
}
if (($_SESSION['config']['mail_for_answer_by_index_file'] <> "false"))
{
$date = date("d-m-Y");
$mail_answer = "
"._ONE_ANSWER_JOINED." ".$_SESSION['courrier']['attach_num']."
"._HELLO.",
"._AN_ANSWER_HAS_BEEN_JOINED_TO_THE_DOC." ".$_SESSION['courrier']['attach_num']." "._ACTUALLY."...
"._ACCESS_MAIL_TO_PROCESS."
";
$conn->query("select MAIL from ".$_SESSION['tablename']['users']." where USER_ID = '".$dest_user."'");
$res = $conn->fetch_object();
$mail = $res->MAIL;
mail($mail, _ANSWER_JOINED_TITLE_MAIL, $mail_answer , "From: ".$_SESSION['config']['adminmail']."\nReply-To: ".$_SESSION['config']['adminmail']." \nContent-Type: text/html; charset=\"iso-8859-1\"\n");
}
}
$courr->release($res_id,"res_x");
$conn->query("update ".$_SESSION['tablechoice']." set STATUS = 'COU' where RES_ID = ".$_SESSION['courrier']['attach_num']);
if($_SESSION['history']['resadd'] == "true")
{
require_once("class_history.php");
$users = new history();
$users->add($_SESSION['tablechoice'], $_SESSION['courrier']['attach_num'],"ADD", _NEW_ANSWER_ADDED." : ".$identifier." (".$type.")");
}
$_SESSION['indexation'] = true;
$_SESSION['indexation_id'] = $_SESSION['courrier']['attach_num'];
if($is_folder =='N')
{
$res_id = $folder_id;
}
if ($_SESSION['courrier']['chk_date_limite'] == 'N')
{
$conn->query("UPDATE ".$_SESSION['tablechoice']." SET CUSTOM_D2=NULL, CUSTOM_D4=NULL, CUSTOM_D5=NULL WHERE RES_ID = ".$res_id);
}
?>