EVOLUTION-NINJA
Edit File: new_lead_list.php
<?php $this->load->view('includes/admin_header');?> <!-- page specific plugin scripts --> <script src="<?php echo base_url('admin_assets/assets/js/tree.min.js');?>"></script> <script src="<?php echo base_url('admin_assets/assets/js/select2.min.js');?>"></script> <script src="<?php echo base_url('admin_assets/assets/js/jquery-ui.custom.min.js');?>"></script> <script src="<?php echo base_url('admin_assets/assets/js/jquery.ui.touch-punch.min.js');?>"></script> <script src="<?php echo base_url('admin_assets/assets/js/holder.min.js');?>"></script> <!-- ace scripts --> <script src="<?php echo base_url('admin_assets/assets/js/ace-elements.min.js');?>"></script> <script src="<?php echo base_url('admin_assets/assets/js/ace.min.js');?>"></script> <!-- inline scripts related to this page --> <script src="<?php echo base_url('admin_assets/assets/datatables/jquery.dataTables.min.js');?>"></script> <script src="<?php echo base_url('admin_assets/assets/datatables/dataTables.bootstrap.min.js');?>"></script> <link rel="stylesheet" href="<?php echo base_url('admin_assets/assets/datatables/dataTables.bootstrap.css');?>"> <!-- jQuery --> <script src="<?php echo base_url('https://code.jquery.com/jquery-3.6.0.min.js') ?>"></script> <!-- Bootstrap JavaScript --> <script src="<?php echo base_url('https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js') ?>"></script> <!-- SweetAlert2 CSS --> <link href="https://cdn.jsdelivr.net/npm/sweetalert2@11.7.0/dist/sweetalert2.min.css" rel="stylesheet"> <!-- SweetAlert2 JavaScript --> <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.7.0/dist/sweetalert2.all.min.js"></script> <script src="<?php echo base_url('admin_assets/assets/js/jquery.table2excel.js');?>"></script> <div class=" page-content" style="background-color:#f0f0f0;"> <div class="row"> <div class="col-sm-10" style=""> </div> <div class="col-sm-1 pd-7"> <div style="float:right;"> <div class="" style="padding-top:10px;"><a href="<?php echo base_url('new-lead');?>"><i class=" fa fa-plus fa-2x"></i></a></div> </div> </div> <div class="col-sm-1 pd-7" style="width:7%;"> <div class="dropdown"> <button type="button" id="new-lead-list" class="btn btn-sm">Export</button> </ul> </div> </div> <!-- Modal --> <div class="modal fade" id="myModal" role="dialog"> <div class="modal-dialog"> <!-- Modal content--> <form id="import_lead"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">Import Leads</h4> </div> <div class="modal-body"> <input type="file" name="import_leads" > </div> <div class="modal-footer"> </div> </div> </form> </div> </div> <!-- <div class="col-sm-1 pd-7" style="width:5%;"> <div class="dropdown"> <button class="btn btn-primary dropdown-toggle pd-9" id="menu1" data-toggle="dropdown"><i class="fa fa-ellipsis-h fa-2x"></i> </button> <ul class="dropdown-menu"> <li><a href="#">Mass Transfer</a></li> <li><a href="#">Mass Delete</a></li> <li><a href="#">Mass Update</a></li> <li><a href="#">Mass E-Mail</a></li> <li><a href="#">Approve Leads</a></li> <li><a href="#">Zoho Sheet View</a></li> <li><a href="#">Print View</a></li> </ul> </div> </div> --> <div class="col-sm-1 pd-7"> <!-- <div class="dropdown" > <button class="fa fa-sort-alpha-asc fa-1x btn btn-primary dropdown-toggle" id="menu1" data-toggle="dropdown" style="font-size:20px;"> </button> <ul class="dropdown-menu"> <li><a href="#">A</a></li> <li><a href="#">B</a></li> <li><a href="#">C</a></li> <li><a href="#">D</a></li> <li><a href="#">E</a></li> <li><a href="#">F</a></li> <li><a href="#">G</a></li> </ul> </div> --> </div> </div> <div class="row"> <div class="col-sm-7 " style="margin-top:5px;"> <h3>Lead List</h3> </div> <div class="col-sm-2" style="float:left;"> </div> </div> <div class="row" style="background-color:white;margin-top:10px;"> <div class="col-xs-12"> <!-- PAGE CONTENT BEGINS --> <div class="hr dotted"></div> <div class="row col-sm-12 table-responsive"> <label><input type="radio" name="status" value="ALL" class="inv_st" checked>NEW LEADS</label>   <label><input type="radio" name="status" value="CONTACTED" class="inv_st" >CONTACTED</label>   <label><input type="radio" name="status" value="CLOSED" class="inv_st">CLOSED</label>   <label><input type="radio" name="status" value="CONVERTED" class="inv_st">CONVERTED</label>   <div id="addele_more"> <table class="table" id="maintable"> <thead> <tr id="column_id"> <th>Sl.No.</th> <th style="width:70px;">Lead Name</th> <th style="width:70px;">Company</th> <th>Mobile</th> <th>Address</th> <th>Email</th> <th>Description</th> <th>Lead Created Date</th> <th>Lead Owner</th> <th>Action</th> </tr> </thead> <tbody id="ddd"> <?php $ct=1;foreach($lead as $value){ ?> <tr class="hoverr click-on"> <td><?php echo $ct;?></td> <td><?php echo $value['first_name'];?></td> <td><a href="<?php echo site_url("lead-info/")?>/<?php echo $value['lead_id']; ?>" id="<?php echo $value['lead_id'];?>"><?php if(!empty($value['company_name'])) { echo $value['company_name']; } else { echo 'No Name'; }?></a></td> <td><?php echo $value['mobile'];?></td> <td><?php echo $value['street'];?></td> <td><?php echo $value['email'];?></td> <td><?php echo $value['description']; ?></td> <td><?php echo date('d-m-Y',strtotime($value['c_date'])); ?></td> <td><?php echo $value['user_name'];?></td> <td> <span class="glyphicon glyphicon-pencil" onclick='openEditModal("<?php echo $value['lead_id']; ?>");'></span> <span class="glyphicon glyphicon-trash" onclick='delete_lead("<?php echo $value['lead_id']; ?>");' ></span> <?php if($value['lead_convert']=='CLOSED'){ ?> <button class="button1<?php echo $value['lead_id']; ?>" onclick="closed('<?php echo $value['lead_id']; ?>');" disabled>Closed</button> <?php } else{ ?> <button class="button1<?php echo $value['lead_id']; ?>" onclick="closed('<?php echo $value['lead_id']; ?>');">Close</button> <?php } ?> </td> </tr> <?php $ct++; }?> </tbody> </table> <!-- Edit Lead Modal --> <div id="editModal" class="modal" tabindex="-1" role="dialog"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title">Edit Lead</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> <form id="editLeadForm"> <input type="hidden" id="edit_lead_id" name="lead_id"> <div class="form-group"> <label for="edit_first_name">Lead Name</label> <input type="text" id="edit_first_name" name="first_name" class="form-control"> </div> <div class="form-group"> <label for="edit_company_name">Company</label> <input type="text" id="edit_company_name" name="company_name" class="form-control"> </div> <div class="form-group"> <label for="edit_mobile">Mobile</label> <input type="text" id="edit_mobile" name="mobile" class="form-control"> </div> <div class="form-group"> <label for="edit_address">Address</label> <input type="text" id="edit_address" name="street" class="form-control"> </div> <div class="form-group"> <label for="edit_email">Email</label> <input type="email" id="edit_email" name="email" class="form-control"> </div> <div class="form-group"> <label for="edit_description">Description</label> <textarea id="edit_description" name="description" class="form-control"></textarea> </div> <div class="form-group"> <button type="submit" class="btn btn-primary">Save changes</button> </div> </form> </div> </div> </div> </div> <script> function openEditModal(lead_id) { // Show the modal $('#editModal').modal('show'); // Make an AJAX request to fetch the lead data $.ajax({ url: '<?php echo site_url("Yaskawa/fetch_lead_data"); ?>', // Correct URL method: 'POST', data: { lead_id: lead_id }, dataType: 'json', success: function(response) { if (response.error) { alert(response.error); // If there's an error message } else { // Populate the modal with the lead data $('#edit_lead_id').val(response.lead_id); $('#edit_first_name').val(response.first_name); $('#edit_company_name').val(response.company_name); $('#edit_mobile').val(response.mobile); $('#edit_address').val(response.street); $('#edit_email').val(response.email); $('#edit_description').val(response.description); } }, error: function() { alert("An error occurred while fetching lead data."); } }); } </script> <script> $('#editLeadForm').submit(function(e) { e.preventDefault(); // Prevent the form from submitting the default way // Send the updated data via AJAX $.ajax({ url: '<?php echo site_url("Yaskawa/update_lead"); ?>', // Your update URL method: 'POST', data: $(this).serialize(), // Serialize the form data (the form ID must be correct) dataType: 'json', // Make sure the server returns JSON success: function(response) { if (response.success) { Swal.fire({ icon: 'success', title: 'Lead updated successfully!', text: 'The lead details have been updated.', confirmButtonText: 'OK' }).then((result) => { if (result.isConfirmed) { location.reload(); // Reload the page or update the table dynamically } }); // Reload the page (or update the table instead of reload) } else { alert('Error updating lead!'); // Show error message if response.success is false } }, error: function(xhr, status, error) { console.log(xhr.responseText); // Log the error in the console alert("An error occurred while updating the lead."); } }); }); </script> <!-- edit lead data --> <table id="maintable_hidden" style="display:none;"> <thead> <tr id="column_id"> <th>Sl.No.</th> <th style="width:70px;">Lead Name</th> <th style="width:70px;">Company</th> <th>Mobile</th> <th>Address</th> <th>Email</th> <th>Note Description</th> <th>Lead Created Date</th> <th>Lead Owner</th> <th>Action</th> </tr> </thead> <tbody id="ddd"> <?php $ct=1;foreach($lead as $value){ ?> <tr class="hoverr click-on"> <td><?php echo $ct;?></td> <td><?php echo $value['first_name'];?></td> <td><a href="<?php echo site_url("lead-info/")?>/<?php echo $value['lead_id']; ?>" id="<?php echo $value['lead_id'];?>"><?php if(!empty($value['company_name'])) { echo $value['company_name']; } else { echo 'No Name'; }?></a></td> <td><?php echo $value['mobile'];?></td> <td><?php echo $value['street'];?></td> <td><?php echo $value['email'];?></td> <td><?php echo $value['description']; ?></td> <td><?php echo date('d-m-Y',strtotime($value['c_date'])); ?></td> <td><?php echo $value['user_name'];?></td> <td> <span class="glyphicon glyphicon-trash" onclick='delete_lead("<?php echo $value['lead_id']; ?>");' ></span> <?php if($value['lead_convert']=='CLOSED'){ ?> <button class="button1<?php echo $value['lead_id']; ?>" onclick="closed('<?php echo $value['lead_id']; ?>');" disabled>Closed</button> <?php } else{ ?> <button class="button1<?php echo $value['lead_id']; ?>" onclick="closed('<?php echo $value['lead_id']; ?>');">Close</button> <?php } ?> </td> </tr> <?php $ct++; }?> </tbody> </table> </div> <div id="contacted_table" style="display:none;"> <table class="table" id="contacted_table_id"> <thead> <tr id="column_id"> <th>Sl.No.</th> <th style="width:70px;">Lead Name</th> <th style="width:70px;">Company</th> <th>Mobile</th> <th>Address</th> <th>Email</th> <th>Note Description</th> <th>Lead Created Date</th> <th>Lead Owner</th> <th>Action</th> </tr> </thead> <tbody id="ddd"> <?php $ct=1;foreach($contacted_leads as $value){ ?> <tr class="hoverr click-on"> <td><?php echo $ct;?></td> <td><?php echo $value->first_name;?></td> <td><a href="<?php echo site_url("lead-info/")?>/<?php echo $value->lead_id; ?>" id="<?php echo $value->lead_id;?>"><?php if(!empty($value->company_name)) { echo $value->company_name; } else { echo 'No Name'; }?></a></td> <td><?php echo $value->mobile;?></td> <td><?php echo $value->street;?></td> <td><?php echo $value->email;?></td> <td><?php echo $value->description; ?></td> <td><?php echo date('d-m-Y',strtotime($value->c_date)); ?></td> <td><?php echo $value->user_name;?></td> <td> <span class="glyphicon glyphicon-trash" onclick='delete_lead("<?php echo $value->lead_id; ?>");' ></span> <?php if($value->lead_convert=='CLOSED'){ ?> <button class="button1<?php echo $value->lead_id; ?>" onclick="closed('<?php echo $value->lead_id; ?>');" disabled>Closed</button> <?php } else{ ?> <button class="button1<?php echo $value->lead_id; ?>" onclick="closed('<?php echo $value->lead_id; ?>');">Close</button> <?php } ?> </td> </tr> <?php $ct++; }?> </tbody> </table> <table style="display:none;" id="contacted_table_hidden"> <thead> <tr id="column_id"> <th>Sl.No.</th> <th style="width:70px;">Lead Name</th> <th style="width:70px;">Company</th> <th>Mobile</th> <th>Address</th> <th>Email</th> <th>Note Description</th> <th>Lead Created Date</th> <th>Lead Owner</th> <th>Action</th> </tr> </thead> <tbody id="ddd"> <?php $ct=1;foreach($contacted_leads as $value){ ?> <tr class="hoverr click-on"> <td><?php echo $ct;?></td> <td><?php echo $value->first_name;?></td> <td><a href="<?php echo site_url("lead-info/")?>/<?php echo $value->lead_id; ?>" id="<?php echo $value->lead_id;?>"><?php if(!empty($value->company_name)) { echo $value->company_name; } else { echo 'No Name'; }?></a></td> <td><?php echo $value->mobile;?></td> <td><?php echo $value->street;?></td> <td><?php echo $value->email;?></td> <td><?php echo $value->description; ?></td> <td><?php echo date('d-m-Y',strtotime($value->c_date)); ?></td> <td><?php echo $value->user_name;?></td> <td> <span class="glyphicon glyphicon-trash" onclick='delete_lead("<?php echo $value->lead_id; ?>");' ></span> <?php if($value->lead_convert=='CLOSED'){ ?> <button class="button1<?php echo $value->lead_id; ?>" onclick="closed('<?php echo $value->lead_id; ?>');" disabled>Closed</button> <?php } else{ ?> <button class="button1<?php echo $value->lead_id; ?>" onclick="closed('<?php echo $value->lead_id; ?>');">Close</button> <?php } ?> </td> </tr> <?php $ct++; }?> </tbody> </table> </div> <div id="closed_table" style="display:none;"> <table class="table" id="closed_table_id"> <thead> <tr id="column_id"> <th>Sl.No.</th> <th style="width:70px;">Lead Name</th> <th style="width:70px;">Company</th> <th>Mobile</th> <th>Address</th> <th>Email</th> <th>Note Description</th> <th>Lead Created Date</th> <th>Lead Owner</th> <th>Action</th> </tr> </thead> <tbody id="ddd"> <?php $ct=1;foreach($closed_leads as $value){ ?> <tr class="hoverr click-on"> <td><?php echo $ct;?></td> <td><?php echo $value->first_name;?></td> <td><a href="<?php echo site_url("lead-info/")?>/<?php echo $value->lead_id; ?>" id="<?php echo $value->lead_id;?>"><?php if(!empty($value->company_name)) { echo $value->company_name; } else { echo 'No Name'; }?></a></td> <td><?php echo $value->mobile;?></td> <td><?php echo $value->street;?></td> <td><?php echo $value->email;?></td> <td><?php echo $value->description; ?></td> <td><?php echo date('d-m-Y',strtotime($value->c_date)); ?></td> <td><?php echo $value->user_name;?></td> <td> <span class="glyphicon glyphicon-trash" onclick='delete_lead("<?php echo $value->lead_id; ?>");' ></span> <?php if($value->lead_convert=='CLOSED'){ ?> <button class="button1<?php echo $value->lead_id; ?>" onclick="closed('<?php echo $value->lead_id; ?>');" disabled>Closed</button> <?php } else{ ?> <button class="button1<?php echo $value->lead_id; ?>" onclick="closed('<?php echo $value->lead_id; ?>');">Close</button> <?php } ?> </td> </tr> <?php $ct++; }?> </tbody> </table> <table style="display:none;" id="closed_table_hidden"> <thead> <tr id="column_id"> <th>Sl.No.</th> <th style="width:70px;">Lead Name</th> <th style="width:70px;">Company</th> <th>Mobile</th> <th>Address</th> <th>Email</th> <th>Note Description</th> <th>Lead Created Date</th> <th>Lead Owner</th> <th>Action</th> </tr> </thead> <tbody id="ddd"> <?php $ct=1;foreach($closed_leads as $value){ ?> <tr class="hoverr click-on"> <td><?php echo $ct;?></td> <td><?php echo $value->first_name;?></td> <td><a href="<?php echo site_url("lead-info/")?>/<?php echo $value->lead_id; ?>" id="<?php echo $value->lead_id;?>"><?php if(!empty($value->company_name)) { echo $value->company_name; } else { echo 'No Name'; }?></a></td> <td><?php echo $value->mobile;?></td> <td><?php echo $value->street;?></td> <td><?php echo $value->email;?></td> <td><?php echo $value->description; ?></td> <td><?php echo date('d-m-Y',strtotime($value->c_date)); ?></td> <td><?php echo $value->user_name;?></td> <td> <span class="glyphicon glyphicon-trash" onclick='delete_lead("<?php echo $value->lead_id; ?>");' ></span> <?php if($value->lead_convert=='CLOSED'){ ?> <button class="button1<?php echo $value->lead_id; ?>" onclick="closed('<?php echo $value->lead_id; ?>');" disabled>Closed</button> <?php } else{ ?> <button class="button1<?php echo $value->lead_id; ?>" onclick="closed('<?php echo $value->lead_id; ?>');">Close</button> <?php } ?> </td> </tr> <?php $ct++; }?> </tbody> </table> </div> <div id="converted_table" style="display:none;"> <table class="table" id="converted_table_id"> <thead> <tr id="column_id"> <th>Sl.No.</th> <th style="width:70px;">Lead Name</th> <th style="width:70px;">Company</th> <th>Mobile</th> <th>Address</th> <th>Email</th> <th>Note Description</th> <th>Lead Created Date</th> <th>Lead Owner</th> <th>Action</th> </tr> </thead> <tbody id="ddd"> <?php $ct=1;foreach($converted_leads as $value){ ?> <tr class="hoverr click-on"> <td><?php echo $ct;?></td> <td><?php echo $value->first_name;?></td> <td><a href="<?php echo site_url("converted-lead-info/")?>/<?php echo $value->lead_id; ?>" id="<?php echo $value->lead_id;?>"><?php if(!empty($value->company_name)) { echo $value->company_name; } else { echo 'No Name'; }?></a></td> <td><?php echo $value->mobile;?></td> <td><?php echo $value->street;?></td> <td><?php echo $value->email;?></td> <td><?php echo $value->description; ?></td> <td><?php echo date('d-m-Y',strtotime($value->c_date)); ?></td> <td><?php echo $value->user_name;?></td> <td> <span class="glyphicon glyphicon-trash" onclick='delete_lead("<?php echo $value->lead_id; ?>");' ></span> <?php if($value->lead_convert=='CLOSED'){ ?> <button class="button1<?php echo $value->lead_id; ?>" onclick="closed('<?php echo $value->lead_id; ?>');" disabled>Closed</button> <?php } else{ ?> <button class="button1<?php echo $value->lead_id; ?>" onclick="closed('<?php echo $value->lead_id; ?>');">Close</button> <?php } ?> </td> </tr> <?php $ct++; }?> </tbody> </table> <table style="display:none;" id="converted_table_hidden"> <thead> <tr id="column_id"> <th>Sl.No.</th> <th style="width:70px;">Lead Name</th> <th style="width:70px;">Company</th> <th>Mobile</th> <th>Address</th> <th>Email</th> <th>Note Description</th> <th>Lead Created Date</th> <th>Lead Owner</th> <th>Action</th> </tr> </thead> <tbody id="ddd"> <?php $ct=1;foreach($converted_leads as $value){ ?> <tr class="hoverr click-on"> <td><?php echo $ct;?></td> <td><?php echo $value->first_name;?></td> <td><a href="<?php echo site_url("lead-info/")?>/<?php echo $value->lead_id; ?>" id="<?php echo $value->lead_id;?>"><?php if(!empty($value->company_name)) { echo $value->company_name; } else { echo 'No Name'; }?></a></td> <td><?php echo $value->mobile;?></td> <td><?php echo $value->street;?></td> <td><?php echo $value->email;?></td> <td><?php echo $value->description; ?></td> <td><?php echo date('d-m-Y',strtotime($value->c_date)); ?></td> <td><?php echo $value->user_name;?></td> <td> <span class="glyphicon glyphicon-trash" onclick='delete_lead("<?php echo $value->lead_id; ?>");' ></span> <?php if($value->lead_convert=='CLOSED'){ ?> <button class="button1<?php echo $value->lead_id; ?>" onclick="closed('<?php echo $value->lead_id; ?>');" disabled>Closed</button> <?php } else{ ?> <button class="button1<?php echo $value->lead_id; ?>" onclick="closed('<?php echo $value->lead_id; ?>');">Close</button> <?php } ?> </td> </tr> <?php $ct++; }?> </tbody> </table> </div> </div> </div><!-- /.col --> </div><!-- /.row --> </div><!-- /.page-content --> </body> </html> <script type="text/javascript"> var datatable; var tbody = $('#table_body'); datatable = $('.table').DataTable({ }); // function closed(lead_id){ // new swal({ // title: "Are you sure?", // text: "You are moving to closed Status!", // type: "warning", showCancelButton: true, // confirmButtonColor: "#DD6B55", // confirmButtonText: "Yes, Close it!", // cancelButtonText: "No, cancel plz!", // closeOnConfirm: false, // closeOnCancel: false // }, // function(isConfirm){ // if (isConfirm) { // $(".sweet-alert").hide(); // $(".sweet-overlay").hide(); // $.ajax({ // type : 'post', // url : '<?php echo site_url("yaskawa/close_lead")?>', // data : {'id':lead_id}, // success:function(response){ // response=jQuery.parseJSON(response); // console.log(response); // if(response) // { // toastr['success']("Lead Closed"); // } // } // }); // } // else // { // $(".sweet-alert").hide(); // $(".sweet-overlay").hide(); // } // }); // } function closed(lead_id) { Swal.fire({ title: "Are you sure?", text: "You are moving to closed Status!", icon: "warning", // Use 'icon' instead of 'type' showCancelButton: true, confirmButtonColor: "#DD6B55", confirmButtonText: "Yes, Close it!", cancelButtonText: "No, cancel plz!" }).then((result) => { if (result.isConfirmed) { $.ajax({ type: 'POST', url: '<?php echo site_url("yaskawa/close_lead")?>', data: { 'id': lead_id }, success: function(response) { response = jQuery.parseJSON(response); console.log(response); if (response) { alert('Lead closed'); location.reload(); } } }); } }); } $('#import_lead').submit(function(e){ e.preventDefault(); formdata = new FormData($(this)[0]); $.ajax({ type : 'post', url : '<?php echo site_url("import-leads")?>', data : formdata, contentType: false, processData: false, success:function(response){ response=jQuery.parseJSON(response); console.log(response); if(response.result == 1) { location.reload(); } else if(response.result == 2) { toastr["error"](response.message); } else { toastr["error"](response.message); } } }); }); $('.inv_st').change(function(e){ e.preventDefault(); var status = $("input[type=radio][name=status]:checked" ).val(); if(status == "CONTACTED") { $("#addele_more").hide(); $("#contacted_table").show(); $("#closed_table").hide(); $("#converted_table").hide(); } else if(status == "CLOSED") { $("#addele_more").hide(); $("#contacted_table").hide(); $("#closed_table").show(); $("#converted_table").hide(); } else if(status == "CONVERTED") { $("#addele_more").hide(); $("#contacted_table").hide(); $("#closed_table").hide(); $("#converted_table").show(); } else { $("#addele_more").show(); $("#contacted_table").hide(); $("#closed_table").hide(); $("#converted_table").hide(); } }); // function delete_lead(id) // { // var id = id; // new swal({ // title: "Are you sure?", // text: "You will not be able to recover this data!", // type: "warning", showCancelButton: true, // confirmButtonColor: "#DD6B55", // confirmButtonText: "Yes, delete it!", // cancelButtonText: "No, cancel plz!", // closeOnConfirm: false, // closeOnCancel: false // }, // function(isConfirm){ // if (isConfirm) { // $(".sweet-alert").hide(); // $(".sweet-overlay").hide(); // $.ajax({ // url:"<?php echo site_url("delete-lead")?>", // type:"POST", // data:{id:id}, // success:function(response) { // response=jQuery.parseJSON(response); // console.log(response); // if(response.result == 1) // { // toastr["success"]("Deleted successfully"); // } // } // }); // } // else { // $(".sweet-alert").hide(); // $(".sweet-overlay").hide(); // } // }); // } //}); </script> <script> function delete_lead(lead_id) { event.stopPropagation(); // Prevents other event handlers (like opening edit modal) from being triggered // SweetAlert confirmation prompt Swal.fire({ title: 'Are you sure?', text: "You won't be able to revert this!", icon: 'warning', showCancelButton: true, confirmButtonColor: '#d33', cancelButtonColor: '#3085d6', confirmButtonText: 'Yes, delete it!' }).then((result) => { if (result.isConfirmed) { // Perform the deletion via AJAX $.ajax({ url: "<?php echo site_url('delete-lead'); ?>", // Correct URL to the controller method method: "POST", data: { lead_id: lead_id }, // Send the ID to delete dataType: "json", success: function(response) { if (response.status === 'success') { // Success SweetAlert Swal.fire({ title: 'Deleted!', text: 'The lead has been deleted.', icon: 'success', confirmButtonText: 'OK' }).then(() => { // Optionally remove the lead row from the table $('tr').find(`td:contains(${lead_id})`).closest('tr').remove(); // Reload the page to reflect changes location.reload(); }); } else { // Failure SweetAlert Swal.fire({ title: 'Error!', text: 'Failed to delete the lead.', icon: 'error', confirmButtonText: 'OK' }); } }, error: function(xhr, status, error) { // AJAX error SweetAlert Swal.fire({ title: 'Error!', text: 'An error occurred while deleting the lead.', icon: 'error', confirmButtonText: 'OK' }); console.error('AJAX Error:', error); } }); } }); } </script> <script type="text/javascript"> $("#new-lead-list").click(function(){ var radio_value = $('input[name=status]:checked').val(); //alert(radio_value); if(radio_value == "ALL") { $("#maintable_hidden").table2excel({ exclude: ".noExl", name: "Excel Document Name", filename: "new_lead_list", fileext: ".xls", exclude_img: true, exclude_links: true, exclude_inputs: true }); } else if(radio_value == "CONTACTED") { $("#contacted_table_hidden").table2excel({ exclude: ".noExl", name: "Excel Document Name", filename: "contacted_lead_list", fileext: ".xls", exclude_img: true, exclude_links: true, exclude_inputs: true }); } else if(radio_value == "CLOSED") { $("#closed_table_hidden").table2excel({ exclude: ".noExl", name: "Excel Document Name", filename: "closed_lead_list", fileext: ".xls", exclude_img: true, exclude_links: true, exclude_inputs: true }); } else if(radio_value == "CONVERTED") { $("#converted_table_hidden").table2excel({ exclude: ".noExl", name: "Excel Document Name", filename: "converted_lead_list", fileext: ".xls", exclude_img: true, exclude_links: true, exclude_inputs: true }); } }); </script> <script type="text/javascript"> $(document).ready(function(){ function DropDown() { $.ajax({ type : 'get', url : '<?php echo site_url("menu-list")?>', success:function(response){ response=jQuery.parseJSON(response); console.log(response); var table_content=''; if(response.result==1) { $.each(response.menu_list,function(idx,vx) { table_content+= '<li>'; table_content+= '<input class="col1" type="checkbox" name="columns[]" value="'+vx.alt_name+'" id="'+vx.menu_id+'"/>'; table_content+= '<label for="'+vx.menu_id+'" >'+vx.menu_name+'</label>'; table_content+= '</li>'; }); $("#menu_list_content").html(table_content); }else { $("#menu_list_content").empty(); } } }); } }); </script> <script type="text/javascript"> //$(function () { $('#checkall').toggle( function() { $('#checkthis').prop('checked', true); }, function() { $('#checkthis').prop('checked', false); } ); //}); </script> <script type="text/javascript"> $(".table td").hover(function() { //$(this).prop('title', $.trim($(this).text())); addclass(); }); function addclass(){ $('.table td').addClass("edit1"); } </script> <style type="text/css"> #treeview-searchable .node-disabled { display: none; } .hoverr:hover .addd { display:block; } .addd{ display:none; } .add_more { padding: 0px 7px !important; font-size: 12px !important; } #block{display:none;padding-left:10px;} .pd-7{ padding-right:7px !important; padding-left:7px !important; } .pd-9{ padding:2px 9px !important; } </style> <script> $('#cbxShowHide').click(function(){ this.checked?$('#block').show():$('#block').hide(); }); </script> <!-- edit modal --> <?php $this->load->view('includes/admin_footer');?>