retrieve_view_from_coll_id($coll_id); if(empty($view)) { $view = $sec->retrieve_table_from_coll($coll_id); } $db = new dbquery(); $db->connect(); //$db->query("select docserver_id, path, filename from ".$view." where res_id = ".$res_id); $db->query("select docserver_id from res_view_attachments where res_id_master = " . $res_id . " order by res_id desc"); while ($res = $db->fetch_object()) { $docserver_id = $res->docserver_id; break; } $db->query("select path_template from ".$_SESSION['tablename']['docservers']." where docserver_id = '".$docserver_id."'"); $res = $db->fetch_object(); $docserver_path = $res->path_template; $db->query("select filename, path,title,res_id,res_id_version,attachment_type from res_view_attachments where res_id_master = " . $res_id . " AND status <> 'OBS' AND status <> 'SIGN' AND status <> 'DEL' and attachment_type IN ('response_project','signed_response') order by creation_date asc"); $array_reponses = array(); $cpt_rep = 0; while ($res2 = $db->fetch_object()){ $filename=$res2->filename; $path = preg_replace('/#/', DIRECTORY_SEPARATOR, $res2->path); $filename_pdf = str_replace(pathinfo($filename, PATHINFO_EXTENSION), "pdf",$filename); if (file_exists($docserver_path.$path.$filename_pdf)){ $array_reponses[$cpt_rep]['path'] = $docserver_path.$path.$filename_pdf; $array_reponses[$cpt_rep]['title'] = $res2->title; $array_reponses[$cpt_rep]['attachment_type'] = $res2->attachment_type; if ($res2->res_id_version == 0){ $array_reponses[$cpt_rep]['res_id'] = $res2->res_id; $array_reponses[$cpt_rep]['is_version'] = 0; } else{ $array_reponses[$cpt_rep]['res_id'] = $res2->res_id_version; $array_reponses[$cpt_rep]['is_version'] = 1; } $cpt_rep++; } } return $array_reponses; } function getNotes($res_id){ $db = new dbquery(); $db->connect(); $req_notes = "select * from notes where identifier = '".$res_id."'"; $db->query($req_notes); $tab_notes = array(); while ($notes = $db->fetch_object()) { $note = "Note de ".$notes->user_id.", le ".$notes->date_note." : ".$notes->note_text; //array_push($tab_notes, $note); array_push($tab_notes, array('id_note'=>$notes->id,'user_id'=>$notes->user_id,'date_note'=>$notes->date_note,'note_text'=>$notes->note_text)); } return $tab_notes; } function get_attach_path($res_id, $coll_id) { require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_security.php"); require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."docservers_controler.php"); $docserverControler = new docservers_controler(); $sec =new security(); $view = $sec->retrieve_view_from_coll_id($coll_id); if(empty($view)) { $view = $sec->retrieve_table_from_coll($coll_id); } $db = new dbquery(); $db->connect(); $db->query("select docserver_id, path, filename from ".$view." where res_id = ".$res_id); $res = $db->fetch_object(); $docserver_id = $res->docserver_id; $db->query("select path_template from ".$_SESSION['tablename']['docservers']." where docserver_id = '".$docserver_id."'"); $res = $db->fetch_object(); $docserver_path = $res->path_template; $db->query("select filename, path,title,res_id,status,typist,creation_date,format,attachment_type from res_view_attachments where status <> 'DEL' AND status IN ('TRA','SIGN') AND res_id_master = " . $res_id . " order by attachment_type, creation_date asc"); $array_attach = array(); $cpt_rep = 0; while ($res2 = $db->fetch_object()){ $filename=$res2->filename; $path = preg_replace('/#/', DIRECTORY_SEPARATOR, $res2->path); $filename_pdf = str_replace(pathinfo($filename, PATHINFO_EXTENSION), "pdf",$filename); $array_attach[$cpt_rep]['path'] = $docserver_path.$path.$filename_pdf; $array_attach[$cpt_rep]['title'] = $res2->title; $array_attach[$cpt_rep]['res_id'] = $res2->res_id; $array_attach[$cpt_rep]['attachment_type'] = $res2->attachment_type; $array_attach[$cpt_rep]['format'] = $res2->format; $array_attach[$cpt_rep]['typist'] = $res2->typist; $date = explode(" ",$res2->creation_date); $array_attach[$cpt_rep]['date'] = $date[0]; $cpt_rep++; } return $array_attach; } function getInfosUser($user_id){ $db=new dbquery(); $db->connect(); $db->query("SELECT firstname, lastname, group_id, entity_id from users u, usergroup_content uc, users_entities ue where u.user_id = '$user_id' AND uc.user_id = u.user_id AND ue.user_id = u.user_id AND ue.primary_entity='Y' AND uc.primary_group = 'Y' "); $user = array(); $res = $db->fetch_object(); $user['prenom'] = $res->firstname; $user['nom'] = $res->lastname; $user['groupe'] = $res->group_id; $user['entite'] = $res->entity_id; return $user; } /*************/ $res_id = $_REQUEST['res_id']; $coll_id = $_REQUEST['coll_id']; require_once "modules" . DIRECTORY_SEPARATOR . "visa" . DIRECTORY_SEPARATOR . "class" . DIRECTORY_SEPARATOR . "class_modules_tools.php"; include('apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'definition_mail_categories.php'); require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_request.php"); $core =new core_tools(); $data = get_general_data($coll_id, $res_id, 'minimal'); /* Partie centrale */ // AVANCEMENT $avancement_html = ''; $avancement_html .= '

'. _WF .'

