<?php
    $errors = $this->session->userdata('errors');
    if (isset($errors)) {
        ?>
        <script>
            swal ( "Oops" ,  "<?php echo $errors ?>" ,  "error" )
        </script>
        <?php echo $errors ?>
        <?php
        $this->session->unset_userdata('errors');
    }
    $error = $this->session->userdata('error');
    if (isset($error)) {
        ?>
         <script>
            swal ( "Oops" ,  "<?php echo $error ?>" ,  "error" )
        </script>
        <?php
        $this->session->unset_userdata('error');
    }
    $success = $this->session->userdata('success');
    if (isset($success)) {
        ?>
         <script>
            swal({
          title: "Done!",
          text: "<?php echo $success ?>",
          icon: "success",
        });
        </script>
        <?php
        $this->session->unset_userdata('success');
    }
    ?>
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1>View All Product Inquiry </h1>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="<?php echo admin_url() ?>admin">Home</a></li>
              <li class="breadcrumb-item active">View All Product Inquery</li>
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>
       <section class="content">
      <div class="container-fluid">
        <div class="card card-default">
          <div class="card-header">
           <form method="GET" action=
            "">
                <div class="container">
                  <div class="row">
                    <div class="col-sm-4">
                       <div class="form-group">
                        <label class="" for="from_date">Start Date &nbsp;&nbsp;&nbsp;</label>
                        <input required="" type="date" name="start_date" class="form-control datepicker" id="from_date">
                      </div>
                    </div> 

                   
                    <div class="col-sm-4">
                      <div class="form-group end_date">
                          <label class="" for="to_date">End Date &nbsp;&nbsp;&nbsp;</label>
                          <input required=""  type="date" name="end_date" class="form-control datepicker" id="to_date" >
                      </div>
                    </div>
                    <div class="col-sm-3">
                     <label style="color: #fff;">s</label>
                      <div class="form-group end_date">
                           
                          <button style="float: right;" type="submit" class="btn btn-success">Search</button>
                      </div>
                    </div>
                  </div>
                </div>  
              
            <?php echo form_close()?>
          </div>
        </div><!--/. container-fluid -->
    </section>

    <section class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-sm-12">
            <div class="card card-default">
              <div class="card-header">
                <h3 class="card-title">Entry pop-up Inquiry Users</h4>
                <div class="card-tools">
                  <button type="button" class="btn btn-success btn-sm" id="delete_pop_up">Delete All</button>
                </div>
              </div>
                <div class="card-body">
                  <table class="table table-bordered datatable">
                    <thead>
                    <tr>
                      <th>id</th>
                      <th><input id="pop_all" type="checkbox">&nbsp;Check All</th>
                      <th>Product</th>
                      <th>Name</th>
                      <th>Email</th>
                      <th>Phone</th>
                      <th>Date</th>
                      <th></th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php $i=1; foreach ($product_first_seen as $key => $product_inq):?>
                    <tr>
                      <td><?php echo $i ?></td>
                      <td><input name="checkbox[]" class="sub_chk_pop" type="checkbox" data-id="<?php echo $product_inq->inq_id; ?>"> </td>
                      <td><?php echo $product_inq->prd_name ?></td>
                      <td><?php echo $product_inq->inq_name ?></td>
                      <td><?php echo $product_inq->inq_email ?></td>
                      <td><?php echo $product_inq->inq_mob ?></td>
                      <td><?php echo $product_inq->inq_date ?></td>
                      <td>
                        <a class="btn btn-danger btn-sm" onclick="return confirm('Are you sure?')" href="<?php echo base_url() ?>admin/product/delete_inq_first/<?php echo $product_inq->inq_id ?>"><i class="fa fa-trash" aria-hidden="true"></i></a>
                      </td>
                    </tr>
                    <?php $i++; ?>
                    <?php endforeach; ?>
                    </tbody>
                    
                  </table>
                </div>
              </div>
            </div>
          </div>
      </div>
    </section>

    <section class="content">
      <div class="container-fluid">
        <div class="row">

          <div class="col-sm-12">
            <div class="card card-default">
              <div class="card-header">
                <h4 class="card-title">Advance Payment Users</h4>
                <div class="card-tools">
                  <button type="button" class="btn btn-success btn-sm" id="delete_advance">Delete All</button>
                </div>
              </div>
                <div class="card-body">
                  <table id="example" class="table table-bordered table-striped">
                    <thead>
                    <tr>
                      <th>id</th>
                      <th><input id="advance_all" type="checkbox">&nbsp;Check All</th>
                      <th>Product</th>
                      <th>Name & Contact</th>
                      <th>Address</th>
                      <th>Domain Info</th>
                      <th>Price</th>
                      <th>Pay Status</th>
                      <th>Amount</th>
                      <th>Pay ID</th>
                      <th>Date</th>
                      <th></th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php $i=1; foreach ($product_inquery as $key => $product):?>
                    <tr>
                      <td><?php echo $i ?></td>
                      <td><input name="checkbox[]" class="sub_chk_advance" type="checkbox" data-id="<?php echo $product->prd_inq_id; ?>"> </td>
                      <td><?php echo $product->prd_name ?></td>
                      <td><?php echo $product->prd_inq_name ?><br/>
                          <?php echo $product->prd_inq_email ?><br/>
                          <?php echo $product->prd_inq_mobile ?>
                      </td>
                      <td><?php echo $product->prd_inq_address ?>, <?php echo $product->prd_inq_area ?>, <?php echo $product->prd_inq_city ?>, <?php echo $product->prd_inq_state ?> - <?php echo $product->prd_inq_pin_code ?></td>
                      <td>
                        <?php if($product->prd_inq_domain_status == 1):?>
                          Own Domain <br/>
                          <?php echo $product->prd_inq_domain_name ?>
                        <?php else: ?>
                          Expected Domain <br/>
                          <?php echo $product->prd_inq_domain_name_expected ?>
                        <?php endif;?>
                      </td>
                      <td><?php echo $product->prd_inq_price ?></td>

                      <td>
                        <?php if($product->prd_inq_payment == 1): ?>
                          <span class="badge badge-success"> Yes</span>
                        <?php else:?>
                          <span class="badge badge-danger">No</span>
                        <?php endif;?>
                      </td>
                      <td><?php echo $product->prd_inq_pay_amount ?></td>
                      <td><?php echo $product->prd_inq_pay_id ?></td>

                      <td><?php echo $product->prd_inq_date ?></td>
                      <td>
                        <a class="btn btn-danger btn-sm" onclick="return confirm('Are you sure?')" href="<?php echo base_url() ?>admin/product/delete_inq/<?php echo $product->prd_inq_id ?>"><i class="fa fa-trash" aria-hidden="true"></i></a>
                      </td>
                    </tr>
                    <?php $i++; ?>
                    <?php endforeach; ?>
                    </tbody>
                    
                  </table>
                </div>
              </div>
            </div>
          </div>
      </div>
    </section>

    <section class="content">
      <div class="container-fluid">
        <div class="row">

          <div class="col-sm-12">
            <div class="card card-default">
              <div class="card-header">
                <h4 class="card-title">Abandoned Payment Users</h4>
                <div class="card-tools">
                  <button type="button" class="btn btn-success btn-sm" id="delete_abandoned">Delete All</button>
                </div>
              </div>
                <div class="card-body">
                  <table  class="table table-bordered table-striped datatable">
                    <thead>
                    <tr>
                      <th>id</th>
                      <th><input id="abandoned_all" type="checkbox">&nbsp;Check All</th>
                      <th>Product</th>
                      <th>Name</th>
                      <th>Contact</th>
                      <th>Date</th>
                      <th></th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php $i=1; foreach ($abandoned_product_inquery as $key => $product_inquery):?>
                    <tr>
                      <td><?php echo $i ?></td>
                      <td><input name="checkbox[]" class="sub_chk_abandoned" type="checkbox" data-id="<?php echo $product_inquery->prd_inq_id; ?>"> </td>
                      <td><?php echo $product_inquery->prd_name ?></td>
                      <td><?php echo $product_inquery->prd_inq_name ?></td>
                      <td><?php echo $product_inquery->prd_inq_email ?><br/>
                          <?php echo $product_inquery->prd_inq_mobile ?></td>
                      <td><?php echo $product_inquery->prd_inq_date ?></td>
                      <td>
                        <a class="btn btn-danger btn-sm" onclick="return confirm('Are you sure?')" href="<?php echo base_url() ?>admin/product/delete_inq/<?php echo $product_inquery->prd_inq_id ?>"><i class="fa fa-trash" aria-hidden="true"></i></a>
                      </td>
                    </tr>
                    <?php $i++; ?>
                    <?php endforeach; ?>
                    </tbody>
                    
                  </table>
                </div>
              </div>
            </div>
          </div>
      </div>
    </section>

    <section class="content">
      <div class="container-fluid">
        <div class="row">

          <div class="col-sm-12">
            <div class="card card-default">
              <div class="card-header">
                <h4 class="card-title">Product Video Demo</h4>
                <div class="card-tools">
                  <button type="button" class="btn btn-success btn-sm" id="delete_video">Delete All</button>
                </div>
              </div>
                <div class="card-body">
                  <table class="table table-bordered table-striped datatable">
                    <thead>
                    <tr>
                      <th>id</th>
                      <th><input id="video_all" type="checkbox">&nbsp;Check All</th>
                      <th>Product</th>
                      <th>Name</th>
                      <th>Email</th>
                      <th>Phone</th>
                      <th>Date</th>
                      <th></th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php $i=1; foreach ($get_all_product_video_demo as $key => $video_demo):?>
                    <tr>
                      <td><?php echo $i ?></td>
                      <td><input name="checkbox[]" class="sub_chk_video" type="checkbox" data-id="<?php echo $video_demo->v_d_id; ?>"> </td>
                      <td><?php echo $video_demo->prd_name ?></td>
                      <td><?php echo $video_demo->v_d_name ?></td>
                      <td><?php echo $video_demo->v_d_email ?></td>
                      <td><?php echo $video_demo->v_d_mobile ?></td>
                      <td><?php echo $video_demo->v_d_date ?></td>
                      <td>
                        <a class="btn btn-danger btn-sm" onclick="return confirm('Are you sure?')" href="<?php echo base_url() ?>admin/product/delete_video_demo/<?php echo $video_demo->v_d_id ?>"><i class="fa fa-trash" aria-hidden="true"></i></a>
                      </td>
                    </tr>
                    <?php $i++; ?>
                    <?php endforeach; ?>
                    </tbody>
                    
                  </table>
                </div>
              </div>
            </div>
          </div>
      </div>
    </section>

    <section class="content">
      <div class="container-fluid">
        <div class="row">

          <div class="col-sm-12">
            <div class="card card-default">
              <div class="card-header">
                <h4 class="card-title">Admin Demo Inquiry Users</h4>
                <div class="card-tools">
                  <button type="button" class="btn btn-success btn-sm" id="delete_demo">Delete All</button>
                </div>
              </div>
                <div class="card-body">
                  <table class="table table-bordered table-striped datatable">
                    <thead>
                    <tr>
                      <th>id</th>
                      <th><input id="demo_all" type="checkbox">&nbsp;Check All</th>
                      <th>Product</th>
                      <th>Name</th>
                      <th>Email</th>
                      <th>Phone</th>
                      <th>Date</th>
                      <th></th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php $i=1; foreach ($demo_inquery as $key => $inquery):?>
                    <tr>
                      <td><?php echo $i ?></td>
                      <td><input name="checkbox[]" class="sub_chk_demo" type="checkbox" data-id="<?php echo $inquery->prd_adm_id; ?>"> </td>
                      <td><?php echo $inquery->prd_name ?></td>
                      <td><?php echo $inquery->prd_adm_name ?></td>
                      <td><?php echo $inquery->prd_adm_email ?></td>
                      <td><?php echo $inquery->prd_adm_mobile ?></td>
                      <td><?php echo $inquery->date ?></td>
                      <td>
                        <a class="btn btn-danger btn-sm" onclick="return confirm('Are you sure?')" href="<?php echo base_url() ?>admin/product/delete_demo_inq/<?php echo $inquery->prd_adm_id ?>"><i class="fa fa-trash" aria-hidden="true"></i></a>
                      </td>
                    </tr>
                    <?php $i++; ?>
                    <?php endforeach; ?>
                    </tbody>
                    
                  </table>
                </div>
              </div>
            </div>
          </div>
      </div>
    </section>
    <section class="content">
      <div class="container-fluid">
        <div class="row">

          <div class="col-sm-12">
            <div class="card card-default">
              <div class="card-header">
                <h4 class="card-title">Product brochure Download Users</h4>
                <div class="card-tools">
                  <button type="button" class="btn btn-success btn-sm" id="delete_brochure">Delete All</button>
                </div>
              </div>
                <div class="card-body">
                  <table class="table table-bordered table-striped datatable">
                    <thead>
                    <tr>
                      <th>id</th>
                      <th><input id="brochure_all" type="checkbox">&nbsp;Check All</th>
                      <th>Product</th>
                      <th>Name</th>
                      <th>Email</th>
                      <th>Phone</th>
                      <th></th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php $i=1; foreach ($download_boucher as $key => $boucher):?>
                    <tr>
                      <td><?php echo $i ?></td>
                      <td><input name="checkbox[]" class="sub_chk_brochure" type="checkbox" data-id="<?php echo $boucher->b_id; ?>"> </td>
                      <td><?php echo $boucher->prd_name ?></td>
                      <td><?php echo $boucher->b_f_name ?> <?php echo $boucher->b_l_name ?></td>
                      <td><?php echo $boucher->b_email ?></td>
                      <td><?php echo $boucher->b_mobile ?></td>
                      <td>
                        <a class="btn btn-danger btn-sm" onclick="return confirm('Are you sure?')" href="<?php echo base_url() ?>admin/product/delete_boucher_inq/<?php echo $boucher->b_id ?>"><i class="fa fa-trash" aria-hidden="true"></i></a>
                      </td>
                    </tr>
                    <?php $i++; ?>
                    <?php endforeach; ?>
                    </tbody>
                    
                  </table>
                </div>
              </div>
            </div>
          </div>
      </div>
    </section>


  </div>
