Browse Source

changes of 02012026

Devansh Vakharia 4 days ago
parent
commit
37eeda9b76

+ 9 - 14
src/app/contact/contact.component.html

@@ -200,26 +200,22 @@
 
                                 </div>
                                 <div class="col-lg-3">
-
-                                    <label class="animated-label">Department<span style="color: red;"> *</span></label>
-
-                                    <!-- <div class="form-group">
-                                        <input type="text" class="form-control " formControlName='department'
-                                            name="department">
-                                        <label for="Dept." class="animated-label">Department</label>
-                                    </div> -->
-                                    <select id="Axis" class="form-control" formControlName='department'
+                                    <!-- <label class="animated-label">Department<span style="color: red;"> *</span></label> -->
+                                    <div class="form-group">
+                                        <input type="text" class="form-control " formControlName='department' name="department">
+                                        <label class="animated-label">Department<span style="color: red;"> *</span></label>                                        
+                                    </div>
+                                    <!-- <select id="Axis" class="form-control" formControlName='department'
                                         style="margin-top: 0px;">
                                         <option value="IT">IT</option>
                                         <option value="Procurement">Procurement</option>
                                         <option value="Finance">Finance</option>
                                         <option value="Business">Business</option>
-                                    </select>
+                                    </select> -->
                                     <app-field-error-display [displayError]="isFieldValid('department')"
                                         errorMsg="Please enter Department">
                                     </app-field-error-display>
 
-
                                 </div>
                                 <div class="col-lg-3">
                                     <div class="form-group">
@@ -266,9 +262,8 @@
 
         <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()" 
+            <button class="submitbutton" *ngIf="role === 'admin'"
+                    type="button" (click)="onEditButtonClick()" 
                     [style.background-color]="isEditMode ? '#f9b523' : 'grey'">
                 {{ isEditMode ? 'Edit' : 'Edit' }}
             </button>

+ 3 - 3
src/app/contact/contact.component.ts

@@ -598,7 +598,7 @@ $(document).on('click', function () {
                   console.log("duplicate contact");
                    this.openPopup();
                     this.status_msg = "Warning";
-                    this.error_msg = response.data[0].exception.errormessage;
+                    this.error_msg = response.data[0].exception.errormessage || response.error;
                 } else {
                   this.openPopup();
                   this.status_msg = "Success";
@@ -672,7 +672,7 @@ updateContact() {
         this.loadData();
       }
       else {
-          const msg = response.message || response.errors;
+          const msg = response.message || response.error;
             alert("Error updating contact!  " + msg);
         }
     });
@@ -722,7 +722,7 @@ deleteContact(contact_id: any) {
         this.loadData();
       }
       else {
-          const msg = response.message || response.errors;
+          const msg = response.message || response.error;
             alert("Error updating contact!  " + msg);
         }
     });

+ 11 - 4
src/app/createentry/dvrentry.component.html

@@ -266,7 +266,7 @@
 
                     <div class="col-lg-4" style="margin-top:38px;">
                       <div class="form-group">
-                        <label style="font-size: 16px; margin-top: 5px; margin-bottom: 5px;"> Next Action On:</label>
+                        <label style="font-size: 16px; margin-top: 5px; margin-bottom: 5px;"> Next Action On:</label><span style="color: red;"> *</span>
                         <select id="function" class="form-control" formControlName="postion" (change)="funcPersonDetails(contactEntryForm)"
                           style="margin: 6px;margin-top: 0px;">
                           <option value="" disabled selected>Choose Function</option>
@@ -283,6 +283,12 @@
                             {{ person.person_name }}
                           </option>
                         </select>
+                        <app-field-error-display [displayError]="isFieldValid('postion')"
+                          errorMsg="Please select Function">
+                        </app-field-error-display>
+                        <app-field-error-display [displayError]="isFieldValid('personData')"
+                          errorMsg="Please select Position">
+                        </app-field-error-display>
 
                       </div>
                     </div>
@@ -308,8 +314,7 @@
 
                   <input class="submitbutton" type="submit" value="Save" style="margin-right:15px">
 
-                  <input class="cancelbutton" type="submit" value="reset"
-                    (click)="(contactEntryForm.reset({}));addUser()">
+                  <input class="cancelbutton" type="reset" value="reset" (click)="onReset()">
                 </div>
 
               </div>
@@ -383,8 +388,9 @@
                 <th>Date of Visit</th>
                 <th>Customer Name</th>
                 <th>Contact Name</th>
