<?php 
include('inc/header.php');
include('inc/sidebar.php');
$manage_enquiry = new website();
if(isset($_POST['active']))
{

    if(count($_POST['opt'])==1)
    {
        $id = "where id='".$_POST['opt'][0]."'";
        $total_row = 1;
    }
    else
    {
        $total_row = count($_POST['opt']);
        $id_emp = implode(',',$_POST['opt']);
        $id = "where id in ($id_emp)";

    }

    $manage_enquiry->active("tbl_enquiry",$id,$total_row,$page);
}
if(isset($_POST['deactive']))
{
  

    if(count($_POST['opt'])==1)
    {
        $id = "where id='".$_POST['opt'][0]."'";
        $total_row = 1;
    }
    else
    {
        $total_row = count($_POST['opt']);
        $id_emp = implode(',',$_POST['opt']);
        $id = "where id in ($id_emp)";

    }

    $manage_enquiry->deactive("tbl_enquiry",$id,$total_row,$page);
}
if(isset($_POST['delete']))
{

    if(count($_POST['opt'])==1)
    {
        $id = "where id='".$_POST['opt'][0]."'";
        $total_row = 1;
    }
    else
    {
        $total_row = count($_POST['opt']);
        $id_emp = implode(',',$_POST['opt']);
        $id = "where id in ($id_emp)";

    }

    $manage_enquiry->delete("tbl_enquiry",$id,$total_row,$page);
}

?>    
    <script type="text/javascript">
function checkall(objForm)
{
    var x = objForm;
  
   
len = objForm.elements.length;
var i=0;
for( i=0 ; i<len ; i++) 
{
if (objForm.elements[i].type=='checkbox') 
{
objForm.elements[i].checked=objForm.check_all.checked;
}
}
}  
</script>
     	<!--start page wrapper -->
				<!--start page wrapper -->
		<div class="page-wrapper">
			<div class="page-content"> 
				<!--breadcrumb-->
        <div class="row">
            <div class="col-lg-12">
                <div class="d-flex flex-wrap align-items-center justify-content-between mb-4">
                    <div>
                        <h4 class="mb-3">Enquiry List</h4>
                        <?php if($_SESSION['total_data']) echo '<p style="color:red;">'.$_SESSION['total_data'].'</p>';
                        
                         
                        ?>
                    </div>
                    
                </div>
            </div>
            <div class="col-lg-12">
                 <form name="form2"  method="post" id="form">
                <div class="table-responsive rounded mb-3">
              
                <table class="data-table table mb-0 tbl-server-info">
                    <thead class="bg-white text-uppercase">
                        <tr class="ligth ligth-data">
                            
                            <th>Sr.</th>
                            <th>Name</th>
                            <th>Email</th>
                            <th>Mobile</th>
                            <th>Class</th>
                            <th>Description</th>
                            <th>Date</th>
                            <th>Action</th>
                            <th>
                                <div class="checkbox d-inline-block">
                                    <input type="checkbox" class="checkbox-input"  id="check_all" onclick="checkall(this.form)" value="check_all" name="checkbox">
                                    <label for="checkbox1" class="mb-0"></label>
                                </div>
                            </th>
                        </tr>
                    </thead>
                    <tbody class="ligth-body">
                       <?php
                       $enquiry_list = $manage_enquiry->self_query("select * from tbl_enquiry order by id desc");
                       
                        if(count($enquiry_list)==0)
                        {
                            echo '<tr><td><td><td><span style="color:red">No Record Found</span></td></td></td></tr>';
                        }
                        else
                        {
                            for($i=0;$i<count($enquiry_list);$i++)
                            {
                                

                       ?>
                        <tr>
                            
                            <td><?=$i+1?>
                            <td>
                                <?=$enquiry_list[$i]['name'].' '.$enquiry_list[$i]['last_name'];?>
                            </td>
                            <td>
                                <?=$enquiry_list[$i]['email'];?>
                            </td>
                            <td>
                                <?=$enquiry_list[$i]['mobile'];?>
                            </td>
                            
                            <td>
                                <?=$enquiry_list[$i]['class'];?>
                            </td>
                           
                            <td>
                                <?=substr($enquiry_list[$i]['message'],0,100);?>
                            </td>
                            
                            
        
                            <td><?=date('d-m-Y h:i:s',strtotime($enquiry_list[$i]['add_date']));?></td>
                            <td>
                                <div class="d-flex align-items-center list-action">
                                    <a href="enquiry_detail?id=<?=$enquiry_list[$i]['id']?>"><i class="fa fa-eye"></i></a><!--
                                    <a class="badge bg-success mr-2" data-toggle="tooltip" data-placement="top" title="" data-original-title="Edit"
                                        href="add_news.php?edit=<?=$enquiry_list[$i]['id']?>"><i class="ri-pencil-line mr-0"></i></a>
                                    <!--<a class="badge bg-warning mr-2" data-toggle="tooltip" data-placement="top" title="" data-original-title="Delete"
                                        href="add_category.php?delete=<?=$enquiry_list[$i]['id']?>"><i class="ri-delete-bin-line mr-0"></i></a>-->
                                </div>
                            </td>
                            <td>
                                <div class="checkbox d-inline-block">
                                    <input type="checkbox" class="checkbox-input" id="checkbox2" name="opt[]" value="<?=$enquiry_list[$i]['id']?>">
                                    <label for="checkbox2" class="mb-0"></label>
                                </div>
                            </td>
                        </tr>
                    <?php }  } ?>
                    </tbody>
                </table>
                
            
            </div>
            <div class="row">
                <div class="col-md-4"></div>
                  <div class="col-md-8">
                       <!--<button type="submit" class="btn btn-primary" name="active">Active</button>
                       <button type="submit" class="btn btn-primary" name="deactive">Deactive</button>-->
                       <button type="submit" class="btn btn-primary" name="delete" onClick="return confirm('Are You Sure')">Delete</button>
                  </div>
               </div>
               <br>
               </form>
        </div>
    </div>
        <!-- Page end  -->
    </div>
    <!-- Modal Edit -->
    <div class="modal fade" id="edit-note" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">
                <div class="modal-body">
                    <div class="popup text-left">
                        <div class="media align-items-top justify-content-between">                            
                            <h3 class="mb-3">Product</h3>
                            <div class="btn-cancel p-0" data-dismiss="modal"><i class="las la-times"></i></div>
                        </div>
                        <div class="content edit-notes">
                            <div class="card card-transparent card-block card-stretch event-note mb-0">
                                <div class="card-body px-0 bukmark">
                                    <div class="d-flex align-items-center justify-content-between pb-2 mb-3 border-bottom">                                                    
                                        <div class="quill-tool">
                                        </div>
                                    </div>
                                    <div id="quill-toolbar1">
                                        <p>Virtual Digital Marketing Course every week on Monday, Wednesday and Saturday.Virtual Digital Marketing Course every week on Monday</p>
                                    </div>
                                </div>
                                <div class="card-footer border-0">
                                    <div class="d-flex flex-wrap align-items-ceter justify-content-end">
                                        <div class="btn btn-primary mr-3" data-dismiss="modal">Cancel</div>
                                        <div class="btn btn-outline-primary" data-dismiss="modal">Save</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
      </div>
    </div>
<?php 
include('inc/footer.php');
?>