ソースを参照

cretaed second contact for dvr

AnilBwavhal 1 ヶ月 前
コミット
eb1e6c0e81

+ 25 - 9
src/app/createentry/dvrentry.component.html

@@ -169,8 +169,7 @@
 
                       <div class="form-group" [ngClass]="displayFieldCss('nextstep')">
                         <label style="font-size: 16px;margin-top: 5px;margin-bottom: 0px;">Next Action
-                          <span
-                            style="color: red;"> *</span></label>
+                          <span style="color: red;"> *</span></label>
                         <textarea type="text" name="First Name" formControlName="nextstep" class="textarea" id="user"
                           onkeyup="this.setAttribute('value', this.value);" value=""
                           style="margin: 25px 0;padding: 14px;height:auto !important;border-bottom: 2px solid #e0e0e0 !important;margin-top: -2px;padding: 0px;margin-left: -2px;"></textarea>
@@ -181,6 +180,8 @@
 
                     </div>
 
+
+
                   </div>
 
 
@@ -202,6 +203,22 @@
 
 
                 </div>
+                <div class="col-lg-4" style="margin-top:38px;margin-left: 60px;">
+                  <div class="form-group" style="margin-bottom:2px" [ngClass]="displayFieldCss('secondContact')">
+                    <label style="font-size: 16px;margin-top: 5px;margin-bottom: 0px;"> Second Contact<span
+                        style="color: red;"> *</span></label>
+
+                    <select id="Axis" (change)="contactDetails(contactEntryForm)" class="form-control"
+                      formControlName='secondContact' style="margin-top: 0px;">
+                      <option><a href="" (click)="contactDetails(contactEntryForm)"
+                          style="cursor: pointer;color: #7f7f7f;"> Add New Contact</a></option>
+                      <option *ngIf="second_contact" default disabled>{{second_contact}}</option>
+                      <option *ngFor="let second_contact of contact_data" [ngValue]="second_contact">
+                        {{ second_contact.first_name }} {{ second_contact.last_name }}
+                      </option>
+                    </select>
+                  </div>
+                </div>
 
 
               </div>
@@ -223,13 +240,6 @@
                     (click)="(contactEntryForm.reset({}));addUser()">
                 </div>
 
-
-
-
-
-
-
-
               </div>
 
 
@@ -301,10 +311,13 @@
                 <th>Date of Visit</th>
                 <th>Customer Name</th>
                 <th>Contact Name</th>
+                <th>Second Contact</th>
+                <th>Next Action</th>
                 <th>Physical Meeting</th>
                 <th>Message</th>
                 <th>Status</th>
 
+
               </tr>
             </thead>
 
@@ -313,10 +326,13 @@
                 <td>{{current.date_of_visit | datePipe}}</td>
                 <td>{{current.customer_name }}</td>
                 <td>{{current.contact_name }}</td>
+                <td>{{current.second_contact }}</td>
+                <td>{{current.nextstep }}</td>
                 <td>{{current.physical_meeting | titlecase}}</td>
                 <td>{{current.message }}</td>
                 <td>{{current.stage_desc }}</td>
 
+
               </tr>
             </tbody>
           </table>

+ 99 - 52
src/app/createentry/dvrentry.component.ts

@@ -52,9 +52,9 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
   role: any;
   check_date: any;
 
-  nextstep:any;
+  nextstep: any;
 
-   checkupdatedelete:boolean;
+  checkupdatedelete: boolean;
   saveautoData = [];
   autofillData = [];
 
@@ -64,6 +64,7 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
 
 
   entry_successflag: boolean = false;
+  second_contact: any;
 
   constructor(private commonservice: CommonFunctionService, private router: Router, private http: HttpClient) {
 
@@ -103,11 +104,12 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
         this.stage_des = response.data[0].stage_desc;
         this.stage_id = response.data[0].stage_id;
         this.check_date = response.data[0].created_on;
-        this.nextstep=response.data[0].nextstep;
+        this.nextstep = response.data[0].nextstep;
+        this.second_contact = response.data[0].second_contact;
         //this.visit_date = datePipetransform(this.visit_date.now(),'dd/MM/yyyy');
         this.visit_date = this.formatDate(this.visit_date);
-        this.check_date=this.formatDate(this.check_date);
-      
+        this.check_date = this.formatDate(this.check_date);
+
         this.visit_date = String(this.visit_date)
         console.log(" this.visit_date", this.visit_date, this.customer_name, this.contact_name, this.stage_des);
         console.log("in updatation");
@@ -120,34 +122,35 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
           stageName: new FormControl(this.stage_des, Validators.required),
           ph_meet: new FormControl('yes', Validators.required),
           nextstep: new FormControl(this.nextstep, Validators.required),
+          secondContact: new FormControl(this.second_contact, Validators.required)
 
 
         });
         console.log("this.check_date", this.check_date);
