Browse Source

creat new component

amr 6 years ago
parent
commit
22051ffd02

+ 3 - 0
src/app/dashboard/adminstration-contact-officers/adminstration-contact-officers-list/adminstration-contact-officers-list.component.css

@@ -0,0 +1,3 @@
+.flex{
+    display: flex
+}

+ 71 - 0
src/app/dashboard/adminstration-contact-officers/adminstration-contact-officers-list/adminstration-contact-officers-list.component.html

@@ -0,0 +1,71 @@
+<div class="container">
+
+  <div class="row">
+    <div class="col-12">
+      <ul class="list-unstyled titileLi-w">
+        <li class="headingText-w">خدمه البلاغات  </li>
+        <li class="headingText-w activeLi-w" style="margin-right:5px">ادارة ضباط الاتصال</li>
+      </ul>
+    </div>
+  </div>
+
+  <div class="containerContent-w">
+   <table class="table table-bordered " *ngIf="this.count != 0">
+      <thead class="headBackground-w">
+          <tr>
+           
+            <th style=" width: 18%;">ضباط الاتصال الحاليين</th>
+  
+          </tr>
+        </thead>
+      <tbody>
+          <tr>
+            <th scope="row"></th>
+            <td class="flex" style=" margin-right: 10px;">الموظفين</td>
+          </tr>
+      </tbody>
+      <tbody  >
+          <tr *ngFor="let admin of currentadmins">
+            <th scope="row"></th>
+              <td class="flex"  style=" margin-right: 10px;">{{admin.name}}</td>
+          </tr>
+         
+      </tbody>
+
+   </table>
+   <table class="table table-bordered " >
+           <thead class="headBackground-w">
+               <tr>
+                
+                 <th style=" width: 18%;"> ضباط الاتصال اتصال</th>
+       
+               </tr>
+             </thead>
+           <tbody>
+               <tr>
+                <th scope="row"  >
+                  <div class="custom-control custom-checkbox" style=" display: flex;justify-content: center;">
+                    <input type="checkbox" class="custom-control-input" [(ngModel)]="selectedAll" (change)="selectAll();" id="customCheck" name="example1">
+                  </div>
+                 </th>
+                 <td class="flex" style="  margin-right: 10px;">الموظفين</td>
+               </tr>
+           </tbody>
+           <tbody  >
+               <tr  *ngFor="let emplyee of emplyees | paginate: { itemsPerPage: perPagePagenation, currentPage: currentPage, totalItems: count }; let i = index">
+                 <th scope="row">
+                  <div class="custom-control custom-checkbox centerIneerItem"  style=" display: flex;justify-content: center;">
+                    <input type="checkbox" class="custom-control-input" id="{{emplyee.id}}" [(ngModel)]="emplyee.selected" [value]='emplyee' (change)="checkIfAllSelected();">
+                  </div>
+                 </th>
+                 <td class="flex" style="  margin-right: 10px;">{{emplyee.name}}</td>
+               </tr>
+           </tbody>
+        </table>   
+        <button type="submit" class="btn btn-success pull-left" style="    width: 124px;text-align: -webkit-auto;" (click)="onSubmit()" [disabled]="checkSaveDisabled" >  <i class='fas fa-save' style='font-size:24px'></i> <span style="font-weight: bolder;
+          font-size: 20px;padding: 20px;">حـــفظ </span></button>
+    </div>
+    
+  </div>
+
+  

+ 204 - 0
src/app/dashboard/adminstration-contact-officers/adminstration-contact-officers-list/adminstration-contact-officers-list.component.ts

