<?php
include 'header.php';
$page_nm = "Inquiry";
$pageUrl = "inquiry.php";

$id = $_REQUEST['id'];
	if ($_GET['mode'] == 'edit' && $id != '')
	{
		$editqry = "UPDATE ".DB_PREFIX."inquiry SET 
                   status='checked' WHERE id=" . $id;
				   
            $ai_db->aiQuery($editqry);
			
			$ai_core->aiGoPage($pageUrl . "?msg=2");
		
	}
    
    if ($_GET['mode'] == 'delete' && $id != '') 
	{
		$qry_del_su = "Delete from ".DB_PREFIX."inquiry WHERE id=".$id;
        $ai_db->aiQuery($qry_del_su);
		
		$ai_core->aiGoPage($pageUrl . "?msg=3");
    }
	

$qry = "SELECT * FROM tbl_inquiry ORDER BY id DESC";
$result = $ai_db->aiGetQueryObj($qry);

?>
<div class="main-panel">
    <div class="main-content">
        <div class="content-wrapper"><!-- Basic form layout section start -->
            <section id="horizontal-form-layouts">
                <div class="row">
                    <div class="col-sm-12">
                        <div class="content-header">Manage <?php echo $page_nm; ?></div>
                    </div>
                </div>
              

                    
                    <div class="col-lg-12 card">
                        <?php if ($_GET['msg'] != '') { ?>
                            <div class="alert <?php if($_GET['msg'] == "2"){ ?>alert-success<?php }else{?>alert-danger <?php } ?> alert-dismissible mb-2" role="alert" style="margin-top: 15px;">
                                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                    <span aria-hidden="true">&times;</span>
                                </button>
                                <strong>
                                    <?php
                                    if ($_GET['msg'] == "2") {
                                        echo UPDATE_MSG;
                                    }else if ($_GET['msg'] == '3') {
                                        echo DELETE_MSG;
                                    }
									
                                    ?>
                                </strong>
                            </div>
                        <?php } ?>

                        <div class="card-body collapse show">

                            <div class="card-block card-dashboard">

                                <table class="table table-striped table-bordered multi-ordering">
                                    <thead>
                                        <tr>
											<th>Name</th>
											<th>Email</th>
											<th>Mobile</th>
											<th>Message</th>
											<th>status</th>
											<th>Action</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php
                                        if (COUNT($result) > 0) {
                                            foreach ($result as $row) {
                                                ?>
                                                <tr>
													<td><?php echo $row->name;?></td>
													<td><?php echo $row->email;?></td>
													<td><?php echo $row->mobile;?></td>
													<td><?php echo $row->message;?></td>
													<td><?php echo $row->status;?></td>
													<td>
                                                        <a href="<?php echo $pageUrl . "?mode=delete&&id=".$row->id.""; ?>"><img src="assets/img/ico/delete.png" alt="Delete Icon" data-toggle="tooltip" data-placement="right" title="delete this row" onclick="return confirm('Are you sure You Want To Delete This Inquiry');"/></a>
														<?php if($row->status == 'unchecked'){ ?>
														<a href="<?php echo $pageUrl . "?mode=edit&&id=".$row->id.""; ?>" class="btn btn-raised btn-success btn-min-width mr-1 mb-1">Checked</a>
														<?php } ?>
														
                                                    </td>
													
                                                </tr>
                                                <?php
                                            }
                                        }
                                        ?>

                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                

            </section>
            <!-- // Basic form layout section end -->
        </div>
    </div>
	
	
	
											
											
<?php include ('footer.php'); ?>
<script type="text/javascript">
function chkFrm()
{
	if(document.getElementById("cover_image").value == "" && document.getElementById("old_file_name").value == "")
	{
		document.getElementById("cover_image").focus();
		alert("Please select image.");
		return false;
	}
	if(document.getElementById("status").value == "")
	{
		document.getElementById("status").focus();
		alert("Please select status.");
		return false;
	}
return true;
}
</script>