diff --git a/apps/maarch_entreprise/Views/profile.component.html b/apps/maarch_entreprise/Views/profile.component.html index 9295bd872599dbe00344c8ded1840e3f53c5d7a3..dafb83ae5f5358872997a0ba44a453564fb007ca 100755 --- a/apps/maarch_entreprise/Views/profile.component.html +++ b/apps/maarch_entreprise/Views/profile.component.html @@ -22,7 +22,7 @@ <a data-toggle="modal" data-target="#manageAbs" id="redirectBasketCard"><i class="fa fa-share"></i> {{lang.manageAbsences}} </a> </li> <li style="cursor: pointer"> - <a data-toggle="modal" data-target="#manageHistory"><i class="fa fa-history"></i> {{lang.history}} </a> + <a data-toggle="modal" data-target="#manageHistory" (click)="getHistories()"><i class="fa fa-history"></i> {{lang.history}} </a> </li> <li style="cursor: pointer"> <a (click)="askRedirectBasket()" ><i class="fa fa-user-times"></i> Activer mon absence </a> @@ -337,8 +337,8 @@ <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title">{{lang.history}}</h4> </div> - <div class="modal-body"> - <table id="historyTable" class="table table-hover table-condensed" [md2Data]="user.histories" #md2="md2DataTable" [sortBy]='event_date' [rowsPerPage]="10"> + <div class="modal-body" style="height: 70vh"> + <table id="historyTable" class="table table-hover table-condensed" [md2Data]="histories" #md2="md2DataTable" [sortBy]='event_date' [rowsPerPage]="10"> <thead> <tr> <td> diff --git a/apps/maarch_entreprise/js/angular/app/profile.component.js b/apps/maarch_entreprise/js/angular/app/profile.component.js index 7af650c737eab4341f8b2acf8ed98e5a0d26df79..5b3132d68c2dea649712014230964e4b62f97b9d 100755 --- a/apps/maarch_entreprise/js/angular/app/profile.component.js +++ b/apps/maarch_entreprise/js/angular/app/profile.component.js @@ -23,6 +23,7 @@ var ProfileComponent = /** @class */ (function () { this.user = { baskets: [] }; + this.histories = []; this.passwordModel = { currentPassword: "", newPassword: "", @@ -387,6 +388,17 @@ var ProfileComponent = /** @class */ (function () { }); } }; + ProfileComponent.prototype.getHistories = function () { + var _this = this; + if (this.histories.length == 0) { + this.http.get(this.coreUrl + 'rest/histories/users/' + this.user.id) + .subscribe(function (data) { + _this.histories = data.histories; + }, function (err) { + _this.notify.error(err.error.errors); + }); + } + }; ProfileComponent.prototype.onSubmit = function () { var _this = this; this.http.put(this.coreUrl + 'rest/currentUser/profile', this.user) diff --git a/apps/maarch_entreprise/js/angular/app/profile.component.ts b/apps/maarch_entreprise/js/angular/app/profile.component.ts index ed59a366cd8bf5fcb6526589c2d890ce33f0d19d..135575c9550c8a7658ac26bd5ebf1479eb530e60 100755 --- a/apps/maarch_entreprise/js/angular/app/profile.component.ts +++ b/apps/maarch_entreprise/js/angular/app/profile.component.ts @@ -24,6 +24,7 @@ export class ProfileComponent implements OnInit { user : any = { baskets : [] }; + histories : any[] = []; passwordModel : any = { currentPassword : "", newPassword : "", @@ -420,6 +421,17 @@ export class ProfileComponent implements OnInit { } } + getHistories() { + if (this.histories.length == 0) { + this.http.get(this.coreUrl + 'rest/histories/users/' + this.user.id) + .subscribe((data : any) => { + this.histories = data.histories; + }, (err) => { + this.notify.error(err.error.errors); + }); + } + } + onSubmit() { this.http.put(this.coreUrl + 'rest/currentUser/profile', this.user) .subscribe(() => { diff --git a/rest/index.php b/rest/index.php index 2462594f0358dfeac2d2e6b5a47a26a785c01ebf..15e336aa2e06fd9842cb2bceb51b1173bad30d32 100755 --- a/rest/index.php +++ b/rest/index.php @@ -225,6 +225,7 @@ $app->delete('/priorities/{id}', \Core\Controllers\PriorityController::class . ' //History $app->get('/administration/history/eventDate/{date}', \History\controllers\HistoryController::class . ':getForAdministration'); +$app->get('/histories/users/{userSerialId}', \History\controllers\HistoryController::class . ':getByUserId'); //HistoryBatch $app->get('/administration/historyBatch/eventDate/{date}', \History\controllers\HistoryController::class . ':getBatchForAdministration'); diff --git a/src/app/history/controllers/HistoryController.php b/src/app/history/controllers/HistoryController.php index a5f9ca3b205c978c1c2dbce1ae321e81b6d75076..f4d462cbe019a967d09f38d1852e7386309e97f2 100644 --- a/src/app/history/controllers/HistoryController.php +++ b/src/app/history/controllers/HistoryController.php @@ -130,6 +130,18 @@ class HistoryController ]); } + public function getByUserId(Request $request, Response $response, array $aArgs) + { + $user = UserModel::getById(['id' => $aArgs['userSerialId'], 'select' => ['user_id']]); + if ($user['user_id'] != $GLOBALS['userId'] && !ServiceModel::hasService(['id' => 'view_history', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'admin'])) { + return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); + } + + $aHistories = HistoryModel::getByUserId(['userId' => $user['user_id'], 'select' => ['info', 'event_date']]); + + return $response->withJson(['histories' => $aHistories]); + } + public function getForAdministration(Request $request, Response $response, array $aArgs) { if (!ServiceModel::hasService(['id' => 'view_history', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'admin'])) {