Commit 26dbd50b authored by Florian Azizian's avatar Florian Azizian

FEAT #10704 TIME 3:15 save workflow (before and after send doc to MP) + save real note writer

parent 5f62e29f
......@@ -266,7 +266,7 @@ function manage_form($arr_id, $history, $id_action, $label_action, $status, $col
$attachmentToFreeze = $sendedInfo['sended'];
}
$message = ' (à ' . $processingUserInfo['firstname'] . ' ' . $processingUserInfo['lastname'] . ')';
$message = $sendedInfo['historyInfos'];
}
}
......@@ -289,17 +289,6 @@ function manage_form($arr_id, $history, $id_action, $label_action, $status, $col
]);
}
}
$stmt = $db->query('SELECT status FROM res_letterbox WHERE res_id = ?', array($res_id));
$resource = $stmt->fetchObject();
if ($resource->status == 'EVIS' || $resource->status == 'ESIG') {
$sequence = $circuit_visa->getCurrentStep($res_id, $coll_id, 'VISA_CIRCUIT');
$stepDetails = array();
$stepDetails = $circuit_visa->getStepDetails($res_id, $coll_id, 'VISA_CIRCUIT', $sequence);
$message = $circuit_visa->processVisaWorkflow(['stepDetails' => $stepDetails, 'res_id' => $res_id]);
}
}
}
......
......@@ -157,9 +157,16 @@ function Bt_myInclude($file)
function Bt_createAttachment($aArgs = [])
{
if (!empty($aArgs['noteContent'])) {
$creatorName = '';
if (!empty($aArgs['noteCreatorId'])) {
$creatorId = $aArgs['noteCreatorId'];
} else {
$creatorId = 'superadmin';
$creatorName = $aArgs['noteCreatorName'] . ' : ';
}
$GLOBALS['db']->query(
"INSERT INTO notes (identifier, user_id, creation_date, note_text) VALUES (?, 'superadmin', CURRENT_TIMESTAMP, ?)",
[$aArgs['res_id_master'], $aArgs['noteContent']]
"INSERT INTO notes (identifier, user_id, creation_date, note_text) VALUES (?, ?, CURRENT_TIMESTAMP, ?)",
[$aArgs['res_id_master'], $creatorId, $creatorName . $aArgs['noteContent']]
);
}
......@@ -247,9 +254,16 @@ function Bt_createAttachment($aArgs = [])
function Bt_refusedSignedMail($aArgs = [])
{
if (!empty($aArgs['noteContent'])) {
$creatorName = '';
if (!empty($aArgs['noteCreatorId'])) {
$creatorId = $aArgs['noteCreatorId'];
} else {
$creatorId = 'superadmin';
$creatorName = $aArgs['noteCreatorName'] . ' : ';
}
$GLOBALS['db']->query(
"INSERT INTO notes (identifier, user_id, creation_date, note_text) VALUES (?, 'superadmin', CURRENT_TIMESTAMP, ?)",
[$aArgs['resIdMaster'], $aArgs['noteContent']]
"INSERT INTO notes (identifier, user_id, creation_date, note_text) VALUES (?, $creatorId, CURRENT_TIMESTAMP, ?)",
[$aArgs['resIdMaster'], $creatorName . $aArgs['noteContent']]
);
}
$GLOBALS['db']->query("UPDATE ".$aArgs['tableAttachment']." SET status = 'A_TRA' WHERE res_id = ?", [$aArgs['resIdAttachment']]);
......@@ -257,7 +271,7 @@ function Bt_refusedSignedMail($aArgs = [])
$GLOBALS['db']->query("UPDATE res_letterbox SET status = '" . $aArgs['refusedStatus'] . "' WHERE res_id = ?", [$aArgs['resIdMaster']]);
$historyInfo = 'La signature de la pièce jointe '.$aArgs['resIdAttachment'].' ('.$aArgs['tableAttachment'].') a été refusée dans le parapheur externe';
$historyInfo = 'La signature de la pièce jointe '.$aArgs['resIdAttachment'].' ('.$aArgs['tableAttachment'].') a été refusée dans le parapheur externe' . $aArgs['additionalHistoryInfo'];
Bt_history([
'table_name' => $aArgs['tableAttachment'],
'record_id' => $aArgs['resIdAttachment'],
......
......@@ -304,6 +304,10 @@ foreach ($retrievedMails['isVersion'] as $resId => $value) {
'table' => 'res_attachments'
]);
}
$additionalHistoryInfo = '';
if (!empty($value->workflowInfo)) {
$additionalHistoryInfo = ' : ' . $value->workflowInfo;
}
if ($value->status == 'validated') {
if (!empty($value->encodedFile)) {
......@@ -324,7 +328,9 @@ foreach ($retrievedMails['isVersion'] as $resId => $value) {
'status' => 'TRA',
'encodedFile' => $value->encodedFile,
'table' => 'res_version_attachments',
'noteContent' => $value->noteContent
'noteContent' => $value->noteContent,
'noteCreatorId' => $value->noteCreatorId,
'noteCreatorName' => $value->noteCreatorName
]);
}
......@@ -337,7 +343,7 @@ foreach ($retrievedMails['isVersion'] as $resId => $value) {
}
Bt_validatedMail(['status' => $status, 'resId' => $value->res_id_master]);
$historyInfo = 'La signature de la pièce jointe '.$resId.' (res_version_attachments) a été validée dans le parapheur externe';
$historyInfo = 'La signature de la pièce jointe '.$resId.' (res_version_attachments) a été validée dans le parapheur externe' . $additionalHistoryInfo;
Bt_history([
'table_name' => 'res_version_attachments',
'record_id' => $resId,
......@@ -370,7 +376,9 @@ foreach ($retrievedMails['isVersion'] as $resId => $value) {
'encodedFile' => $value->encodedFile,
'in_signature_book' => 'false',
'table' => 'res_attachments',
'noteContent' => $value->noteContent
'noteContent' => $value->noteContent,
'noteCreatorId' => $value->noteCreatorId,
'noteCreatorName' => $value->noteCreatorName
]);
$value->noteContent = '';
}
......@@ -380,7 +388,10 @@ foreach ($retrievedMails['isVersion'] as $resId => $value) {
'resIdAttachment' => $resId,
'refusedStatus' => $refusedStatus,
'resIdMaster' => $value->res_id_master,
'noteContent' => $value->noteContent
'noteContent' => $value->noteContent,
'noteCreatorId' => $value->noteCreatorId,
'noteCreatorName' => $value->noteCreatorName,
'additionalHistoryInfo' => $additionalHistoryInfo
]);
}
}
......@@ -408,6 +419,10 @@ foreach ($retrievedMails['noVersion'] as $resId => $value) {
'table' => 'res_attachments'
]);
}
$additionalHistoryInfo = '';
if (!empty($value->workflowInfo)) {
$additionalHistoryInfo = ' : ' . $value->workflowInfo;
}
if ($value->status == 'validated') {
if (!empty($value->encodedFile)) {
......@@ -428,7 +443,9 @@ foreach ($retrievedMails['noVersion'] as $resId => $value) {
'status' => 'TRA',
'encodedFile' => $value->encodedFile,
'table' => 'res_version_attachments',
'noteContent' => $value->noteContent
'noteContent' => $value->noteContent,
'noteCreatorId' => $value->noteCreatorId,
'noteCreatorName' => $value->noteCreatorName
]);
}
......@@ -441,7 +458,7 @@ foreach ($retrievedMails['noVersion'] as $resId => $value) {
}
Bt_validatedMail(['status' => $status, 'resId' => $value->res_id_master]);
$historyInfo = 'La signature de la pièce jointe '.$resId.' (res_attachments) a été validée dans le parapheur externe';
$historyInfo = 'La signature de la pièce jointe '.$resId.' (res_attachments) a été validée dans le parapheur externe' . $additionalHistoryInfo;
Bt_history([
'table_name' => 'res_attachments',
'record_id' => $resId,
......@@ -474,7 +491,9 @@ foreach ($retrievedMails['noVersion'] as $resId => $value) {
'encodedFile' => $value->encodedFile,
'in_signature_book' => 'false',
'table' => 'res_attachments',
'noteContent' => $value->noteContent
'noteContent' => $value->noteContent,
'noteCreatorId' => $value->noteCreatorId,
'noteCreatorName' => $value->noteCreatorName
]);
$value->noteContent = '';
}
......@@ -484,7 +503,10 @@ foreach ($retrievedMails['noVersion'] as $resId => $value) {
'resIdAttachment' => $resId,
'refusedStatus' => $refusedStatus,
'resIdMaster' => $value->res_id_master,
'noteContent' => $value->noteContent
'noteContent' => $value->noteContent,
'noteCreatorId' => $value->noteCreatorId,
'noteCreatorName' => $value->noteCreatorName,
'additionalHistoryInfo' => $additionalHistoryInfo
]);
}
}
......@@ -501,11 +523,16 @@ foreach ($retrievedMails['resLetterbox'] as $resId => $value) {
'format' => $value->format,
'encodedFile' => $value->encodedFile,
'noteContent' => $value->noteContent,
'noteCreatorId' => $value->noteCreatorId,
'noteCreatorName' => $value->noteCreatorName,
'in_signature_book' => 'false',
'attachment_type' => 'document_with_notes'
'attachment_type' => 'document_with_notes'
]);
}
$additionalHistoryInfo = '';
if (!empty($value->workflowInfo)) {
$additionalHistoryInfo = ' : ' . $value->workflowInfo;
}
if ($value->status == 'validatedNote') {
$GLOBALS['logger']->write('Document validated', 'INFO');
Bt_validatedMail(['status' => $validatedStatusAnnot, 'resId' => $value->res_id]);
......@@ -513,7 +540,7 @@ foreach ($retrievedMails['resLetterbox'] as $resId => $value) {
Bt_history([
'table_name' => 'res_letterbox',
'record_id' => $value->res_id,
'info' => 'Le document '.$resId.' (res_letterbox) a été validé dans le parapheur externe',
'info' => 'Le document '.$resId.' (res_letterbox) a été validé dans le parapheur externe' . $additionalHistoryInfo,
'event_type' => 'ACTION#1',
'event_id' => '1'
]);
......@@ -524,7 +551,7 @@ foreach ($retrievedMails['resLetterbox'] as $resId => $value) {
Bt_history([
'table_name' => 'res_letterbox',
'record_id' => $resId,
'info' => 'Le document '.$resId.' (res_letterbox) a été refusé dans le parapheur externe',
'info' => 'Le document '.$resId.' (res_letterbox) a été refusé dans le parapheur externe' . $additionalHistoryInfo,
'event_type' => 'ACTION#1',
'event_id' => '1'
]);
......
......@@ -304,3 +304,12 @@ if (!defined('_MAIL_NOTE')) {
if (!defined('_ATTACHMENT_SIGNATURE')) {
define('_ATTACHMENT_SIGNATURE', "Signature of attachment in signature book");
}
if (!defined('_NOTE_USER')) {
define('_NOTE_USER', "Note user");
}
if (!defined('_WF_SEND_TO')) {
define('_WF_SEND_TO', "Send to :");
}
if (!defined('_VISA_USER_MIN')) {
define('_VISA_USER_MIN', "Visa user");
}
......@@ -485,3 +485,12 @@ if (!defined('_MAIL_NOTE')) {
if (!defined('_ATTACHMENT_SIGNATURE')) {
define('_ATTACHMENT_SIGNATURE', "Signature des documents intégrés au parapheur");
}
if (!defined('_NOTE_USER')) {
define('_NOTE_USER', "Annotateur");
}
if (!defined('_WF_SEND_TO')) {
define('_WF_SEND_TO', "Envoyé à :");
}
if (!defined('_VISA_USER_MIN')) {
define('_VISA_USER_MIN', "Viseur");
}
......@@ -391,3 +391,12 @@ if (!defined('_MAIL_NOTE')) {
if (!defined('_ATTACHMENT_SIGNATURE')) {
define('_ATTACHMENT_SIGNATURE', 'Handtekening van de documenten die in het vloeiboek geïntegreerd zijn');
}
if (!defined('_NOTE_USER')) {
define('_NOTE_USER', "Note user _TO_TRANSLATE");
}
if (!defined('_WF_SEND_TO')) {
define('_WF_SEND_TO', "Send to : _TO_TRANSLATE");
}
if (!defined('_VISA_USER_MIN')) {
define('_VISA_USER_MIN', "Visa user _TO_TRANSLATE");
}
......@@ -13,13 +13,11 @@
namespace Action\controllers;
use Attachment\models\AttachmentModel;
use Entity\models\ListInstanceModel;
use ExternalSignatoryBook\controllers\MaarchParapheurController;
use ExternalSignatoryBook\controllers\XParaphController;
use Resource\models\ResModel;
use SrcCore\models\CoreConfigModel;
use SrcCore\models\ValidatorModel;
use User\models\UserModel;
trait ExternalSignatoryBookTrait
{
......@@ -72,7 +70,7 @@ trait ExternalSignatoryBookTrait
$attachmentToFreeze = $sendedInfo['sended'];
}
$historyInfo = '';
$historyInfo = $sendedInfo['historyInfos'];
} elseif ($config['id'] == 'xParaph') {
$attachments = AttachmentModel::getOnView([
'select' => [
......@@ -127,33 +125,6 @@ trait ExternalSignatoryBookTrait
}
}
}
$document = ResModel::getById(['resId' => $args['resId'], 'select' => ['status']]);
if ($document['status'] == 'EVIS' || $document['status'] == 'ESIG') {
$stepDetails = ListInstanceModel::getCurrentStepByResId(['resId' => $args['resId']]);
if (!empty($stepDetails) && $stepDetails['item_id'] != $GLOBALS['userId']) {
ListInstanceModel::update([
'set' => ['process_date' => 'CURRENT_TIMESTAMP'],
'where' => ['listinstance_id = ?', 'item_mode = ?', 'res_id = ?', 'item_id = ?', 'difflist_type = ?'],
'data' => [$stepDetails['listinstance_id'], $stepDetails['item_mode'], $args['resId'], $stepDetails['item_id'], 'VISA_CIRCUIT']
]);
$currentUserInfo = UserModel::getByLogin(['login' => $GLOBALS['userId'], 'select' => ['firstname', 'lastname']]);
$visaUserInfo = UserModel::getByLogin(['login' => $stepDetails['item_id'], 'select' => ['firstname', 'lastname']]);
$historyInfo = ' ' . _VISA_BY . ' ' . $currentUserInfo['firstname'] . ' ' . $currentUserInfo['lastname'] . ' ' . _INSTEAD_OF . ' ' . $visaUserInfo['firstname'] . ' ' . $visaUserInfo['lastname'];
} elseif (!empty($stepDetails)) {
ListInstanceModel::update([
'set' => ['process_date' => 'CURRENT_TIMESTAMP'],
'where' => ['listinstance_id = ?', 'item_mode = ?', 'res_id = ?', 'item_id = ?', 'difflist_type = ?'],
'data' => [$stepDetails['listinstance_id'], $stepDetails['item_mode'], $args['resId'], $GLOBALS['userId'], 'VISA_CIRCUIT']
]);
$historyInfo = '';
}
}
}
return ['history' => $historyInfo];
......
......@@ -312,7 +312,27 @@ class MaarchParapheurController
$attachmentToFreeze['letterbox_coll'][$aArgs['resIdMaster']] = $response['id'];
}
return ['sended' => $attachmentToFreeze];
$workflowInfos = [];
foreach ($workflow as $value) {
$userInfos = UserModel::getByExternalId([
'select' => ['firstname', 'lastname'],
'externalId' => $value['userId'],
'signatoryBookName' => 'maarchParapheur'
]);
if ($value['mode'] == 'note') {
$mode = _NOTE_USER;
} elseif ($value['mode'] == 'visa') {
$mode = _VISA_USER;
} elseif ($value['mode'] == 'sign') {
$mode = _SIGNATORY;
}
$workflowInfos[] = $userInfos['firstname'] . ' ' . $userInfos['lastname'] . ' ('. $mode .')';
}
if (!empty($workflowInfos)) {
$historyInfos = ' ' . _WF_SEND_TO . ' ' . implode(", ", $workflowInfos);
}
return ['sended' => $attachmentToFreeze, 'historyInfos' => $historyInfos];
}
public static function createZip(array $aArgs)
......@@ -371,7 +391,18 @@ class MaarchParapheurController
}
if (!empty($state['note'])) {
$aArgs['idsToRetrieve'][$version][$resId]->noteContent = $state['note'];
$userInfos = UserModel::getByExternalId([
'select' => ['user_id'],
'externalId' => $state['noteCreatorId'],
'signatoryBookName' => 'maarchParapheur'
]);
if (!empty($userInfos)) {
$aArgs['idsToRetrieve'][$version][$resId]->noteCreatorId = $userInfos['user_id'];
} else {
$aArgs['idsToRetrieve'][$version][$resId]->noteCreatorName = $state['noteCreatorName'];
}
}
$aArgs['idsToRetrieve'][$version][$resId]->workflowInfo = implode(", ", $state['workflowInfo']);
} else {
unset($aArgs['idsToRetrieve'][$version][$resId]);
}
......@@ -409,10 +440,19 @@ class MaarchParapheurController
public static function getState($aArgs)
{
$state['status'] = 'validated';
$state['workflowInfo'] = [];
foreach ($aArgs['workflow'] as $step) {
if ($step['status'] == 'VAL' && $step['mode'] == 'sign') {
$state['workflowInfo'][] = $step['userDisplay'] . ' (Signé le ' . $step['processDate'] . ')';
} elseif ($step['status'] == 'VAL' && $step['mode'] == 'visa') {
$state['workflowInfo'][] = $step['userDisplay'] . ' (Visé le ' . $step['processDate'] . ')';
}
if ($step['status'] == 'REF') {
$state['status'] = 'refused';
$state['note'] = $step['note'];
$state['status'] = 'refused';
$state['note'] = $step['note'];
$state['noteCreatorId'] = $step['userId'];
$state['noteCreatorName'] = $step['userDisplay'];
$state['workflowInfo'][] = $step['userDisplay'] . ' (Refusé le ' . $step['processDate'] . ')';
break;
} elseif (empty($step['status'])) {
$state['status'] = 'inProgress';
......@@ -426,7 +466,6 @@ class MaarchParapheurController
public static function getUserPicture(Request $request, Response $response, array $aArgs)
{
$check = Validator::intVal()->validate($aArgs['id']);
if (!$check) {
return $response->withStatus(400)->withJson(['errors' => 'id should be an integer']);
......
......@@ -58,6 +58,25 @@ abstract class UserModelAbstract
return $aUser[0];
}
public static function getByExternalId(array $aArgs)
{
ValidatorModel::notEmpty($aArgs, ['externalId', 'signatoryBookName']);
ValidatorModel::intVal($aArgs, ['externalId']);
$aUser = DatabaseModel::select([
'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'],
'table' => ['users'],
'where' => ['external_id->>\''.$aArgs['signatoryBookName'].'\' = ?'],
'data' => [$aArgs['externalId']]
]);
if (empty($aUser)) {
return [];
}
return $aUser[0];
}
public static function create(array $aArgs)
{
ValidatorModel::notEmpty($aArgs, ['user']);
......
......@@ -498,3 +498,7 @@ define("_FILE_NOT_ALLOWED_INFO_3", "is not allowed");
define("_ENTITY", "Entity");
define("_PRINT_SEP_TITLE", "Mail separator");
define("_SIGNATORY", "Signatory");
define("_VISA_USER_MIN", "Visa user");
define("_NOTE_USER", "Note user");
define("_WF_SEND_TO", "Send to : ");
......@@ -497,3 +497,7 @@ define("_FILE_NOT_ALLOWED_INFO_2", "avec le type MIME");
define("_FILE_NOT_ALLOWED_INFO_3", "n'est pas autorisée");
define("_ENTITY", "Entité");
define("_PRINT_SEP_TITLE", "Séparateur de courrier");
define("_SIGNATORY", "Signataire");
define("_VISA_USER_MIN", "Viseur");
define("_NOTE_USER", "Annotateur");
define("_WF_SEND_TO", "Envoyé à : ");
......@@ -500,4 +500,9 @@ define("_FILE_NOT_ALLOWED_INFO_3", "is not allowed_TO_TRANSLATE");
define("_ENTITY", "Entity_TO_TRANSLATE");
define("_PRINT_SEP_TITLE", "Mail separator_TO_TRANSLATE");
define('_SEND_TO_EXTERNAL_NOTEBOOK', 'Send data to external note book_TO_TRANSLATE');
\ No newline at end of file
define('_SEND_TO_EXTERNAL_NOTEBOOK', 'Send data to external note book_TO_TRANSLATE');
define("_SIGNATORY", "Signatory_TO_TRANSLATE");
define("_VISA_USER_MIN", "Visa user_TO_TRANSLATE");
define("_NOTE_USER", "Note user_TO_TRANSLATE");
define("_WF_SEND_TO", "Send to : _TO_TRANSLATE");
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment