Parcourir la source

changes on contact page - update/delete contacts for admin, designation mandatory, customer name dropdown

Devansh Vakharia il y a 2 semaines
Parent
commit
2530d1a6d8

+ 38 - 0
src/app/contact/contact.component.css

@@ -45,4 +45,42 @@ border-color: #cacdd1 !important;
 }
 th{background: #ffe8cb !important;}
 
+.form-button {
+    margin-right: 10px;   /* equal spacing between all buttons */
+}
+
+/* Match dropdown to DataTables search input */
+#CustomerFilter {
+    height: 34px !important;               /* matches DataTables input */
+    padding: 5px 8px !important;
+    font-size: 14px !important;
+    border: 1px solid #cacdd1 !important;  /* same border as input focus color */
+    border-radius: 4px !important;
+    background-color: white !important;
+    display: inline-block !important;
+    width: auto !important;
+    margin-right: 10px !important;         /* spacing between dropdown and search */
+    box-sizing: border-box !important;
+}
+
+/* Style for Excel filter row */
+#filterRow input.col-filter {
+    width: 100%;
+    padding: 4px 6px;
+    border: 1px solid #dad8d8;
+    border-radius: 3px;
+    font-size: 13px;
+    box-sizing: border-box;
+}
+
+/* On focus */
+#filterRow input.col-filter:focus {
+    border: 1px solid #a7a7a7 !important;
+    outline: none;
+}
 
+/* Keep height consistent with table */
+#filterRow th {
+    background: #fff !important;
+    padding: 3px !important;
+}

+ 91 - 60
src/app/contact/contact.component.html

@@ -50,38 +50,34 @@
                     <p class="formheader"><i class="fa fa-user" style="padding-right:10px"></i>Create new Contact</p>
                 </div>
             </div>
-            <div class=" p-4 p-md-5 pt-5">
-
-                <div class="row ">
-
-                    <div class="col-lg-12 row">
-                        <div class="col-lg-2 padding0 pt-2">
-                            <span style="color:#544f4f;font-size:14px">New Contact for:<span style="color: red;"> *</span></span>
-                        </div>
-                        <div class="col-lg-3" *ngIf="contnav_flag == true">
-                            <div class="input-group">
-
-                                <input type="text" class="form-control" name="email" [(ngModel)]="cont_name"
-                                    readonly="">
-                            </div>
-
-
-                        </div>
-                        <div class="col-lg-3" *ngIf="contnav_flag ==false">
-                            <div class="input-group">
-                                <select id="Axis" [(ngModel)]="mySelect" class="form-control"
-                                    (ngModelChange)="modo(mySelect)">
-                                    <option [ngValue]='0'>All</option>
-                                    <option *ngFor="let cust of cust_data" [ngValue]="cust">
-                                        {{ cust.customer_name }}
-                                    </option>
-
-                                </select>
-                            </div>
-
-                        </div>
-                    </div>
+<div class=" p-4 p-md-5 pt-5">
+    <div class="row ">
+        <div class="col-lg-12 row">
+            
+            <div class="col-lg-2 padding0 pt-2">
+                <span style="color:#544f4f;font-size:14px">New Contact for:<span style="color: red;"> *</span></span>
+            </div>
+            
+            <div class="col-lg-3" *ngIf="contnav_flag == true">
+                <div class="input-group">
+                    <input type="text" class="form-control" name="email" [(ngModel)]="cont_name" readonly="">
+                </div>
+            </div>
+            
+            <div class="col-lg-3" *ngIf="contnav_flag ==false">
+                <div class="input-group">
+                    <select id="Axis" [(ngModel)]="mySelect" class="form-control"
+                        (ngModelChange)="modo(mySelect)">
+                        <option [ngValue]='0'>All</option>
+                        <option *ngFor="let cust of cust_data" [ngValue]="cust">
+                            {{ cust.customer_name }}
+                        </option>
+                    </select>
                 </div>
+            </div>
+            
+        </div>
+    </div>
                 <br>
 
 
@@ -169,19 +165,20 @@
                                 
                                 <div class="col-lg-6">
 
-                                    <div class="form-group">
+                                    <!-- <div class="form-group">
                                         <input type="text" class="form-control " formControlName='designation'
                                             name="designation">
                                         <label for="Desg." class="animated-label">Designation</label>
-                                    </div>
-
-
-
-
-
-
-
+                                    </div> -->
 
+                                    <div class="form-group" [ngClass]="displayFieldCss('designation')">
+                                        <input type="text" class="form-control" formControlName='designation'
+                                            name="designation" id="designation">
+                                        <label for="Desg." class="animated-label">Designation<span style="color: red;"> *</span></label>
+                                        <app-field-error-display [displayError]="isFieldValid('designation')"
+                                            errorMsg="Please enter Designation">
+                                        </app-field-error-display>
+                                    </div>
 
                                 </div>
                             </div>
@@ -259,29 +256,35 @@
 
                             <br>
 
-                            <div class="row text-lg-right">
-                                <div class="col-lg-12 row">
-
-                                    <div class="col-lg-9 col-md-8">
-                                    </div>
-
-                                    <div class="col-lg-2 col-sm-12 col-md-2" style="margin-bottom:6px">
-
-
-
-                                        <input class="submitbutton" type="submit" value="Save">
-                                    </div>
-
-
-                                    <div class="col-lg-1 col-sm-12 col-md-2">
-                                        <input class="cancelbutton" type="reset" value="reset"
-                                            (click)="(contactForm.reset({}))">
-                                    </div>
+<div class="row text-lg-right">
+    <div class="col-lg-12 row">
+        <div class="col-lg-8 col-md-8">
+        </div>
 
+        <div class="col-lg-1 col-sm-12 col-md-2" style="margin-bottom:6px; margin-right: 12px;">
+            <!-- EDIT / UPDATE BUTTON -->
+            <button class="submitbutton" 
+                    type="button" 
+                    (click)="onEditButtonClick()" 
+                    [style.background-color]="isEditMode ? '#f9b523' : 'grey'">
+                {{ isEditMode ? 'Edit' : 'Edit' }}
+            </button>
+        </div>
 
-                                </div>
+        <div class="col-lg-1 col-sm-12 col-md-2" style="margin-bottom:6px; margin-right: 12px;">
+            <!-- SAVE / SUBMIT BUTTON -->
+            <input class="submitbutton" 
+                   type="submit" 
+                   value="Save" 
+                   [style.background-color]="!isEditMode ? '#f9b523' : 'grey'" />
+        </div>
 
-                            </div>
+        <div class="col-lg-1 col-sm-12 col-md-2" style="margin-bottom:6px;">
+            <input class="cancelbutton" type="reset" value="reset"
+                   (click)="onReset()">
+        </div>
+    </div>
+</div>
                         </fieldset>
                     </form>
 
@@ -298,11 +301,22 @@
                 <div class="col-lg-12 " style="    border: 1px solid #cbcbcb;
                 padding: 10px;
                 border-radius: 5px;overflow: auto;"  >
+<div id="customer-filter-container">
+                    <select id="CustomerFilter" [(ngModel)]="selectedCustomerFilter" class="form-control"
+                        (ngModelChange)="filterByCustomerName()">
+                        <option [ngValue]="''">All Customers</option> 
+                        <option *ngFor="let cust of cust_data" [ngValue]="cust.customer_name">
+                            {{ cust.customer_name }}
+                        </option>
+                    </select>
+</div>
+            
                     <table datatable [dtOptions]="dtOptions" [dtTrigger]="dtTrigger"
                         class="dataTable row-border hover display" cellspacing="0" width="100%"> 
 
                         <thead>
                             <tr>
+                                <th class="no-export" *ngIf="role === 'admin'" style="width:10%">Actions</th>
                                 <th style="width:15%">Customer Name</th>   
                                 <th style="width:15%">First Name</th>
                                 <th style="width:15%">Last Name</th>