-        
+
         var date1 = new Date(this.check_date);
         var date2 = new Date();
-          
+
         // To calculate the time difference of two dates
         var Difference_In_Time = date2.getTime() - date1.getTime();
-          
+
         // To calculate the no. of days between two dates
         var Difference_In_Days = Difference_In_Time / (1000 * 3600 * 24);
-    
-        console.log("Difference_In_Days---->",Math.round(Difference_In_Days));
 
-        if(Math.round(Difference_In_Days) <= 1){
+        console.log("Difference_In_Days---->", Math.round(Difference_In_Days));
+
+        if (Math.round(Difference_In_Days) <= 1) {
           console.log("differnt in one days");
-          this.checkupdatedelete=true;
+          this.checkupdatedelete = true;
 
-        }else{
-            console.log("difference is longer");
-            this.checkupdatedelete=false;
-            // this.FormControl['name'].disable();
+        } else {
+          console.log("difference is longer");
+          this.checkupdatedelete = false;
+          // this.FormControl['name'].disable();
 
 
         }
-       
+
       });
 
 
@@ -168,6 +171,8 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
         stageName: new FormControl(null, Validators.required),
         ph_meet: new FormControl('yes', Validators.required),
         nextstep: new FormControl(null, Validators.required),
+        secondContact: new FormControl(null, Validators.required)
+
 
       });
 
@@ -196,7 +201,7 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
 
     this.current_date = new Date();
     var dd = this.current_date.getDate();
-    var mm = this.current_date.getMonth() + 1; 
+    var mm = this.current_date.getMonth() + 1;
     var yyyy = this.current_date.getFullYear();
     if (dd < 10) {
       dd = '0' + dd
@@ -205,7 +210,7 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
       mm = '0' + mm
     }
     this.current_date = yyyy + '-' + mm + '-' + dd;
-    console.log("max date------>",this.current_date);
+    console.log("max date------>", this.current_date);
 
     document.getElementById("Date").setAttribute("max", this.current_date);
 
@@ -214,22 +219,22 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
     //console.log("dddddddd------->", this.current_date.getDate() - 7);
 
     var date = dd - 7;
-    console.log("date====>",date);
+    console.log("date====>", date);
 
     if (date < 10) {
       dd1 = '0' + date;
-    }else{
-      dd1=date;
+    } else {
+      dd1 = date;
     }
 
-    console.log("dd1-------->",dd1)
+    console.log("dd1-------->", dd1)
+
 
-   
     this.mincurrent_date = yyyy + '-' + mm + '-' + dd1;
     document.getElementById("Date").setAttribute("min", this.mincurrent_date);
-    
 
-   
+
+
 
 
 
@@ -317,6 +322,8 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
         custName: new FormControl(this.customer_name, Validators.required),
         stageName: new FormControl(this.stage_des, Validators.required),
         nextstep: new FormControl(this.autofillData["nextstep"], Validators.required),
+        secondContact: new FormControl(this.second_contact, Validators.required),
+
 
       });
     }
@@ -355,6 +362,8 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
         stageName: new FormControl(this.stage_des, Validators.required),
         ph_meet: new FormControl(this.autofillData["ph_meet"], Validators.required),
         nextstep: new FormControl(this.autofillData["nextstep"], Validators.required),
+        secondContact: new FormControl(this.second_contact, Validators.required),
+
 
       });
     }
@@ -409,6 +418,10 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
       } if (form.value.stageName.length == undefined) {
         console.log("change stage id");
         this.stage_id = form.value.stageName.stage_id;
+      } if (form.value.secondContact.length == undefined) {
+        console.log("change contactname", form.value.secondContact);
+        this.second_contact = form.value.secondContact.first_name + '  ' + form.value.secondContact.last_name;
+        console.log("contact name", this.second_contact);
       }
 
       const createdvr = {
@@ -420,7 +433,8 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
         physical_metting: form.value.ph_meet,
         stage_id: this.stage_id,
         updated_by: this.login_id,
-        nextstep: form.value.nextstep
+        nextstep: form.value.nextstep,
+        second_contact: this.second_contact
 
       }
 
