diff --git a/apps/maarch_entreprise/actions/sendToExternalSignatureBook.php b/apps/maarch_entreprise/actions/sendToExternalSignatureBook.php index 6d98306e05db3f555140c77cc60c76b6f015b60b..89e975772c3ce7699764502c6fc3f17826923faa 100644 --- a/apps/maarch_entreprise/actions/sendToExternalSignatureBook.php +++ b/apps/maarch_entreprise/actions/sendToExternalSignatureBook.php @@ -1,5 +1,17 @@ <?php +/** +* Copyright Maarch since 2008 under licence GPLv3. +* See LICENCE.txt file at the root folder for more details. +* This file is part of Maarch software. + +* +* @brief sendToExternalSignatureBok +* +* @author dev <dev@maarch.org> +* @ingroup visa +*/ + $confirm = true; $frm_width = '400px'; $frm_height = 'auto'; @@ -13,6 +25,19 @@ if ($isMailingAttach != false) { $warnMsg = $isMailingAttach['nbContacts'] . " " . _RESPONSES_WILL_BE_GENERATED; } +$error_visa_workflow_signature_book = false; +$attachments = \Attachment\models\AttachmentModel::getOnView([ + 'select' => [ + 'count(1) as nb' + ], + 'where' => ["res_id_master = ?", "attachment_type not in (?)", "status not in ('DEL', 'OBS', 'FRZ', 'TMP')", "in_signature_book = 'true'"], + 'data' => [$_SESSION['doc_id'], ['converted_pdf', 'incoming_mail_attachment', 'print_folder', 'signed_response']] +]); + +if ($attachments[0]['nb'] == 0) { + $error_visa_workflow_signature_book = true; +} + function get_form_txt($values, $path_manage_action, $id_action, $table, $module, $coll_id, $mode) { $db = new Database(); diff --git a/core/manage_action.php b/core/manage_action.php index 2ad84448f41b6b9617ed4d990ab2212185d42ac1..934357edbf43f5239fea8f30b650c373a1ef01db 100755 --- a/core/manage_action.php +++ b/core/manage_action.php @@ -42,19 +42,17 @@ $res_action = array(); */ function get_values_in_array($val) { - $tab = explode('$$',$val); + $tab = explode('$$', $val); $values = array(); - for($i=0; $i<count($tab);$i++) - { + for ($i=0; $i<count($tab);$i++) { $tmp = explode('#', $tab[$i]); $val_tmp=array(); - for($idiese=1;$idiese<count($tmp);$idiese++){ - $val_tmp[]=$tmp[$idiese]; - } - $valeurDiese = implode("#",$val_tmp); - if(isset($tmp[1])) - { + for ($idiese=1;$idiese<count($tmp);$idiese++) { + $val_tmp[]=$tmp[$idiese]; + } + $valeurDiese = implode("#", $val_tmp); + if (isset($tmp[1])) { array_push($values, array('ID' => $tmp[0], 'VALUE' => $valeurDiese)); } } @@ -62,15 +60,12 @@ function get_values_in_array($val) } // Form validation -if($_POST['req'] == 'valid_form' && !empty($_POST['action_id']) && isset($_POST['action_id']) && !empty($_POST['form_to_check'])&& isset($_POST['form_to_check'])) -{ - +if ($_POST['req'] == 'valid_form' && !empty($_POST['action_id']) && isset($_POST['action_id']) && !empty($_POST['form_to_check'])&& isset($_POST['form_to_check'])) { $id_action = $_POST['action_id']; // Gets the action informations from the database $stmt = $db->query("select * from ".$_SESSION['tablename']['actions']." where id = ?", array($id_action)); - if($stmt->rowCount() < 1) - { + if ($stmt->rowCount() < 1) { $_SESSION['action_error'] = _ACTION_NOT_IN_DB; echo "{status : 5, error_txt : '".addslashes(functions::xssafe($_SESSION['action_error']))."'}"; exit(); @@ -80,16 +75,15 @@ if($_POST['req'] == 'valid_form' && !empty($_POST['action_id']) && isset($_POST[ $label_action = $res->label_action; $status = $res->id_status; $action_page = $res->action_page; - if($res->history == 'Y' && $_POST['hist']!='N'){ + if ($res->history == 'Y' && $_POST['hist']!='N') { $bool_history = $res->history; - }else{ + } else { $bool_history = 'N'; } $create_id = $res->create_id; - //No script defined for this action - if($action_page == '') - { + //No script defined for this action + if ($action_page == '') { $_SESSION['action_error'] = _ACTION_NOT_IN_DB; echo "{status : 5, error_txt : '".addslashes(functions::xssafe($_SESSION['action_error']))."'}"; exit(); @@ -97,22 +91,15 @@ if($_POST['req'] == 'valid_form' && !empty($_POST['action_id']) && isset($_POST[ $custom_path = ''; $path_action_page = $core->get_path_action_page($action_page); - if(isset($_SESSION['custom_override_id']) && !empty($_SESSION['custom_override_id'])) - { + if (isset($_SESSION['custom_override_id']) && !empty($_SESSION['custom_override_id'])) { $custom_path = 'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR.$path_action_page; } - if($custom_path <> '' && file_exists($_SESSION['config']['corepath'].$custom_path)) - { + if ($custom_path <> '' && file_exists($_SESSION['config']['corepath'].$custom_path)) { include($custom_path); - } - else - { - if(file_exists($path_action_page)) - { + } else { + if (file_exists($path_action_page)) { include($path_action_page); - } - else - { + } else { // Invalid path to script $_SESSION['action_error'] = $label_action.' '._ACTION_PAGE_MISSING; echo "{status : 8, error_txt: '".addslashes(functions::xssafe($_SESSION['action_error']))."'}"; @@ -121,40 +108,33 @@ if($_POST['req'] == 'valid_form' && !empty($_POST['action_id']) && isset($_POST[ } - $frm_error = check_form(trim($_POST['form_to_check']),get_values_in_array($_POST['form_values'])); - if($frm_error == false) - { + $frm_error = check_form(trim($_POST['form_to_check']), get_values_in_array($_POST['form_values'])); + if ($frm_error == false) { echo "{status : 1, error_txt : '".addslashes(functions::xssafe($_SESSION['action_error']))."'}"; exit(); - } - else - { - if($create_id == 'N') - { + } else { + if ($create_id == 'N') { echo "{status : 0, error_txt : '".addslashes(functions::xssafe($_SESSION['action_error']))."', page_result : '', manage_form_now : false}"; - } - else - { + } else { echo "{status : 0, error_txt : '".addslashes(functions::xssafe($_SESSION['action_error']))."', page_result : '', manage_form_now : true}"; } exit(); } -} -elseif(trim($_POST['req']) == 'change_status' && !empty($_POST['values']) && !empty($_POST['new_status']) && !empty($_POST['table'])){ +} elseif (trim($_POST['req']) == 'change_status' && !empty($_POST['values']) && !empty($_POST['new_status']) && !empty($_POST['table'])) { $stmt = $db->query("select id, label_status from status where id = ?", array($_POST['new_status'])); $lineStatus = $stmt->fetchObject(); if ($lineStatus->id <> '') { $arr_id = explode(',', $_POST['values']); $result = ''; - for ($i=0; $i<count($arr_id );$i++) { + for ($i=0; $i<count($arr_id);$i++) { $arr_id[$i] = str_replace('#', '', $arr_id[$i]); $result .= $arr_id[$i].'#'; if (trim($_POST['new_status']) <> '' && is_numeric($arr_id[$i])) { if ($_POST['table'] == 'folders') { - $query_str = "update " . $_POST['table'] + $query_str = "update " . $_POST['table'] . " set status = ? where folders_system_id = ?"; } else { - $query_str = "update " . $_POST['table'] + $query_str = "update " . $_POST['table'] . " set status = ? where res_id = ?"; } $stmt = $db->query($query_str, array($_POST['new_status'], $arr_id[$i])); @@ -173,10 +153,9 @@ elseif(trim($_POST['req']) == 'change_status' && !empty($_POST['values']) && !em } } // Post variables error -else if(empty($_POST['values']) || !isset($_POST['action_id']) || empty($_POST['action_id']) || +elseif (empty($_POST['values']) || !isset($_POST['action_id']) || empty($_POST['action_id']) || ($_POST['mode'] <> 'mass' && $_POST['mode'] <> 'page') || empty($_POST['table']) -|| empty($_POST['coll_id']) || empty($_POST['module']) || ($_POST['req'] <> 'first_request' && $_POST['req'] <> 'second_request' && $_POST['req'] <> 'change_status')) -{ +|| empty($_POST['coll_id']) || empty($_POST['module']) || ($_POST['req'] <> 'first_request' && $_POST['req'] <> 'second_request' && $_POST['req'] <> 'change_status')) { $tmp = 'values : '.$_POST['values'].', action_id : '.$_POST['action_id'].', mode : '. $_POST['mode'].', table : '.$_POST['table'].', coll_id : '.$_POST['coll_id'].', module : '.$_POST['module'].', req : '.$_POST['req']; $_SESSION['action_error'] = $tmp._AJAX_PARAM_ERROR; echo "{status : 1, error_txt : '".functions::xssafe($id_action).addslashes(functions::xssafe($_SESSION['action_error']))."'}"; @@ -197,25 +176,22 @@ else if(empty($_POST['values']) || !isset($_POST['action_id']) || empty($_POST[' $label_action = $res->label_action; $status = $res->id_status; $action_page = $res->action_page; - if($res->history == 'Y' && $_POST['hist']!='N'){ + if ($res->history == 'Y' && $_POST['hist']!='N') { $bool_history = $res->history; - }else{ + } else { $bool_history = 'N'; } //No script defined for this action - if($action_page == '') - { + if ($action_page == '') { //If second request : Error - if($_POST['req'] == 'second_request') - { + if ($_POST['req'] == 'second_request') { $_SESSION['action_error'] = _ACTION_NOT_IN_DB; echo "{status : 5, error_txt : '".addslashes(functions::xssafe($_SESSION['action_error']))."'}"; exit(); } //If no status defined in the action file , error - if($status == '' || $status == 'NONE') - { + if ($status == '' || $status == 'NONE') { $_SESSION['action_error'] = $label_action.' : '._ERROR_PARAM_ACTION; echo "{status : 6, error_txt : '".functions::xssafe(addslashes($_SESSION['action_error']))."'}"; exit(); @@ -225,21 +201,21 @@ else if(empty($_POST['values']) || !isset($_POST['action_id']) || empty($_POST[' if ($lineStatus->id <> '') { // Update the status $result = ''; - for ($i=0;$i<count($arr_id );$i++) { + for ($i=0;$i<count($arr_id);$i++) { $arr_id[$i] = str_replace('#', '', $arr_id[$i]); $result .= $arr_id[$i].'#'; if (trim($status) <> '') { if ($_POST['table'] == 'folders') { - $query_str = "update " . $_POST['table'] + $query_str = "update " . $_POST['table'] . " set status = ? where folders_system_id = ?"; } else { - $query_str = "update " . $_POST['table'] + $query_str = "update " . $_POST['table'] . " set status = ? where res_id = ?"; } $stmt = $db->query($query_str, array($status, $arr_id[$i])); if (!$stmt) { $_SESSION['action_error'] = _SQL_ERROR . ' : ' . $query_str; - echo "{status : 7, error_txt : '" . addslashes(functions::xssafe($label_action) + echo "{status : 7, error_txt : '" . addslashes(functions::xssafe($label_action) . ' : ' . functions::xssafe($_SESSION['action_error'])) . "'}"; exit(); } @@ -252,27 +228,19 @@ else if(empty($_POST['values']) || !isset($_POST['action_id']) || empty($_POST[' .functions::xssafe($status).", ".functions::xssafe($_POST['values'])."', page_result : ''}"; } // There is a script for the action - else - { + else { $custom_path = ''; $path_action_page = $core->get_path_action_page($action_page); - if(isset($_SESSION['custom_override_id']) && !empty($_SESSION['custom_override_id'])) - { + if (isset($_SESSION['custom_override_id']) && !empty($_SESSION['custom_override_id'])) { $custom_path = 'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR.$path_action_page; } - if($custom_path <> '' && file_exists($_SESSION['config']['corepath'].$custom_path)) - { + if ($custom_path <> '' && file_exists($_SESSION['config']['corepath'].$custom_path)) { include($custom_path); - } - else - { - if(file_exists($path_action_page)) - { + } else { + if (file_exists($path_action_page)) { include($path_action_page); - } - else - { + } else { // Invalid path to script $_SESSION['action_error'] = $label_action.' '._ACTION_PAGE_MISSING; echo "{status : 8, error_txt: '".addslashes(functions::xssafe($_SESSION['action_error']))."'}"; @@ -280,116 +248,82 @@ else if(empty($_POST['values']) || !isset($_POST['action_id']) || empty($_POST[' } } - if($_POST['req'] == 'first_request' && in_array('form', $etapes)) - { - $frm_test = get_form_txt($arr_id, $_SESSION['config']['businessappurl'].'index.php?display=true&page=manage_action&module=core', $id_action, $_POST['table'],$_POST['module'], $_POST['coll_id'], $_POST['mode'] ); + if ($_POST['req'] == 'first_request' && in_array('form', $etapes) && $error_visa_workflow_signature_book != true) { + $frm_test = get_form_txt($arr_id, $_SESSION['config']['businessappurl'].'index.php?display=true&page=manage_action&module=core', $id_action, $_POST['table'], $_POST['module'], $_POST['coll_id'], $_POST['mode']); echo "{status : 3, form_content : '".$frm_test."', height : '".$frm_height."', width : '".$frm_width."', 'mode_frm' : '".$mode_form."', 'action_status' : '".functions::xssafe($status)."'}"; exit(); - } - elseif( $_POST['req'] == 'first_request' && in_array('no_attachment',$etapes)) - { + } elseif ($_POST['req'] == 'first_request' && in_array('no_attachment', $etapes)) { echo "{status : 3, form_content : '<div class=\"h2_title\">" . addslashes(_ADD_ATTACHMENT_TO_SEND_TO_CONTACT) . "</div><p class=\"buttons\"><input type=\"button\" class=\"button\" value=\""._CANCEL."\" onclick=\"destroyModal(\'modal_" .$id_action . "\')\" id=\"submit\" name=\"submit\"></p>', height : '250px', width : '300px', 'mode_frm' : '', validate : 'OK', 'action_status' : '".functions::xssafe($status)."'}"; exit(); - } - elseif( $_POST['req'] == 'first_request' && $error_visa_workflow_signature_book == true) - { + } elseif ($_POST['req'] == 'first_request' && $error_visa_workflow_signature_book == true) { echo "{status : 4, error : '".addslashes(_NO_RESPONSE_PROJECT_VISA)."', validate : 'OK', 'action_status' : '".functions::xssafe($status)."'}"; exit(); - } - elseif( $_POST['req'] == 'first_request' && $error_visa == true) - { + } elseif ($_POST['req'] == 'first_request' && $error_visa == true) { echo "{status : 4, error : '".addslashes(_NO_VISA)."', validate : 'OK', 'action_status' : '".functions::xssafe($status)."'}"; exit(); - } - elseif( $_POST['req'] == 'first_request' && $error_visa_response_project == true) - { + } elseif ($_POST['req'] == 'first_request' && $error_visa_response_project == true) { echo "{status : 3, form_content : '<div class=\"h2_title\">" . addslashes($visa->errorMessageVisa) . "</div><p class=\"buttons\"><input type=\"button\" onclick=\"destroyModal(\'modal_" .$id_action . "\')\" class=\"button\" value=\"OK\" id=\"submit\" name=\"submit\"></p>', height : 'auto', width : 'auto', 'mode_frm' : '', validate : 'OK', 'action_status' : '".functions::xssafe($status)."'}"; exit(); - } - elseif( $_POST['req'] == 'first_request' && $error_visa_workflow == true) - { + } elseif ($_POST['req'] == 'first_request' && $error_visa_workflow == true) { echo "{status : 4, error : '".addslashes(_NO_NEXT_STEP_VISA)."', validate : 'OK', 'action_status' : '".functions::xssafe($status)."'}"; exit(); - } - elseif( $_POST['req'] == 'first_request' && $confirm == true) - { + } elseif ($_POST['req'] == 'first_request' && $confirm == true) { if (!empty($warnMsg)) { echo "{status : 2, confirm_content : '".addslashes("<p style='font-size: 12px;text-align: center;color: white;background: #F99830;padding: 5px;margin: -10px -10px 20px -10px;'><i class='fa fa-exclamation-triangle'></i> ".$warnMsg."<p>"._ACTION_CONFIRM." ".functions::xssafe($label_action))."', validate : '"._VALIDATE."', cancel : '"._CANCEL."', label_action : '".addslashes(functions::xssafe($label_action))."', 'action_status' : '".functions::xssafe($status)."'}"; } else { echo "{status : 2, confirm_content : '".addslashes(_ACTION_CONFIRM." ".functions::xssafe($label_action))."', validate : '"._VALIDATE."', cancel : '"._CANCEL."', label_action : '".addslashes(functions::xssafe($label_action))."', 'action_status' : '".functions::xssafe($status)."'}"; } exit(); - } - elseif( $_POST['req'] == 'first_request' && $confirm == false && $action_page == 'close_mail_with_attachment') - { + } elseif ($_POST['req'] == 'first_request' && $confirm == false && $action_page == 'close_mail_with_attachment') { echo "{status : 3, form_content : '<div class=\"h2_title\">" . addslashes(_ADD_ATTACHMENT_OR_NOTE) . "</div><p class=\"buttons\"><input type=\"button\" class=\"button\" value=\""._CANCEL."\" onclick=\"destroyModal(\'modal_" .$id_action . "\')\" id=\"submit\" name=\"submit\"></p>', height : '250px', width : '300px', 'mode_frm' : '', validate : 'OK', 'action_status' : '".functions::xssafe($status)."'}"; exit(); - } - else - { - if($confirm == false) - { + } else { + if ($confirm == false) { $_SESSION['action_error'] = $label_action.' : '._ERROR_SCRIPT; } - for($i=0; $i<count($etapes);$i++) - { - if($etapes[$i] <> 'status') - { - if( function_exists('manage_'.$etapes[$i]) ) - { - try - { - if($_POST['req'] == 'second_request') - { - $res_action = call_user_func('manage_'.$etapes[$i],$arr_id, $bool_history, $id_action, $label_action, $status, $_POST['coll_id'], $_POST['table'], get_values_in_array($_POST['form_values']) ); + for ($i=0; $i<count($etapes);$i++) { + if ($etapes[$i] <> 'status') { + if (function_exists('manage_'.$etapes[$i])) { + try { + if ($_POST['req'] == 'second_request') { + $res_action = call_user_func('manage_'.$etapes[$i], $arr_id, $bool_history, $id_action, $label_action, $status, $_POST['coll_id'], $_POST['table'], get_values_in_array($_POST['form_values'])); + } else { + $res_action = call_user_func('manage_'.$etapes[$i], $arr_id, $bool_history, $id_action, $label_action, $status, $_POST['coll_id'], $_POST['table']); } - else - { - $res_action = call_user_func('manage_'.$etapes[$i],$arr_id, $bool_history, $id_action, $label_action, $status, $_POST['coll_id'], $_POST['table']); - } - } - catch(Exception $e) - { + } catch (Exception $e) { echo "{status : 9, error_txt : '".addslashes(functions::xssafe($_SESSION['action_error']))."'}"; exit(); } - } - else - { + } else { echo "{status : 9, error_txt : '".addslashes(functions::xssafe($_SESSION['action_error']))."'}"; exit(); } } } //print_r($res_action); - if($res_action == false) - { + if ($res_action == false) { echo "{status : 9, error_txt : '".addslashes(functions::xssafe($_SESSION['action_error']))."'}"; exit(); } $comp = ", page_result : ''"; - if(isset($res_action['page_result']) && !empty($res_action['page_result'])) - { + if (isset($res_action['page_result']) && !empty($res_action['page_result'])) { $comp = ", page_result : '".$res_action['page_result']."'"; } - if(isset($res_action['table_dest']) && !empty($res_action['table_dest'])) - { + if (isset($res_action['table_dest']) && !empty($res_action['table_dest'])) { $comp .= ", table : '".$res_action['table_dest']."'"; } - - - if(isset($res_action['newResultId']) && !empty($res_action['newResultId'])) - { + + + if (isset($res_action['newResultId']) && !empty($res_action['newResultId'])) { $comp .= ", newResultId : '".$res_action['newResultId']."'"; } - if(isset($res_action['action_status']) && !empty($res_action['action_status'])) - { + if (isset($res_action['action_status']) && !empty($res_action['action_status'])) { $comp .= ", action_status : '".$res_action['action_status']."'"; } - + $_SESSION['action_error'] = _ACTION_DONE.' : '.$label_action; echo "{status : 0, error_txt : '".addslashes(functions::xssafe($_SESSION['action_error']))."'".$comp.", result_id : '".$res_action['result']."'}"; } @@ -399,64 +333,60 @@ else if(empty($_POST['values']) || !isset($_POST['action_id']) || empty($_POST[' require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_history.php"); $hist = new history(); $arr_res = explode('#', $res_action['result']); - if(!is_array($res_action['history_msg'])){ + if (!is_array($res_action['history_msg'])) { $res_action['history_msg'] = [$res_action['history_msg']]; } - for($i=0; $i<count($arr_res);$i++) - { - if(!empty($arr_res[$i])) - { - if(is_numeric($arr_res[$i])){ + for ($i=0; $i<count($arr_res);$i++) { + if (!empty($arr_res[$i])) { + if (is_numeric($arr_res[$i])) { $docLocker = new docLocker($arr_res[$i]); - $docLocker->unlock(); + $docLocker->unlock(); } // Save action in history if needed - if($bool_history=='Y') - { + if ($bool_history=='Y') { $what = ''; if (isset($_SESSION['current_basket']['id']) && !empty($_SESSION['current_basket']['id'])) { - if(isset($_SESSION['current_basket']['basket_owner']) && !empty($_SESSION['current_basket']['basket_owner'])){ - + if (isset($_SESSION['current_basket']['basket_owner']) && !empty($_SESSION['current_basket']['basket_owner'])) { $pos =stripos($_SESSION['current_basket']['id'], $_SESSION['current_basket']['basket_owner']); $string = substr($_SESSION['current_basket']['id'], 0, $pos -1); $stmt = $db->query("SELECT basket_name FROM baskets WHERE basket_id = ?", array($string)); - while($data = $stmt->fetchObject()) { - $what = $data->basket_name; - $what .= " (".$_SESSION['current_basket']['basket_owner'].")"; + while ($data = $stmt->fetchObject()) { + $what = $data->basket_name; + $what .= " (".$_SESSION['current_basket']['basket_owner'].")"; } - - }else{ + } else { $stmt = $db->query("SELECT basket_name FROM baskets WHERE basket_id = ?", array($_SESSION['current_basket']['id'])); - while($data = $stmt->fetchObject()) { - $what = $data->basket_name; + while ($data = $stmt->fetchObject()) { + $what = $data->basket_name; } - } $what .= ' : '; } //$what .= $label_action.'('._NUM.$arr_res[$i].') '; $what .= $label_action; - if(isset($res_action['history_msg'][$i]) && !empty($res_action['history_msg'][$i])) - { + if (isset($res_action['history_msg'][$i]) && !empty($res_action['history_msg'][$i])) { $what .= $res_action['history_msg'][$i]; } $_SESSION['info'] = $what . ' '; $_SESSION['cpt_info_basket'] = 0; - if($_POST['module'] == 'null'){ + if ($_POST['module'] == 'null') { $_POST['module'] = ''; } $hist->add( $_POST['table'], - $arr_res[$i],'ACTION#'.$id_action, $id_action, - $what, $_SESSION['config']['databasetype'], $_POST['module']); + $arr_res[$i], + 'ACTION#'.$id_action, + $id_action, + $what, + $_SESSION['config']['databasetype'], + $_POST['module'] + ); // SEND MESSAGE EXCHANGE REVIEW M2M require_once "modules/sendmail/Controllers/MessageExchangeReviewController.php"; \Sendmail\Controllers\MessageExchangeReviewController::sendMessageExchangeReview(['res_id' => $arr_res[$i], 'action_id' => $id_action]); - - } } } diff --git a/modules/visa/class/IxbusController.php b/modules/visa/class/IxbusController.php index ce51b58f7a564f26e4e9f487efc128f6b4b3411d..b6ec72f91671e0a805ba6ef7b5d1fe5f8dbc7beb 100755 --- a/modules/visa/class/IxbusController.php +++ b/modules/visa/class/IxbusController.php @@ -261,8 +261,8 @@ class IxbusController 'status', 'typist', 'docserver_id', 'path', 'filename', 'creation_date', 'validation_date', 'relation', 'attachment_id_master' ], - 'where' => ["res_id_master = ?", "attachment_type not in (?)", "status not in ('DEL', 'OBS', 'FRZ')", "in_signature_book = 'true'"], - 'data' => [$aArgs['resIdMaster'], ['incoming_mail_attachment', 'print_folder', 'signed_response']] + 'where' => ["res_id_master = ?", "attachment_type not in (?)", "status not in ('DEL', 'OBS', 'FRZ', 'TMP')", "in_signature_book = 'true'"], + 'data' => [$aArgs['resIdMaster'], ['converted_pdf', 'incoming_mail_attachment', 'print_folder', 'signed_response']] ]); $attachmentToFreeze = []; @@ -374,8 +374,8 @@ class IxbusController // Refused if ((string)$etatDossier == $aArgs['config']['data']['ixbusIdEtatRefused']) { $aArgs['idsToRetrieve'][$version][$resId]->status = 'refused'; - $notes = IxbusController::getAnnotations(['config' => $aArgs['config'], 'sessionId' => $sessionId, 'dossier_id' => $value->external_id]); - $aArgs['idsToRetrieve'][$version][$resId]->noteContent = (string)$notes->Annotation; + $notes = IxbusController::getDossier(['config' => $aArgs['config'], 'sessionId' => $sessionId, 'dossier_id' => $value->external_id]); + $aArgs['idsToRetrieve'][$version][$resId]->noteContent = (string)$notes->MotifRefus; // Validated } elseif ((string)$etatDossier == $aArgs['config']['data']['ixbusIdEtatValidated']) { $aArgs['idsToRetrieve'][$version][$resId]->status = 'validated'; @@ -469,6 +469,43 @@ class IxbusController return $response; } + public static function getDossier($aArgs) + { + $xmlPostString = '<?xml version="1.0" encoding="utf-8"?> + <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> + <soap:Body> + <GetDossier xmlns="http://www.srci.fr"> + <messageID>'.$aArgs['dossier_id'].'</messageID> + </GetDossier> + </soap:Body> + </soap:Envelope>'; + + $opts = [ + CURLOPT_URL => $aArgs['config']['data']['url'] . '/parapheurws/service.asmx', + CURLOPT_HTTPHEADER => [ + 'content-type:text/xml;charset=\"utf-8\"', + 'accept:text/xml', + "Cache-Control: no-cache", + "Pragma: no-cache", + "Content-length: ".strlen($xmlPostString), + "Cookie:".$aArgs['sessionId'], + "SOAPAction: \"http://www.srci.fr/GetDossier\"" + ], + CURLOPT_RETURNTRANSFER => true, + CURLOPT_POST => true, + CURLOPT_POSTFIELDS => $xmlPostString + ]; + + $curl = curl_init(); + curl_setopt_array($curl, $opts); + $rawResponse = curl_exec($curl); + + $data = simplexml_load_string($rawResponse); + $response = $data->children('http://schemas.xmlsoap.org/soap/envelope/')->Body->children()->GetDossierResponse->GetDossierResult; + + return $response; + } + public static function getAnnexes($aArgs) { $xmlPostString = '<?xml version="1.0" encoding="utf-8"?>