@@ -0,0 +1,204 @@
+import { AuthServiceService } from './../../../shared/auth-service.service';
+import { NgxSpinnerService } from 'ngx-spinner';
+import { ActivatedRoute, Router, Params } from '@angular/router';
+import { DashboardService } from './../../../shared/dashboard.service';
+import { HttpClient } from '@angular/common/http';
+import { Component, OnInit } from '@angular/core';
+import { Modal } from 'ngx-modialog/plugins/bootstrap';
+import { UserService } from '../../../shared/user.service';
+import { ToastrService } from 'ngx-toastr';
+
+@Component({
+  selector: 'app-adminstration-contact-officers-list',
+  templateUrl: './adminstration-contact-officers-list.component.html',
+  styleUrls: ['./adminstration-contact-officers-list.component.css']
+})
+export class AdminstrationContactOfficersListComponent implements OnInit {
+
+  constructor(private http: HttpClient,
+    private route: ActivatedRoute,
+    private router: Router,
+    private modal: Modal,
+    private userSer: UserService,
+    private spinner: NgxSpinnerService,
+    private authSer: AuthServiceService,
+    private toastr: ToastrService,
+    private dashboardSer: DashboardService) { }
+
+    currentadmins = [];
+    emplyees =[];
+    pages= [];
+    pageId: number;
+    Ids = [];
+    count: number;
+    perPagePagenation: number;
+    currentPage:number = 1;
+    filtterStatus = 'all';
+    selectedAll: any;
+    userLoginId:number;
+    serviceId:number;
+    dataTableNumber: number = 5;
+    absorpationListIds = [];
+    dataListIds = [];
+    onSaving: boolean = false;
+    selected: boolean = false;
+    checkSaveDisabled:boolean = false;
+
+  ngOnInit() {
+
+    this.route.params.subscribe(
+      (params) =>{
+      this.pageId = params['adminId'];
+      localStorage.setItem('pageIdActive', params['adminId']);
+
+      if(this.pageId == 54){
+        this.http.get(this.authSer.pathApi + '/current_employees_officer_for_adminstration').subscribe(
+ 
+      (response) => {
+       console.log('xx', response);
+       this.currentadmins = response['officers'];
+      },
+      (error) => {
+       console.log(error);
+      
+      }
+      
+      );
+      this.http.get(this.authSer.pathApi+ '/get_adminstration_employees').subscribe(
+       (response) => {
+         console.log(response);
+         this.emplyees = response['users'];
+         for (let i = 0; i< this.currentadmins.length; i++) {
+          for(let j = 0; j < this.emplyees.length; j++)
+          {
+            if(this.currentadmins[i].id == this.emplyees[j].id){
+              this.emplyees[i].selected = true;
+             
+            }
+          }
+         }
+       },
+       (error) => {
+         console.log(error);
+       }
+      );
+
+
+     }
+    else if(this.pageId == 57){
+      
+       this.http.get(this.authSer.pathApi + '/current_employees_officer_for_department').subscribe(
+    
+         (response) => {
+          console.log('xx', response);
+          this.currentadmins = response['officers'];
+         },
+         (error) => {
+          console.log(error);
+         
+         }
+         
+         );
+         this.http.get(this.authSer.pathApi+ '/get_department_employees').subscribe(
+          (response) => {
+            console.log(response);
+            this.emplyees = response['users'];
+            for (let i = 0; i< this.currentadmins.length; i++) {
+              for(let j = 0; j < this.emplyees.length; j++)
+              {
+                if(this.currentadmins[i].id == this.emplyees[j].id){
+                  this.emplyees[i].selected = true;
+                 
+                }
+              }
+             }
+          },
+          (error) => {
+            console.log(error);
+          }
+         );
+        
+
+        }
+      }
+    );
+     
+  }
+
+//make all checkbox of user checked 
+selectAll() {
+  for (var i = 0; i < this.emplyees.length; i++) {
+    this.emplyees[i].selected = this.selectedAll;
+    }
+  }
+
+  checkIfAllSelected() {
+    this.selectedAll = this.emplyees.every(function(item:any) {
+        return item.selected == true;
+      })
+  }
+  
+  onSubmit(){
+    const employeesIds = [];
+    this.checkSaveDisabled = true;
+
+
+    for(let i = 0 ; i < this.emplyees.length; i++) {
+      if(this.emplyees[i].selected == true) {
+        employeesIds.push(this.emplyees[i].id);
+      };
+    }
+        if(employeesIds.length == 0){
+          this.toastr.success('تم نعين ضباط الاتصال');
+          this.checkSaveDisabled = false;
+        }else{
+         if(this.pageId == 54){
+          this.http.post(this.authSer.pathApi + '/asign_adminstration_employees_to_contact_officers', {'officers' : employeesIds}).subscribe(
+            (response) => {
+              this.currentadmins = [];
+              for(let i = 0 ; i < this.emplyees.length; i++) {  
+                if(this.emplyees[i].selected == true) {
+                    this.currentadmins.push(this.emplyees[i]);
+                   };  
+              }
+              this.toastr.success('تم نعين ضباط الاتصال');
+              console.log(response);
+              for(let i = 0; i < this.emplyees.length; i++){
+                this.emplyees[i].selected == false;
+              }
+            },
+            (error) => {
+              this.toastr.error('حدث خطئ في التعين يرجا المحاوله لاحقاً')
+              console.log(error);
+            }
+          );
+        }
+         else  if(this.pageId == 57){
+          this.http.post(this.authSer.pathApi + '/asign_department_employees_to_contact_officers',{'officers' : employeesIds} ).subscribe(
+            (response) => {
+              this.currentadmins = [];
+              for(let i = 0 ; i < this.emplyees.length; i++) {  
+                if(this.emplyees[i].selected == true) {
+                    this.currentadmins.push(this.emplyees[i]);
+                   };  
+              }
+              this.toastr.success('تم نعين ضباط الاتصال');
+              console.log(response);
+              
+            },
+            (error) => {
+              this.toastr.error('حدث خطئ في التعين يرجا المحاوله لاحقاً')
+              console.log(error);
+            }
+          );
+        }
+          this.checkSaveDisabled = false;
+        }
+       
+     
+   
+
+  
+
+  }
+}

