diff --git a/apps/maarch_entreprise/js/angular/app/status-administration.component.js b/apps/maarch_entreprise/js/angular/app/status-administration.component.js index 29df22c4fe440cc7afca66b80dcf35a89c89b17d..2e5cb6968f39f6ba960dbdafeddb74c75909c0c1 100644 --- a/apps/maarch_entreprise/js/angular/app/status-administration.component.js +++ b/apps/maarch_entreprise/js/angular/app/status-administration.component.js @@ -38,8 +38,8 @@ var StatusAdministrationComponent = (function () { this.coreUrl = angularGlobals.coreUrl; this.prepareStatus(); this.route.params.subscribe(function (params) { - if (_this.route.toString().includes('status/new')) { - _this.http.get(_this.coreUrl + 'rest/status/new') + if (typeof params['identifier'] == "undefined") { + _this.http.get(_this.coreUrl + 'rest/administration/status/new') .map(function (res) { return res.json(); }) .subscribe(function (data) { _this.lang = data['lang']; @@ -80,7 +80,7 @@ var StatusAdministrationComponent = (function () { }; StatusAdministrationComponent.prototype.getStatusInfos = function (statusIdentifier) { var _this = this; - this.http.get(this.coreUrl + 'rest/status/' + statusIdentifier) + this.http.get(this.coreUrl + 'rest/administration/status/' + statusIdentifier) .map(function (res) { return res.json(); }) .subscribe(function (data) { _this.status = data['status'][0]; diff --git a/apps/maarch_entreprise/js/angular/app/status-administration.component.ts b/apps/maarch_entreprise/js/angular/app/status-administration.component.ts index f257d972fe2a977e8b63b49e5419ce654381d08d..4961d7d64af9d75aa69af43c601f4cbea456a838 100644 --- a/apps/maarch_entreprise/js/angular/app/status-administration.component.ts +++ b/apps/maarch_entreprise/js/angular/app/status-administration.component.ts @@ -40,8 +40,8 @@ export class StatusAdministrationComponent implements OnInit { this.prepareStatus(); this.route.params.subscribe((params) => { - if (this.route.toString().includes('status/new')){ - this.http.get(this.coreUrl + 'rest/status/new') + if (typeof params['identifier'] == "undefined"){ + this.http.get(this.coreUrl + 'rest/administration/status/new') .map(res => res.json()) .subscribe((data) => { this.lang = data['lang']; @@ -82,7 +82,7 @@ export class StatusAdministrationComponent implements OnInit { } getStatusInfos(statusIdentifier : string){ - this.http.get(this.coreUrl + 'rest/status/'+statusIdentifier) + this.http.get(this.coreUrl + 'rest/administration/status/'+statusIdentifier) .map(res => res.json()) .subscribe((data) => { this.status = data['status'][0]; diff --git a/apps/maarch_entreprise/js/angular/app/status-list-administration.component.js b/apps/maarch_entreprise/js/angular/app/status-list-administration.component.js index 82d8e21e921e035ab699af33eb20300a4426eb75..5230f002d817e565421578717a764eaebcfe90b0 100644 --- a/apps/maarch_entreprise/js/angular/app/status-list-administration.component.js +++ b/apps/maarch_entreprise/js/angular/app/status-list-administration.component.js @@ -54,7 +54,8 @@ var StatusListAdministrationComponent = (function () { "order": [[2, "asc"]], "columnDefs": [ { "orderable": false, "targets": [0, 3] } - ] + ], + "stateSave": true }); $j('.dataTables_filter input').attr("placeholder", _this.lang.search); $j('dataTables_filter input').addClass('form-control'); diff --git a/apps/maarch_entreprise/js/angular/app/status-list-administration.component.ts b/apps/maarch_entreprise/js/angular/app/status-list-administration.component.ts index bfbcc6534a0af403db261c52cea5969e98d83fc6..f20bf156a0c1138815293de610ea737ead60cb3e 100644 --- a/apps/maarch_entreprise/js/angular/app/status-list-administration.component.ts +++ b/apps/maarch_entreprise/js/angular/app/status-list-administration.component.ts @@ -61,7 +61,8 @@ export class StatusListAdministrationComponent implements OnInit { "order": [[ 2, "asc" ]], "columnDefs": [ { "orderable": false, "targets": [0,3] } - ] + ], + "stateSave": true }); $j('.dataTables_filter input').attr("placeholder", this.lang.search); $j('dataTables_filter input').addClass('form-control'); diff --git a/core/Controllers/StatusController.php b/core/Controllers/StatusController.php index 9e9752c11815a630d39ba30ce58fdb1f9740b575..9c788124090e300f575f0be1b00ff890f1c71fa5 100644 --- a/core/Controllers/StatusController.php +++ b/core/Controllers/StatusController.php @@ -86,9 +86,19 @@ class StatusController } if (StatusModel::create($aArgs)) { - return $response->withJson([ + $return = [ StatusModel::getById(['id' => $aArgs['id']]) + ]; + + HistoryController::add([ + 'table_name' => 'status', + 'record_id' => $return[0][0]['id'], + 'event_type' => 'ADD', + 'event_id' => 'statusup', + 'info' => _STATUS_ADDED . ' : ' . $return[0][0]['id'] ]); + + return $response->withJson($return); } else { return $response->withStatus(500)->withJson(['errors' => _NOT_CREATE]); } @@ -185,9 +195,8 @@ class StatusController if(!Validator::notEmpty()->validate($request['id'])){ array_push($errors, _ID . ' ' . _EMPTY); } else if ($mode == 'create') { - $obj = StatusModel::getById([ - 'id' => $request['id'] - ]); + $obj = StatusModel::getById(['id' => $request['id']]); + if (!empty($obj)) { array_push( $errors, @@ -195,9 +204,8 @@ class StatusController ); } } elseif ($mode == 'update') { - $obj = StatusModel::getByIdentifier([ - 'identifier' => $request['identifier'] - ]); + $obj = StatusModel::getByIdentifier(['identifier' => $request['identifier']]); + if (empty($obj)) { array_push( $errors, diff --git a/rest/index.php b/rest/index.php index e77c3c720a641ef9df61d9bf8f07b7b69b5304cb..e5849fb0727427bd95761414e109338aa35e9933 100644 --- a/rest/index.php +++ b/rest/index.php @@ -107,8 +107,8 @@ $app->get('/administration/users/{id}', \Core\Controllers\UserController::class //status $app->get('/administration/status', \Core\Controllers\StatusController::class . ':getList'); -$app->get('/status/new', \Core\Controllers\StatusController::class . ':getNewInformations'); -$app->get('/status/{identifier}', \Core\Controllers\StatusController::class . ':getByIdentifier'); +$app->get('/administration/status/new', \Core\Controllers\StatusController::class . ':getNewInformations'); +$app->get('/administration/status/{identifier}', \Core\Controllers\StatusController::class . ':getByIdentifier'); $app->post('/status', \Core\Controllers\StatusController::class . ':create'); $app->put('/status/{identifier}', \Core\Controllers\StatusController::class . ':update'); $app->delete('/status/{identifier}', \Core\Controllers\StatusController::class . ':delete');