<style type="text/css">
.dataTables_length
{
  display: none!important;
}</style>
<script type="text/javascript">
   $(document).ready(function () {  
      $('#pop_all').on('click', function(e) {  
         if($(this).is(':checked',true))    
         {  
            $(".sub_chk_pop").prop('checked', true);    
         } 
         else 
         {    
            $(".sub_chk_pop").prop('checked',false);    
         }    
      });  
 
      $('#delete_pop_up').on('click', function(e) 
      {  
        var allVals = [];    
        $(".sub_chk_pop:checked").each(function() 
        {    
            allVals.push($(this).attr('data-id'));  
        });    
        
        if(allVals.length <=0)    
        {    
            alert("Please select row.");    
        }  
        else 
        {    
          var check = confirm("Are you sure you want to delete this row?");    
          if(check == true){    
            var join_selected_values = allVals.join(",");   
            $.ajax({  
                url: '<?php echo base_url()?>admin/product/delete_inq_first_all',  
                type: 'POST',  
                data: 'ids='+join_selected_values,  
                success: function (data) {  
                  console.log(data);  
                  $(".sub_chk_pop:checked").each(function() 
                  {    
                      $(this).parents("tr").remove();  
                  });  
                  alert("Item Deleted successfully.");  
                },  
                error: function (data) {  
                    alert(data.responseText);  
                }  
            });  
          $.each(allVals, function( index, value ) {  
              $('table tr').filter("[data-row-id='" + value + "']").remove();  
          });  
        }    
      }    
    }); 
  }); 
    $(document).ready(function () {  
    $('#advance_all').on('click', function(e) {  
         if($(this).is(':checked',true))    
         {  
            $(".sub_chk_advance").prop('checked', true);    
         } 
         else 
         {    
            $(".sub_chk_advance").prop('checked',false);    
         }    
      });  
 
      $('#delete_advance').on('click', function(e) 
      {  
        var allVals = [];    
        $(".sub_chk_advance:checked").each(function() 
        {    
            allVals.push($(this).attr('data-id'));  
        });    
        
        if(allVals.length <=0)    
        {    
            alert("Please select row.");    
        }  
        else 
        {    
          var check = confirm("Are you sure you want to delete this row?");    
          if(check == true){    
            var join_selected_values = allVals.join(",");   
            $.ajax({  
                url: '<?php echo base_url()?>admin/product/delete_inq_all',  
                type: 'POST',  
                data: 'ids='+join_selected_values,  
                success: function (data) {  
                  console.log(data);  
                  $(".sub_chk_advance:checked").each(function() 
                  {    
                      $(this).parents("tr").remove();  
                  });  
                  alert("Item Deleted successfully.");  
                },  
                error: function (data) {  
                    alert(data.responseText);  
                }  
            });  
          $.each(allVals, function( index, value ) {  
              $('table tr').filter("[data-row-id='" + value + "']").remove();  
          });  
        }    
      }    
    }); 
  });  
  $(document).ready(function () {  
    $('#abandoned_all').on('click', function(e) {  
         if($(this).is(':checked',true))    
         {  
            $(".sub_chk_abandoned").prop('checked', true);    
         } 
         else 
         {    
            $(".sub_chk_abandoned").prop('checked',false);    
         }    
      });  
 
      $('#delete_abandoned').on('click', function(e) 
      {  
        var allVals = [];    
        $(".sub_chk_abandoned:checked").each(function() 
        {    
            allVals.push($(this).attr('data-id'));  
        });    
        
        if(allVals.length <=0)    
        {    
            alert("Please select row.");    
        }  
        else 
        {    
          var check = confirm("Are you sure you want to delete this row?");    
          if(check == true){    
            var join_selected_values = allVals.join(",");   
            $.ajax({  
                url: '<?php echo base_url()?>admin/product/delete_inq_all',  
                type: 'POST',  
                data: 'ids='+join_selected_values,  
                success: function (data) {  
                  console.log(data);  
                  $(".sub_chk_abandoned:checked").each(function() 
                  {    
                      $(this).parents("tr").remove();  
                  });  
                  alert("Item Deleted successfully.");  
                },  
                error: function (data) {  
                    alert(data.responseText);  
                }  
            });  
          $.each(allVals, function( index, value ) {  
              $('table tr').filter("[data-row-id='" + value + "']").remove();  
          });  
        }    
      }    
    }); 
  });  
    $(document).ready(function () {  
    $('#video_all').on('click', function(e) {  
         if($(this).is(':checked',true))    
         {  
            $(".sub_chk_video").prop('checked', true);    
         } 
         else 
         {    
            $(".sub_chk_video").prop('checked',false);    
         }    
      });  
 
      $('#delete_video').on('click', function(e) 
      {  
        var allVals = [];    
        $(".sub_chk_video:checked").each(function() 
        {    
            allVals.push($(this).attr('data-id'));  
        });    
        
        if(allVals.length <=0)    
        {    
            alert("Please select row.");    
        }  
        else 
        {    
          var check = confirm("Are you sure you want to delete this row?");    
          if(check == true){    
            var join_selected_values = allVals.join(",");   
            $.ajax({  
                url: '<?php echo base_url()?>admin/product/delete_video_demo_all',  
                type: 'POST',  
                data: 'ids='+join_selected_values,  
                success: function (data) {  
                  console.log(data);  
                  $(".sub_chk_video:checked").each(function() 
                  {    
                      $(this).parents("tr").remove();  
                  });  
                  alert("Item Deleted successfully.");  
                },  
                error: function (data) {  
                    alert(data.responseText);  
                }  
            });  
          $.each(allVals, function( index, value ) {  
              $('table tr').filter("[data-row-id='" + value + "']").remove();  
          });  
        }    
      }    
    }); 
  });  
    $(document).ready(function () {  
    $('#demo_all').on('click', function(e) {  
         if($(this).is(':checked',true))    
         {  
            $(".sub_chk_demo").prop('checked', true);    
         } 
         else 
         {    
            $(".sub_chk_demo").prop('checked',false);    
         }    
      });  
 
      $('#delete_demo').on('click', function(e) 
      {  
        var allVals = [];    
        $(".sub_chk_demo:checked").each(function() 
        {    
            allVals.push($(this).attr('data-id'));  
        });    
        
        if(allVals.length <=0)    
        {    
            alert("Please select row.");    
        }  
        else 
        {    
          var check = confirm("Are you sure you want to delete this row?");    
          if(check == true){    
            var join_selected_values = allVals.join(",");   
            $.ajax({  
                url: '<?php echo base_url()?>admin/product/delete_demo_inq_all',  
                type: 'POST',  
                data: 'ids='+join_selected_values,  
                success: function (data) {  
                  console.log(data);  
                  $(".sub_chk_demo:checked").each(function() 
                  {    
                      $(this).parents("tr").remove();  
                  });  
                  alert("Item Deleted successfully.");  
                },  
                error: function (data) {  
                    alert(data.responseText);  
                }  
            });  
          $.each(allVals, function( index, value ) {  
              $('table tr').filter("[data-row-id='" + value + "']").remove();  
          });  
        }    
      }    
    }); 
  });  
    $(document).ready(function () {  
    $('#brochure_all').on('click', function(e) {  
         if($(this).is(':checked',true))    
         {  
            $(".sub_chk_brochure").prop('checked', true);    
         } 
         else 
         {    
            $(".sub_chk_brochure").prop('checked',false);    
         }    
      });  
 
      $('#delete_brochure').on('click', function(e) 
      {  
        var allVals = [];    
        $(".sub_chk_brochure:checked").each(function() 
        {    
            allVals.push($(this).attr('data-id'));  
        });    
        
        if(allVals.length <=0)    
        {    
            alert("Please select row.");    
        }  
        else 
        {    
          var check = confirm("Are you sure you want to delete this row?");    
          if(check == true){    
            var join_selected_values = allVals.join(",");   
            $.ajax({  
                url: '<?php echo base_url()?>admin/product/delete_boucher_inq_all',  
                type: 'POST',  
                data: 'ids='+join_selected_values,  
                success: function (data) {  
                  console.log(data);  
                  $(".sub_chk_brochure:checked").each(function() 
                  {    
                      $(this).parents("tr").remove();  
                  });  
                  alert("Item Deleted successfully.");  
                },  
                error: function (data) {  
                    alert(data.responseText);  
                }  
            });  
          $.each(allVals, function( index, value ) {  
              $('table tr').filter("[data-row-id='" + value + "']").remove();  
          });  
        }    
      }    
    }); 
  }); 
  </script>