amr 6 years ago
parent
commit
5672dda702
22 changed files with 696 additions and 421 deletions
  1. 1 1
      src/app/Internal-Page/internal-page-content/internal-page-content.component.html
  2. 8 8
      src/app/dashboard/Registration-trainee-movement/registration-trainee-movement-add/registration-trainee-movement-add.component.html
  3. 105 3
      src/app/dashboard/Registration-trainee-movement/registration-trainee-movement-add/registration-trainee-movement-add.component.ts
  4. 38 35
      src/app/dashboard/Registration-trainee-movement/registration-trainee-movement-list/registration-trainee-movement-list.component.html
  5. 15 15
      src/app/dashboard/dashboard-routing.ts
  6. 32 21
      src/app/dashboard/final-accreditation-of-trainees/final-accerditation-list/final-accerditation-list.component.html
  7. 0 3
      src/app/dashboard/final-accreditation-of-trainees/final-accerditation-list/final-accerditation-list.component.ts
  8. 3 3
      src/app/dashboard/reivew-trainee-data/review-trainee-add/review-trainee-add.component.css
  9. 19 9
      src/app/dashboard/reivew-trainee-data/review-trainee-add/review-trainee-add.component.html
  10. 48 16
      src/app/dashboard/reivew-trainee-data/review-trainee-add/review-trainee-add.component.ts
  11. 71 63
      src/app/dashboard/reivew-trainee-data/review-trainee-data-list/review-trainee-data-list.component.html
  12. 6 1
      src/app/dashboard/section-review-for-trainee/section-review-trainee-add/section-review-trainee-add.component.css
  13. 54 44
      src/app/dashboard/section-review-for-trainee/section-review-trainee-add/section-review-trainee-add.component.html
  14. 19 12
      src/app/dashboard/section-review-for-trainee/section-review-trainee-add/section-review-trainee-add.component.ts
  15. 61 52
      src/app/dashboard/section-review-for-trainee/section-review-trainee-list/section-review-trainee-list.component.html
  16. 1 1
      src/app/dashboard/section-review-for-trainee/section-review-trainee-list/section-review-trainee-list.component.ts
  17. 1 0
      src/app/shared/auth-service.service.ts
  18. 6 0
      src/app/trainning-service/add-request/add-request.component.css
  19. 46 22
      src/app/trainning-service/add-request/add-request.component.html
  20. 123 87
      src/app/trainning-service/add-request/add-request.component.ts
  21. 38 25
      src/app/trainning-service/all-requests/all-requests.component.html
  22. 1 0
      src/app/trainning-service/all-requests/all-requests.component.ts

+ 1 - 1
src/app/Internal-Page/internal-page-content/internal-page-content.component.html

@@ -201,7 +201,7 @@
                                         <li *ngFor="let data of tabsData">
                                             {{data.name}}
                                             <span style="margin: 0 50px;">( {{data.created_at}} )</span>
-                                            <button class="btn btn-default" *ngIf="data.file" type="button" style="position: absolute; background:transparent; border:none; left:45px"> <a href="{{authSer.pathImg + data.file}}" target="_blank"><i class="fas fa-download"></i></a></button>
+                                            <button class="btn btn-default" *ngIf="data.file" type="button" style="position: absolute; background:transparent; border:none; left:45px"> <a href="{{authSer.pathImg + data.file}}" target="_blank"><i class="fas fa-download"></i></a> </button>
                                         </li>
                                     </ol>
                                     <button class="btn btn-primary" (click)="onPageCir()" style="margin:0 auto; display:block; background-color:#bda380; width:150px;border:none;">المزيد</button>

+ 8 - 8
src/app/dashboard/Registration-trainee-movement/registration-trainee-movement-add/registration-trainee-movement-add.component.html

@@ -1,9 +1,9 @@
 <div class="addHospital-w">
     <div class="container">
   
-      <div class="row" style="margin-bottom: 30px;">
+      <div class="row">
           <div class="col-12">
-            <ul class="list-unstyled titileLi-w">
+            <ul class="list-unstyled titileLi-w" style="margin: 0">
               <li class="headingText-w">خدمه التدريب</li>
               <li class="headingText-w" style="cursor:pointer" (click)="authSer.perviousLocation()"> تسجيل حركه المتدرب</li>
               <li class="headingText-w">{{typeLink}}</li>
@@ -157,7 +157,7 @@
                   <div class="col-12 col-sm-12 col-md-4 col-lg-4" *ngIf="formData.type == 'fellowship'">
                     <div class="form-group">
                       <label for="regester" style="float:right">رقم التسجيل <span class="spanReqired-w">*</span></label>
-                      <input type="number" id="regester" placeholder="رقم التسجيل" class="form-control" name="training_period" ngModel [(ngModel)]="formData.registration_number" [disabled]="disabledInput" required/>
+                      <input type="number" id="regester" placeholder="رقم التسجيل" class="form-control" name="regester" ngModel [(ngModel)]="formData.registration_number" [disabled]="disabledInput" required/>
                     </div>
                   </div>
 
@@ -188,7 +188,7 @@
                   </div>
 
                 <!-- <h2 class="departmentHeading-w">أختر الأقسام <span>(قم بإختيار قسم كحد أدني)</span></h2> -->
-                  <div class="col-12 col-sm-12 col-md-4 col-lg-4">
+                  <!-- <div class="col-12 col-sm-12 col-md-4 col-lg-4">
                     <div class="form-group">
                       <label for="department1" style="float:right;">القسم الأول</label>
                       <select class="form-control selectStyle-w" id="department1" name="department1" (input)="changeDepartment($event , 1)" [(ngModel)]="formData.department1" [disabled]="disabledInput">
@@ -214,7 +214,7 @@
                         <option [value]="2003">حذف</option>
                       </select>
                     </div>
-                  </div>
+                  </div> -->
                 </div>
               </div>
             </div>
@@ -238,13 +238,13 @@
                     </thead>
                     <tbody>
                       <tr style="text-align:center;" *ngFor="let file of files; let i = index">
-                        <td><input type="text" class="form-control" placeholder="إسم الملف" [(ngModel)]="file.title" [ngModelOptions]="{standalone: true}" [disabled]="disabledInput"/></td>
+                        <td><input type="text" class="form-control" placeholder="إسم الملف" [(ngModel)]="file.title" [ngModelOptions]="{standalone: true}"/></td>
                         <td style="position: relative;">
-                          <input type="file" name="file{{i}}" id="file{{i}}" class="inputfile" alife-file-to-base64 (onFileChanged)="onFileChanges($event,i)" [disabled]="disabledInput"/>
+                          <input type="file" name="file{{i}}" id="file{{i}}" class="inputfile" alife-file-to-base64 (onFileChanged)="onFileChanges($event,i)"/>
                           <label for="file{{i}}" class="iconUpload-w"><i class="fas fa-upload"></i></label>
                           <span class="fileName-w">{{file.nameFile}}</span>
                         </td>
-                        <td><button type="button" class="btn btn-danger form-control deleteRow-w" (click)="onDeleteRow(i)" [disabled]="disabledInput">حذف</button></td>
+                        <td><button type="button" class="btn btn-danger form-control deleteRow-w" (click)="onDeleteRow(i)">حذف</button></td>
                       </tr>
                     </tbody>
                   </table>

+ 105 - 3
src/app/dashboard/Registration-trainee-movement/registration-trainee-movement-add/registration-trainee-movement-add.component.ts

@@ -95,6 +95,7 @@ export class RegistrationTraineeMovementAddComponent implements OnInit {
     nameFile: '',
     id: null,
   }];
