Commit c56133f5 authored by Guillaume Heurtier's avatar Guillaume Heurtier
Browse files

FIX #16246 TIME 0:55 fix email/AR attachment + fix create summary sheet with traffic record

parent 77603ef7
......@@ -15,6 +15,6 @@
<img src="assets/spinner.gif"/>
</div>
</app-root>
<script src="runtime-es2015.1a02c9460fb9ddda5582.js" type="module"></script><script src="runtime-es5.1a02c9460fb9ddda5582.js" nomodule defer></script><script src="polyfills-es5.75b6ffa131ed9d18e439.js" nomodule defer></script><script src="polyfills-es2015.a3390f1652700a53f04b.js" type="module"></script><script src="scripts.3f995a62571f9f668311.js" defer></script><script src="main-es2015.072e00f3f3f4505e0299.js" type="module"></script><script src="main-es5.072e00f3f3f4505e0299.js" nomodule defer></script></body>
<script src="runtime-es2015.1a02c9460fb9ddda5582.js" type="module"></script><script src="runtime-es5.1a02c9460fb9ddda5582.js" nomodule defer></script><script src="polyfills-es5.75b6ffa131ed9d18e439.js" nomodule defer></script><script src="polyfills-es2015.a3390f1652700a53f04b.js" type="module"></script><script src="scripts.3f995a62571f9f668311.js" defer></script><script src="main-es2015.47283959f60c5795a21d.js" type="module"></script><script src="main-es5.47283959f60c5795a21d.js" nomodule defer></script></body>
</html>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -161,6 +161,84 @@ class EmailController
return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']);
}
if (!empty($document['isLinked'])) {
$resource = ResModel::getById(['resId' => $document['id'], 'select' => ['alt_identifier', 'subject', 'typist', 'format', 'filesize', 'version']]);
$size = null;
if (empty($document['original'])) {
$convertedResource = AdrModel::getDocuments([
'select' => ['docserver_id', 'path', 'filename'],
'where' => ['res_id = ?', 'type in (?)', 'version = ?'],
'data' => [$document['id'], ['PDF', 'SIGN'], $resource['version']],
'orderBy' => ["type='SIGN' DESC"],
'limit' => 1
]);
$convertedDocument = null;
if (!empty($convertedResource[0])) {
$docserver = DocserverModel::getByDocserverId(['docserverId' => $convertedResource[0]['docserver_id'], 'select' => ['path_template']]);
$pathToDocument = $docserver['path_template'] . str_replace('#', DIRECTORY_SEPARATOR, $convertedResource[0]['path']) . $convertedResource[0]['filename'];
if (file_exists($pathToDocument)) {
$size = StoreController::getFormattedSizeFromBytes(['size' => filesize($pathToDocument)]);
}
}
} else {
$size = StoreController::getFormattedSizeFromBytes(['size' => $resource['filesize']]);
}
$document['resource'] = [
'id' => $document['id'],
'chrono' => $resource['alt_identifier'],
'label' => $resource['subject'],
'creator' => UserModel::getLabelledUserById(['id' => $resource['typist']]),
'format' => $resource['format'],
'size' => $size
];;
}
if (!empty($document['attachments'])) {
foreach ($document['attachments'] as $key => $attachment) {
$attachmentInfo = AttachmentModel::getById(['id' => $attachment['id'], 'select' => ['title', 'format', 'filesize']]);
$size = null;
if (empty($attachment['original'])) {
$convertedResource = AdrModel::getDocuments([
'select' => ['docserver_id', 'path', 'filename'],
'where' => ['res_id = ?', 'type in (?)'],
'data' => [$attachment['id'], ['PDF', 'SIGN']],
'orderBy' => ["type='SIGN' DESC"],
'limit' => 1
]);
$convertedDocument = null;
if (!empty($convertedResource[0])) {
$docserver = DocserverModel::getByDocserverId(['docserverId' => $convertedResource[0]['docserver_id'], 'select' => ['path_template']]);
$pathToDocument = $docserver['path_template'] . str_replace('#', DIRECTORY_SEPARATOR, $convertedResource[0]['path']) . $convertedResource[0]['filename'];
if (file_exists($pathToDocument)) {
$size = StoreController::getFormattedSizeFromBytes(['size' => filesize($pathToDocument)]);
$document['attachments'][$key]['format'] = 'PDF';
}
}
} else {
$document['attachments'][$key]['format'] = $attachmentInfo['format'];
$size = StoreController::getFormattedSizeFromBytes(['size' => $attachmentInfo['filesize']]);
}
$document['attachments'][$key]['label'] = $attachmentInfo['title'];
$document['attachments'][$key]['size'] = $size;
}
}
if (!empty($document['notes'])) {
$notes = NoteModel::get(['select' => ['id', 'note_text', 'user_id'], 'where' => ['id in (?)'], 'data' => [$document['notes']]]);
$notes = array_column($notes, null, 'id');
foreach ($document['notes'] as $key => $noteId) {
$document['notes'][$key] = [
'id' => $noteId,
'label' => $notes[$noteId]['note_text'],
'typeLabel' => 'note',
'creator' => UserModel::getLabelledUserById(['id' => $notes[$noteId]['user_id']]),
'format' => 'pdf',
'size' => null
];
}
}
$sender = json_decode($rawEmail['sender'], true);
$entityLabel = null;
if (!empty($sender['entityId'])) {
......
......@@ -759,13 +759,15 @@ class SummarySheetController
$parameter = ParameterModel::getById(['select' => ['param_value_string'], 'id' => 'traffic_record_summary_sheet']);
$pdf2 = clone $pdf;
$pdf2 = new Fpdi('P', 'pt');
$pdf2->setPrintHeader(false);
$pdf2->AddPage();
$pdf2->writeHTMLCell($widthNoMargins + $dimensions['lm'], 0, $widthNoMargins + $dimensions['lm'], 0, $parameter['param_value_string'], 0, 1, 0, true, 'C', true);
$height = 10 - ($pdf2->GetY());
if (($pdf->GetY() + abs($height)) > $bottomHeight) {
$pdf->AddPage();
}
unset($pdf2);
$pdf->SetFont('', 'B', 11);
$pdf->Cell(0, 15, $unit['label'], 0, 2, 'L', false);
......
......@@ -164,7 +164,7 @@
<ng-container *ngIf="keyVal.key !== 'document'">
<mat-chip class="copy" *ngFor="let item of emailAttach[keyVal.key]; let i=index;"
[removable]="canManageMail()"
(removed)="removeAttachMail(i, keyVal.key)" [title]="item.title">
(removed)="removeAttachMail(i, keyVal.key)" [title]="item.label">
<i
class="{{emailAttachTool[keyVal.key].icon}} attachLabel"></i>&nbsp;{{item.label | shorten: 25: '...'}}&nbsp;<small
class="attachLabel">({{item.format}}{{!functions.empty(item.size) ? ' - '+item.size : ''}})</small>
......
......@@ -11,7 +11,7 @@ import { FunctionsService } from '@service/functions.service';
import { CdkDragDrop, transferArrayItem } from '@angular/cdk/drag-drop';
import { ContactService } from '@service/contact.service';
import { AppService } from '@service/app.service';
import { ConfirmComponent } from '../../../plugins/modal/confirm.component';
import { ConfirmComponent } from '@plugins/modal/confirm.component';
import { PrivilegeService } from '@service/privileges.service';
import { HeaderService } from '@service/header.service';
import { Observable, of } from 'rxjs';
......@@ -85,7 +85,6 @@ export class SentResourcePageComponent implements OnInit {
};
emailAttach: any = {};
encodedSummarySheet: any = null;
summarySheetUnits: any = [];
canManage: boolean = false;
......@@ -122,7 +121,9 @@ export class SentResourcePageComponent implements OnInit {
}
});
await this.getAttachElements();
if (this.functions.empty(this.data.emailId)) {
await this.getAttachElements();
}
if (this.data.emailId && this.data.emailType === 'email') {
await this.getEmailData(this.data.emailId);
......@@ -153,7 +154,7 @@ export class SentResourcePageComponent implements OnInit {
selector: 'textarea#emailSignature',
base_url: '../node_modules/tinymce/',
setup: (editor: any) => {
editor.on('init', (e: any) => {
editor.on('init', () => {
this.loading = false;
});
},
......@@ -358,26 +359,24 @@ export class SentResourcePageComponent implements OnInit {
this.emailContent = data.body;
Object.keys(data.document).forEach(element => {
if (['id', 'isLinked', 'original'].indexOf(element) === -1) {
this.emailAttach[element] = [];
data.document[element].forEach((dataAttach: any) => {
const elem = this.emailAttachTool[element].list.filter((item: any) => item.id === dataAttach.id || item.id === dataAttach);
if (elem.length > 0) {
this.emailAttach[element] = this.emailAttach[element].concat(elem.map((item: any) => {
return {
...item,
format: dataAttach.original || dataAttach.original === undefined ? item.format : 'pdf',
original: dataAttach.original,
size: dataAttach.original || dataAttach.original === undefined ? item.size : item.convertedDocument.size
};
}));
}
if (['id', 'isLinked', 'original', 'resource'].indexOf(element) === -1) {
data.document[element].forEach(item => this.emailAttachTool[element].list.push(item));
this.emailAttachTool[element].list = data.document[element].map((item: any) => {
this.toggleAttachMail(item, element, item.status === 'SIGN' ? 'pdf' : 'original');
return {
...item,
original: item.original !== undefined ? item.original : true,
title: item.chrono !== undefined ? `${item.chrono} - ${item.label} (${item.typeLabel})` : `${item.label} (${item.typeLabel})`
};
});
} else if (element === 'isLinked' && data.document.isLinked === true) {
this.emailAttach.document.isLinked = true;
this.emailAttach.document.format = data.document.original || data.document.original === undefined ? this.emailAttachTool.document.list[0].format : 'pdf';
this.emailAttach.document.format = data.document.original || data.document.original === undefined ? data.document.resource.format : 'pdf';
this.emailAttach.document.original = data.document.original;
this.emailAttach.document.size = this.emailAttach.document.original ? this.emailAttachTool.document.list[0].size : this.emailAttachTool.document.list[0].convertedDocument.size;
this.emailAttach.document.size = data.document.resource.size;
this.emailAttach.document.label = data.document.resource.label;
this.emailAttach.document.chrono = data.document.resource.chrono;
}
});
......@@ -575,7 +574,7 @@ export class SentResourcePageComponent implements OnInit {
switchMap(data => this.http.get('../rest/autocomplete/correspondents', { params: { 'search': data, 'searchEmails': 'true' } })),
tap((data: any) => {
data = data.filter((contact: any) => !this.functions.empty(contact.email) || contact.type === 'contactGroup').map((contact: any) => {
let label = '';
let label: string;
if (contact.type === 'user' || contact.type === 'contact') {
if (!this.functions.empty(contact.firstname) || !this.functions.empty(contact.lastname)) {
label = contact.firstname + ' ' + contact.lastname;
......
Supports Markdown
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