*/ //updated by lgi for oo_generate $dir = '../'; include($dir . "session.php"); if (file_exists($dir . $_SESSION['config']['lang'].'.php')) { include($dir . $_SESSION['config']['lang'].'.php'); } else { $_SESSION['error'] = "Language file missing...
"; } require($dir . "class_functions.php"); require($dir . "class_db.php"); require($dir . "class_letterbox.php"); //added by lgi for webdav_ws.php $_SESSION['admin_models'] = array(); $db = new dbquery(); $db->connect(); $lb = new letterbox(); $answer= array(); $answer['TITLE'] = ""; $answer['CONTENT'] = ""; $answer['MODEL_ID'] = ""; $id = ""; $table = "res_x"; if (isset($_REQUEST['mode']) && !empty( $_REQUEST['mode'])) { $mode = $_REQUEST['mode']; } else { $mode = ""; $_SESSION['error'] .= _NO_MODE_DEFINED.".
"; } if (isset($_REQUEST['model']) && !empty($_REQUEST['model'])) { $answer['MODEL_ID']= trim($_REQUEST['model']); } if(isset($_REQUEST['id']) && !empty($_REQUEST['id'])) { $id = trim($_REQUEST['id']); $db->query("select TITLE from ".$table." where RES_ID = ".$id); $res = $db->fetch_object(); $answer['TITLE'] = stripslashes($res->TITLE); } if (!empty($answer['MODEL_ID']) && $mode == 'add') { $db->query("select ID, LABEL from ".$_SESSION['tablename']['models']." where ID = '".$answer['MODEL_ID']."'"); if($db->nb_result() == 0) { $_SESSION['error'] .= _MODEL.' '._UNKNOWN."
"; } else { $line = $db->fetch_object(); $answer['MODEL_ID'] = $line->ID; copy($dir . $_SESSION['config']['includedir']."/odtphp/models/model_".$answer['MODEL_ID'].".odt", $dir . $_SESSION['config']['tmpdir']."/model_".$answer['MODEL_ID'].".odt"); $answer['MODEL_LABEL'] = trim($line->LABEL); //$answer['TITLE'] = $_SESSION['courrier']['res_id']."_".$answer['MODEL_LABEL']."_".date("dmYhis").".odt"; $answer['TITLE'] = "REP".$_SESSION['courrier']['res_id']."_".date("dmyhis").".odt"; $dpt_id = substr($_SESSION['user']['department'],0,3); $db->query("select ID, SERVICE from ".$_SESSION['tablename']['services']." where ID = '".$dpt_id."'"); $line = $db->fetch_object(); $department =stripslashes($line->SERVICE); include($dir . 'models_fusion.php'); require_once($dir . $_SESSION['config']['includedir'].'/odtphp/library/odf.php'); $odf = new odf("model_".$answer['MODEL_ID'].".odt"); foreach ($resultArray as $key => $value) { if(preg_match('/DATE/', $key)) { $odf->setVars($key, html_entity_decode(utf8_decode($db->inverse_date($value)))); } else { $odf->setVars($key, html_entity_decode(utf8_decode(stripslashes($value)))); } } $odf->setVars('NEW_EMETTEUR', html_entity_decode(utf8_decode($_SESSION['user']['FirstName'])) . ' ' . html_entity_decode(utf8_decode($_SESSION['user']['LastName']))); $odf->setVars('PHONE_EMETTEUR', html_entity_decode(utf8_decode($_SESSION['user']['Phone']))); $odf->setVars('MAIL_EMETTEUR', html_entity_decode(utf8_decode($_SESSION['user']['Mail']))); $odf->setVars('DEP_EMETTEUR', html_entity_decode(utf8_decode($_SESSION['user']['department']))); $odf->setVars('DATE_TODAY', html_entity_decode(utf8_decode(date('d-m-Y')))); $db->query("select count(*) AS TOTAL FROM ".$_SESSION['tablename']['notes']." WHERE RECORD_ID = '".$_SESSION['courrier']['res_id']."'"); $line = $db->fetch_object(); $total = $line->TOTAL; $txtnotes = ""; if ($total == 1) { $db->query("select ID, INFO FROM ".$_SESSION['tablename']['notes']." WHERE RECORD_ID = '".$_SESSION['courrier']['res_id']."'"); $line = $db->fetch_object(); $txtnotes= utf8_decode(stripslashes($line->INFO)); } elseif($total > 1) { $i = 1; $txtnotes = " :\n\r"; $db->query("select ID, INFO FROM ".$_SESSION['tablename']['notes']." WHERE RECORD_ID = '".$_SESSION['courrier']['res_id']."'"); while ($line = $db->fetch_object()) { if ($i < $total) { $txtnotes= $txtnotes."- ".utf8_decode(stripslashes($line->INFO))." \n\r"; } else { $txtnotes= $txtnotes."- ".utf8_decode(stripslashes($line->INFO)); } $i++; } } else { $txtnotes = ""; } $odf->setVars('annotations',$txtnotes); //$odf->ExportAsAttachedFile($answer['TITLE']); $fileName = 'model_'.$answer['MODEL_ID'].'_'.$_SESSION['user']['UserId'].'_'.rand().'.odt'; $filePath = '../'.$_SESSION['config']['tmpdir'].'/'.$fileName; $odf->saveToDisk($fileName); /*****************************************************************************************************************************/ //stockage sur le docserver de la pièce jointe require_once($dir . "class_functions.php"); require_once($dir . "class_db.php"); require_once($dir . "class_docserver.php"); $conn = new dbquery(); $conn->connect(); $conn->query("SELECT DOCSERVER_ID, PATH_TEMPLATE, SIZE_LIMIT, ACTUAL_SIZE FROM ".$_SESSION['tablename']['docservers']." WHERE IS_READONLY = 'N' AND ENABLED = 'Y' "); if($conn->nb_result() == 0) { echo _NO_AVAILABLE_DOCSERVER."."._MORE_INFOS." : ".$_SESSION['config']['adminname'].".
"; exit; } else { $info = $conn->fetch_object(); $docserver_id = $info->DOCSERVER_ID; $docserver_size = $info->ACTUAL_SIZE + filesize($fileName); $path_template = trim($info->PATH_TEMPLATE); if($info->SIZE_LIMIT > 0 && $docserver_size >= $info->SIZE_LIMIT) { echo _NOT_ENOUGH_DISK_SPACE."."._MORE_INFOS." : ".$_SESSION['config']['adminname'].".
";exit; } else { if(!file_exists($filePath)) { echo _FILE_NOT_SEND.". "._TRY_AGAIN."."._MORE_INFOS." : ".$_SESSION['config']['adminname'].".
";exit; } else { $path_template = $info->PATH_TEMPLATE; $docserver = new docserver(); $result = $docserver->store($docserver_id, $path_template, $filePath, 'odt', filesize($filePath)); if(!is_array($result) || count($result) < 2 ) { echo $docserver->get_last_error()." ".$_SESSION['config']['adminname'].".
"; exit; } else { $signing = 'NULL'; if(isset($_REQUEST['signing']) && $_REQUEST['signing'] != "0" ) { $signing = "'".$_REQUEST['signing']."'"; } $the_ext = 'odt'; $new_doc_date = explode("-", $_SESSION['courrier']['doc_date']); $modified_doc_date = $new_doc_date[2].$new_doc_date[1].$new_doc_date[0]; $new_custom_d1 = explode("-", $_SESSION['courrier']['date_arrivee']); $modified_custom_d1 = $new_custom_d1[2].$new_custom_d1[1].$new_custom_d1[0]; $new_custom_d2 = explode("-", $_SESSION['courrier']['date_limite']); $modified_custom_d2 = $new_custom_d2[2].$new_custom_d2[1].$new_custom_d2[0]; $md5 = md5($result["destination_rept"].$result["file_destination_name"].".".$the_ext); $destination_rept = substr($result["destination_rept"],strlen($path_template),4); $destination_rept = str_replace(DIRECTORY_SEPARATOR,'#',$destination_rept); $file_destination_name = $result["file_destination_name"]; //enregistrement en base de données de la pièce jointe $_SESSION['courrier']['description'] = addslashes($_SESSION['courrier']['description']); $conn->query("INSERT INTO ".$table." (TITLE, RELATION, DESCRIPTION, FORMAT, CREATION_DATE, DOC_DATE, DOCSERVER_ID, PATH, FILENAME, FILESIZE, STATUS, TYPIST, TYPE_ID, CUSTOM_T3, CUSTOM_T4, AUTHOR, CUSTOM_D1, CUSTOM_D2, DESTINATION, DEST_USER, SOURCE, GID_ID, SIGNING) VALUES ('".addslashes($fileName)."', '".$_SESSION['courrier']['res_id']."', '".addslashes($_SESSION['courrier']['description'])."', '".strtoupper($the_ext)."', now() , '".$modified_doc_date."','".$docserver_id."','" .$destination_rept."','".$file_destination_name.".".strtolower($the_ext) ."',".filesize($fileName) .",'REP','".$_SESSION['user']['UserId'] ."','".$_SESSION['courrier']['type_id']."','".addslashes($_SESSION['courrier']['civ'])."', '".addslashes($_SESSION['courrier']['prenom'])."', '".addslashes($_SESSION['courrier']['author'])."', '".$modified_custom_d1."', '".$modified_custom_d2."' , '".addslashes($_SESSION['courrier']['service'])."', '".$_SESSION['courrier']['dest']."', 'Local File', 'R".date('Y').$_REQUEST['gid_id']."', ".$signing." )"); $conn->query("select res_id from ".$table." where DOCSERVER_ID = '".$docserver_id."' and PATH = '".$destination_rept."' and FILENAME = '".$file_destination_name.".".strtolower($the_ext)."'" ); $res = $conn->fetch_object(); $id_rep = $res->res_id; $conn->query("update ".$table." set fingerprint = '".$md5."' where res_id = ".$id_rep); if($_SESSION['history']['resadd'] == "true") { require_once($dir . "class_history.php"); $users = new history(); $users->add($table, $_SESSION['courrier']['res_id'],"ADD", _NEW_ANSWER_ADDED." : ".$_SESSION['courrier']['identifier']." (".$_SESSION['courrier']['type_id'].")"); } unlink($filePath); ?> "; }