<?php include("../Header/Session.php"); ?>
<?php include("../Header/Connection.php"); ?>

<!DOCTYPE html>
<html lang="en">
<?php include ("../Header/head.php"); ?>
<body class="skin-default fixed-layout">
<!-- Main wrapper - style you can find in pages.scss -->
<div id="main-wrapper">    
<?php include ("../Header/header.php"); ?>
<?php include ("../Header/left_menu.php"); ?>
<?php include ("../Header/right_sidebar.php"); ?>
        
<!-- Page wrapper  -->
<div class="page-wrapper">
<!-- Container fluid  -->
<div class="container-fluid">

<!-- Bread crumb and right sidebar toggle -->
<!--?php include ("../Header/breadcumb.php"); ?-->
<br><br>
<!-- End Bread crumb and right sidebar toggle -->   
<!-- Start Page Content -->
<!-- ============================================================== -->

<div class="row">
<div class="col-lg-12">


<div class="card">
    <div class="card-body">
        <h4 class="card-title">List of MyUHM  Attachment</h4>
        <div class="table-responsive m-t-40">            
            <table class="display nowrap table table-hover table-striped table-bordered" cellspacing="0" width="100%">
                <thead>
                    <tr>
                        <th>File Attachment</th>
                        <th>Info</th>
                        <th>Created Date</th>
                        <?php if ($level == '1')
                        {
                        ?>
                        <th>Action</th>
                        <?php
						}
                        ?>
                        
                    </tr>
                </thead>                                      
                <tbody>
                    <?php if ($level == '1')
                    {
                    ?>
                        <form method="post" action="../Controller/Database_sql.php" enctype="multipart/form-data">
                        <tr>
                            <td><input type="file" class="form-control" name="file_attach"></td> 
                            <td><input type="text" class="form-control" name="title"></td> 
                            <td></td>
                            <td>
                                <button name="Add_Attachment" class="btn btn-success"><i class="fa fa-check"></i> Add</button>  
                            </td>
                        </form> 
                    <?php
					}
                    ?>
                    
                    <?php
                    $q = "SELECT *
                    FROM my_attachment
                    Where status='1'
                    order by id Asc";
                    $result = $mysqli->query($q);
                    if ($result->num_rows > 0)
                    {
                        while($record = $result -> fetch_assoc())
                        {  
						    $id = $record['id'];
                            $title = $record['title'];
                            $file_attach = $record['file_attach'];
                            $created_date = date('d-m-Y', strtotime($record['created_date']));
                    ?>
                    <form method="post" action="../Controller/Database_sql.php" enctype="multipart/form-data">
                    <tr>
                        <td> 
                            <?php if ($level == '1')
                            {
                            ?>
                            <input type="file" class="form-control" name="file_attach">
                            <?php
						    }
                            ?>
                        
                            <?php if ($file_attach != "")
                            {
                            ?>
                              <br>
                              <a href="../Controller/uploads/<?php echo $file_attach; ?>" download><font color="blue">Click To Download</font></a><br>
                            <?php
							}
                            ?>
                        </td> 
                        <td>
                            <?php if ($level == '1')
                            {
                            ?>
                            <input type="text" class="form-control" name="title" value="<?php echo $title; ?>">
                            <?php
						    }
                            else
                            {
                            ?>
                            <?php echo $title; ?>
                            <?php
							}
                            ?>
                        </td> 
                        <td><?php echo $created_date; ?></td> 
                        <input type="hidden" class="form-control"  name="id" value="<?php echo $id; ?>">
                        <?php if ($level == '1')
                        {
                        ?>
                        <td>
                            <button name="Update_Attachment" class="btn btn-success"><i class="fa fa-check"></i> Update</button>
                            <a href="../Controller/Database_sql.php?form_name_delete_attachment=delete_attachment&id=<?php echo $id;?>" class="btn btn-danger"></i>&nbsp; Delete</a>    
                        </td>
                        <?php
						}
                        ?>                           
                    </form> 
                    </tr>
                    <?php 
                    }
                    }
                    ?>
                </tbody>
            </table>
            </form>                                 
        </div>
    </div>
</div>    




</div> 
</div> 


<!-- ============================================================== -->
<!-- End PAge Content -->

</div>
<!-- End Container fluid  -->
</div>
<!-- End Page wrapper  -->

<!-- Footer Start-->
<?php include ("../Footer/footer.php"); ?>
<!-- Footer End-->

</div>
<!-- End Wrapper -->
<!-- All Jquery -->
    

<!-- All Jquery Start-->
<?php include ("../Header/all_jquery.php"); ?>
<!-- All Jquery End-->

</body>

</html>