@@ -467,19 +481,22 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
       //in insert
       var createdvr;
       console.log("this.stage_id", this.stage_id);
+      console.log("this.second_contact",this.second_contact,form.value.secondContact);
 
       if (this.stage_id == undefined) {
 
         createdvr = {
           visit_date: form.value.date,
           customer_name: (this.customer_name == undefined ? form.value.custName.customer_name : this.customer_name),
-          contact_name: (this.contact_name == undefined ? form.value.contactName.first_name +' '+form.value.contactName.last_name : this.contact_name),
+          contact_name: (this.contact_name == undefined ? form.value.contactName.first_name + ' ' + form.value.contactName.last_name : this.contact_name),
           message: form.value.message,
           physical_metting: form.value.ph_meet,
           sale_person: this.username,
           stage_id: (form.value.stageName ? form.value.stageName.stage_id : ''),
           created_by: this.login_id,
-          nextstep: form.value.nextstep
+          nextstep: form.value.nextstep,
+          second_contact: (this.second_contact == undefined ? form.value.secondContact.first_name + ' ' + form.value.secondContact.last_name : this.second_contact),
+
 
         }
       } else {
@@ -493,7 +510,9 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
           sale_person: this.username,
           stage_id: this.stage_id,
           created_by: this.login_id,
-          nextstep: form.value.nextstep
+          nextstep: form.value.nextstep,
+          second_contact: (this.second_contact == undefined ? form.value.secondContact.first_name + form.value.secondContact.last_name : this.second_contact),
+
 
         }
       }
@@ -528,6 +547,7 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
             this.contact_name = "";
             this.stage_id = "";
             this.stage_des = "";
+            this.second_contact = "";
             localStorage.removeItem("autofilldata")
             this.contactEntryForm = new FormGroup({
               date: new FormControl(null, Validators.required),
@@ -537,7 +557,7 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
               stageName: new FormControl(null, Validators.required),
               ph_meet: new FormControl('yes', Validators.required),
               nextstep: new FormControl(null, Validators.required),
-
+              secondContact: new FormControl(null, Validators.required)
             });
             // console.log("response.data.message", response.data[0].exception.errorid);
             if (response.data[0].exception.errorid != '') {
@@ -588,6 +608,7 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
     this.contact_name = "";
     this.stage_id = "";
     this.stage_des = "";
+    this.second_contact = "";
     this.contactEntryForm = new FormGroup({
       date: new FormControl(null, Validators.required),
       message: new FormControl(null, Validators.required),
@@ -596,7 +617,7 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
       stageName: new FormControl(null, Validators.required),
       ph_meet: new FormControl('yes', Validators.required),
       nextstep: new FormControl(null, Validators.required),
-
+      secondContact: new FormControl(null, Validators.required)
     });
   }
 
@@ -631,24 +652,50 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
 
     }
 
+    if (form.value.secondContact == "Add New Contact") {
+
+      if (form.value.custName == null) {
+        console.log("value not entered");
+        //user not entered customer details
+        this.router.navigate(['/contactDetails'])
+        localStorage.removeItem('autofilldata');
+
+      } else if (this.customer_name != null) {
+        this.router.navigate(["/contactDetails/contact:" + this.customer_name + "/id:" + this.cust_id]);
+      }
+      else {
+        console.log("value entered");
+        this.cust_name = form.value.custName.customer_name;
+        this.cust_id = form.value.custName.customer_id
+        this.saveautoData.push(form.value);
+        console.log("this.saveautoData", this.saveautoData)
+        localStorage.setItem('autofilldata', JSON.stringify(this.saveautoData));
+        //user entered customer details
+        this.router.navigate(["/contactDetails/contact:" + this.cust_name + "/id:" + this.cust_id]);
+      }
+    } else {
+      console.log('other options selected');
+
+    }
+
 
   }
 