+  attachments_ids = []; //attachements ids;
 
 
   ngOnInit() {
@@ -213,13 +214,14 @@ export class RegistrationTraineeMovementAddComponent implements OnInit {
           }
 
           for(let i = 0; i < responce['data']['request'].departments.length; i++) {
-            if(responce['data']['request'].departments[i].asked_for_opinion == 1) {
+            if(responce['data']['request'].departments[i].is_confirmed == 1) {
               this.actionForm.department_id = responce['data']['request'].departments[i].department_id;
             }
           }
 
           if(responce['data']['request'].attachments.length > 0) {
             for(let i = 0; i < responce['data']['request'].attachments.length; i++) {
+              this.attachments_ids.push(responce['data']['request'].attachments[i].id);
               this.files.push({
                 title: responce['data']['request'].attachments[i].title,
                 file: '',
@@ -228,9 +230,11 @@ export class RegistrationTraineeMovementAddComponent implements OnInit {
                 id: responce['data']['request'].attachments[i].id,
               })
             }
+            console.log('attachements ids', this.attachments_ids);
           } else {
             console.log('no attachements user add !');
           }
+          
           this.spinner.hide();
         },
         (error) => {
@@ -261,7 +265,105 @@ export class RegistrationTraineeMovementAddComponent implements OnInit {
     }
   }
 
+   //change file 
+  onFileChanges(event, index:number) {
+  console.log(event);
+  console.log(index);
+    this.files[index].nameFile = event[0].name.substring(0,20) + '....';
+    this.files[index].file = event[0].base64;
+    this.files[index].file_type = event[0].type.split('/')[1];
+      //validate in pdf type file in create mode 
+      if(this.files[index].file_type != 'pdf') {
+        this.toastr.warning('يجب أن تكون صيفه الملف pdf !');
+        this.checkSaveClick = true;
+      } else {
+        this.checkSaveClick = false;
+      }
+      console.log(this.files);
+  console.log('files after change ',this.files);
+}
+
+plusImage() {
+  this.files.push({
+    title: '',
+    file: '',
+    file_type: '',
+    nameFile: '',
+    id: null,
+  });
+  console.log('files after plus ', this.files);
+}
+
+
+ //delete row from table
+ onDeleteRow(index:number) {
+  this.files.splice(index , 1);
+  if(this.attachments_ids.length > 0) {
+    this.attachments_ids.splice(index, 1);
+  }
+  console.log('files after delete ',this.files);
+  console.log('attachements ids', this.attachments_ids);
+}
+
   onSubmittedForm() {
+
+    this.checkSaveClick = true;
+
+    const editAttachements = [];
+
+    for(let i = 0; i < this.files.length; i++) {
+      for(let j = 0; j < this.attachments_ids.length; j++) {
+       if(this.files[i].id == this.attachments_ids[j]) {
+        editAttachements[i] = this.files[i];
+       }
+      }
+    }
+
+    if(editAttachements.length > 0) {
+      //delete file & file type if not change it in old file
+      for(let i = 0; i < editAttachements.length; i++) {
+        if(editAttachements[i].file_type == '') {
+          delete editAttachements[i].file;
+          delete editAttachements[i].file_type;
+        }
+      }
+
+      //delete the extera key file name 
+      for(let i = 0; i < editAttachements.length; i++) {
+        delete editAttachements[i].nameFile;
+      }
+      
+      
+      //remove old file from files object
+      for(let i = 0; i < editAttachements.length; i++) {
+        for(let j = 0; j < this.files.length; j++) {
+          if(editAttachements[i].id == this.files[j].id) {
+            this.files.splice(j , 1);
+          }
+        }
+      }
+    }
+ 
+
+    //remove nameFile and id from object
+    for(let i = 0; i < this.files.length; i++) {
+      delete this.files[i].nameFile;
+      delete this.files[i].id;
+    }
+
+      //get attachmeents in object files
+      const attachements = [];
+      for(let i = 0; i < this.files.length; i++) {
+        if(this.files[i].file != '') {
+          attachements.push(this.files[i]);
+        }
+      }
+
+     //add to form the edit old file 
+     this.actionForm['editable_attachments'] = editAttachements;
+     this.actionForm['attachments'] = attachements;
+     this.actionForm['attachments_ids'] = this.attachments_ids;//departments_ids
+
     console.log(this.actionForm);
     this.http.post(this.authSer.pathApi + '/trace_trainee_movement', this.actionForm).subscribe(
       (responce) => {
@@ -271,10 +373,10 @@ export class RegistrationTraineeMovementAddComponent implements OnInit {
       },
       (error) => {
         console.log(error);
-        this.toastr.error('يوجد خطأ في السيرفر ، حاول لاحقاً');
+        this.toastr.error('يوجد خطأ في الحفظ ، حاول لاحقاً');
         this.location.back();
       }
-    )
+    );
   }
 
 }

+ 38 - 35
src/app/dashboard/Registration-trainee-movement/registration-trainee-movement-list/registration-trainee-movement-list.component.html

@@ -12,19 +12,6 @@
 
       <div class="row">
         <div class="col-12 col-sm-12 col-md-6 col-lg-6">
-            <!-- <button type="button" class="btn btn-outline-success butttonCreate dashButton-w" (click)="onAdd()" *ngIf="authSer.showAddBtn"><i class="fas fa-plus marginFontAowsome-w"></i>إنشاء جديد</button> -->
-            <!-- <button type="button" class="btn btn-outline-danger butttonDelete dashButton-w" (click)="onDelete()" *ngIf="authSer.showDeleteBtn"><i class="fas fa-times marginFontAowsome-w"></i>حذف</button> -->
-        </div>
-        <div class="col-12 col-sm-12 col-md-6 col-lg-6">
-          <div class="form-group">
-            <input type="text" placeholder="البحث" class="form-control inputSearchTable-w" style="margin-top:13px;" (input)="filtterFunc($event)"/>
-            <hr>
-          </div>
-        </div>
-      </div>
-
-
-      <div class="row">
           <div class="col-12 col-sm-12 col-md-12 col-lg-6">
             <div class="form-group">
               <span class="spanSelect-w">
@@ -38,30 +25,46 @@
               </span>
             </div>
           </div>
-   
+        </div>
+        <div class="col-12 col-sm-12 col-md-6 col-lg-6">
+          <div class="form-group">
+            <input type="text" placeholder="البحث" class="form-control inputSearchTable-w" style="margin-top:0" (input)="filtterFunc($event)"/>
+            <hr>
+          </div>
+        </div>
+      </div>
+
+      <div class="row" *ngIf="dataList.length == 0">
+        <div class="col-12">
+          <h2>لا يوجد بيانات لعرضها</h2>
+        </div>
       </div>
   
-      <table class="table table-bordered">
-        <thead class="headBackground-w">
-          <tr>
-            <th> إسم المتدرب</th>
-            <th>إسم التخصص</th>
-            <th>إسم التخصص الدقيق</th>
-            <th> الجامعه</th>
-            <th *ngIf="authSer.showEditBtn">تفاصيل المتدرب</th>
-          </tr>
-        </thead>
-        <tbody>
-          <tr *ngFor="let data of dataList | paginate: { itemsPerPage: perPagePagenation, currentPage: currentPage, totalItems: count }; let i = index ">
-            <td>{{data.trainee_name}}</td>
-            <td> {{data.specialization_name}}</td>
-            <td>{{data.specific_specialization}}</td>
-            <td>{{data.university}}</td>
-            <td *ngIf="authSer.showEditBtn"><button type="button" class="btn btn-outline-secondary" (click)="onEdit(data.id)"><i class="fas fa-edit"></i></button></td>
-          </tr>
-        </tbody>
-      </table>
-      <pagination-controls nextLabel="التالي" previousLabel="السابق" (pageChange)="onPageChange($event)"></pagination-controls>
+      <div class="row" *ngIf="dataList.length > 0">
+        <div class="col-12">
+          <table class="table table-bordered">
+            <thead class="headBackground-w">
+              <tr>
+                <th> إسم المتدرب</th>
+                <th>إسم التخصص</th>
+                <th>إسم التخصص الدقيق</th>
+                <th> الجامعه</th>
+                <th *ngIf="authSer.showEditBtn">تفاصيل المتدرب</th>
+              </tr>
+            </thead>
+            <tbody>
+              <tr *ngFor="let data of dataList | paginate: { itemsPerPage: perPagePagenation, currentPage: currentPage, totalItems: count }; let i = index ">
+                <td>{{data.trainee_name}}</td>
+                <td> {{data.specialization_name}}</td>
+                <td>{{data.specific_specialization}}</td>
+                <td>{{data.university}}</td>
+                <td *ngIf="authSer.showEditBtn"><button type="button" class="btn btn-outline-secondary" (click)="onEdit(data.id)"><i class="fas fa-edit"></i></button></td>
+              </tr>
+            </tbody>
+          </table>
+          <pagination-controls nextLabel="التالي" previousLabel="السابق" (pageChange)="onPageChange($event)"></pagination-controls>
+        </div>
+      </div>
     </div>
   
   

+ 15 - 15
src/app/dashboard/dashboard-routing.ts

@@ -162,21 +162,21 @@ const dashboardRouting: Routes = [
     {path: 'addAdvertising', component: AddAdvertisingServiceComponent, canActivate: [AuthGuard] },
     {path: 'advertising/:typeAdvertising/:advertisingId', component: AddAdvertisingServiceComponent , canActivate: [AuthGuard]},
     {path: 'map/:listPageId', component: MapComponent, canActivate: [AuthGuard]},
-    {path: 'supervisorList/:listPageId', component: SupervisorListComponent},
-    {path: 'superVisor/Add', component: SupervisorAddComponent},
-    {path: 'superVisor/edit/:superEditId', component: SupervisorAddComponent},
-    {path: 'absorpationList/:listPageId', component: AbsorpationListComponent},
-    {path: 'absorpation/Add', component: AbsorpationAddComponent},
-    {path: 'absorpation/edit/:absorpationEditId', component: AbsorpationAddComponent},
-    {path: 'trainnerList/:listPageId', component: TrainnerDataListComponent},
-    {path: 'trainer/add', component: TrainnerDataAddComponent},
-    {path: 'trainer/edit/:trainnerEditId', component: TrainnerDataAddComponent},
-    {path: 'reviewTrainerData/:listPageId', component: ReviewTraineeDataListComponent},
-    {path: 'reviewTraineeData/add', component: ReviewTraineeAddComponent},
-    {path: 'reviewTraineeData/edit/:reviewTraineeId', component: ReviewTraineeAddComponent},
-    {path: 'reviewSectionForTrainee/:listPageId', component: SectionReviewTraineeListComponent},
-    {path: 'reviewSectionForTrainee/edit/:reviewSectionAddId', component: SectionReviewTraineeAddComponent},
-    {path: 'registrationTraineeList/:listPageId', component: RegistrationTraineeMovementListComponent},
+    {path: 'supervisorList/:listPageId', component: SupervisorListComponent, canActivate: [AuthGuard]},
+    {path: 'superVisor/Add', component: SupervisorAddComponent, canActivate: [AuthGuard]},
+    {path: 'superVisor/edit/:superEditId', component: SupervisorAddComponent, canActivate: [AuthGuard]},
+    {path: 'absorpationList/:listPageId', component: AbsorpationListComponent, canActivate: [AuthGuard]},
+    {path: 'absorpation/Add', component: AbsorpationAddComponent, canActivate: [AuthGuard]},
+    {path: 'absorpation/edit/:absorpationEditId', component: AbsorpationAddComponent, canActivate: [AuthGuard]},
+    {path: 'trainnerList/:listPageId', component: TrainnerDataListComponent, canActivate: [AuthGuard]},
+    {path: 'trainer/add', component: TrainnerDataAddComponent, canActivate: [AuthGuard]},
+    {path: 'trainer/edit/:trainnerEditId', component: TrainnerDataAddComponent, canActivate: [AuthGuard]},
+    {path: 'reviewTrainerData/:listPageId', component: ReviewTraineeDataListComponent, canActivate: [AuthGuard]},
+    {path: 'reviewTraineeData/add', component: ReviewTraineeAddComponent, canActivate: [AuthGuard]},
+    {path: 'reviewTraineeData/edit/:reviewTraineeId', component: ReviewTraineeAddComponent, canActivate: [AuthGuard]},
+    {path: 'reviewSectionForTrainee/:listPageId', component: SectionReviewTraineeListComponent, canActivate: [AuthGuard]},
+    {path: 'reviewSectionForTrainee/edit/:reviewSectionAddId', component: SectionReviewTraineeAddComponent, canActivate: [AuthGuard]},
+    {path: 'registrationTraineeList/:listPageId', component: RegistrationTraineeMovementListComponent, canActivate: [AuthGuard]},
     {path: 'registrationTraineeList/edit/:registrationTraineereviewSectionAddId', component: RegistrationTraineeMovementAddComponent, canActivate: [AuthGuard]},
     {path: 'printCardTraineeList/:listPageId', component: PrintCardTraineeListComponent, canActivate: [AuthGuard]},
     {path: 'printCardTrainee/edit/:printCardAddId', component: PrintCardTraineeAddComponent, canActivate: [AuthGuard]},

+ 32 - 21
src/app/dashboard/final-accreditation-of-trainees/final-accerditation-list/final-accerditation-list.component.html

@@ -40,27 +40,38 @@
           </div>
       </div>
   
-      <table class="table table-bordered">
-        <thead class="headBackground-w">
-          <tr>
-            <th> إسم المتدرب</th>
-            <th>إسم التخصص</th>
-            <th>إسم التخصص الدقيق</th>
-            <th> الجامعه</th>
-            <th *ngIf="authSer.showEditBtn">تفاصيل المتدرب</th>
-          </tr>
-        </thead>
-        <tbody>
-          <tr *ngFor="let data of dataList | paginate: { itemsPerPage: perPagePagenation, currentPage: currentPage, totalItems: count }; let i = index ">
-            <td>{{data.trainee_name}}</td>
-            <td> {{data.specialization_name}}</td>
-            <td>{{data.specific_specialization}}</td>
-            <td>{{data.university}}</td>
-            <td *ngIf="authSer.showEditBtn"><button type="button" class="btn btn-outline-secondary" (click)="onEdit(data.id)"><i class="fas fa-edit"></i></button></td>
-          </tr>
-        </tbody>
-      </table>
-      <pagination-controls nextLabel="التالي" previousLabel="السابق" (pageChange)="onPageChange($event)"></pagination-controls>
+      <div class="row" *ngIf="dataList.length == 0">
+        <div class="col-12">
+          <h2>لا يوجد بيانات لعرضها</h2>
+        </div>
+      </div>
+      
+      <div class="row" *ngIf="dataList.length > 0">
+        <div class="col-12">
+          <table class="table table-bordered">
+            <thead class="headBackground-w">
+              <tr>
+                <th> إسم المتدرب</th>
+                <th>إسم التخصص</th>
+                <th>إسم التخصص الدقيق</th>
+                <th> الجامعه</th>
+                <th *ngIf="authSer.showEditBtn">تفاصيل المتدرب</th>
+              </tr>
+            </thead>
+            <tbody>
+              <tr *ngFor="let data of dataList | paginate: { itemsPerPage: perPagePagenation, currentPage: currentPage, totalItems: count }; let i = index ">
+                <td>{{data.trainee_name}}</td>
+                <td> {{data.specialization_name}}</td>
+                <td>{{data.specific_specialization}}</td>
+                <td>{{data.university}}</td>
+                <td *ngIf="authSer.showEditBtn"><button type="button" class="btn btn-outline-secondary" (click)="onEdit(data.id)"><i class="fas fa-edit"></i></button></td>
+              </tr>
+            </tbody>
+          </table>
+          <pagination-controls nextLabel="التالي" previousLabel="السابق" (pageChange)="onPageChange($event)"></pagination-controls>
+        </div>
+      </div>
+
     </div>
   
   </div>

+ 0 - 3
src/app/dashboard/final-accreditation-of-trainees/final-accerditation-list/final-accerditation-list.component.ts

@@ -106,9 +106,6 @@ export class FinalAccerditationListComponent implements OnInit {
             (responce) => {
               console.log('rescponce dataaaa', responce);
               this.dataList = responce['requests'];
-              if(this.dataList.length == 0) {
-                this.toastr.warning('القائمه فارغه من الطلبات ');
-              }
               this.count = responce['count'];
               this.perPagePagenation = responce['per_page'];
               console.log('evennnnts', this.dataList);

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

@@ -185,7 +185,7 @@ select.ng-invalid{
     color: #fff;
 }
 .statusBtn-w {
-    width: 80px;
+    width: 145px;
     margin: 5px 7px;
     cursor: pointer;
     float: right;
@@ -208,7 +208,7 @@ select.ng-invalid{
 }
 
 .wrapper .iconUpload-w {
-    width: 265px;
+    width: 200px;
     height: 37px;
     border-radius: 5px;
     font-size: 1.25em;
@@ -217,7 +217,7 @@ select.ng-invalid{
     background-color: #fff;
     border: 1px solid #ccc;
     padding: 0 10px;
-    position: absolute;
+    display: contents;
     right: 75px;
 }
 

+ 19 - 9
src/app/dashboard/reivew-trainee-data/review-trainee-add/review-trainee-add.component.html

@@ -1,9 +1,9 @@
 <div class="addHospital-w">
     <div class="container">
   
-      <div class="row" style="margin-bottom: 30px;">
+      <div class="row">
           <div class="col-12">
-            <ul class="list-unstyled titileLi-w">
+            <ul class="list-unstyled titileLi-w" style="margin: 0;">
               <li class="headingText-w">خدمه التدريب</li>
               <li class="headingText-w" style="cursor:pointer" (click)="authSer.perviousLocation()"> إستعراض بيانات المتدربين</li>
               <li class="headingText-w activeLi-w" style="margin-right:5px"> {{typeLink}} </li>
@@ -59,7 +59,7 @@
                   <div class="col-12 col-sm-12 col-md-6 col-lg-4">
                     <div class="form-group">
                     <label for="identityNumber" style="float:right">رقم الهويه <span class="spanReqired-w">*</span></label>
-                    <input type="number" class="form-control" placeholder="رقم الهويه" (keypress)="authSer.onKeydown($event)" id="identityNumber" (input)="onIdentitiyChange($event.target.value)" ngModel name="identity_number" [(ngModel)]="userData.identity_number" [disabled]="disabledInput" min="0" required/>
+                    <input type="number" class="form-control" placeholder="رقم الهويه" (keypress)="authSer.onKeydown($event)" id="identityNumber" appOnlyNumber (input)="onIdentitiyChange($event.target.value)" ngModel name="identity_number" [(ngModel)]="userData.identity_number" [disabled]="disabledInput" min="0" required/>
                     <span class="errorMessage-w" *ngIf="identity_id == 1">أدخل رقم هويه مكون من 10 أرقام يبدأ برقم 1</span>
                     <span class="errorMessage-w" *ngIf="identity_id == 2">أدخل رقم هويه مكون من 10 أرقام </span>
                     <span class="errorMessage-w" *ngIf="identity_id == 3">أدخل رقم الإقامه مكون من 10 أرقام يبدأ برقم 2 </span>
@@ -127,7 +127,8 @@
                   <thead class="headBackground-w">
                     <tr>
                       <th> إسم المرفق</th>
-                      <th>رفع املف ( بصيغه pdf )</th>
+                      <th>أختر الملف ( بصيغه pdf )</th>
+                      <th *ngIf="typeMode">عرض الملف</th>
                       <th>حذف</th>
                     </tr>
                   </thead>
@@ -139,6 +140,7 @@
                         <label for="file{{i}}" class="iconUpload-w"><i class="fas fa-upload"></i></label>
                         <span class="fileName-w">{{file.nameFile}}</span>
                       </td>
+                      <th *ngIf="typeMode" style="text-align:center"><a *ngIf="file.nameFile" href="{{authSer.pathImg + file.nameFile}}" target="_blank"><i class="fas fa-download"></i></a></th>
                       <td><button type="button" class="btn btn-danger form-control deleteRow-w" (click)="onDeleteRow(i)">حذف</button></td>
                     </tr>
                   </tbody>
@@ -160,8 +162,9 @@
                           : formData.status == 'replayed_opinion' ? 'رأي القسم'
                           : formData.status == 'refused' ? 'مرفوض' 
                           : formData.status == 'canceled' ? 'ملغي'
-                          : formData.status == 'asked_for_opinion' ? 'طلب رأي'
+                          : formData.status == 'asked_for_opinion' ? 'طلب رأي القسم'
                           : 'لم يتم تسجيل حاله الطلب'}}</h2>
+                          <!-- <span>{{departmentNameOpinion}}</span> -->
                     </div>
                   <!-- <div class="form-group">
                    
@@ -274,9 +277,9 @@
                 </div>
                 <div class="col-12 col-sm-12 col-md-4 col-lg-4"  *ngIf="editMode">
                   <div class="form-group">
-                    <label for="department4" style="float:right;">القسم المناسب</label>
+                    <label for="department4" style="float:right;">القسم المناسب للتدريب</label>
                     <select class="form-control selectStyle-w" id="department4" name="department4" [(ngModel)]="formData.department4">
-                      <option *ngFor="let department of departments" [value]="department.department_id">{{department.department_name}}</option>
+                      <option *ngFor="let department of chosenDepartments" [value]="department.department_id">{{department.department_name}}</option>
                     </select>
                   </div>
                 </div>
@@ -287,8 +290,15 @@
                     <label for="status" style="float:right; display:block"> الأوامر <span class="spanReqired-w">*</span></label>
                     <button type="button" class="btn btn-success statusBtn-w" (click)="statusShow('accepted')">قبول</button>
                     <button type="button" class="btn btn-danger statusBtn-w" (click)="statusShow('refused')">رفض</button>
-                    <button type="button" class="btn btn-default statusBtn-w" (click)="statusShow('asked_for_opinion')">طلب رأي</button>
-                    <input type="text" placeholder="سبب الرفض" class="form-control" name="status_description" ngModel [(ngModel)]="formData.status_description" *ngIf="showRefusedCause" required>
+                    <button type="button" class="btn btn-default statusBtn-w" (click)="statusShow('asked_for_opinion')"> طلب رأي القسم</button>
+                    <div class="row" *ngIf="showRefusedCause">
+                      <div class="col-12">
+                        <div class="form-group">
+                          <label for="department4" style="float:right;">سبب الرفض</label>
+                          <input type="text" placeholder="سبب الرفض" class="form-control" name="status_description" ngModel [(ngModel)]="formData.status_description" required>
+                        </div>
+                      </div>
+                    </div>
                   </div>
                 </div>
 

+ 48 - 16
src/app/dashboard/reivew-trainee-data/review-trainee-add/review-trainee-add.component.ts

@@ -34,12 +34,14 @@ export class ReviewTraineeAddComponent implements OnInit {
   editMode: boolean = false; //true in edit mode 
   showPersonalData: boolean = false;
   reportId: number;
+  departmentNameOpinion: string = "";
   attachments_ids = []; //for edit mode;
 
   countries: any[] = [];
   identities: any[] = [];
   trainees:any[] = [];
   departments:any[] = [];
+  chosenDepartments = [];
   departmentsId:any[] = [];
 
   @ViewChild('f') traineeForm: NgForm;
@@ -186,16 +188,17 @@ export class ReviewTraineeAddComponent implements OnInit {
           this.userId = responce['data']['user'].id;
           
           this.userData['id'] = this.userId;
-
              //full departments in edit mode 
           if(responce['data']['request'].departments.length > 0) {
-               this.departments = [];
-              for(let i = 0; i < responce['data']['request'].departments.length; i++) {
-                this.departments[i] = responce['data']['request'].departments[i];
-                if(this.departments[i].asked_for_opinion == 1){
-                  this.formData.department4 = responce['data']['request'].departments[i].department_id;
-                }
+            for(let i = 0; i < responce['data']['request'].departments.length; i++) {
+              this.chosenDepartments[i] = responce['data']['request'].departments[i];
+              if(this.chosenDepartments[i].is_confirmed == 1){
+                this.formData.department4 = responce['data']['request'].departments[i].department_id;
+              }
+              if(this.chosenDepartments[i].asked_for_opinion == '1') {
+                this.departmentNameOpinion = this.chosenDepartments[i].department_name;
               }
+            }
           }
 
 
@@ -238,35 +241,38 @@ export class ReviewTraineeAddComponent implements OnInit {
     console.log(this.formData.status_description);
     this.formData['id'] = this.reportId;
     
+    statusData.choosen_department_id = this.formData['department4'];
     statusData.id = this.reportId;
     statusData.status = typeStatus;
   
 
-    if(typeStatus == 'refused') {
+    if(typeStatus == 'refused' && this.formData['department4'] != '') {
       this.showRefusedCause = true;
     }
 
     if(this.formData['department4'] == '') {
       this.toastr.warning('من فضلك قم بإختيار قسم مناسب ثم قم بتسجيل حاله الطلب !');
     } else if(typeStatus == 'refused' && this.formData.status_description == ''){
-      this.toastr.warning('قم بتسجيل سبب الرفص !');
+      this.toastr.warning('قم بتسجيل سبب الرفص ثم قم بالضغط علي رفض مره أخري ليتم التسجيل!');
     } else {
+    
       if(typeStatus == 'accepted') {
         this.formData.status = typeStatus;
+        this.formData.status_description = '';
         this.toastr.success('تم تسجيل الحاله مقبول');
         this.showRefusedCause = false;
       } else if(typeStatus == 'refused') {
         statusData.status_description = this.formData.status_description;
         console.log( statusData.status_description);
         this.formData.status = typeStatus;
-        this.toastr.error('تم تسجيل الحاله بالرفض');
+        this.toastr.error('تم تسجيل الحاله بالرفض ');
       } else if(typeStatus == 'asked_for_opinion') {
         this.formData.status = typeStatus;
         this.showRefusedCause = false;
+        this.formData.status_description = '';
         this.toastr.warning('تم تسجيل الحاله طلب رأي ');
       }
 
-      statusData.choosen_department_id = this.formData['department4'];
 
 
     
@@ -280,7 +286,8 @@ export class ReviewTraineeAddComponent implements OnInit {
         (error) => {
           console.log(error);
         }
-      )
+      );
+
     }
    
   }
@@ -417,7 +424,7 @@ export class ReviewTraineeAddComponent implements OnInit {
 
   onSubmittedForm() {
     
-    
+    this.checkSaveClick = true;
 
     if(this.editMode) {
 
@@ -436,6 +443,7 @@ export class ReviewTraineeAddComponent implements OnInit {
   
       if(this.formData.trainee == '') {
         this.toastr.warning('من فضلك قم بإختيار متدرب !');
+        this.checkSaveClick = false;
       } else {
         
         //delete file & file type if not change it in old file
@@ -475,9 +483,17 @@ export class ReviewTraineeAddComponent implements OnInit {
         delete this.formData['status_description'];
 
 
+         //get attachmeents in object files
+         const attachements = [];
+         for(let i = 0; i < this.files.length; i++) {
+           if(this.files[i].file != '') {
+             attachements.push(this.files[i]);
+           }
+         }
+
         //add to form the edit old file 
         this.formData['editable_attachments'] = editAttachements;
-        this.formData['attachments'] = this.files;
+        this.formData['attachments'] = attachements;
         this.formData['attachments_ids'] = this.attachments_ids;//departments_ids
 
         const formArraySend = [];
@@ -493,6 +509,7 @@ export class ReviewTraineeAddComponent implements OnInit {
           },
           (error) => {
             console.log(error);
+            this.checkSaveClick = false;
             this.toastr.error('يوجد مشكله في السيرفر يتم العمل عليها حالياً');
           }
         );
@@ -524,8 +541,10 @@ export class ReviewTraineeAddComponent implements OnInit {
 
       if(this.departmentsId.length == 0) {
         this.toastr.warning('قم بإختيار قسم كحد أدني !');
+        this.checkSaveClick = false;
       } else if(this.formData.trainee == '') {
         this.toastr.warning('قم بإختيار متدرب !');
+        this.checkSaveClick = false;
       } else {
         //delete extra keies
         delete this.formData.trainee;
@@ -538,9 +557,20 @@ export class ReviewTraineeAddComponent implements OnInit {
           delete this.files[i].nameFile;
           delete this.files[i].id;
         }
-        this.formData['attachments'] = this.files; //add files to form json
+
+        //get attachmeents in object files
+        const attachements = [];
+        for(let i = 0; i < this.files.length; i++) {
+          if(this.files[i].file != '') {
+            attachements.push(this.files[i]);
+          }
+        }
+
+        console.log(attachements);
+        this.formData['attachments'] =  attachements; //add files to form json
         this.formData['user_id'] = this.userId;
         console.log(this.formData);
+
         this.dashBoardSer.addItem(this.formData, 'traineeRequest').subscribe(
           (responce) => {
             console.log(responce);
@@ -552,14 +582,16 @@ export class ReviewTraineeAddComponent 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;
                 this.location.back();                
               } else {
                 this.toastr.error('يوجد مشكله في السرفر ، سيتم معالجتها لاحقاً');
-                this.location.back();
+                this.checkSaveClick = false;
                 this.location.back();
               }
           }
         );
+
       }
     }
 

+ 71 - 63
src/app/dashboard/reivew-trainee-data/review-trainee-data-list/review-trainee-data-list.component.html

@@ -38,18 +38,18 @@
               من العناصر يتم عرضها
             </span>
             <span class="spanSelect-w">
-                <select [ngModel]="viewTableData" class="form-control selectButton-w" (input)="onFiltterChosen($event)" style="width:100px; margin-right:15px;">
-                  <option value="all">الكل</option>
-                  <option value="pending">تحت الإجراء</option>
-                  <option value="accepted">مقبول</option>
-                  <option value="refused">مرفوض</option>
-                  <option value="canceled">ملغي</option>
-                  <option value="ended">مغلق</option>
-                  <option value="asked_for_opinion">طلب رأي</option>
-                  <option value="replayed_opinion">رأي القسم</option>
-                </select>
-                حاله الطلب
-              </span>
+              <select [ngModel]="viewTableData" class="form-control selectButton-w" (input)="onFiltterChosen($event)" style="width:130px; margin-right:15px;">
+                <option value="all">الكل</option>
+                <option value="pending">تحت الإجراء</option>
+                <option value="accepted">مقبول</option>
+                <option value="refused">مرفوض</option>
+                <option value="canceled">ملغي</option>
+                <option value="ended">مغلق</option>
+                <option value="asked_for_opinion">طلب رأي القسم</option>
+                <option value="replayed_opinion">رأي القسم</option>
+              </select>
+              حاله الطلب
+            </span>
           </div>
           <!-- <div class="form-group">
            
@@ -60,58 +60,66 @@
         </div>
       </div>
   
-      <table class="table table-bordered">
-        <thead class="headBackground-w">
-          <tr>
-            <th>
-              <div class="custom-control custom-checkbox">
-                  <input type="checkbox" class="custom-control-input" [(ngModel)]="selectedAll" (change)="selectAll();" id="customCheck" name="example1">
-                  <!-- <label class="custom-control-label fixedWidthLabel-w checkAll-w" for="customCheck" style="margin-bottom:20px; cursor: pointer;"></label> -->
-              </div>
-            </th>
-            <th> إسم المتدرب</th>
-            <th>إسم التخصص</th>
-            <th>الجنسيه</th>
-            <th>الجامعه</th>
-            <th>نوع التدريب</th>
-            <th>الحاله</th>
-            <th *ngIf="authSer.showEditBtn">تفاصيل الطلب</th>
-          </tr>
-        </thead>
-        <tbody>
-          <tr *ngFor="let data of dataList | paginate: { itemsPerPage: perPagePagenation, currentPage: currentPage, totalItems: count }; let i = index ">
-            <td>
-              <div class="custom-control custom-checkbox centerIneerItem">
-                <input type="checkbox" class="custom-control-input" id="{{data.id}}" [(ngModel)]="data.selected" [value]='data' (change)="checkIfAllSelected();">
-                <!-- <label class="custom-control-label disblayBlock-w" for="{{news.id}}" style="color:#2a2a2a;cursor: pointer;"></label> -->
-              </div>
-            </td>
-            <td>{{data.trainee_name}}</td>
-            <td> {{data.specialization_name}}</td>
-            <td>{{data.country_arNationality}}</td>
-            <td>{{data.university}}</td>
-            <!-- <td>{{data.type == 'trainees' ? 'متدربين' 
-              : data.type == 'fellowship' ? 'زماله' 
-              : data.type == 'university_administrators' : 'مشرفي الجامعات'
-              : 'لايوجد'}}
-            </td> -->
-            <td>{{data.type == 'trainees' ? 'متدربين' 
-                : data.type == 'fellowship' ? 'زماله' 
-                : data.type == 'university_administrators' ? 'مشرفي الجامعات'
-                : 'لايوجد'}}</td>
+      <div class="row" *ngIf="dataList.length == 0">
+        <div class="col-12">
+          <h2>لايوجد بيانات لعرضها</h2>
+        </div>
+      </div>
 
-            <td>{{data.status == 'pending' ? 'تحت الإجراء' 
-              : data.status == 'accepted' ? 'مقبول' 
-              : data.status == 'replayed_opinion' ? 'رأي القسم'
-              : data.status == 'refused' ? 'مرفوض' 
-              : data.status == 'canceled' ? 'ملغي'
-              : data.status == 'asked_for_opinion' ? 'طلب رأي'
-              : data.status == 'asked_for_opinion' ? 'طلب رأي' : 'لايوجد'}}</td>
-            <td *ngIf="authSer.showEditBtn"><button type="button" class="btn btn-outline-secondary" (click)="onEdit(data.id)"><i class="fas fa-edit"></i></button></td>
-          </tr>
-        </tbody>
-      </table>
-      <pagination-controls nextLabel="التالي" previousLabel="السابق" (pageChange)="onPageChange($event)"></pagination-controls>
+      <div class="row" *ngIf="dataList.length > 0">
+        <div class="col-12">
+          <table class="table table-bordered">
+              <thead class="headBackground-w">
+                <tr>
+                  <!-- <th>
+                    <div class="custom-control custom-checkbox">
+                        <input type="checkbox" class="custom-control-input" [(ngModel)]="selectedAll" (change)="selectAll();" id="customCheck" name="example1">
+                    </div>
+                  </th> -->
+                  <th> إسم المتدرب</th>
+                  <th>إسم التخصص</th>
+                  <th>الجنسيه</th>
+                  <th>الجامعه</th>
+                  <th>نوع التدريب</th>
+                  <th>الحاله</th>
+                  <th *ngIf="authSer.showEditBtn">تفاصيل الطلب</th>
+                </tr>
+              </thead>
+              <tbody>
+                <tr *ngFor="let data of dataList | paginate: { itemsPerPage: perPagePagenation, currentPage: currentPage, totalItems: count }; let i = index ">
+                  <!-- <td>
+                    <div class="custom-control custom-checkbox centerIneerItem">
+                      <input type="checkbox" class="custom-control-input" id="{{data.id}}" [(ngModel)]="data.selected" [value]='data' (change)="checkIfAllSelected();">
+                    </div>
+                  </td> -->
+                  <td>{{data.trainee_name}}</td>
+                  <td> {{data.specialization_name}}</td>
+                  <td>{{data.country_arNationality}}</td>
+                  <td>{{data.university}}</td>
+                  <!-- <td>{{data.type == 'trainees' ? 'متدربين' 
+                    : data.type == 'fellowship' ? 'زماله' 
+                    : data.type == 'university_administrators' : 'مشرفي الجامعات'
+                    : 'لايوجد'}}
+                  </td> -->
+                  <td>{{data.type == 'trainees' ? 'متدربين' 
+                      : data.type == 'fellowship' ? 'زماله' 
+                      : data.type == 'university_administrators' ? 'مشرفي الجامعات'
+                      : 'لايوجد'}}
+                  </td>
+      
+                  <td>{{data.status == 'pending' ? 'تحت الإجراء' 
+                    : data.status == 'accepted' ? 'مقبول' 
+                    : data.status == 'replayed_opinion' ? 'رأي القسم'
+                    : data.status == 'refused' ? 'مرفوض' 
+                    : data.status == 'canceled' ? 'ملغي'
+                    : data.status == 'asked_for_opinion' ? 'طلب رأي القسم' : 'لايوجد '}}</td>
+                  <td *ngIf="authSer.showEditBtn"><button type="button" class="btn btn-outline-secondary" (click)="onEdit(data.id)"><i class="fas fa-edit"></i></button></td>
+                </tr>
+              </tbody>
+            </table>
+            <pagination-controls nextLabel="التالي" previousLabel="السابق" (pageChange)="onPageChange($event)"></pagination-controls>        
+        </div>
+      </div>
     </div>
   
   

+ 6 - 1
src/app/dashboard/section-review-for-trainee/section-review-trainee-add/section-review-trainee-add.component.css

@@ -12,6 +12,11 @@ input,select {
     border: 2px solid #bda380;
 }
 
+.titileFiles-w{
+    font-size: 18px;
+    float: right;
+    margin: 10px 20px;
+}
 /* input.ng-invalid.ng-touched {
     border: 2px solid #ccc;
 }
@@ -217,7 +222,7 @@ select.ng-invalid{
 }
 
 .wrapper .iconUpload-w {
-    width: 265px;
+    width: 170px;
     height: 37px;
     border-radius: 5px;
     font-size: 1.25em;

+ 54 - 44
src/app/dashboard/section-review-for-trainee/section-review-trainee-add/section-review-trainee-add.component.html

@@ -1,9 +1,9 @@
 <div class="addHospital-w">
     <div class="container">
   
-      <div class="row" style="margin-bottom: 30px;">
+      <div class="row">
           <div class="col-12">
-            <ul class="list-unstyled titileLi-w">
+            <ul class="list-unstyled titileLi-w" style="margin:0">
               <li class="headingText-w">خدمه التدريب</li>
               <li class="headingText-w" style="cursor:pointer" (click)="authSer.perviousLocation()"> إستعراض القسم للمتدربين</li>
               <li class="headingText-w activeLi-w" style="margin-right:5px"> {{typeLink}} </li>
@@ -108,6 +108,15 @@
               <div class="row">
                 <div class="wrapper">
                   
+                  <div class="col-12">
+                    <h2>حاله الطلب : {{statusName == 'pending' ? 'تحت الإجراء' 
+                        : statusName == 'accepted' ? 'مقبول' 
+                        : statusName == 'replayed_opinion' ? 'رأي القسم'
+                        : statusName == 'refused' ? 'مرفوض' 
+                        : statusName == 'canceled' ? 'ملغي'
+                        : statusName == 'asked_for_opinion' ? 'طلب رأي القسم' : 'لايوجد '}}</h2>
+                  </div>
+
                   <div class="col-12 col-sm-12 col-md-4 col-lg-4">
                     <div class="form-group">
                       <label style="float:right">نوع الطلب <span class="spanReqired-w">*</span></label>
@@ -187,8 +196,7 @@
                     </div>
                   </div>
 
-                <!-- <h2 class="departmentHeading-w">أختر الأقسام <span>(قم بإختيار قسم كحد أدني)</span></h2> -->
-                  <div class="col-12 col-sm-12 col-md-4 col-lg-4">
+                  <!-- <div class="col-12 col-sm-12 col-md-4 col-lg-4">
                     <div class="form-group">
                       <label for="department1" style="float:right;">القسم الأول</label>
                       <select class="form-control selectStyle-w" id="department1" name="department1" (input)="changeDepartment($event , 1)" [(ngModel)]="formData.department1" [disabled]="disabledInput">
@@ -214,7 +222,7 @@
                         <option [value]="2003">حذف</option>
                       </select>
                     </div>
-                  </div>
+                  </div> -->
                 </div>
               </div>
             </div>
@@ -222,17 +230,23 @@
             <div class="col-12">
               <h2 class="title">المرفقات</h2>
               <div class="row">
-                <div class="wrapper">
+
+                <div class="col-12" *ngIf="files.length == 0">
+                  <h2 class="titileFiles-w">لا يوجد مرفقات لعرضها </h2>
+                </div>
+
+                <div class="wrapper" *ngIf="files.length > 0">
                   
-                  <div class="col-12">
+                  <!-- <div class="col-12">
                     <button type="button" class="btn btn-default" (click)="plusImage()" style="margin:20px 0; float:right;">إضافه مرفق</button>
-                  </div>
+                  </div> -->
 
                   <table class="table table-bordered">
                     <thead class="headBackground-w">
                       <tr>
                         <th> إسم المرفق</th>
                         <th>رفع املف ( بصيغه pdf )</th>
+                        <th>عرض الملف</th>
                         <th>حذف</th>
                       </tr>
                     </thead>
@@ -244,6 +258,7 @@
                           <label for="file{{i}}" class="iconUpload-w"><i class="fas fa-upload"></i></label>
                           <span class="fileName-w">{{file.nameFile}}</span>
                         </td>
+                        <td><a href="{{authSer.pathImg + file.nameFile}}" target="_blank"><i class="fas fa-download"></i></a></td>
                         <td><button type="button" class="btn btn-danger form-control deleteRow-w" (click)="onDeleteRow(i)" [disabled]="disabledInput">حذف</button></td>
                       </tr>
                     </tbody>
@@ -254,51 +269,46 @@
             </div>
 
             <div class="col-12" style="margin: 20px 0;">
-                <div class="row">
-                  <div class="wrapper">
-                    
-                    <div class="askForOpinion-w" *ngIf="!isConfirmedStatus">
-                      <div class="col-12 col-md-6">
-                        <div class="form-group">
-                          <label style="float:right; margin: 20px;"> رأي القسم </label>
-                          <quill-editor id="description" name="actionOpinionForm" [(ngModel)]="actionOpinionForm.department_opinion" required>
-                            </quill-editor>
-                        </div>
+              <div class="row">
+                <div class="wrapper">
+                  
+                  <div class="askForOpinion-w" *ngIf="!isConfirmedStatus">
+                    <div class="col-12 col-md-12">
+                      <div class="form-group">
+                        <label style="float:right; margin: 20px;"> رأي القسم </label>
+                        <quill-editor id="description" name="actionOpinionForm" [(ngModel)]="actionOpinionForm.department_opinion" required>
+                          </quill-editor>
                       </div>
                     </div>
-                    
-                    <div class="confirmed-w" *ngIf="isConfirmedStatus">
-                      <div class="col-12 col-sm-12 col-md-4 col-lg-4">
-                          <div class="form-group">
-                            <label for="startDate" style="float:right" >تاريخ البدايه</label>
-                            <div *ngIf='bindingDateSplitStart && typeMode'>
-                              <app-higri-date (onDatePicked)="getDate($event, 'start')" [myDate]="bindingDateSplitStart"></app-higri-date>
-                            </div>
-                            <!-- <div *ngIf='!typeMode'>
-                              <app-higri-date (onDatePicked)="getDate($event, 'start')" ></app-higri-date>
-                            </div> -->
+                  </div>
+                  
+                  <div class="confirmed-w" *ngIf="isConfirmedStatus">
+                    <div class="col-12 col-sm-12 col-md-4 col-lg-4">
+                        <div class="form-group">
+                          <label for="startDate" style="float:right" >تاريخ البدايه</label>
+                          <div *ngIf='bindingDateSplitStart && typeMode'>
+                            <app-higri-date (onDatePicked)="getDate($event, 'start')" [myDate]="bindingDateSplitStart"></app-higri-date>
                           </div>
                         </div>
-          
-                        <div class="col-12 col-sm-12 col-md-4 col-lg-4">
-                          <div class="form-group">
-                            <label for="endDate" style="float:right" >تاريخ الإنتهاء</label>
-                            <div *ngIf='bindingDateSplitEnd && typeMode'>
-                              <app-end-higri-date  (onDatePicked)="getDate($event, 'end')" [myEndDate]="bindingDateSplitEnd"> </app-end-higri-date>
-                            </div>
-                            <!-- <div *ngIf='!typeMode'>
-                              <app-end-higri-date  (onDatePicked)="getDate($event, 'end')" ></app-end-higri-date>
-                            </div> -->
+                      </div>
+        
+                      <div class="col-12 col-sm-12 col-md-4 col-lg-4">
+                        <div class="form-group">
+                          <label for="endDate" style="float:right" >تاريخ الإنتهاء</label>
+                          <div *ngIf='bindingDateSplitEnd && typeMode'>
+                            <app-end-higri-date  (onDatePicked)="getDate($event, 'end')" [myEndDate]="bindingDateSplitEnd"> </app-end-higri-date>
                           </div>
                         </div>
+                      </div>
 
-                        <div class="col-12 col-sm-12 col-md-4 col-lg-4">
-                          <button class="btn btn-success" type="button" (click)="beginTrainning()" style="width: 100%; margin-top:30px;">بدء التدريب</button>
-                        </div>
-                    </div>
-                  
+                      <div class="col-12 col-sm-12 col-md-4 col-lg-4">
+                        <button class="btn btn-success" type="button" (click)="beginTrainning()" style="width: 100%; margin-top:30px;">بدء التدريب</button>
+                      </div>
+                      
                   </div>
+                
                 </div>
+              </div>
             </div>
 
             <div class="col-12">

+ 19 - 12
src/app/dashboard/section-review-for-trainee/section-review-trainee-add/section-review-trainee-add.component.ts

@@ -46,6 +46,8 @@ export class SectionReviewTraineeAddComponent implements OnInit {
   bindingDateSplitStart;
   bindingDateSplitEnd;
 
+  statusName: string = '';
+
   @ViewChild('f') traineeForm: NgForm;
 
   //all form data 
@@ -200,6 +202,7 @@ export class SectionReviewTraineeAddComponent implements OnInit {
           this.formData.functional_number = responce['data']['request'].functional_number;
           this.formData.organization_affiliated_with = responce['data']['request'].organization_affiliated_with;
           this.formData.registration_number = responce['data']['request'].registration_number;
+          this.statusName = responce['data']['request'].status ? responce['data']['request'].status : '';
           this.userData.name = responce['data']['user'].name;
           this.userData.email = responce['data']['user'].email;
           this.userData.identity_number = responce['data']['user'].identity_number;
@@ -350,18 +353,22 @@ export class SectionReviewTraineeAddComponent implements OnInit {
       }
     } else {
       console.log(this.actionOpinionForm);
-      this.http.post(this.authSer.pathApi +  '/department_shows_opinion', this.actionOpinionForm).subscribe(
-        (responce) => {
-          console.log(responce);
-          this.toastr.success('تم بنجاح');
-          this.location.back();
-        },
-        (error) => {
-          console.log(error);
-          this.toastr.warning('خطأ في الحفظ ، نعمل علي حلها ، حاول لاحقا');
-          this.location.back();
-        }
-      )
+      if(this.actionOpinionForm.department_opinion == '') {
+        this.toastr.warning('أدخل رأي القسم !');
+      } else {
+        this.http.post(this.authSer.pathApi +  '/department_shows_opinion', this.actionOpinionForm).subscribe(
+          (responce) => {
+            console.log(responce);
+            this.toastr.success('تم بنجاح');
+            this.location.back();
+          },
+          (error) => {
+            console.log(error);
+            this.toastr.warning('خطأ في الحفظ ، نعمل علي حلها ، حاول لاحقا');
+            this.location.back();
+          }
+        );
+      }
     }
    
 

+ 61 - 52
src/app/dashboard/section-review-for-trainee/section-review-trainee-list/section-review-trainee-list.component.html

@@ -12,69 +12,78 @@
 
       <div class="row">
         <div class="col-12 col-sm-12 col-md-6 col-lg-6">
-            <!-- <button type="button" class="btn btn-outline-success butttonCreate dashButton-w" (click)="onAdd()" *ngIf="authSer.showAddBtn"><i class="fas fa-plus marginFontAowsome-w"></i>إنشاء جديد</button> -->
-            <!-- <button type="button" class="btn btn-outline-danger butttonDelete dashButton-w" (click)="onDelete()" *ngIf="authSer.showDeleteBtn"><i class="fas fa-times marginFontAowsome-w"></i>حذف</button> -->
+          <div class="form-group" style="float:right;">
+            <span class="spanSelect-w">
+              <select [ngModel]="dataTableNumber" class="form-control selectButton-w" (input)="onGetValue($event)">
+                <option value="5">5</option>
+                <option value="10">10</option>
+                <option value="15">15</option>
+                <option value="20">20</option>
+              </select>
+              من العناصر يتم عرضها
+            </span>
+          </div>
+
+          <div class="form-group" style="float:right; margin:0 10px;">
+            <span class="spanSelect-w">
+              <select [ngModel]="defaultValueFiltter" class="form-control selectButton-w" (input)="onFiltterChosen($event)" style="width:200px;">
+                <option value="all">الكل</option>
+                <option value="asked_for_opinion">طلبات مطلوب الرأي بها</option>
+                <option value="is_confirmed ">الطلبات المقبوله</option>
+                <option value="stopped">الطلبات الموقوفه</option>
+                <option value="ended">الطلبات المنتهيه</option>
+              </select>
+              حاله الطلب
+            </span>
+          </div>
+
         </div>
+
         <div class="col-12 col-sm-12 col-md-6 col-lg-6">
           <div class="form-group">
-            <input type="text" placeholder="البحث" class="form-control inputSearchTable-w" style="margin-top:13px;" (input)="filtterFunc($event)"/>
+            <input type="text" placeholder="البحث ( رقم الهويه أو الإيميل أو الجوال )" class="form-control inputSearchTable-w" style="margin:0" (input)="filtterFunc($event)"/>
             <hr>
           </div>
         </div>
-      </div>
 
+      </div>
 
-      <div class="row">
-          <div class="col-12 col-sm-12 col-md-12 col-lg-12">
-            
-            <div class="form-group" style="float:right;">
-              <span class="spanSelect-w">
-                <select [ngModel]="dataTableNumber" class="form-control selectButton-w" (input)="onGetValue($event)">
-                  <option value="5">5</option>
-                  <option value="10">10</option>
-                  <option value="15">15</option>
-                  <option value="20">20</option>
-                </select>
-                من العناصر يتم عرضها
-              </span>
-            </div>
-
-            <div class="form-group" style="float:right; margin:0 10px;">
-              <span class="spanSelect-w">
-                <select [ngModel]="dataTableNumber" class="form-control selectButton-w" (input)="onFiltterChosen($event)" style="width:200px;">
-                  <option value="all">الكل</option>
-                  <option value="asked_for_opinion">طلب رأي</option>
-                  <option value="is_confirmed">الطلبات المقبوله</option>
-                </select>
-                حاله الطلب
-              </span>
-            </div>
+      <div class="row" *ngIf='dataList.length == 0'>
+        <div class="col-12">
+          <h2>لا يوجد بيانات لعرضها </h2>
+        </div>
+      </div>
 
-          </div>
+      <div class="row" *ngIf='dataList.length > 0'>
+        <div class="col-12">
+          <table class="table table-bordered">
+              <thead class="headBackground-w">
+                <tr>
+                  <th> إسم المتدرب</th>
+                  <th>إسم التخصص</th>
+                  <th>إسم التخصص الدقيق</th>
+                  <th>الحاله</th>
+                  <th> الجامعه</th>
+                  <th *ngIf="authSer.showEditBtn">تفاصيل المتدرب</th>
+                </tr>
+              </thead>
+              <tbody>
+                <tr *ngFor="let data of dataList | paginate: { itemsPerPage: perPagePagenation, currentPage: currentPage, totalItems: count }; let i = index ">
+                  <td>{{data.trainee_name}}</td>
+                  <td> {{data.specialization_name}}</td>
+                  <td>{{data.specific_specialization}}</td>
+                  <td>{{data.status == 'accepted' ? 'مقبول' : data.status == 'refused' ? 'مرفوض' : 'لايوجد'}}</td>
+                  <td>{{data.university}}</td>
+                  <td *ngIf="authSer.showEditBtn"><button type="button" class="btn btn-outline-secondary" (click)="onEdit(data.id)"><i class="fas fa-edit"></i></button></td>
+                </tr>
+              </tbody>
+            </table>
+      
+            <pagination-controls nextLabel="التالي" previousLabel="السابق" (pageChange)="onPageChange($event)"></pagination-controls>
         
+        </div>
       </div>
-  
-      <table class="table table-bordered">
-        <thead class="headBackground-w">
-          <tr>
-            <th> إسم المتدرب</th>
-            <th>إسم التخصص</th>
-            <th>إسم التخصص الدقيق</th>
-            <th> الجامعه</th>
-            <th *ngIf="authSer.showEditBtn">تفاصيل المتدرب</th>
-          </tr>
-        </thead>
-        <tbody>
-          <tr *ngFor="let data of dataList | paginate: { itemsPerPage: perPagePagenation, currentPage: currentPage, totalItems: count }; let i = index ">
-            <td>{{data.trainee_name}}</td>
-            <td> {{data.specialization_name}}</td>
-            <td>{{data.specific_specialization}}</td>
-            <td>{{data.university}}</td>
-            <td *ngIf="authSer.showEditBtn"><button type="button" class="btn btn-outline-secondary" (click)="onEdit(data.id)"><i class="fas fa-edit"></i></button></td>
-          </tr>
-        </tbody>
-      </table>
-      <pagination-controls nextLabel="التالي" previousLabel="السابق" (pageChange)="onPageChange($event)"></pagination-controls>
+
     </div>
   
   

+ 1 - 1
src/app/dashboard/section-review-for-trainee/section-review-trainee-list/section-review-trainee-list.component.ts

@@ -39,6 +39,7 @@ export class SectionReviewTraineeListComponent implements OnInit {
     dataTableNumber: number = 5;
     serviceName: string = '';
     pages = [];
+    defaultValueFiltter: string = 'all';
 
   ngOnInit() {
 
@@ -99,7 +100,6 @@ export class SectionReviewTraineeListComponent implements OnInit {
                 (error) => {console.log(error)}
               );
             }
-      
           );
 
           //get list data 

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

@@ -52,6 +52,7 @@ export class AuthServiceService {
 
   pathApi: string = 'http://kfmc.info/back_end/api';
   pathImg: string = "http://kfmc.info/back_end/public/";
+
   myInnerHeight = window.innerHeight;
   imgSrc: string =  '../../assets/image/avatar.png'; //page profile default
   iconImg: string = '../../assets/image/Group 92.png';

+ 6 - 0
src/app/trainning-service/add-request/add-request.component.css

@@ -87,4 +87,10 @@
 
 .table tbody tr:nth-child(even):hover {
     color: #bda380 !important;
+}
+
+.titleFiles {
+    font-size: 18px;
+    margin: 20px 0;
+    color: red;
 }

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

@@ -17,7 +17,7 @@
             <div class="col-12 col-sm-12 col-md-4 col-lg-4">
               <div class="form-group">
                 <label>نوع الطلب</label>
-                <select class="form-control selectStyle-w" name="type" (input)="changeType($event)" [ngModel]="dataForm.type" required>
+                <select class="form-control selectStyle-w" name="type" (input)="changeType($event)" [ngModel]="dataForm.type" [disabled]="disabledInput" required>
                   <option value="trainees">المتدربين</option>
                   <option value="fellowship"> زماله(البورد السعودي) </option>
                   <option value="university_administrators">مشرفي الجامعات</option>
@@ -27,71 +27,72 @@
             <div class="col-12 col-sm-12 col-md-4 col-lg-4">
               <div class="form-group">
                 <label for="specialize">اسم التخصص</label>
-                <input type="text" placeholder="اسم التخصص" class="form-control" name="specialization_name" [ngModel]="dataForm.specialization_name" required/>
+                <input type="text" placeholder="اسم التخصص" class="form-control" name="specialization_name" [ngModel]="dataForm.specialization_name" [disabled]="disabledInput" required/>
               </div>
             </div>
             <div class="col-12 col-sm-12 col-md-4 col-lg-4">
               <div class="form-group">
                 <label for="specialize">التخصص الدقيق</label>
-                <input type="text" placeholder="التخصص الدقيق" class="form-control" name="specific_specialization" [ngModel]="dataForm.specific_specialization" required/>
+                <input type="text" placeholder="التخصص الدقيق" class="form-control" name="specific_specialization" [ngModel]="dataForm.specific_specialization" [disabled]="disabledInput" required/>
               </div>
             </div>
             <div class="col-12 col-sm-12 col-md-4 col-lg-4">
               <div class="form-group">
                 <label for="specialize">الجامعه</label>
-                <input type="text" placeholder="الجامعه" class="form-control" name="university" [ngModel]="dataForm.university" required/>
+                <input type="text" placeholder="الجامعه" class="form-control" name="university" [ngModel]="dataForm.university" [disabled]="disabledInput" required/>
               </div>
             </div>
             <div class="col-12 col-sm-12 col-md-4 col-lg-4">
               <div class="form-group">
                 <label for="specialize">المستوي</label>
-                <input type="text" placeholder="المستوي" class="form-control" name="level" [ngModel]="dataForm.level" required/>
+                <input type="text" placeholder="المستوي" class="form-control" name="level" [ngModel]="dataForm.level" [disabled]="disabledInput" required/>
               </div>
             </div>
             <div class="col-12 col-sm-12 col-md-4 col-lg-4">
               <div class="form-group">
                 <label for="specialize">الفتره التدريبيه</label>
-                <input type="text" placeholder="الفتره التدريبيه" class="form-control" name="training_period" [ngModel]="dataForm.training_period" required/>
+                <input type="text" placeholder="الفتره التدريبيه" class="form-control" name="training_period" [ngModel]="dataForm.training_period" [disabled]="disabledInput" required/>
               </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" placeholder="رقم التسجيل" (keypress)="onKeyPress($event)" appNumber class="form-control" name="registration_number" [ngModel]="dataForm.registration_number"/>
+                <label for="registration">رقم التسجيل</label>
+                <input type="number" min="0" placeholder="رقم التسجيل" (keypress)="authService.onKeydown($event)" appNumber class="form-control" name="registration_number" id="registration" [ngModel]="dataForm.registration_number" [disabled]="disabledInput"/>
               </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" [disabled]="disabledInput"/>
               </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" [disabled]="disabledInput"/>
               </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="text" placeholder="نوع التعاقد" class="form-control" name="contract_type" [ngModel]="dataForm.contract_type"/>
+                <input type="text" placeholder="نوع التعاقد" class="form-control" name="contract_type" [ngModel]="dataForm.contract_type" [disabled]="disabledInput"/>
               </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="text" placeholder="الجهه التابع لها المتدرب" class="form-control" name="organization_affiliated_with" [ngModel]="dataForm.organization_affiliated_with"/>
+                <input type="text" placeholder="الجهه التابع لها المتدرب" class="form-control" name="organization_affiliated_with" [ngModel]="dataForm.organization_affiliated_with" [disabled]="disabledInput"/>
               </div>
             </div>
             <div class="col-12 col-sm-12 col-md-12 col-lg-12">
-              <h2>أختر الأقسام <span>(قم بإختيار قسم كحد أدني)</span></h2>
+              <h2 *ngIf="saveButtonShow">أختر الأقسام <span>(قم بإختيار قسم كحد أدني)</span></h2>
+              <!-- <h2 *ngIf="!saveButtonShow">الأقسام</h2> -->
               <hr>
-              <div class="row">
+              <div class="row" *ngIf="saveButtonShow">
                 <div class="col-12 col-sm-12 col-md-4 col-lg-4">
                   <div class="form-group">
                     <label for="department1">القسم الأول</label>
-                    <select class="form-control selectStyle-w" id="department1" name="department1" (input)="changeDepartment($event , 1)" [ngModel]="dataForm.department1">
+                    <select class="form-control selectStyle-w" id="department1" name="department1" (input)="changeDepartment($event , 1)" [ngModel]="dataForm.department1" [disabled]="disabledInput">
                       <option *ngFor="let department of departments" [value]="department.id">{{department.name}}</option>
                     </select>
                   </div>
@@ -99,7 +100,7 @@
                 <div class="col-12 col-sm-12 col-md-4 col-lg-4">
                   <div class="form-group">
                     <label for="department2">القسم الثاني</label>
-                    <select class="form-control selectStyle-w" id="department2" name="department2" (input)="changeDepartment($event , 2)" [ngModel]="dataForm.department2">
+                    <select class="form-control selectStyle-w" id="department2" name="department2" (input)="changeDepartment($event , 2)" [ngModel]="dataForm.department2" [disabled]="disabledInput">
                       <option *ngFor="let department of departments" [value]="department.id">{{department.name}}</option>
                     </select>
                   </div>
@@ -107,34 +108,56 @@
                 <div class="col-12 col-sm-12 col-md-4 col-lg-4">
                   <div class="form-group">
                     <label for="department3">القسم الثالث</label>
-                    <select class="form-control selectStyle-w" id="department3" name="department3" (input)="changeDepartment($event , 3)" [ngModel]="dataForm.department3">
+                    <select class="form-control selectStyle-w" id="department3" name="department3" (input)="changeDepartment($event , 3)" [ngModel]="dataForm.department3" [disabled]="disabledInput">
                       <option *ngFor="let department of departments" [value]="department.id">{{department.name}}</option>
                     </select>
                   </div>
                 </div>
               </div>
+
+              <div class="row" *ngIf="!saveButtonShow">
+                <div class="col-12 col-sm-12 col-md-4 col-lg-4">
+                  <label for="department"> قسم التدريب</label>
+                  <select class="form-control selectStyle-w" id="department" name="department" [ngModel]="dataForm.department" [disabled]="disabledInput">
+                    <option *ngFor="let department of departments" [value]="department.id">{{department.name}}</option>
+                  </select>
+                </div>
+                <div class="col-12 col-sm-12 col-md-4 col-lg-4">
+                  <h2 style="margin-top: 40px">تاريخ النهايه <span>{{dataForm.start_date ? dataForm.start_date : 'لم يتم التحديد'}}</span></h2>
+                </div>
+                <div class="col-12 col-sm-12 col-md-4 col-lg-4">
+                  <h2 style="margin-top: 40px">تاريخ البدايه <span>{{dataForm.end_date ? dataForm.end_date : 'لم يتم التحديد'}}</span></h2>
+                </div>
+              </div>
+
               <div class="col-12">
-               <div class="row">
+                <h2 style="margin-top: 30px;">المرفقات</h2>
+                <hr>
+                <h1 class="titleFiles" *ngIf="files.length == 0">لا يوجد مرفقات لعرضها</h1>
+
+               <div class="row" *ngIf="files.length > 0">
 
                   <div class="col-12">
-                  <button type="button" class="btn btn-default" (click)="plusImage()" style="margin:10px 0;">إضافه مرفق</button>
-                 </div>
+                    <button type="button" class="btn btn-default" (click)="plusImage()" style="margin:10px 0;" [disabled]="disabledInput">إضافه مرفق</button>
+                  </div>
                  <table class="table table-bordered">
                     <thead class="headBackground-w">
                       <tr>
                         <th> إسم المرفق</th>
                         <th>رفع املف ( بصيغه pdf )</th>
+                        <th>عرض الملف</th>
                         <th>حذف</th>
                       </tr>
                     </thead>
                     <tbody>
                       <tr style="text-align:center;" *ngFor="let file of files; let i = index">
-                        <td><input type="text" class="form-control" placeholder="إسم الملف" [(ngModel)]="file.title" [ngModelOptions]="{standalone: true}"/></td>
+                        <td><input type="text" class="form-control" placeholder="إسم الملف" [(ngModel)]="file.title" [disabled]="disabledInput" [ngModelOptions]="{standalone: true}"/></td>
                         <td>
                           <input type="file" name="file{{i}}" id="file{{i}}" class="inputfile" alife-file-to-base64 (onFileChanged)="onFileChanges($event,i)" />
                           <label for="file{{i}}" class="iconUpload-w"><i class="fas fa-upload"></i></label>
                           <span>{{file.nameFile}}</span>
                         </td>
+                        <td><a href="{{authService.pathImg + file.nameFile}}" target="_blank"><i class="fas fa-download"></i></a></td>
                         <td><button type="button" class="btn btn-danger form-control deleteRow-w" (click)="onDeleteRow(i)">حذف</button></td>
                       </tr>
                     </tbody>
@@ -142,8 +165,9 @@
                </div>
               </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="saveButtonShow" [disabled]="!f.valid || checkSaveClick">حفظ</button>
               <button type="button" class="btn btn-warning rightW" (click)="authService.backFromEdit()" style="margin:20px 10px;">إلغاء</button>
             </div>
           </form>

+ 123 - 87
src/app/trainning-service/add-request/add-request.component.ts

@@ -6,13 +6,14 @@ import { ActivatedRoute, Params } from '@angular/router';
 import { Component, OnInit, ViewChild } from '@angular/core';
 import { NgForm } from '@angular/forms';
 import { ToastrService } from 'ngx-toastr';
-import { Location } from '@angular/common';
+import { Location, formatDate } from '@angular/common';
 
 @Component({
   selector: 'app-add-request',
   templateUrl: './add-request.component.html',
   styleUrls: ['./add-request.component.css']
 })
+
 export class AddRequestComponent implements OnInit {
 
   constructor(private route: ActivatedRoute, 
@@ -31,6 +32,11 @@ export class AddRequestComponent implements OnInit {
   requestId: number;
   statusType: string = '';
 
+  attachments_ids = []; //for edit mode;
+  disabledInput:boolean = false; //disabled button of row in edit mode 
+  editButtonShow:boolean = false; //show edit button in edit mode 
+  saveButtonShow:boolean = true; //show save button in edit mode 
+
   @ViewChild('f') addRequestFrom: NgForm;
 
 
@@ -49,6 +55,7 @@ export class AddRequestComponent implements OnInit {
     department1: '',
     department2: '',
     department3: '',
+    department: '',
   };
   
   files = [{
@@ -61,11 +68,6 @@ export class AddRequestComponent implements OnInit {
 
 
 
-  attachments_ids = []; //for edit mode;
-  departmentsIds = []; //attachemnts id edit
-  disabledInput:boolean = false; //disabled button of row in edit mode 
-  editButtonShow:boolean = false; //show edit button in edit mode 
-  saveButtonShow:boolean = false; //show save button in edit mode 
 
   ngOnInit() {
 
@@ -90,14 +92,25 @@ export class AddRequestComponent implements OnInit {
     this.route.params.subscribe(
     (params: Params) => {
       this.requestId = params['requestId'];
+
+      //edit mode in all requests component 
       if(this.requestId) {
+
+        //get status of this user request
         this.statusType = localStorage.getItem('requestStatus');
+        if(this.statusType == 'pending') {
+          this.saveButtonShow = true;
+          this.disabledInput = false;
+        } else {
+          this.saveButtonShow = false;
+          this.disabledInput = true;
+        }
 
         this.spiner.show();
         this.files = [];
         this.editButtonShow = true;
-        this.disabledInput = true;
         this.editMode = true;
+
         this.http.get(this.authService.pathApi + '/get_request/' + this.requestId).subscribe(
           (responce) => {
             console.log(responce);
@@ -117,6 +130,11 @@ export class AddRequestComponent implements OnInit {
             //add departmrnts ids 
             if(responce['data']['request'].departments.length > 0) {
               for(let i = 0; i < responce['data']['request'].departments.length; i++) {
+                
+                if(responce['data']['request'].departments[i].is_confirmed == '1') {
+                  this.dataForm.department = responce['data']['request'].departments[i].department_id;
+                }
+
                 if(i == 0) {
                   this.dataForm.department1 = responce['data']['request'].departments[0].department_id;
                   this.departmentsId[i] = responce['data']['request'].departments[i].department_id;
@@ -146,6 +164,8 @@ export class AddRequestComponent implements OnInit {
               console.log('no attachements user add !');
             }
 
+            console.log('filessss', this.files);
+
             this.spiner.hide();
           },
           (error) => {
@@ -156,6 +176,7 @@ export class AddRequestComponent implements OnInit {
     }
   );
 
+  //get departments data 
     this.http.get(this.authService.pathApi + '/training_adminstration_departments').subscribe(
       (responce) => {
         this.departments = responce['departments'];
@@ -169,7 +190,7 @@ export class AddRequestComponent implements OnInit {
   }
 
 
-
+//add file in table 
  plusImage() {
    this.files.push({
      title: '',
@@ -181,6 +202,8 @@ export class AddRequestComponent implements OnInit {
    console.log('files after plus ', this.files);
  }
 
+
+ //on file change 
  onFileChanges(event, index:number) {
    console.log(event);
    console.log(index);
@@ -188,6 +211,7 @@ export class AddRequestComponent implements OnInit {
     this.files[index].file = event[0].base64;
     this.files[index].file_type = event[0].type.split('/')[1];
     if(this.editMode) {
+      
       //validate in pdf type file in edit mode 
       if(this.files[index].file_type != '') {
         if(this.files[index].file_type != 'pdf') {
@@ -211,7 +235,7 @@ export class AddRequestComponent implements OnInit {
  }
 
  
-
+//change department 
  changeDepartment(event, typeSelect) {
    console.log(event.target.value);
    if(typeSelect == 1) {
@@ -221,19 +245,16 @@ export class AddRequestComponent implements OnInit {
    } else if(typeSelect == 3) {
     this.departmentsId[2] = event.target.value;
    }
-
-  
-   
-    console.log(this.departmentsId);
-    for(let i = 0; i < this.departmentsId.length; i++) {
-      if(this.departmentsId[i] == this.departmentsId[i+1]) {
-        this.toastr.warning('يوجد أقسام متشابهه ، يجب أن تكون جميه الاقسام مختلفه');
-        this.checkSaveClick = true;
-        break;
-      } else {
-        this.checkSaveClick = false;
-      }
+  console.log(this.departmentsId);
+  for(let i = 0; i < this.departmentsId.length; i++) {
+    if(this.departmentsId[i] == this.departmentsId[i+1]) {
+      this.toastr.warning('يوجد أقسام متشابهه ، يجب أن تكون جميه الاقسام مختلفه');
+      this.checkSaveClick = true;
+      break;
+    } else {
+      this.checkSaveClick = false;
     }
+  }
  }
 
  changeType(event) {
@@ -256,15 +277,20 @@ export class AddRequestComponent implements OnInit {
  onSubmitted() {
 
   this.addRequestFrom.value['departments_ids'] = [];
+  const attachements = [];
 
   for(let i = 0; i < this.departmentsId.length; i++) {
     this.addRequestFrom.value['departments_ids'][i] = this.departmentsId[i];
   }
+  
+  this.checkSaveClick = true;
 
   const editAttachements = [];
 
   if(this.editMode) {
 
+  console.log('edit mode');
+
    for(let i = 0; i < this.files.length; i++) {
      for(let j = 0; j < this.attachments_ids.length; j++) {
       if(this.files[i].id == this.attachments_ids[j]) {
@@ -273,54 +299,46 @@ export class AddRequestComponent implements OnInit {
      }
    }
 
-   
-
   } else {
+    console.log('add mode');
+    console.log('files length before loop', this.files.length);
+
     //remove fileName from files and remove file is empty 
     for(let i = 0; i < this.files.length; i++) {
       //delete this.files[i].nameFile;
       if(this.files[i].file_type){
       this.files[i].file_type = this.files[i].file_type.toLowerCase();
       }
-      if(this.files[i].file == '') {
-      //this.files.splice(this.files.indexOf(this.files[i], 1));
-      console.log('empty number ' , i);  
-      this.files.splice(i , 1);
+      if(this.files[i].file != '') {
+        attachements.push(this.files[i]);
       }
     }
-    console.log('after submitted form ', this.files);
-    this.addRequestFrom.value['attachments'] = this.files; //add files to form json
+    this.addRequestFrom.value['attachments'] = attachements; //add files to form json
   }
 
-
- 
-
-    
-
-
-
-
-
-
-
-  
-
    if(this.requestId) {
+
      console.log('attachements ids after submitted' , this.attachments_ids);
     
     //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'];
@@ -337,6 +355,7 @@ export class AddRequestComponent implements OnInit {
           for(let i = 0; i < editAttachements.length; i++) {
             delete editAttachements[i].nameFile;
           }
+          
           this.addRequestFrom.value['editable_attachments'] = editAttachements;
           for(let i = 0; i < editAttachements.length; i++) {
             for(let j = 0; j < this.files.length; j++) {
@@ -345,8 +364,22 @@ export class AddRequestComponent implements OnInit {
               }
             }
           }
+
           this.addRequestFrom.value['editable_attachments'] = editAttachements;
-          this.addRequestFrom.value['attachments'] = this.files;
+
+          const attach = [];//to add new attachements in edit mode 
+          //remove fileName from files and remove file is empty 
+          for(let i = 0; i < this.files.length; i++) {
+            //delete this.files[i].nameFile;
+            if(this.files[i].file_type){
+            this.files[i].file_type = this.files[i].file_type.toLowerCase();
+            }
+            if(this.files[i].file != '') {
+              attach.push(this.files[i]);
+            }
+          }
+
+          this.addRequestFrom.value['attachments'] = attach;
           this.addRequestFrom.value['attachments_ids'] = this.attachments_ids;
           
           console.log('attachements ids', this.attachments_ids);
@@ -357,24 +390,26 @@ export class AddRequestComponent implements OnInit {
           
 
 
-          this.dashBoardSer.editItem(this.requestId, this.addRequestFrom.value,'request').subscribe(
-            (responce) => {
-              console.log(responce);
-              this.toastr.success('تم التعديل بنحاج');
+        this.dashBoardSer.editItem(this.requestId, this.addRequestFrom.value,'request').subscribe(
+          (responce) => {
+            console.log(responce);
+            this.toastr.success('تم التعديل بنحاج');
+            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.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('يوجد مشكله في السرفر ، سيتم معالجتها لاحقاً');
-                this.location.back();
-              }
+              this.checkSaveClick = false;
             }
-          );
+          }
+        );
     }
    } else {
      
@@ -382,51 +417,52 @@ 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;
           }
-        );
+        }
+      );
     }
    }
 
  }
 
- onKeyPress(event) {
-   console.log(event.target.value);
-   if(event.target.value < 0) {
-     event.target.value = null;
-    event.preventDefault();
-   }
- }
-
 }

+ 38 - 25
src/app/trainning-service/all-requests/all-requests.component.html

@@ -10,35 +10,48 @@
     </div>
 
     <div class="containerContent-w" style="text-align: center;">
+      
       <div class="col-12 "  *ngIf="requests.length == 0 " >
         <h2 class="title">لا يوجد بيانات لعرضها </h2>
-
       </div>
+
         <table class="table table-bordered" *ngIf="requests.length != 0 " >
-            <thead class="headBackground-w">
-              <tr>
-                <th>الحاله</th>
-                <th> فتره التدريب</th>
-                <th>نوع التدريب</th>
-                <th>التخصص العام</th>
-                <th>التخصص الدقيق</th>
-                <th>الأوامر</th>
-              </tr>
-            </thead>
-            <tbody>
-              <tr *ngFor="let data of requests; let i = index " style="text-align:center">
-                <td>{{data.status == 'pending' ? 'تحت الإجراء' : '....'}}</td>
-                <td>{{data.training_period}}</td>
-                <td>{{data.type}}</td>
-                <td>{{data.specialization_name}}</td>
-                <td>{{data.specific_specialization}}</td>
+          <thead class="headBackground-w">
+            <tr>
+              <th>الحاله</th>
+              <th> فتره التدريب</th>
+              <th>نوع التدريب</th>
+              <th>التخصص العام</th>
+              <th>التخصص الدقيق</th>
+              <th>الأوامر</th>
+            </tr>
+          </thead>
+          <tbody>
+            <tr *ngFor="let data of requests; let i = index " style="text-align:center">
+              <td>
+                {{data.status == 'pending' ? 'تحت الإجراء' 
+              : data.status == 'accepted' ? 'مقبول' 
+              : data.status == 'replayed_opinion' ? 'رأي القسم'
+              : data.status == 'refused' ? 'مرفوض' 
+              : data.status == 'canceled' ? 'ملغي'
+              : data.status == 'asked_for_opinion' ? 'طلب رأي'
+              : data.status == 'asked_for_opinion' ? 'طلب رأي' : 'لايوجد'}}
+              </td>
+              <td>{{data.training_period}}</td>
+              <td>
+                {{data.type == 'trainees' ? 'متدربين' 
+                : data.type == 'fellowship' ? 'زماله' 
+                : data.type == 'university_administrators' ? 'مشرفي الجامعات'
+                : 'لايوجد'}}
+              </td>
+              <td>{{data.specialization_name}}</td>
+              <td>{{data.specific_specialization}}</td>
 
-                <td>
-                  <button *ngIf=" data.status == 'pending' " type="button" class="btn btn-outline-secondary" (click)="onEdit(data)"><i class="fas fa-edit"></i></button>
-                  <span *ngIf="data.status != 'pending'">غير مسموح</span>
-                </td>
-              </tr>
-            </tbody>
-          </table>
+              <td>
+                <button type="button" class="btn btn-outline-secondary" (click)="onEdit(data)"><i class="fas fa-edit"></i></button>
+              </td>
+            </tr>
+          </tbody>
+      </table>
     </div>
   </div>

+ 1 - 0
src/app/trainning-service/all-requests/all-requests.component.ts

@@ -63,6 +63,7 @@ export class AllRequestsComponent implements OnInit {
   onEdit(requestData) {
     console.log(requestData);
     console.log('editRequest/' + this.visitorId + '/' + requestData.id);
+    //to show save button or no in status pending 
     localStorage.setItem('requestStatus', requestData.status);
     this.router.navigate(['editRequest/' + this.visitorId + '/' + requestData.id]);
   }