diff --git a/apps/maarch_entreprise/Views/user-administration.component.html b/apps/maarch_entreprise/Views/user-administration.component.html index 95b5377efd9ae10f75d7442de101f26d8bebf89f..823ec602d0b676a542526f5b73154c84ddcf45f4 100755 --- a/apps/maarch_entreprise/Views/user-administration.component.html +++ b/apps/maarch_entreprise/Views/user-administration.component.html @@ -1,15 +1,19 @@ <div class="page-header"> - <h1 *ngIf="!creationMode">{{lang.userModification}} <small>{{user.lastname}} {{user.firstname}}</small></h1> - <h1 *ngIf="creationMode">{{lang.userCreation}} <small>{{user.lastname}} {{user.firstname}}</small></h1> + <h1 *ngIf="!creationMode">{{lang.userModification}} + <small>{{user.lastname}} {{user.firstname}}</small> + </h1> + <h1 *ngIf="creationMode">{{lang.userCreation}} + <small>{{user.lastname}} {{user.firstname}}</small> + </h1> </div> <div *ngIf="loading"> <mat-spinner style="margin:auto;"></mat-spinner> </div> <div *ngIf="!loading" class="container-fluid"> <div class="container-fluid"> - <mat-tab-group (selectChange)="initService()"> - <mat-tab label="Informations"> - <div *ngIf="user.status == 'ABS'" class="text-warning" style="position: absolute;opacity: 0.1;font-size: 120px;transform: rotate(324deg);-webkit-transform: rotate(324deg);margin-left: 35%;margin-top: 90px;">{{user.status}}</div> + <mat-tab-group [(selectedIndex)]="selectedTabIndex" (selectChange)="initService()"> + <mat-tab label="Informations"> + <div *ngIf="user.status == 'ABS'" class="text-warning" style="position: absolute;opacity: 0.1;font-size: 120px;transform: rotate(324deg);-webkit-transform: rotate(324deg);margin-left: 35%;margin-top: 90px;">{{user.status}}</div> <div class="col-md-6 col-md-offset-3"> <div class="example-sidenav-content"> <form class="form-horizontal" (ngSubmit)="onSubmit()" #profileForm="ngForm"> @@ -24,7 +28,8 @@ <input matInput *ngIf="creationMode" type="text" title="{{lang.id}}" name="user_id" [(ngModel)]="user.userId" placeholder="{{lang.id}}" pattern="^[\w.@-]*$" required> - <input matInput *ngIf="!creationMode" type="text" title="{{lang.id}}" value="{{user.user_id}}" placeholder="{{lang.id}}" disabled> + <input matInput *ngIf="!creationMode" type="text" title="{{lang.id}}" value="{{user.user_id}}" placeholder="{{lang.id}}" + disabled> </mat-form-field> </div> </div> @@ -60,7 +65,7 @@ <div class="col-sm-12"> <mat-form-field> <input matInput type="email" id="mail" name="mail" title="{{lang.email}}" placeholder="{{lang.email}}" [(ngModel)]="user.mail" - pattern="[^@\s]+@[^@\s]+"> + pattern="[^@\s]+@[^@\s]+" required> </mat-form-field> </div> </div> @@ -74,11 +79,16 @@ </div> <div class="form-group"> <div style="text-align:center;"> - <button *ngIf="creationMode" type="submit" class="btn btn-success" [disabled]="!profileForm.form.valid"><i class="fa fa-plus"></i> {{lang.save}}</button> - <button *ngIf="!creationMode" type="submit" class="btn btn-success" [disabled]="!profileForm.form.valid"><i class="fa fa-save"></i> {{lang.update}}</button> - <button *ngIf="user.status != 'ABS' && !creationMode" type="button" (click)="activateAbsence()" class="btn btn-warning"><i class="fa fa-plane"></i> {{lang.activateAbsence}}</button> - <button *ngIf="user.status == 'ABS' && !creationMode" type="button" (click)="desactivateAbsence()" class="btn btn-success"><i class="fa fa-check"></i> {{lang.desactivateAbsence}}</button> - <button type="button" *ngIf="!creationMode" (click)="resetPassword(user)" class="btn btn-default"><i class="fa fa-key"></i> {{lang.reinitPassword}}</button> + <button mat-raised-button color="primary" *ngIf="creationMode" type="submit" [disabled]="!profileForm.form.valid"> + <mat-icon class="fa fa-save" aria-hidden="true"></mat-icon> {{lang.save}}</button> + <button mat-raised-button color="primary" *ngIf="!creationMode" type="submit" [disabled]="!profileForm.form.valid"> + <mat-icon class="fa fa-save" aria-hidden="true"></mat-icon> {{lang.update}}</button> + <button mat-raised-button color="warn" *ngIf="user.status != 'ABS' && !creationMode" type="button" (click)="activateAbsence()"> + <mat-icon class="fa fa-plane" aria-hidden="true"></mat-icon> {{lang.activateAbsence}}</button> + <button mat-raised-button color="accent" *ngIf="user.status == 'ABS' && !creationMode" type="button" (click)="desactivateAbsence()"> + <mat-icon class="fa fa-check" aria-hidden="true"></mat-icon> {{lang.desactivateAbsence}}</button> + <button mat-raised-button type="button" *ngIf="!creationMode" (click)="resetPassword(user)"> + <mat-icon class="fa fa-key" aria-hidden="true"></mat-icon> {{lang.reinitPassword}}</button> </div> </div> </form> @@ -96,46 +106,63 @@ </div> </div> <div class="col-md-4 col-md-offset-1"> - <div class="panel" *ngFor="let userGroup of user.groups" [ngClass]="[userGroup.primary_group == 'Y' ? 'panel-primary' : 'panel-default']"> - <div class="panel-heading"> - {{userGroup.group_desc}} <i *ngIf="userGroup.primary_group != 'Y'" class="fa fa-asterisk" aria-hidden="true"></i> - </div> - <div class="panel-body"> - <mat-form-field> + <mat-accordion class="example-headers-align"> + <mat-expansion-panel *ngFor="let userGroup of user.groups" hideToggle="true"> + <mat-expansion-panel-header> + <mat-panel-title> + {{userGroup.group_desc}} + </mat-panel-title> + <mat-panel-description> + Groupe + <mat-icon class="fa fa-users"></mat-icon> + </mat-panel-description> + </mat-expansion-panel-header> + <div class="col-md-12"> <input matInput type="text" id="role" name="role" title="{{lang.role}}" placeholder="{{lang.role}}" [(ngModel)]="userGroup.role" (focusout)="updateGroup(userGroup)"> - </mat-form-field> - <div class="col-md-12"> <ul class="list-unstyled"> <li *ngFor="let basket of user.baskets; let i = index"> <span *ngIf="basket.group_id == userGroup.group_id"> - <mat-slide-toggle [(ngModel)]="basket.enabled" color="primary">{{basket.basket_name}} <small class="text-danger" style="font-style:italic;" *ngIf="basket.userToDisplay != '' && basket.enabled">(Redirigé à {{basket.userToDisplay}})</small></mat-slide-toggle> - <i (click)="toogleRedirect(basket)" *ngIf="basket.userToDisplay == '' && basket.enabled" matTooltip="Rediriger la banette à une personne lors de l'activation de l'absence" matTooltipPosition="above" - class="fa fa-share-square text-primary" style="cursor:pointer;"></i> - <sup><i style="cursor:pointer;" *ngIf="basket.userToDisplay != '' && basket.enabled" matTooltip="Supprimer la redirection" class="fa fa-times text-danger" aria-hidden="true" (click)="delBasketRedirection(i)"></i></sup> + <mat-slide-toggle [(ngModel)]="basket.enabled" color="primary">{{basket.basket_name}} + <small class="text-danger" style="font-style:italic;" *ngIf="basket.userToDisplay != '' && basket.enabled">(Redirigé à {{basket.userToDisplay}})</small> + </mat-slide-toggle> + <button mat-icon-button color="primary" (click)="toogleRedirect(basket)" *ngIf="basket.userToDisplay == '' && basket.enabled" + matTooltip="Rediriger la banette à une personne lors de l'activation de l'absence" + matTooltipPosition="above"> + <mat-icon class="fa fa-share-square"></mat-icon> + </button> + <sup> + <i style="cursor:pointer;" *ngIf="basket.userToDisplay != '' && basket.enabled" matTooltip="Supprimer la redirection" class="fa fa-times text-danger" + aria-hidden="true" (click)="delBasketRedirection(i)"></i> + </sup> <div *ngIf="basket.userToDisplay == '' && basket.enabled" id="redirectUser_{{basket.group_id}}_{{basket.basket_id}}" style="display:none;"> - <md2-autocomplete - [items]="userList" - item-text="user_id" - item-value="user_id" - placeholder="utilisateur de redirection" - [(ngModel)]="basket.userToDisplay" - required - (change)="addBasketRedirection(i,basket)"> - </md2-autocomplete> + <mat-form-field class="example-full-width"> + <input type="text" placeholder="Utilisateur de redirection" matInput [matAutocomplete]="auto" [formControl]="userCtrl" (change)="addBasketRedirection(i,basket)"> + <mat-autocomplete #auto="matAutocomplete"> + <mat-option *ngFor="let user of filteredUsers | async" [value]="user.user_id"> + <div class="container-fluid"> + <div class="col-md-1"> + <mat-icon class="fa fa-user fa-2x"></mat-icon> + </div> + <div class="col-md-11"> + {{ user.firstname }} {{ user.lastname }} + <small>{{ user.user_id }}</small> + </div> + </div> + </mat-option> + </mat-autocomplete> + </mat-form-field> </div> </span> </li> </ul> </div> - </div> - <div class="panel-footer"> - <mat-form-field> - <input value="{{userGroup.maarch_comment}}" matInput type="text" title="{{lang.perimeter}}" placeholder="Ressource documentaire" - disabled> - </mat-form-field> - </div> - </div> + <mat-action-row> + <input value="{{userGroup.maarch_comment}}" matInput type="text" matTooltip="{{lang.perimeter}}" disabled> + </mat-action-row> + + </mat-expansion-panel> + </mat-accordion> </div> </mat-tab> <mat-tab *ngIf="!creationMode" label="Entité(s)"> @@ -146,27 +173,39 @@ <div id="jstree"></div> </div> <div class="col-md-4 col-md-offset-1"> - <div class="panel" *ngFor="let userEntity of user.entities" [ngClass]="[userEntity.primary_entity == 'Y' ? 'panel-primary' : 'panel-default']"> - <div class="panel-heading"> - {{userEntity.entity_label}} <i matTooltip="Passer en entité primaire" *ngIf="userEntity.primary_entity != 'Y'" - (click)="updatePrimaryEntity(userEntity)" class="fa fa-asterisk text-primary pull-right" style="cursor:pointer;"></i> - </div> - <div class="panel-body"> + <mat-accordion class="example-headers-align"> + <mat-expansion-panel *ngFor="let userEntity of user.entities" hideToggle="true"> + <mat-expansion-panel-header> + <mat-panel-title> + {{userEntity.entity_label}} + </mat-panel-title> + <mat-panel-description> + Entité + <i *ngIf="userEntity.primary_entity == 'Y'" color="primary"> primaire</i> + + <button *ngIf="userEntity.primary_entity == 'Y'" mat-icon-button disabled> + <mat-icon class="fa fa-sitemap" color="primary"></mat-icon> + </button> + <button *ngIf="userEntity.primary_entity != 'Y'" mat-icon-button (click)="updatePrimaryEntity(userEntity)" matTooltip="{{lang.entityTooglePrimary}}"> + <mat-icon class="fa fa-sitemap"></mat-icon> + </button> + + </mat-panel-description> + </mat-expansion-panel-header> <mat-form-field> <input matInput type="text" id="role" name="role" title="{{lang.role}}" placeholder="{{lang.role}}" [(ngModel)]="userEntity.user_role" (focusout)="updateEntity(userEntity)"> </mat-form-field> - </div> - </div> + </mat-expansion-panel> + </mat-accordion> </div> </mat-tab> <mat-tab *ngIf="!creationMode" label="Signature(s)"> <div class="col-md-6 col-md-offset-3"> <div class="form-group"> - <button (click)="clickOnUploader('uploadSignFile')" matTooltip="taille de 2 mo maximum" class="form-control btn btn-sm btn-success" - style="width:auto;"> - <i class="fa fa-plus"></i> Ajouter une signature - </button> + <button (click)="clickOnUploader('uploadSignFile')" matTooltip="taille de 2 mo maximum" mat-raised-button color="accent"> + <mat-icon class="fa fa-plus"></mat-icon> Ajouter une signature</button> + </div> <div class="form-group"> <div class="row" style="margin-top:5px;display:none;"> @@ -182,12 +221,13 @@ </div> <div class="col-md-1" style="margin-bottom:5px;"> <button class="form-control btn btn-sm btn-success" type="submit" [disabled]="!signatureForm.form.valid || !signatureModel.size"> - <i class="fa fa-plus"></i> - </button> + <i class="fa fa-plus"></i> + </button> </div> <div [ngClass]="[signatureModel.size != '' ? 'col-md-10' : 'col-md-12']"> <div class="upload-drop-zone" (click)="clickOnUploader('uploadSignFile')" style="cursor:pointer"> - {{lang.clickOn}} <i class="fa fa-upload fa-2x"></i> ( + {{lang.clickOn}} + <i class="fa fa-upload fa-2x"></i> ( < 2MB) </div> </div> <div class="col-md-2" *ngIf="signatureModel.size"> @@ -205,10 +245,10 @@ (focusout)="updateSignature(i)"> </mat-form-field> </mat-card-title> - <i class="fa fa-times text-danger" style="cursor:pointer;" (click)="deleteSignature(signature)"></i> + <button mat-icon-button (click)="deleteSignature(signature)" color="warn" matTooltip="{{lang.delete}}"> + <mat-icon class="fa fa-times"></mat-icon> + </button> </mat-card-header> - - <mat-card-content> <img src="{{signature.pathToSignatureOnTmp}}" alt="Signature" style="width:100%;height:60px;"> </mat-card-content> @@ -219,32 +259,61 @@ </div> </div> </mat-tab> - <mat-tab label="Historique"> + <mat-tab *ngIf="!creationMode" label="Historique"> <div class="col-md-12"> - <table id="hisotryTable" class="table table-hover table-condensed" [md2Data]="data | dataPipe : 'info' : search" #md2="md2DataTable" [sortBy]='event_date' [rowsPerPage]="10"> - <thead> - <tr> - <td> - <md2-pagination></md2-pagination> - </td> - <td style="text-align:right;"> + <div class="example-container"> + <mat-grid-list cols="3" rowHeight="100px"> + <mat-grid-tile> + <mat-paginator #paginator [length]="100" [pageSize]="10" [pageSizeOptions]="[10, 25, 50, 100]"> + </mat-paginator> + </mat-grid-tile> + <mat-grid-tile> + </mat-grid-tile> + <mat-grid-tile> + <mat-form-field> + <input matInput (keyup)="applyFilter($event.target.value)" placeholder="{{lang.filterBy}}"> + </mat-form-field> + </mat-grid-tile> + </mat-grid-list> + <mat-table #table [dataSource]="dataSource" matSort matSortActive="event_date" matSortDirection="desc"> + <ng-container matColumnDef="event_date"> + <mat-header-cell *matHeaderCellDef mat-sort-header>{{lang.date}}</mat-header-cell> + <mat-cell *matCellDef="let element">{{element.event_date | date : "dd/MM/y HH:mm"}}</mat-cell> + </ng-container> + <ng-container matColumnDef="event_type"> + <mat-header-cell *matHeaderCellDef mat-sort-header>{{lang.event}}</mat-header-cell> + <mat-cell *matCellDef="let element"> {{element.event_type}} </mat-cell> + </ng-container> + <ng-container matColumnDef="user_id"> + <mat-header-cell *matHeaderCellDef mat-sort-header>{{lang.user}}</mat-header-cell> + <mat-cell *matCellDef="let element"> {{element.user_id}} </mat-cell> + </ng-container> + <ng-container matColumnDef="info"> + <mat-header-cell *matHeaderCellDef mat-sort-header>{{lang.desc}}</mat-header-cell> + <mat-cell *matCellDef="let element"> {{element.info}} </mat-cell> + </ng-container> + <ng-container matColumnDef="remote_ip"> + <mat-header-cell *matHeaderCellDef mat-sort-header>{{lang.ip}}</mat-header-cell> + <mat-cell *matCellDef="let element"> {{element.remote_ip}} </mat-cell> + </ng-container> + <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row> + <mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row> + </mat-table> + + <mat-grid-list cols="3" rowHeight="100px"> + <mat-grid-tile> + </mat-grid-tile> + <mat-grid-tile> + </mat-grid-tile> + <mat-grid-tile> <mat-form-field> - <input matInput placeholder="{{lang.filterBy}} : {{lang.desc}}" class="searchTable" [(ngModel)]="search" /> + <input matInput [(ngModel)]="minDate" [matDatepicker]="picker" placeholder="Depuis" disabled> + <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle> + <mat-datepicker #picker startView="month" [startAt]="minDate"></mat-datepicker> </mat-form-field> - </td> - </tr> - <tr> - <th md2SortBy="event_date">{{lang.date}}</th> - <th md2SortBy="info">{{lang.desc}}</th> - </tr> - </thead> - <tbody> - <tr *ngFor="let history of md2.data"> - <td style="vertical-align:middle;">{{history.event_date | date : "dd/MM/y HH:mm"}}</td> - <td style="vertical-align:middle;">{{history.info}}</td> - </tr> - </tbody> - </table> + </mat-grid-tile> + </mat-grid-list> + </div> </div> </mat-tab> </mat-tab-group> diff --git a/apps/maarch_entreprise/Views/users-administration.component.html b/apps/maarch_entreprise/Views/users-administration.component.html index 351300cba0e24194611ec948fb4212a919780cfb..e478ff75e8f873f20fba77d9b73296d491c66015 100755 --- a/apps/maarch_entreprise/Views/users-administration.component.html +++ b/apps/maarch_entreprise/Views/users-administration.component.html @@ -1,103 +1,81 @@ - <div class="page-header"> - <h1>{{lang.administration}} {{lang.users}} <small>{{data.length}} {{lang.users}}</small></h1> + <h1>{{lang.administration}} {{lang.users}} + <small>{{data.length}} {{lang.users}}</small> + </h1> </div> <div *ngIf="loading"> <mat-spinner style="margin:auto;"></mat-spinner> </div> <div *ngIf="!loading" class="container-fluid"> <div class="col-md-12"> - <table id="usersTable" class="table table-hover table-condensed" [md2Data]="data | dataPipe : 'user_id' : search" #md2="md2DataTable" [sortBy]='user_id' [rowsPerPage]="10"> - <thead> - <tr> - <td colspan="5"> - <md2-pagination></md2-pagination> - </td> - <td style="text-align:right;"> - <mat-form-field> - <input matInput placeholder="{{lang.filterBy}} : {{lang.id}}" class="searchTable" [(ngModel)]="search" /> - </mat-form-field> - - <a class="text-primary" style="cursor: pointer" routerLink="/administration/users/new" title="{{lang.addUser}}"><i class="fa fa-user-plus fa-2x"></i></a> - </td> - </tr> - <tr> - <th md2SortBy="user_id">{{lang.id}}</th> - <th md2SortBy="lastname">{{lang.lastname}}</th> - <th md2SortBy="firstname">{{lang.firstname}}</th> - <th md2SortBy="status">{{lang.status}}</th> - <th md2SortBy="mail">{{lang.email}}</th> - <th> </th> - </tr> - </thead> - <tbody> - <tr *ngFor="let user of md2.data"> - <td style="vertical-align:middle;">{{user.user_id}}</td> - <td style="vertical-align:middle;">{{user.lastname}}</td> - <td style="vertical-align:middle;">{{user.firstname}}</td> - <td style="vertical-align:middle;"> - <span *ngIf="user.status == 'OK' && user.enabled == 'Y'" class="label label-primary">{{lang.active}}</span> - <span *ngIf="user.enabled == 'N'" class="label label-danger">{{lang.inactive}}</span> - <span *ngIf="user.status == 'ABS'" class="label label-warning">{{lang.abs}}</span> - </td> - <td style="vertical-align:middle;">{{user.mail}}</td> - <td style="text-align:right;"> - <div class="btn-group" role="group" aria-label="..."> - <button routerLink="/administration/users/{{user.id}}" type="button" class="btn btn-default" title="{{lang.update}}"> - <a><i style="cursor:pointer" class="fa fa-edit"></i></a> - </button> - <button *ngIf="user.enabled == 'Y' && user.inDiffListDest == 'Y'" data-toggle="modal" data-target="#changeDiffListDest" type="button" class="btn btn-default" title="{{lang.suspend}}" (click)="suspendUser(user)"> - <a><i style="cursor:pointer;color:#f0ad4e;" class="fa fa-pause"></i></a> - </button> - <button *ngIf="user.enabled == 'Y' && user.inDiffListDest == 'N'" type="button" class="btn btn-default" title="{{lang.suspend}}" (click)="suspendUser(user)"> - <a><i style="cursor:pointer;color:#f0ad4e;" class="fa fa-pause"></i></a> - </button> + <div class="example-container"> + <mat-grid-list cols="3" rowHeight="100px"> + <mat-grid-tile> + <mat-paginator #paginator [length]="100" [pageSize]="10" [pageSizeOptions]="[10, 25, 50, 100]"> + </mat-paginator> + </mat-grid-tile> + <mat-grid-tile></mat-grid-tile> + <mat-grid-tile> + <mat-form-field> + <input matInput (keyup)="applyFilter($event.target.value)" placeholder="{{lang.filterBy}}"> + </mat-form-field> + <button mat-mini-fab color="accent" matTooltip="{{lang.add}}" routerLink="/administration/users/new"> + <mat-icon class="fa fa-plus" aria-hidden="true"></mat-icon> + </button> + </mat-grid-tile> + </mat-grid-list> + <mat-table #table [dataSource]="dataSource" matSort matSortActive="user_id" matSortDirection="asc"> + <ng-container matColumnDef="user_id"> + <mat-header-cell *matHeaderCellDef mat-sort-header>{{lang.id}}</mat-header-cell> + <mat-cell *matCellDef="let element"> {{element.user_id}} </mat-cell> + </ng-container> + <ng-container matColumnDef="lastname"> + <mat-header-cell *matHeaderCellDef mat-sort-header>{{lang.lastname}}</mat-header-cell> + <mat-cell *matCellDef="let element"> {{element.lastname}} </mat-cell> + </ng-container> + <ng-container matColumnDef="firstname"> + <mat-header-cell *matHeaderCellDef mat-sort-header>{{lang.firstname}}</mat-header-cell> + <mat-cell *matCellDef="let element"> {{element.firstname}} </mat-cell> + </ng-container> + <ng-container matColumnDef="status"> + <mat-header-cell *matHeaderCellDef mat-sort-header>{{lang.status}}</mat-header-cell> + <mat-cell *matCellDef="let element"> + <span *ngIf="element.status == 'OK' && element.enabled == 'Y'" color="primary" class="label">{{lang.active}}</span> + <span *ngIf="element.enabled == 'N'" color="warn" class="label">{{lang.inactive}}</span> + <span *ngIf="element.status == 'ABS'" color="warn" class="label">{{lang.abs}}</span> + </mat-cell> - <button *ngIf="user.enabled == 'N'" type="button" class="btn btn-default" title="{{lang.authorize}}" (click)="activateUser(user)"> - <a><i style="cursor:pointer;color:#5cb85c;" class="fa fa-check"></i></a> - </button> - <button *ngIf="user.inDiffListDest == 'Y'" type="button" class="btn btn-default" title="{{lang.delete}}" data-toggle="modal" data-target="#changeDiffListDest" (click)="deleteUser(user)"> - <a><i style="cursor:pointer;color: #D9534F" class="fa fa-trash"></i></a> - </button> - <button *ngIf="user.inDiffListDest == 'N'" type="button" class="btn btn-default" title="{{lang.delete}}" (click)="deleteUser(user)"> - <a><i style="cursor:pointer;color: #D9534F" class="fa fa-trash"></i></a> - </button> - </div> - </td> - </tr> - </tbody> - </table> - </div> -</div> - -<div class="modal fade" id="changeDiffListDest" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> - <div class="modal-dialog" role="document"> - <div class="modal-content"> - <div class="modal-header"> - <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> - <h4 class="modal-title" id="myModalLabel">Changement de destinataire des modèles de liste de diffusion</h4> - </div> - <form (ngSubmit)="onSubmit()" #changeDiffListDestForm="ngForm"> - <div class="modal-body"> - <div class="alert alert-warning" role="alert"> - <b>{{this.userDestRedirect.firstname}} {{this.userDestRedirect.lastname}}</b> est en <b>destinataire</b> des modèles liste de difffusion suivante, veuillez choisir un utilisateur de <b>remplacement</b> : - </div> - <div *ngFor="let userDestRedirectModel of userDestRedirectModels" id="{{userDestRedirectModel.object_id}}" class="form-group"> - <md2-autocomplete name="userList" - [items]="data" - item-text="user_id" - item-value="user_id" - placeholder="nouveau destinataire pour : {{userDestRedirectModel.title}}" - [(ngModel)]="userDestRedirectModel.redirectUserId" - required> - </md2-autocomplete> - </div> - </div> - <div class="modal-footer"> - <button *ngIf="userDestRedirect.mode == 'del'" type="button" class="btn btn-danger" (click)="deleteUserModal(userDestRedirect)" [disabled]="!changeDiffListDestForm.form.valid">{{lang.delete}} {{lang.user}}</button> - <button *ngIf="userDestRedirect.mode == 'up'" type="button" class="btn btn-warning" (click)="suspendUserModal(userDestRedirect)" [disabled]="!changeDiffListDestForm.form.valid">{{lang.suspend}} {{lang.user}}</button> - </div> - </form> + </ng-container> + <ng-container matColumnDef="mail"> + <mat-header-cell *matHeaderCellDef mat-sort-header>{{lang.email}}</mat-header-cell> + <mat-cell *matCellDef="let element"> {{element.mail}} </mat-cell> + </ng-container> + <ng-container matColumnDef="actions"> + <mat-header-cell *matHeaderCellDef mat-sort-header></mat-header-cell> + <mat-cell *matCellDef="let element" style="text-align:right"> + <button mat-icon-button color="primary" matTooltip="{{lang.update}}" routerLink="/administration/users/{{element.id}}"> + <mat-icon class="fa fa-edit fa-2x" aria-hidden="true"></mat-icon> + </button> + <button mat-icon-button color="primary" *ngIf="element.enabled == 'Y' && element.inDiffListDest == 'Y'" matTooltip="{{lang.suspend}}" (click)="suspendUser(element)"> + <mat-icon class="fa fa-pause fa-2x" aria-hidden="true"></mat-icon> + </button> + <button mat-icon-button color="primary" *ngIf="element.enabled == 'Y' && element.inDiffListDest == 'N'" matTooltip="{{lang.suspend}}" (click)="suspendUser(element)"> + <mat-icon class="fa fa-pause fa-2x" aria-hidden="true"></mat-icon> + </button> + <button mat-icon-button color="accent" *ngIf="element.enabled == 'N'" matTooltip="{{lang.authorize}}" (click)="activateUser(element)"> + <mat-icon class="fa fa-check fa-2x" aria-hidden="true"></mat-icon> + </button> + <button mat-icon-button color="warn" *ngIf="element.inDiffListDest == 'Y'" matTooltip="{{lang.delete}}" data-toggle="modal" data-target="#changeDiffListDest" (click)="deleteUser(element)"> + <mat-icon class="fa fa-trash fa-2x" aria-hidden="true"></mat-icon> + </button> + <button mat-icon-button color="warn" *ngIf="element.inDiffListDest == 'N'" matTooltip="{{lang.delete}}" (click)="deleteUser(element)"> + <mat-icon class="fa fa-trash fa-2x" aria-hidden="true"></mat-icon> + </button> + </mat-cell> + </ng-container> + <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row> + <mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row> + </mat-table> </div> </div> -</div> +</div> \ No newline at end of file diff --git a/apps/maarch_entreprise/js/angular/app/administration/user-administration.component.js b/apps/maarch_entreprise/js/angular/app/administration/user-administration.component.js index 43e9bd2a189333d6a6a0cdd7425583d7fa1cedb4..01993c039e360ec7c87853013209383cbcdd6e57 100755 --- a/apps/maarch_entreprise/js/angular/app/administration/user-administration.component.js +++ b/apps/maarch_entreprise/js/angular/app/administration/user-administration.component.js @@ -1,4 +1,14 @@ "use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); @@ -14,18 +24,21 @@ var http_1 = require("@angular/common/http"); var router_1 = require("@angular/router"); var translate_component_1 = require("../translate.component"); var notification_service_1 = require("../notification.service"); -var UserAdministrationComponent = /** @class */ (function () { +var material_1 = require("@angular/material"); +var autocomplete_plugin_1 = require("../../plugins/autocomplete.plugin"); +var UserAdministrationComponent = /** @class */ (function (_super) { + __extends(UserAdministrationComponent, _super); function UserAdministrationComponent(http, route, router, zone, notify) { - var _this = this; - this.http = http; - this.route = route; - this.router = router; - this.zone = zone; - this.notify = notify; - this.lang = translate_component_1.LANG; - this._search = ''; - this.user = {}; - this.signatureModel = { + var _this = _super.call(this, http, 'users') || this; + _this.http = http; + _this.route = route; + _this.router = router; + _this.zone = zone; + _this.notify = notify; + _this.lang = translate_component_1.LANG; + _this._search = ''; + _this.user = {}; + _this.signatureModel = { base64: "", base64ForJs: "", name: "", @@ -33,16 +46,27 @@ var UserAdministrationComponent = /** @class */ (function () { size: 0, label: "", }; - this.userAbsenceModel = []; - this.userList = []; - this.selectedSignature = -1; - this.selectedSignatureLabel = ""; - this.data = []; - this.loading = false; + _this.userAbsenceModel = []; + _this.userList = []; + _this.selectedSignature = -1; + _this.selectedSignatureLabel = ""; + _this.data = []; + _this.CurrentYear = new Date().getFullYear(); + _this.currentMonth = new Date().getMonth() + 1; + _this.minDate = new Date(); + _this.loading = false; + _this.displayedColumns = ['event_date', 'event_type', 'user_id', 'info', 'remote_ip']; + _this.dataSource = new material_1.MatTableDataSource(_this.data); window['angularUserAdministrationComponent'] = { componentAfterUpload: function (base64Content) { return _this.processAfterUpload(base64Content); }, }; + return _this; } + UserAdministrationComponent.prototype.applyFilter = function (filterValue) { + filterValue = filterValue.trim(); // Remove whitespace + filterValue = filterValue.toLowerCase(); // MatTableDataSource defaults to lowercase matches + this.dataSource.filter = filterValue; + }; UserAdministrationComponent.prototype.updateBreadcrumb = function (applicationName) { var breadCrumb = "<a href='index.php?reinit=true'>" + applicationName + "</a> > <a onclick='location.hash = \"/administration\"' style='cursor: pointer'>" + this.lang.administration + "</a> > <a onclick='location.hash = \"/administration/users\"' style='cursor: pointer'>" + this.lang.users + "</a> > "; if (this.creationMode == true) { @@ -73,7 +97,13 @@ var UserAdministrationComponent = /** @class */ (function () { _this.data = data.history; _this.userId = data.user_id; _this.updateBreadcrumb(angularGlobals.applicationName); + _this.minDate = new Date(_this.CurrentYear + '-' + _this.currentMonth + '-01'); _this.loading = false; + setTimeout(function () { + _this.dataSource = new material_1.MatTableDataSource(_this.data); + _this.dataSource.paginator = _this.paginator; + _this.dataSource.sort = _this.sort; + }, 0); }, function () { location.href = "index.php"; }); @@ -81,11 +111,10 @@ var UserAdministrationComponent = /** @class */ (function () { }); }; UserAdministrationComponent.prototype.toogleRedirect = function (basket) { - var _this = this; $j('#redirectUser_' + basket.group_id + '_' + basket.basket_id).toggle(); this.http.get(this.coreUrl + 'rest/administration/users') .subscribe(function (data) { - _this.userList = data['users']; + //this.userList = data['users']; }, function () { location.href = "index.php"; }); @@ -110,7 +139,7 @@ var UserAdministrationComponent = /** @class */ (function () { .on('select_node.jstree', function (e, data) { _this.addEntity(data.node.id); }).on('deselect_node.jstree', function (e, data) { - console.log(data.node.id); + //console.log(data.node.id); _this.deleteEntity(data.node.id); }) .jstree(); @@ -125,9 +154,6 @@ var UserAdministrationComponent = /** @class */ (function () { }, 250); }); } - if ($j("[md2sortby='event_date']").length != 0) { - $j("[md2sortby='event_date']").click(); - } }; UserAdministrationComponent.prototype.processAfterUpload = function (b64Content) { var _this = this; @@ -329,7 +355,7 @@ var UserAdministrationComponent = /** @class */ (function () { }; UserAdministrationComponent.prototype.activateAbsence = function () { var _this = this; - this.http.post(this.coreUrl + "rest/users/" + this.serialId + "/baskets/absence", this.userAbsenceModel) + this.http.put(this.coreUrl + "rest/users/" + this.serialId + "/status", { "status": "ABS" }) .subscribe(function (data) { _this.user.status = data.user.status; _this.userAbsenceModel = []; @@ -371,6 +397,14 @@ var UserAdministrationComponent = /** @class */ (function () { }); } }; + __decorate([ + core_1.ViewChild(material_1.MatPaginator), + __metadata("design:type", material_1.MatPaginator) + ], UserAdministrationComponent.prototype, "paginator", void 0); + __decorate([ + core_1.ViewChild(material_1.MatSort), + __metadata("design:type", material_1.MatSort) + ], UserAdministrationComponent.prototype, "sort", void 0); UserAdministrationComponent = __decorate([ core_1.Component({ templateUrl: angularGlobals["user-administrationView"], @@ -380,5 +414,5 @@ var UserAdministrationComponent = /** @class */ (function () { __metadata("design:paramtypes", [http_1.HttpClient, router_1.ActivatedRoute, router_1.Router, core_1.NgZone, notification_service_1.NotificationService]) ], UserAdministrationComponent); return UserAdministrationComponent; -}()); +}(autocomplete_plugin_1.AutoCompletePlugin)); exports.UserAdministrationComponent = UserAdministrationComponent; diff --git a/apps/maarch_entreprise/js/angular/app/administration/user-administration.component.ts b/apps/maarch_entreprise/js/angular/app/administration/user-administration.component.ts index c9d5cdca250189269870fa5dfd237fd525ee36f0..93177883827439fb820f842e5624847f876c112f 100755 --- a/apps/maarch_entreprise/js/angular/app/administration/user-administration.component.ts +++ b/apps/maarch_entreprise/js/angular/app/administration/user-administration.component.ts @@ -1,57 +1,70 @@ -import { Component, OnInit, NgZone } from '@angular/core'; +import { Component, OnInit, NgZone, ViewChild } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { ActivatedRoute, Router } from '@angular/router'; import { LANG } from '../translate.component'; import { NotificationService } from '../notification.service'; +import { MatPaginator, MatTableDataSource, MatSort } from '@angular/material'; -declare function $j(selector: any) : any; +import { AutoCompletePlugin } from '../../plugins/autocomplete.plugin'; -declare const angularGlobals : any; +declare function $j(selector: any): any; +declare const angularGlobals: any; @Component({ - templateUrl : angularGlobals["user-administrationView"], - styleUrls : ['css/user-administration.component.css'], - providers : [NotificationService] + templateUrl: angularGlobals["user-administrationView"], + styleUrls: ['css/user-administration.component.css'], + providers: [NotificationService] }) -export class UserAdministrationComponent implements OnInit { - - coreUrl : string; - lang : any = LANG; - _search : string = ''; - - userId : string; - serialId : number; - creationMode : boolean; - - user : any = {}; - signatureModel : any = { - base64 : "", - base64ForJs : "", - name : "", - type : "", - size : 0, - label : "", +export class UserAdministrationComponent extends AutoCompletePlugin implements OnInit { + coreUrl: string; + lang: any = LANG; + _search: string = ''; + userId: string; + serialId: number; + creationMode: boolean; + + user: any = {}; + signatureModel: any = { + base64: "", + base64ForJs: "", + name: "", + type: "", + size: 0, + label: "", }; - userAbsenceModel : any[] = []; - userList : any[] = []; - - selectedSignature : number = -1; - selectedSignatureLabel : string = ""; - data : any = []; - loading : boolean = false; + userAbsenceModel: any[] = []; + userList: any[] = []; + + selectedSignature: number = -1; + selectedSignatureLabel: string = ""; + data: History[] = []; + CurrentYear: number = new Date().getFullYear(); + currentMonth: number = new Date().getMonth() + 1; + minDate: Date = new Date(); + loading: boolean = false; + + displayedColumns = ['event_date', 'event_type', 'user_id', 'info', 'remote_ip']; + dataSource = new MatTableDataSource(this.data); + @ViewChild(MatPaginator) paginator: MatPaginator; + @ViewChild(MatSort) sort: MatSort; + applyFilter(filterValue: string) { + filterValue = filterValue.trim(); // Remove whitespace + filterValue = filterValue.toLowerCase(); // MatTableDataSource defaults to lowercase matches + this.dataSource.filter = filterValue; + } constructor(public http: HttpClient, private route: ActivatedRoute, private router: Router, private zone: NgZone, private notify: NotificationService) { + super(http,'users'); window['angularUserAdministrationComponent'] = { componentAfterUpload: (base64Content: any) => this.processAfterUpload(base64Content), }; - } updateBreadcrumb(applicationName: string) { - var breadCrumb = "<a href='index.php?reinit=true'>" + applicationName + "</a> > <a onclick='location.hash = \"/administration\"' style='cursor: pointer'>"+this.lang.administration+"</a> > <a onclick='location.hash = \"/administration/users\"' style='cursor: pointer'>"+this.lang.users+"</a> > "; + var breadCrumb = "<a href='index.php?reinit=true'>" + applicationName + "</a> > <a onclick='location.hash = \"/administration\"' style='cursor: pointer'>" + this.lang.administration + "</a> > <a onclick='location.hash = \"/administration/users\"' style='cursor: pointer'>" + this.lang.users + "</a> > "; - if(this.creationMode == true){ + if (this.creationMode == true) { breadCrumb += this.lang.userCreation; } else { breadCrumb += this.lang.userModification; @@ -74,14 +87,18 @@ export class UserAdministrationComponent implements OnInit { this.creationMode = false; this.serialId = params['id']; this.http.get(this.coreUrl + "rest/users/" + this.serialId + "/details") - .subscribe((data : any) => { + .subscribe((data: any) => { this.user = data; this.data = data.history; this.userId = data.user_id; this.updateBreadcrumb(angularGlobals.applicationName); + this.minDate = new Date(this.CurrentYear + '-' + this.currentMonth + '-01'); this.loading = false; - - + setTimeout(() => { + this.dataSource = new MatTableDataSource(this.data); + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; + }, 0); }, () => { location.href = "index.php"; }); @@ -89,56 +106,53 @@ export class UserAdministrationComponent implements OnInit { }); } - toogleRedirect(basket:any) { - $j('#redirectUser_'+basket.group_id+'_'+basket.basket_id).toggle(); + toogleRedirect(basket: any) { + $j('#redirectUser_' + basket.group_id + '_' + basket.basket_id).toggle(); this.http.get(this.coreUrl + 'rest/administration/users') - .subscribe((data : any) => { - this.userList = data['users']; + .subscribe((data: any) => { + //this.userList = data['users']; - }, () => { - location.href = "index.php"; - }); + }, () => { + location.href = "index.php"; + }); } - initService(){ - if($j('.jstree-container-ul').length == 0){ - $j('#jstree').jstree({ - "checkbox" : { - "three_state" : false //no cascade selection + initService() { + if ($j('.jstree-container-ul').length == 0) { + $j('#jstree').jstree({ + "checkbox": { + "three_state": false //no cascade selection }, - 'core' : { + 'core': { 'themes': { 'name': 'proton', 'responsive': true }, - 'data' : this.user.allEntities + 'data': this.user.allEntities }, - "plugins" : [ "checkbox", "search" ] + "plugins": ["checkbox", "search"] }); $j('#jstree') - // listen for event - .on('select_node.jstree', (e:any, data:any) => { - this.addEntity(data.node.id); - }).on('deselect_node.jstree', (e:any, data:any) => { - console.log(data.node.id); - this.deleteEntity(data.node.id); - }) - // create the instance - .jstree(); - - var to : any = false; + // listen for event + .on('select_node.jstree', (e: any, data: any) => { + this.addEntity(data.node.id); + }).on('deselect_node.jstree', (e: any, data: any) => { + //console.log(data.node.id); + this.deleteEntity(data.node.id); + }) + // create the instance + .jstree(); + + var to: any = false; $j('#jstree_search').keyup(function () { - if(to) { clearTimeout(to); } - to = setTimeout(function () { - var v = $j('#jstree_search').val(); - $j('#jstree').jstree(true).search(v); - }, 250); + if (to) { clearTimeout(to); } + to = setTimeout(function () { + var v = $j('#jstree_search').val(); + $j('#jstree').jstree(true).search(v); + }, 250); }); } - if($j("[md2sortby='event_date']").length != 0){ - $j("[md2sortby='event_date']").click(); - } } processAfterUpload(b64Content: any) { @@ -190,48 +204,48 @@ export class UserAdministrationComponent implements OnInit { } resetPassword(user: any) { - let r = confirm(this.lang.confirmAction+' '+this.lang.resetPsw); + let r = confirm(this.lang.confirmAction + ' ' + this.lang.resetPsw); if (r) { this.http.put(this.coreUrl + "rest/users/" + this.serialId + "/password", {}) - .subscribe((data : any) => { - this.notify.success(this.lang.pswReseted+' '+this.lang.for+' « '+user.user_id+' »'); + .subscribe((data: any) => { + this.notify.success(this.lang.pswReseted + ' ' + this.lang.for + ' « ' + user.user_id + ' »'); }, (err) => { this.notify.error(err.error.errors); }); } } - toggleGroup(group: any){ - if($j('#'+group.group_id+'-input').is(':checked') == true){ + toggleGroup(group: any) { + if ($j('#' + group.group_id + '-input').is(':checked') == true) { var groupReq = { - "groupId" : group.group_id, - "role" : group.role + "groupId": group.group_id, + "role": group.role }; this.http.post(this.coreUrl + "rest/users/" + this.serialId + "/groups", groupReq) - .subscribe((data : any) => { - this.user.groups = data.groups; - this.user.allGroups = data.allGroups; - this.user.baskets = data.baskets; - this.notify.success(this.lang.groupAdded+' « '+group.group_id+' »'); - }, (err) => { - this.notify.error(err.error.errors); - }); - }else{ + .subscribe((data: any) => { + this.user.groups = data.groups; + this.user.allGroups = data.allGroups; + this.user.baskets = data.baskets; + this.notify.success(this.lang.groupAdded + ' « ' + group.group_id + ' »'); + }, (err) => { + this.notify.error(err.error.errors); + }); + } else { this.http.delete(this.coreUrl + "rest/users/" + this.serialId + "/groups/" + group.group_id) - .subscribe((data : any) => { - this.user.groups = data.groups; - this.user.allGroups = data.allGroups; - this.notify.success(this.lang.groupDeleted+' « '+group.group_id+' »'); - }, (err) => { - this.notify.error(err.error.errors); - }); + .subscribe((data: any) => { + this.user.groups = data.groups; + this.user.allGroups = data.allGroups; + this.notify.success(this.lang.groupDeleted + ' « ' + group.group_id + ' »'); + }, (err) => { + this.notify.error(err.error.errors); + }); } } updateGroup(group: any) { this.http.put(this.coreUrl + "rest/users/" + this.serialId + "/groups/" + group.group_id, group) - .subscribe((data : any) => { - this.notify.success(this.lang.groupUpdated+' « '+group.group_id+' »'); + .subscribe((data: any) => { + this.notify.success(this.lang.groupUpdated + ' « ' + group.group_id + ' »'); }, (err) => { this.notify.error(err.error.errors); }); @@ -240,25 +254,25 @@ export class UserAdministrationComponent implements OnInit { addEntity(entiyId: any) { var entity = { - "entityId" : entiyId, - "role" : '' + "entityId": entiyId, + "role": '' }; this.http.post(this.coreUrl + "rest/users/" + this.serialId + "/entities", entity) - .subscribe((data : any) => { + .subscribe((data: any) => { this.user.entities = data.entities; this.user.allEntities = data.allEntities; - this.notify.success(this.lang.entityAdded+' « '+entiyId+' »'); + this.notify.success(this.lang.entityAdded + ' « ' + entiyId + ' »'); }, (err) => { this.notify.error(err.error.errors); }); - + } updateEntity(entity: any) { this.http.put(this.coreUrl + "rest/users/" + this.serialId + "/entities/" + entity.entity_id, entity) - .subscribe((data : any) => { - this.notify.success(this.lang.entityUpdated+' « '+entity.entity_id+' »'); + .subscribe((data: any) => { + this.notify.success(this.lang.entityUpdated + ' « ' + entity.entity_id + ' »'); }, (err) => { this.notify.error(err.error.errors); }); @@ -266,9 +280,9 @@ export class UserAdministrationComponent implements OnInit { updatePrimaryEntity(entity: any) { this.http.put(this.coreUrl + "rest/users/" + this.serialId + "/entities/" + entity.entity_id + "/primaryEntity", {}) - .subscribe((data : any) => { + .subscribe((data: any) => { this.user['entities'] = data.entities; - this.notify.success(this.lang.entityTooglePrimary+' « '+entity.entity_id+' »'); + this.notify.success(this.lang.entityTooglePrimary + ' « ' + entity.entity_id + ' »'); }, (err) => { this.notify.error(err.error.errors); }); @@ -277,102 +291,102 @@ export class UserAdministrationComponent implements OnInit { deleteEntity(entityId: any) { this.http.delete(this.coreUrl + "rest/users/" + this.serialId + "/entities/" + entityId) - .subscribe((data : any) => { + .subscribe((data: any) => { this.user.entities = data.entities; this.user.allEntities = data.allEntities; - this.notify.success(this.lang.entityDeleted+' « '+entityId+' »'); + this.notify.success(this.lang.entityDeleted + ' « ' + entityId + ' »'); }, (err) => { this.notify.error(err.error.errors); }); - + } submitSignature() { this.http.post(this.coreUrl + "rest/users/" + this.serialId + "/signatures", this.signatureModel) - .subscribe((data : any) => { + .subscribe((data: any) => { this.user.signatures = data.signatures; - this.notify.success(this.lang.signAdded+' « '+this.signatureModel.name+' »'); - this.signatureModel = { - base64 : "", - base64ForJs : "", - name : "", - type : "", - size : 0, - label : "", + this.notify.success(this.lang.signAdded + ' « ' + this.signatureModel.name + ' »'); + this.signatureModel = { + base64: "", + base64ForJs: "", + name: "", + type: "", + size: 0, + label: "", }; }, (err) => { this.notify.error(err.error.errors); }); } - updateSignature(selectedSignature:any) { + updateSignature(selectedSignature: any) { var id = this.user.signatures[selectedSignature].id; var label = this.user.signatures[selectedSignature].signature_label; - - this.http.put(this.coreUrl + "rest/users/" + this.serialId + "/signatures/" + id, {"label" : label}) - .subscribe((data : any) => { + + this.http.put(this.coreUrl + "rest/users/" + this.serialId + "/signatures/" + id, { "label": label }) + .subscribe((data: any) => { this.user.signatures[selectedSignature].signature_label = data.signature.signature_label; - this.notify.success(this.lang.signUpdated+' « '+data.signature.signature_label+' »'); + this.notify.success(this.lang.signUpdated + ' « ' + data.signature.signature_label + ' »'); }, (err) => { this.notify.error(err.error.errors); }); } deleteSignature(signature: any) { - let r = confirm(this.lang.confirmAction+' '+this.lang.delete+' « '+signature.signature_label+' »'); + let r = confirm(this.lang.confirmAction + ' ' + this.lang.delete + ' « ' + signature.signature_label + ' »'); if (r) { this.http.delete(this.coreUrl + "rest/users/" + this.serialId + "/signatures/" + signature.id) - .subscribe((data : any) => { + .subscribe((data: any) => { this.user.signatures = data.signatures; - this.notify.success(this.lang.signDeleted+' « '+signature.signature_label+' »'); + this.notify.success(this.lang.signDeleted + ' « ' + signature.signature_label + ' »'); }, (err) => { this.notify.error(err.error.errors); }); } } - addBasketRedirection(i:number,basket:any) { + addBasketRedirection(i: number, basket: any) { let r = false; - if(this.user.status != 'ABS'){ - let r = confirm(this.lang.confirmAction+' '+this.lang.activateAbs); + if (this.user.status != 'ABS') { + let r = confirm(this.lang.confirmAction + ' ' + this.lang.activateAbs); } - + if (r || this.user.status == 'ABS') { this.userAbsenceModel.push({ - "basketId" : this.user.baskets[i].basket_id, - "basketName" : this.user.baskets[i].basket_name, - "virtual" : this.user.baskets[i].is_virtual, - "basketOwner" : this.user.baskets[i].basket_owner, - "newUser" : this.user.baskets[i].userToDisplay + "basketId": this.user.baskets[i].basket_id, + "basketName": this.user.baskets[i].basket_name, + "virtual": this.user.baskets[i].is_virtual, + "basketOwner": this.user.baskets[i].basket_owner, + "newUser": this.user.baskets[i].userToDisplay }); this.activateAbsence(); } } - delBasketRedirection(i:number) { + delBasketRedirection(i: number) { this.user.baskets[i].userToDisplay = ''; } activateAbsence() { - this.http.post(this.coreUrl + "rest/users/" + this.serialId + "/baskets/absence", this.userAbsenceModel) - .subscribe((data : any) => { + this.http.put(this.coreUrl + "rest/users/" + this.serialId + "/status", {"status":"ABS"}) + .subscribe((data: any) => { this.user.status = data.user.status; - this.userAbsenceModel = []; - this.notify.success(this.lang.absOn+' '+this.lang.for+' « '+this.user.user_id+' »'); + this.userAbsenceModel = []; + this.notify.success(this.lang.absOn + ' ' + this.lang.for + ' « ' + this.user.user_id + ' »'); }, (err) => { this.notify.error(err.error.errors); }); } desactivateAbsence() { - this.http.put(this.coreUrl + "rest/users/" + this.serialId + "/status", {"status" : "OK"}) - .subscribe((data : any) => { + this.http.put(this.coreUrl + "rest/users/" + this.serialId + "/status", { "status": "OK" }) + .subscribe((data: any) => { this.user.status = data.user.status; for (let i in this.user.baskets) { this.user.baskets[i].userToDisplay = ''; } - this.notify.success(this.lang.absOff+' '+this.lang.for+' « '+this.user.user_id+' »'); + this.notify.success(this.lang.absOff + ' ' + this.lang.for + ' « ' + this.user.user_id + ' »'); }, (err) => { this.notify.error(err.error.errors); }); @@ -381,19 +395,27 @@ export class UserAdministrationComponent implements OnInit { onSubmit() { if (this.creationMode) { this.http.post(this.coreUrl + "rest/users", this.user) - .subscribe((data : any) => { - this.notify.success(this.lang.userAdded+' « '+data.user.user_id+' »'); + .subscribe((data: any) => { + this.notify.success(this.lang.userAdded + ' « ' + data.user.user_id + ' »'); this.router.navigate(["/administration/users/" + data.user.id]); }, (err) => { this.notify.error(err.error.errors); }); } else { this.http.put(this.coreUrl + "rest/users/" + this.serialId, this.user) - .subscribe((data : any) => { - this.notify.success(this.lang.userUpdated+' « '+this.user.user_id+' »'); + .subscribe((data: any) => { + this.notify.success(this.lang.userUpdated + ' « ' + this.user.user_id + ' »'); }, (err) => { this.notify.error(err.error.errors); }); } } } +export interface History { + event_date: Date; + event_type: string; + user_id: string; + table_name: number; + info: string; + remote_ip: string; +} diff --git a/apps/maarch_entreprise/js/angular/app/administration/users-administration.component.js b/apps/maarch_entreprise/js/angular/app/administration/users-administration.component.js index 409f93c0efa1487416070a0e74116d62a6d797a1..a58961dac067bd9ee77ce0b0206e2ffd26eb580b 100755 --- a/apps/maarch_entreprise/js/angular/app/administration/users-administration.component.js +++ b/apps/maarch_entreprise/js/angular/app/administration/users-administration.component.js @@ -1,4 +1,14 @@ "use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); @@ -8,41 +18,40 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; +var __param = (this && this.__param) || function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +}; Object.defineProperty(exports, "__esModule", { value: true }); var core_1 = require("@angular/core"); var http_1 = require("@angular/common/http"); var translate_component_1 = require("../translate.component"); var notification_service_1 = require("../notification.service"); -var DataTablePipe = /** @class */ (function () { - function DataTablePipe() { +var material_1 = require("@angular/material"); +var autocomplete_plugin_1 = require("../../plugins/autocomplete.plugin"); +var UsersAdministrationComponent = /** @class */ (function (_super) { + __extends(UsersAdministrationComponent, _super); + function UsersAdministrationComponent(http, notify, dialog) { + var _this = _super.call(this, http, 'users') || this; + _this.http = http; + _this.notify = notify; + _this.dialog = dialog; + _this.search = null; + _this.users = []; + _this.userDestRedirect = {}; + _this.userDestRedirectModels = []; + _this.lang = translate_component_1.LANG; + _this.loading = false; + _this.data = []; + _this.config = {}; + _this.displayedColumns = ['user_id', 'lastname', 'firstname', 'status', 'mail', 'actions']; + _this.dataSource = new material_1.MatTableDataSource(_this.data); + return _this; } - DataTablePipe.prototype.transform = function (array, field, query) { - if (query) { - query = query.toLowerCase(); - return array.filter(function (value) { - return value[field].toLowerCase().indexOf(query) > -1; - }); - } - return array; + UsersAdministrationComponent.prototype.applyFilter = function (filterValue) { + filterValue = filterValue.trim(); // Remove whitespace + filterValue = filterValue.toLowerCase(); // MatTableDataSource defaults to lowercase matches + this.dataSource.filter = filterValue; }; - DataTablePipe = __decorate([ - core_1.Pipe({ name: 'dataPipe' }) - ], DataTablePipe); - return DataTablePipe; -}()); -exports.DataTablePipe = DataTablePipe; -var UsersAdministrationComponent = /** @class */ (function () { - function UsersAdministrationComponent(http, notify) { - this.http = http; - this.notify = notify; - this.search = null; - this.users = []; - this.userDestRedirect = {}; - this.userDestRedirectModels = []; - this.lang = translate_component_1.LANG; - this.loading = false; - this.data = []; - } UsersAdministrationComponent.prototype.updateBreadcrumb = function (applicationName) { if ($j('#ariane')[0]) { $j('#ariane')[0].innerHTML = "<a href='index.php?reinit=true'>" + applicationName + "</a> > <a onclick='location.hash = \"/administration\"' style='cursor: pointer'>" + this.lang.administration + "</a> > " + this.lang.users; @@ -59,7 +68,9 @@ var UsersAdministrationComponent = /** @class */ (function () { _this.data = _this.users; _this.loading = false; setTimeout(function () { - $j("[md2sortby='user_id']").click(); + _this.dataSource = new material_1.MatTableDataSource(_this.data); + _this.dataSource.paginator = _this.paginator; + _this.dataSource.sort = _this.sort; }, 0); }, function () { location.href = "index.php"; @@ -73,6 +84,37 @@ var UsersAdministrationComponent = /** @class */ (function () { this.http.get(this.coreUrl + 'rest/listModels/itemId/' + user.user_id + '/itemMode/dest/objectType/entity_id') .subscribe(function (data) { _this.userDestRedirectModels = data.listModels; + _this.config = { data: { userDestRedirect: _this.userDestRedirect, userDestRedirectModels: _this.userDestRedirectModels } }; + _this.dialogRef = _this.dialog.open(UsersAdministrationRedirectModalComponent, _this.config); + _this.dialogRef.afterClosed().subscribe(function (result) { + console.log(result); + if (result) { + user.enabled = 'N'; + user.redirectListModels = result; + //first, update listModels + _this.http.put(_this.coreUrl + 'rest/listModels/itemId/' + user.user_id + '/itemMode/dest/objectType/entity_id', user) + .subscribe(function (data) { + if (data.errors) { + user.enabled = 'Y'; + _this.notify.error(data.errors); + } + else { + //then suspend user + _this.http.put(_this.coreUrl + 'rest/users/' + user.id, user) + .subscribe(function (data) { + user.inDiffListDest = 'N'; + _this.notify.success(_this.lang.userSuspended + ' « ' + user.user_id + ' »'); + }, function (err) { + user.enabled = 'Y'; + _this.notify.error(JSON.parse(err._body).errors); + }); + } + }, function (err) { + _this.notify.error(JSON.parse(err._body).errors); + }); + } + _this.dialogRef = null; + }); }, function (err) { console.log(err); location.href = "index.php"; @@ -92,36 +134,6 @@ var UsersAdministrationComponent = /** @class */ (function () { } } }; - UsersAdministrationComponent.prototype.suspendUserModal = function (user) { - var _this = this; - var r = confirm(this.lang.confirmAction + ' ' + this.lang.suspend + ' « ' + user.user_id + ' »'); - if (r) { - user.enabled = 'N'; - user.redirectListModels = this.userDestRedirectModels; - //first, update listModels - this.http.put(this.coreUrl + 'rest/listModels/itemId/' + user.user_id + '/itemMode/dest/objectType/entity_id', user) - .subscribe(function (data) { - if (data.errors) { - user.enabled = 'Y'; - _this.notify.error(data.errors); - } - else { - //then suspend user - _this.http.put(_this.coreUrl + 'rest/users/' + user.id, user) - .subscribe(function (data) { - user.inDiffListDest = 'N'; - $j('#changeDiffListDest').modal('hide'); - _this.notify.success(_this.lang.userSuspended + ' « ' + user.user_id + ' »'); - }, function (err) { - user.enabled = 'Y'; - _this.notify.error(JSON.parse(err._body).errors); - }); - } - }, function (err) { - _this.notify.error(JSON.parse(err._body).errors); - }); - } - }; UsersAdministrationComponent.prototype.activateUser = function (user) { var _this = this; var r = confirm(this.lang.confirmAction + ' ' + this.lang.authorize + ' « ' + user.user_id + ' »'); @@ -144,6 +156,36 @@ var UsersAdministrationComponent = /** @class */ (function () { this.http.get(this.coreUrl + 'rest/listModels/itemId/' + user.user_id + '/itemMode/dest/objectType/entity_id') .subscribe(function (data) { _this.userDestRedirectModels = data.listModels; + _this.config = { data: { userDestRedirect: _this.userDestRedirect, userDestRedirectModels: _this.userDestRedirectModels } }; + _this.dialogRef = _this.dialog.open(UsersAdministrationRedirectModalComponent, _this.config); + _this.dialogRef.afterClosed().subscribe(function (result) { + if (result) { + user.redirectListModels = result; + //first, update listModels + _this.http.put(_this.coreUrl + 'rest/listModels/itemId/' + user.user_id + '/itemMode/dest/objectType/entity_id', user) + .subscribe(function (data) { + if (data.errors) { + _this.notify.error(data.errors); + } + else { + //then delete user + _this.http.delete(_this.coreUrl + 'rest/users/' + user.id) + .subscribe(function (data) { + user.inDiffListDest = 'N'; + _this.data = data.users; + _this.dataSource = new material_1.MatTableDataSource(_this.data); + _this.dataSource.paginator = _this.paginator; + _this.dataSource.sort = _this.sort; + _this.notify.success(_this.lang.userDeleted + ' « ' + user.user_id + ' »'); + }, function (err) { + _this.notify.error(JSON.parse(err._body).errors); + }); + } + }, function (err) { + _this.notify.error(JSON.parse(err._body).errors); + }); + } + }); }, function (err) { _this.notify.error(JSON.parse(err._body).errors); }); @@ -154,6 +196,9 @@ var UsersAdministrationComponent = /** @class */ (function () { this.http.delete(this.coreUrl + 'rest/users/' + user.id, user) .subscribe(function (data) { _this.data = data.users; + _this.dataSource = new material_1.MatTableDataSource(_this.data); + _this.dataSource.paginator = _this.paginator; + _this.dataSource.sort = _this.sort; _this.notify.success(_this.lang.userDeleted + ' « ' + user.user_id + ' »'); }, function (err) { _this.notify.error(JSON.parse(err._body).errors); @@ -161,42 +206,42 @@ var UsersAdministrationComponent = /** @class */ (function () { } } }; - UsersAdministrationComponent.prototype.deleteUserModal = function (user) { - var _this = this; - var r = confirm(this.lang.confirmAction + ' ' + this.lang.delete + ' « ' + user.user_id + ' »'); - if (r) { - user.redirectListModels = this.userDestRedirectModels; - //first, update listModels - this.http.put(this.coreUrl + 'rest/listModels/itemId/' + user.user_id + '/itemMode/dest/objectType/entity_id', user) - .subscribe(function (data) { - if (data.errors) { - _this.notify.error(data.errors); - } - else { - //then delete user - _this.http.delete(_this.coreUrl + 'rest/users/' + user.id) - .subscribe(function (data) { - user.inDiffListDest = 'N'; - _this.data = data.users; - $j('#changeDiffListDest').modal('hide'); - _this.notify.success(_this.lang.userDeleted + ' « ' + user.user_id + ' »'); - }, function (err) { - _this.notify.error(JSON.parse(err._body).errors); - }); - } - }, function (err) { - _this.notify.error(JSON.parse(err._body).errors); - }); - } - }; + __decorate([ + core_1.ViewChild(material_1.MatPaginator), + __metadata("design:type", material_1.MatPaginator) + ], UsersAdministrationComponent.prototype, "paginator", void 0); + __decorate([ + core_1.ViewChild(material_1.MatSort), + __metadata("design:type", material_1.MatSort) + ], UsersAdministrationComponent.prototype, "sort", void 0); UsersAdministrationComponent = __decorate([ core_1.Component({ templateUrl: angularGlobals["users-administrationView"], - styleUrls: ['../../node_modules/bootstrap/dist/css/bootstrap.min.css', 'css/users-administration.component.css'], + styleUrls: ['css/users-administration.component.css'], providers: [notification_service_1.NotificationService] }), - __metadata("design:paramtypes", [http_1.HttpClient, notification_service_1.NotificationService]) + __metadata("design:paramtypes", [http_1.HttpClient, notification_service_1.NotificationService, material_1.MatDialog]) ], UsersAdministrationComponent); return UsersAdministrationComponent; -}()); +}(autocomplete_plugin_1.AutoCompletePlugin)); exports.UsersAdministrationComponent = UsersAdministrationComponent; +var UsersAdministrationRedirectModalComponent = /** @class */ (function (_super) { + __extends(UsersAdministrationRedirectModalComponent, _super); + function UsersAdministrationRedirectModalComponent(http, data, dialogRef) { + var _this = _super.call(this, http, 'users') || this; + _this.http = http; + _this.data = data; + _this.dialogRef = dialogRef; + _this.lang = translate_component_1.LANG; + return _this; + } + UsersAdministrationRedirectModalComponent = __decorate([ + core_1.Component({ + templateUrl: angularGlobals["users-administration-redirect-modalView"], + }), + __param(1, core_1.Inject(material_1.MAT_DIALOG_DATA)), + __metadata("design:paramtypes", [http_1.HttpClient, Object, material_1.MatDialogRef]) + ], UsersAdministrationRedirectModalComponent); + return UsersAdministrationRedirectModalComponent; +}(autocomplete_plugin_1.AutoCompletePlugin)); +exports.UsersAdministrationRedirectModalComponent = UsersAdministrationRedirectModalComponent; diff --git a/apps/maarch_entreprise/js/angular/app/administration/users-administration.component.ts b/apps/maarch_entreprise/js/angular/app/administration/users-administration.component.ts index dc7f5ba41319323a315cd3aab55435c68a278eef..90fe538012d1fdef5157c2b3210dd26907934a2f 100755 --- a/apps/maarch_entreprise/js/angular/app/administration/users-administration.component.ts +++ b/apps/maarch_entreprise/js/angular/app/administration/users-administration.component.ts @@ -1,50 +1,56 @@ -import { Component, OnInit, Pipe, PipeTransform} from '@angular/core'; +import { Component, OnInit, ViewChild, Inject, TemplateRef } from '@angular/core'; +import {DOCUMENT} from '@angular/common'; import { HttpClient } from '@angular/common/http'; import { LANG } from '../translate.component'; import { NotificationService } from '../notification.service'; +import { MatPaginator, MatTableDataSource, MatSort, MatDialog, MatDialogConfig, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material'; -declare function $j(selector: any) : any; +import { AutoCompletePlugin } from '../../plugins/autocomplete.plugin'; -declare var angularGlobals : any; +declare function $j(selector: any): any; -@Pipe({ name: 'dataPipe' }) -export class DataTablePipe implements PipeTransform { - transform(array: any[], field: string, query: string): any { - if (query) { - query = query.toLowerCase(); - return array.filter((value: any) => - value[field].toLowerCase().indexOf(query) > -1); - } - return array; - } -} +declare var angularGlobals: any; @Component({ - templateUrl : angularGlobals["users-administrationView"], - styleUrls : ['../../node_modules/bootstrap/dist/css/bootstrap.min.css', 'css/users-administration.component.css'], - providers : [NotificationService] + templateUrl: angularGlobals["users-administrationView"], + styleUrls: ['css/users-administration.component.css'], + providers: [NotificationService] }) +export class UsersAdministrationComponent extends AutoCompletePlugin implements OnInit { + dialogRef: MatDialogRef<any>; + search: string = null; + coreUrl: string; + + users: any[] = []; + userDestRedirect: any = {}; + userDestRedirectModels: any[] = []; -export class UsersAdministrationComponent implements OnInit { - search : string = null; - - coreUrl : string; + lang: any = LANG; - users : any[] = []; - userDestRedirect : any = {}; - userDestRedirectModels : any[] = []; + loading: boolean = false; - lang : any = LANG; + data: Users[] = []; - loading : boolean = false; + config: any = {}; - data : any = []; - constructor(public http: HttpClient, private notify: NotificationService) { + displayedColumns = ['user_id', 'lastname', 'firstname', 'status', 'mail', 'actions']; + dataSource = new MatTableDataSource(this.data); + @ViewChild(MatPaginator) paginator: MatPaginator; + @ViewChild(MatSort) sort: MatSort; + applyFilter(filterValue: string) { + filterValue = filterValue.trim(); // Remove whitespace + filterValue = filterValue.toLowerCase(); // MatTableDataSource defaults to lowercase matches + this.dataSource.filter = filterValue; + } + + + constructor(public http: HttpClient, private notify: NotificationService, public dialog: MatDialog) { + super(http, 'users'); } updateBreadcrumb(applicationName: string) { if ($j('#ariane')[0]) { - $j('#ariane')[0].innerHTML = "<a href='index.php?reinit=true'>" + applicationName + "</a> > <a onclick='location.hash = \"/administration\"' style='cursor: pointer'>"+this.lang.administration+"</a> > "+this.lang.users; + $j('#ariane')[0].innerHTML = "<a href='index.php?reinit=true'>" + applicationName + "</a> > <a onclick='location.hash = \"/administration\"' style='cursor: pointer'>" + this.lang.administration + "</a> > " + this.lang.users; } } @@ -55,12 +61,14 @@ export class UsersAdministrationComponent implements OnInit { this.loading = true; this.http.get(this.coreUrl + 'rest/administration/users') - .subscribe((data : any) => { + .subscribe((data: any) => { this.users = data['users']; this.data = this.users; this.loading = false; setTimeout(() => { - $j("[md2sortby='user_id']").click(); + this.dataSource = new MatTableDataSource(this.data); + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; }, 0); }, () => { location.href = "index.php"; @@ -68,25 +76,57 @@ export class UsersAdministrationComponent implements OnInit { } suspendUser(user: any) { - if(user.inDiffListDest == 'Y') { + if (user.inDiffListDest == 'Y') { user.mode = 'up'; this.userDestRedirect = user; - this.http.get(this.coreUrl + 'rest/listModels/itemId/'+user.user_id+'/itemMode/dest/objectType/entity_id') - .subscribe((data : any) => { + this.http.get(this.coreUrl + 'rest/listModels/itemId/' + user.user_id + '/itemMode/dest/objectType/entity_id') + .subscribe((data: any) => { this.userDestRedirectModels = data.listModels; + this.config = {data : {userDestRedirect : this.userDestRedirect, userDestRedirectModels : this.userDestRedirectModels}}; + this.dialogRef = this.dialog.open(UsersAdministrationRedirectModalComponent,this.config); + this.dialogRef.afterClosed().subscribe((result: string) => { + console.log(result); + if (result) { + user.enabled = 'N'; + user.redirectListModels = result; + //first, update listModels + this.http.put(this.coreUrl + 'rest/listModels/itemId/' + user.user_id + '/itemMode/dest/objectType/entity_id', user) + .subscribe((data: any) => { + if (data.errors) { + user.enabled = 'Y'; + this.notify.error(data.errors); + } else { + //then suspend user + this.http.put(this.coreUrl + 'rest/users/' + user.id, user) + .subscribe((data: any) => { + user.inDiffListDest = 'N'; + this.notify.success(this.lang.userSuspended + ' « ' + user.user_id + ' »'); + + }, (err) => { + user.enabled = 'Y'; + this.notify.error(JSON.parse(err._body).errors); + }); + } + }, (err) => { + this.notify.error(JSON.parse(err._body).errors); + }); + } + this.dialogRef = null; + }); + }, (err) => { console.log(err); location.href = "index.php"; }); } else { - let r = confirm(this.lang.confirmAction+' '+this.lang.suspend+' « '+user.user_id+' »'); + let r = confirm(this.lang.confirmAction + ' ' + this.lang.suspend + ' « ' + user.user_id + ' »'); if (r) { user.enabled = 'N'; this.http.put(this.coreUrl + 'rest/users/' + user.id, user) - .subscribe((data : any) => { - this.notify.success(this.lang.userSuspended+' « '+user.user_id+' »'); - + .subscribe((data: any) => { + this.notify.success(this.lang.userSuspended + ' « ' + user.user_id + ' »'); + }, (err) => { user.enabled = 'Y'; this.notify.error(JSON.parse(err._body).errors); @@ -95,47 +135,15 @@ export class UsersAdministrationComponent implements OnInit { } } - suspendUserModal(user: any) { - let r = confirm(this.lang.confirmAction+' '+this.lang.suspend+' « '+user.user_id+' »'); - - if (r) { - user.enabled = 'N'; - user.redirectListModels = this.userDestRedirectModels; - //first, update listModels - this.http.put(this.coreUrl + 'rest/listModels/itemId/'+user.user_id+'/itemMode/dest/objectType/entity_id', user) - .subscribe((data : any) => { - if (data.errors) { - user.enabled = 'Y'; - this.notify.error(data.errors); - } else { - //then suspend user - this.http.put(this.coreUrl + 'rest/users/' + user.id, user) - .subscribe((data : any) => { - user.inDiffListDest = 'N'; - $j('#changeDiffListDest').modal('hide'); - this.notify.success(this.lang.userSuspended+' « '+user.user_id+' »'); - - }, (err) => { - user.enabled = 'Y'; - this.notify.error(JSON.parse(err._body).errors); - }); - } - }, (err) => { - this.notify.error(JSON.parse(err._body).errors); - }); - } - - } - activateUser(user: any) { - let r = confirm(this.lang.confirmAction+' '+this.lang.authorize+' « '+user.user_id+' »'); + let r = confirm(this.lang.confirmAction + ' ' + this.lang.authorize + ' « ' + user.user_id + ' »'); if (r) { user.enabled = 'Y'; this.http.put(this.coreUrl + 'rest/users/' + user.id, user) - .subscribe((data : any) => { - this.notify.success(this.lang.userAuthorized+' « '+user.user_id+' »'); - + .subscribe((data: any) => { + this.notify.success(this.lang.userAuthorized + ' « ' + user.user_id + ' »'); + }, (err) => { user.enabled = 'N'; this.notify.error(JSON.parse(err._body).errors); @@ -145,59 +153,79 @@ export class UsersAdministrationComponent implements OnInit { deleteUser(user: any) { - if(user.inDiffListDest == 'Y') { + if (user.inDiffListDest == 'Y') { user.mode = 'del'; this.userDestRedirect = user; - this.http.get(this.coreUrl + 'rest/listModels/itemId/'+user.user_id+'/itemMode/dest/objectType/entity_id') - .subscribe((data : any) => { + this.http.get(this.coreUrl + 'rest/listModels/itemId/' + user.user_id + '/itemMode/dest/objectType/entity_id') + .subscribe((data: any) => { this.userDestRedirectModels = data.listModels; + this.config = {data : {userDestRedirect : this.userDestRedirect, userDestRedirectModels : this.userDestRedirectModels}}; + this.dialogRef = this.dialog.open(UsersAdministrationRedirectModalComponent,this.config); + this.dialogRef.afterClosed().subscribe((result: string) => { + if (result) { + user.redirectListModels = result; + //first, update listModels + this.http.put(this.coreUrl + 'rest/listModels/itemId/' + user.user_id + '/itemMode/dest/objectType/entity_id', user) + .subscribe((data: any) => { + if (data.errors) { + this.notify.error(data.errors); + } else { + //then delete user + this.http.delete(this.coreUrl + 'rest/users/' + user.id) + .subscribe((data: any) => { + user.inDiffListDest = 'N'; + this.data = data.users; + this.dataSource = new MatTableDataSource(this.data); + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; + + this.notify.success(this.lang.userDeleted + ' « ' + user.user_id + ' »'); + + }, (err) => { + this.notify.error(JSON.parse(err._body).errors); + }); + } + }, (err) => { + this.notify.error(JSON.parse(err._body).errors); + }); + } + }); }, (err) => { this.notify.error(JSON.parse(err._body).errors); }); - } else { - let r = confirm(this.lang.confirmAction+' '+this.lang.delete+' « '+user.user_id+' »'); + } else { + let r = confirm(this.lang.confirmAction + ' ' + this.lang.delete + ' « ' + user.user_id + ' »'); if (r) { this.http.delete(this.coreUrl + 'rest/users/' + user.id, user) - .subscribe((data : any) => { + .subscribe((data: any) => { this.data = data.users; - this.notify.success(this.lang.userDeleted+' « '+user.user_id+' »'); - + this.dataSource = new MatTableDataSource(this.data); + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; + this.notify.success(this.lang.userDeleted + ' « ' + user.user_id + ' »'); + }, (err) => { this.notify.error(JSON.parse(err._body).errors); }); } } } - - deleteUserModal(user: any) { - let r = confirm(this.lang.confirmAction+' '+this.lang.delete+' « '+user.user_id+' »'); - - if (r) { - user.redirectListModels = this.userDestRedirectModels; - //first, update listModels - this.http.put(this.coreUrl + 'rest/listModels/itemId/'+user.user_id+'/itemMode/dest/objectType/entity_id', user) - .subscribe((data : any) => { - if (data.errors) { - this.notify.error(data.errors); - } else { - //then delete user - this.http.delete(this.coreUrl + 'rest/users/' + user.id) - .subscribe((data : any) => { - user.inDiffListDest = 'N'; - this.data = data.users; - $j('#changeDiffListDest').modal('hide'); - this.notify.success(this.lang.userDeleted+' « '+user.user_id+' »'); - - }, (err) => { - this.notify.error(JSON.parse(err._body).errors); - }); - } - }, (err) => { - this.notify.error(JSON.parse(err._body).errors); - }); - } - } - } +export interface Users { + user_id: string; + lastname: string; + firstname: string; + status: string; + mail: string; +} +@Component({ + templateUrl: angularGlobals["users-administration-redirect-modalView"], + }) + export class UsersAdministrationRedirectModalComponent extends AutoCompletePlugin { + lang: any = LANG; + constructor(public http: HttpClient, @Inject(MAT_DIALOG_DATA) public data: any,public dialogRef: MatDialogRef<UsersAdministrationRedirectModalComponent>) { + super(http, 'users'); + } + } \ No newline at end of file diff --git a/apps/maarch_entreprise/js/angularFunctions.js b/apps/maarch_entreprise/js/angularFunctions.js index 8d53b4382660b468def1de3c4460174d051d6fef..74785c9c21cc8e88d3a94d092b32e1b149982371 100755 --- a/apps/maarch_entreprise/js/angularFunctions.js +++ b/apps/maarch_entreprise/js/angularFunctions.js @@ -4,6 +4,7 @@ function triggerAngular(prodmode, locationToGo) { //'header', 'administration', 'users-administration', + 'users-administration-redirect-modal', 'user-administration', 'groups-administration', 'group-administration', diff --git a/core/Models/UserModelAbstract.php b/core/Models/UserModelAbstract.php index 4b9a54d122069abcc4364ad1cee0346ea82ad3a9..72b94f7bdacf149bc8f4724213fdbec75153db74 100755 --- a/core/Models/UserModelAbstract.php +++ b/core/Models/UserModelAbstract.php @@ -1,17 +1,17 @@ <?php /** -* Copyright Maarch since 2008 under licence GPLv3. -* See LICENCE.txt file at the root folder for more details. -* This file is part of Maarch software. -* -*/ + * Copyright Maarch since 2008 under licence GPLv3. + * See LICENCE.txt file at the root folder for more details. + * This file is part of Maarch software. + */ /** -* @brief User Model -* @author dev@maarch.org -* @ingroup core -*/ + * @brief User Model + * + * @author dev@maarch.org + * @ingroup core + */ namespace Core\Models; @@ -25,10 +25,10 @@ class UserModelAbstract ValidatorModel::arrayType($aArgs, ['select', 'where', 'data']); $aUsers = DatabaseModel::select([ - 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], - 'table' => ['users'], - 'where' => empty($aArgs['where']) ? [] : $aArgs['where'], - 'data' => empty($aArgs['data']) ? [] : $aArgs['data'] + 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], + 'table' => ['users'], + 'where' => empty($aArgs['where']) ? [] : $aArgs['where'], + 'data' => empty($aArgs['data']) ? [] : $aArgs['data'], ]); return $aUsers; @@ -40,10 +40,10 @@ class UserModelAbstract ValidatorModel::intVal($aArgs, ['id']); $aUser = DatabaseModel::select([ - 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], - 'table' => ['users'], - 'where' => ['id = ?'], - 'data' => [$aArgs['id']] + 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], + 'table' => ['users'], + 'where' => ['id = ?'], + 'data' => [$aArgs['id']], ]); if (empty($aUser)) { @@ -60,21 +60,21 @@ class UserModelAbstract ValidatorModel::stringType($aArgs['user'], ['userId', 'firstname', 'lastname', 'mail', 'initials', 'thumbprint', 'phone', 'changePassword']); DatabaseModel::insert([ - 'table' => 'users', + 'table' => 'users', 'columnsValues' => [ - 'user_id' => $aArgs['user']['userId'], - 'firstname' => $aArgs['user']['firstname'], - 'lastname' => $aArgs['user']['lastname'], - 'mail' => $aArgs['user']['mail'], - 'phone' => $aArgs['user']['phone'], - 'initials' => $aArgs['user']['initials'], - 'thumbprint' => $aArgs['user']['thumbprint'], - 'enabled' => 'Y', - 'status' => 'OK', - 'change_password' => empty($aArgs['user']['changePassword']) ? 'Y' : $aArgs['user']['changePassword'], - 'loginmode' => 'standard', - 'password' => SecurityModel::getPasswordHash('maarch') - ] + 'user_id' => $aArgs['user']['userId'], + 'firstname' => $aArgs['user']['firstname'], + 'lastname' => $aArgs['user']['lastname'], + 'mail' => $aArgs['user']['mail'], + 'phone' => $aArgs['user']['phone'], + 'initials' => $aArgs['user']['initials'], + 'thumbprint' => $aArgs['user']['thumbprint'], + 'enabled' => 'Y', + 'status' => 'OK', + 'change_password' => empty($aArgs['user']['changePassword']) ? 'Y' : $aArgs['user']['changePassword'], + 'loginmode' => 'standard', + 'password' => SecurityModel::getPasswordHash('maarch'), + ], ]); return true; @@ -88,18 +88,18 @@ class UserModelAbstract ValidatorModel::stringType($aArgs['user'], ['firstname', 'lastname', 'mail', 'initials', 'thumbprint', 'phone', 'enabled']); DatabaseModel::update([ - 'table' => 'users', - 'set' => [ - 'firstname' => $aArgs['user']['firstname'], - 'lastname' => $aArgs['user']['lastname'], - 'mail' => $aArgs['user']['mail'], - 'phone' => $aArgs['user']['phone'], - 'initials' => $aArgs['user']['initials'], - 'enabled' => $aArgs['user']['enabled'], - 'thumbprint' => $aArgs['user']['thumbprint'] + 'table' => 'users', + 'set' => [ + 'firstname' => $aArgs['user']['firstname'], + 'lastname' => $aArgs['user']['lastname'], + 'mail' => $aArgs['user']['mail'], + 'phone' => $aArgs['user']['phone'], + 'initials' => $aArgs['user']['initials'], + 'enabled' => $aArgs['user']['enabled'], + 'thumbprint' => $aArgs['user']['thumbprint'], ], - 'where' => ['id = ?'], - 'data' => [$aArgs['id']] + 'where' => ['id = ?'], + 'data' => [$aArgs['id']], ]); return true; @@ -111,12 +111,12 @@ class UserModelAbstract ValidatorModel::intVal($aArgs, ['id']); DatabaseModel::update([ - 'table' => 'users', - 'set' => [ - 'status' => 'DEL', + 'table' => 'users', + 'set' => [ + 'status' => 'DEL', ], - 'where' => ['id = ?'], - 'data' => [$aArgs['id']] + 'where' => ['id = ?'], + 'data' => [$aArgs['id']], ]); return true; @@ -128,10 +128,10 @@ class UserModelAbstract ValidatorModel::stringType($aArgs, ['userId']); $aUser = DatabaseModel::select([ - 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], - 'table' => ['users'], - 'where' => ['user_id = ?'], - 'data' => [$aArgs['userId']] + 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], + 'table' => ['users'], + 'where' => ['user_id = ?'], + 'data' => [$aArgs['userId']], ]); if (empty($aUser)) { @@ -147,10 +147,10 @@ class UserModelAbstract ValidatorModel::arrayType($aArgs, ['entities']); $aUsers = DatabaseModel::select([ - 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], - 'table' => ['users, users_entities'], - 'where' => ['users.user_id = users_entities.user_id', 'users_entities.entity_id in (?)'], - 'data' => [$aArgs['entities']] + 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], + 'table' => ['users, users_entities'], + 'where' => ['users.user_id = users_entities.user_id', 'users_entities.entity_id in (?)'], + 'data' => [$aArgs['entities']], ]); return $aUsers; @@ -162,11 +162,11 @@ class UserModelAbstract ValidatorModel::stringType($aArgs, ['mail']); $aUser = DatabaseModel::select([ - 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], - 'table' => ['users'], - 'where' => ['mail = ? and status = ?'], - 'data' => [$aArgs['mail'], 'OK'], - 'limit' => 1 + 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], + 'table' => ['users'], + 'where' => ['mail = ? and status = ?'], + 'data' => [$aArgs['mail'], 'OK'], + 'limit' => 1, ]); return $aUser; @@ -179,12 +179,12 @@ class UserModelAbstract ValidatorModel::stringType($aArgs, ['password']); DatabaseModel::update([ - 'table' => 'users', - 'set' => [ - 'password' => SecurityModel::getPasswordHash($aArgs['password']) + 'table' => 'users', + 'set' => [ + 'password' => SecurityModel::getPasswordHash($aArgs['password']), ], - 'where' => ['id = ?'], - 'data' => [$aArgs['id']] + 'where' => ['id = ?'], + 'data' => [$aArgs['id']], ]); return true; @@ -196,12 +196,12 @@ class UserModelAbstract ValidatorModel::intVal($aArgs, ['id']); DatabaseModel::update([ - 'table' => 'users', - 'set' => [ - 'password' => SecurityModel::getPasswordHash('maarch') + 'table' => 'users', + 'set' => [ + 'password' => SecurityModel::getPasswordHash('maarch'), ], - 'where' => ['id = ?'], - 'data' => [$aArgs['id']] + 'where' => ['id = ?'], + 'data' => [$aArgs['id']], ]); return true; @@ -214,13 +214,13 @@ class UserModelAbstract ValidatorModel::intVal($aArgs, ['userSerialId']); DatabaseModel::insert([ - 'table' => 'user_signatures', + 'table' => 'user_signatures', 'columnsValues' => [ - 'user_serial_id' => $aArgs['userSerialId'], - 'signature_label' => $aArgs['signatureLabel'], - 'signature_path' => $aArgs['signaturePath'], - 'signature_file_name' => $aArgs['signatureFileName'] - ] + 'user_serial_id' => $aArgs['userSerialId'], + 'signature_label' => $aArgs['signatureLabel'], + 'signature_path' => $aArgs['signaturePath'], + 'signature_file_name' => $aArgs['signatureFileName'], + ], ]); return true; @@ -233,12 +233,12 @@ class UserModelAbstract ValidatorModel::intVal($aArgs, ['signatureId', 'userSerialId']); DatabaseModel::update([ - 'table' => 'user_signatures', - 'set' => [ - 'signature_label' => $aArgs['label'] + 'table' => 'user_signatures', + 'set' => [ + 'signature_label' => $aArgs['label'], ], - 'where' => ['user_serial_id = ?', 'id = ?'], - 'data' => [$aArgs['userSerialId'], $aArgs['signatureId']] + 'where' => ['user_serial_id = ?', 'id = ?'], + 'data' => [$aArgs['userSerialId'], $aArgs['signatureId']], ]); return true; @@ -250,9 +250,9 @@ class UserModelAbstract ValidatorModel::intVal($aArgs, ['signatureId', 'userSerialId']); DatabaseModel::delete([ - 'table' => 'user_signatures', - 'where' => ['user_serial_id = ?', 'id = ?'], - 'data' => [$aArgs['userSerialId'], $aArgs['signatureId']], + 'table' => 'user_signatures', + 'where' => ['user_serial_id = ?', 'id = ?'], + 'data' => [$aArgs['userSerialId'], $aArgs['signatureId']], ]); return true; @@ -264,12 +264,12 @@ class UserModelAbstract ValidatorModel::stringType($aArgs, ['userId', 'title', 'htmlBody']); DatabaseModel::insert([ - 'table' => 'users_email_signatures', + 'table' => 'users_email_signatures', 'columnsValues' => [ - 'user_id' => $aArgs['userId'], - 'title' => $aArgs['title'], - 'html_body' => $aArgs['htmlBody'] - ] + 'user_id' => $aArgs['userId'], + 'title' => $aArgs['title'], + 'html_body' => $aArgs['htmlBody'], + ], ]); return true; @@ -277,18 +277,18 @@ class UserModelAbstract public static function updateEmailSignature(array $aArgs = []) { - ValidatorModel::notEmpty($aArgs, ['id','userId', 'title', 'htmlBody']); + ValidatorModel::notEmpty($aArgs, ['id', 'userId', 'title', 'htmlBody']); ValidatorModel::stringType($aArgs, ['userId', 'title', 'htmlBody']); ValidatorModel::intVal($aArgs, ['id']); DatabaseModel::update([ - 'table' => 'users_email_signatures', - 'set' => [ - 'title' => $aArgs['title'], + 'table' => 'users_email_signatures', + 'set' => [ + 'title' => $aArgs['title'], 'html_body' => $aArgs['htmlBody'], ], - 'where' => ['user_id = ?', 'id = ?'], - 'data' => [$aArgs['userId'], $aArgs['id']] + 'where' => ['user_id = ?', 'id = ?'], + 'data' => [$aArgs['userId'], $aArgs['id']], ]); return true; @@ -300,9 +300,9 @@ class UserModelAbstract ValidatorModel::stringType($aArgs, ['userId']); DatabaseModel::delete([ - 'table' => 'users_email_signatures', - 'where' => ['user_id = ?', 'id = ?'], - 'data' => [$aArgs['userId'], $aArgs['id']] + 'table' => 'users_email_signatures', + 'where' => ['user_id = ?', 'id = ?'], + 'data' => [$aArgs['userId'], $aArgs['id']], ]); return true; @@ -314,11 +314,11 @@ class UserModelAbstract ValidatorModel::intVal($aArgs, ['id']); $aReturn = DatabaseModel::select([ - 'select' => ['id', 'user_serial_id', 'signature_label', 'signature_path', 'signature_file_name'], - 'table' => ['user_signatures'], - 'where' => ['user_serial_id = ?'], - 'data' => [$aArgs['id']], - 'order_by' => ['id'] + 'select' => ['id', 'user_serial_id', 'signature_label', 'signature_path', 'signature_file_name'], + 'table' => ['user_signatures'], + 'where' => ['user_serial_id = ?'], + 'data' => [$aArgs['id']], + 'order_by' => ['id'], ]); $docserver = []; @@ -330,16 +330,16 @@ class UserModelAbstract return []; } $tmpPath = CoreConfigModel::getTmpPath(); - $urlTmpPath = str_replace('rest/', '', \Url::coreurl()) . 'apps/maarch_entreprise/tmp/'; - foreach($aReturn as $key => $value) { - $pathToSignature = $docserver['path_template'] . str_replace('#', '/', $value['signature_path']) . $value['signature_file_name']; + $urlTmpPath = str_replace('rest/', '', \Url::coreurl()).'apps/maarch_entreprise/tmp/'; + foreach ($aReturn as $key => $value) { + $pathToSignature = $docserver['path_template'].str_replace('#', '/', $value['signature_path']).$value['signature_file_name']; $extension = explode('.', $pathToSignature); $extension = $extension[count($extension) - 1]; - $fileNameOnTmp = 'tmp_file_' . $aArgs['id'] . '_' . rand() . '.' . strtolower($extension); - $filePathOnTmp = $tmpPath . $fileNameOnTmp; + $fileNameOnTmp = 'tmp_file_'.$aArgs['id'].'_'.rand().'.'.strtolower($extension); + $filePathOnTmp = $tmpPath.$fileNameOnTmp; if (file_exists($pathToSignature) && copy($pathToSignature, $filePathOnTmp)) { - $aReturn[$key]['pathToSignatureOnTmp'] = $urlTmpPath . $fileNameOnTmp; + $aReturn[$key]['pathToSignatureOnTmp'] = $urlTmpPath.$fileNameOnTmp; } else { $aReturn[$key]['pathToSignatureOnTmp'] = ''; } @@ -354,13 +354,13 @@ class UserModelAbstract public static function getSignatureWithSignatureIdById(array $aArgs = []) { ValidatorModel::notEmpty($aArgs, ['id', 'signatureId']); - ValidatorModel::intVal($aArgs, ['id','signatureId']); + ValidatorModel::intVal($aArgs, ['id', 'signatureId']); $aReturn = DatabaseModel::select([ - 'select' => ['id', 'user_serial_id', 'signature_label'], - 'table' => ['user_signatures'], - 'where' => ['user_serial_id = ?', 'id = ?'], - 'data' => [$aArgs['id'], $aArgs['signatureId']], + 'select' => ['id', 'user_serial_id', 'signature_label'], + 'table' => ['user_signatures'], + 'where' => ['user_serial_id = ?', 'id = ?'], + 'data' => [$aArgs['id'], $aArgs['signatureId']], ]); return $aReturn[0]; @@ -372,11 +372,11 @@ class UserModelAbstract ValidatorModel::stringType($aArgs, ['userId']); $aReturn = DatabaseModel::select([ - 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], - 'table' => ['users_email_signatures'], - 'where' => ['user_id = ?'], - 'data' => [$aArgs['userId']], - 'order_by' => ['id'] + 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], + 'table' => ['users_email_signatures'], + 'where' => ['user_id = ?'], + 'data' => [$aArgs['userId']], + 'order_by' => ['id'], ]); return $aReturn; @@ -389,10 +389,10 @@ class UserModelAbstract ValidatorModel::intVal($aArgs, ['signatureId']); $aReturn = DatabaseModel::select([ - 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], - 'table' => ['users_email_signatures'], - 'where' => ['user_id = ?', 'id = ?'], - 'data' => [$aArgs['userId'], $aArgs['signatureId']], + 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], + 'table' => ['users_email_signatures'], + 'where' => ['user_id = ?', 'id = ?'], + 'data' => [$aArgs['userId'], $aArgs['signatureId']], ]); return $aReturn[0]; @@ -411,7 +411,7 @@ class UserModelAbstract $labelledUser = ''; if (!empty($rawUser)) { - $labelledUser = $rawUser['firstname']. ' ' .$rawUser['lastname']; + $labelledUser = $rawUser['firstname'].' '.$rawUser['lastname']; } return $labelledUser; @@ -422,14 +422,13 @@ class UserModelAbstract ValidatorModel::notEmpty($aArgs, ['resId']); ValidatorModel::intVal($aArgs, ['resId']); - $aReturn = DatabaseModel::select([ - 'select' => ['process_comment'], - 'table' => ['listinstance'], - 'where' => ['res_id = ?', 'process_date is null', 'item_mode in (?)'], - 'data' => [$aArgs['resId'], ['visa', 'sign']], - 'order_by' => ['listinstance_id ASC'], - 'limit' => 1 + 'select' => ['process_comment'], + 'table' => ['listinstance'], + 'where' => ['res_id = ?', 'process_date is null', 'item_mode in (?)'], + 'data' => [$aArgs['resId'], ['visa', 'sign']], + 'order_by' => ['listinstance_id ASC'], + 'limit' => 1, ]); if (empty($aReturn[0])) { @@ -444,12 +443,11 @@ class UserModelAbstract ValidatorModel::notEmpty($aArgs, ['userId']); ValidatorModel::stringType($aArgs, ['userId']); - $aGroup = DatabaseModel::select([ - 'select' => ['usergroup_content.group_id', 'usergroups.group_desc'], - 'table' => ['usergroup_content, usergroups'], - 'where' => ['usergroup_content.group_id = usergroups.group_id', 'usergroup_content.user_id = ?', 'usergroup_content.primary_group = ?'], - 'data' => [$aArgs['userId'], 'Y'] + 'select' => ['usergroup_content.group_id', 'usergroups.group_desc'], + 'table' => ['usergroup_content, usergroups'], + 'where' => ['usergroup_content.group_id = usergroups.group_id', 'usergroup_content.user_id = ?', 'usergroup_content.primary_group = ?'], + 'data' => [$aArgs['userId'], 'Y'], ]); if (empty($aGroup[0])) { @@ -465,10 +463,10 @@ class UserModelAbstract ValidatorModel::stringType($aArgs, ['userId']); $aEntity = DatabaseModel::select([ - 'select' => ['users_entities.entity_id', 'entities.entity_label', 'users_entities.user_role', 'users_entities.primary_entity'], - 'table' => ['users_entities, entities'], - 'where' => ['users_entities.entity_id = entities.entity_id', 'users_entities.user_id = ?', 'users_entities.primary_entity = ?'], - 'data' => [$aArgs['userId'], 'Y'] + 'select' => ['users_entities.entity_id', 'entities.entity_label', 'users_entities.user_role', 'users_entities.primary_entity'], + 'table' => ['users_entities, entities'], + 'where' => ['users_entities.entity_id = entities.entity_id', 'users_entities.user_id = ?', 'users_entities.primary_entity = ?'], + 'data' => [$aArgs['userId'], 'Y'], ]); if (empty($aEntity[0])) { @@ -484,10 +482,10 @@ class UserModelAbstract ValidatorModel::stringType($aArgs, ['userId']); $aGroups = DatabaseModel::select([ - 'select' => ['usergroup_content.group_id', 'usergroups.group_desc', 'usergroup_content.primary_group', 'usergroup_content.role', 'security.maarch_comment', 'security.where_clause'], - 'table' => ['usergroup_content, usergroups, security'], - 'where' => ['usergroup_content.group_id = usergroups.group_id', 'usergroup_content.user_id = ?','usergroups.group_id = security.group_id'], - 'data' => [$aArgs['userId']] + 'select' => ['usergroup_content.group_id', 'usergroups.group_desc', 'usergroup_content.primary_group', 'usergroup_content.role', 'security.maarch_comment', 'security.where_clause'], + 'table' => ['usergroup_content, usergroups, security'], + 'where' => ['usergroup_content.group_id = usergroups.group_id', 'usergroup_content.user_id = ?', 'usergroups.group_id = security.group_id'], + 'data' => [$aArgs['userId']], ]); return $aGroups; @@ -499,11 +497,11 @@ class UserModelAbstract ValidatorModel::stringType($aArgs, ['userId']); $aEntities = DatabaseModel::select([ - 'select' => ['users_entities.entity_id', 'entities.entity_label', 'users_entities.user_role', 'users_entities.primary_entity'], - 'table' => ['users_entities, entities'], - 'where' => ['users_entities.entity_id = entities.entity_id', 'users_entities.user_id = ?'], - 'data' => [$aArgs['userId']], - 'order_by' => ['users_entities.primary_entity DESC'] + 'select' => ['users_entities.entity_id', 'entities.entity_label', 'users_entities.user_role', 'users_entities.primary_entity'], + 'table' => ['users_entities, entities'], + 'where' => ['users_entities.entity_id = entities.entity_id', 'users_entities.user_id = ?'], + 'data' => [$aArgs['userId']], + 'order_by' => ['users_entities.primary_entity DESC'], ]); return $aEntities; @@ -515,10 +513,10 @@ class UserModelAbstract ValidatorModel::stringType($aArgs, ['userId']); $aServices = DatabaseModel::select([ - 'select' => ['usergroups_services.service_id'], - 'table' => ['usergroup_content, usergroups_services'], - 'where' => ['usergroup_content.group_id = usergroups_services.group_id', 'usergroup_content.user_id = ?'], - 'data' => [$aArgs['userId']] + 'select' => ['usergroups_services.service_id'], + 'table' => ['usergroup_content, usergroups_services'], + 'where' => ['usergroup_content.group_id = usergroups_services.group_id', 'usergroup_content.user_id = ?'], + 'data' => [$aArgs['userId']], ]); return $aServices; @@ -531,12 +529,12 @@ class UserModelAbstract ValidatorModel::stringType($aArgs, ['status']); DatabaseModel::update([ - 'table' => 'users', - 'set' => [ - 'status' => $aArgs['status'] + 'table' => 'users', + 'set' => [ + 'status' => $aArgs['status'], ], - 'where' => ['id = ?'], - 'data' => [$aArgs['id']] + 'where' => ['id = ?'], + 'data' => [$aArgs['id']], ]); return true; @@ -567,23 +565,23 @@ class UserModelAbstract $user = UserModel::getById(['id' => $aArgs['id'], 'select' => ['user_id']]); DatabaseModel::insert([ - 'table' => 'usergroup_content', + 'table' => 'usergroup_content', 'columnsValues' => [ - 'user_id' => $user['user_id'], - 'group_id' => $aArgs['groupId'], - 'role' => $aArgs['role'], - 'primary_group' => 'Y' - ] + 'user_id' => $user['user_id'], + 'group_id' => $aArgs['groupId'], + 'role' => $aArgs['role'], + 'primary_group' => 'Y', + ], ]); - $groupInfos = GroupModel::getById(['groupId' => $aArgs['groupId']]); + $groupInfos = GroupModel::getByGroupId(['groupId' => $aArgs['groupId']]); HistoryController::add([ 'tableName' => 'users', - 'recordId' =>$user['user_id'], + 'recordId' => $user['user_id'], 'eventType' => 'GROUP ADD', - 'eventId' => 'groupadded', - 'info' =>$_SESSION['user']['UserId'].' '._ADDED_USER.' '.$user['user_id'].' '._IN_GROUP.' '.$groupInfos['group_desc'] + 'eventId' => 'groupadded', + 'info' => $_SESSION['user']['UserId'].' '._ADDED_USER.' '.$user['user_id'].' '._IN_GROUP.' '.$groupInfos['group_desc'], ]); return true; @@ -597,12 +595,12 @@ class UserModelAbstract $user = UserModel::getById(['id' => $aArgs['id'], 'select' => ['user_id']]); DatabaseModel::update([ - 'table' => 'usergroup_content', - 'set' => [ - 'role' => $aArgs['role'] + 'table' => 'usergroup_content', + 'set' => [ + 'role' => $aArgs['role'], ], - 'where' => ['user_id = ?', 'group_id = ?'], - 'data' => [$user['user_id'], $aArgs['groupId']] + 'where' => ['user_id = ?', 'group_id = ?'], + 'data' => [$user['user_id'], $aArgs['groupId']], ]); return true; @@ -616,19 +614,19 @@ class UserModelAbstract $user = UserModel::getById(['id' => $aArgs['id'], 'select' => ['user_id']]); DatabaseModel::delete([ - 'table' => 'usergroup_content', - 'where' => ['group_id = ?', 'user_id = ?'], - 'data' => [$aArgs['groupId'], $user['user_id']] + 'table' => 'usergroup_content', + 'where' => ['group_id = ?', 'user_id = ?'], + 'data' => [$aArgs['groupId'], $user['user_id']], ]); - $groupInfos = GroupModel::getById(['groupId' => $aArgs['groupId']]); + $groupInfos = GroupModel::getByGroupId(['groupId' => $aArgs['groupId']]); HistoryController::add([ 'tableName' => 'users', - 'recordId' =>$user['user_id'], + 'recordId' => $user['user_id'], 'eventType' => 'GROUP DELETED', - 'eventId' => 'groupdeleted', - 'info' =>$_SESSION['user']['UserId'].' '._REMOVED_USER.' '.$user['user_id'].' '._FROM_GROUP.' '.$groupInfos['group_desc'] + 'eventId' => 'groupdeleted', + 'info' => $_SESSION['user']['UserId'].' '._REMOVED_USER.' '.$user['user_id'].' '._FROM_GROUP.' '.$groupInfos['group_desc'], ]); return true; @@ -659,23 +657,23 @@ class UserModelAbstract $user = UserModel::getById(['id' => $aArgs['id'], 'select' => ['user_id']]); DatabaseModel::insert([ - 'table' => 'users_entities', + 'table' => 'users_entities', 'columnsValues' => [ - 'user_id' => $user['user_id'], - 'entity_id' => $aArgs['entityId'], - 'user_role' => $aArgs['role'], - 'primary_entity' => $aArgs['primaryEntity'] - ] + 'user_id' => $user['user_id'], + 'entity_id' => $aArgs['entityId'], + 'user_role' => $aArgs['role'], + 'primary_entity' => $aArgs['primaryEntity'], + ], ]); $entityInfos = EntityModel::getByID(['entityId' => $aArgs['entityId']]); HistoryController::add([ 'tableName' => 'users', - 'recordId' => $user['user_id'], + 'recordId' => $user['user_id'], 'eventType' => 'ENTITY ADD', - 'eventId' => 'entityadded', - 'info' => $_SESSION['user']['UserId'].' '._ADDED_USER.' '.$user['user_id'].' '._IN_ENTITY.' '.$entityInfos['entity_label'] + 'eventId' => 'entityadded', + 'info' => $_SESSION['user']['UserId'].' '._ADDED_USER.' '.$user['user_id'].' '._IN_ENTITY.' '.$entityInfos['entity_label'], ]); return true; @@ -689,12 +687,12 @@ class UserModelAbstract $user = UserModel::getById(['id' => $aArgs['id'], 'select' => ['user_id']]); DatabaseModel::update([ - 'table' => 'users_entities', - 'set' => [ - 'user_role' => $aArgs['role'] + 'table' => 'users_entities', + 'set' => [ + 'user_role' => $aArgs['role'], ], - 'where' => ['user_id = ?', 'entity_id = ?'], - 'data' => [$user['user_id'], $aArgs['entityId']] + 'where' => ['user_id = ?', 'entity_id = ?'], + 'data' => [$user['user_id'], $aArgs['entityId']], ]); return true; @@ -711,23 +709,23 @@ class UserModelAbstract foreach ($entities as $entity) { if ($entity['primary_entity'] == 'Y') { DatabaseModel::update([ - 'table' => 'users_entities', - 'set' => [ - 'primary_entity' => 'N' + 'table' => 'users_entities', + 'set' => [ + 'primary_entity' => 'N', ], - 'where' => ['user_id = ?', 'entity_id = ?'], - 'data' => [$user['user_id'], $entity['entity_id']] + 'where' => ['user_id = ?', 'entity_id = ?'], + 'data' => [$user['user_id'], $entity['entity_id']], ]); } } DatabaseModel::update([ - 'table' => 'users_entities', - 'set' => [ - 'primary_entity' => 'Y' + 'table' => 'users_entities', + 'set' => [ + 'primary_entity' => 'Y', ], - 'where' => ['user_id = ?', 'entity_id = ?'], - 'data' => [$user['user_id'], $aArgs['entityId']] + 'where' => ['user_id = ?', 'entity_id = ?'], + 'data' => [$user['user_id'], $aArgs['entityId']], ]); return true; @@ -741,12 +739,12 @@ class UserModelAbstract $entities = EntityModel::getByUserId(['userId' => $aArgs['userId']]); if (!empty($entities[0])) { DatabaseModel::update([ - 'table' => 'users_entities', - 'set' => [ - 'primary_entity' => 'Y' + 'table' => 'users_entities', + 'set' => [ + 'primary_entity' => 'Y', ], - 'where' => ['user_id = ?', 'entity_id = ?'], - 'data' => [$aArgs['userId'], $entities[0]['entity_id']] + 'where' => ['user_id = ?', 'entity_id = ?'], + 'data' => [$aArgs['userId'], $entities[0]['entity_id']], ]); } @@ -761,19 +759,19 @@ class UserModelAbstract $user = UserModel::getById(['id' => $aArgs['id'], 'select' => ['user_id']]); DatabaseModel::delete([ - 'table' => 'users_entities', - 'where' => ['entity_id = ?', 'user_id = ?'], - 'data' => [$aArgs['entityId'], $user['user_id']] + 'table' => 'users_entities', + 'where' => ['entity_id = ?', 'user_id = ?'], + 'data' => [$aArgs['entityId'], $user['user_id']], ]); - $entityInfos=EntityModel::getByID(['entityId' => $aArgs['entityId']]); + $entityInfos = EntityModel::getByID(['entityId' => $aArgs['entityId']]); HistoryController::add([ 'tableName' => 'users', - 'recordId' =>$user['user_id'], + 'recordId' => $user['user_id'], 'eventType' => 'ENTITY DELETE', - 'eventId' => 'entitydeleted', - 'info' =>$_SESSION['user']['UserId'].' '._REMOVED_USER.' '.$user['user_id'].' '._FROM_ENTITY.' '.$entityInfos['entity_label'] + 'eventId' => 'entitydeleted', + 'info' => $_SESSION['user']['UserId'].' '._REMOVED_USER.' '.$user['user_id'].' '._FROM_ENTITY.' '.$entityInfos['entity_label'], ]); return true; @@ -786,32 +784,32 @@ class UserModelAbstract ValidatorModel::stringType($aArgs, ['groupId', 'basketId', 'color']); $isPresent = DatabaseModel::select([ - 'select' => ['1'], - 'table' => ['users_baskets'], - 'where' => ['user_serial_id = ?', 'group_id = ?', 'basket_id = ?'], - 'data' => [$aArgs['id'], $aArgs['groupId'], $aArgs['basketId']] + 'select' => ['1'], + 'table' => ['users_baskets'], + 'where' => ['user_serial_id = ?', 'group_id = ?', 'basket_id = ?'], + 'data' => [$aArgs['id'], $aArgs['groupId'], $aArgs['basketId']], ]); if (empty($isPresent)) { DatabaseModel::insert( [ - 'table' => 'users_baskets', + 'table' => 'users_baskets', 'columnsValues' => [ - 'user_serial_id' => $aArgs['id'], - 'basket_id' => $aArgs['basketId'], - 'group_id' => $aArgs['groupId'], - 'color' => $aArgs['color'] - ] + 'user_serial_id' => $aArgs['id'], + 'basket_id' => $aArgs['basketId'], + 'group_id' => $aArgs['groupId'], + 'color' => $aArgs['color'], + ], ] ); } else { DatabaseModel::update([ - 'table' => 'users_baskets', - 'set' => [ - 'color' => $aArgs['color'] + 'table' => 'users_baskets', + 'set' => [ + 'color' => $aArgs['color'], ], - 'where' => ['user_serial_id = ?', 'group_id = ?', 'basket_id = ?'], - 'data' => [$aArgs['id'], $aArgs['groupId'], $aArgs['basketId']] + 'where' => ['user_serial_id = ?', 'group_id = ?', 'basket_id = ?'], + 'data' => [$aArgs['id'], $aArgs['groupId'], $aArgs['basketId']], ]); } @@ -828,12 +826,10 @@ class UserModelAbstract [ 'table' => 'users_baskets', 'where' => ['user_serial_id = ?', 'group_id = ?', 'basket_id = ?'], - 'data' => [$aArgs['id'], $aArgs['groupId'], $aArgs['basketId']] + 'data' => [$aArgs['id'], $aArgs['groupId'], $aArgs['basketId']], ] ); return true; } - - }