<?php  $this->load->view('master/common/header.php',$data);
$base_name = $data['base_name'];
?>

    <div class="content">
        
        <!-- Start Content-->
        <div class="container-fluid">
            
            <!-- start page title -->
            <div class="row">
                <div class="col-12">
                    <div class="page-title-box">
                        <div class="page-title-right">
                            <ol class="breadcrumb m-0">
                                <li class="breadcrumb-item"><a href="javascript: void(0);"><?= $base_name;?></a></li>
                                <li class="breadcrumb-item active text-capitalize"><?= $page;?></li>
                            </ol>
                        </div>
                        <h4 class="page-title text-uppercase"><?= $page;?></h4>
                    </div>
                </div>
            </div>     
            <!-- end page title --> 

            <div class="row">
                <div class="col-md-12 col-xl-12">
                    <div class="card-box">
                        <div class="row">
                            <div class="col-sm-12">
							    <table id="key-table" class="table table-bordered dt-responsive nowrap" style="border-collapse: collapse; border-spacing: 0; width: 100%;">
                                    <thead>
                                        <tr>
                                            <th>#</th>
        									<th>Full Name</th>
        									<th>Phone</th>
        									<th>Email ID</th>
        									<th>User Message</th>
        									<th>Addon</th>
        									<th>Status</th>
        									<th>Action</th>
                                        </tr>
                                    </thead>


                                        <tbody>
                                        
								<?php if (!empty($enquiry)) {?>
									<?php foreach ($enquiry as $row) {?>
								        <tr>
                                            <td><?=$row['id'];?></td>
        									<td><?=$row['name'];?></td>
        									<td><?=$row['phone'];?></td>
        									<td><?=$row['email'];?></td>
        									<td>
        									    <a href="#custom-modal" class="btn btn-info btn-sm waves-effect waves-light"  onclick="viewMessage('#message_<?=$row['id'];?>')" data-animation="fadein" data-plugin="custommodal" data-overlayspeed="100" data-overlaycolor="#36404a">View Message</a>
        									    <input type="hidden" id="message_<?=$row['id'];?>" value="<?=$row['message'];?>">
        									</td>
        									<td><?=date('d M Y h:i:s A',strtotime($row['addon']));?></td>
        									<td>
        										<?php if ($row['status'] == 1) {?>
        											<span class="badge badge-success">Active</span>
        										<?php } else {?>
        											<span class="badge badge-warning">Pending</span>
        										<?php }?>
        									</td>
        									<td class="text-center">
        									    <div class="row">
        									        <div class="col-sm-12">
        									            <form class="form-horizontal" onsubmit="return deleteenquiry();" action="<?= base_url('master/action/delete');?>" method="post" enctype="multipart/form-data">
                                                            <input type="hidden" name="table" value="tbl_contact_inq" />
                                                            <input type="hidden" name="page" value="Contact Enquiry" />
                                                            <input type="hidden" name="id" value="<?=$row['id'];?>" />
                                                            
                                                            <button type="submit" class="btn btn-danger btn-sm" title="Delete">Delete</button>
                										</form>
        									        </div>
        									    </div>
        									</td>
        								</tr>
								<?php }?>
								<?php } else {?>
								<tr>
									<td colspan="9" class="text-center">Records Not Found</td>
								</tr>
								<?php }?>
							</tbody>
							</table>
							</div>
					    </div>
					</div>
				</div>
				<!-- /.col-md-6 -->
			</div>
			<!-- /.row -->
		</div>
		<!-- /.container-fluid -->
	</div>
	<!-- /.content -->
</div>
<!-- /.content-wrapper -->
<?php $this->load->view('master/common/footer.php'); ?>

<!-- Modal -->
<div id="custom-modal" class="modal-demo">
    <button type="button" class="close" onclick="Custombox.modal.close();">
        <span>&times;</span><span class="sr-only">Close</span>
    </button>
    <h4 class="custom-modal-title">User Message</h4>
    <div class="custom-modal-text text-muted overflow-y-auto mb-3" id="message_data"></div>
</div>
<style>
    .overflow-y-auto{
        overflow-y: auto;
        max-height: 300px;
    }
</style>
<script type="text/javascript">
    function viewMessage(id) {
        var val = $(id).val();
        $("#message_data").html(val);
    }
</script>

<script type="text/javascript">
	function deleteenquiry() {
		if (confirm("Are You Sure You Want TO Delete Contact Enquiry ?")) {
            return true;
		}
		return false;
	}
</script>