Hima 6 years ago
parent
commit
0e8cb96ac3

+ 3 - 1
src/app/dashboard/reivew-trainee-data/review-trainee-add/review-trainee-add.component.ts

@@ -251,6 +251,7 @@ export class ReviewTraineeAddComponent implements OnInit {
     } else if(typeStatus == 'refused' && this.formData.status_description == ''){
       this.toastr.warning('قم بتسجيل سبب الرفص !');
     } else {
+    
       if(typeStatus == 'accepted') {
         this.formData.status = typeStatus;
         this.toastr.success('تم تسجيل الحاله مقبول');
@@ -280,7 +281,8 @@ export class ReviewTraineeAddComponent implements OnInit {
         (error) => {
           console.log(error);
         }
-      )
+      );
+
     }
    
   }

+ 4 - 4
src/app/trainning-service/add-request/add-request.component.html

@@ -57,19 +57,19 @@
             <div class="col-12 col-sm-12 col-md-4 col-lg-4" *ngIf="dataForm.type == 'fellowship'">
               <div class="form-group">
                 <label for="specialize">رقم التسجيل</label>
-                <input type="number" min="0" placeholder="رقم التسجيل" (keypress)="onKeyPress($event)" appNumber class="form-control" name="registration_number" [ngModel]="dataForm.registration_number"/>
+                <input type="number" min="0" placeholder="رقم التسجيل" (keypress)="authService.onKeydown($event)" appNumber class="form-control" name="registration_number" [ngModel]="dataForm.registration_number"/>
               </div>
             </div>
             <div class="col-12 col-sm-12 col-md-4 col-lg-4" *ngIf="dataForm.type == 'fellowship'">
               <div class="form-group">
                 <label for="specialize">رقم البطاقه الهينه</label>
-                <input type="number" min="0" (keypress)="onKeyPress($event)" appNumber placeholder="رقم البطاقه الهينه" class="form-control" name="authority_card_number" [ngModel]="dataForm.authority_card_number"/>
+                <input type="number" min="0" (keypress)="authService.onKeydown($event)" appNumber placeholder="رقم البطاقه الهينه" class="form-control" name="authority_card_number" [ngModel]="dataForm.authority_card_number"/>
               </div>
             </div>
             <div class="col-12 col-sm-12 col-md-4 col-lg-4" *ngIf="dataForm.type == 'fellowship'">
               <div class="form-group">
                 <label for="specialize"> البطاقه الوظيفي</label>
-                <input type="number" min="0" (keypress)="onKeyPress($event)" appNumber placeholder="البطاقه الوظيفي" class="form-control" name="functional_number" [ngModel]="dataForm.functional_number"/>
+                <input type="number" min="0" (keypress)="authService.onKeydown($event)" appNumber placeholder="البطاقه الوظيفي" class="form-control" name="functional_number" [ngModel]="dataForm.functional_number"/>
               </div>
             </div>
             <div class="col-12 col-sm-12 col-md-4 col-lg-4" *ngIf="dataForm.type == 'fellowship'">
@@ -143,7 +143,7 @@
               </div>
             </div>
             <div class="col-12">
-              <button type="submit" class="btn btn-success rightW" [disabled]="!f.valid || checkSaveClick">حفظ</button>
+              <button type="submit" class="btn btn-success rightW" *ngIf="statusType == 'pending' " [disabled]="!f.valid || checkSaveClick">حفظ</button>
               <button type="button" class="btn btn-warning rightW" (click)="authService.backFromEdit()" style="margin:20px 10px;">إلغاء</button>
             </div>
           </form>

+ 39 - 21
src/app/trainning-service/add-request/add-request.component.ts

