-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
3767: Auto email reports by using cron job r=jniles a=mbayopanda This PR add a new feature of sending report automatically by email. In this PR, we have : - In the enterprise settings an option to enable or disable this feature of emailing - Create a component to add in reports modules for having this feature on the report module - Added this feature in : - Balance Report - Bilan Report - Compte Resultat Report - Compte d'exploitation Report ![PCfDwQk18n](https://user-images.githubusercontent.com/5445251/59752269-f2941580-9279-11e9-8088-7c18982c973e.gif) Co-authored-by: mbayopanda <mbayopanda@gmail.com> Co-authored-by: Jonathan Niles <jonathanwniles@gmail.com>
- Loading branch information
Showing
70 changed files
with
2,018 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"CRON":{ | ||
"TITLE":"Cron", | ||
"AUTO_EMAIL_REPORT":"Auto sending report by email", | ||
"FREQUENCY":"Frequency", | ||
"RECEIVERS":"Receivers", | ||
"DAILY":"Daily", | ||
"WEEKLY":"Weekly", | ||
"MONTHLY":"Monthly", | ||
"YEARLY":"Yearly", | ||
"EACH_MINUTE":"Each Minute", | ||
"SAVE":"Save", | ||
"SAVED_AUTO_REPORT":"Saved report for mailing", | ||
"LAST":"Last Sent", | ||
"NEXT":"Next Send", | ||
"PLEASE_FILL_REPORT_FORM":"Oops! It looks like there is an error in the report configuration form. Please fill it in correctly before saving the email configuration.", | ||
"PLEASE_FILL_CRON_FORM":"The email form isn't filled out correctly. Please check the values and resubmit", | ||
"DATES_BEHAVIOR":"Dates behaviors", | ||
"FIXED_DATES":"Fixed dates", | ||
"DYNAMIC_DATES":"Dynamic dates", | ||
"EMAIL_SENT_SUCCESSFULLY":"Email sent successfully", | ||
"SEND":"Send" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"CRON":{ | ||
"TITLE":"Cron", | ||
"AUTO_EMAIL_REPORT":"Envoi automatique de rapport par email", | ||
"FREQUENCY":"Fréquence", | ||
"RECEIVERS":"Recepteurs", | ||
"DAILY":"Chaque jour", | ||
"WEEKLY":"Chaque semaine", | ||
"MONTHLY":"Chaque mois", | ||
"YEARLY":"Chaque année", | ||
"EACH_MINUTE":"Chaque minute", | ||
"SAVE":"Sauvegarder", | ||
"SAVED_AUTO_REPORT":"Rapports sauvegardés pour le mailing", | ||
"LAST":"Dernier envoi", | ||
"NEXT":"Prochain envoi", | ||
"PLEASE_FILL_REPORT_FORM":"Oops! Il semble y avoir une erreur dans le formulaire de configuration du rapport. Veuillez le remplir correctement avant de sauvegarder la configuration du courrier électronique.", | ||
"PLEASE_FILL_CRON_FORM":"The email form isn't filled out correctly. Please check the values and resubmit", | ||
"DATES_BEHAVIOR":"Comportement des dates", | ||
"FIXED_DATES":"Dates fixes", | ||
"DYNAMIC_DATES":"Dates dynamiques", | ||
"EMAIL_SENT_SUCCESSFULLY":"Email envoyé avec succès", | ||
"SEND":"Envoyer" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,30 @@ | ||
{ | ||
"ENTITY":{ | ||
"MANAGEMENT":"Gestion des entités", | ||
"ADD_ENTITY":"Ajouter une entité", | ||
"EDIT_ENTITY":"Modifier l'entité", | ||
"MANAGEMENT":"Gestion des contacts", | ||
"ADD_ENTITY":"Ajouter un contact", | ||
"EDIT_ENTITY":"Modifier le contact", | ||
"NAME":"Nom", | ||
"SEX":"Sex", | ||
"PHONE":"Téléphone", | ||
"EMAIL":"Email", | ||
"ADDRESS":"Adresse", | ||
"CREATED":"Création de l'entité réussie avec succès", | ||
"CREATED":"Création du contact réussie avec succès", | ||
"SUCCESS":"Opération réussie avec succès", | ||
"UPDATED":"Mise à jour réussie avec succès", | ||
"LABEL":"Entité", | ||
"TYPE":{ | ||
"LABEL":"Type d'entité", | ||
"LABEL":"Type de contact", | ||
"PERSON":"Personne", | ||
"ENTERPRISE":"Entreprise", | ||
"SERVICE":"Service", | ||
"OFFICE":"Bureau" | ||
}, | ||
"GROUP":{ | ||
"TITLE":"Gestion des groupe de contacts", | ||
"ADD":"Ajouter un groupe", | ||
"EDIT":"Editer le groupe", | ||
"DELETE":"Supprimer le groupe", | ||
"GROUP":"Groupe des contacts" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
client/src/js/components/bhCronEmailReport/bhCronEmailReport.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<section data-element="cron-email-report" ng-if="$ctrl.isEmailFeatureEnabled"> | ||
<!-- form --> | ||
<div class="panel panel-info"> | ||
<div class="panel-heading"> | ||
<i class="fa fa-envelope-o"></i> | ||
<span translate>CRON.AUTO_EMAIL_REPORT</span> | ||
</div> | ||
<div class="panel-body"> | ||
<form name="CronForm" bh-submit="$ctrl.submit(CronForm)" novalidate> | ||
<!-- label --> | ||
<bh-input-text | ||
key="label" | ||
text-value="$ctrl.cron.label" | ||
label="FORM.LABELS.LABEL" | ||
autocomplete="off" | ||
required="true"> | ||
</bh-input-text> | ||
|
||
<!-- group --> | ||
<bh-entity-group-select | ||
uuid="$ctrl.cron.entity_group_uuid" | ||
on-select-callback="$ctrl.onSelectEntityGroup(entityGroup)" | ||
required="true"> | ||
</bh-entity-group-select> | ||
|
||
<!-- frequency --> | ||
<bh-cron-select | ||
id="$ctrl.cron.cron_id" | ||
on-select-callback="$ctrl.onSelectCron(cron)" | ||
required="true"> | ||
</bh-cron-select> | ||
|
||
<!-- dates behaviour --> | ||
<bh-yes-no-radios | ||
label="CRON.DYNAMIC_DATES" | ||
value="$ctrl.cron.has_dynamic_dates" | ||
on-change-callback="$ctrl.onChangeDynamicDates(value)"> | ||
</bh-yes-no-radios> | ||
|
||
<div class="text-right"> | ||
<button data-method="save-cron-report" type="submit" class="btn btn-primary" translate> | ||
CRON.SAVE | ||
</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
|
||
<!-- table --> | ||
<div ng-if="$ctrl.list.length" class="panel panel-info"> | ||
<div class="panel-heading"> | ||
<i class="fa fa-clock-o"></i> | ||
<span translate>CRON.SAVED_AUTO_REPORT</span> | ||
</div> | ||
<table class="table table-condensed"> | ||
<tbody> | ||
<tr ng-repeat="item in $ctrl.list track by item.id"> | ||
<td><span class="text-action" ng-click="$ctrl.details(item.id)">{{ item.label}}</span></td> | ||
<td><a ui-sref="entityGroup">{{ item.entity_group_label }}</a> <i>(<span translate>{{ item.cron_label }}</span>)</i></td> | ||
<td><span ng-if="item.last_send"><span translate>CRON.LAST</span><br> {{ item.last_send | date:'dd MMMM yyyy, hh:mm' }}</span></td> | ||
<td><span ng-if="item.next_send"><span translate>CRON.NEXT</span><br> {{ item.next_send | date:'dd MMMM yyyy, hh:mm' }}</span></td> | ||
<td> | ||
<a class="text-info" ng-if="!$ctrl.sendingPending" href ng-click="$ctrl.send(item.id)"> | ||
<i class="fa fa-send"></i> <span translate>CRON.SEND</span> | ||
</a> | ||
<i ng-if="$ctrl.sendingPending" class="fa fa-circle-o-notch fa-spin"></i> | ||
</td> | ||
<td> | ||
<a class="text-danger" href ng-click="$ctrl.remove(item.id)"> | ||
<i class="fa fa-trash"></i> <span translate>FORM.BUTTONS.DELETE</span> | ||
</a> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</section> |
113 changes: 113 additions & 0 deletions
113
client/src/js/components/bhCronEmailReport/bhCronEmailReport.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
angular.module('bhima.components') | ||
.component('bhCronEmailReport', { | ||
templateUrl : 'js/components/bhCronEmailReport/bhCronEmailReport.html', | ||
controller : bhCronEmailReportController, | ||
transclude : true, | ||
bindings : { | ||
reportId : '@', | ||
reportForm : '<', | ||
reportDetails : '<', | ||
onSelectReport : '&', | ||
}, | ||
}); | ||
|
||
bhCronEmailReportController.$inject = [ | ||
'CronEmailReportService', 'NotifyService', 'SessionService', | ||
]; | ||
|
||
function bhCronEmailReportController(CronEmailReports, Notify, Session) { | ||
const $ctrl = this; | ||
|
||
$ctrl.submit = submit; | ||
$ctrl.remove = remove; | ||
$ctrl.details = details; | ||
$ctrl.send = send; | ||
|
||
$ctrl.onSelectEntityGroup = entityGroup => { | ||
$ctrl.cron.entity_group_uuid = entityGroup.uuid; | ||
}; | ||
|
||
$ctrl.onSelectCron = cron => { | ||
$ctrl.cron.cron_id = cron.id; | ||
}; | ||
|
||
$ctrl.onChangeDynamicDates = value => { | ||
$ctrl.cron.has_dynamic_dates = value; | ||
}; | ||
|
||
$ctrl.$onInit = init; | ||
|
||
function init() { | ||
$ctrl.cron = { | ||
report_id : $ctrl.reportId, | ||
report_url : $ctrl.reportUrl, | ||
has_dynamic_dates : 0, | ||
}; | ||
$ctrl.isEmailFeatureEnabled = Session.enterprise.settings.enable_auto_email_report; | ||
load($ctrl.reportId); | ||
} | ||
|
||
function load(id) { | ||
CronEmailReports.read(null, { report_id : id }) | ||
.then(rows => { | ||
$ctrl.list = rows; | ||
}) | ||
.catch(Notify.handleError); | ||
} | ||
|
||
function details(id) { | ||
CronEmailReports.read(id) | ||
.then(row => { | ||
if (!row) { return; } | ||
const report = JSON.parse(row.params); | ||
$ctrl.onSelectReport({ report }); | ||
}) | ||
.catch(Notify.handleError); | ||
} | ||
|
||
function send(id) { | ||
$ctrl.sendingPending = true; | ||
CronEmailReports.send(id) | ||
.then(() => { | ||
$ctrl.sendingPending = false; | ||
Notify.success('CRON.EMAIL_SENT_SUCCESSFULLY'); | ||
}) | ||
.catch(Notify.handleError) | ||
.finally(() => { | ||
$ctrl.sendingPending = false; | ||
}); | ||
} | ||
|
||
function remove(id) { | ||
CronEmailReports.delete(id) | ||
.then(() => load($ctrl.reportId)) | ||
.catch(Notify.handleError); | ||
} | ||
|
||
function submit(cronForm) { | ||
if ($ctrl.reportForm.$invalid) { | ||
Notify.warn('CRON.PLEASE_FILL_REPORT_FORM'); | ||
return; | ||
} | ||
|
||
if (cronForm.$invalid) { | ||
return; | ||
} | ||
|
||
const params = { | ||
cron : $ctrl.cron, | ||
reportOptions : $ctrl.reportDetails, | ||
}; | ||
|
||
CronEmailReports.create(params) | ||
.then(() => reset(cronForm)) | ||
.then(() => init()) | ||
.catch(Notify.handleError); | ||
} | ||
|
||
function reset(form) { | ||
form.CronForm.$setPristine(); | ||
form.EntityGroupForm.$setPristine(); | ||
form.textValueForm.$setPristine(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<div ng-form="CronForm" bh-cron-select ng-model-options="{ updateOn: 'default' }"> | ||
<div | ||
class="form-group" | ||
ng-class="{ 'has-error' : CronForm.$submitted && CronForm.cron_id.$invalid }"> | ||
|
||
<label class="control-label" translate> | ||
{{ $ctrl.label }} | ||
</label> | ||
|
||
<ng-transclude></ng-transclude> | ||
<ui-select | ||
name="cron_id" | ||
ng-model="$ctrl.id" | ||
on-select="$ctrl.onSelect($item)" | ||
ng-required="$ctrl.required"> | ||
<ui-select-match placeholder="{{ 'FORM.SELECT.FREQUENCY' | translate }}"> | ||
<span>{{$select.selected.hrLabel}}</span> | ||
</ui-select-match> | ||
<ui-select-choices ui-select-focus-patch repeat="cron.id as cron in $ctrl.crons | filter: { 'hrLabel': $select.search }"> | ||
<span ng-bind-html="cron.hrLabel | highlight:$select.search"></span> | ||
</ui-select-choices> | ||
</ui-select> | ||
|
||
<div class="help-block" ng-messages="CronForm.cron_id.$error" ng-show="CronForm.$submitted"> | ||
<div ng-messages-include="modules/templates/messages.tmpl.html"></div> | ||
</div> | ||
</div> | ||
</div> |
Oops, something went wrong.