@@ -321,6 +335,23 @@
 
                         <tbody>
                             <tr *ngFor="let current of contactList; let i = index">
+                                <td class="no-export" *ngIf="role === 'admin'">
+                                    <table>
+                                        <tr>
+                                            <td>
+                                        <button class="btn btn-primary btn-sm" (click)="editContact(current)">
+                                    <i class="fa fa-edit"></i>
+                                </button>
+                                            </td>
+                                            <td>
+                                <button class="btn btn-danger btn-sm" style="margin-left: 5px;" 
+                                        (click)="deleteContact(current.contact_id)">
+                                    <i class="fa fa-trash"></i>
+                                </button>
+                                            </td>
+                                        </tr>
+                                    </table>
+                            </td>
                                 <td>{{current.customer_name }}</td>
                                 <td><a routerLink="/dvrentry"
                                         (click)="getContactName(current.first_name,current.last_name)">{{current.first_name

+ 288 - 95
src/app/contact/contact.component.ts

@@ -19,7 +19,9 @@ export class ContactComponent implements OnInit {
   @ViewChild(DataTableDirective, { static: false })
   dtElement: DataTableDirective;
 
-
+// Inside your component class
+selectedCustomerFilter: string = ''; // Holds the name selected in the new filter dropdown
+// ... (Your existing properties: dtElement, dtTrigger, contactList, cust_data)
   public contactForm !: FormGroup;
   currentDateData: any = [];
 
@@ -34,7 +36,8 @@ export class ContactComponent implements OnInit {
   contnav_flag: boolean = false;
   mySelect: any;
   cont_id: any;
-
+  isEditMode: boolean = false;
+  selectedContactId: number | null = null;
   checkfirstnm_flag: boolean = false;
   checklastnm_flag: boolean = false;
   checkmobilleno_flag: boolean = false;
@@ -77,14 +80,68 @@ export class ContactComponent implements OnInit {
       ordering: false,
       dom: 'Blfrtip',
 
+      // Use initComplete to manipulate the DOM after DataTables is ready
+    initComplete: function (settings: any, json: any) {
+        
+        // Get the DataTables API instance
+        const api = new $.fn.dataTable.Api(settings);
+  const filterContainer = document.querySelector('.dataTables_filter');
+  const dropdown = document.getElementById('customer-filter-container');
+
+  if (filterContainer && dropdown) {
+    dropdown.style.display = 'inline-block';  // Align nicely
+    filterContainer.insertBefore(dropdown, filterContainer.firstChild); 
+  }
+
+
+    //     // 1. Find the search input element created by DataTables
+    //     const searchInput = $(api.table().container()).find('.dataTables_filter');
+
+    //     // 2. Find your placeholder div
+    //     const customFilterHtml = $('#CustomerFilterContainer').html(); 
+
+    //     // 3. Prepend your filter container's content (the dropdown) to the search div
+    //     // You'll need to create the container HTML (step 3)
+    //     // For now, let's use the standard search input parent.
+        
+    //     // Find the main filter div (which contains the label and input)
+    //     const filterWrapper = $(api.table().container()).find('.dataTables_filter').parent();
+        
+    //     // 4. Insert the new dropdown HTML before the search box wrapper
+    //     // NOTE: Replace the placeholder ID with the actual HTML of your filter dropdown
+    //     // This assumes you rendered the filter HTML somewhere else and are moving it.
+        
+    //     // Since it's complex to move Angular components with jQuery, a simpler client-side filter is usually done by:
+        
+    //     // Get the original placeholder element
+    //     const placeholder = $('#custom-filter-placeholder'); 
+        
+    //     // Get the search wrapper
+    //     const searchWrapper = $(api.table().container()).find('.dataTables_filter');
+        
+    //     // Move the HTML content from the placeholder into the search wrapper.
+    //     // You'll need to render the Angular select box outside and move it, OR 
+    //     // use an Angular ViewChild to access the native element.
+        
+    //     // --- RECOMMENDED ANGULAR APPROACH ---
+    //     // Access the native search input and inject the filter HTML *before* it.
+    //     // This requires access to the 'this' context, so use an arrow function.
+    },
+
       buttons: [
         {
           extend: 'print',
-          title: 'Contact Details Reports'
+          title: 'Contact Details Reports',
+          exportOptions: {
+            columns: ':not(.no-export)'
+          }
         },
         {
           extend: 'excelHtml5',
-          title: 'Contact Details Reports'
+          title: 'Contact Details Reports',
+          exportOptions: {
+            columns: ':not(.no-export)'
+          }
         }
 
       ]
@@ -150,41 +207,14 @@ export class ContactComponent implements OnInit {
 
   }
 
-  ngOnInit() {
-
-
-
-
-
 
-
-
-    this.contactList = [];
-
-
-    this.loginData.push(JSON.parse(localStorage.getItem("loginData")));
-    console.log("", this.loginData[0]["user_name"]);
-    this.login_name = this.loginData[0]["user_name"];
-    this.last_login_date = this.loginData[0]["last_loginDate"];
-    this.login_id = this.loginData[0]["user_id"];
-    this.role = this.loginData[0]["role"];
-
-    if (this.cont_name) {
+  loadData() {
+   if (this.cont_name) {
       console.log("in if")
       this.contnav_flag = true;
 
     } else {
       this.contnav_flag = false;
-      // this.commonservice.getAllData(this.commonservice.projectpath + "/getcontactdetails?role=" + this.role + "&login_id=" + this.login_id).subscribe(response => {
-      //   if (response.status == 'falsetoken') {
-      //     this.router.navigate(['/login'])
-      //   } else {
-      //     this.contactList = response.data[0].conrtactData;
-      //     console.log("aaaaaaaaaaa------------>", this.contactList);
-      //     this.dtTrigger.next(this.dtOptions)
-
-      //   }
-      // });
 
       this.commonservice.getAllData(this.commonservice.projectpath + "/getcustcontactdetails?customer_id=0&passid=number").subscribe(response => {
         if (response.status == 'falsetoken') {
@@ -192,8 +222,33 @@ export class ContactComponent implements OnInit {
         } else {
           this.contactList = response.data[0].conrtactData;
           console.log("aaaaaaaaaaa------------>", this.contactList);
-          this.dtTrigger.next(this.dtOptions)
-
+          // this.dtTrigger.next(this.dtOptions);
+          this.rerender();
+
+          // 4. 🔥 NEW STEP: Move the filter after a short delay to ensure DataTables is done
+        // setTimeout(() => {
+        //     // Find the DataTables filter search box wrapper
+        //     const dtFilterWrapper = $('.dataTables_filter');
+            
+        //     // Get the HTML content of the filter dropdown you rendered elsewhere
+        //     const filterToMove = $('#filter-to-move').html();
+
+        //     if (dtFilterWrapper.length > 0) {
+        //         // Insert the HTML content BEFORE the DataTables search box
+        //         dtFilterWrapper.prepend(filterToMove);
+                
+        //         // Re-bind the Angular function to the newly moved element
+        //         // NOTE: This requires you to ensure the (ngModelChange) binding still works 
+        //         // on the dynamically moved element, which might need Angular's Renderer2. 
+        //         // For quick jQuery fix, you'd need to re-bind the change event manually here.
+                
+        //         // --- QUICK FIX: Manual Change Event Re-binding ---
+        //         $('#CustomerFilter').on('change', (e) => {
+        //             this.selectedCustomerFilter = $(e.target).val() as string;
+        //             this.filterByCustomerName();
+        //         });
+        //     }
+        // }, 100); // Small delay
         }
       });
     }
@@ -208,8 +263,20 @@ export class ContactComponent implements OnInit {
       }
     });
 
+  }
+  
+  ngOnInit() {
 
+    this.contactList = [];
+
+    
 
+    this.loginData.push(JSON.parse(localStorage.getItem("loginData")));
+    console.log("", this.loginData[0]["user_name"]);
+    this.login_name = this.loginData[0]["user_name"];
+    this.last_login_date = this.loginData[0]["last_loginDate"];
+    this.login_id = this.loginData[0]["user_id"];
+    this.role = this.loginData[0]["role"];
 
     this.contactForm = new FormGroup({
       first_name: new FormControl('', Validators.required),
@@ -221,10 +288,18 @@ export class ContactComponent implements OnInit {
       function: new FormControl('', Validators.required),
       mob_no: new FormControl('', [Validators.required, Validators.maxLength(10)])
     })
+
+    this.loadData();
   }
+  
 
   contactData(form: FormGroup) {
 
+    console.log(this.isEditMode);
+    if (this.isEditMode) {
+      console.log("EDITING");
+      return;
+    }
     this.msg = "";
 
     console.log("first name", form.value.first_name);
@@ -251,6 +326,7 @@ export class ContactComponent implements OnInit {
     if (this.cont_name) {
 
       console.log("get from url")
+      console.log(this.cont_id);
       const contactData = {
         first_name: form.value.first_name,
         last_name: form.value.last_name,
@@ -476,17 +552,131 @@ export class ContactComponent implements OnInit {
 
   }
 
+onEditButtonClick() {
+    if (this.isEditMode) {
+        this.updateContact();
+    }
+}
+
+updateContact() {
+
+  console.log("Updating");
+
+    if (!this.selectedContactId) return;
+
+    const updatedData = this.contactForm.value;
+    updatedData.contact_id = this.selectedContactId;
+    updatedData.customer_id = (this.mySelect ? this.mySelect.customer_id : '');
+    updatedData.updated_by = this.login_id;
+    console.log(updatedData);
+
+    this.commonservice.updateContact(this.commonservice.projectpath + "/updateContactDetails", updatedData).subscribe(
+      response => {
+      if (response.status == 'tokenfalse') {
+        this.router.navigate(['/login'])
+      } 
+      else if (response.updateContactStatus == 0) {
+        console.log("Contact Updated");
+        alert("Contact updated successfully!");
+        this.isEditMode = false;
+        this.selectedContactId = null;
+        this.contactForm.reset();
+        this.loadData();
+      }
+      else {
+          const msg = response.message || response.errors;
+            alert("Error updating contact!  " + msg);
+        }
+    });
+}
+
+  editContact(contact: any) {
+    this.isEditMode = true;
+    this.selectedContactId = contact.contact_id;
+    console.log(this.selectedContactId);
+
+    this.contactForm.patchValue({
+        first_name: contact.first_name,
+        last_name: contact.last_name,
+        email_Id: contact.email_id,
+        mobile_number: contact.mobile_number,
+        mob_no: contact.mob_no,
+        designation: contact.designation,
+        department: contact.department,
+        function: contact.function_area
+    });
+
+    const nameToSelect = contact.customer_name;
+    const selected = this.cust_data.find(c => c.customer_name === nameToSelect);
+    console.log(selected);
+
+    if (selected) {
+      this.mySelect = selected;
+    }
+
+    // Scroll to top where the form is
+    window.scrollTo({ top: 0, behavior: 'smooth' });
+}
+
+deleteContact(contact_id: any) {
+  console.log(contact_id);
+  // deleteData.updated_by = this.login_id;
+  // deleteData.contact_id = this.selectedContactId;
+    if (confirm("Are you sure you want to delete this contact?")) {
+      this.commonservice.deleteContact(this.commonservice.projectpath + "/deleteContactDetails", this.login_id, contact_id).subscribe(
+      response => {
+      if (response.status == 'tokenfalse') {
+        this.router.navigate(['/login'])
+      } 
+      else if (response.deleteContactStatus == 0) {
+        console.log("Contact Deleted");
+        alert("Contact deleted successfully!");
+        this.loadData();
+      }
+      else {
+          const msg = response.message || response.errors;
+            alert("Error updating contact!  " + msg);
+        }
+    });
+    }
+}
 
   resetForm() {
     this.msg = "";
   }
 
+  onReset() {
+  this.contactForm.reset();
+  this.isEditMode = false;
+}
+
+rerender(): void {
+  // 1. Check if the DataTables instance exists
+  if (this.dtElement && this.dtElement.dtInstance) { // Added check for dtElement itself
+    this.dtElement.dtInstance.then((dtInstance: DataTables.Api) => {
+      // 2. **DESTROY:** Destroy the existing table instance
+      dtInstance.destroy();
+      
+      // 3. **TRIGGER:** Call .next() on the trigger subject 
+      //    to re-initialize the table with the new data source.
+      this.dtTrigger.next(null);
+    });
+  } else {
+    // If the table hasn't been rendered yet, just trigger the first render
+    this.dtTrigger.next(null);
+  }
+}
 
   onBack() {
     console.log("back dvr page");
     this.router.navigate(['/dvrentry'])
   }
 
+  ngOnDestroy(): void {
+    // Essential to prevent memory leaks with RxJS Subject
+    this.dtTrigger.unsubscribe();
+}
+
   clearForm() {
     // this.form.reset();
   }
@@ -538,71 +728,74 @@ export class ContactComponent implements OnInit {
     return true;
   }
 
-  modo(value: any) {
-    this.dtElement.dtInstance.then((dtInstance: DataTables.Api) => {
-      // Destroy the table first
-      dtInstance.destroy();
-      // Call the dtTrigger to rerender again
-    });
-
-    console.log("data---->", value);
-    console.log("customer_id", value.customer_id);
-
-    var id;
-    if (value.customer_id != undefined) {
-      console.log("specific customer contact");
-      id = parseInt(value.customer_id);
-      console.log("parseInt", typeof (id));
+  // Inside your component class
+
+// ✅ NEW FUNCTION FOR CLIENT-SIDE FILTERING
+filterByCustomerName(): void {
+    if (this.dtElement && this.dtElement.dtInstance) {
+        this.dtElement.dtInstance.then((dtInstance: DataTables.Api) => {
+            
+            const filterValue = this.selectedCustomerFilter; 
+            const customerNameColumnIndex = this.role === 'admin' ? 1 : 0; // Index 1 is 'Customer Name' based on your template
+            
+            // Use DataTables API to search the specific column
+            dtInstance
+                .column(customerNameColumnIndex) 
+                .search(filterValue) 
+                .draw();
+                
+            console.log(`Table filtered by Customer Name: ${filterValue}`);
+        });
+    }
+}
 
+// ❌ MODIFIED modo() - REMOVE ALL DATATABLES/API LOGIC
+modo(value: any) {
+    // Keep only the logic related to the form/flags (e.g., cont_name, contnav_flag)
+    
+    // Check if the value is being used for other purposes (like form setup)
+    if (value && value.customer_id != undefined) {
+      console.log("Customer selected for form context.");
     } else {
-      console.log("in all customer data");
-      id = value;
+      console.log("All customers selected for form context.");
     }
 
+    this.mySelect = value;
+    console.log(this.mySelect);
+    
+    // Do NOT call API, destroy table, or call dtTrigger.next() here.
+    // The table data is now handled by loadData() once.
+}
 
-
-    this.commonservice.getAllData(this.commonservice.projectpath + "/getcustcontactdetails?customer_id=" + id + "&passid=number").subscribe(response => {
-      if (response.status == 'falsetoken') {
-        this.router.navigate(['/login'])
-      } else {
-
-        this.dtTrigger.next(this.dtOptions)
-
-        //console.log("check length",response.data[0]);
-        if (response.data[0].getdvrDataStatus == '1') {
-          //data not found
-          this.contactList = [];
-          console.log("in dataa not found");
-          $(document).ready(function () {
-            $('.odd').show();
-
-          });
-
-
-        } else {
-          console.log("in data");
-
-          this.contactList = response.data[0].conrtactData;
-          //this.dtTrigger1.next(this.dtOptions1)
-
-          // document.getElementById("myH1").style.display = "none";
-
-          $(document).ready(function () {
-            $('.odd').hide()
-          });
-
-
-
-
-        }
-
-        console.log("aaaaaaaaaaa", this.contactList);
-      }
-    });
-
-
-
-  }
+// modo(value: any) {
+//     var id;
+//     // Determine the customer ID
+//     if (value && value.customer_id != undefined) {
+//         id = parseInt(value.customer_id);
+//     } else {
+//         id = 0; // Assuming '0' is the value for 'All'
+//     }
+
+//     // 1. Call the API to get the new, filtered data
+//     this.commonservice.getAllData(this.commonservice.projectpath + "/getcustcontactdetails?customer_id=" + id + "&passid=number").subscribe(response => {
+//         if (response.status == 'falsetoken') {
+//             this.router.navigate(['/login']);
+//         } else {
+//             // 2. Assign the new data
+//             if (response.data[0].getdvrDataStatus == '1') {
+//                 this.contactList = [];
+//             } else {
+//                 this.contactList = response.data[0].conrtactData;
+//             }
+            
+//             // 3. 🔥 CALL THE ROBUST RERENDER METHOD
+//             this.rerender(); // This handles the destroy and re-trigger
+//         }
+//     });
+    
+//     // ❌ REMOVE THE DESTROY CALLS OUTSIDE THE SUBSCRIBE
+//     // ❌ REMOVE THE dtTrigger.next(this.dtOptions) INSIDE THE SUBSCRIBE
+// }
 
 
   getContactName(first_name: any, last_name: any) {

+ 67 - 0
src/app/services/commonfunctions.service.ts

@@ -118,6 +118,73 @@ export class CommonFunctionService {
 
   }
 
+  updateContact(url: string, json: any) {
+        var headers = new HttpHeaders();
+    console.log("url---->", url);
+    headers = headers.append("Content-Type", "application/json")
+    headers = headers.append("Access-Control-Allow-Origin", '*')
+
+    var urlfind = url.includes("loginuser") || url.includes("changepassword");
+    if (urlfind) {
+      console.log("login url");
+      let abc: any;
+      abc = this.http.put(url, json, { headers: headers });
+
+      return abc;
+
+    } else {
+      console.log("other url");
+      var gettoken = localStorage.getItem("tokenkey");
+
+      console.log("url---->", url);
+      headers = headers.append("token", gettoken);
+
+      console.log(headers.get('token'));
+
+      //headers.append('token', gettoken);
+      console.log("headers", { headers: headers })
+      let abc: any;
+      abc = this.http.put(url, json, { headers: headers });
+
+      return abc;
+
+    }
+  }
 
+  deleteContact(url: string, login_id: string, contact_id: any) {
+    var headers = new HttpHeaders();
+    console.log("url---->", url);
+    headers = headers.append("Content-Type", "application/json")
+    headers = headers.append("Access-Control-Allow-Origin", '*')
+
+    var urlfind = url.includes("loginuser") || url.includes("changepassword");
+    if (urlfind) {
+      console.log("login url");
+      let abc: any;
+      abc = this.http.delete(url, { headers: headers, 
+        body: { updated_by: login_id, contact_id: contact_id } 
+      });
+
+      return abc;
+
+    } else {
+      console.log("other url");
+      var gettoken = localStorage.getItem("tokenkey");
+
+      console.log("url---->", url);
+      headers = headers.append("token", gettoken);
+
+      console.log(headers.get('token'));
+
+      //headers.append('token', gettoken);
+      console.log("headers", { headers: headers })
+      let abc: any;
+      abc = this.http.delete(url, { headers: headers, 
+        body: { updated_by: login_id, contact_id: contact_id } 
+      });
+
+      return abc;
+    }
+  }
 
 }

+ 2 - 1
src/assets/css/style.css

@@ -8874,4 +8874,5 @@ font-size: 17px !important;
 #customer{
   font-size: 15px !important;
   
-}
+}
+