@@ -260,6 +260,8 @@ export class AddRequestComponent implements OnInit {
   for(let i = 0; i < this.departmentsId.length; i++) {
     this.addRequestFrom.value['departments_ids'][i] = this.departmentsId[i];
   }
+  
+  this.checkSaveClick = true;
 
   const editAttachements = [];
 
@@ -311,16 +313,22 @@ export class AddRequestComponent implements OnInit {
     //edit mode
     if(this.departmentsId.length == 0) {
       this.toastr.warning('من فضلك ، قم بإختيار قسم كحد أدني !');
+      this.checkSaveClick = false;
     } else if(this.addRequestFrom.value['type'] == 'fellowship' && this.addRequestFrom.value['registration_number'] == '') {
       this.toastr.warning('قم بإختيار رقم التسجيل !');
+      this.checkSaveClick = false;
     } else if(this.addRequestFrom.value['type'] == 'fellowship' && this.addRequestFrom.value['authority_card_number'] == '') {
       this.toastr.warning('قم بإختيار  رقم البطاقه الهنيه !');
+      this.checkSaveClick = false;
     } else if(this.addRequestFrom.value['type'] == 'fellowship' && this.addRequestFrom.value['functional_number'] == '') {
       this.toastr.warning('قم بإختيار الرقم الوظيفي!');
+      this.checkSaveClick = false;
     } else if(this.addRequestFrom.value['type'] == 'fellowship' && this.addRequestFrom.value['contract_type'] == '') {
       this.toastr.warning('قم بإختيار نوع العقد !');
+      this.checkSaveClick = false;
     } else if(this.addRequestFrom.value['type'] == 'fellowship' && this.addRequestFrom.value['organization_affiliated_with'] == '') {
       this.toastr.warning('الجهه التابع لها المتدرب !');
+      this.checkSaveClick = false;
     } else {
       //store departments in object save
         delete this.addRequestFrom.value['department1'];
@@ -368,10 +376,12 @@ export class AddRequestComponent implements OnInit {
               console.log(error.error['error']);
               if(error.error['error'] == 'can not add new request untill old one done') {
                 this.toastr.warning('لا يمكن التعديل طلب جديد ، حتي يتم إجراءات علي الطلب السابق ، شكراً');
+                this.checkSaveClick = false;
                 
               } else {
-                this.toastr.error('يوجد مشكله في السرفر ، سيتم معالجتها لاحقاً');
+                this.toastr.error('يوجد مشكله في الحفظ ، سيتم معالجتها لاحقاً');
                 this.location.back();
+                this.checkSaveClick = false;
               }
             }
           );
@@ -382,40 +392,48 @@ export class AddRequestComponent implements OnInit {
     //add mode
     if(this.departmentsId.length == 0) {
       this.toastr.warning('من فضلك ، قم بإختيار قسم كحد أدني !');
+      this.checkSaveClick = false;
     } else if(this.addRequestFrom.value['type'] == 'fellowship' && this.addRequestFrom.value['registration_number'] == '') {
       this.toastr.warning('قم بإختيار رقم التسجيل !');
+      this.checkSaveClick = false;
     } else if(this.addRequestFrom.value['type'] == 'fellowship' && this.addRequestFrom.value['authority_card_number'] == '') {
       this.toastr.warning('قم بإختيار  رقم البطاقه الهنيه !');
+      this.checkSaveClick = false;
     } else if(this.addRequestFrom.value['type'] == 'fellowship' && this.addRequestFrom.value['functional_number'] == '') {
       this.toastr.warning('قم بإختيار الرقم الوظيفي!');
+      this.checkSaveClick = false;
     } else if(this.addRequestFrom.value['type'] == 'fellowship' && this.addRequestFrom.value['contract_type'] == '') {
       this.toastr.warning('قم بإختيار نوع العقد !');
+      this.checkSaveClick = false;
     } else if(this.addRequestFrom.value['type'] == 'fellowship' && this.addRequestFrom.value['organization_affiliated_with'] == '') {
       this.toastr.warning('الجهه التابع لها المتدرب !');
+      this.checkSaveClick = false;
     } else {
     
       //store departments in object save
-        delete this.addRequestFrom.value['department1'];
-        delete this.addRequestFrom.value['department2'];
-        delete this.addRequestFrom.value['department3'];
-        console.log('successsss save ' , this.addRequestFrom.value);
-        this.dashBoardSer.addItem(this.addRequestFrom.value,'request').subscribe(
-          (responce) => {
-            console.log(responce);
-            this.toastr.success('تم الإضافه بنحاج');
-            this.addRequestFrom.reset();
-            this.location.back();
-          },
-          (error) => {
-            console.log(error);
-            console.log(error.error['error']);
-            if(error.error['error'] == 'can not add new request untill old one done') {
-              this.toastr.warning('لا يمكن إضافه طلب جديد ، حتي يتم إجراءات علي الطلب السابق ، شكراً');
-            } else {
-              this.toastr.error('يوجد مشكله في السرفر ، سيتم معالجتها لاحقاً');
-            }
+      delete this.addRequestFrom.value['department1'];
+      delete this.addRequestFrom.value['department2'];
+      delete this.addRequestFrom.value['department3'];
+      console.log('successsss save ' , this.addRequestFrom.value);
+      this.dashBoardSer.addItem(this.addRequestFrom.value,'request').subscribe(
+        (responce) => {
+          console.log(responce);
+          this.toastr.success('تم الإضافه بنحاج');
+          this.addRequestFrom.reset();
+          this.location.back();
+        },
+        (error) => {
+          console.log(error);
+          console.log(error.error['error']);
+          if(error.error['error'] == 'can not add new request untill old one done') {
+            this.toastr.warning('لا يمكن إضافه طلب جديد ، حتي يتم إجراءات علي الطلب السابق ، شكراً');
+            this.checkSaveClick = false;
+          } else {
+            this.toastr.error('يوجد مشكله في الحفظ ، سيتم معالجتها لاحقاً');
+            this.checkSaveClick = false;
           }
-        );
+        }
+      );
     }
    }