+                <th>Mobile Number</th>
                 <th>Second Contact</th>
-                <th >Next Action</th>
+                <th>Next Action</th>
                 <th>Physical Meeting</th>
                 <th >Message</th>
                 <th>Status</th>
@@ -404,6 +410,7 @@
                 <td>{{current.date_of_visit | datePipe}}</td>
                 <td>{{current.customer_name }}</td>
                 <td>{{current.contact_name }}</td>
+                <td>{{current.mobile_number }}</td>
                 <td>{{current.second_contact }}</td>
                 <!-- <td style="    width: 85%;
              

+ 12 - 9
src/app/createentry/dvrentry.component.ts

@@ -528,14 +528,14 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
         if (response.status == 'falsetoken') {
           this.router.navigate(['/login'])
         } else {
-          console.log("response.error", response.errors);
+          console.log("response.error", response.error);
           console.log("response.data", response.data[0]);
 
           if (response.data.length == 0) {
             //warning 
             this.openPopup();
             this.status_msg = "Warning";
-            this.error_msg = response.errors;
+            this.error_msg = response.error;
           } else if (response.data.length > 0) {
             console.log("inside if(response.message== '') ")
             this.openPopup();
@@ -546,7 +546,7 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
             // if (response.data[0].exception.errorid != '') {
             //   this.openPopup();
             //   this.status_msg = "Warning";
-            //   this.error_msg = response.errors;
+            //   this.error_msg = response.error;
             // }
           }
           else {
@@ -569,8 +569,8 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
 
         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),
+          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),
           message: form.value.message,
           physical_metting: form.value.ph_meet,
           sale_person: this.username,
