diff --git a/apps/maarch_entreprise/actions/sendToExternalSignatureBook.php b/apps/maarch_entreprise/actions/sendToExternalSignatureBook.php index b49c09c9d40f0a3efc3f1e41f104b46a4585a294..ec663b8d10dc28e31e54cbf6c94355ce32715c86 100644 --- a/apps/maarch_entreprise/actions/sendToExternalSignatureBook.php +++ b/apps/maarch_entreprise/actions/sendToExternalSignatureBook.php @@ -80,6 +80,10 @@ function get_form_txt($values, $path_manage_action, $id_action, $table, $module, include_once 'modules/visa/class/FastParapheurController.php'; $html .= FastParapheurController::getModal($config); + } elseif ($config['id'] == 'maarchParapheur') { + include_once 'modules/visa/class/MaarchParapheurController.php'; + + $html .= MaarchParapheurController::getModal($config); } } @@ -144,13 +148,32 @@ function manage_form($arr_id, $history, $id_action, $label_action, $status, $col $nature = get_value_fields($values_form, 'nature'); $messageModel = get_value_fields($values_form, 'messageModel'); $manSignature = get_value_fields($values_form, 'mansignature'); - $attachmentToFreeze = IxbusController::sendDatas(['config' => $config, 'resIdMaster' => $res_id, 'loginIxbus' => $loginIxbus, 'passwordIxbus' => $passwordIxbus, 'classeurName' => $nature, 'messageModel' => $messageModel, 'manSignature' => $manSignature]); + $attachmentToFreeze = IxbusController::sendDatas([ + 'config' => $config, 'resIdMaster' => $res_id, + 'loginIxbus' => $loginIxbus, + 'passwordIxbus' => $passwordIxbus, + 'classeurName' => $nature, + 'messageModel' => $messageModel, + 'manSignature' => $manSignature + ]); } elseif ($config['id'] == 'iParapheur') { include_once 'modules/visa/class/IParapheurController.php'; $attachmentToFreeze = IParapheurController::sendDatas(['config' => $config, 'resIdMaster' => $res_id]); } elseif ($config['id'] == 'fastParapheur') { include_once 'modules/visa/class/FastParapheurController.php'; $attachmentToFreeze = FastParapheurController::sendDatas(['config' => $config, 'resIdMaster' => $res_id]); + } elseif ($config['id'] == 'maarchParapheur') { + include_once 'modules/visa/class/MaarchParapheurController.php'; + + $processingUser = get_value_fields($values_form, 'processingUser'); + $mode = get_value_fields($values_form, 'mode'); + $attachmentToFreeze = MaarchParapheurController::sendDatas([ + 'config' => $config, + 'resIdMaster' => $res_id, + 'processingUser' => $processingUser, + 'mode' => $mode, + 'userId' => $_SESSION['user']['UserId'] + ]); } } diff --git a/apps/maarch_entreprise/lang/en.php b/apps/maarch_entreprise/lang/en.php index a3e0690d0a6850167f698c18b23906e79286ac81..f81a507a9917641df6aac3d03b1d2062aa2ddce3 100755 --- a/apps/maarch_entreprise/lang/en.php +++ b/apps/maarch_entreprise/lang/en.php @@ -5055,3 +5055,6 @@ if (!defined('_CONTACTS_USERS_SEARCH')) { if (!defined('_CONTACTS_USERS_GROUPS_SEARCH')) { define('_CONTACTS_USERS_GROUPS_SEARCH', 'Contacts / users / contacts groups search'); } +if (!defined('_USER_MAARCH_PARAPHEUR')) { + define('_USER_MAARCH_PARAPHEUR', 'Maarch Parapheur user'); +} \ No newline at end of file diff --git a/apps/maarch_entreprise/lang/fr.php b/apps/maarch_entreprise/lang/fr.php index 15cca322b1fc2e0f45143609fd52f544e0db0418..ca0a53a9402e534602fba1e5bd74c3fd2c2aa3c0 100755 --- a/apps/maarch_entreprise/lang/fr.php +++ b/apps/maarch_entreprise/lang/fr.php @@ -5217,3 +5217,6 @@ if (!defined('_CONTACTS_USERS_SEARCH')) { if (!defined('_CONTACTS_USERS_GROUPS_SEARCH')) { define('_CONTACTS_USERS_GROUPS_SEARCH', 'Rechercher un contact / utilisateur / groupement de contacts'); } +if (!defined('_USER_MAARCH_PARAPHEUR')) { + define('_USER_MAARCH_PARAPHEUR', 'Utilisateur Maarch Parapheur'); +} \ No newline at end of file diff --git a/apps/maarch_entreprise/xml/config.xml.default b/apps/maarch_entreprise/xml/config.xml.default index 4733e5a56f0498540dce6951f54de4ea8091c153..8246b69467a66791e669878bb153f128ae9a9f2a 100755 --- a/apps/maarch_entreprise/xml/config.xml.default +++ b/apps/maarch_entreprise/xml/config.xml.default @@ -14,7 +14,7 @@ <adminmail>support@maarch.fr</adminmail> <adminname>maarch</adminname> <debug>false</debug> - <applicationname>MAARCH 18.10</applicationname> + <applicationname>MAARCH COURRIER 19.04</applicationname> <defaultPage>welcome</defaultPage> <CookieTime>20</CookieTime> <!-- minutes --> <timezone>Europe/Paris</timezone> diff --git a/modules/notes/lang/en.php b/modules/notes/lang/en.php index 284a556906b4a2e60187917dc71f5a52ae6965a2..2d6b58c72733b544ac53b632ad504679830d635a 100755 --- a/modules/notes/lang/en.php +++ b/modules/notes/lang/en.php @@ -18,41 +18,65 @@ * You should have received a copy of the GNU General Public License * along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. */ -if (!defined("_RESTRICTED_SERVICES")) define("_RESTRICTED_SERVICES", "Service(s) restricted : "); -if (!defined("_VISIBLEBY")) define("_VISIBLEBY", "Visible by"); -if (!defined("_ADD_NOTE")) - define("_ADD_NOTE","Add a note"); -if (!defined("_READ")) +if (!defined("_RESTRICTED_SERVICES")) { + define("_RESTRICTED_SERVICES", "Service(s) restricted : "); +} +if (!defined("_VISIBLEBY")) { + define("_VISIBLEBY", "Visible by"); +} +if (!defined("_ADD_NOTE")) { + define("_ADD_NOTE", "Add a note"); +} +if (!defined("_READ")) { define("_READ", "Read"); -if (!defined("_ADDITION_NOTE")) +} +if (!defined("_ADDITION_NOTE")) { define("_ADDITION_NOTE", "Note addition"); -if (!defined("_ADDITION_NOTE_PRIVATE")) +} +if (!defined("_ADDITION_NOTE_PRIVATE")) { define("_ADDITION_NOTE_PRIVATE", "Private note addition"); -if (!defined("_NOTES_ADDED")) +} +if (!defined("_NOTES_ADDED")) { define("_NOTES_ADDED", "Added note"); -if (!defined("_NOTES_DELETED")) +} +if (!defined("_NOTES_DELETED")) { define("_NOTES_DELETED", "Deleted note"); -if (!defined("_NOTES_MODIFIED")) +} +if (!defined("_NOTES_MODIFIED")) { define("_NOTES_MODIFIED", "Modified note"); -if (!defined("_NOTE_UPDATED")) +} +if (!defined("_NOTE_UPDATED")) { define("_NOTE_UPDATED", "Modified note"); -if (!defined("_NOTES")) +} +if (!defined("_NOTES")) { define("_NOTES", "Notes"); -if (!defined("_NOTES_COMMENT")) +} +if (!defined("_NOTES_COMMENT")) { define("_NOTES_COMMENT", "Notes"); -if (!defined("_OF")) +} +if (!defined("_OF")) { define("_OF", "of"); -if (!defined("_NOTE_DONT_EXIST")) +} +if (!defined("_NOTE_DONT_EXIST")) { define("_NOTE_DONT_EXIST", "This note doesn't exist"); -if (!defined("_THIS_NOTE_IS_VISIBLE_BY")) +} +if (!defined("_THIS_NOTE_IS_VISIBLE_BY")) { define("_THIS_NOTE_IS_VISIBLE_BY", "Limit this note to the following departments (if it's empty, the note is public)"); +} //TEMPLATES FOR NOTES -if (!defined("_NOTE_TEMPLATE")) +if (!defined("_NOTE_TEMPLATE")) { define("_NOTE_TEMPLATE", "Note template"); -if (!defined("_SELECT_NOTE_TEMPLATE")) +} +if (!defined("_SELECT_NOTE_TEMPLATE")) { define("_SELECT_NOTE_TEMPLATE", "Select a note template"); +} //SERVICES FOR NOTES -if (!defined("_NOTES_RESTRICTION")) +if (!defined("_NOTES_RESTRICTION")) { define("_NOTES_RESTRICTION", "By default, limit the notes to your department"); +} + +if (!defined("_NOTE")) { + define("_NOTE", "Note"); +} diff --git a/modules/notes/lang/fr.php b/modules/notes/lang/fr.php index 8708f38b794fe656e9a142dfe1ea710cba86dd19..1ae3bbaf22c1fc94507277f1bdaca81df1dee025 100755 --- a/modules/notes/lang/fr.php +++ b/modules/notes/lang/fr.php @@ -76,3 +76,7 @@ if (!defined("_SELECT_NOTE_TEMPLATE")) { if (!defined("_NOTES_RESTRICTION")) { define("_NOTES_RESTRICTION", "Restreindre par défaut les annotations à votre entité"); } + +if (!defined("_NOTE")) { + define("_NOTE", "Annotation"); +} diff --git a/modules/visa/batch/config/config.xml.default b/modules/visa/batch/config/config.xml.default index d36fa85f0736eab7d79f5dad635347f2825f2fbc..48509fc83bcd5e0d8f68ab03c4192b7edd3dbfda 100755 --- a/modules/visa/batch/config/config.xml.default +++ b/modules/visa/batch/config/config.xml.default @@ -2,7 +2,7 @@ <ROOT> <CONFIG> <MaarchDirectory>/var/www/html/maarchdev/</MaarchDirectory> - <CustomId>cs_maarchdev_last</CustomId> + <CustomId>cs_maarchdev_last</CustomId> <validatedStatus>VAL</validatedStatus> <refusedStatus>COU</refusedStatus> <applicationUrl>http://localhost/maarchdev/</applicationUrl> diff --git a/modules/visa/batch/process_mailsFromSignatoryBook.php b/modules/visa/batch/process_mailsFromSignatoryBook.php index 966305654c4362edd71f4a72bbfd3079e44f21af..c0f915486cd2e689380e3732ddb745821b2e467c 100755 --- a/modules/visa/batch/process_mailsFromSignatoryBook.php +++ b/modules/visa/batch/process_mailsFromSignatoryBook.php @@ -182,6 +182,8 @@ try { $signatoryBook = "/modules/visa/class/IParapheurController.php"; } elseif ($configRemoteSignatoryBook['id'] == 'fastParapheur') { $signatoryBook = "/modules/visa/class/FastParapheurController.php"; + } elseif ($configRemoteSignatoryBook['id'] == 'maarchParapheur') { + $signatoryBook = "/modules/visa/class/MaarchParapheurController.php"; } } else { $GLOBALS['logger']->write('no signatory book enabled', 'ERROR', 102); @@ -251,6 +253,8 @@ if ($configRemoteSignatoryBook['id'] == 'ixbus') { $retrievedMails = IParapheurController::retrieveSignedMails(['config' => $configRemoteSignatoryBook, 'idsToRetrieve' => $idsToRetrieve]); } elseif ($configRemoteSignatoryBook['id'] == 'fastParapheur') { $retrievedMails = FastParapheurController::retrieveSignedMails(['config' => $configRemoteSignatoryBook, 'idsToRetrieve' => $idsToRetrieve]); +} elseif ($configRemoteSignatoryBook['id'] == 'maarchParapheur') { + $retrievedMails = MaarchParapheurController::retrieveSignedMails(['config' => $configRemoteSignatoryBook, 'idsToRetrieve' => $idsToRetrieve]); } // On dégele les pj et on créé une nouvelle ligne si le document a été signé diff --git a/modules/visa/class/MaarchParapheurController.php b/modules/visa/class/MaarchParapheurController.php new file mode 100644 index 0000000000000000000000000000000000000000..254ba254f5366ddc6032d8abd516496acae0e398 --- /dev/null +++ b/modules/visa/class/MaarchParapheurController.php @@ -0,0 +1,373 @@ +<?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 MaarchParapheur Controller + * @author dev@maarch.org + */ + + +class MaarchParapheurController +{ + public static function getModal($config) + { + $initializeDatas = MaarchParapheurController::getInitializeDatas($config); + + $html .= '<label for="nature">' . _USERS . '</label><select name="nature" id="nature">'; + if (!empty($initializeDatas['users'])) { + foreach ($initializeDatas['users'] as $value) { + $html .= '<option value="'; + $html .= $value['id']; + $html .= '">'; + $html .= $value['firstname'] . ' ' . $value['lastname']; + $html .= '</option>'; + } + } + $html .= '</select><br /><br />'; + + // $html .= '<label for="messageModel">' . _WORKFLOW_MODEL_IXBUS . '</label><select name="messageModel" id="messageModel">'; + // foreach ($initializeDatas['messagesModel'] as $value) { + // $html .= '<option value="'; + // $html .= $value; + // $html .= '">'; + // $html .= $value; + // $html .= '</option>'; + // } + // $html .= '</select><br /><br />'; + // $html .= '<label for="loginIxbus">'._ID_IXBUS.'</label><input name="loginIxbus" id="loginIxbus"/><br /><br />'; + // $html .= '<label for="passwordIxbus">'._PASSWORD_IXBUS.'</label><input type="password" name="passwordIxbus" id="passwordIxbus"/><br /><br />'; + // $html .= _ESIGN . '<input type="radio" name="mansignature" id="mansignature" value="false" checked="checked" />' . _HANDWRITTEN_SIGN .'<input type="radio" name="mansignature" id="mansignature" value="true" /><br /><br />'; + + return $html; + } + + public static function getInitializeDatas($config) + { + $rawResponse['users'] = MaarchParapheurController::getUsers(['config' => $config]); + // $rawResponse['usersList'] = IxbusController::getUsersList(['config' => $config, 'sessionId' => $sessionId]); + // $messagesModels = IxbusController::getMessagesModel(['config' => $config, 'sessionId' => $sessionId]); + + // $rawResponse['messagesModel'] = []; + // if (!empty($rawResponse['natures']->Classeur)) { + // foreach ($rawResponse['natures']->Classeur as $nature) { + // foreach ($messagesModels->Message as $message) { + // if ($message->Identifiant == 392213) { + // $messageModel = IxbusController::getMessageNature(['config' => $config, 'messageId' => $message->Identifiant, 'sessionId' => $sessionId]); + // if ((string)$messageModel->IdentifiantClasseur == (string)$nature->Identifiant) { + // $rawResponse['messagesModel'][(string)$messageModel->IdentifiantMessage] = (string)$message->IdentifiantSpecifique; + // } + // } + // } + // } + // } + + return $rawResponse; + } + + public static function getUsers($aArgs) + { + $response = \SrcCore\models\CurlModel::exec(['url' => $aArgs['config']['data']['url'] . '/rest/users', 'user' => $aArgs['config']['data']['userId'], 'password' => $aArgs['config']['data']['password'], 'method' => 'GET']); + + return $response['users']; + } + + public static function sendDatas($aArgs) + { + $sessionId = IxbusController::createSession($aArgs['config']); + $userInfo = IxbusController::getInfoUtilisateur(['config' => $aArgs['config'], 'login' => $aArgs['loginIxbus'], 'password' => $aArgs['passwordIxbus']]); + + $attachments = \Attachment\models\AttachmentModel::getOnView([ + 'select' => [ + 'res_id', 'res_id_version', 'title', 'identifier', 'attachment_type', + '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', 'TMP')", "in_signature_book = 'true'"], + 'data' => [$aArgs['resIdMaster'], ['converted_pdf', 'incoming_mail_attachment', 'print_folder', 'signed_response']] + ]); + + $attachmentToFreeze = []; + + foreach ($attachments as $value) { + if (!empty($value['res_id'])) { + $resId = $value['res_id']; + $collId = 'attachments_coll'; + } else { + $resId = $value['res_id_master']; + $collId = 'attachments_version_coll'; + } + $adrInfo = \Convert\models\AdrModel::getConvertedDocumentById(['resId' => $resId, 'collId' => $collId, 'type' => 'PDF']); + $docserverInfo = \Docserver\models\DocserverModel::getByDocserverId(['docserverId' => $adrInfo['docserver_id']]); + $filePath = $docserverInfo['path_template'] . str_replace('#', '/', $adrInfo['path']) . $adrInfo['filename']; + + $encodedZipFile = IxbusController::createZip(['filepath' => $filePath, 'filename' => $adrInfo['filename'], 'res_id_master' => $aArgs['resIdMaster']]); + + $mainResource = \Resource\models\ResModel::getExtById(['resId' => $aArgs['resIdMaster'], 'select' => ['process_limit_date']]); + if (empty($mainResource['process_limit_date'])) { + $processLimitDate = date('Y-m-d', strtotime(date("Y-m-d"). ' + 14 days')); + } else { + $processLimitDateTmp = explode(" ", $mainResource['process_limit_date']); + $processLimitDate = $processLimitDateTmp[0]; + } + + $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> + <SendDossier xmlns="http://www.srci.fr"> + <ContenuDocumentZip>'. $encodedZipFile .'</ContenuDocumentZip> + <NomDocumentPrincipal>'. $adrInfo['filename'] . '</NomDocumentPrincipal> + <NomDossier>'. $value['title'] .'</NomDossier> + <NomModele>'. $aArgs['messageModel'] .'</NomModele> + <NomNature>'. $aArgs['classeurName'] .'</NomNature> + <DateLimite>'.$processLimitDate.'</DateLimite> + <LoginResponsable>'. $userInfo->NomUtilisateur .'</LoginResponsable> + <Confidentiel>false</Confidentiel> + <DocumentModifiable>true</DocumentModifiable> + <AnnexesSignables>false</AnnexesSignables> + <SignatureManuscrite>'.$aArgs['manSignature'].'</SignatureManuscrite> + </SendDossier> + </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:".$sessionId, + "SOAPAction: \"http://www.srci.fr/SendDossier\"" + ], + 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()->SendDossierResponse->SendDossierResult; + + $attachmentToFreeze[$value['res_id']] = (string)$response; + } + + return $attachmentToFreeze; + } + + public static function createZip($aArgs) + { + $zip = new ZipArchive(); + + $pathInfo = pathinfo($aArgs['filepath'], PATHINFO_FILENAME); + $tmpPath = \SrcCore\models\CoreConfigModel::getTmpPath(); + $zipFilename = $tmpPath . $pathInfo."_".rand().".zip"; + + if ($zip->open($zipFilename, ZipArchive::CREATE) === true) { + $zip->addFile($aArgs['filepath'], $aArgs['filename']); + + $adrInfo = \Convert\models\AdrModel::getConvertedDocumentById(['resId' => $aArgs['res_id_master'], 'collId' => 'letterbox_coll', 'type' => 'PDF']); + $docserverInfo = \Docserver\models\DocserverModel::getByDocserverId(['docserverId' => $adrInfo['docserver_id']]); + $arrivedMailfilePath = $docserverInfo['path_template'] . str_replace('#', '/', $adrInfo['path']) . $adrInfo['filename']; + $zip->addFile($arrivedMailfilePath, 'courrier_arrivee.pdf'); + + $zip->close(); + + $fileContent = file_get_contents($zipFilename); + $base64 = base64_encode($fileContent); + return $base64; + } else { + echo 'Impossible de créer l\'archive;'; + } + } + + public static function retrieveSignedMails($aArgs) + { + $sessionId = IxbusController::createSession($aArgs['config']); + + foreach (['noVersion', 'isVersion'] as $version) { + foreach ($aArgs['idsToRetrieve'][$version] as $resId => $value) { + $etatDossier = IxbusController::getEtatDossier(['config' => $aArgs['config'], 'sessionId' => $sessionId, 'dossier_id' => $value->external_id]); + + // Refused + if ((string)$etatDossier == $aArgs['config']['data']['ixbusIdEtatRefused']) { + $aArgs['idsToRetrieve'][$version][$resId]->status = 'refused'; + $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'; + $signedDocument = IxbusController::getAnnexes(['config' => $aArgs['config'], 'sessionId' => $sessionId, 'dossier_id' => $value->external_id]); + $aArgs['idsToRetrieve'][$version][$resId]->format = 'pdf'; // format du fichier récupéré + $aArgs['idsToRetrieve'][$version][$resId]->encodedFile = (string)$signedDocument->Fichier; + + $notes = IxbusController::getAnnotations(['config' => $aArgs['config'], 'sessionId' => $sessionId, 'dossier_id' => $value->external_id]); + $aArgs['idsToRetrieve'][$version][$resId]->noteContent = (string)$notes->Annotation->Texte; + } else { + unset($aArgs['idsToRetrieve'][$version][$resId]); + } + } + } + + // retourner seulement les mails récupérés (validés ou signés) + return $aArgs['idsToRetrieve']; + } + + public static function getEtatDossier($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> + <GetEtatDossier xmlns="http://www.srci.fr"> + <DossierID>'.$aArgs['dossier_id'].'</DossierID> + </GetEtatDossier> + </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/GetEtatDossier\"" + ], + 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()->GetEtatDossierResponse->GetEtatDossierResult; + + return $response; + } + + public static function getAnnotations($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> + <GetAnnotations xmlns="http://www.srci.fr"> + <messageID>'.$aArgs['dossier_id'].'</messageID> + </GetAnnotations> + </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/GetAnnotations\"" + ], + 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()->GetAnnotationsResponse->GetAnnotationsResult; + + 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"?> + <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> + <GetAnnexe xmlns="http://www.srci.fr"> + <messageID>'.$aArgs['dossier_id'].'</messageID> + <extension>pdf</extension> + </GetAnnexe> + </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/GetAnnexe\"" + ], + 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()->GetAnnexeResponse->GetAnnexeResult; + + return $response; + } +} diff --git a/modules/visa/xml/remoteSignatoryBooks.xml b/modules/visa/xml/remoteSignatoryBooks.xml index 89d9f978dfa45cd3e7b4f4918701ec5fcab94ae7..87657d2979921d4040de689d531593e960287330 100755 --- a/modules/visa/xml/remoteSignatoryBooks.xml +++ b/modules/visa/xml/remoteSignatoryBooks.xml @@ -1,6 +1,14 @@ <?xml version="1.0" encoding="utf-8"?> <root> - <signatoryBookEnabled>fastParapheur</signatoryBookEnabled> + <signatoryBookEnabled>maarchParapheur</signatoryBookEnabled> + <signatoryBook> + <id>maarchParapheur</id> + <userId>jjane@maarch.com</userId> + <password>maarch</password> + <url>http://10.2.95.58/MaarchParapheur</url> + <signature>SIGN</signature> + <annotation>ANNOT</annotation> + </signatoryBook> <signatoryBook> <id>ixbus</id> <userId></userId> diff --git a/src/core/models/CurlModel.php b/src/core/models/CurlModel.php index 643bc014dc64af4929f8d331bc77d2f01737a018..04a9cabfaa5b7a92cc86ee8bf21a61eefbc9751b 100644 --- a/src/core/models/CurlModel.php +++ b/src/core/models/CurlModel.php @@ -18,14 +18,17 @@ class CurlModel { public static function exec(array $aArgs) { - ValidatorModel::notEmpty($aArgs, ['curlCallId']); ValidatorModel::stringType($aArgs, ['curlCallId']); ValidatorModel::arrayType($aArgs, ['bodyData']); ValidatorModel::boolType($aArgs, ['noAuth', 'multipleObject']); - $curlConfig = CurlModel::getConfigByCallId(['curlCallId' => $aArgs['curlCallId']]); - if (empty($curlConfig)) { - return []; + if (!empty($aArgs['curlCallId'])) { + $curlConfig = CurlModel::getConfigByCallId(['curlCallId' => $aArgs['curlCallId']]); + } else { + $curlConfig['url'] = $aArgs['url']; + $curlConfig['user'] = $aArgs['user']; + $curlConfig['password'] = $aArgs['password']; + $curlConfig['method'] = $aArgs['method']; } $opts = [