Skip to content
Snippets Groups Projects
Commit a3b2d109 authored by Guillaume Heurtier's avatar Guillaume Heurtier
Browse files

FEAT #12072 TIME 1:30 get m2m list by res id

parent b64b6203
No related branches found
No related tags found
No related merge requests found
......@@ -371,6 +371,7 @@ $app->put('/resources/{resId}/sign', \SignatureBook\controllers\SignatureBookCon
$app->put('/resources/{resId}/unsign', \SignatureBook\controllers\SignatureBookController::class . ':unsignResource');
$app->get('/resources/{resId}/acknowledgementReceipts', \AcknowledgementReceipt\controllers\AcknowledgementReceiptController::class . ':getByResId');
$app->get('/resources/{resId}/shippings', \Shipping\controllers\ShippingController::class . ':getByResId');
$app->get('/resources/{resId}/messageExchanges', \MessageExchange\controllers\MessageExchangeController::class . ':getByResId');
$app->put('/res/resource/status', \Resource\controllers\ResController::class . ':updateStatus');
$app->post('/res/list', \Resource\controllers\ResController::class . ':getList');
......
<?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 Message Exchange Controller
* @author dev@maarch.org
*/
namespace MessageExchange\controllers;
use MessageExchange\models\MessageExchangeModel;
use Resource\controllers\ResController;
use Respect\Validation\Validator;
use Slim\Http\Request;
use Slim\Http\Response;
use User\models\UserModel;
class MessageExchangeController
{
public static function getByResId(Request $request, Response $response, array $args)
{
if (!Validator::intVal()->validate($args['resId']) || !ResController::hasRightByResId(['resId' => [$args['resId']], 'userId' => $GLOBALS['id']])) {
return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']);
}
$messagesModel = MessageExchangeModel::get([
'select' => [
'message_id', 'date', 'reference', 'type', 'sender_org_name', 'account_id', 'recipient_org_identifier', 'recipient_org_name',
'reception_date', 'operation_date', 'data', 'res_id_master', 'filename', 'status'
],
'where' => ['res_id_master = ?', "(type = 'ArchiveTransfer' or reference like '%_ReplySent')"],
'data' => [$args['resId']]
]);
$messages = [];
foreach ($messagesModel as $message) {
$messageType = 'm2m_' . strtoupper($message['type']);
$user = UserModel::getLabelledUserById(['login' => $message['account_id']]);
$sender = $user . ' (' . $message['sender_org_name'] . ')';
$recipient = $message['recipient_org_name'] . ' (' . $message['recipient_org_identifier'] . ')';
if ($message['status'] == 'S') {
$status = 'sent';
} elseif ($message['status'] == 'E') {
$status = 'error';
} elseif ($message['status'] == 'W') {
$status = 'wait';
} else {
$status = 'draft';
}
$messages[] = [
'messageId' => $message['message_id'],
'creationDate' => $message['date'],
'type' => $messageType,
'sender' => $sender,
'recipient' => $recipient,
'receptionDate' => $message['reception_date'],
'operationDate' => $message['operation_date'],
'status' => $status
];
}
return $response->withJson(['messageExchanges' => $messages]);
}
}
......@@ -1524,4 +1524,6 @@ export const LANG_FR = {
"noMailContact" : "Aucun contact (externe) attaché pour ce courrier",
"noSelectedAddress": "Aucune adresse associée",
"documentUnsigned": "La signature du document a été retirée",
"m2m_ARCHIVETRANSFER" : "Pli numérique",
"m2m_ARCHIVETRANSFERREPLY" : "Réponse envoyée",
};
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