@@ -618,14 +618,14 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
         if (response.status == 'falsetoken') {
           this.router.navigate(['/login'])
         } else {
-          console.log("response.error", response.errors);
+          console.log("response.error", response.error);
           console.log("response.data", response.data.length);
 
           if (response.data.length == 0) {
             //warning 
             this.openPopup();
             this.status_msg = "Warning";
-            this.error_msg = response.errors;
+            this.error_msg = response.error;
           } else if (response.data.length > 0) {
             console.log("inside if(response.message== '') ");
             localStorage.removeItem("contactlastinsert")
@@ -665,7 +665,7 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
             if (response.data[0].exception.errorid != '') {
               this.openPopup();
               this.status_msg = "Warning";
-              this.error_msg = response.errors;
+              this.error_msg = response.error;
             }
           }
           else {
@@ -701,6 +701,9 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
 
   }
 
+  onReset() {
+    this.contactEntryForm.reset();
+  }
 
 
   addUser() {
@@ -885,7 +888,7 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
           console.log("in warning")
           this.openPopup();
           this.status_msg = "Warning";
-          this.error_msg = response.errors;
+          this.error_msg = response.error;
         } else if (response.data.length > 0) {
           console.log("inside if(response.message== '') ");
           console.log("message", response.data[0].message);

+ 12 - 0
src/app/customer/customer.component.css

@@ -80,3 +80,15 @@ th{background: #ffe8cb !important;}
   font-size: 22px;
   cursor: pointer;
 }
+
+.sort-btn {
+  padding: 0 4px;
+  background: none;
+  border: none;
+  cursor: pointer;
+  font-size: 12px;
+}
+
+.sort-btn:hover, .filter-btn:hover {
+  color: #007bff;
+}

+ 5 - 5
src/app/customer/customer.component.html

@@ -236,7 +236,7 @@
                         <thead>
                             <tr>
                                 <th class="no-export" style="width:15%">Actions</th>
-                                <th style="width:15%">Sr. No.</th>
+                                <!-- <th style="width:15%">Sr. No.</th> -->
                                 <th style="width:15%">Customer Name</th>
                                 <th style="width:15%">Customer Status</th>
                                 <th style="width:15%;">Sales Person Name</th>
@@ -249,21 +249,21 @@
                                 <td class="no-export">
                                     <table>
                                         <tr>
-                                            <td>
+                                            <!-- <td> -->
                                                 <button class="btn btn-primary btn-sm" (click)="editCustomer(current)">
                                                     <i class="fa fa-edit"></i>
                                                 </button>
-                                            </td>
+                                            <!-- </td>
                                             <td>
                                                 <button class="btn btn-danger btn-sm" style="margin-left: 5px;" 
                                                     (click)="deleteCustomer(current)" disabled>
                                                     <i class="fa fa-trash"></i>
                                                 </button>
-                                            </td>
+                                            </td> -->
                                         </tr>
                                     </table>
                                 </td>
-                                <td>{{i+1 }}</td>
+                                <!-- <td>{{i+1 }}</td> -->
                                 <td>{{current.customer_name }}</td>
                                 <td>{{current.customer_status}}</td>
                                 <td>{{current.first_name}} {{current.last_name}}</td>

+ 119 - 8
src/app/customer/customer.component.ts

@@ -62,14 +62,125 @@ export class CustomerComponent implements OnInit {
 
 
     this.dtOptions = {
-      paging: true,
+      // paging: true,
       pagingType: 'full_numbers',
       pageLength: 15,
       processing: true,
       order: [],
       lengthMenu: [15, 25, 35],
-      ordering: false,
+      ordering: true,
       dom: 'Blfrtip',
+      initComplete: function(settings: any, json: any) {
+  const api = new $.fn.dataTable.Api(settings);
+
+  // Add filter row for spacing (optional)
+  const tableHeader = $(settings.nTable).find('thead');
+  if (!tableHeader.find('.filter-row').length) {
+    tableHeader.append('<tr class="filter-row"></tr>');
+  }
+  const filterRow = tableHeader.find('.filter-row');
+
+  api.columns().every(function () {
+    const column = this;
+    const colIndex = column.index();
+    const header = $(column.header());
+    const colName = header.text().trim(); // get column name text
+
+    // --- SORT BUTTON (always added) ---
+    // const sortBtn = $('<button class="sort-btn"></button>');
+    const sortBtn = $('<button class="sort-btn" style="margin-left:4px;border:none;background:none;cursor:pointer;font-size:12px;"></button>');
+
+    let sortState = 0;
+    sortBtn.on('click', function () {
+      // if (sortState === 0) { api.order([colIndex,'asc']).draw(); sortBtn.text('▲'); sortState = 1; }
+      // else if (sortState === 1) { api.order([colIndex,'desc']).draw(); sortBtn.text('▼'); sortState = 2; }
+      // else { api.order([]).draw(); sortBtn.text('⬍'); sortState = 0; }
+    });
+    header.append(sortBtn);
+
+    // --- Skip filter if column is in skip list ---
+    // if (skipFilterCols.includes(colIndex) || header.hasClass('no-export')) return;
+    // Skip filter if column is in skipFilterCols or has 'no-export' class
+    if (header.hasClass('no-export')) return;
+
+    // --- FILTER BUTTON AND DROPDOWN ---
+    const filterBtn = $('<button type="button" class="filter-btn">⬇</button>').appendTo(header);
+    const dropdown = $('<div style="opacity: 1; background: white; overflow-y: auto; max-height: 400px;" class="floating-filter-dropdown"></div>').appendTo('body').hide();
+
+    // Unique sorted values
+    const uniqueValues = column.data()
+      .unique()
+      .toArray()
+      .filter(d => d != null && d !== '')
+      .map(d => d.toString())
+      .sort((a,b) => a.localeCompare(b));
+
+    // "All" checkbox
+    const allCheckbox = $(`
+      <div>
+        <input type="checkbox" id="all_${colIndex}" value="all" checked>
+        <label for="all_${colIndex}">All</label>
+      </div>
+    `);
+    dropdown.append(allCheckbox);
+
+    // Individual checkboxes
+    uniqueValues.forEach(val => {
+      const id = `filter_${colIndex}_${val.replace(/\s+/g,'_')}`;
+      const checkbox = $(`
+        <div>
+          <input type="checkbox" id="${id}" value="${val}" checked>
+          <label for="${id}">${val}</label>
+        </div>
+      `);
+      dropdown.append(checkbox);
+    });
+
+    // --- Checkbox handling ---
+    dropdown.on('change', 'input[type=checkbox]', function () {
+      const allChecked = allCheckbox.find('input').prop('checked');
+
+      if ($(this).val() === 'all') {
+        const checked = $(this).prop('checked');
+        dropdown.find('input[type=checkbox]').prop('checked', checked);
+      } else {
+        const total = dropdown.find('input[type=checkbox]').not('[value="all"]').length;
+        const checkedCount = dropdown.find('input[type=checkbox]:checked').not('[value="all"]').length;
+        allCheckbox.find('input').prop('checked', checkedCount === total);
+      }
+
+      const selectedValues: string[] = dropdown.find('input[type=checkbox]:checked').not('[value="all"]').map((i, el) => $(el).val()?.toString() || '').get();
+      if (selectedValues.length === 0 || allChecked) column.search('').draw();
+      else {
+        // const regex = selectedValues.map(v => $.fn.dataTable.util.escapeRegex(v)).join('|');
+        const regex = selectedValues.map(v => '^' + $.fn.dataTable.util.escapeRegex(v) + '$').join('|');
+        column.search(regex, true, false).draw();
+      }
+    });
+
+    // --- Show/hide dropdown ---
+    filterBtn.on('click', function (e) {
+      e.stopPropagation();
+      const offset = filterBtn.offset();
+      dropdown.css({
+        top: offset.top + filterBtn.outerHeight() + 2,
+        left: offset.left,
+        position: 'absolute',
+        zIndex: 1000
+      }).toggle();
+    });
+
+// Prevent clicks inside the dropdown from closing it
+dropdown.on('click', function (e) {
+  e.stopPropagation(); // stops the document click from firing
+});
+
+// Only hide dropdown when clicking outside
+$(document).on('click', function () {
+  dropdown.hide();
+});
+  });
+},
       buttons: [
         {
           extend: 'print',
@@ -164,7 +275,7 @@ export class CustomerComponent implements OnInit {
           //error occured
           this.openPopup();
           this.status_msg = "Warning";
-          this.error_msg = response.errors;
+          this.error_msg = response.error;
         } else {
           //succeessful response
           if (response.data[0].createcustomerStatus == 0) {
@@ -191,7 +302,7 @@ export class CustomerComponent implements OnInit {
         // console.log("inside if")
         //     this.openPopup();
         //     this.status_msg = "Warning";
-        //     this.error_msg = response.errors;
+        //     this.error_msg = response.error;
         //   } else if (response.data.length > 0) {
 
         //     this.openPopup();
@@ -204,7 +315,7 @@ export class CustomerComponent implements OnInit {
         //     if (response.data[0].exception.errorid != '') {
         //       this.openPopup();
         //       this.status_msg = "Warning";
-        //       this.error_msg = response.errors;
+        //       this.error_msg = response.error;
         //     }
         //   }
         //   else {
@@ -217,7 +328,7 @@ export class CustomerComponent implements OnInit {
         //     //console.log("inside if")
         //     this.openPopup();
         //     this.status_msg = "Warning";
-        //     this.error_msg = response.errors;
+        //     this.error_msg = response.error;
         //   }
         //   else if (response.data.length > 0) {
         //     //console.log("inside if(response.message== '')222222222222 ")
@@ -235,7 +346,7 @@ export class CustomerComponent implements OnInit {
         //     if (response.data[0].exception.errorid != '') {
         //       this.openPopup();
         //       this.status_msg = "Warning";
-        //       this.error_msg = response.errors;
+        //       this.error_msg = response.error;
         //     }
         //   }
         //   else {
@@ -367,7 +478,7 @@ addTask(customerId: string, userId: string) {
           //error occured
           this.openPopup();
           this.status_msg = "Warning";
-          this.error_msg = response.errors || response.mesasge;
+          this.error_msg = response.error || response.mesasge;
         } else {
           //succeessful response
           if (response.updateCustomerStatus == 0) {

+ 2 - 0
src/app/home/home.component.html

@@ -419,6 +419,7 @@
 
                 <th style="width:15%">Customer Name</th>
                 <th style="width:15%">Contact Name</th>
+                <!-- <th style="width: 15%;">Mobile Number</th> -->
                 <th style="width:15%">Second Contact</th>
                 <th style="width:15%">Next Action</th>
                 <th style="width:15%">Date of Visit</th>
@@ -441,6 +442,7 @@
                 <!-- <td><a routerLink="/dvrentry/id:"+{{dvrData.customer_name}}+>{{dvrData.customer_name}}</a></td> -->
                 <td> <a routerLink="/dvrentry/id:{{dvrData.dvr_id}}"> {{dvrData.customer_name}}</a></td>
                 <td>{{dvrData.contact_name}}</td>
+                <!-- <td>{{dvrData?.mobile_number}}</td> -->
                 <td >{{dvrData.second_contact}}</td>
                 <td>
                 <!-- <td style="    width: 85%;