Hima 5 years ago
parent
commit
8c1243fd20

+ 5 - 0
src/app/dashboard/create-report/add-new-report/add-new-report.component.css

@@ -124,4 +124,9 @@
     opacity: 0.5;
     cursor: not-allowed;
     background-color:  #e9ecef
+}
+
+
+.checkReport {
+    display: block;
 }

+ 46 - 0
src/app/dashboard/create-report/add-new-report/add-new-report.component.html

@@ -16,6 +16,52 @@
 
         <div class="row">
 
+          <div class="col-12" *ngIf="departmentUserLoginId == 6">
+            <h2 class="title">بيانات صاحب البلاغ</h2>
+            <div class="row">
+              <div class="col-12">
+                <div class="wrapper">
+                  <div class="col-12 col-md-6">
+                    <div class="form-group">
+                      <input type="checkbox" class="form-check-input checkReport" name="report" id="report" [(ngModel)]="reportVal" value="report">
+                      <label class="form-check-label" for="report" style="margin: 0 20px; float: right;">إنشاء بلاغ ع الغير</label>
+                    </div>
+                  </div>
+
+                  <div class="col-12 col-md-6">
+                    <input type="text" class="form-control" placeholder="البحث ( برقم الهويه / الرقم الوظيفي )" style="width:85%; float:right" appOnlyNumber [(ngModel)]="search" [ngModelOptions]="{standalone: true}"/>
+                    <button class="btn btn-success" type="button" style="float:right; margin:0 2px;" (click)="getValue()">أبحث</button>
+                  </div>
+
+                  <div class="col-12 col-md-4" style="margin: 20px 0">
+                    <div class="form-group">
+                      <label for="name" style="float:right">الإسم<span class="spanReqired-w">*</span></label>
+                      <input type="text" class="form-control" id="name" [ngModel]="reportAuthor.name" [ngModelOptions]="{standalone: true}"/>
+                    </div>
+                  </div>
+                  <div class="col-12 col-md-4" style="margin: 20px 0">
+                    <div class="form-group">
+                      <label for="identityNumber" style="float:right">رقم الهويه <span class="spanReqired-w">*</span></label>
+                      <input type="phone" class="form-control" id="identityNumber" [ngModel]="reportAuthor.identity_number" [ngModelOptions]="{standalone: true}"/>
+                    </div>
+                  </div>
+                  <div class="col-12 col-md-4" style="margin: 20px 0">
+                    <div class="form-group">
+                      <label for="functionalNumber" style="float:right">رقم الوظيفي <span class="spanReqired-w">*</span></label>
+                      <input type="phone" class="form-control" id="functionalNumber" [ngModel]="reportAuthor.functional_number" [ngModelOptions]="{standalone: true}"/>
+                    </div>
+                  </div>
+                  <div class="col-12 col-md-4">
+                    <div class="form-group">
+                      <label for="phone" style="float:right">الهاتف<span class="spanReqired-w">*</span></label>
+                      <input type="phone" class="form-control" id="phone" [ngModel]="reportAuthor.phone" [ngModelOptions]="{standalone: true}"/>
+                    </div>
+                  </div>
+                </div>
+              </div>
+            </div>
+          </div>
+
           <div class="col-12">
             <h2 class="title">بيانات مقدم البلاغ</h2>
             <div class="row">

+ 42 - 4
src/app/dashboard/create-report/add-new-report/add-new-report.component.ts

@@ -38,6 +38,16 @@ export class AddNewReportComponent implements OnInit {
     disabledVal: boolean = true;
     serviceId: number;
     userId: number;
+    search: any;
+
+    reportAuthor = {
+      name: '',
+      identity_number: '',
+      functional_number: '',
+      phone: '',
+      id: null,
+    };
+
 
     files = [{
       title : null,
@@ -48,6 +58,7 @@ export class AddNewReportComponent implements OnInit {
 
     dataForm = {
       id_number: '',
+      user_id: null,
       name : '',
       phoneNum: '',
       created_date : "",
@@ -61,9 +72,10 @@ export class AddNewReportComponent implements OnInit {
 
 
   currentDate: any = Date.now();
+  departmentUserLoginId: number;
 
        //higri date array
-  month = ['محرم', 'صفر', 'ربيع الأول', 'ربيع الآخر', 'جمادى الأولى', 'جمادى الآخرة', 'رجب', 'Shaʻban', 'رمضان', 'شوال',
+  month = ['محرم', 'صفر', 'ربيع الأول', 'ربيع الآخر', 'جمادى الأولى', 'جمادى الآخرة', 'رجب', 'Shaʻban', 'Ramadan', 'شوال',
   'ذو القعدة', 'ذو الحجة'];
 
 
@@ -146,7 +158,9 @@ export class AddNewReportComponent implements OnInit {
       (responce) => {
        this.dataForm.id_number = responce['user'].identity_number;
        this.dataForm.name = responce['user'].name;
-       this.dataForm.phoneNum = responce['user'].phone
+       this.dataForm.phoneNum = responce['user'].phone;
+       this.departmentUserLoginId = responce['user'].adminstration_id;
+       this.dataForm.user_id = responce['user'].id;
        console.log('dsf',responce)
       },
       (error) => {console.log(error)},
@@ -201,6 +215,28 @@ export class AddNewReportComponent implements OnInit {
       console.log(this.files);
       console.log('files after change ',this.files);
   }
+
+  //onSearchChange function
+  getValue() {
+    console.log(this.search);
+    this.http.get(this.authService.pathApi + '/find_user/' + this.search).subscribe(
+      (response) => {
+        console.log(response);
+        if(response['user'] != null) {
+          this.reportAuthor.name = response['user'].name;
+          this.reportAuthor.phone = response['user'].phone;
+          this.reportAuthor.identity_number = response['user'].identity_number;
+          this.reportAuthor.functional_number = response['user'].functional_number;
+          this.reportAuthor.id = response['user'].id;
+        } else {
+          this.toastr.warning('لا يوجد مستخدم')
+        }
+      },
+      (error) => {
+        console.log(error);
+      }
+    )
+  }
   
   onSubmitted(){
     for (let i = 0; i < this.files.length; i++) {
@@ -218,8 +254,6 @@ export class AddNewReportComponent implements OnInit {
        delete this.files[i].nameFile;
         this.dataForm.files.push(this.files[i]);
       }
-
-      
     }
     if(!this.checked){
       delete this.dataForm.id_number;
@@ -228,6 +262,10 @@ export class AddNewReportComponent implements OnInit {
       if(this.dataForm.files.length == 0 ){
         delete this.dataForm.files;
       }
+
+      if(this.reportAuthor.id) {
+        this.dataForm.user_id = this.reportAuthor.id
+      } 
     console.log(this.dataForm);
    this.http.post(this.authService.pathApi + '/add_communication' , this.dataForm )
       .subscribe(