Skip to content
Snippets Groups Projects
Verified Commit 75b2ce2b authored by Florian Azizian's avatar Florian Azizian
Browse files

FEAT #9685 close mail action V2

parent 4d259ca6
No related branches found
No related tags found
No related merge requests found
......@@ -110,6 +110,7 @@ An action page is described in a ACTIONPAGE tag :
<LABEL>_CLOSE_MAIL</LABEL>
<NAME>close_mail</NAME>
<DESC>_CLOSE_MAIL_DESC</DESC>
<component>closeMailAction</component>
<ORIGIN>apps</ORIGIN>
<MODULE></MODULE>
<FLAG_CREATE>false</FLAG_CREATE>
......
......@@ -17,11 +17,13 @@ use Note\models\NoteModel;
use Resource\models\ResModel;
use Action\models\ActionModel;
use SrcCore\models\ValidatorModel;
use SrcCore\models\CurlModel;
class ActionMethodController
{
const COMPONENTS_ACTIONS = [
'confirmAction' => null
'confirmAction' => null,
'closeMailAction' => 'closeMailAction',
];
public static function terminateAction(array $aArgs)
......@@ -57,7 +59,7 @@ class ActionMethodController
if ($action['history'] == 'Y') {
foreach ($aArgs['resources'] as $resource) {
HistoryController::add([
'tableName' => 'actions',
'tableName' => 'res_view_letterbox',
'recordId' => $resource,
'eventType' => 'ACTION#' . $resource,
'eventId' => $aArgs['id'],
......@@ -70,4 +72,85 @@ class ActionMethodController
return true;
}
public static function closeMailAction(array $aArgs)
{
ValidatorModel::notEmpty($aArgs, ['id', 'resId']);
ValidatorModel::intVal($aArgs, ['id', 'resId']);
ResModel::updateExt(['set' => ['closing_date' => 'CURRENT_TIMESTAMP'], 'where' => ['res_id = ?'], 'data' => [$aArgs['resId']]]);
if (CurlModel::isEnabled(['curlCallId' => 'closeResource'])) {
$bodyData = [];
$config = CurlModel::getConfigByCallId(['curlCallId' => 'closeResource']);
$configResource = CurlModel::getConfigByCallId(['curlCallId' => 'sendResourceToExternalApplication']);
$resource = ResModel::getOnView(['select' => ['doc_' . $configResource['return']['value']], 'where' => ['res_id = ?'], 'data' => [$aArgs['resId']]]);
if (!empty($resource[0]['doc_' . $configResource['return']['value']])) {
if (!empty($config['inObject'])) {
$multipleObject = true;
foreach ($config['objects'] as $object) {
$select = [];
$tmpBodyData = [];
foreach ($object['rawData'] as $value) {
if ($value == $configResource['return']['value']) {
$select[] = 'doc_' . $configResource['return']['value'];
} elseif ($value != 'note') {
$select[] = $value;
}
}
$document = ResModel::getOnView(['select' => $select, 'where' => ['res_id = ?'], 'data' => [$aArgs['resId']]]);
if (!empty($document[0])) {
foreach ($object['rawData'] as $key => $value) {
if ($value == 'note') {
$tmpBodyData[$key] = $formValues['note_content_to_users'];
} elseif ($value == $configResource['return']['value']) {
$tmpBodyData[$key] = $document[0]['doc_' . $value];
} else {
$tmpBodyData[$key] = $document[0][$value];
}
}
}
if (!empty($object['data'])) {
$tmpBodyData = array_merge($tmpBodyData, $object['data']);
}
$bodyData[$object['name']] = $tmpBodyData;
}
} else {
$multipleObject = false;
$select = [];
foreach ($config['rawData'] as $value) {
if ($value != 'note') {
$select[] = $value;
}
}
$document = ResModel::getOnView(['select' => $select, 'where' => ['res_id = ?'], 'data' => [$aArgs['resId']]]);
if (!empty($document[0])) {
foreach ($config['rawData'] as $key => $value) {
if ($value == 'note') {
$bodyData[$key] = $formValues['note_content_to_users'];
} else {
$bodyData[$key] = $document[0][$value];
}
}
}
if (!empty($config['data'])) {
$bodyData = array_merge($bodyData, $config['data']);
}
}
CurlModel::exec(['curlCallId' => 'closeResource', 'bodyData' => $bodyData, 'multipleObject' => $multipleObject, 'noAuth' => true]);
}
}
return true;
}
}
......@@ -145,14 +145,14 @@ class ResourceListController
]);
foreach ($resources as $key => $resource) {
$formattedResources[$key]['res_id'] = $resource['res_id'];
$formattedResources[$key]['alt_identifier'] = $resource['alt_identifier'];
$formattedResources[$key]['barcode'] = $resource['barcode'];
$formattedResources[$key]['subject'] = $resource['subject'];
$formattedResources[$key]['statusLabel'] = $resource['status.label_status'];
$formattedResources[$key]['statusImage'] = $resource['status.img_filename'];
$formattedResources[$key]['priorityColor'] = $resource['priorities.color'];
$formattedResources[$key]['closing_date'] = $resource['closing_date'];
$formattedResources[$key]['res_id'] = $resource['res_id'];
$formattedResources[$key]['alt_identifier'] = $resource['alt_identifier'];
$formattedResources[$key]['barcode'] = $resource['barcode'];
$formattedResources[$key]['subject'] = $resource['subject'];
$formattedResources[$key]['statusLabel'] = $resource['status.label_status'];
$formattedResources[$key]['statusImage'] = $resource['status.img_filename'];
$formattedResources[$key]['priorityColor'] = $resource['priorities.color'];
$formattedResources[$key]['closing_date'] = $resource['closing_date'];
$formattedResources[$key]['countAttachments'] = 0;
foreach ($attachments as $attachment) {
if ($attachment['res_id_master'] == $resource['res_id']) {
......@@ -243,12 +243,12 @@ class ResourceListController
$wherePriorities = $where;
$whereCategories = $where;
$whereStatuses = $where;
$whereEntities = $where;
$dataPriorities = $queryData;
$dataCategories = $queryData;
$dataStatuses = $queryData;
$dataEntities = $queryData;
$whereStatuses = $where;
$whereEntities = $where;
$dataPriorities = $queryData;
$dataCategories = $queryData;
$dataStatuses = $queryData;
$dataEntities = $queryData;
if (isset($data['priorities'])) {
if (empty($data['priorities'])) {
......@@ -262,13 +262,13 @@ class ResourceListController
$tmpWhere = 'priority in (?)';
}
$dataCategories[] = explode(',', $replace);
$dataStatuses[] = explode(',', $replace);
$dataEntities[] = explode(',', $replace);
$dataStatuses[] = explode(',', $replace);
$dataEntities[] = explode(',', $replace);
}
$whereCategories[] = $tmpWhere;
$whereStatuses[] = $tmpWhere;
$whereEntities[] = $tmpWhere;
$whereStatuses[] = $tmpWhere;
$whereEntities[] = $tmpWhere;
}
if (isset($data['categories'])) {
if (empty($data['categories'])) {
......@@ -282,21 +282,21 @@ class ResourceListController
$tmpWhere = 'category_id in (?)';
}
$dataPriorities[] = explode(',', $replace);
$dataStatuses[] = explode(',', $replace);
$dataEntities[] = explode(',', $replace);
$dataStatuses[] = explode(',', $replace);
$dataEntities[] = explode(',', $replace);
}
$wherePriorities[] = $tmpWhere;
$whereStatuses[] = $tmpWhere;
$whereEntities[] = $tmpWhere;
$whereStatuses[] = $tmpWhere;
$whereEntities[] = $tmpWhere;
}
if (!empty($data['statuses'])) {
$wherePriorities[] = 'status in (?)';
$dataPriorities[] = explode(',', $data['statuses']);
$dataPriorities[] = explode(',', $data['statuses']);
$whereCategories[] = 'status in (?)';
$dataCategories[] = explode(',', $data['statuses']);
$whereEntities[] = 'status in (?)';
$dataEntities[] = explode(',', $data['statuses']);
$dataCategories[] = explode(',', $data['statuses']);
$whereEntities[] = 'status in (?)';
$dataEntities[] = explode(',', $data['statuses']);
}
if (isset($data['entities'])) {
if (empty($data['entities'])) {
......@@ -316,7 +316,7 @@ class ResourceListController
$wherePriorities[] = $tmpWhere;
$whereCategories[] = $tmpWhere;
$whereStatuses[] = $tmpWhere;
$whereStatuses[] = $tmpWhere;
}
if (!empty($data['entitiesChildren'])) {
$entities = explode(',', $data['entitiesChildren']);
......@@ -327,11 +327,11 @@ class ResourceListController
}
if (!empty($entitiesChildren)) {
$wherePriorities[] = 'destination in (?)';
$dataPriorities[] = $entitiesChildren;
$dataPriorities[] = $entitiesChildren;
$whereCategories[] = 'destination in (?)';
$dataCategories[] = $entitiesChildren;
$whereStatuses[] = 'destination in (?)';
$dataStatuses[] = $entitiesChildren;
$dataCategories[] = $entitiesChildren;
$whereStatuses[] = 'destination in (?)';
$dataStatuses[] = $entitiesChildren;
}
}
......@@ -416,8 +416,8 @@ class ResourceListController
$priorities = (count($priorities) >= 2) ? $priorities : [];
$categories = (count($categories) >= 2) ? $categories : [];
$statuses = (count($statuses) >= 2) ? $statuses : [];
$entities = (count($entities) >= 2) ? $entities : [];
$statuses = (count($statuses) >= 2) ? $statuses : [];
$entities = (count($entities) >= 2) ? $entities : [];
$entitiesChildren = [];
foreach ($entities as $entity) {
......
......@@ -5,7 +5,7 @@ import { NotificationService } from '../notification.service';
import { MatDialog, MatMenuTrigger } from '@angular/material';
import { ConfirmActionComponent } from './confirm-action/confirm-action.component';
import { ClosingActionComponent } from './closing-action/closing-action.component';
import { CloseMailActionComponent } from './close-mail-action/close-mail-action.component';
@Component({
selector: 'app-actions-list',
......@@ -105,8 +105,8 @@ export class ActionsListComponent implements OnInit {
});
}
closingAction() {
this.dialog.open(ClosingActionComponent, {
closeMailAction() {
const dialogRef = this.dialog.open(CloseMailActionComponent, {
width: '500px',
data: {
contextMode: this.contextMode,
......@@ -116,6 +116,13 @@ export class ActionsListComponent implements OnInit {
currentBasketInfo: this.currentBasketInfo
}
});
dialogRef.afterClosed().subscribe(result => {
this.unlock();
if (result == 'success') {
this.endAction();
}
});
}
////
......
<div mat-dialog-content>
<div class="row">
<div class="col-md-12 text-center">
Voulez-vous <b color="primary" class="highlight">{{data.actionName}}</b>&nbsp;
<b *ngIf="data.contextMode && data.selectedRes.length == 1" color="primary" class="highlight">{{data.contextChrono}}</b>
<b *ngIf="!data.contextMode || (data.contextMode && data.selectedRes.length > 1)" color="primary" class="highlight">{{data.selectedRes.length}}
élement(s)</b> ?
<div class="alert-message alert-message-danger" role="alert" style="margin-top: 30px;">
Cela actualisera la <b class="highlight">date de clôture</b> des courriers.
</div>
</div>
<div class="col-md-12">
<app-note-editor></app-note-editor>
</div>
</div>
</div>
<div mat-dialog-actions class="actions">
<button mat-raised-button mat-button color="primary">{{lang.validate}}</button>
<button mat-raised-button mat-button [mat-dialog-close]="">{{lang.cancel}}</button>
</div>
\ No newline at end of file
.mat-dialog-actions, .mat-dialog-title {
justify-content: center;
text-align: center;
}
.highlight {
font-size: 110%;
}
.alert-message
{
margin: 20px 0;
padding: 20px;
border-left: 3px solid #eee;
}
.alert-message h4
{
margin-top: 0;
margin-bottom: 5px;
}
.alert-message p:last-child
{
margin-bottom: 0;
}
.alert-message code
{
background-color: #fff;
border-radius: 3px;
}
.alert-message-success
{
background-color: #F4FDF0;
border-color: #3C763D;
}
.alert-message-success h4
{
color: #3C763D;
}
.alert-message-danger
{
background-color: #8e3e521a;
border-color: #8e3e52;
color: #8e3e52;
}
.alert-message-danger h4
{
color: #8e3e52;
}
.alert-message-warning
{
background-color: #fcf8f2;
border-color: #f0ad4e;
}
.alert-message-warning h4
{
color: #f0ad4e;
}
.alert-message-info
{
background-color: #f4f8fa;
border-color: #5bc0de;
}
.alert-message-info h4
{
color: #5bc0de;
}
.alert-message-default
{
background-color: #EEE;
border-color: #B4B4B4;
}
.alert-message-default h4
{
color: #000;
}
.alert-message-notice
{
background-color: #FCFCDD;
border-color: #BDBD89;
}
.alert-message-notice h4
{
color: #444;
}
\ No newline at end of file
import { Component, OnInit, Inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { LANG } from '../../translate.component';
import { NotificationService } from '../../notification.service';
import { MAT_DIALOG_DATA, MatDialog } from '@angular/material';
@Component({
templateUrl: "closing-action.component.html",
styleUrls: ['closing-action.component.scss'],
providers: [NotificationService],
})
export class ClosingActionComponent implements OnInit {
lang: any = LANG;
loading: boolean = false;
constructor(public http: HttpClient, private notify: NotificationService, public dialog: MatDialog, @Inject(MAT_DIALOG_DATA) public data: any) { }
ngOnInit(): void {
/*this.http.get('../../rest/resourcesList/exportTemplate')
.subscribe((data: any) => {
this.loading = false;
}, (err: any) => {
this.notify.handleErrors(err);
});*/
this.loading = false;
}
}
......@@ -24,7 +24,7 @@ import { ActivateUserComponent } from './activate-user.component'
import { ActionsListComponent } from './actions/actions-list.component';
/*ACTIONS PAGES */
import { ConfirmActionComponent } from './actions/confirm-action/confirm-action.component';
import { ClosingActionComponent } from './actions/closing-action/closing-action.component';
import { CloseMailActionComponent } from './actions/close-mail-action/close-mail-action.component';
import { FiltersListComponent } from './list/filters/filters-list.component';
import { FiltersToolComponent } from './list/filters/filters-tool.component';
......@@ -67,7 +67,7 @@ import { DiffusionsListComponent } from './diffusions/diffusions-lis
SummarySheetComponent,
ExportComponent,
ConfirmActionComponent,
ClosingActionComponent,
CloseMailActionComponent,
ActionsListComponent,
],
entryComponents: [
......@@ -80,7 +80,7 @@ import { DiffusionsListComponent } from './diffusions/diffusions-lis
SummarySheetComponent,
ExportComponent,
ConfirmActionComponent,
ClosingActionComponent,
CloseMailActionComponent,
],
providers: [ ShortcutMenuService, HeaderService, FiltersListService ],
bootstrap: [ AppComponent ]
......
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