<?php include("../../check.php"); ?>

<!DOCTYPE html>
<html>

<head>

<!-- Stylesheet file -->
<link rel="stylesheet" type="text/css" href="css/style.css">
    <?php include("../common/head.php") ?>

</head>
<body class="fixed-navbar fixed-sidebar">

<?php include("../common/header.php") ?>


<?php include("../common/aside.php") ?>

<div id="wrapper">

    <div class="small-header transition animated fadeIn">
    <div class="hpanel">
        <div class="panel-body">
            <div id="hbreadcrumb" class="pull-right">
                <ol class="hbreadcrumb breadcrumb">
                    <li><a href="<?php print $baseurl; ?>welcome/draft/addEdit.php"><button class="btn btn-info " type="button"><i class="fa fa-paste"></i> Add Pages</button></a></li>
                    <li><a href="<?php print $baseurl; ?>welcome/draft/index.php"><button class="btn btn-success " type="button"><i class="fa fa-list"></i> <span class="bold">All Pages Show</span></button></a></li>
                </ol>
            </div>
			
           <h2 class="font-light m-b-xs"><button class="btn btn-orange " type="button"><strong>Message:- <?=$_SESSION['message'];?><?php unset($_SESSION['message']);?></strong>
    
    
			   </button></h2>
        </div>
    </div>
</div>


<div class="content animate-panel">



    <div class="row">
        <div class="col-lg-12">
            <div class="hpanel">
                
                <div class="panel-body">
                 
     <form name="bulk_action_form" action="#" method="post" onSubmit="return deleteConfirm();"/>
                    <table id="example2" class="table table-striped table-bordered table-hover" width="100%" style="font-size:12px;">
            <thead class="thead-dark">
                <tr>
                    <th width="2%"></th>
					<th width="7%">Created</th>
					<th width="25%">Bodies</th>
					<th width="25%">Standard</th>
					<th width="7%">Comp.Name</th>
					<th width="19%">Certificate No</th>
					<th width="19%">Issue</th>
					<th width="15%">Send to Email</th>
					<th width="8%">Status</th>
                    <th width="20%">Action</th>
                </tr>
            </thead>
            <tbody>
                 <?php
                $j=1;
                $getall = $getData->runQuery("SELECT * FROM `live`");
                foreach($getall as $rows){
                    $bodies = $rows['bodies'];
                    $bodies = explode(',',$bodies);
                    $counts_bodies = count($bodies);
                    
                    $standard = $rows['standard'];
                    $standard = explode(',',$standard);
                    $counts_standard = count($standard);
                ?>
                <tr>
                    <td><?= $j++;?></td>
					<td><?= date("d M Y h:i:s A", strtotime($rows['date']));?></td>
					<td>
					    <?php
                            for($j=0; $j <= $counts_bodies; $j++){
                                $getall = $getData->runQuery("SELECT * FROM `bodies_tbl` where id='".$bodies[$j]."'");
                                echo $getall[0]['title'];
                                if($i != ($counts_bodies)){ echo "<br>";}
                        }?>
					</td>
                    <td>
                        <?php
                            for($i=0; $i <= $counts_standard; $i++){
                                $getalls = $getData->runQuery("SELECT * FROM `standard_tbl`  where id='".$standard[$i]."'");
                                echo $getalls[0]['title'];
                                if($i != ($counts_standard)){ echo "<br>";}
                        }?>
                    </td>
					<td><?= $rows['company_name']?></td>
					<td>BMG/12/022</td>
					<td><?= date("d-m-Y", strtotime($rows['date']));?></td>
					<td><img src="../images/email.png"></td>
                    <td class="status_<?= $rows['id']?>" onClick = status("<?= $rows['id']?>")><?php if($rows['status'] == "A"){ echo '<span class="badge badge-success">Active</span>'; }elseif($rows['status'] == "I"){ echo '<span class="badge badge-danger">Inactive</span>'; } ?></td>
                     <td>
                        <a href="addEdit.php?edit=<?= $rows['id']?>" class="btn btn-primary">edit</a>
                        <a href="postAction.php?del=<?= $rows['id']?>" class="btn btn-danger" onclick="return confirm('Are you sure to delete data?')?true:false;">delete</a>
                    </td>
                </tr>
                <?php } ?>
				
            </tbody>
        </table>
</form>
                </div>
            </div>

            
        </div>

    </div>
    </div>

   

    <?php include("../common/footer.php") ?>

</div>



<?php include("../common/js.php") ?>
<script>
	
    $(function () {

        // Initialize Example 1
        $('#example2').dataTable( {
            
            dom: "<'row'<'col-sm-4'l><'col-sm-4 text-center'B><'col-sm-4'f>>tp",
            "lengthMenu": [ [10, 25, 50, -1], [10, 25, 50, "All"] ],
            buttons: [
                {extend: 'copy',className: 'btn-sm'},
                {extend: 'csv',title: 'ExampleFile', className: 'btn-sm'},
                {extend: 'pdf', title: 'ExampleFile', className: 'btn-sm'},
                {extend: 'print',className: 'btn-sm'}
            ]
        });

        // Initialize Example 2
        $('#example1').dataTable();

    });
    
    function status(id){
        $.ajax({
            url:'postAction.php',
            type:'POST',
            data:{'status':id},
            success:function(data){
                $(".status_"+id).html(data);
            }
        });
    }

</script>

</body>

</html>