Hima 5 years ago
parent
commit
a62d1357fe

+ 2 - 0
src/app/auth-services/regester/regester.component.css

@@ -182,6 +182,8 @@ select.ng-invalid{
     border-radius: 3px;
 }
 
+
+
 /* start media query style */
 
 @media(max-width: 767px){

+ 51 - 27
src/app/auth-services/regester/regester.component.html

@@ -94,18 +94,30 @@
 						</div>
 							 <div class="col-12 col-sm-12 col-md-6 col-lg-4">
               <div class="form-group">
-                <label for="birthday" style="float:right">تاريخ الميلاد <span class="spanReqired-w">*</span></label>
+                <label for="birthday" style="float:right">تاريخ الميلاد <span class="spanReqired-w">*</span></label><br>
+                <div class="wrapping-date-div">
+                  <select class="width_100" [(ngModel)]="birthDate.year" [ngModelOptions]="{standalone: true}">
+                    <option *ngFor="let year of higriYears" value="{{year}}">{{year}}</option>
+                  </select>
+                  <select class="width_100" [(ngModel)]="birthDate.month" [ngModelOptions]="{standalone: true}">
+                    <option *ngFor="let month of higriMonth" [value]="month.value">{{month.name}}</option>
+                  </select>
+                  <select class="width_100" [(ngModel)]="birthDate.day" [ngModelOptions]="{standalone: true}">
+                    <option *ngFor="let day of days" [value]="day">{{day}}</option>
+                  </select>
+                </div>
+                
                 <!-- <input type="date" max="{{min}}" id="birthdate" placeholder="تاريخ الميلاد" class="form-control" formControlName="birthday" />  -->
                 <!-- <app-end-higri-date *ngIf="higri_birth_date && typeMode"  (onDatePicked)="getDate($event, 'higri_birthDate')" [myEndDate]="higri_birth_date" [higriDisabled]="disabledVal"> </app-end-higri-date>
                 <app-end-higri-date *ngIf="!typeMode"  (onDatePicked)="getDate($event, 'higri_birthDate')"> </app-end-higri-date> -->
-                <input class="form-control"  
+                <!-- <input class="form-control"  
                 placeholder="yyyy-mm-dd"
                 formControlName="birthday" 
                 ngbDatepicker #d="ngbDatepicker" />
                         
                 <div class="input-group-append">
                     <button class="btn calendar higriButton" (click)="d.toggle()" type="button"><i class="fas fa-calendar-minus"></i></button>
-                </div>
+                </div> -->
               </div>
             </div>
 						 <div class="col-12 col-sm-12 col-md-6 col-lg-4">
@@ -148,33 +160,11 @@
             </div>
 
             <div class="col-12 col-sm-12 col-md-6 col-lg-4">
-                <div class="form-group">
-                  <label for="position" style="float:right">المنصب <span class="spanReqired-w">*</span></label>
-                  <input type="text" id="position" class="form-control" placeholder="المنصب" formControlName="position" />
-                </div>
-              </div>
-            
-						<div class="col-12 col-sm-12 col-md-6 col-lg-4">
-              <div class="form-group">
-                <label for="date_employment" style="float:right">تاريخ التوظيف الميلادي <span class="spanReqired-w">*</span></label>
-                <input type="date" class="form-control" id="date_employment" formControlName="date_of_employment_gre" />
-              </div>
-            </div>
-
-            <div class="col-12 col-sm-12 col-md-4 col-lg-4">
               <div class="form-group">
-                <label for="date_employment_hij" style="float:right">تاريخ التوظيف الهجري <span class="spanReqired-w">*</span></label>
-                <input class="form-control"  
-                  placeholder="yyyy-mm-dd"
-                  formControlName="date_of_employment_hij" 
-                  ngbDatepicker #d="ngbDatepicker" />
-                          
-              <div class="input-group-append">
-                  <button class="btn calendar higriButton" (click)="d.toggle()" type="button"><i class="fas fa-calendar-minus"></i></button>
-              </div>
+                <label for="position" style="float:right">المنصب <span class="spanReqired-w">*</span></label>
+                <input type="text" id="position" class="form-control" placeholder="المنصب" formControlName="position" />
               </div>
             </div>
-
             
             <div class="col-12 col-sm-12 col-md-6 col-lg-4">
               <div class="form-group">
@@ -230,6 +220,40 @@
                 </select>
               </div>
             </div>
+
+            <div class="col-12 col-sm-12 col-md-6 col-lg-4">
+                <div class="form-group">
+                  <label for="date_employment" style="float:right">تاريخ التوظيف الميلادي <span class="spanReqired-w">*</span></label>
+                  <input type="date" class="form-control" id="date_employment" formControlName="date_of_employment_gre" #gerDate (change)="changeEployeeGre()" />
+                </div>
+              </div>
+  
+              <div class="col-12 col-sm-12 col-md-4 col-lg-4">
+                <div class="form-group">
+                  <label for="date_employment_hij" style="float:right">تاريخ التوظيف الهجري <span class="spanReqired-w">*</span></label>
+                  <br>
+                  <div class="wrapping-date-div">
+                    <select class="width_100" [(ngModel)]="griDate.year" [ngModelOptions]="{standalone: true}">
+                      <option *ngFor="let year of higriYears" [value]="year">{{year}}</option>
+                    </select>
+                    <select class="width_100" [(ngModel)]="griDate.month" [ngModelOptions]="{standalone: true}">
+                      <option *ngFor="let month of higriMonth" [value]="month.value">{{month.name}}</option>
+                    </select>
+                    <select class="width_100" [(ngModel)]="griDate.day" [ngModelOptions]="{standalone: true}">
+                      <option *ngFor="let day of days" [value]="day">{{day}}</option>
+                    </select>
+                  </div>
+                  
+                  <!-- <input class="form-control"  
+                    placeholder="yyyy-mm-dd"
+                    formControlName="date_of_employment_hij" 
+                    ngbDatepicker #d="ngbDatepicker" />
+                            
+                <div class="input-group-append">
+                    <button class="btn calendar higriButton" (click)="d.toggle()" type="button"><i class="fas fa-calendar-minus"></i></button>
+                </div> -->
+                </div>
+              </div>
             
 					 </fieldset>
 				

+ 109 - 19
src/app/auth-services/regester/regester.component.ts

@@ -1,3 +1,4 @@
+import { ViewChild, ElementRef } from '@angular/core';
 import { Modal } from 'ngx-modialog/plugins/bootstrap';
 import { Observable } from 'rxjs/Observable';
 import { AuthServiceService } from '../../shared/auth-service.service';
@@ -15,6 +16,8 @@ const WEEKDAYS = ['ن', 'ث', 'ر', 'خ', 'ج', 'س', 'ح'];
 const MONTHS = ['محرم', 'صفر', 'ربيع الأول', 'ربيع الآخر', 'جمادى الأولى', 'جمادى الآخرة', 'رجب', 'شعبان', 'رمضان', 'شوال',
   'ذو القعدة', 'ذو الحجة'];
 
+
+
   @Injectable()
   export class IslamicI18n extends NgbDatepickerI18n {
     getWeekdayShortName(weekday: number) {
@@ -96,6 +99,39 @@ export class RegesterComponent implements OnInit {
 
 
 
+  birthDate = {
+    year: '1410',
+    month: '1',
+    day: '1'
+  }
+
+  griDate: any = {
+    year: '1410',
+    month: '1',
+    day: '1'
+  }
+
+   higriYears:any = [];
+
+   higriMonth = [{name: 'محرم', value :"1"},
+    {name: 'صفر', value: '2'}, 
+    {name: 'ربيع الأول', value: '3'}, 
+    {name: 'ربيع الآخر', value: '4'}, 
+    {name: 'جمادى الأولى', value: '5'}, 
+    {name: 'جمادى الآخرة', value: '6'}, 
+    {name: 'رجب', value: '7'}, 
+    {name: 'شعبان', value: '8'}, 
+    {namee: 'رمضان', value: '9'}, 
+    {name: 'شوال', value: '10'},
+    {name: 'ذو القعدة', value: '11'}, 
+    {name: 'ذو الحجة', value: '12'}];
+
+   days: any = [];
+
+  @ViewChild('gerDate') gerDate: ElementRef;
+
+
+
   ngOnInit() {
     
     this.authSer.showSearchHeader = false;
@@ -107,6 +143,18 @@ export class RegesterComponent implements OnInit {
     
     this.typeTitle = 'تسجيل الدخول';
 
+    //days array
+    for(let i = 1; i <= 31; i++) {
+      this.days.push(i);
+    }
+
+    //higr years
+    for(let i = 1410; i < 1460; i++) {
+      this.higriYears.push(i);
+    }
+
+  
+
     this.route.params.subscribe(
       (params:Params) => {
         this.userProfileId = params['idProfile'];
@@ -131,12 +179,12 @@ export class RegesterComponent implements OnInit {
         password_confirmation: new FormControl(null, [Validators.required, Validators.minLength(6)]),
         phone: new FormControl(null, Validators.required),
         gender: new FormControl(null, Validators.required),
-        birthday: new FormControl(null, Validators.required),
+        //birthday: new FormControl(null, Validators.required),
         adminstration_id: new FormControl(null, Validators.required),
         department_id: new FormControl(null, Validators.required),
         nationality_id: new FormControl(null, Validators.required),
         date_of_employment_gre: new FormControl(null, Validators.required),
-        date_of_employment_hij: new FormControl(null,Validators.required),
+        //date_of_employment_hij: new FormControl(null,Validators.required),
         job_title_id: new FormControl(null),
         specialization_id: new FormControl(null),
         functional_number: new FormControl(null, Validators.required),
@@ -256,7 +304,7 @@ export class RegesterComponent implements OnInit {
               password: new FormControl(null, [Validators.required, Validators.minLength(6)]),
               password_confirmation: new FormControl(null, [Validators.required, Validators.minLength(6)]),
               gender: new FormControl(null, Validators.required),
-              birthday: new FormControl(null, Validators.required),
+              //birthday: new FormControl(null, Validators.required),
               nationality_id: new FormControl(null, Validators.required),
             });
 
@@ -267,7 +315,7 @@ export class RegesterComponent implements OnInit {
               identity_number: responce['user'].identity_number,
               email: responce['user'].email,
               gender: responce['user'].gender,
-              birthday: responce['user'].birthday,
+              //birthday: responce['user'].birthday,
               nationality_id: responce['user'].nationality_id,  
               phone: responce['user'].phone,         
             });
@@ -289,12 +337,12 @@ export class RegesterComponent implements OnInit {
               password_confirmation: new FormControl(null, [Validators.minLength(6)]),
               phone: new FormControl(null,Validators.required),
               gender: new FormControl(null, Validators.required),
-              birthday: new FormControl(null, Validators.required),
+              //birthday: new FormControl(null, Validators.required),
               adminstration_id: new FormControl(null, Validators.required),
               department_id: new FormControl(null, Validators.required),
               nationality_id: new FormControl(null, Validators.required),
               date_of_employment_gre: new FormControl(null, Validators.required),
-              date_of_employment_hij: new FormControl(null,Validators.required),
+              //date_of_employment_hij: new FormControl(null,Validators.required),
               job_title_id: new FormControl(null),
               specialization_id: new FormControl(null),
               functional_number: new FormControl(null, Validators.required),
@@ -320,7 +368,7 @@ export class RegesterComponent implements OnInit {
               position: responce['user'].position,
               phone: responce['user'].phone,
               gender: responce['user'].gender,
-              birthday: responce['user'].birthday,
+              //birthday: responce['user'].birthday,
               adminstration_id: responce['user'].adminstration_id,
               department_id: responce['user'].department_id,
               nationality_id: responce['user'].nationality_id,
@@ -331,7 +379,7 @@ export class RegesterComponent implements OnInit {
               staff_id: responce['user'].staff_id,
               functional_number: responce['user'].functional_number,
               status: responce['user'].status,
-              date_of_employment_hij: this.bindingDateSplit, //responce['user'].date_of_employment_hij//
+              //date_of_employment_hij: this.bindingDateSplit, //responce['user'].date_of_employment_hij//
             });
             console.log(this.bindingDateSplit);
 
@@ -438,7 +486,7 @@ export class RegesterComponent implements OnInit {
             password: new FormControl(null, [Validators.required, Validators.minLength(6)]),
             password_confirmation: new FormControl(null, [Validators.required, Validators.minLength(6)]),
             gender: new FormControl(null, Validators.required),
-            birthday: new FormControl(null, Validators.required),
+            //birthday: new FormControl(null, Validators.required),
             nationality_id: new FormControl(null, Validators.required),
             phone: new FormControl(null, Validators.required),
           });
@@ -454,12 +502,12 @@ export class RegesterComponent implements OnInit {
             password_confirmation: new FormControl(null, [Validators.required, Validators.minLength(6)]),
             phone: new FormControl(null, Validators.required),
             gender: new FormControl(null, Validators.required),
-            birthday: new FormControl(null, Validators.required),
+            //birthday: new FormControl(null, Validators.required),
             adminstration_id: new FormControl(null, Validators.required),
             department_id: new FormControl(null, Validators.required),
             nationality_id: new FormControl(null, Validators.required),
             date_of_employment_gre: new FormControl(null, Validators.required),
-            date_of_employment_hij: new FormControl(null,Validators.required),
+            //date_of_employment_hij: new FormControl(null,Validators.required),
             job_title_id: new FormControl(null),
             specialization_id: new FormControl(null),
             functional_number: new FormControl(null, Validators.required),
@@ -469,9 +517,50 @@ export class RegesterComponent implements OnInit {
         } 
       }
 
-   
 
+      changeEployeeGre() {
+        console.log(this.gerDate.nativeElement.value);
+        const dateArray = this.gerDate.nativeElement.value.split('-');
+        console.log(dateArray); 
+        const dateValConvertingSpliting = this.authSer.writeHijri(new Date(this.gerDate.nativeElement.value), 'ar', 'system').split(' ');
+        
+        let dateValExisting: any = {
+          year : '',
+          month: '',
+          day: ''
+        };
+
+        if(dateValConvertingSpliting.length  == 5){
+          const year = this.authSer.parseArabic(dateValConvertingSpliting[3]);
+          const day = this.authSer.parseArabic(dateValConvertingSpliting[0]); 
+          dateValExisting.year = year;
+          dateValExisting.day = day;
+        } else {
+          const year = this.authSer.parseArabic(dateValConvertingSpliting[2]);
+          const day = this.authSer.parseArabic(dateValConvertingSpliting[0]); 
+          dateValExisting.year = year;
+          dateValExisting.day = day;
+        }
 
+        MONTHS.forEach((element, index) => {
+          if(dateValConvertingSpliting.length  == 5){
+            if(element == dateValConvertingSpliting[1] + ' ' + dateValConvertingSpliting[2]) {
+              dateValExisting.month = index + 1 
+            }
+          } else {
+            if(element == dateValConvertingSpliting[1]) {
+              dateValExisting.month = index + 1 
+            }
+          }
+         
+        });
+        console.log(dateValConvertingSpliting);
+        console.log(dateValExisting);
+        this.griDate.year = dateValExisting.year;
+        this.griDate.month = dateValExisting.month;
+        this.griDate.day = parseInt(dateValExisting.day);
+        console.log(this.griDate);
+      }
      
 
     //submitted form 
@@ -482,15 +571,15 @@ export class RegesterComponent implements OnInit {
       let joinJobDate;
 
       if(userDataRegester['type'] == '0') {
-        userDataRegester['date_of_employment_hij'] = userDataRegester['date_of_employment_hij'].year  + '-' + userDataRegester['date_of_employment_hij'].month + '-' + userDataRegester['date_of_employment_hij'].day;
-        joinJobDate = userDataRegester['date_of_employment_gre'].split('-')[0];
-        userDataRegester['birthday'] = userDataRegester['birthday'].year  + '-' + userDataRegester['birthday'].month + '-' + userDataRegester['birthday'].day;
+        userDataRegester['date_of_employment_hij'] = this.griDate.year  + '-' + this.griDate.month + '-' + this.griDate.day;
+        userDataRegester['birthday'] = this.birthDate.year  + '-' + this.birthDate.month + '-' + this.birthDate.day;
+      } else {
+        userDataRegester['birthday'] = this.birthDate.year  + '-' + this.birthDate.month + '-' + this.birthDate.day;
       }
 
       userDataRegester['identity_number'] = userDataRegester['identity_number'].toString();
       console.log('valueee' , userDataRegester);
 
-      const birthDate = userDataRegester['birthday'].split('-')[0];///to check if birthday > employment date
     
 
 
@@ -547,7 +636,7 @@ export class RegesterComponent implements OnInit {
             this.toastr.warning('رقم الهويه يجب ان يبدأ ب رقم 1');
           } else if(this.regesterForm.get('identity_number').value.substring(0,1) != 2 && this.regesterForm.get('identity_type_id').value == 3){
             this.toastr.warning('رقم الهويه يجب ان يبدأ ب رقم 2');
-          } else if(birthDate > joinJobDate) {
+          } else if(this.birthDate.year > this.griDate.year) {
             this.toastr.warning('تارخ الميلاد أكبر من تاريخ التوظيف الميلادي !');
           } else if(this.regesterForm.get('phone').value.substring(0,2) != '05') {
             this.toastr.warning('رقم الجوال يجب أن يبدأ ب 05');
@@ -611,7 +700,7 @@ export class RegesterComponent implements OnInit {
             this.toastr.warning('رقم الهويه يجب ان يبدأ ب رقم 1');
           } else if(userDataRegester['identity_number'].substring(0,1) != 2 && this.regesterForm.get('identity_type_id').value == 3){
             this.toastr.warning('رقم الهويه يجب ان يبدأ ب رقم 2');
-          } else if(birthDate > joinJobDate) {
+          } else if(this.birthDate.year > this.griDate.year) {
             this.toastr.warning('تارخ الميلاد أكبر من تاريخ التوظيف الميلادي !');
           } else if(this.regesterForm.get('phone').value.substring(0,2) != '05') {
             this.toastr.warning('رقم الجوال يجب أن يبدأ ب 05');
@@ -636,5 +725,6 @@ export class RegesterComponent implements OnInit {
         }  
       }      
   }
-       
+      
+  
 }

+ 1 - 1
src/app/dashboard/department/department-list/department-list.component.ts

@@ -233,7 +233,7 @@ export class DepartmentListComponent implements OnInit {
             (error) => {
               console.log(error);
               if(error['error'].error == 'can not remove adminstration') {
-                this.toastr.warning('لا يمكن مسح الادارات المحدده لإتصالها بالنظام');
+                this.toastr.warning('لا يمكن مسح الادارات المحدده لإرتباطهم بسجلات أخري');
               }
               this.spinner.hide();
             },

+ 0 - 2
src/app/dashboard/events/add-event/add-event.component.html

@@ -50,8 +50,6 @@
                     <option value="2">2</option>
                     <option value="3">3</option>
                     <option value="4">4</option>
-                    <option value="5">5</option>
-                    <option value="6">6</option>
                   </select>
                   <!-- <span *ngIf="!name.valid && name.touched"></span>  -->
                 </div>

+ 2 - 2
src/app/dashboard/lectures/add-lecture/add-lecture.component.html

@@ -43,7 +43,7 @@
               </div>
             </div>
 
-            <div class="col-12 col-sm-12 col-md-4">
+            <!-- <div class="col-12 col-sm-12 col-md-4">
               <div class="form-group">
                 <label for="display_location" style="float: right; margin-right: 5px"> الصفحه <span class="spanReqired-w">*</span></label>
                 <select class="form-control" name="display_location" [ngModel]="lecture.display_location" id="display_location" required>
@@ -52,7 +52,7 @@
                   <option value="both">كلاهما</option>
                 </select>
               </div>
-            </div>
+            </div> -->
 
             <div class="col-12 col-sm-12 col-md-4">
               <div class="form-group">

+ 1 - 1
src/app/dashboard/lectures/add-lecture/add-lecture.component.ts

@@ -89,7 +89,7 @@ export class AddLectureComponent implements OnInit {
   //submitted form
   onSubmitted() {
     console.log(this.lectureForm.value);
-    
+    this.lectureForm.value['display_location'] = 'internal';
     this.lectureForm.value['lecture_time'] = this.lectureForm.value['lecture_time'].split('T').join(" ");
     this.lectureForm.value['end_time'] = this.lectureForm.value['end_time'].split('T').join(" ");
     console.log(this.lectureForm.value['lecture_time']);

+ 1 - 1
src/app/dashboard/main-menu/main-list/main-list.component.ts

@@ -262,7 +262,7 @@ export class MainListComponent implements OnInit {
               (error) => {
                 console.log(error);
                 if(error['error'].error == 'menu already used'){
-                  this.toastr.warning('لايمكن مسح القوائم المحدده ، لربطها بالنظام !');
+                  this.toastr.warning('لايمكن مسح القوائم المحدده ، لإرتباطها بسجلات أخري !');
                 } else {
                   this.toastr.error('حدث خطأ رجاء الانتظار وحاول ثانيه');
                 }

+ 3 - 1
src/app/dashboard/roles/roles-list/roles-list.component.ts

@@ -234,6 +234,9 @@ export class RolesListComponent implements OnInit {
             },
             (error) => {
               console.log(error);
+              if(error['error'].error == 'roles already used') {
+                this.toastr.warning('لايمكن مسح المجموعات المحدده لإرتباطهم بسجلات أخري !');
+              }
               this.spinner.hide();
             },
           )
@@ -241,7 +244,6 @@ export class RolesListComponent implements OnInit {
       } else {
         this.toastr.warning('لم يتم إختيار أي عنصر للمسح !');
       }
-
   }
 
   //add roles

+ 1 - 1
src/app/dashboard/sections/section-list/section-list.component.ts

@@ -227,7 +227,7 @@ export class SectionListComponent implements OnInit {
             (error) => {
               console.log(error);
               if(error['error'].error == 'department already used') {
-                this.toastr.warning('لايمكن مسح الأقسام المحدده لربطها بالنظام !');
+                this.toastr.warning('لايمكن مسح الأقسام المحدده لإرتباطهابسجلات أخري !');
               }
               this.spinner.hide();
             },

+ 2 - 2
src/app/dashboard/statistics/add-statistic/add-statistic.component.html

@@ -51,7 +51,7 @@
                 <div class="form-group">
                   <label for="year" style="float: right; margin-right: 5px"> السنة<span class="spanReqired-w">*</span></label>
                   <select class="form-control" name="year" id="year" ngModel [ngModel]="statistic.year" required>
-                      <option *ngFor="let year of years; let i = index" [value]="year.id">{{year.value}}</option>
+                      <option *ngFor="let year of years; let i = index" [value]="year.value">{{year.value}}</option>
                     </select>
                 </div>
               </div>
@@ -66,7 +66,7 @@
               </div>
 
               <div class="col-6">
-                <button type="submit" class="btn btn-success rightW" [disabled]="!f.valid">حفظ</button>
+                <button type="submit" class="btn btn-success rightW" [disabled]="!f.valid || checkDisabledSave">حفظ</button>
                 <button type="button" class="btn btn-warning rightW" (click)="authSer.backFromEdit()">إلغاء</button>
               </div>
 

+ 1 - 1
src/app/dashboard/statistics/add-statistic/add-statistic.component.ts

@@ -69,7 +69,7 @@ export class AddStatisticComponent implements OnInit {
       this.route.params.subscribe(
         (params: Params) => {
           console.log(params)
-          if(params['typeStatistic'] == 'add'){
+          if(params['typeStatistic'] != 'edit'){
             this.typeMode = false;
             this.typeLink = 'إنشاء احصائية';
           } else if(params['typeStatistic'] == 'edit') {

+ 3 - 3
src/app/dashboard/statistics/statistics-list/statistics-list.component.html

@@ -58,7 +58,7 @@
           <th>إسم الإحصائية</th>
           <th>رقم الإجصائية</th>
           <th>الشهر</th>
-          <th>السنة</th>
+          <!-- <th>السنة</th> -->
           <th>الحالة</th>
           <th *ngIf="authSer.showEditBtn">تعديل</th>
         </tr>
@@ -78,9 +78,9 @@
           <td>
             {{statistic.month}}
           </td>
-          <td>
+          <!-- <td>
             {{statistic.year}}
-          </td>
+          </td> -->
           <td>{{statistic.status == '0' ? 'غير فعال' : statistic.status == '1' ? 'فعال' : 'No'}}</td>
           <td *ngIf="authSer.showEditBtn"><button type="button" class="btn btn-outline-secondary" (click)="onEdit(statistic.id)"><i class="fas fa-edit"></i></button></td>
         </tr>

+ 28 - 5
src/app/dashboard/users/form-user/form-user.component.html

@@ -126,27 +126,50 @@
               <div class="form-group">
                 <label for="birthday" style="float:right">تاريخ الميلاد <span class="spanReqired-w">*</span></label>
                 <!-- <input type="date" [max]="authSer.end" id="birthdate" class="form-control" formControlName="birthday" />  -->
-                <app-end-higri-date *ngIf="higri_birth_date && typeMode"  (onDatePicked)="getDate($event, 'higri_birthDate')" [myEndDate]="higri_birth_date" [higriDisabled]="disabledVal"> </app-end-higri-date>
-                <app-end-higri-date *ngIf="!typeMode"  (onDatePicked)="getDate($event, 'higri_birthDate')"> </app-end-higri-date>
+                <!-- <app-end-higri-date *ngIf="higri_birth_date && typeMode"  (onDatePicked)="getDate($event, 'higri_birthDate')" [myEndDate]="higri_birth_date" [higriDisabled]="disabledVal"> </app-end-higri-date>
+                <app-end-higri-date *ngIf="!typeMode"  (onDatePicked)="getDate($event, 'higri_birthDate')"> </app-end-higri-date> -->
+                <div class="wrapping-date-div">
+                  <select class="width_100" [(ngModel)]="birthDate.year" [ngModelOptions]="{standalone: true}">
+                    <option *ngFor="let year of higriYears" value="{{year}}">{{year}}</option>
+                  </select>
+                  <select class="width_100" [(ngModel)]="birthDate.month" [ngModelOptions]="{standalone: true}">
+                    <option *ngFor="let month of higriMonth" [value]="month.value">{{month.name}}</option>
+                  </select>
+                  <select class="width_100" [(ngModel)]="birthDate.day" [ngModelOptions]="{standalone: true}">
+                    <option *ngFor="let day of days" [value]="day">{{day}}</option>
+                  </select>
+                </div>
               </div>
             </div>
 
             <div class="col-12 col-sm-12 col-md-4 col-lg-4" *ngIf="signupForm.controls.type.value == '0' ">
               <div class="form-group">
                 <label for="date_employment" style="float:right">تاريخ التوظيف الميلادي <span class="spanReqired-w">*</span></label>
-                <input type="date" class="form-control"  id="date_employment" formControlName="date_of_employment_gre" />
+                <input type="date" class="form-control"  id="date_employment" formControlName="date_of_employment_gre" #gerDate (change)="changeEployeeGre()" />
               </div>
             </div>
 
             <div class="col-12 col-sm-12 col-md-4 col-lg-4" *ngIf="signupForm.controls.type.value == '0' ">
               <div class="form-group">
                 <label for="date_employment_hij" style="float:right" >تاريخ التوظيف الهجري <span class="spanReqired-w">*</span></label>
-                <div *ngIf='bindingDateSplit && typeMode'>
+                <br>
+                  <div class="wrapping-date-div">
+                    <select class="width_100" [(ngModel)]="griDate.year" [ngModelOptions]="{standalone: true}">
+                      <option *ngFor="let year of higriYears" [value]="year">{{year}}</option>
+                    </select>
+                    <select class="width_100" [(ngModel)]="griDate.month" [ngModelOptions]="{standalone: true}">
+                      <option *ngFor="let month of higriMonth" [value]="month.value">{{month.name}}</option>
+                    </select>
+                    <select class="width_100" [(ngModel)]="griDate.day" [ngModelOptions]="{standalone: true}">
+                      <option *ngFor="let day of days" [value]="day">{{day}}</option>
+                    </select>
+                  </div>
+                <!--<div *ngIf='bindingDateSplit && typeMode'>
                   <app-higri-date (onDatePicked)="getDate($event, 'higriEmployement')" [myDate]="bindingDateSplit"></app-higri-date>
                 </div>
                 <div *ngIf='!typeMode'>
                   <app-higri-date (onDatePicked)="getDate($event, 'higriEmployement')" ></app-higri-date>
-                </div>
+                </div> -->
               </div>
             </div>
             

+ 114 - 27
src/app/dashboard/users/form-user/form-user.component.ts

@@ -1,7 +1,7 @@
 import { AuthServiceService } from './../../../shared/auth-service.service';
 import { ActivatedRoute, Params } from '@angular/router';
 import { NgForm, FormGroup, FormControl, Validators } from '@angular/forms';
-import { Component, OnInit } from '@angular/core';
+import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
 import { UserService } from '../../../shared/user.service';
 import { Location } from '@angular/common';
 import { ToastrService } from 'ngx-toastr';
@@ -11,6 +11,14 @@ interface HTMLInputEvent extends Event {
   target: HTMLInputElement & EventTarget;
 }
 
+import {
+  NgbDate,NgbDateStruct, NgbCalendar, NgbCalendarIslamicUmalqura, NgbDatepickerI18n
+} from '@ng-bootstrap/ng-bootstrap';
+
+const WEEKDAYS = ['ن', 'ث', 'ر', 'خ', 'ج', 'س', 'ح'];
+const MONTHS = ['محرم', 'صفر', 'ربيع الأول', 'ربيع الآخر', 'جمادى الأولى', 'جمادى الآخرة', 'رجب', 'شعبان', 'رمضان', 'شوال',
+  'ذو القعدة', 'ذو الحجة'];
+
 @Component({
   selector: 'app-form-user',
   templateUrl: './form-user.component.html',
@@ -19,6 +27,7 @@ interface HTMLInputEvent extends Event {
 
 
 
+
 export class FormUserComponent implements OnInit {
 
   constructor(private userSer: UserService,
@@ -30,6 +39,9 @@ export class FormUserComponent implements OnInit {
         this.spineer.show();
        }
 
+
+
+
   files:any;
   adminstration = [];
   countries = [];
@@ -66,7 +78,39 @@ export class FormUserComponent implements OnInit {
   end:any;
   higri_birth_date;
 
+  @ViewChild('gerDate') gerDate: ElementRef;
+
+  birthDate: any = {
+    year: '1410',
+    month: '1',
+    day: '1'
+  }
+
+  griDate: any = {
+    year: '1410',
+    month: '1',
+    day: '1'
+  }
+
+   higriYears:any = [];
+
+   higriMonth = [{name: 'محرم', value :"1"},
+    {name: 'صفر', value: '2'}, 
+    {name: 'ربيع الأول', value: '3'}, 
+    {name: 'ربيع الآخر', value: '4'}, 
+    {name: 'جمادى الأولى', value: '5'}, 
+    {name: 'جمادى الآخرة', value: '6'}, 
+    {name: 'رجب', value: '7'}, 
+    {name: 'شعبان', value: '8'}, 
+    {namee: 'رمضان', value: '9'}, 
+    {name: 'شوال', value: '10'},
+    {name: 'ذو القعدة', value: '11'}, 
+    {name: 'ذو الحجة', value: '12'}];
+
+   days: any = [];
+
   ngOnInit() {
+
     this.spineer.show();
       //show / hide notification search in header
       this.authSer.notificationLogin = true;
@@ -83,7 +127,17 @@ export class FormUserComponent implements OnInit {
       
       //get profile data
       this.userSer.getUserDataProfile();
-  
+    
+      //days array
+      for(let i = 1; i <= 31; i++) {
+        this.days.push(i);
+      }
+
+      //higr years
+      for(let i = 1410; i < 1460; i++) {
+        this.higriYears.push(i);
+      }
+    
       //get adminstration
       this.userSer.getAdministration().subscribe(
         (responce) => {
@@ -232,21 +286,14 @@ export class FormUserComponent implements OnInit {
               console.log(this.urlImg);
               const date = responce['user'].date_of_employment_hij ? responce['user'].date_of_employment_hij.split('-') : '';
               const birthday_val = responce['user'].birthday ? responce['user'].birthday.split('-') : '';
-              this.bindingDateSplit = {
-                'year': parseInt(date[0]),
-                'month': parseInt(date[1]),
-                'day': parseInt(date[2])
-              };
-
-              this.higri_birth_date = {
-                'year': parseInt(birthday_val[0]),
-                'month': parseInt(birthday_val[1]),
-                'day': parseInt(birthday_val[2])
-              }
+              this.griDate.year = date[0];
+              this.griDate.month = date[1];
+              this.griDate.day = date[2];
               
-              this.higriDateVal = responce['user'].date_of_employment_hij;
-              console.log(this.bindingDateSplit);
-              console.log('birth day => ', this.higri_birth_date);
+              this.birthDate.year = birthday_val[0];
+              this.birthDate.month = birthday_val[1];
+              this.birthDate.day = birthday_val[2];
+                           
               
               this.getDepartment();
               this.spineer.hide();
@@ -391,6 +438,50 @@ export class FormUserComponent implements OnInit {
   };
 
 
+  changeEployeeGre() {
+    console.log(this.gerDate.nativeElement.value);
+    const dateArray = this.gerDate.nativeElement.value.split('-');
+    console.log(dateArray); 
+    const dateValConvertingSpliting = this.authSer.writeHijri(new Date(this.gerDate.nativeElement.value), 'ar', 'system').split(' ');
+    
+    let dateValExisting: any = {
+      year : '',
+      month: '',
+      day: ''
+    };
+
+    if(dateValConvertingSpliting.length  == 5){
+      const year = this.authSer.parseArabic(dateValConvertingSpliting[3]);
+      const day = this.authSer.parseArabic(dateValConvertingSpliting[0]); 
+      dateValExisting.year = year;
+      dateValExisting.day = day;
+    } else {
+      const year = this.authSer.parseArabic(dateValConvertingSpliting[2]);
+      const day = this.authSer.parseArabic(dateValConvertingSpliting[0]); 
+      dateValExisting.year = year;
+      dateValExisting.day = day;
+    }
+
+    MONTHS.forEach((element, index) => {
+      if(dateValConvertingSpliting.length  == 5){
+        if(element == dateValConvertingSpliting[1] + ' ' + dateValConvertingSpliting[2]) {
+          dateValExisting.month = index + 1 
+        }
+      } else {
+        if(element == dateValConvertingSpliting[1]) {
+          dateValExisting.month = index + 1 
+        }
+      }
+     
+    });
+    console.log(dateValConvertingSpliting);
+    console.log(dateValExisting);
+    this.griDate.year = dateValExisting.year;
+    this.griDate.month = dateValExisting.month;
+    this.griDate.day = parseInt(dateValExisting.day);
+    console.log(this.griDate);
+  }
+
 
 
 
@@ -399,14 +490,12 @@ export class FormUserComponent implements OnInit {
 
     this.checkSaveDisabled = true;
     const userData = this.signupForm.value;
-    let joinJopYear;
-    let birthDate;
+    
     if(userData['type'] == 0){
-      userData['date_of_employment_hij'] = this.higriDateVal;
-       birthDate = this.higri_birth_date;
-       userData['birthday'] = birthDate;
-       joinJopYear = userData['date_of_employment_gre'].split('-')[0];
-      console.log(joinJopYear);
+      userData['date_of_employment_hij'] = this.griDate.year + '-' + this.griDate.month + '-' + this.griDate.day;
+      userData['birthday'] = this.birthDate.year + '-' + this.birthDate.month + '-' + this.birthDate.day;
+    } else {
+      userData['birthday'] = this.birthDate.year + '-' + this.birthDate.month + '-' + this.birthDate.day;
     }
  
     if(this.checkChangeImage) {
@@ -424,8 +513,6 @@ export class FormUserComponent implements OnInit {
       } else if(userData['date_of_employment_hij'] == "") {
         this.toastr.warning('من فضلك ، أدخل تاريخ التوظيف الهجري !');
         this.checkSaveDisabled = false;
-     } else if(!birthDate){
-        this.toastr.warning('من فضلك أدخل تاريخ الميلاد !');
      } else if(this.signupForm.get('identity_number').value.substring(0,1) != 1 && this.signupForm.get('identity_type_id').value == 1){
         this.toastr.warning('رقم الهويه يجب ان يبدأ ب رقم 1');
         this.checkSaveDisabled = false;
@@ -435,7 +522,7 @@ export class FormUserComponent implements OnInit {
       } else if(this.signupForm.get('phone').value.substring(0,2) != '05') {
         this.toastr.warning('رقم الجوال يجب أن يبدأ ب 05');
         this.checkSaveDisabled = false;
-      } else if(birthDate > joinJopYear) {
+      } else if(this.birthDate.year > this.griDate.year) {
         this.toastr.warning('تاريخ التوظيف الميلادي أكبر من تاريخ الميلاد !');
         this.checkSaveDisabled = false;
       } 
@@ -472,7 +559,7 @@ export class FormUserComponent implements OnInit {
         }else if(this.signupForm.get('identity_number').value.substring(0,1) != 2 && this.signupForm.get('identity_type_id').value == 3){
           this.toastr.warning('رقم الهويه يجب ان يبدأ ب رقم 2');
           this.checkSaveDisabled = false;
-        } else if(birthDate > joinJopYear) {
+        } else if(this.birthDate.year > this.griDate.year) {
           this.toastr.warning('تاريخ التوظيف الميلادي أكبر من تاريخ الميلاد !');
           this.checkSaveDisabled = false;
         } else if(this.signupForm.get('phone').value.substring(0,2) != '05') {

+ 11 - 6
src/app/dashboard/users/user-report/user-report.component.html

@@ -16,17 +16,21 @@
                   </thead>
                   <tbody>
                     <tr *ngFor="let data of reportData; let i = index">
-                      <td><p>{{data['user']?.name? data['user'].name : ''}}</p></td>
+                      <td><p>{{data['user']?.name? data['user'].name : '-'}}</p></td>
                       <td><p *ngFor="let role of data['roles']">{{role.role_name ? role.role_name : ''}}</p></td>
-                      <td><p *ngFor="let role of data['roles']">
+                      <td *ngIf="data['roles'].length > 0"><p *ngFor="let role of data['roles']">
                         <span style="display:block; margin: 10px 0;" *ngFor="let page of role['pages']">
                           {{page.name ? page.name : ''}}
                           <span style="display:block" *ngFor="let p of page.permissions"><br></span>
                         </span>
                       </p></td>
-                      <td><p *ngFor="let role of data['roles'][i].pages"><span style="display: block; margin-bottom: 6px;" *ngFor="let page of role['permissions']">{{page.permission_name ? page.permission_name : ''}}</span></p></td>
-                      <td><p *ngFor="let role of data['roles'][i].pages"><span style="display: block; margin-bottom: 6px;" *ngFor="let page of role['permissions']">{{page.asigned_by ? page.asigned_by : ''}}</span></p></td>
-                      <td><p *ngFor="let role of data['roles'][i].pages"><span style="display: block; margin-bottom: 6px; font-size:14px" *ngFor="let page of role['permissions']">{{page.created_at ? page.created_at : ''}}</span></p></td>
+                      <td *ngIf="data['roles'].length == 0">-</td>
+                      <td *ngIf="data['roles'].length > 0"><p *ngFor="let role of data['roles'][i].pages"><span style="display: block; margin-bottom: 6px;" *ngFor="let page of role['permissions']">{{page.permission_name ? page.permission_name : ''}}</span></p></td>
+                      <td *ngIf="data['roles'].length > 0"><p *ngFor="let role of data['roles'][i].pages"><span style="display: block; margin-bottom: 6px;" *ngFor="let page of role['permissions']">{{page.asigned_by ? page.asigned_by : ''}}</span></p></td>
+                      <td *ngIf="data['roles'].length > 0"><p *ngFor="let role of data['roles'][i].pages"><span style="display: block; margin-bottom: 6px; font-size:14px" *ngFor="let page of role['permissions']">{{page.created_at ? page.created_at : ''}}</span></p></td>
+                      <td *ngIf="data['roles'].length == 0">-</td>
+                      <td *ngIf="data['roles'].length == 0">-</td>
+                      <td *ngIf="data['roles'].length == 0">-</td>
                     </tr>
                   </tbody>
                 </table>
@@ -36,4 +40,5 @@
 
       </div>
   </div>
-</div>
+</div>
+

+ 1 - 1
src/app/dashboard/users/user-report/user-report.component.ts

@@ -72,7 +72,7 @@ export class UserReportComponent implements OnInit, OnDestroy {
       (responce) => {
         console.log(responce);
         this.reportData.push(responce['data']);
-        console.log(this.reportData);
+        console.log('report data => ', this.reportData);
         this.spinner.hide();
       },
       (error) => {

+ 1 - 1
src/app/dashboard/users/users.component.ts

@@ -314,7 +314,7 @@ export class UsersComponent implements OnInit {
             (error) => {
               console.log(error);
               if(error['error'].error == 'user already used') {
-                this.toastr.warning('لايمكن مسح المستخدمين المحددين لإرتباطهم بالنظام !');
+                this.toastr.warning('لايمكن مسح المستخدمين المحددين بسجلات أخري !');
               }
             },
           )

+ 1 - 3
src/app/higri-date/higri-date.component.ts

@@ -1,4 +1,4 @@
-import { Component, Injectable, OnInit, EventEmitter, Output, Input } from '@angular/core';
+import { Component, Injectable, OnInit, EventEmitter, Output, Input, ViewChild } from '@angular/core';
 
 import {
   NgbDate,NgbDateStruct, NgbCalendar, NgbCalendarIslamicUmalqura, NgbDatepickerI18n
@@ -42,7 +42,6 @@ export class HigriDateComponent implements OnInit {
   @Output() onDatePicked: EventEmitter<NgbDate> = new EventEmitter<NgbDate>();
   @Input() myDate;
   @Input() higriDisabled;
-
   model: NgbDateStruct;
 
 
@@ -64,7 +63,6 @@ export class HigriDateComponent implements OnInit {
  
  
   onGetDateVal(event) {
-    alert('hello');
     console.log(event);
   }
 

+ 9 - 0
src/app/shared/auth-service.service.ts

@@ -230,5 +230,14 @@ export class AuthServiceService {
     }
   }
 
+  //convert arabic number to english number 
+   parseArabic(str) {
+    return Number( str.replace(/[٠١٢٣٤٥٦٧٨٩]/g, function(d) {
+        return d.charCodeAt(0) - 1632; // Convert Arabic numbers
+    }).replace(/[۰۱۲۳۴۵۶۷۸۹]/g, function(d) {
+        return d.charCodeAt(0) - 1776; // Convert Persian numbers
+    }) );
+}
+
 
 }

+ 11 - 0
src/styles.css

@@ -1403,6 +1403,17 @@ height: 7px !important;
 	}
 }
 
+.width_100 {
+  width: 92px;
+  height: 36px;
+  float: right;
+  margin-top: 0;
+}
+
+.wrapping-date-div{
+  display: inline-block;
+  width: 100%;
+}
   /* Eng Magdy Style */