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

Merge branch 'develop' of labs.maarch.org:maarch/MaarchCourrier into develop

parents 0c88783c 16f0c330
No related branches found
No related tags found
No related merge requests found
Showing
with 164 additions and 186 deletions
...@@ -32,17 +32,17 @@ ...@@ -32,17 +32,17 @@
</thead> </thead>
<tbody> <tbody>
<tr *ngFor="let priority of priorities" id="{{priority.id}}"> <tr *ngFor="let priority of priorities" id="{{priority.id}}">
<td>{{priority.label_priority}}</td> <td>{{priority.label}}</td>
<td><input type="color" value="{{priority.color_priority}}" style="background:none;border:none;width:45px;" disabled></td> <td><input type="color" value="{{priority.color}}" style="background:none;border:none;width:45px;" disabled></td>
<td>{{priority.delays}}</td> <td>{{priority.delays}}</td>
<td *ngIf="priority.working_days =='Y'">Jours ouvrés</td> <td *ngIf="priority.working_days">Jours ouvrés</td>
<td *ngIf="priority.working_days =='N'">Jours calendaires</td> <td *ngIf="!priority.working_days">Jours calendaires</td>
<td style="text-align:right;"> <td style="text-align:right;">
<div class="btn-group" role="group" aria-label="..."> <div class="btn-group" role="group" aria-label="...">
<button routerLink="/administration/priorities/{{priority.id}}" type="button" class="btn btn-default" title="{{lang.edit}}"> <button routerLink="/administration/priorities/{{priority.id}}" type="button" class="btn btn-default" title="{{lang.edit}}">
<a><i style="cursor:pointer" class="fa fa-edit"></i></a> <a><i style="cursor:pointer" class="fa fa-edit"></i></a>
</button> </button>
<button type="button" class="btn btn-default" title="{{lang.delete}}" (click)="deletePriority(priority)"> <button type="button" class="btn btn-default" title="{{lang.delete}}" (click)="deletePriority(priority.id)">
<a><i style="cursor:pointer;color: #D9534F" class="fa fa-trash"></i></a> <a><i style="cursor:pointer;color: #D9534F" class="fa fa-trash"></i></a>
</button> </button>
</div> </div>
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<div class="col-sm-12"> <div class="col-sm-12">
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"><i class="fa fa-envelope-o" aria-hidden="true"></i></span> <span class="input-group-addon"><i class="fa fa-envelope-o" aria-hidden="true"></i></span>
<input type="text" class="form-control" name="label" title="Label" placeholder="Label" [(ngModel)]="priority.label" required> <input type="text" class="form-control" name="label" title="{{lang.label}}" placeholder="{{lang.label}}" [(ngModel)]="priority.label" required>
</div> </div>
</div> </div>
</div> </div>
...@@ -33,16 +33,15 @@ ...@@ -33,16 +33,15 @@
<div class="col-sm-12"> <div class="col-sm-12">
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"><i class="fa fa-envelope-o" aria-hidden="true"></i></span> <span class="input-group-addon"><i class="fa fa-envelope-o" aria-hidden="true"></i></span>
<input type="color" class="form-control" name="color" title="Couleur" placeholder="Couleur" [(ngModel)]="priority.color" required> <input type="color" class="form-control" name="color" [(ngModel)]="priority.color" required>
</div> </div>
</div> </div>
</div> </div>
{{priority.working_days}}
<div class="form-group"> <div class="form-group">
<div class="col-sm-12"> <div class="col-sm-12">
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"><i class="fa fa-envelope-o" aria-hidden="true"></i></span> <span class="input-group-addon"><i class="fa fa-envelope-o" aria-hidden="true"></i></span>
<input type="checkbox" class="form-control" name="working_days" title="Jours travaillés" [(ngModel)]="priority.working_days"> <input type="checkbox" class="form-control" name="working_days" title="{{lang.workingDays}}" [(ngModel)]="priority.working_days">
</div> </div>
</div> </div>
</div> </div>
...@@ -50,13 +49,13 @@ ...@@ -50,13 +49,13 @@
<div class="col-sm-12"> <div class="col-sm-12">
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"><i class="fa fa-paw" aria-hidden="true"></i></span> <span class="input-group-addon"><i class="fa fa-paw" aria-hidden="true"></i></span>
<input type="number" class="form-control" name="delays" title="Délai de traitement" placeholder="Délai de traitement" [(ngModel)]="priority.delays" required> <input type="number" class="form-control" name="delays" title="{{lang.processDelay}}" placeholder="{{lang.processDelay}}" [(ngModel)]="priority.delays" required>
</div> </div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div style="text-align:center;"> <div style="text-align:center;">
<button type="submit" class="btn btn-default" [disabled]="!priorityForm.form.valid">Enregistrer la priorité</button> <button type="submit" class="btn btn-default" [disabled]="!priorityForm.form.valid">{{lang.save}}</button>
</div> </div>
</div> </div>
</form> </form>
......
...@@ -12,12 +12,13 @@ Object.defineProperty(exports, "__esModule", { value: true }); ...@@ -12,12 +12,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core"); var core_1 = require("@angular/core");
var http_1 = require("@angular/http"); var http_1 = require("@angular/http");
require("rxjs/add/operator/map"); require("rxjs/add/operator/map");
var translate_component_1 = require("./translate.component");
var PrioritiesAdministrationComponent = (function () { var PrioritiesAdministrationComponent = (function () {
function PrioritiesAdministrationComponent(http) { function PrioritiesAdministrationComponent(http) {
this.http = http; this.http = http;
this.priorities = []; this.lang = translate_component_1.LANG;
this.lang = {};
this.loading = false; this.loading = false;
this.priorities = [];
} }
PrioritiesAdministrationComponent.prototype.updateBreadcrumb = function (applicationName) { PrioritiesAdministrationComponent.prototype.updateBreadcrumb = function (applicationName) {
if ($j('#ariane')[0]) { if ($j('#ariane')[0]) {
...@@ -29,11 +30,10 @@ var PrioritiesAdministrationComponent = (function () { ...@@ -29,11 +30,10 @@ var PrioritiesAdministrationComponent = (function () {
this.coreUrl = angularGlobals.coreUrl; this.coreUrl = angularGlobals.coreUrl;
this.updateBreadcrumb(angularGlobals.applicationName); this.updateBreadcrumb(angularGlobals.applicationName);
this.loading = true; this.loading = true;
this.http.get(this.coreUrl + 'rest/administration/priorities') this.http.get(this.coreUrl + 'rest/priorities')
.map(function (res) { return res.json(); }) .map(function (res) { return res.json(); })
.subscribe(function (data) { .subscribe(function (data) {
_this.priorities = data.priorities; _this.priorities = data.priorities;
_this.lang = data.lang;
//setTimeout(() => { //setTimeout(() => {
// this.datatable = $j('#prioritiesTable').DataTable({ // this.datatable = $j('#prioritiesTable').DataTable({
// "dom": '<"datatablesLeft"p><"datatablesRight"f><"datatablesCenter"l>rt<"datatablesCenter"i><"clear">', // "dom": '<"datatablesLeft"p><"datatablesRight"f><"datatablesCenter"l>rt<"datatablesCenter"i><"clear">',
...@@ -68,6 +68,20 @@ var PrioritiesAdministrationComponent = (function () { ...@@ -68,6 +68,20 @@ var PrioritiesAdministrationComponent = (function () {
location.href = "index.php"; location.href = "index.php";
}); });
}; };
PrioritiesAdministrationComponent.prototype.deletePriority = function (id) {
var _this = this;
var r = confirm("Voulez-vous vraiment supprimer cette priorité ?");
if (r) {
this.http.delete(this.coreUrl + "rest/priorities/" + id)
.map(function (res) { return res.json(); })
.subscribe(function (data) {
_this.priorities = data.priorities;
successNotification(data.success);
}, function (err) {
errorNotification(JSON.parse(err._body).errors);
});
}
};
return PrioritiesAdministrationComponent; return PrioritiesAdministrationComponent;
}()); }());
PrioritiesAdministrationComponent = __decorate([ PrioritiesAdministrationComponent = __decorate([
......
import { Component, OnInit} from '@angular/core'; import { Component, OnInit} from '@angular/core';
import { Http } from '@angular/http'; import { Http } from '@angular/http';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
import { LANG } from './translate.component';
declare function $j(selector: any) : any; declare function $j(selector: any) : any;
declare function successNotification(message: string) : void;
declare function errorNotification(message: string) : void;
declare var angularGlobals : any; declare var angularGlobals : any;
...@@ -13,12 +16,12 @@ declare var angularGlobals : any; ...@@ -13,12 +16,12 @@ declare var angularGlobals : any;
export class PrioritiesAdministrationComponent implements OnInit { export class PrioritiesAdministrationComponent implements OnInit {
coreUrl : string; coreUrl : string;
lang : any = LANG;
loading : boolean = false;
priorities : any[] = []; priorities : any[] = [];
lang : any = {};
datatable : any; datatable : any;
loading : boolean = false;
constructor(public http: Http) { constructor(public http: Http) {
...@@ -35,11 +38,10 @@ export class PrioritiesAdministrationComponent implements OnInit { ...@@ -35,11 +38,10 @@ export class PrioritiesAdministrationComponent implements OnInit {
this.loading = true; this.loading = true;
this.http.get(this.coreUrl + 'rest/administration/priorities') this.http.get(this.coreUrl + 'rest/priorities')
.map(res => res.json()) .map(res => res.json())
.subscribe((data) => { .subscribe((data) => {
this.priorities = data.priorities; this.priorities = data.priorities;
this.lang = data.lang;
//setTimeout(() => { //setTimeout(() => {
// this.datatable = $j('#prioritiesTable').DataTable({ // this.datatable = $j('#prioritiesTable').DataTable({
// "dom": '<"datatablesLeft"p><"datatablesRight"f><"datatablesCenter"l>rt<"datatablesCenter"i><"clear">', // "dom": '<"datatablesLeft"p><"datatablesRight"f><"datatablesCenter"l>rt<"datatablesCenter"i><"clear">',
...@@ -76,29 +78,18 @@ export class PrioritiesAdministrationComponent implements OnInit { ...@@ -76,29 +78,18 @@ export class PrioritiesAdministrationComponent implements OnInit {
}) })
} }
//deletePriority(priorityId: string){ deletePriority(id: string) {
// var resp = confirm('Confirmer?'); let r = confirm("Voulez-vous vraiment supprimer cette priorité ?");
// if(resp){
// var intId = parseInt(priorityId); if (r) {
// this.http.delete(this.coreUrl + 'rest/priorities/'+intId) this.http.delete(this.coreUrl + "rest/priorities/" + id)
// .map(res => res.json()) .map(res => res.json())
// .subscribe((data) => { .subscribe((data) => {
// if(data.errors){ this.priorities = data.priorities;
// this.resultInfo = data.errors; successNotification(data.success);
// $j('#resultInfo').removeClass().addClass('alert alert-danger alert-dismissible'); }, (err) => {
// $j("#resultInfo").fadeTo(3000, 500).slideUp(500, function(){ errorNotification(JSON.parse(err._body).errors);
// $j("#resultInfo").slideUp(500); })
// }); }
// } else { }
// var list = this.prioritiesList;
// for(var i=0;i<list.length;i++){
// if(list[i].id==priorityId){
// list.splice(i,1)
// }
// }
// prioritiesDataTable.row($j('#'+priorityId)).remove().draw();
// }
// })
// }
//}
} }
\ No newline at end of file
...@@ -13,16 +13,17 @@ var core_1 = require("@angular/core"); ...@@ -13,16 +13,17 @@ var core_1 = require("@angular/core");
var http_1 = require("@angular/http"); var http_1 = require("@angular/http");
var router_1 = require("@angular/router"); var router_1 = require("@angular/router");
require("rxjs/add/operator/map"); require("rxjs/add/operator/map");
var translate_component_1 = require("./translate.component");
var PriorityAdministrationComponent = (function () { var PriorityAdministrationComponent = (function () {
function PriorityAdministrationComponent(http, route, router) { function PriorityAdministrationComponent(http, route, router) {
this.http = http; this.http = http;
this.route = route; this.route = route;
this.router = router; this.router = router;
this.lang = translate_component_1.LANG;
this.loading = false;
this.priority = { this.priority = {
working_days: false working_days: false
}; };
this.lang = {};
this.loading = false;
} }
PriorityAdministrationComponent.prototype.updateBreadcrumb = function (applicationName) { PriorityAdministrationComponent.prototype.updateBreadcrumb = function (applicationName) {
if ($j('#ariane')[0]) { if ($j('#ariane')[0]) {
...@@ -37,23 +38,15 @@ var PriorityAdministrationComponent = (function () { ...@@ -37,23 +38,15 @@ var PriorityAdministrationComponent = (function () {
this.route.params.subscribe(function (params) { this.route.params.subscribe(function (params) {
if (typeof params['id'] == "undefined") { if (typeof params['id'] == "undefined") {
_this.creationMode = true; _this.creationMode = true;
_this.http.get(_this.coreUrl + "rest/administration/priorities/new") _this.loading = false;
.map(function (res) { return res.json(); })
.subscribe(function (data) {
_this.lang = data.lang;
_this.loading = false;
}, function () {
location.href = "index.php";
});
} }
else { else {
_this.creationMode = false; _this.creationMode = false;
_this.id = params['id']; _this.id = params['id'];
_this.http.get(_this.coreUrl + "rest/administration/priorities/" + _this.id) _this.http.get(_this.coreUrl + "rest/priorities/" + _this.id)
.map(function (res) { return res.json(); }) .map(function (res) { return res.json(); })
.subscribe(function (data) { .subscribe(function (data) {
_this.priority = data.priority; _this.priority = data.priority;
_this.lang = data.lang;
_this.loading = false; _this.loading = false;
}, function () { }, function () {
location.href = "index.php"; location.href = "index.php";
...@@ -62,11 +55,13 @@ var PriorityAdministrationComponent = (function () { ...@@ -62,11 +55,13 @@ var PriorityAdministrationComponent = (function () {
}); });
}; };
PriorityAdministrationComponent.prototype.onSubmit = function () { PriorityAdministrationComponent.prototype.onSubmit = function () {
var _this = this;
if (this.creationMode) { if (this.creationMode) {
this.http.post(this.coreUrl + "rest/priorities", this.priority) this.http.post(this.coreUrl + "rest/priorities", this.priority)
.map(function (res) { return res.json(); }) .map(function (res) { return res.json(); })
.subscribe(function (data) { .subscribe(function (data) {
successNotification(data.success); successNotification(data.success);
_this.router.navigate(["/administration/priorities"]);
}, function (err) { }, function (err) {
errorNotification(JSON.parse(err._body).errors); errorNotification(JSON.parse(err._body).errors);
}); });
...@@ -76,6 +71,7 @@ var PriorityAdministrationComponent = (function () { ...@@ -76,6 +71,7 @@ var PriorityAdministrationComponent = (function () {
.map(function (res) { return res.json(); }) .map(function (res) { return res.json(); })
.subscribe(function (data) { .subscribe(function (data) {
successNotification(data.success); successNotification(data.success);
_this.router.navigate(["/administration/priorities"]);
}, function (err) { }, function (err) {
errorNotification(JSON.parse(err._body).errors); errorNotification(JSON.parse(err._body).errors);
}); });
......
...@@ -2,6 +2,7 @@ import { Component, OnInit} from '@angular/core'; ...@@ -2,6 +2,7 @@ import { Component, OnInit} from '@angular/core';
import { Http } from '@angular/http'; import { Http } from '@angular/http';
import { Router, ActivatedRoute } from '@angular/router'; import { Router, ActivatedRoute } from '@angular/router';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
import { LANG } from './translate.component';
declare function $j(selector: any) : any; declare function $j(selector: any) : any;
declare function successNotification(message: string) : void; declare function successNotification(message: string) : void;
...@@ -19,13 +20,13 @@ export class PriorityAdministrationComponent implements OnInit { ...@@ -19,13 +20,13 @@ export class PriorityAdministrationComponent implements OnInit {
coreUrl : string; coreUrl : string;
id : string; id : string;
creationMode : boolean; creationMode : boolean;
lang : any = LANG;
loading : boolean = false;
priority : any = { priority : any = {
working_days : false working_days : false
}; };
lang : any = {};
loading : boolean = false;
constructor(public http: Http, private route: ActivatedRoute, private router: Router) { constructor(public http: Http, private route: ActivatedRoute, private router: Router) {
} }
...@@ -45,23 +46,14 @@ export class PriorityAdministrationComponent implements OnInit { ...@@ -45,23 +46,14 @@ export class PriorityAdministrationComponent implements OnInit {
this.route.params.subscribe((params) => { this.route.params.subscribe((params) => {
if (typeof params['id'] == "undefined") { if (typeof params['id'] == "undefined") {
this.creationMode = true; this.creationMode = true;
this.http.get(this.coreUrl + "rest/administration/priorities/new") this.loading = false;
.map(res => res.json())
.subscribe((data) => {
this.lang = data.lang;
this.loading = false;
}, () => {
location.href = "index.php";
});
} else { } else {
this.creationMode = false; this.creationMode = false;
this.id = params['id']; this.id = params['id'];
this.http.get(this.coreUrl + "rest/administration/priorities/" + this.id) this.http.get(this.coreUrl + "rest/priorities/" + this.id)
.map(res => res.json()) .map(res => res.json())
.subscribe((data) => { .subscribe((data) => {
this.priority = data.priority; this.priority = data.priority;
this.lang = data.lang;
this.loading = false; this.loading = false;
}, () => { }, () => {
...@@ -77,6 +69,7 @@ export class PriorityAdministrationComponent implements OnInit { ...@@ -77,6 +69,7 @@ export class PriorityAdministrationComponent implements OnInit {
.map(res => res.json()) .map(res => res.json())
.subscribe((data) => { .subscribe((data) => {
successNotification(data.success); successNotification(data.success);
this.router.navigate(["/administration/priorities"]);
}, (err) => { }, (err) => {
errorNotification(JSON.parse(err._body).errors); errorNotification(JSON.parse(err._body).errors);
}); });
...@@ -85,12 +78,11 @@ export class PriorityAdministrationComponent implements OnInit { ...@@ -85,12 +78,11 @@ export class PriorityAdministrationComponent implements OnInit {
.map(res => res.json()) .map(res => res.json())
.subscribe((data) => { .subscribe((data) => {
successNotification(data.success); successNotification(data.success);
this.router.navigate(["/administration/priorities"]);
}, (err) => { }, (err) => {
errorNotification(JSON.parse(err._body).errors); errorNotification(JSON.parse(err._body).errors);
}); });
} }
} }
} }
\ No newline at end of file
...@@ -37,5 +37,10 @@ exports.LANG_EN = { ...@@ -37,5 +37,10 @@ exports.LANG_EN = {
'user': "user", 'user': "user",
'delete': "Delete", 'delete': "Delete",
'basketToRedirect': "Choose a basket", 'basketToRedirect': "Choose a basket",
'autoLogoutAbsence': "You are going to be automaticaly disconnected after your redirections" 'autoLogoutAbsence': "You are going to be automaticaly disconnected after your redirections",
'color': "Color",
'label': "Label",
'workingDays': "Working days",
'processDelay': "Process delay",
'save': "Save",
}; };
...@@ -35,5 +35,10 @@ export const LANG_EN = { ...@@ -35,5 +35,10 @@ export const LANG_EN = {
'user' : "user", 'user' : "user",
'delete' : "Delete", 'delete' : "Delete",
'basketToRedirect' : "Choose a basket", 'basketToRedirect' : "Choose a basket",
'autoLogoutAbsence' : "You are going to be automaticaly disconnected after your redirections" 'autoLogoutAbsence' : "You are going to be automaticaly disconnected after your redirections",
'color' : "Color",
'label' : "Label",
'workingDays' : "Working days",
'processDelay' : "Process delay",
'save' : "Save",
}; };
\ No newline at end of file
...@@ -37,5 +37,10 @@ exports.LANG_FR = { ...@@ -37,5 +37,10 @@ exports.LANG_FR = {
'user': "utilisateur", 'user': "utilisateur",
'delete': "Supprimer", 'delete': "Supprimer",
'basketToRedirect': "Choisissez une banette", 'basketToRedirect': "Choisissez une banette",
'autoLogoutAbsence': "Vous allez être automatiquement déconnecté après avoir défini vos redirections de bannettes" 'autoLogoutAbsence': "Vous allez être automatiquement déconnecté après avoir défini vos redirections de bannettes",
'color': "Couleur",
'label': "Label",
'workingDays': "Jours travaillés",
'processDelay': "Délai de traitement",
'save': "Enregistrer"
}; };
...@@ -35,5 +35,10 @@ export const LANG_FR = { ...@@ -35,5 +35,10 @@ export const LANG_FR = {
'user' : "utilisateur", 'user' : "utilisateur",
'delete' : "Supprimer", 'delete' : "Supprimer",
'basketToRedirect' : "Choisissez une banette", 'basketToRedirect' : "Choisissez une banette",
'autoLogoutAbsence' : "Vous allez être automatiquement déconnecté après avoir défini vos redirections de bannettes" 'autoLogoutAbsence' : "Vous allez être automatiquement déconnecté après avoir défini vos redirections de bannettes",
'color' : "Couleur",
'label' : "Label",
'workingDays' : "Jours travaillés",
'processDelay' : "Délai de traitement",
'save' : "Enregistrer"
}; };
\ No newline at end of file
This diff is collapsed.
...@@ -1922,7 +1922,7 @@ if (!defined('_AUTO_LOGOUT_AFTER_BASKETS_REDIRECTIONS')) ...@@ -1922,7 +1922,7 @@ if (!defined('_AUTO_LOGOUT_AFTER_BASKETS_REDIRECTIONS'))
define('_AUTO_LOGOUT_AFTER_BASKETS_REDIRECTIONS', 'You are going to be automaticaly disconnected after your redirections'); define('_AUTO_LOGOUT_AFTER_BASKETS_REDIRECTIONS', 'You are going to be automaticaly disconnected after your redirections');
/***** Profile *****/ /***** Profile *****/
/***** User Administration *****/ /***** Administration *****/
if (!defined('_ADMIN_USER_MODIFICATION')) if (!defined('_ADMIN_USER_MODIFICATION'))
define('_ADMIN_USER_MODIFICATION', 'Modification of user'); define('_ADMIN_USER_MODIFICATION', 'Modification of user');
if (!defined('_ADDED_GROUP')) if (!defined('_ADDED_GROUP'))
...@@ -1959,7 +1959,13 @@ if (!defined('_ACTIVE')) ...@@ -1959,7 +1959,13 @@ if (!defined('_ACTIVE'))
define('_ACTIVE', 'Active'); define('_ACTIVE', 'Active');
if (!defined('_INACTIVE')) if (!defined('_INACTIVE'))
define('_INACTIVE', 'Inactive'); define('_INACTIVE', 'Inactive');
/***** User Administration *****/ if (!defined('_ADDED_PRIORITY'))
define('_ADDED_PRIORITY', 'Priority created');
if (!defined('_UPDATED_PRIORITY'))
define('_UPDATED_PRIORITY', 'Priority updated');
if (!defined('_DELETED_PRIORITY'))
define('_DELETED_PRIORITY', 'Priority deleted');
/***** Administration *****/
/**** admin update control ****/ /**** admin update control ****/
if (!defined('_ADMIN_UPDATE_CONTROL')) if (!defined('_ADMIN_UPDATE_CONTROL'))
......
...@@ -1958,7 +1958,7 @@ if (!defined('_AUTO_LOGOUT_AFTER_BASKETS_REDIRECTIONS')) ...@@ -1958,7 +1958,7 @@ if (!defined('_AUTO_LOGOUT_AFTER_BASKETS_REDIRECTIONS'))
define('_AUTO_LOGOUT_AFTER_BASKETS_REDIRECTIONS', 'Vous allez être automatiquement déconnecté après avoir défini vos redirections de bannettes'); define('_AUTO_LOGOUT_AFTER_BASKETS_REDIRECTIONS', 'Vous allez être automatiquement déconnecté après avoir défini vos redirections de bannettes');
/***** Profile *****/ /***** Profile *****/
/***** User Administration *****/ /***** Administration *****/
if (!defined('_ADMIN_USER_MODIFICATION')) if (!defined('_ADMIN_USER_MODIFICATION'))
define('_ADMIN_USER_MODIFICATION', 'Modification de l\'utilisateur'); define('_ADMIN_USER_MODIFICATION', 'Modification de l\'utilisateur');
if (!defined('_ADDED_GROUP')) if (!defined('_ADDED_GROUP'))
...@@ -1995,7 +1995,13 @@ if (!defined('_ACTIVE')) ...@@ -1995,7 +1995,13 @@ if (!defined('_ACTIVE'))
define('_ACTIVE', 'Actif'); define('_ACTIVE', 'Actif');
if (!defined('_INACTIVE')) if (!defined('_INACTIVE'))
define('_INACTIVE', 'Inactif'); define('_INACTIVE', 'Inactif');
/***** User Administration *****/ if (!defined('_ADDED_PRIORITY'))
define('_ADDED_PRIORITY', 'Priorité ajoutée');
if (!defined('_UPDATED_PRIORITY'))
define('_UPDATED_PRIORITY', 'Priorité modifiée');
if (!defined('_DELETED_PRIORITY'))
define('_DELETED_PRIORITY', 'Priorité supprimée');
/***** Administration *****/
/**** admin update control ****/ /**** admin update control ****/
if (!defined('_ADMIN_UPDATE_CONTROL')) if (!defined('_ADMIN_UPDATE_CONTROL'))
......
...@@ -11,21 +11,16 @@ use Core\Models\PriorityModel; ...@@ -11,21 +11,16 @@ use Core\Models\PriorityModel;
class PriorityController class PriorityController
{ {
public function getPrioritiesForAdministration(RequestInterface $request, ResponseInterface $response) public function get(RequestInterface $request, ResponseInterface $response)
{ {
if (!ServiceModel::hasService(['id' => 'admin_priorities', 'userId' => $_SESSION['user']['UserId'], 'location' => 'apps', 'type' => 'admin'])) { if (!ServiceModel::hasService(['id' => 'admin_priorities', 'userId' => $_SESSION['user']['UserId'], 'location' => 'apps', 'type' => 'admin'])) {
return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
} }
$return = [ return $response->withJson(['priorities' => PriorityModel::get()]);
'priorities' => PriorityModel::get(),
'lang' => []
];
return $response->withJson($return);
} }
public function getPriorityForAdministration(RequestInterface $request, ResponseInterface $response, $aArgs) public function getById(RequestInterface $request, ResponseInterface $response, $aArgs)
{ {
if (!ServiceModel::hasService(['id' => 'admin_priorities', 'userId' => $_SESSION['user']['UserId'], 'location' => 'apps', 'type' => 'admin'])) { if (!ServiceModel::hasService(['id' => 'admin_priorities', 'userId' => $_SESSION['user']['UserId'], 'location' => 'apps', 'type' => 'admin'])) {
return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
...@@ -37,113 +32,68 @@ class PriorityController ...@@ -37,113 +32,68 @@ class PriorityController
return $response->withStatus(400)->withJson(['errors' => 'Priority not found']); return $response->withStatus(400)->withJson(['errors' => 'Priority not found']);
} }
return $response->withJson([ return $response->withJson(['priority' => $priotity]);
'priority' => $priotity,
'lang' => []
]);
} }
public function getNewPriorityForAdministration(RequestInterface $request, ResponseInterface $response) public function create(RequestInterface $request, ResponseInterface $response)
{ {
if (!ServiceModel::hasService(['id' => 'admin_priorities', 'userId' => $_SESSION['user']['UserId'], 'location' => 'apps', 'type' => 'admin'])) { if (!ServiceModel::hasService(['id' => 'admin_priorities', 'userId' => $_SESSION['user']['UserId'], 'location' => 'apps', 'type' => 'admin'])) {
return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
} }
$priority = []; $data = $request->getParams();
$priority['lang'] = []; $check = Validator::stringType()->notEmpty()->validate($data['label']);
$check = $check && Validator::stringType()->notEmpty()->validate($data['color']);
$check = $check && Validator::intVal()->notEmpty()->validate($data['delays']);
$check = $check && Validator::boolType()->validate($data['working_days']);
if (!$check) {
return $response->withStatus(400)->withJson(['errors' => 'Bad Request']);
}
$data['working_days'] = $data['working_days'] ? 'true' : 'false';
$id = PriorityModel::create($data);
return $response->withJson($priority); return $response->withJson([
'success' => _ADDED_PRIORITY,
'priority' => $id
]);
} }
public function create(RequestInterface $request, ResponseInterface $response) public function update(RequestInterface $request, ResponseInterface $response, $aArgs)
{ {
if (!ServiceModel::hasService(['id' => 'admin_priorities', 'userId' => $_SESSION['user']['UserId'], 'location' => 'apps', 'type' => 'admin'])) { if (!ServiceModel::hasService(['id' => 'admin_priorities', 'userId' => $_SESSION['user']['UserId'], 'location' => 'apps', 'type' => 'admin'])) {
return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
} }
$data = $request->getParams(); $data = $request->getParams();
$check = Validator::stringType()->notEmpty()->validate($data['label']);
$check = $check && Validator::stringType()->notEmpty()->validate($data['color']);
$check = $check && Validator::intVal()->notEmpty()->validate($data['delays']);
$check = $check && Validator::boolType()->notEmpty()->validate($data['working_days']);
if (!$check) {
return $response->withStatus(400)->withJson(['errors' => 'Bad Request']);
}
$data['id'] = $aArgs['id'];
$data['working_days'] = $data['working_days'] ? 'true' : 'false'; $data['working_days'] = $data['working_days'] ? 'true' : 'false';
$id = PriorityModel::create($data); PriorityModel::update($data);
return $response->withJson(['success' => _UPDATED_PRIORITY]);
}
public function delete(RequestInterface $request, ResponseInterface $response, $aArgs)
{
if (!ServiceModel::hasService(['id' => 'admin_priorities', 'userId' => $_SESSION['user']['UserId'], 'location' => 'apps', 'type' => 'admin'])) {
return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
}
PriorityModel::delete(['id' => $aArgs['id']]);
return $response->withJson([ return $response->withJson([
'success' => _USER_ADDED, 'success' => _DELETED_PRIORITY,
'priority' => $id 'priorities' => PriorityModel::get()
]); ]);
} }
// public function update(RequestInterface $request, ResponseInterface $response, $aArgs){
// $errors = $this->control($request, 'update');
//
// if (!empty($errors)) {
// return $response
// ->withJson(['errors' => $errors]);
// }
//
//
// $aArgs = $request->getParams();
// $checkExist = PrioritiesModel::getById([
// 'id' => $aArgs['id']
// ]);
// if($checkExist){
// $return = PrioritiesModel::update($aArgs);
// if($return) {
// $obj = PrioritiesModel::getById([
// 'id' => $aArgs['id']
// ]);
// } else {
// return $response
// ->withStatus(500)
// ->withJson(['errors' => _NOT_UPDATE]);
// }
// } else {
// array_push($errors,'Cette priorité n\'existe pas');
// return $response
// ->withJson(['errors' => $errors]);
// }
// $return = PrioritiesModel::update($aArgs);
// return $response->withJson($obj);
// }
//
// public function delete(RequestInterface $request, ResponseInterface $response, $aArgs)
// {
//
// $obj = PrioritiesModel::delete(['id' => $aArgs['id']]);
// return $response->withJson($obj);
// }
//
// protected static function control( $request, $mode){
// $errors = [];
// if (empty($request))
// array_push($errors,'Tableau d\'arguments vide');
//
// if (!Validator::notEmpty()->validate($request->getParam('label_priority'))){
// array_push($errors,'Valeur label vide');
// }
// if (!Validator::notEmpty()->validate($request->getParam('color_priority'))) {
// array_push($errors, 'Aucune Couleur assignée');
// }
// else if(!Validator::regex('/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/')->validate($request->getParam('color_priority')) && Validator::notEmpty()->validate($request->getParam('color_priority')) || $request->getParam('color_priority')=='#ffffff'){
// array_push($errors,'Format couleur invalide');
// }
// if (!Validator::notEmpty()->validate($request->getParam('delays'))){
// array_push($errors,'Delai vide');
// }
// if (!Validator::notEmpty()->validate($request->getParam('working_days'))){
// array_push($errors,'jours vide');
// }
// else if ($request->getParam('working_days')!= 'Y' && $request->getParam('working_days') != 'N') {
// array_push($errors,'Valeur working_days invalide');
// //return false;
// }
// if ($request->getParam('delays') !== '*' &&!ctype_digit($request->getParam('delays'))&&Validator::notEmpty()->validate($request->getParam('delays'))) {
// array_push($errors,'Valeur delays invalide');
// }
// if ((int)$request->getParam('delays') < 0) {
// array_push($errors,'Valeur négative');
// }
// return $errors;
// }
} }
?>
\ No newline at end of file
...@@ -29,7 +29,7 @@ abstract class PriorityModelAbstract ...@@ -29,7 +29,7 @@ abstract class PriorityModelAbstract
public static function getById(array $aArgs) public static function getById(array $aArgs)
{ {
ValidatorModel::notEmpty($aArgs, ['id']); ValidatorModel::notEmpty($aArgs, ['id']);
ValidatorModel::intVal($aArgs, ['id']); ValidatorModel::stringType($aArgs, ['id']);
$aPriority = DatabaseModel::select([ $aPriority = DatabaseModel::select([
'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'],
...@@ -51,6 +51,7 @@ abstract class PriorityModelAbstract ...@@ -51,6 +51,7 @@ abstract class PriorityModelAbstract
ValidatorModel::stringType($aArgs, ['label', 'color', 'working_days']); ValidatorModel::stringType($aArgs, ['label', 'color', 'working_days']);
ValidatorModel::intVal($aArgs, ['delays']); ValidatorModel::intVal($aArgs, ['delays']);
//working_days => true (monday to friday) => false (monday to sunday)
$id = DatabaseModel::uniqueId(); $id = DatabaseModel::uniqueId();
DatabaseModel::insert([ DatabaseModel::insert([
'table' => 'priorities', 'table' => 'priorities',
...@@ -59,7 +60,7 @@ abstract class PriorityModelAbstract ...@@ -59,7 +60,7 @@ abstract class PriorityModelAbstract
'label' => $aArgs['label'], 'label' => $aArgs['label'],
'color' => $aArgs['color'], 'color' => $aArgs['color'],
'working_days' => $aArgs['working_days'], 'working_days' => $aArgs['working_days'],
'delays' => $aArgs['delays'], 'delays' => $aArgs['delays']
] ]
]); ]);
...@@ -68,12 +69,18 @@ abstract class PriorityModelAbstract ...@@ -68,12 +69,18 @@ abstract class PriorityModelAbstract
public static function update(array $aArgs) public static function update(array $aArgs)
{ {
ValidatorModel::notEmpty($aArgs, ['id']); ValidatorModel::notEmpty($aArgs, ['id', 'label', 'color', 'delays', 'working_days']);
ValidatorModel::intVal($aArgs, ['id']); ValidatorModel::stringType($aArgs, ['id', 'label', 'color', 'working_days']);
ValidatorModel::intVal($aArgs, ['delays']);
//working_days => true (monday to friday) => false (monday to sunday)
DatabaseModel::update([ DatabaseModel::update([
'table' => 'priorities', 'table' => 'priorities',
'set' => [ 'set' => [
'label' => $aArgs['label'],
'color' => $aArgs['color'],
'working_days' => $aArgs['working_days'],
'delays' => $aArgs['delays']
], ],
'where' => ['id = ?'], 'where' => ['id = ?'],
'data' => [$aArgs['id']] 'data' => [$aArgs['id']]
...@@ -85,10 +92,9 @@ abstract class PriorityModelAbstract ...@@ -85,10 +92,9 @@ abstract class PriorityModelAbstract
public static function delete(array $aArgs) public static function delete(array $aArgs)
{ {
ValidatorModel::notEmpty($aArgs, ['id']); ValidatorModel::notEmpty($aArgs, ['id']);
ValidatorModel::intVal($aArgs, ['id']); ValidatorModel::stringType($aArgs, ['id']);
DatabaseModel::deleteFrom([ DatabaseModel::delete([
'table' => 'priorities', 'table' => 'priorities',
'where' => ['id = ?'], 'where' => ['id = ?'],
'data' => [$aArgs['id']] 'data' => [$aArgs['id']]
......
...@@ -103,10 +103,6 @@ $app->get('/administration/users/{id}', \Core\Controllers\UserController::class ...@@ -103,10 +103,6 @@ $app->get('/administration/users/{id}', \Core\Controllers\UserController::class
$app->get('/administration/status', \Core\Controllers\StatusController::class . ':getList'); $app->get('/administration/status', \Core\Controllers\StatusController::class . ':getList');
$app->get('/administration/status/new', \Core\Controllers\StatusController::class . ':getNewInformations'); $app->get('/administration/status/new', \Core\Controllers\StatusController::class . ':getNewInformations');
$app->get('/administration/status/{identifier}', \Core\Controllers\StatusController::class . ':getByIdentifier'); $app->get('/administration/status/{identifier}', \Core\Controllers\StatusController::class . ':getByIdentifier');
$app->get('/administration/priorities', \Core\Controllers\PriorityController::class . ':getPrioritiesForAdministration');
$app->get('/administration/priorities/new', \Core\Controllers\PriorityController::class . ':getNewPriorityForAdministration');
$app->get('/administration/priorities/{id}', \Core\Controllers\PriorityController::class . ':getPriorityForAdministration');
//status //status
$app->post('/status', \Core\Controllers\StatusController::class . ':create'); $app->post('/status', \Core\Controllers\StatusController::class . ':create');
...@@ -191,7 +187,9 @@ $app->put('/parameters/{id}', \Core\Controllers\ParametersController::class . ': ...@@ -191,7 +187,9 @@ $app->put('/parameters/{id}', \Core\Controllers\ParametersController::class . ':
$app->delete('/parameters/{id}', \Core\Controllers\ParametersController::class . ':delete'); $app->delete('/parameters/{id}', \Core\Controllers\ParametersController::class . ':delete');
//Priorities //Priorities
$app->get('/priorities', \Core\Controllers\PriorityController::class . ':get');
$app->post('/priorities', \Core\Controllers\PriorityController::class . ':create'); $app->post('/priorities', \Core\Controllers\PriorityController::class . ':create');
$app->get('/priorities/{id}', \Core\Controllers\PriorityController::class . ':getById');
$app->put('/priorities/{id}', \Core\Controllers\PriorityController::class . ':update'); $app->put('/priorities/{id}', \Core\Controllers\PriorityController::class . ':update');
$app->delete('/priorities/{id}', \Core\Controllers\PriorityController::class . ':delete'); $app->delete('/priorities/{id}', \Core\Controllers\PriorityController::class . ':delete');
......
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