'; $avancement_html .= ''; $avancement_html .= '
'; $avancement_html .= '
'; $avancement_html .= ''; $avancement_html .= '<<'; $avancement_html .= ' '. _ALL_HISTORY .''; $avancement_html .= ''; $avancement_html .= ''; require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_security.php"); $sec =new security(); //NOTES if ($core->is_module_loaded('notes')){ require_once "modules" . DIRECTORY_SEPARATOR . "notes" . DIRECTORY_SEPARATOR . "class" . DIRECTORY_SEPARATOR . "class_modules_tools.php"; $notes_tools = new notes(); //Count notes $nbr_notes = $notes_tools->countUserNotes($res_id, $coll_id); if ($nbr_notes > 0 ) $nbr_notes = ' ('.$nbr_notes.')'; else $nbr_notes = ''; //Notes iframe $notes_html_dt = _NOTES.$nbr_notes; $notes_html_dd = '

'. _NOTES .'

'; } //PJ $countAttachments = "select res_id from res_view_attachments where status NOT IN ('DEL','OBS') and res_id_master = " . $res_id . " and coll_id = '" . $coll_id . "'"; $dbAttach = new dbquery(); $dbAttach->query($countAttachments); if ($dbAttach->nb_result() > 0) { $nb_attach = ' (' . ($dbAttach->nb_result()). ')'; } $pj_html_dt = _ATTACHED_DOC .$nb_attach; $pj_html_dd = ''; if ($core->is_module_loaded('attachments')) { require 'modules/templates/class/templates_controler.php'; $templatesControler = new templates_controler(); $templates = array(); $templates = $templatesControler->getAllTemplatesForProcess($curdest); $_SESSION['destination_entity'] = $curdest; //var_dump($templates); $pj_html_dd .= '
'; $pj_html_dd .= '
'; $pj_html_dd .= '
'; $pj_html_dd .= '

' . _PJ . ', ' . _ATTACHEMENTS . '

'; $req = new request; $req->connect(); $req->query("select res_id from ".$_SESSION['tablename']['attach_res_attachments'] . " where (status = 'A_TRA' or status = 'TRA') and res_id_master = " . $res_id . " and coll_id = '" . $coll_id . "'"); //$req->show(); $nb_attach = 0; if ($req->nb_result() > 0) { $nb_attach = $req->nb_result(); } $pj_html_dd .= '
'; $pj_html_dd .= '
'; if ($core->is_module_loaded('templates')) { $pj_html_dd .= ''; } $pj_html_dd .= '
'; $pj_html_dd .= '
'; $pj_html_dd .= '
'; $pj_html_dd .= '
'; $pj_html_dd .= '
'; $pj_html_dd .= '
'; } /* Partie droite */ $right_html = ''; $right_html .= '
Dossier
'; $right_html .= '
'; $right_html .= '

Contenu du dossier de réponse

'; $right_html .= '

Requérent : '.$data['contact'].'

'; $right_html .= '

Objet : '.$data['subject'].'

'; $right_html .= '
'; $tab_attach_file = get_attach_path($res_id, $coll_id); $right_html .= ''; $right_html .= ''; $right_html .= ''; if ($data['category_id']['value'] == "incoming"){ $right_html .= ''; $right_html .= ''; } else{ $right_html .= ''; $right_html .= ''; } $currentStat = ""; $bordereauExists = false; for ($i=0; $i'.$tab_attach_file[$i]['title'].''; } if (!$bordereauExists){ $right_html .= ""; $right_html .= ''; } $tab_notes = getNotes($res_id); if (count($tab_notes) > 0){ $right_html .= ''; foreach($tab_notes as $note){ $auteur = getInfosUser($note['user_id']); $right_html .= ''; } } $right_html .= ''; $right_html .= '
TitreRédacteurDate

+ Courrier entrant

'.$data['subject'].''.$data['contact'].''.$data['doc_date'].'

+ Courrier sortant

'.$data['subject'].''.$typist.''.$data['doc_date'].'
'.$auteur['prenom'].' '.$auteur['nom'].''.$tab_attach_file[$i]['date'].'

+ Générer la fiche de circulation

+ Notes

'.$note['note_text'].''.$auteur['prenom'].' '.$auteur['nom'].''.$note['date_note'].'
'; $right_html .= '
'; $right_html .= '
'; $right_html = str_replace("'", "\\'",$right_html); //Onglet Circuit $right_html .= '
Circuit de visa
'; $right_html .= '

Circuit de visa

'; $modifVisaWorkflow = false; if ($core->test_service('config_visa_workflow', 'visa', false)) { $modifVisaWorkflow = true; } $visa = new visa(); $right_html .= '
'; $right_html .= '
'; $right_html .= str_replace("'", "\\'", $visa->getList($res_id, $coll_id, $modifVisaWorkflow, 'VISA_CIRCUIT')); $right_html .= '

'; $right_html .= '
'; $right_html .= '
'; $right_html .= ''; $right_html .= '<<'; $right_html .= ' Historique du circuit de visa'; $right_html .= ''; $right_html .= ''; $right_html .= '
'; $valid_but = 'valid_action_form( \\\'index_file\\\', \\\'index.php?display=true&page=manage_action&module=core\\\', \\\''.$_REQUEST['action'].'\\\', \\\''.$res_id.'\\\', \\\'res_letterbox\\\', \\\'null\\\', \\\''.$coll_id.'\\\', \\\'page\\\');'; echo "{status : 4,notes_dt:'".$notes_html_dt."',notes_dd:'".$notes_html_dd."',pj_dt:'".$pj_html_dt."',pj_dd:'".$pj_html_dd."',avancement:'".$avancement_html."',right_html:'".$right_html."',valid_button:'".$valid_but."'}"; exit(); ?>