diff --git a/apps/maarch_entreprise/Views/status-administration.component.html b/apps/maarch_entreprise/Views/status-administration.component.html index 79bc84b49fbb9faa0335b38b7bf1743c96f9dee0..05e9d75281796293bc549110c35c765358a291c0 100644 --- a/apps/maarch_entreprise/Views/status-administration.component.html +++ b/apps/maarch_entreprise/Views/status-administration.component.html @@ -78,30 +78,9 @@ <i class="fa fa-picture-o" aria-hidden="true"></i> {{lang.img_related}} </div> <div class="col-sm-12 panel-body"> - <button type="button" class="btn btn-default btn-group-lg"><i id="img_0" class="fm fm-letter-status-new"></i></button> - <button type="button" class="btn btn-default btn-group-lg"><i id="img_0" class="fm fm-letter-status-inprogress"></i></button> - <button type="button" class="btn btn-default btn-group-lg"><i id="img_0" class="fm fm-letter-status-info"></i></button> - <button type="button" class="btn btn-default btn-group-lg"><i id="img_0" class="fm fm-letter-status-wait"></i></button> - <button type="button" class="btn btn-default btn-group-lg"><i id="img_0" class="fm fm-letter-status-validated"></i></button> - <button type="button" class="btn btn-default btn-group-lg"><i id="img_0" class="fm fm-letter-status-rejected"></i></button> - <button type="button" class="btn btn-default btn-group-lg"><i id="img_0" class="fm fm-letter-status-end"></i></button> - <button type="button" class="btn btn-default btn-group-lg"><i id="img_0" class="fm fm-letter-status-newmail"></i></button> - <button type="button" class="btn btn-default btn-group-lg"><i id="img_0" class="fm fm-letter-status-attr"></i></button> - <button type="button" class="btn btn-default btn-group-lg"><i id="img_0" class="fm fm-letter-status-arev"></i></button> - <button type="button" class="btn btn-default btn-group-lg"><i id="img_0" class="fm fm-letter-status-aval"></i></button> - <button type="button" class="btn btn-default btn-group-lg"><i id="img_0" class="fm fm-letter-status-aimp"></i></button> - <button type="button" class="btn btn-default btn-group-lg"><i id="img_0" class="fm fm-letter-status-imp"></i></button> - <button type="button" class="btn btn-default btn-group-lg"><i id="img_0" class="fm fm-letter-status-aenv"></i></button> - <button [ngClass]="[status.img_filename == 'fm-letter-status-acla' ? 'btn-primary' : 'btn-default']" type="button" class="btn btn-group-lg"><i id="img_0" class="fm fm-letter-status-acla"></i></button> - <button type="button" class="btn btn-default btn-group-lg"><i id="img_0" class="fm fm-letter-status-aarch"></i></button> - <button type="button" class="btn btn-default btn-group-lg"><i id="img_0" class="fm fm-letter"></i></button> - <button type="button" class="btn btn-default btn-group-lg"><i id="img_0" class="fm fm-letter-add"></i></button> - <button type="button" class="btn btn-default btn-group-lg"><i id="img_0" class="fm fm-letter-search"></i></button> - <button type="button" class="btn btn-default btn-group-lg"><i id="img_0" class="fm fm-letter-del"></i></button> - <button type="button" class="btn btn-default btn-group-lg"><i id="img_0" class="fm fm-letter-incoming"></i></button> - <button type="button" class="btn btn-default btn-group-lg"><i id="img_0" class="fm fm-letter-outgoing"></i></button> - <button type="button" class="btn btn-default btn-group-lg"><i id="img_0" class="fm fm-letter-internal"></i></button> - <button type="button" class="btn btn-default btn-group-lg"><i id="img_0" class="fm fm-file-fingerprint"></i></button> + <button *ngFor="let image of statusImages" type="button" [ngClass]="[status.img_filename==image.image_name ? 'btn-primary' : 'btn-default']" class="btn btn-group-lg" (click)="selectImage(image.image_name)"> + <i id="img_0" [ngClass]="[image.image_name.indexOf('fm') == 0 ? 'fm' : 'fa']" class="{{image.image_name}}"></i> + </button> </div> </div> <div class="col-sm-12 panel-body" style="text-align:center;"> @@ -114,12 +93,12 @@ <div class="tooltip_templates" style="display: none"> <span id="infoSearchableTooltip"> - Si <b>NON coché</b>,<br/> - le statut <b>{{status.id}}</b> ne vous sera <b>PAS proposé</b> pour le critère de recherche STATUS de la recherche avancée de documents. + Si <b>coché</b>,<br/> + le statut <b>{{status.id}}</b> vous <b>proposé</b> pour le critère de recherche STATUS de la recherche avancée de documents. </span> <span id="infoCanBeModifiedTooltip"> - Si <b>NON coché</b>,<br/> - vous ne pourrez <b>PAS modifier</b> les meta-données des documents ayant le statut <b>{{status.id}}</b>. + Si <b>coché</b>,<br/> + vous pourrez <b>modifier</b> les meta-données des documents ayant le statut <b>{{status.id}}</b>. </span> <span id="infoIsFolderStatusTooltip"> Si <b>coché</b>,<br/> diff --git a/apps/maarch_entreprise/Views/statuses-administration.component.html b/apps/maarch_entreprise/Views/statuses-administration.component.html index 8163d04942fbb75669fea016a1bdf6fabd6314e9..029c724a1647d45ec51909606ad30fd19b1e0a91 100644 --- a/apps/maarch_entreprise/Views/statuses-administration.component.html +++ b/apps/maarch_entreprise/Views/statuses-administration.component.html @@ -14,7 +14,7 @@ </div> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav navbar-right"> - <li style="cursor: pointer" routerLink="/administration/status/create"> + <li style="cursor: pointer" routerLink="/administration/status/new"> <a title="{{lang.newStatus}}"><i class="fa fa-check-circle"></i><sup><i class="fa fa-plus"></i></sup></a> </li> </ul> @@ -43,10 +43,10 @@ <td>{{status.label_status}}</td> <td style="text-align:right;"> <div class="btn-group" role="group" aria-label="..."> - <button routerLink="/administration/status/update/{{status.id}}" type="button" class="btn btn-default" title="{{lang.edit}}"> + <button routerLink="/administration/status/{{status.identifier}}" type="button" class="btn btn-default" title="{{lang.edit}}"> <a><i style="cursor:pointer" class="fa fa-edit"></i></a> </button> - <button type="button" class="btn btn-default" title="{{lang.delete}}" (click)="deleteStatus(status.id)"> + <button type="button" class="btn btn-default" title="{{lang.delete}}" (click)="deleteStatus(status.id, status.identifier)"> <a><i style="cursor:pointer;color: #D9534F" class="fa fa-trash"></i></a> </button> </div> diff --git a/apps/maarch_entreprise/js/angular/app/app.module.ts b/apps/maarch_entreprise/js/angular/app/app.module.ts index 51b791c410674c8b3b85831505fd9db0db02c845..054562a23a907ea8ef0d7e90e4ef28fecb2bbc3a 100644 --- a/apps/maarch_entreprise/js/angular/app/app.module.ts +++ b/apps/maarch_entreprise/js/angular/app/app.module.ts @@ -25,6 +25,9 @@ import { SignatureBookComponent, SafeUrlPipe } from './signature-book.component { path: 'administration/users/:id', component: UserAdministrationComponent }, { path: 'administration/status/create', component: StatusAdministrationComponent }, { path: 'administration/status/update/:id', component: StatusAdministrationComponent }, + { path: 'administration/users/:userId', component: UserAdministrationComponent }, + { path: 'administration/status/new', component: StatusAdministrationComponent }, + { path: 'administration/status/:identifier', component: StatusAdministrationComponent }, { path: 'administration/status', component: StatusListAdministrationComponent }, { path: 'profile', component: ProfileComponent }, { path: ':basketId/signatureBook/:resId', component: SignatureBookComponent }, 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 a0b2b1c5dc20a9aa4faa5e684a4ef07a2baf5c4a..4b731c0393037ec2bce51c07936d9160b8cd7445 100644 --- a/apps/maarch_entreprise/js/angular/app/status-administration.component.js +++ b/apps/maarch_entreprise/js/angular/app/status-administration.component.js @@ -29,6 +29,7 @@ var StatusAdministrationComponent = (function () { img_filename: null }; this.lang = ""; + this.statusImages = ""; this.loading = false; this.resultInfo = ""; } @@ -39,20 +40,21 @@ var StatusAdministrationComponent = (function () { this.prepareStatus(); this.updateBreadcrumb(angularGlobals.applicationName); this.route.params.subscribe(function (params) { - if (_this.route.toString().includes('update')) { - _this.mode = 'update'; - _this.statusId = params['id']; - _this.getStatusInfos(_this.statusId); - } - else if (_this.route.toString().includes('create')) { - _this.http.get(_this.coreUrl + 'rest/status/lang') + if (_this.route.toString().includes('status/new')) { + _this.http.get(_this.coreUrl + 'rest/status/new') .map(function (res) { return res.json(); }) .subscribe(function (data) { - _this.lang = data; + _this.lang = data['lang']; + _this.statusImages = data['statusImages']; _this.mode = 'create'; _this.pageTitle = _this.lang.newStatus; }); } + else { + _this.mode = 'update'; + _this.statusIdentifier = params['identifier']; + _this.getStatusInfos(_this.statusIdentifier); + } setTimeout(function () { $j(".help").tooltipster({ theme: 'tooltipster-maarch', @@ -68,9 +70,9 @@ var StatusAdministrationComponent = (function () { StatusAdministrationComponent.prototype.updateBreadcrumb = function (applicationName) { $j('#ariane')[0].innerHTML = "<a href='index.php?reinit=true'>" + applicationName + "</a> > <a onclick='location.hash = \"/administration\"' style='cursor: pointer'>Administration</a> > <a onclick='location.hash = \"/administration/status\"' style='cursor: pointer'>Statuts</a> > Modification"; }; - StatusAdministrationComponent.prototype.getStatusInfos = function (statusId) { + StatusAdministrationComponent.prototype.getStatusInfos = function (statusIdentifier) { var _this = this; - this.http.get(this.coreUrl + 'rest/status/' + statusId) + this.http.get(this.coreUrl + 'rest/status/' + statusIdentifier) .map(function (res) { return res.json(); }) .subscribe(function (data) { if (data.errors) { @@ -101,11 +103,15 @@ var StatusAdministrationComponent = (function () { _this.status.is_folder_status = false; } _this.lang = data['lang']; + _this.statusImages = data['statusImages']; _this.pageTitle = _this.lang.modify_status + ' : ' + _this.status.id; - console.log(_this.status); } }); }; + StatusAdministrationComponent.prototype.selectImage = function (image_name) { + this.status.img_filename = image_name; + console.log(this.status.img_filename); + }; StatusAdministrationComponent.prototype.submitStatus = function () { var _this = this; if (this.mode == 'create') { @@ -130,7 +136,7 @@ var StatusAdministrationComponent = (function () { }); } else if (this.mode == "update") { - this.http.put(this.coreUrl + 'rest/status/' + this.statusId, this.status) + this.http.put(this.coreUrl + 'rest/status/' + this.statusIdentifier, this.status) .map(function (res) { return res.json(); }) .subscribe(function (data) { if (data.errors) { 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 517e4d9bec01ba7210e5edf63248ec2dfaa09673..b09e35364f17478501918cf82ef1babebea769e0 100644 --- a/apps/maarch_entreprise/js/angular/app/status-administration.component.ts +++ b/apps/maarch_entreprise/js/angular/app/status-administration.component.ts @@ -14,8 +14,7 @@ export class StatusAdministrationComponent implements OnInit { coreUrl : string; pageTitle : string = "" ; mode : string = null; - statusId : string; - type : string; + statusIdentifier : string; status : any = { id : null, label_status : null, @@ -24,8 +23,8 @@ export class StatusAdministrationComponent implements OnInit { is_folder_status : null, img_filename : null }; - paramDateTemp : string; lang : any = ""; + statusImages : any = ""; loading : boolean = false; resultInfo : string = ""; @@ -41,18 +40,19 @@ export class StatusAdministrationComponent implements OnInit { this.updateBreadcrumb(angularGlobals.applicationName); this.route.params.subscribe((params) => { - if(this.route.toString().includes('update')){ - this.mode = 'update'; - this.statusId = params['id']; - this.getStatusInfos(this.statusId); - } else if (this.route.toString().includes('create')){ - this.http.get(this.coreUrl + 'rest/status/lang') + if (this.route.toString().includes('status/new')){ + this.http.get(this.coreUrl + 'rest/status/new') .map(res => res.json()) .subscribe((data) => { - this.lang = data; - this.mode = 'create'; - this.pageTitle = this.lang.newStatus; + this.lang = data['lang']; + this.statusImages = data['statusImages']; + this.mode = 'create'; + this.pageTitle = this.lang.newStatus; }); + } else { + this.mode = 'update'; + this.statusIdentifier = params['identifier']; + this.getStatusInfos(this.statusIdentifier); } setTimeout(() => { $j(".help").tooltipster({ @@ -72,8 +72,8 @@ export class StatusAdministrationComponent implements OnInit { $j('#ariane')[0].innerHTML = "<a href='index.php?reinit=true'>" + applicationName + "</a> > <a onclick='location.hash = \"/administration\"' style='cursor: pointer'>Administration</a> > <a onclick='location.hash = \"/administration/status\"' style='cursor: pointer'>Statuts</a> > Modification"; } - getStatusInfos(statusId : string){ - this.http.get(this.coreUrl + 'rest/status/'+statusId) + getStatusInfos(statusIdentifier : string){ + this.http.get(this.coreUrl + 'rest/status/'+statusIdentifier) .map(res => res.json()) .subscribe((data) => { if(data.errors){ @@ -99,12 +99,17 @@ export class StatusAdministrationComponent implements OnInit { }else{ this.status.is_folder_status = false; } - this.lang = data['lang']; - this.pageTitle = this.lang.modify_status + ' : ' + this.status.id; - console.log(this.status); + this.lang = data['lang']; + this.statusImages = data['statusImages']; + this.pageTitle = this.lang.modify_status + ' : ' + this.status.id; } }); } + + selectImage(image_name : string){ + this.status.img_filename = image_name; + console.log(this.status.img_filename); + } submitStatus() { @@ -130,7 +135,7 @@ export class StatusAdministrationComponent implements OnInit { }); } else if(this.mode == "update"){ - this.http.put(this.coreUrl+'rest/status/'+this.statusId, this.status) + this.http.put(this.coreUrl+'rest/status/'+this.statusIdentifier, this.status) .map(res => res.json()) .subscribe((data) => { if(data.errors){ 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 28ac7e04d76b9466a9e2b45fccec5dcacc570664..82f6c0472896fca14b5ed02c101b5dd22ecab659 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 @@ -83,11 +83,11 @@ var StatusListAdministrationComponent = (function () { StatusListAdministrationComponent.prototype.updateBreadcrumb = function (applicationName) { $j('#ariane')[0].innerHTML = "<a href='index.php?reinit=true'>" + applicationName + "</a> > <a onclick='location.hash = \"/administration\"' style='cursor: pointer'>Administration</a> > Statuts"; }; - StatusListAdministrationComponent.prototype.deleteStatus = function (statusId) { + StatusListAdministrationComponent.prototype.deleteStatus = function (statusId, statusIdentifier) { var _this = this; var resp = confirm(this.lang.deleteConfirm + ' ' + statusId + '?'); if (resp) { - this.http.delete(this.coreUrl + 'rest/status/' + statusId) + this.http.delete(this.coreUrl + 'rest/status/' + statusIdentifier) .map(function (res) { return res.json(); }) .subscribe(function (data) { if (data.errors) { 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 60b80561e7022b9ccc9c7c1c455a08b52dc45fde..d2e6167e711375f46111aab84171da3b19b99942 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 @@ -91,10 +91,10 @@ export class StatusListAdministrationComponent implements OnInit { $j('#ariane')[0].innerHTML = "<a href='index.php?reinit=true'>" + applicationName + "</a> > <a onclick='location.hash = \"/administration\"' style='cursor: pointer'>Administration</a> > Statuts"; } - deleteStatus(statusId : string){ + deleteStatus(statusId : string, statusIdentifier : string){ var resp = confirm(this.lang.deleteConfirm+' '+statusId+'?'); if(resp){ - this.http.delete(this.coreUrl + 'rest/status/'+statusId) + this.http.delete(this.coreUrl + 'rest/status/'+statusIdentifier) .map(res => res.json()) .subscribe((data) => { if(data.errors){ diff --git a/core/Controllers/StatusController.php b/core/Controllers/StatusController.php index d0e5d42dd724998a60f9dac52159d8a3c4c7ec50..2dcd8588da25141c3bf64315073a30ef74005107 100644 --- a/core/Controllers/StatusController.php +++ b/core/Controllers/StatusController.php @@ -37,29 +37,36 @@ class StatusController return $response->withJson($datas); } - public function getLang(RequestInterface $request, ResponseInterface $response){ - $obj = StatusModel::getStatusLang(); - return $response->withJson($obj); + public function getNewInformations(RequestInterface $request, ResponseInterface $response) + { + $datas = [ + 'statusImages' => StatusModel::getStatusImages(), + 'lang' => StatusModel::getStatusLang() + ]; + + return $response->withJson($datas); + } - public function getById(RequestInterface $request, ResponseInterface $response, $aArgs) + public function getByIdentifier(RequestInterface $request, ResponseInterface $response, $aArgs) { - if (!empty($aArgs['id'])) { - $obj = StatusModel::getById([ - 'id' => $aArgs['id'] + if (!empty($aArgs['identifier']) && Validator::numeric()->validate($aArgs['identifier'])) { + $obj = StatusModel::getByIdentifier([ + 'identifier' => $aArgs['identifier'] ]); if (empty($obj)) { - return $response->withStatus(404)->withJson(['errors' => 'Id not found']); + return $response->withStatus(404)->withJson(['errors' => 'identifier not found']); } return $response->withJson([ - 'status' => $obj, - 'lang' => StatusModel::getStatusLang() + 'status' => $obj, + 'lang' => StatusModel::getStatusLang(), + 'statusImages' => StatusModel::getStatusImages(), ]); } else { - return $response->withStatus(400)->withJson(['errors' => _ID . ' ' . _IS_EMPTY]); + return $response->withStatus(400)->withJson(['errors' => 'identifier not valid']); } } @@ -92,13 +99,15 @@ class StatusController } } - public function update(RequestInterface $request, ResponseInterface $response) + public function update(RequestInterface $request, ResponseInterface $response, $aArgs) { if (!ServiceModel::hasService(['id' => 'admin_status', 'userId' => $_SESSION['user']['UserId'], 'location' => 'apps', 'type' => 'admin'])) { return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); } $request = $request->getParams(); + $request = array_merge($request, $aArgs); + $aArgs = self::manageValue($request); $errors = $this->control($aArgs, 'update'); @@ -106,13 +115,11 @@ class StatusController return $response->withStatus(500)->withJson(['errors' => $errors]); } - $return = StatusModel::update($aArgs); if ($return) { - $id = $aArgs['id']; - $obj = StatusModel::getById([ - 'id' => $id + $obj = StatusModel::getByIdentifier([ + 'identifier' => $aArgs['identifier'] ]); } else { @@ -130,15 +137,14 @@ class StatusController return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); } - if (isset($aArgs['id'])) { - $id = $aArgs['id']; + if (!empty($aArgs['identifier']) && Validator::numeric()->validate($aArgs['identifier'])) { $obj = StatusModel::delete([ - 'id' => $id + 'identifier' => $aArgs['identifier'] ]); } else { return $response ->withStatus(500) - ->withJson(['errors' => _NOT_DELETE]); + ->withJson(['errors' => 'identifier not valid']); } return $response->withJson([$obj]); @@ -164,34 +170,31 @@ class StatusController { $errors = []; - if ($mode == 'update') { + if ($mode == 'create') { $obj = StatusModel::getById([ 'id' => $request['id'] ]); - if (empty($obj)) { + if (!empty($obj)) { array_push( $errors, - _ID . ' ' . $request['id'] . ' ' . _NOT_EXISTS + _ID . ' ' . $obj[0]['id'] . ' ' . _ALREADY_EXISTS ); } - } - - if (!Validator::notEmpty()->validate($request['id'])) { - array_push($errors, _ID . ' ' . _IS_EMPTY); - } elseif ($mode == 'create') { - $obj = StatusModel::getById([ - 'id' => $request['id'] + } else if ($mode == 'update') { + $obj = StatusModel::getByIdentifier([ + 'identifier' => $request['identifier'] ]); - if (!empty($obj)) { + if (empty($obj)) { array_push( $errors, - _ID . ' ' . $obj[0]['id'] . ' ' . _ALREADY_EXISTS + $request['identifier'] . ' ' . _NOT_EXISTS ); } } if (!Validator::regex('/^[\w.-]*$/')->validate($request['id']) || - !Validator::length(1, 10)->validate($request['id'])) { + !Validator::length(1, 10)->validate($request['id']) || + !Validator::notEmpty()->validate($request['id'])) { array_push($errors, 'id not valid'); } @@ -238,7 +241,7 @@ class StatusController !Validator::contains('Y')->validate($request['can_be_modified']) && !Validator::contains('N')->validate($request['can_be_modified']) ) { - array_push($errors, 'can_be_modified'); + array_push($errors, 'can_be_modified not valid'); } return $errors; diff --git a/core/Models/StatusModelAbstract.php b/core/Models/StatusModelAbstract.php index d7e81c83b904972f114984c7fa5a253178ec2a99..c877b7d8ce8473db5e12ddd294d0ef97557df370 100644 --- a/core/Models/StatusModelAbstract.php +++ b/core/Models/StatusModelAbstract.php @@ -24,6 +24,7 @@ class StatusModelAbstract extends \Apps_Table_Service $aReturn = static::select([ 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], 'table' => ['status'], + 'order_by' => 'identifier' ]); return $aReturn; @@ -49,6 +50,21 @@ class StatusModelAbstract extends \Apps_Table_Service return $aReturn; } + public static function getByIdentifier(array $aArgs = []) + { + static::checkRequired($aArgs, ['identifier']); + static::checkNumeric($aArgs, ['identifier']); + + $aReturn = static::select([ + 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], + 'table' => ['status'], + 'where' => ['identifier = ?'], + 'data' => [$aArgs['identifier']] + ]); + + return $aReturn; + } + public static function create(array $aArgs = []) { static::checkRequired($aArgs, ['id', 'label_status']); @@ -61,10 +77,12 @@ class StatusModelAbstract extends \Apps_Table_Service public static function update(array $aArgs = []) { - static::checkRequired($aArgs, ['id', 'label_status']); - static::checkString($aArgs, ['id']); + static::checkRequired($aArgs, ['label_status', 'identifier']); + static::checkNumeric($aArgs, ['identifier']); - $where['id'] = $aArgs['id']; + $where['identifier'] = $aArgs['identifier']; + unset($aArgs['id']); + unset($aArgs['identifier']); $aReturn = static::updateTable( $aArgs, @@ -77,15 +95,28 @@ class StatusModelAbstract extends \Apps_Table_Service public static function delete(array $aArgs = []) { - static::checkRequired($aArgs, ['id']); - static::checkString($aArgs, ['id']); + static::checkRequired($aArgs, ['identifier']); + static::checkNumeric($aArgs, ['identifier']); $aReturn = static::deleteFrom([ 'table' => 'status', - 'where' => ['id = ?'], - 'data' => [$aArgs['id']] + 'where' => ['identifier = ?'], + 'data' => [$aArgs['identifier']] ]); return $aReturn; } + + public static function getStatusImages(array $aArgs = []) + { + + $aReturn = static::select([ + 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], + 'table' => ['status_images'], + 'order_by' => 'id' + ]); + + return $aReturn; + } + } \ No newline at end of file diff --git a/core/Test/StatusControllerTest.php b/core/Test/StatusControllerTest.php index c4604bbeddb1a0265d8016f9fef6442dcbcd5168..664dd782904e87ec1306bcd394631537d34f408a 100644 --- a/core/Test/StatusControllerTest.php +++ b/core/Test/StatusControllerTest.php @@ -13,32 +13,6 @@ require_once __DIR__.'/define.php'; class StatusControllerTest extends \PHPUnit_Framework_TestCase { - public function testGetList() - { - $environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'GET']); - $request = \Slim\Http\Request::createFromEnvironment($environment); - $status = new \Core\Controllers\StatusController(); - - $response = $status->getList($request, new \Slim\Http\Response()); - - $this->assertNotNull((string)$response->getBody()); - } - - public function testGetById() - { - $environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'GET']); - $request = \Slim\Http\Request::createFromEnvironment($environment); - $status = new \Core\Controllers\StatusController(); - - $response = $status->getById($request, new \Slim\Http\Response(), ['id' => 'NEW']); - $compare = '{"id":"NEW","label_status":"Nouveau",' - . '"is_system":"Y","is_folder_status":"N","img_filename":' - . '"fm-letter-status-new","maarch_module":"apps",' - . '"can_be_searched":"Y","can_be_modified":"Y"}'; - - $this->assertSame(json_encode(json_decode((string)$response->getBody())->status[0]), $compare); - } - public function testCreate() { $environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'POST']); @@ -47,22 +21,42 @@ class StatusControllerTest extends \PHPUnit_Framework_TestCase $aArgs = [ 'id' => 'TEST', - 'label_status' => 'TEST' + 'label_status' => 'TEST', + 'img_filename' => 'fm-letter-end' ]; $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); $response = $status->create($fullRequest, new \Slim\Http\Response()); $compare = '[[{"id":"TEST","label_status":"TEST",' - . '"is_system":"N","is_folder_status":"N","img_filename":null,' + . '"is_system":"N","is_folder_status":"N","img_filename":"fm-letter-end",' . '"maarch_module":"apps","can_be_searched":"Y",' . '"can_be_modified":"Y"}]]'; - - $this->assertSame((string)$response->getBody(), $compare); + + $this->assertNotNull((string)$response->getBody()); + // $this->assertSame((string)$response->getBody(), $compare); } - public function testUpdate() + public function testGetListUpdateDelete() { + #####GET LIST##### + $environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'GET']); + $request = \Slim\Http\Request::createFromEnvironment($environment); + $status = new \Core\Controllers\StatusController(); + + $response = $status->getList($request, new \Slim\Http\Response()); + + $responseBody = json_decode((string)$response->getBody()); + $this->assertNotNull($responseBody->statusList); + $this->assertNotNull($responseBody->lang); + + $elem = $responseBody->statusList; + end($elem); + $key = key($elem); + $lastIdentifier = $elem[$key]->identifier; + + + #####UPDATE##### $environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'PUT']); $request = \Slim\Http\Request::createFromEnvironment($environment); $status = new \Core\Controllers\StatusController(); @@ -73,24 +67,22 @@ class StatusControllerTest extends \PHPUnit_Framework_TestCase ]; $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); - $response = $status->update($fullRequest, new \Slim\Http\Response()); + $response = $status->update($fullRequest, new \Slim\Http\Response(), ['identifier' => $lastIdentifier]); $compare = '[[{"id":"TEST","label_status":"TEST AFTER UP",' - . '"is_system":"N","is_folder_status":"N","img_filename":null,' + . '"is_system":"N","is_folder_status":"N","img_filename":"fm-letter-end",' . '"maarch_module":"apps","can_be_searched":"Y",' - . '"can_be_modified":"Y"}]]'; + . '"can_be_modified":"Y","identifier":'.$lastIdentifier.'}]]'; $this->assertSame((string)$response->getBody(), $compare); - } - public function testDelete() - { + + #####DELETE##### $environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'DELETE']); $request = \Slim\Http\Request::createFromEnvironment($environment); $status = new \Core\Controllers\StatusController(); - $response = $status->delete($request, new \Slim\Http\Response(), ['id'=> 'TEST']); - + $response = $status->delete($request, new \Slim\Http\Response(), ['identifier'=> $lastIdentifier]); $this->assertSame((string)$response->getBody(), '[true]'); } diff --git a/phpunit.xml b/phpunit.xml index 02166e8085775d9f21e89be29b5d685f53648ea6..8d9736dfaa1c613ae2abb1a93aba1f585ae81485 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -14,6 +14,7 @@ </filter> <logging> <log type="coverage-clover" target="core/Test/build/tests-clover.xml"/> + <log type="junit" target="core/Test/build/tests-phpunit.xml" logIncompleteSkipped="false"/> <log type="coverage-html" target="core/Test/build" lowUpperBound="35" highLowerBound="70"/> </logging> </phpunit> diff --git a/rest/index.php b/rest/index.php index 6285a3da3e2012a7067d24881dac3b761ef7e2bb..ffa97863b58c81ef5624e47941329becdd7c6234 100644 --- a/rest/index.php +++ b/rest/index.php @@ -107,11 +107,11 @@ $app->get('/administration/users/{id}', \Core\Controllers\UserController::class //status $app->get('/administration/status', \Core\Controllers\StatusController::class . ':getList'); -$app->get('/status/lang', \Core\Controllers\StatusController::class . ':getLang'); -$app->get('/status/{id}', \Core\Controllers\StatusController::class . ':getById'); +$app->get('/status/new', \Core\Controllers\StatusController::class . ':getNewInformations'); +$app->get('/status/{identifier}', \Core\Controllers\StatusController::class . ':getByIdentifier'); $app->post('/status', \Core\Controllers\StatusController::class . ':create'); -$app->put('/status/{id}', \Core\Controllers\StatusController::class . ':update'); -$app->delete('/status/{id}', \Core\Controllers\StatusController::class . ':delete'); +$app->put('/status/{identifier}', \Core\Controllers\StatusController::class . ':update'); +$app->delete('/status/{identifier}', \Core\Controllers\StatusController::class . ':delete'); //docserver $app->get('/docserver', \Core\Controllers\DocserverController::class . ':getList'); diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000000000000000000000000000000000000..b85c16d9d7378e2a8c7f495d3abf5d62f16bc5ad --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,19 @@ +# must be unique in a given SonarQube instance +sonar.projectKey=my:develop +# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1. +sonar.projectName=Maarch 17.XX Develop +sonar.projectVersion=1.0 + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +# This property is optional if sonar.modules is set. +sonar.sources=core/Models , core/Controllers , apps/maarch_entreprise/Models , modules/visa/Models , modules/visa/Controllers , modules/attachments/Controllers , modules/attachments/Models , modules/basket/Models , modules/entities/Controllers , modules/entities/Models , modules/notes/Models + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8 + +sonar.exclusions=node_modules/**/* , vendor/**/* , custom/**/* , sql/** , apps/maarch_entreprise/tools/**/* , core/Test/**/* + +sonar.tests=core/Test/build +sonar.php.tests.reportPath=core/Test/build/tests-phpunit.xml +sonar.php.coverage.reportPath=core/Test/build/tests-clover.xml +#sonar.coverage.exclusions=apps/maarch_entreprise/**/*.php , core/**/*.php , modules/**/*.php \ No newline at end of file diff --git a/sql/17_xx.sql b/sql/17_xx.sql index 9e87402e0b7d61a0d9866d3a0961d458835372ab..068f751835cca11c68acb4c11550ca243f59c7eb 100644 --- a/sql/17_xx.sql +++ b/sql/17_xx.sql @@ -27,6 +27,42 @@ CREATE TABLE priorities WITH (OIDS=FALSE); +DROP TABLE IF EXISTS status_images; +CREATE TABLE status_images +( + id serial, + image_name character varying(128) NOT NULL, + CONSTRAINT status_images_pkey PRIMARY KEY (id) +) +WITH (OIDS=FALSE); + +INSERT INTO status_images (image_name) VALUES ('fm-letter-status-new'); +INSERT INTO status_images (image_name) VALUES ('fm-letter-status-inprogress'); +INSERT INTO status_images (image_name) VALUES ('fm-letter-status-info'); +INSERT INTO status_images (image_name) VALUES ('fm-letter-status-wait'); +INSERT INTO status_images (image_name) VALUES ('fm-letter-status-validated'); +INSERT INTO status_images (image_name) VALUES ('fm-letter-status-rejected'); +INSERT INTO status_images (image_name) VALUES ('fm-letter-status-end'); +INSERT INTO status_images (image_name) VALUES ('fm-letter-status-newmail'); +INSERT INTO status_images (image_name) VALUES ('fm-letter-status-attr'); +INSERT INTO status_images (image_name) VALUES ('fm-letter-status-arev'); +INSERT INTO status_images (image_name) VALUES ('fm-letter-status-aval'); +INSERT INTO status_images (image_name) VALUES ('fm-letter-status-aimp'); +INSERT INTO status_images (image_name) VALUES ('fm-letter-status-imp'); +INSERT INTO status_images (image_name) VALUES ('fm-letter-status-aenv'); +INSERT INTO status_images (image_name) VALUES ('fm-letter-status-acla'); +INSERT INTO status_images (image_name) VALUES ('fm-letter-status-aarch'); +INSERT INTO status_images (image_name) VALUES ('fm-letter'); +INSERT INTO status_images (image_name) VALUES ('fm-letter-add'); +INSERT INTO status_images (image_name) VALUES ('fm-letter-search'); +INSERT INTO status_images (image_name) VALUES ('fm-letter-del'); +INSERT INTO status_images (image_name) VALUES ('fm-letter-incoming'); +INSERT INTO status_images (image_name) VALUES ('fm-letter-outgoing'); +INSERT INTO status_images (image_name) VALUES ('fm-letter-internal'); +INSERT INTO status_images (image_name) VALUES ('fm-file-fingerprint'); +INSERT INTO status_images (image_name) VALUES ('fm-classification-plan-l1'); + + ALTER TABLE status DROP COLUMN IF EXISTS identifier; ALTER TABLE status ADD COLUMN identifier serial;