* @author Loic Vinet */ require_once("class_functions.php"); require_once("class_db.php"); require_once("class_history.php"); require_once("class_workflow.php"); require_once("class_letterbox.php"); require_once("class_diffusion.php"); include("session.php"); if(file_exists($_SESSION['config']['lang'].'.php')) { include($_SESSION['config']['lang'].'.php'); } else { $_SESSION['error'] = "Language file missing...
"; } $s_id=$_SESSION['courrier']['res_id']; //Le courrier n'est plus reservé $courr = new LetterBox(); $courr->release($s_id,"res_x"); $_SESSION['error'] =""; if( isset($_REQUEST['close']) && $_REQUEST['close'] == _CLOSE ) { $_SESSION['courrier'] = array(); ?> connect(); $table="res_x"; $num = ""; $rue = ""; $notes = ""; $cp = ""; $ville = ""; $qualite = ""; $arrondissement = ""; $canton = ""; $epci = ""; $epci_type = ""; //$commune = ""; $custom_t5 = 'false'; $cutom_t15 = 'false'; $custom_t6 = 'false'; $custom_t7 = 'false'; $custom_t16 = 'false'; $custom_t17 = 'false'; $quartier = ""; if($_SESSION['config']['corporate'] == "true" && $_SESSION['config']['borough'] == "false") { if (isset($_REQUEST['num']) && trim($_POST['num']) <> html_entity_decode("["._NUM."]", ENT_NOQUOTES, 'UTF-8')) {$num=$_POST['num'];} if (isset($_POST['rue']) && trim($_POST['rue']) <> html_entity_decode('['._CHRONO_DEP_VALUE.']', ENT_NOQUOTES, 'UTF-8')) {$rue=$_POST['rue'];} if (isset($_POST['cp']) && trim($_POST['cp']) <> html_entity_decode('['._CHRONO_START_VALUE.']', ENT_NOQUOTES, 'UTF-8')) {$cp=$_POST['cp'];} if (isset($_POST['ville']) && trim($_POST['ville']) <> html_entity_decode('['._START_END_DATE.']', ENT_NOQUOTES, 'UTF-8')) {$ville=$_POST['ville'];} } elseif($_SESSION['config']['corporate'] == "false" && $_SESSION['config']['borough'] == "false") { if (isset($_POST['num']) && trim($_POST['num']) <> html_entity_decode("["._NUM."]", ENT_NOQUOTES, 'UTF-8')) {$num=$_POST['num'];} if (isset($_POST['rue']) && trim($_POST['rue']) <> html_entity_decode("["._ROAD."]", ENT_NOQUOTES, 'UTF-8')) {$rue=$_POST['rue'];} if (isset($_POST['cp']) && preg_match('/^[0-9][0-9][0-9][0-9][0-9]$/', $_POST['cp'])) {$cp=$_POST['cp'];} if (isset($_POST['ville']) && trim($_POST['ville']) <> html_entity_decode("["._CITY."]", ENT_NOQUOTES, 'UTF-8')) {$ville=$_POST['ville'];} } if($_SESSION['config']['borough'] == "true") { if (isset($_POST['num']) && trim($_POST['num']) <> html_entity_decode("["._NUM."]", ENT_NOQUOTES, 'UTF-8')) {$num=$_POST['num'];} if (isset($_POST['rue']) && trim($_POST['rue']) <> html_entity_decode("["._ROAD."]", ENT_NOQUOTES, 'UTF-8')) {$rue=$_POST['rue'];} if (isset($_POST['ville']) && trim($_POST['ville']) <> html_entity_decode("["._CITY."]", ENT_NOQUOTES, 'UTF-8')) {$ville=$_POST['ville'];} if (isset($_POST['cp2']) && preg_match('/^[0-9][0-9][0-9][0-9][0-9]$/', $_POST['cp2'])) {$cp = $_POST['cp2'];} if (isset($_POST['arrondissement']) && trim($_POST['arrondissement']) <> html_entity_decode("["._BOROUGH."]", ENT_NOQUOTES, 'UTF-8')) {$arrondissement = $_POST['arrondissement'];} if (isset($_POST['canton']) && trim($_POST['canton']) <> html_entity_decode('['._CANTON.']', ENT_NOQUOTES, 'UTF-8')) {$canton = $_POST['canton'];} if (isset($_POST['epci']) && trim($_POST['epci']) <> html_entity_decode('['._EPCI.']', ENT_NOQUOTES, 'UTF-8')) {$epci = $_POST['epci'];} if (isset($_POST['epci_type']) && trim($_POST['epci_type']) <> html_entity_decode('['._TYPE.']', ENT_NOQUOTES, 'UTF-8')) {$epci_type = $_POST['epci_type'];} if (isset($_POST['commune']) && trim($_POST['commune']) <> html_entity_decode('['._COMMUNE.']', ENT_NOQUOTES, 'UTF-8')) { if( is_numeric($_POST['commune']) ) { $conn->query("SELECT COMMUNE_LABEL FROM communes WHERE COMMUNE_ID ='".$_POST['commune']."' "); if($res = $conn->fetch_object() ) $ville = $res->COMMUNE_LABEL; } else { $ville = $_POST['commune']; } } } if (isset($_POST['qualite'])) {$qualite=$_POST['qualite'];} if (isset($_POST['notes'])) {$notes=$_POST['notes'];} if (isset($_POST['rep_courrier'])){$custom_t5=$_POST['rep_courrier'];} if (isset($_POST['rep_AR'])) {$custom_t15=$_POST['rep_AR'];} if (isset($_POST['direct'])) {$custom_t6=$_POST['direct'];} if (isset($_POST['mail'])) {$custom_t7=$_POST['mail'];} if (($_POST['autre']=="true") && $_POST['info_autre'] <> html_entity_decode("["._DEFINE."]", ENT_NOQUOTES, 'UTF-8')) {$info_autre=$_POST['info_autre'];} else {$info_autre='false';} if (isset($_POST['fax'])) {$custom_t16=$_POST['fax'];} if (isset($_POST['none'])) {$custom_t17=$_POST['none'];} if (isset($_POST['quartier'])) {$quartier=$_POST['quartier'];} if(isset($_POST['notes'])){$notes =$_POST['notes']; } if($_REQUEST['finish']=="redirect") { $_SESSION["diffusion"]->store(); $_SESSION['chosen_doc'] = array(); array_push($_SESSION['chosen_doc'],$s_id); header("location:red_doc_popup_process.php"); exit(); } //Redirection vers l'utilisateur qui a reellement traité le courrier if( $_SESSION['config']['redirect_to_user_on_treatment'] === "true" ) $_SESSION["diffusion"]->redirect_to_user($_SESSION['user']['UserId']); $_SESSION["diffusion"]->store(); //Validation sans changer le status if($_REQUEST['finish'] == "valid_without_change_status"){ $conn->query( "UPDATE ".$table." SET CUSTOM_T14 = '".addslashes($quartier)."', CUSTOM_T17='".$custom_t17."' ,CUSTOM_T5='".$custom_t5."' ,CUSTOM_T6='".$custom_t6."' ,CUSTOM_T7='".$custom_t7."' ,CUSTOM_T8='".$info_autre."' ,CUSTOM_T15='".$custom_t15."' ,CUSTOM_T16='".$custom_t16."' ,CUSTOM_T10='".addslashes($num)."' ,CUSTOM_T11='".addslashes($rue)."', CUSTOM_T12='".addslashes($ville)."' , CUSTOM_T13='".$cp."' ,CUSTOM_T9='".addslashes($qualite)."' ,CUSTOM_T1='".addslashes($notes)."', CUSTOM_T18 = '".$arrondissement."', CUSTOM_T19 = '".$canton."', CUSTOM_T20 = '".$epci."' , CUSTOM_T21 = '".$epci_type."' WHERE RES_ID=".$s_id); } else { $conn->query( "UPDATE ".$table." SET CUSTOM_T14 = '".addslashes($quartier)."', CUSTOM_T17='".$custom_t17."' ,CUSTOM_T5='".$custom_t5."' ,CUSTOM_T6='".$custom_t6."' ,CUSTOM_T7='".$custom_t7."' ,CUSTOM_T8='".$info_autre."' ,CUSTOM_T15='".$custom_t15."' ,CUSTOM_T16='".$custom_t16."' ,CUSTOM_T10='".addslashes($num)."' ,CUSTOM_T11='".addslashes($rue)."', CUSTOM_T12='".addslashes($ville)."' , CUSTOM_T13='".$cp."' ,CUSTOM_T9='".addslashes($qualite)."' ,CUSTOM_T1='".addslashes($notes)."', STATUS = 'COU', CUSTOM_T18 = '".$arrondissement."', CUSTOM_T19 = '".$canton."', CUSTOM_T20 = '".$epci."' , CUSTOM_T21 = '".$epci_type."' WHERE RES_ID=".$s_id); } if($_SESSION['history']['resup'] == "true") { $users = new history(); $users->add($table, $s_id,"UP", _N_PROCESS_LETTER.$s_id." (".$_SESSION['courrier']['type_id'].")"); sleep(1); } if($_REQUEST['finish'] == "waitingdoc") { $conn->query( "UPDATE ".$table." SET STATUS = 'WAI', CUSTOM_D6 = now() WHERE RES_ID = ".$s_id); if($_SESSION['config']['action_waitingdoc'] == "true") { $users = new history(); $users->add($table, $s_id,"WAI", _WAITING_DOC_PROCESS." ".$s_id." (".$_SESSION['courrier']['type_id'].")"); sleep(1); } } if($_REQUEST['finish'] == "continue_process") { $conn->query( "UPDATE ".$table." SET STATUS = 'COU', CUSTOM_D7 = now() WHERE RES_ID = ".$s_id); //Update limitedate $conn->query( "SELECT DATEDIFF(CUSTOM_D7,CUSTOM_D6) FROM ".$_SESSION['ressources'][0]['tablename']." WHERE RES_ID = ".$s_id); $result = $conn->fetch_array(); $conn->query( "UPDATE ".$_SESSION['ressources'][0]['tablename']." SET CUSTOM_D2 = ADDDATE(CUSTOM_D2, INTERVAL ".$result[0]." DAY) WHERE RES_ID = ".$s_id); if($_SESSION['config']['action_waitingdoc'] == "true") { $users = new history(); $users->add($table, $s_id,"WAI", _ENDWAITING_DOC_PROCESS." ".$s_id." (".$_SESSION['courrier']['type_id'].")"); sleep(1); } } if($_REQUEST['finish'] == "cloture") { $conn->query( "UPDATE ".$table." SET STATUS = 'END', CUSTOM_D3 = now() WHERE RES_ID = ".$s_id); if($_SESSION['history']['resup'] == "true") { $hist = new history(); $hist->add($table, $s_id,"UP", _MAIL_PROCESS_END_NUM.$s_id." (".$_SESSION['courrier']['type_id'].")"); } $db = new dbquery(); $db->connect(); $conn->query("select SOURCE, TITLE, FILESIZE, PATH, DOCSERVER_ID, FILENAME, RES_ID from ".$table." where RELATION = ".$s_id); while($res = $conn->fetch_object()) { $docserver = $res->DOCSERVER_ID; $path = $res->PATH; $filename = $res->FILENAME; $filesize = $res->FILESIZE; $title = $res->TITLE; $res_id = $res->RES_ID; $source = $res->SOURCE; $db->query("select PATH_TEMPLATE from ".$_SESSION['tablename']['docservers']." where DOCSERVER_ID = '".$docserver."'"); $line_doc = $db->fetch_object(); $docserver = $line_doc->PATH_TEMPLATE; $file = $docserver.$path.strtolower($filename); /*if ($_SESSION['config']['system'] == "true") { $file = str_replace("#","/",$file); } else { $file = str_replace("#","\\",$file); } */ $file = str_replace("#",DIRECTORY_SEPARATOR,$file); if($source == 'Editor') { $myfile = fopen($file, "r"); if(!$myfile) { $_SESSION['error'] .= _FILE_OPEN_ERROR.'.
'; header("location: process_frame?id=".$s_id); exit; } $data = fread($myfile, $filesize+1); fclose($myfile); $data = stripslashes($data); $header = ' '.$title.' '; $footer = ' '; $oldfile = fopen($file, 'w'); if(!$oldfile) { $_SESSION['error'] .= _FILE_OPEN_ERROR.'.
'; header("location: process_frame?id=".$_SESSION['courrier']['res_id']); exit; } $data = str_replace('query("update ".$table." set FILESIZE = ".$filesize.", FORMAT = 'HTML', FINGERPRINT = '".$md5."', FILENAME = '".$newfilename."', SOURCE = 'Local File' where RES_ID = ".$res_id); } elseif($source == 'Local File') { $md5 = md5($file); $db->query(" Update ".$table." set FINGERPRINT = '".$md5."'"); } } }elseif($_REQUEST['finish'] == "cloture_masse") { $conn->query( "UPDATE ".$table." SET STATUS = 'END', CUSTOM_D3 = now() WHERE RES_ID = ".$s_id); if($_SESSION['history']['resup'] == "true") { $hist = new history(); $hist->add($table, $s_id,"UP", _MAIL_PROCESS_END_NUM.$s_id." (".$_SESSION['courrier']['type_id'].")"); } $db = new dbquery(); $db->connect(); $conn->query("select SOURCE, TITLE, FILESIZE, PATH, DOCSERVER_ID, FILENAME, RES_ID from ".$table." where RELATION = ".$s_id); while($res = $conn->fetch_object()) { $docserver = $res->DOCSERVER_ID; $path = $res->PATH; $filename = $res->FILENAME; $filesize = $res->FILESIZE; $title = $res->TITLE; $res_id = $res->RES_ID; $source = $res->SOURCE; $db->query("select PATH_TEMPLATE from ".$_SESSION['tablename']['docservers']." where DOCSERVER_ID = '".$docserver."'"); $line_doc = $db->fetch_object(); $docserver = $line_doc->PATH_TEMPLATE; $file = $docserver.$path.strtolower($filename); /*if ($_SESSION['config']['system'] == "true") { $file = str_replace("#","/",$file); } else { $file = str_replace("#","\\",$file); } */ $file = str_replace("#",DIRECTORY_SEPARATOR,$file); if($source == 'Editor') { $myfile = fopen($file, "r"); if(!$myfile) { $_SESSION['error'] .= _FILE_OPEN_ERROR.'.
'; header("location: process_frame?id=".$s_id); exit; } $data = fread($myfile, $filesize+1); fclose($myfile); $data = stripslashes($data); $header = ' '.$title.' '; $footer = ' '; $oldfile = fopen($file, 'w'); if(!$oldfile) { $_SESSION['error'] .= _FILE_OPEN_ERROR.'.
'; header("location: process_frame?id=".$_SESSION['courrier']['res_id']); exit; } $data = str_replace('query("update ".$table." set FILESIZE = ".$filesize.", FORMAT = 'HTML', FINGERPRINT = '".$md5."', FILENAME = '".$newfilename."', SOURCE = 'Local File' where RES_ID = ".$res_id); } elseif($source == 'Local File') { $md5 = md5($file); $db->query(" Update ".$table." set FINGERPRINT = '".$md5."'"); } } if ($_SESSION['close']['position'] == count($_SESSION['chosen_doc'])) { $_SESSION['chosen_doc'] = array(); } else { $_SESSION['close']['position'] = $_SESSION['close']['position'] + 1; } //$_SESSION['close']['position'] = $_SESSION['close']['position'] + 1; ?> query( "UPDATE ".$table." SET DEST_USER = 'courrier' WHERE RES_ID = ".$s_id); if($_SESSION['history']['resup'] == "true") { $hist = new history(); $hist->add($table, $s_id,"RED", _LETTER_N.$s_id." (".$s_id.")"._REDIRECTED_TO_GENERAL." (".$_SESSION['courrier']['type_id'].")"); } } elseif($_REQUEST['finish'] == 'validate') { $conn->query( "UPDATE ".$table." SET STATUS = 'FVA', CUSTOM_D10 = now() WHERE RES_ID = ".$s_id); if($_SESSION['history']['resup'] == "true") { $hist = new history(); $hist->add($table, $s_id,"UP", _INVOICE_PROCESS_VALIDATE_NUM.$s_id.' '._PROCESSED_BY.' '.$_SESSION['user']['FirstName'].' '.$_SESSION['user']['LastName']." (".$_SESSION['courrier']['type_id'].")"); } } elseif($_REQUEST['finish'] == 'reject') { $conn->query( "UPDATE ".$table." SET STATUS = 'RJT', CUSTOM_D8 = now() WHERE RES_ID = ".$s_id); if($_SESSION['history']['resup'] == "true") { $hist = new history(); $hist->add($table, $s_id, "UP", _INVOICE_PROCESS_REJECT_NUM.$s_id.' '._PROCESSED_BY.' '.$_SESSION['user']['FirstName'].' '.$_SESSION['user']['LastName']." (".$_SESSION['courrier']['type_id'].")"); } } elseif($_REQUEST['finish'] == 'reject2') { $conn->query( "UPDATE ".$table." SET STATUS = 'RJV', CUSTOM_D11 = now() WHERE RES_ID = ".$s_id); if($_SESSION['history']['resup'] == "true") { $hist = new history(); $hist->add($table, $s_id,"UP", _INVOICE_PROCESS_REJECT_AFTER_VALIDATION_NUM.$s_id.' '._PROCESSED_BY.' '.$_SESSION['user']['FirstName'].' '.$_SESSION['user']['LastName']." (".$_SESSION['courrier']['type_id'].")"); } } elseif($_REQUEST['finish'] == 'setting_payment') { $conn->query( "UPDATE ".$table." SET STATUS = 'MEP', CUSTOM_D12 = now() WHERE RES_ID = ".$s_id); if($_SESSION['history']['resup'] == "true") { $hist = new history(); $hist->add($table, $s_id,"UP", _INVOICE_PROCESS_SETTING_PAYMENT_NUM.$s_id.' '._PROCESSED_BY.' '.$_SESSION['user']['FirstName'].' '.$_SESSION['user']['LastName']." (".$_SESSION['courrier']['type_id'].")"); } $db = new dbquery(); $db->connect(); $conn->query("select SOURCE, TITLE, FILESIZE, PATH, DOCSERVER_ID, FILENAME, RES_ID from ".$table." where RELATION = ".$s_id); while($res = $conn->fetch_object()) { $docserver = $res->DOCSERVER_ID; $path = $res->PATH; $filename = $res->FILENAME; $filesize = $res->FILESIZE; $title = $res->TITLE; $res_id = $res->RES_ID; $source = $res->SOURCE; $db->query("select PATH_TEMPLATE from ".$_SESSION['tablename']['docservers']." where DOCSERVER_ID = '".$docserver."'"); $line_doc = $db->fetch_object(); $docserver = $line_doc->PATH_TEMPLATE; $file = $docserver.$path.strtolower($filename); $file = str_replace("#",DIRECTORY_SEPARATOR,$file); if($source == 'Editor') { $myfile = fopen($file, "r"); if(!$myfile) { $_SESSION['error'] .= _FILE_OPEN_ERROR.'.
'; header("location: process_frame?id=".$s_id); exit; } $data = fread($myfile, $filesize+1); fclose($myfile); $data = stripslashes($data); $header = ' '.$title.' '; $footer = ' '; $oldfile = fopen($file, 'w'); if(!$oldfile) { $_SESSION['error'] .= _FILE_OPEN_ERROR.'.
'; header("location: process_frame?id=".$_SESSION['courrier']['res_id']); exit; } $data = str_replace('query("update ".$table." set FILESIZE = ".$filesize.", FORMAT = 'HTML', FINGERPRINT = '".$md5."', FILENAME = '".$newfilename."', SOURCE = 'Local File' where RES_ID = ".$res_id); } elseif($source == 'Local File') { $md5 = md5($file); $db->query(" Update ".$table." set FINGERPRINT = '".$md5."'"); } } } elseif($_REQUEST['finish'] == 'def_reject') { $conn->query( "UPDATE ".$table." SET STATUS = 'RJD', CUSTOM_D9 = now() WHERE RES_ID = ".$s_id); if($_SESSION['history']['resup'] == "true") { $hist = new history(); $hist->add($table, $s_id,"UP", _INVOICE_PROCESS_FINAL_REJECT_NUM.$s_id.' '._PROCESSED_BY.' '.$_SESSION['user']['FirstName'].' '.$_SESSION['user']['LastName']." (".$_SESSION['courrier']['type_id'].")"); } $db = new dbquery(); $db->connect(); $conn->query("select SOURCE, TITLE, FILESIZE, PATH, DOCSERVER_ID, FILENAME, RES_ID from ".$table." where RELATION = ".$s_id); while($res = $conn->fetch_object()) { $docserver = $res->DOCSERVER_ID; $path = $res->PATH; $filename = $res->FILENAME; $filesize = $res->FILESIZE; $title = $res->TITLE; $res_id = $res->RES_ID; $source = $res->SOURCE; $db->query("select PATH_TEMPLATE from ".$_SESSION['tablename']['docservers']." where DOCSERVER_ID = '".$docserver."'"); $line_doc = $db->fetch_object(); $docserver = $line_doc->PATH_TEMPLATE; $file = $docserver.$path.strtolower($filename); $file = str_replace("#",DIRECTORY_SEPARATOR,$file); if($source == 'Editor') { $myfile = fopen($file, "r"); if(!$myfile) { $_SESSION['error'] .= _FILE_OPEN_ERROR.'.
'; header("location: process_frame?id=".$s_id); exit; } $data = fread($myfile, $filesize+1); fclose($myfile); $data = stripslashes($data); $header = ' '.$title.' '; $footer = ' '; $oldfile = fopen($file, 'w'); if(!$oldfile) { $_SESSION['error'] .= _FILE_OPEN_ERROR.'.
'; header("location: process_frame?id=".$_SESSION['courrier']['res_id']); exit; } $data = str_replace('query("update ".$table." set FILESIZE = ".$filesize.", FORMAT = 'HTML', FINGERPRINT = '".$md5."', FILENAME = '".$newfilename."', SOURCE = 'Local File' where RES_ID = ".$res_id); } elseif($source == 'Local File') { $md5 = md5($file); $db->query(" Update ".$table." set FINGERPRINT = '".$md5."'"); } } } ?>