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

FEAT #12280 TIME 0:30 folder print notes refactor + fix arrow character in summary sheet

parent 4f75825e
No related branches found
No related tags found
No related merge requests found
...@@ -135,24 +135,6 @@ class ResourceDataExportController ...@@ -135,24 +135,6 @@ class ResourceDataExportController
if (!empty($resource['attachments']['resIds'])) { if (!empty($resource['attachments']['resIds'])) {
$attachmentsIds = $resource['attachments']['resIds']; $attachmentsIds = $resource['attachments']['resIds'];
} }
if (!empty($resource['attachments']['types'])) {
if (in_array("ALL", $resource['attachments']['types'])) { // TODO rm types
$attachmentsIds = AttachmentModel::get([
'select' => ['res_id'],
'where' => ['res_id_master = ?'],
'data' => [$resource['resId']]
]);
$attachmentsIds = array_column($attachmentsIds, 'res_id');
} else {
$ids = AttachmentModel::get([
'select' => ['res_id'],
'where' => ['attachment_type in (?)', 'res_id_master = ?'],
'data' => [$resource['attachments']['types'], $resource['resId']]
]);
$ids = array_column($ids, 'res_id');
$attachmentsIds = array_merge($attachmentsIds, $ids);
}
}
if (!empty($attachmentsIds)) { if (!empty($attachmentsIds)) {
$attachments = AttachmentModel::get([ $attachments = AttachmentModel::get([
...@@ -200,18 +182,27 @@ class ResourceDataExportController ...@@ -200,18 +182,27 @@ class ResourceDataExportController
return $response->withStatus(400)->withJson(['errors' => 'Note id is not an integer']); return $response->withStatus(400)->withJson(['errors' => 'Note id is not an integer']);
} }
} }
$notesIds = $resource['notes'];
$notes = NoteModel::get([
'where' => ['id in (?)'],
'data' => [$resource['notes']],
'orderBy' => ['creation_date desc']
]);
if (count($notes) < count($resource['notes'])) {
return $response->withStatus(400)->withJson(['errors' => 'Note(s) not found']);
}
} else { } else {
$notesIds = NoteModel::get([ $notes = NoteModel::get([
'select' => ['id'], 'select' => ['id', 'identifier', 'user_id', 'note_text', 'creation_date'],
'where' => ['identifier = ? '], 'where' => ['identifier = ? '],
'data' => [$resource['resId']] 'data' => [$resource['resId']],
'orderBy' => ['creation_date desc']
]); ]);
$notesIds = array_column($notesIds, 'id');
} }
if (!empty($notesIds)) { if (!empty($notes)) {
$noteFilePath = ResourceDataExportController::getNotesFilePath(['notes' => $notesIds, 'resId' => $resource['resId']]); $noteFilePath = ResourceDataExportController::getNotesFilePath(['notes' => $notes, 'resId' => $resource['resId']]);
if (!empty($noteFilePath['errors'])) { if (!empty($noteFilePath['errors'])) {
return $response->withStatus($noteFilePath['code'])->withJson(['errors' => $noteFilePath['errors']]); return $response->withStatus($noteFilePath['code'])->withJson(['errors' => $noteFilePath['errors']]);
...@@ -245,7 +236,7 @@ class ResourceDataExportController ...@@ -245,7 +236,7 @@ class ResourceDataExportController
if (!empty($acknowledgementReceiptsIds)) { if (!empty($acknowledgementReceiptsIds)) {
$acknowledgementReceipts = AcknowledgementReceiptModel::getByIds([ $acknowledgementReceipts = AcknowledgementReceiptModel::getByIds([
'select' => ['id', 'res_id', 'format', 'contact_id', 'user_id', 'creation_date', 'send_date', 'docserver_id', 'path', 'select' => ['id', 'res_id', 'format', 'contact_id', 'user_id', 'creation_date', 'send_date', 'docserver_id', 'path',
'fileneme', 'fingerprint'], 'filename', 'fingerprint'],
'ids' => $acknowledgementReceiptsIds 'ids' => $acknowledgementReceiptsIds
]); ]);
...@@ -354,7 +345,7 @@ class ResourceDataExportController ...@@ -354,7 +345,7 @@ class ResourceDataExportController
$resourceDocument = $args['document']; $resourceDocument = $args['document'];
if (in_array($args['collId'], ['letterbox_coll', 'attachments_coll'])) { if (!empty($args['collId']) && in_array($args['collId'], ['letterbox_coll', 'attachments_coll'])) {
$document = ConvertPdfController::getConvertedPdfById(['resId' => $resourceDocument['res_id'], 'collId' => $args['collId']]); $document = ConvertPdfController::getConvertedPdfById(['resId' => $resourceDocument['res_id'], 'collId' => $args['collId']]);
if (!empty($document['errors'])) { if (!empty($document['errors'])) {
return ['errors' => 'Conversion error : ' . $document['errors'], 'code' => 400]; return ['errors' => 'Conversion error : ' . $document['errors'], 'code' => 400];
...@@ -397,17 +388,7 @@ class ResourceDataExportController ...@@ -397,17 +388,7 @@ class ResourceDataExportController
$notes = []; $notes = [];
$notesModel = NoteModel::get([ // TODO put this in a param -> query before foreach ($args['notes'] as $note) {
'where' => ['id in (?)'],
'data' => [$args['notes']],
'orderBy' => ['creation_date desc']
]);
if (count($notesModel) < count($args['notes'])) { // TODO useless here ?
return ['errors' => 'Note(s) not found', 'code' => 400];
}
foreach ($notesModel as $note) {
if ($note['identifier'] != $args['resId']) { if ($note['identifier'] != $args['resId']) {
return ['errors' => 'Note not linked to resource', 'code' => 400]; return ['errors' => 'Note not linked to resource', 'code' => 400];
} }
...@@ -415,7 +396,7 @@ class ResourceDataExportController ...@@ -415,7 +396,7 @@ class ResourceDataExportController
$user = UserModel::getById(['id' => $note['user_id'], 'select' => ['firstname', 'lastname']]); $user = UserModel::getById(['id' => $note['user_id'], 'select' => ['firstname', 'lastname']]);
$userName = $user['firstname'] . ' ' . $user['lastname']; $userName = $user['firstname'] . ' ' . $user['lastname'];
$noteText = str_replace('←', '<=', $note['note_text']); // TODO might not work (Alex had '?') $noteText = str_replace('←', '<=', $note['note_text']);
$date = explode('-', date('d-m-Y', strtotime($note['creation_date']))); $date = explode('-', date('d-m-Y', strtotime($note['creation_date'])));
$date = $date[0].'/'.$date[1].'/'.$date[2].' '.date('H:i', strtotime($note['creation_date'])); $date = $date[0].'/'.$date[1].'/'.$date[2].' '.date('H:i', strtotime($note['creation_date']));
......
...@@ -777,7 +777,7 @@ class SummarySheetController ...@@ -777,7 +777,7 @@ class SummarySheetController
$notes[] = [ $notes[] = [
'user' => UserModel::getLabelledUserById(['id' => $rawNote['user_id']]), 'user' => UserModel::getLabelledUserById(['id' => $rawNote['user_id']]),
'date' => TextFormatModel::formatDate($rawNote['creation_date']), 'date' => TextFormatModel::formatDate($rawNote['creation_date']),
'note' => $rawNote['note_text'] 'note' => $noteText = str_replace('←', '<=', $rawNote['note_text'])
]; ];
} }
unset($args['data']['notes'][$noteKey]); unset($args['data']['notes'][$noteKey]);
......
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