+ 3 - 0
src/app/dashboard/dashboard-routing.ts

@@ -90,6 +90,7 @@ import { VehicleMovementReportComponent } from './vehicle-movement-report/vehicl
 import { DefinitionListComponent } from './definition-of-classification/definition-list/definition-list.component';
 import { DefinitionTimeListComponent } from './definition-of-time/definition-time-list/definition-time-list.component';
 import { DefinitionTimeAddComponent } from './definition-of-time/definition-time-add/definition-time-add.component';
+import { AdminstrationContactOfficersListComponent } from './adminstration-contact-officers/adminstration-contact-officers-list/adminstration-contact-officers-list.component';
 
 const dashboardRouting: Routes = [
     {path: 'service/:userID/:serviceID', component: ServiceItemComponent, canActivate: [AuthGuard], children: [
@@ -215,6 +216,8 @@ const dashboardRouting: Routes = [
     {path: 'definitionTimeList/:timeListPageId', component: DefinitionTimeListComponent, canActivate: [AuthGuard]},
     {path: 'definitionTime/add', component: DefinitionTimeAddComponent, canActivate: [AuthGuard]},
     {path: 'definitionTime/edit/:timeEditPageId', component: DefinitionTimeAddComponent, canActivate: [AuthGuard]},
+    {path: 'adminstrationContactOfficers/:adminId', component: AdminstrationContactOfficersListComponent , canActivate: [AuthGuard]},
+    {path: 'departmentContactOfficers/:adminId', component: AdminstrationContactOfficersListComponent , canActivate: [AuthGuard]},
     
 
 

+ 2 - 0
src/app/dashboard/dashboard.module.ts

@@ -134,6 +134,7 @@ import { LocationListComponent } from './definition-of-location/location-list/lo
 import { LocationAddComponent } from './definition-of-location/location-add/location-add.component';
 import { DefinitionTimeListComponent } from './definition-of-time/definition-time-list/definition-time-list.component';
 import { DefinitionTimeAddComponent } from './definition-of-time/definition-time-add/definition-time-add.component';
+import { AdminstrationContactOfficersListComponent } from './adminstration-contact-officers/adminstration-contact-officers-list/adminstration-contact-officers-list.component';
 
 
 @NgModule({
@@ -234,6 +235,7 @@ import { DefinitionTimeAddComponent } from './definition-of-time/definition-time
         LocationAddComponent,
         DefinitionTimeListComponent,
         DefinitionTimeAddComponent,
+        AdminstrationContactOfficersListComponent,
     ],
     imports: [
         CommonModule,

+ 0 - 2
src/app/dashboard/definition-of-time/definition-time-list/definition-time-list.component.ts

@@ -220,8 +220,6 @@ onDelete() {
       this.dataListIds.push(this.dataList[i].id);
     }
   }
-
-
   console.log(this.dataListIds);
 
   if(this.dataListIds.length > 0) {

+ 4 - 0
src/app/dashboard/service-item/service-item.component.ts

@@ -433,6 +433,10 @@ export class ServiceItemComponent implements OnInit {
       this.router.navigate(['definitionLocationList/' + dataPage.id], {relativeTo: this.route});
     }else if(dataPage.id == 53) {
       this.router.navigate(['definitionTimeList/' + dataPage.id], {relativeTo: this.route});
+    }else if(dataPage.id == 54) {
+      this.router.navigate(['adminstrationContactOfficers/' + dataPage.id], {relativeTo: this.route});
+    }else if(dataPage.id == 57) {
+      this.router.navigate(['departmentContactOfficers/' + dataPage.id], {relativeTo: this.route});
     }
     
   }

+ 4 - 0
src/app/servicesItems/services.component.ts

@@ -241,6 +241,10 @@ getDataService(dataService){
             this.router.navigate(['/service/' + this.idUser + '/' + dataService.id + '/definitionLocationList/' + this.pages[0].id]);
           }else  if(this.pages[0].id == 53) {
             this.router.navigate(['/service/' + this.idUser + '/' + dataService.id + '/definitionTimeList/' + this.pages[0].id]);
+          }else  if(this.pages[0].id == 54) {
+            this.router.navigate(['/service/' + this.idUser + '/' + dataService.id + '/adminstrationContactOfficers/' + this.pages[0].id]);
+          }else  if(this.pages[0].id == 57) {
+            this.router.navigate(['/service/' + this.idUser + '/' + dataService.id + '/departmentContactOfficers/' + this.pages[0].id]);
           }
         },
         (error) => {