From b4ae093fc43ee1786b2a7ba291a6b51e4435c6b4 Mon Sep 17 00:00:00 2001 From: lvessiller <lvessiller@open-dsi.fr> Date: Mon, 16 Aug 2021 15:51:05 +0200 Subject: [PATCH] NEW envoi avancement bulletins a la fin de l'execution de la tache planifiee --- js/script.js | 16 ++++++++++++-- lib/BackgroundJob/ArchiveProcess.php | 28 ++++++++++++------------- lib/BackgroundJob/IndexationProcess.php | 22 +++++++++---------- lib/Controller/PageController.php | 14 +++++++++++++ templates/content/archive_list.php | 4 +++- 5 files changed, 56 insertions(+), 28 deletions(-) diff --git a/js/script.js b/js/script.js index b175305..ba32a2e 100644 --- a/js/script.js +++ b/js/script.js @@ -130,7 +130,7 @@ jQuery(document).ready(function(){ 0: "Aucune ligne séléctionnée", 1: "1 ligne séléctionnée" } - } + }, }, "order" : [[6, 'desc'], [4, 'asc'], [5, 'asc']], "pageLength": 50, @@ -144,7 +144,19 @@ jQuery(document).ready(function(){ 'selector': 'input[name="archive_select[]"]' }, 'dom': 'Blfrtip', - 'buttons': buttons + 'buttons': buttons, + //"drawCallback": function(settings) { + // var nbSuccess = 0; + // var nbTotal = 0; + // var errorDataArr = jQuery(this).DataTable().columns(13).data()[0]; + // errorDataArr.forEach(function(value) { + // if (value == 0) { + // nbSuccess++; + // } + // nbTotal++; + // }); + // console.log('Traités : ' + nbSuccess + ' / ' + nbTotal); + //}, }); jQuery('#archive_select_all').click(function(){ diff --git a/lib/BackgroundJob/ArchiveProcess.php b/lib/BackgroundJob/ArchiveProcess.php index 0d7953a..f850cfe 100644 --- a/lib/BackgroundJob/ArchiveProcess.php +++ b/lib/BackgroundJob/ArchiveProcess.php @@ -276,24 +276,24 @@ class ArchiveProcess extends TimedJob { $nbTotal = $nbError + $nbSuccess; $dateTimeNow = new DateTime('now', $this->_timeZone); -// // activity -// $this->_log('Activity add : archives processed'); -// $event = $this->_activityManager->generateEvent(); -// $event->setApp($this->_appName) -// ->setType('job_processed') -// ->setAffectedUser($userId) -// ->setTimestamp($dateTimeNow->getTimestamp()) -// ->setSubject('job_processed', ['nb_success' => $nbSuccess, 'nb_total' => $nbTotal]); -// //->setLink($folderLink) -// //->setObject('folder', $folder->getId(), $folder->getUuid()); -// $this->_activityManager->publish($event); -// -// // notification + // activity + $this->_log('Activity add : archives processed'); + $event = $this->_activityManager->generateEvent(); + $event->setApp($this->_appName) + ->setType('job_processed') + ->setAffectedUser($userId) + ->setTimestamp($dateTimeNow->getTimestamp()) + ->setSubject('job_processed', [$nbSuccess, $nbTotal]); + //->setLink($folderLink) + //->setObject('folder', $folder->getId(), $folder->getUuid()); + $this->_activityManager->publish($event); + + // notification // $this->_log('Notification add : archives processed'); // $notification = $this->_notificationManager->createNotification(); // $notification->setApp($this->_appName) // ->setSubject('job_processed', ['nb_success' => $nbSuccess, 'nb_total' => $nbTotal]) -// ->setObject('dematpayslip_process', 1) +// ->setObject('dematpayslip_process', $dateTimeNow->getTimestamp()) // ->setUser($userId); // //->setIcon($this->_urlGenerator->getAbsoluteURL($this->_urlGenerator->imagePath($this->_appName, 'folder.png'))) // //->setLink($folderLink); diff --git a/lib/BackgroundJob/IndexationProcess.php b/lib/BackgroundJob/IndexationProcess.php index 9b232f4..bb80bb4 100644 --- a/lib/BackgroundJob/IndexationProcess.php +++ b/lib/BackgroundJob/IndexationProcess.php @@ -290,23 +290,23 @@ class IndexationProcess extends TimedJob { $dateTimeNow = new DateTime('now', $this->_timeZone); // activity -// $this->_log('Activity add : indexation processed'); -// $event = $this->_activityManager->generateEvent(); -// $event->setApp($this->_appName) -// ->setType('job_processed') -// ->setAffectedUser($userId) -// ->setTimestamp($dateTimeNow->getTimestamp()) -// ->setSubject('job_processed', ['nb_success' => $nbSuccess, 'nb_total' => $nbTotal]); -// //->setLink($folderLink) -// //->setObject('folder', $folder->getId(), $folder->getUuid()); -// $this->_activityManager->publish($event); + $this->_log('Activity add : indexation processed'); + $event = $this->_activityManager->generateEvent(); + $event->setApp($this->_appName) + ->setType('job_processed') + ->setAffectedUser($userId) + ->setTimestamp($dateTimeNow->getTimestamp()) + ->setSubject('job_processed', [$nbSuccess, $nbTotal]); + //->setLink($folderLink) + //->setObject('folder', $folder->getId(), $folder->getUuid()); + $this->_activityManager->publish($event); // notification // $this->_log('Notification add : indexation processed'); // $notification = $this->_notificationManager->createNotification(); // $notification->setApp($this->_appName) // ->setSubject('job_processed', ['nb_success' => $nbSuccess, 'nb_total' => $nbTotal]) -// ->setObject('dematpayslip_process', 1) +// ->setObject('dematpayslip_process', $dateTimeNow->getTimestamp()) // ->setUser($userId); // //->setIcon($this->_urlGenerator->getAbsoluteURL($this->_urlGenerator->imagePath($this->_appName, 'folder.png'))) // //->setLink($folderLink); diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index f497cc4..22019b6 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -157,11 +157,25 @@ class PageController extends Controller { // get archive list $dematpayslipArchiveList = $this->_dematpaylsipProcess->getArchiveList($stepStatus, $refresh); + // progression (success count / total count) + $nbSuccess = 0; + $nbTotal = 0; + if (!empty($dematpayslipArchiveList)) { + foreach ($dematpayslipArchiveList as $archive) { + if (empty($archive->getError())) { + $nbSuccess++; + } + $nbTotal++; + } + } + return array( 'urlGenerator' => $this->_urlGenerator, 'dematpayslipConfigList' => $this->_dematpayslipConfigList, 'pastellAppExists' => $this->_dematpaylsipProcess->getPastellAppExists(), 'dematpayslipArchiveList' => $dematpayslipArchiveList, + 'nbSuccess' => $nbSuccess, + 'nbTotal' => $nbTotal, 'exportDirUserPath' => $this->_dematpaylsipProcess->getExportDirUserPath(), 'msgList' => $this->_dematpaylsipProcess->getMsgList(), 'paramList' => $paramList, diff --git a/templates/content/archive_list.php b/templates/content/archive_list.php index b1ed0af..85f8c2d 100644 --- a/templates/content/archive_list.php +++ b/templates/content/archive_list.php @@ -7,6 +7,8 @@ // assigned $urlGenerator = $_['urlGenerator']; $dematpayslipArchiveList = (isset($_['dematpayslipArchiveList']) ? $_['dematpayslipArchiveList'] : array()); + $nbSuccess = (isset($_['nbSuccess']) ? $_['nbSuccess'] : 0); + $nbTotal = (isset($_['nbTotal']) ? $_['nbTotal'] : 0); $exportDirUserPath = (isset($_['exportDirUserPath']) ? $_['exportDirUserPath'] : ''); $msgList = (isset($_['msgList']) ? $_['msgList'] : array()); $paramList = (isset($_['paramList']) ? $_['paramList'] : array()); @@ -53,7 +55,7 @@ <?php if (!empty($htmlAlert)) { ?> <div id="dematpayslip_alert"><?php print $htmlAlert; ?></div> <?php } ?> - <h2><?php p($l->t('Liste des bulletins')); ?> <a href="<?php print $urlGenerator->linkToRoute('dematpayslip.page.archive_csv', $paramList); ?>" class="button" title="<?php p($l->t('Export CSV')); ?>"><?php p($l->t('CSV')); ?></a></h2> + <h2><?php p($l->t('Liste des bulletins')); ?> <?php if ($nbTotal > 0) { print ' ['; p($l->t('avancement : ' . $nbSuccess . '/' . $nbTotal)); print '] '; } ?> <a href="<?php print $urlGenerator->linkToRoute('dematpayslip.page.archive_csv', $paramList); ?>" class="button" title="<?php p($l->t('Export CSV')); ?>"><?php p($l->t('CSV')); ?></a></h2> <br /> <div> -- GitLab