Skip to content
Snippets Groups Projects
Commit 0a78bb69 authored by Florian Azizian's avatar Florian Azizian
Browse files

FIX #12708 TIME 0:15 add control in fastParapheur

parent b3ebeb8a
No related branches found
No related tags found
No related merge requests found
......@@ -226,7 +226,13 @@ function manage_form($arr_id, $history, $id_action, $label_action, $status, $col
$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]);
$sendedInfo = FastParapheurController::sendDatas(['config' => $config, 'resIdMaster' => $res_id]);
if (!empty($sendedInfo['error'])) {
var_dump($sendedInfo['error']);
exit;
} else {
$attachmentToFreeze = $sendedInfo['sended'];
}
} elseif ($config['id'] == 'maarchParapheur') {
$listinstances = \Entity\models\ListInstanceModel::getVisaCircuitByResId(['select' => ['external_id', 'users.user_id', 'requested_signature'], 'id' => $res_id]);
if (empty($listinstances)) {
......
......@@ -16,7 +16,7 @@ class FastParapheurController
{
public static function retrieveSignedMails($aArgs)
{
foreach($aArgs['idsToRetrieve']['noVersion'] as $noVersion){
foreach ($aArgs['idsToRetrieve']['noVersion'] as $noVersion) {
$xmlPostString = '<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sei="http://sei.ws.fast.cdc.com/">
<soapenv:Header/>
......@@ -38,23 +38,23 @@ class FastParapheurController
]);
$isError = $curlReturn['response']->children('http://schemas.xmlsoap.org/soap/envelope/')->Body;
if(!empty($isError ->Fault[0])){
if (!empty($isError ->Fault[0])) {
// TODO gestion des erreurs
echo _PJ_NUMBER . $noVersion->res_id . ' ' . _AND_DOC_ORIG . $noVersion->res_id_master . ' : ' . (string)$curlReturn['response']->children('http://schemas.xmlsoap.org/soap/envelope/')->Body->Fault[0]->children()->faultstring . PHP_EOL;
echo 'PJ n° ' . $noVersion->res_id . ' et document original n° ' . $noVersion->res_id_master . ' : ' . (string)$curlReturn['response']->children('http://schemas.xmlsoap.org/soap/envelope/')->Body->Fault[0]->children()->faultstring . PHP_EOL;
continue;
}
$response = $curlReturn['response']->children('http://schemas.xmlsoap.org/soap/envelope/')->Body->children('http://sei.ws.fast.cdc.com/')->historyResponse->children();
foreach ($response->return as $res){ // Loop on all steps of the documents (prepared, send to signature, signed etc...)
foreach ($response->return as $res) { // Loop on all steps of the documents (prepared, send to signature, signed etc...)
$state = (string) $res->stateName;
if($state == $aArgs['config']['data']['validatedState']){
if ($state == $aArgs['config']['data']['validatedState']) {
$response = self::download(['config' => $aArgs['config'], 'documentId' => $noVersion->external_id]);
$aArgs['idsToRetrieve']['noVersion'][$noVersion->res_id]->status = 'validated';
$aArgs['idsToRetrieve']['noVersion'][$noVersion->res_id]->format = 'pdf';
$aArgs['idsToRetrieve']['noVersion'][$noVersion->res_id]->encodedFile = $response['b64FileContent'];
break;
}else if($state == $aArgs['config']['data']['refusedState']){
} elseif ($state == $aArgs['config']['data']['refusedState']) {
$GLOBALS['db'] = new \SrcCore\models\DatabasePDO(['customId' => $GLOBALS['CustomId']]);
$query = $GLOBALS['db']->query(
"SELECT user_id, firstname, lastname FROM listinstance LEFT JOIN users ON item_id = user_id WHERE res_id = ? AND item_mode = ?",
......@@ -66,7 +66,7 @@ class FastParapheurController
$aArgs['idsToRetrieve']['noVersion'][$noVersion->res_id]->status = 'refused';
$aArgs['idsToRetrieve']['noVersion'][$noVersion->res_id]->noteContent = $res->lastname . ' ' . $res->firstname . ' : ' . $response;
break;
}else{
} else {
$aArgs['idsToRetrieve']['noVersion'][$noVersion->res_id]->status = 'waiting';
}
}
......@@ -74,8 +74,9 @@ class FastParapheurController
return $aArgs['idsToRetrieve'];
}
public static function upload($aArgs){
$circuitId = $aArgs['circuitId'];
public static function upload($aArgs)
{
$circuitId = $aArgs['circuitId'];
$label = $aArgs['label'];
$subscriberId = $aArgs['businessId'];
......@@ -87,7 +88,7 @@ class FastParapheurController
'data' => [$aArgs['resIdMaster']]
]);
if($annexes['letterbox'][0]['category_id'] !== 'outgoing'){
if ($annexes['letterbox'][0]['category_id'] !== 'outgoing') {
$letterboxPath = \Docserver\models\DocserverModel::getByDocserverId(['docserverId' => $annexes['letterbox'][0]['docserver_id'], 'select' => ['path_template']]);
$annexes['letterbox'][0]['filePath'] = $letterboxPath['path_template'] . str_replace('#', DIRECTORY_SEPARATOR, $annexes['letterbox'][0]['path']) . $annexes['letterbox'][0]['filename'];
}
......@@ -109,7 +110,7 @@ class FastParapheurController
$attachments = \Attachment\models\AttachmentModel::get([
'select' => ['res_id', 'title', 'attachment_type','path', 'res_id_master', 'format'],
'where' => ['res_id_master = ?', 'attachment_type not in (?)', "status not in ('DEL', 'OBS')", 'in_signature_book = TRUE'],
'where' => ['res_id_master = ?', 'attachment_type not in (?)', "status not in ('DEL', 'OBS', 'FRZ')", 'in_signature_book = TRUE'],
'data' => [$aArgs['resIdMaster'], ['converted_pdf', 'incoming_mail_attachment', 'print_folder', 'signed_response']]
]);
......@@ -122,25 +123,26 @@ class FastParapheurController
$attachmentPath = \Docserver\models\DocserverModel::getByDocserverId(['docserverId' => $adrInfo['docserver_id'], 'select' => ['path_template']]);
$attachmentFilePath = $attachmentPath['path_template'] . str_replace('#', DIRECTORY_SEPARATOR, $adrInfo['path']) . $adrInfo['filename'];
$attachmentFileName = 'projet_courrier_' . $attachments[$i]['res_id_master'] . '_' . rand(0001,9999) . '.pdf';
$attachmentFileName = 'projet_courrier_' . $attachments[$i]['res_id_master'] . '_' . rand(0001, 9999) . '.pdf';
$zip = new ZipArchive();
$tmpPath = \SrcCore\models\CoreConfigModel::getTmpPath();
$zipFilePath = $tmpPath . DIRECTORY_SEPARATOR
. $attachmentFileName . '.zip'; // The zip file need to have the same name as the attachment we want to sign
if ($zip->open($zipFilePath, ZipArchive::CREATE)!==TRUE) {
if ($zip->open($zipFilePath, ZipArchive::CREATE)!==true) {
exit(_ERROR_CREATE_ZIP . "<$zipFilePath>\n");
}
$zip->addFile($attachmentFilePath, $attachmentFileName);
if($annexes['letterbox'][0]['category_id'] !== 'outgoing'){
if ($annexes['letterbox'][0]['category_id'] !== 'outgoing') {
$zip->addFile($annexes['letterbox'][0]['filePath'], 'document_principal.' . $annexes['letterbox'][0]['format']);
}
if(isset($annexes['attachments'])) {
if (isset($annexes['attachments'])) {
for ($j = 0; $j < count($annexes['attachments']); $j++) {
$zip->addFile($annexes['attachments'][$j]['filePath'],
$zip->addFile(
$annexes['attachments'][$j]['filePath'],
'PJ_' . ($j + 1) . '.' . $annexes['attachments'][$j]['format']
);
}
......@@ -178,20 +180,22 @@ class FastParapheurController
]
]);
$isError = $curlReturn['response']->children('http://schemas.xmlsoap.org/soap/envelope/')->Body;
if(!empty($isError ->Fault[0])){
// TODO gestion des erreurs
//echo (string)$curlReturn['response']->children('http://schemas.xmlsoap.org/soap/envelope/')->Body->Fault[0]->children()->faultstring . PHP_EOL;
return false;
}else{
if (!empty($curlReturn['error'])) {
return ['error' => $curlReturn['error']];
} elseif (!empty($curlReturn['response']->children('http://schemas.xmlsoap.org/soap/envelope/')->Body->Fault[0])) {
$error = (string)$curlReturn['response']->children('http://schemas.xmlsoap.org/soap/envelope/')->Body->Fault[0]->children()->faultstring . PHP_EOL;
return ['error' => $error];
} else {
$documentId = $curlReturn['response']->children('http://schemas.xmlsoap.org/soap/envelope/')->Body->children('http://sei.ws.fast.cdc.com/')->uploadResponse->children();
$attachmentToFreeze[$collId][$resId] = (string) $documentId;
}
}
return $attachmentToFreeze;
return ['sended' => $attachmentToFreeze];
}
public static function download($aArgs){
public static function download($aArgs)
{
$xmlPostString = '<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sei="http://sei.ws.fast.cdc.com/">
<soapenv:Header/>
......@@ -213,17 +217,17 @@ class FastParapheurController
]);
$isError = $curlReturn['response']->children('http://schemas.xmlsoap.org/soap/envelope/')->Body;
if(!empty($isError ->Fault[0])){
if (!empty($isError ->Fault[0])) {
// TODO gestion des erreurs
echo (string)$curlReturn['response']->children('http://schemas.xmlsoap.org/soap/envelope/')->Body->Fault[0]->children()->faultstring . PHP_EOL;
return false;
}else{
} else {
$response = $curlReturn['response']->children('http://schemas.xmlsoap.org/soap/envelope/')->Body->children('http://sei.ws.fast.cdc.com/')->downloadResponse->children()->return;
$returnedDocumentId = (string) $response->documentId;
if($aArgs['documentId'] !== $returnedDocumentId){
if ($aArgs['documentId'] !== $returnedDocumentId) {
// TODO gestion d'une potentiel erreur
return false;
}else{
} else {
$b64FileContent = $response->content;
return ['b64FileContent' => (string)$b64FileContent, 'documentId' => $returnedDocumentId];
}
......@@ -255,7 +259,7 @@ class FastParapheurController
'data' => [$aArgs['resIdMaster']]
])[0];
if(empty($signatory['business_id']) || substr($signatory['business_id'], 0, 3) == 'org'){
if (empty($signatory['business_id']) || substr($signatory['business_id'], 0, 3) == 'org') {
$signatory['business_id'] = $config['data']['subscriberId'];
}
......@@ -288,5 +292,4 @@ class FastParapheurController
return $response;
}
}
......@@ -53,7 +53,7 @@
"@types/datatables.net": "^1.10.18",
"@types/jquery": "^2.0.53",
"@types/node": "^7.10.8",
"ajv": "^6.10.2",
"ajv": "^6.11.0",
"hammerjs": "^2.0.8",
"html-minifier": "^3.5.21",
"ng2-dnd": "^5.0.2",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment