Browse Source

Merge branch 'ibrahimBranch2' into amr

Amr 5 years ago
parent
commit
4744b86cd9

+ 0 - 3
src/app/External-Page/external-page-header/external-page-header.component.ts

@@ -18,9 +18,6 @@ export class ExternalPageHeaderComponent implements OnInit {
    
     currentEnglishDate: any = Date.now(); //english date
 
-    372
-
-
 
     dataLoginUser:any;
 

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

@@ -144,9 +144,6 @@ select.ng-invalid{
 
 
 
-.titileLi-w {
-    margin: 0 65px;
-}
 .titileLi-w li {
     margin: 0 5px;
 }

+ 12 - 2
src/app/auth-services/regester/regester.component.html

@@ -95,7 +95,17 @@
 							 <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>
-                <input type="date" max="{{min}}" id="birthdate" placeholder="تاريخ الميلاد" class="form-control" formControlName="birthday" /> 
+                <!-- <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"  
+                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 class="col-12 col-sm-12 col-md-6 col-lg-4">
@@ -284,7 +294,7 @@
       </div>
       
       <div class="col-12">
-          <button type="submit" [disabled]="!regesterForm.valid" class="btn btn-success regesterBtn-w">{{userProfileId ? 'حفظ' : 'سجل'}}</button>
+          <button type="submit" [disabled]="!regesterForm.valid || saveDisabled" class="btn btn-success regesterBtn-w">{{userProfileId ? 'حفظ' : 'سجل'}}</button>
           <button type="button" class="btn btn-warning regesterBtn-w" (click)="authSer.backFromEdit()">إلغاء</button>
       </div>
 

+ 13 - 1
src/app/auth-services/regester/regester.component.ts

@@ -83,6 +83,7 @@ export class RegesterComponent implements OnInit {
   month:any;
   day:any;
   checkShowSpanRequired: boolean = true;
+  saveDisabled:boolean = false;
   changesSave:boolean = false;
   typeMode:boolean = false;
   checkUserType:number;
@@ -357,6 +358,9 @@ export class RegesterComponent implements OnInit {
       (responce) => {
         console.log(responce);
         this.departments = responce['departments'];
+        if(this.departments.length == 0) {
+          this.toastr.warning('لا يوجد اقسام بهذه الاداره !');
+        }
         this.showDepart = true;
       }
     );
@@ -480,12 +484,13 @@ export class RegesterComponent implements OnInit {
       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['identity_number'] = userDataRegester['identity_number'].toString();
       console.log('valueee' , userDataRegester);
 
-      const birthDate = userDataRegester['birthday'].split('-')[0];
+      const birthDate = userDataRegester['birthday'].split('-')[0];///to check if birthday > employment date
     
 
 
@@ -504,12 +509,16 @@ export class RegesterComponent implements OnInit {
           //edit profile visitor submited 
           if(this.regesterForm.get('password').value != this.regesterForm.get('password_confirmation').value){
             this.toastr.warning(' من فضلك , تأكد أن كلمه المورو نفس تأكيد كلمه المرور!');
+            this.saveDisabled = false;
           }else if(this.regesterForm.get('identity_number').value.substring(0,1) != 1 && this.regesterForm.get('identity_type_id').value == 1){
             this.toastr.warning('رقم الهويه يجب ان يبدأ ب رقم 1');
+            this.saveDisabled = false;
           } else if(this.regesterForm.get('identity_number').value.substring(0,1) != 2 && this.regesterForm.get('identity_type_id').value == 3){
             this.toastr.warning('رقم الهويه يجب ان يبدأ ب رقم 2');
+            this.saveDisabled = false;
           }  else if(this.regesterForm.get('phone').value.substring(0,2) != '05') {
             this.toastr.warning('رقم الجوال يجب أن يبدأ ب 05');
+            this.saveDisabled = false;
           } else {
             this.userService.onEditProfile(userDataRegester).subscribe(
               (responce) => {
@@ -519,10 +528,13 @@ export class RegesterComponent implements OnInit {
               (error) => {
                 console.log(error);
                 this.toastr.error('فشل التعديل');
+                this.saveDisabled = false;
                 if(error.error['error'].email) {
                   this.toastr.warning('الايميل تم التسجيل به من قبل !');
+                  this.saveDisabled = false;
                 } else if(error.error['error'].identity_number) {
                   this.toastr.warning('رقم الهويه تم التسجيل به من قبل !');
+                  this.saveDisabled = false;
                 }
               }
             );

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

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

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

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

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

@@ -63,7 +63,7 @@
                   </div>
                 </td>
                 <td>{{section.name}}</td>
-                <td>{{section.department_name ? section.department_name : '-'}}</td>
+                <td>{{section.adminstration_name ? section.adminstration_name : '-'}}</td>
                 <td *ngIf="authSer.showEditBtn"><button type="button" class="btn btn-outline-secondary" (click)="onEdit(section.id)"><i class="fas fa-edit"></i></button></td>
               </tr>
             </tbody>

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

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

+ 7 - 3
src/app/dashboard/users/form-user/form-user.component.html

@@ -101,6 +101,7 @@
               <div class="form-group">
                 <label for="password" style="float:right">كلمه المرور <span class="spanReqired-w" *ngIf="checkRequiredSpan">*</span></label>
                 <input type="password" id="password" class="form-control" placeholder="كلمه المرور" formControlName="password" />
+                <span class="help-block" *ngIf="password.errors?.minlength && signupForm.get('password').touched" style="color:red;font-size:12px"> من فضلك , أدخل كلمه مرور لاتقل عن 6 ارقام</span>
               </div>
             </div>
 
@@ -108,6 +109,7 @@
               <div class="form-group">
                 <label for="password_confirmation" style="float:right">تأكيد كلمه المرور <span class="spanReqired-w">*</span></label>
                 <input type="password" id="password_confirmation" placeholder="تأكيد كلمه المرور" class="form-control" formControlName="password_confirmation" minlength="6"/>
+                <span class="help-block" *ngIf="repeatPassword.errors?.minlength && signupForm.get('password_confirmation').touched" style="color:red;font-size:12px">من فضلك , أدخل كلمه مرور لاتقل عن 6 ارقام</span>
               </div>
             </div>
 
@@ -123,7 +125,9 @@
             <div class="col-12 col-sm-12 col-md-4 col-lg-4">
               <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" /> 
+                <!-- <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>
               </div>
             </div>
 
@@ -138,10 +142,10 @@
               <div class="form-group">
                 <label for="date_employment_hij" style="float:right" >تاريخ التوظيف الهجري <span class="spanReqired-w">*</span></label>
                 <div *ngIf='bindingDateSplit && typeMode'>
-                  <app-higri-date (onDatePicked)="getDate($event)" [myDate]="bindingDateSplit"></app-higri-date>
+                  <app-higri-date (onDatePicked)="getDate($event, 'higriEmployement')" [myDate]="bindingDateSplit"></app-higri-date>
                 </div>
                 <div *ngIf='!typeMode'>
-                  <app-higri-date (onDatePicked)="getDate($event)" ></app-higri-date>
+                  <app-higri-date (onDatePicked)="getDate($event, 'higriEmployement')" ></app-higri-date>
                 </div>
               </div>
             </div>

+ 39 - 16
src/app/dashboard/users/form-user/form-user.component.ts

@@ -64,6 +64,7 @@ export class FormUserComponent implements OnInit {
   checkUserType:number;
 
   end:any;
+  higri_birth_date;
 
   ngOnInit() {
     this.spineer.show();
@@ -182,6 +183,8 @@ export class FormUserComponent implements OnInit {
           this.userSer.onGetUserData(this.userID, 'editUs').subscribe(
             (responce) => {
               console.log('data user' , responce);
+              
+      
               if(responce['user'].type == '0') {
                 this.signupForm.patchValue(
                   {
@@ -193,7 +196,7 @@ export class FormUserComponent implements OnInit {
                     password_confirmation: responce['user'].password_confirmation,
                     phone: responce['user'].phone,
                     gender: responce['user'].gender,
-                    birthday: responce['user'].birthday,
+                    //birthday: responce['user'].birthday,
                     nationality_id: responce['user'].nationality_id,
                     date_of_employment_gre: responce['user'].date_of_employment_gre,
                     job_title_id: responce['user'].job_title_id,
@@ -216,7 +219,7 @@ export class FormUserComponent implements OnInit {
                     email: responce['user'].email,
                     phone: responce['user'].phone,
                     gender: responce['user'].gender,
-                    birthday: responce['user'].birthday,
+                    //birthday: responce['user'].birthday,
                     nationality_id: responce['user'].nationality_id,
                     status: responce['user'].status,
                     identity_type_id: responce['user'].identity_type_id,
@@ -228,15 +231,22 @@ export class FormUserComponent implements OnInit {
               this.urlImg = responce['user'].photo ? this.authSer.pathImg + responce['user'].photo : this.urlImg;
               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.higriDateVal = responce['user'].date_of_employment_hij;
               console.log(this.bindingDateSplit);
+              console.log('birth day => ', this.higri_birth_date);
               
               this.getDepartment();
               this.spineer.hide();
@@ -261,7 +271,7 @@ export class FormUserComponent 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),
@@ -288,7 +298,7 @@ export class FormUserComponent implements OnInit {
         password: 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),
@@ -305,10 +315,17 @@ export class FormUserComponent implements OnInit {
   }
 
   //get value date from child component 
-  public getDate(date: any):void {
+  public getDate(date: any, type: string):void {
     console.log( date);
-    this.higriDateVal = date.year + '-' + date.month + '-' + date.day;
-    console.log('higrii date', this.higriDateVal);
+    if(type == 'higri_birthDate'){
+      this.higri_birth_date = date.year + '-' + date.month + '-' + date.day;
+      console.log('higri_birth_date ', this.higri_birth_date);
+    } else if(type == 'higriEmployement') {
+      this.higriDateVal = date.year + '-' + date.month + '-' + date.day;
+      console.log('higrii date', this.higriDateVal);
+    } else {
+      console.log('no date is recieved !');
+    }
   }
 
 
@@ -320,6 +337,9 @@ export class FormUserComponent implements OnInit {
       (responce) => {
         console.log(responce);
         this.departments = responce['departments'];
+        if(this.departments.length == 0) {
+          this.toastr.warning('لا يوجد أقسام بهذه الإداره !');
+        }
         this.showDepart = true;
       }
     );
@@ -338,7 +358,7 @@ export class FormUserComponent 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),
         status: new FormControl(null , Validators.required),
@@ -355,7 +375,7 @@ export class FormUserComponent 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),
@@ -368,7 +388,9 @@ export class FormUserComponent implements OnInit {
         staff_id: new FormControl(null),
       });
     } 
-  }
+  };
+
+
 
 
 
@@ -381,13 +403,12 @@ export class FormUserComponent implements OnInit {
     let birthDate;
     if(userData['type'] == 0){
       userData['date_of_employment_hij'] = this.higriDateVal;
-       birthDate = userData['birthday'].split('-')[0];
+       birthDate = this.higri_birth_date;
+       userData['birthday'] = birthDate;
        joinJopYear = userData['date_of_employment_gre'].split('-')[0];
       console.log(joinJopYear);
     }
  
-   
-
     if(this.checkChangeImage) {
       userData['photo'] = this.imageBase64;
       userData['photo_type'] = this.photoType[1];
@@ -401,8 +422,10 @@ export class FormUserComponent implements OnInit {
         this.toastr.warning('من فضلك تأكد أن كلمه المرور هي نفس تأكيد كلمه المرور ');
         this.checkSaveDisabled = false;
       } else if(userData['date_of_employment_hij'] == "") {
-          this.toastr.warning('من فضلك ، أدخل تاريخ التوظيف الهجري !');
-          this.checkSaveDisabled = false;
+        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;

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

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

+ 0 - 3
src/app/end-higri-date/end-higri-date.component.ts

@@ -61,8 +61,5 @@ export class EndHigriDateComponent implements OnInit {
     this.onDatePicked.emit(date);
   }
  
- 
-
-
 
 }

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

@@ -41,7 +41,6 @@ export class HigriDateComponent implements OnInit {
   
   @Output() onDatePicked: EventEmitter<NgbDate> = new EventEmitter<NgbDate>();
   @Input() myDate;
-  @Input() myDate2;
   @Input() higriDisabled;
 
   model: NgbDateStruct;