-  customerDetails(form: FormGroup){
+  customerDetails(form: FormGroup) {
     console.log("form value", form.value.custName.customer_name);
-    if(form.value.custName){
-      this.commonservice.getAllData(this.commonservice.projectpath + "/getcustcontactdetails?customer_id="+form.value.custName.customer_name).subscribe(response => {
+    if (form.value.custName) {
+      this.commonservice.getAllData(this.commonservice.projectpath + "/getcustcontactdetails?customer_id=" + form.value.custName.customer_name).subscribe(response => {
         if (response.status == 'falsetoken') {
           this.router.navigate(['/login'])
         } else {
           this.contact_data = response.data[0].conrtactData;
           console.log("aaaaaaaaaaa------------>", this.contact_data);
-         // this.dtTrigger.next(this.dtOptions)
+          // this.dtTrigger.next(this.dtOptions)
 
         }
       });
 
-    }else{
+    } else {
       console.log("customer not selected yet");
     }
 
@@ -684,18 +731,18 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
     return [year, month, day].join('-');
   }
 
-  currformatDate(){
-    var d=new Date(),
-    month = '' + (d.getMonth() + 1),
-    day = '' + d.getDate(),
-    year = d.getFullYear();
+  currformatDate() {
+    var d = new Date(),
+      month = '' + (d.getMonth() + 1),
+      day = '' + d.getDate(),
+      year = d.getFullYear();
 
-  if (month.length < 2)
-    month = '0' + month;
-  if (day.length < 2)
-    day = '0' + day;
+    if (month.length < 2)
+      month = '0' + month;
+    if (day.length < 2)
+      day = '0' + day;
 
-  return [year, month, day].join('-');
+    return [year, month, day].join('-');
   }
 
 
@@ -728,11 +775,11 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
           this.error_msg = response.errors;
         } else if (response.data.length > 0) {
           console.log("inside if(response.message== '') ");
-          console.log("message",response.data[0].message);
+          console.log("message", response.data[0].message);
           this.openPopup();
           this.status_msg = "Success";
           this.error_msg = response.data[0].message;
-          console.log("this.error_msg",this.error_msg);
+          console.log("this.error_msg", this.error_msg);
           this.entry_successflag = true;
           this.customer_name = "";
           this.contact_name = "";
@@ -740,7 +787,7 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
           this.stage_des = "";
           localStorage.removeItem("contactlastinsert")
 
-          
+
           localStorage.removeItem("autofilldata")
           this.contactEntryForm = new FormGroup({
             date: new FormControl(null, Validators.required),
@@ -750,11 +797,11 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
             stageName: new FormControl(null, Validators.required),
             ph_meet: new FormControl('yes', Validators.required),
             nextstep: new FormControl(null, Validators.required),
-
+            secondContact: new FormControl(null, Validators.required)
           });
           //this.router.navigate(['/home'])
           // console.log("response.data.message", response.data[0].exception.errorid);
-         
+
         }
         else {
           this.status_msg = "";

+ 2 - 2
src/app/environments/environment.ts

@@ -1,7 +1,7 @@
 export const environment = {
- //projectpath: "http://localhost:9000/api"
+ projectpath: "http://localhost:9000/api"
  //projectpath:"http://54.225.129.95:31165",
 //projectpath:"http://52.221.194.168:8000"
-projectpath:"https://dvr.mindcraft.in/api"
+//projectpath:"https://dvr.mindcraft.in/api"
 
 }

+ 1 - 1
src/app/home/home.component.html

@@ -51,7 +51,7 @@
             <div class="col-lg-3" style="margin-bottom:6px;margin-bottom:6px">
 
 
-              <select id='saleperson'  name='saleperson' [(ngModel)]="sale_person"
+              <select id='saleperson' (change)="salepersonDetails(sale_person)" name='saleperson' [(ngModel)]="sale_person"
                 class="form-control" placeholder="Sales Person">
 
                 <option class="dropdown-item"  selected value="undefined">Sales Person</option>

+ 19 - 0
src/app/home/home.component.ts

@@ -4,6 +4,7 @@ import { Router } from '@angular/router';
 import { Subject } from 'rxjs';
 import { DataTableDirective } from 'angular-datatables';
 import { ViewChild } from '@angular/core'
+import { log } from 'console';
 
 // import * as $ from 'jquery';
 // import 'datatables.net';
@@ -1110,4 +1111,22 @@ export class HomeComponent implements OnInit {
 
   }
 
+  salepersonDetails(sale_person){
+    console.log(sale_person)
+    if (sale_person) {
+      this.commonservice.getAllData(this.commonservice.projectpath + "/mappingCustomerDetails?sale_person=" + sale_person).subscribe(response => {
+        if (response.status == 'falsetoken') {
+          this.router.navigate(['/login'])
+        } else {
+          console.log("sale_person------------>",response);
+          this.cust_data = response.data
+          console.log("respocne",response.data)
+        }
+      });
+
+    } else {
+      console.log("sale person not selected yet");
+    }
+  }
+
 }