<?php
require_once 'config.php';

include_once "../ichat/admin/route.php";
if ($session->is_logged_in() != true ) {
        redirect_to(WEB_LINK.'/login');
} else {
    $current_user = User::get_specific_id($session->admin_id);
    $current_user->set_online();
    $group = $current_user->prvlg_group;
}


require_once("../ichat/admin/assets/includes/Library/SessManager.php");
require_once("../ichat/admin/assets/includes/Library/User.php");
$session = new  SessManager();

//require_once "check_admin.php";
require_once 'database1.php';

class edit extends database
{
    public function getAllImages()
    {
        return $this->fetchAll('tb_image');
    }
}

$obj = new edit();


$images = $obj->getAllImages();
include 'header.php';
?>

<script src="<?php echo MAIN_DOMAIN ?>/ckeditor/ckeditor.js"></script>
 <link href="<?php echo MAIN_DOMAIN ?>/dropzone/dist/dropzone.css" rel="stylesheet" />
 <script src="<?php echo MAIN_DOMAIN ?>/dropzone/dist/dropzone.js"></script>
   <div class="main-content">
                <div class="section__content section__content--p30">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="overview-wrap">
                                    <h2 class="title-1">Images</h2>
                                    
                                </div>
                           
                            </div>
                        </div>
                        
                        <div class="row m-t-25 m-row">
                    
                            <div class="col-lg-10">
                                <div class="card">
                                    
                                    <div class="card-body card-block">
                                        <form action="ajax/image_upload"
                  class="dropzone"
                  id="flie_upload_dropzone">
                    

                  </form>

                  <table class="table table-bordered table-striped">
                      <thead>
                        <tr>
                            <th>
                                Image
                            </th>
                            <th>
                            	URL
                            </th>
                            <th>
                                Extension
                            </th>
                            <th>

                            </th>
                        </tr>
                      </thead>
                      <tbody>
                        <?php
                            if(!empty($images))
                            {
                                foreach($images AS $image)
                                {
                                    ?>
                                    <tr class="action-container">
                                        <td>
                                            <img src="<?php echo MAIN_DOMAIN ?>/uploads/images/<?php echo htmlspecialchars($image['cl_name']) ?>" style="max-width: 150px" />
                                        </td>
                                        <td>
                                            <a href="<?php echo MAIN_DOMAIN ?>/uploads/images/<?php echo htmlspecialchars($image['cl_name']) ?>" target="_blank"><?php echo DOMAIN ?>/uploads/images/<?php echo htmlspecialchars($image['cl_name']) ?></a>
                                        </td>
                                        <td>
                                            <?php echo htmlspecialchars($image['cl_extension']) ?>
                                        </td>
                                        <td>
                                             <button type="button" cluster-href="../ajax/delete_image_ajax?id=<?php  echo htmlspecialchars($image['cl_id']); ?>" class="remove btn btn-danger btn-delete"><i class="fa fa-trash"></i></button> 
                                             <div class="error-input"></div>                                   
                                        </td>
                                    </tr>
                                    <?php
                                }
                            }
                        ?>
                      </tbody>
                  </table>
                                       
                                    </div>
                                </div>
                            </div>
                          
                        </div>


<?php
include 'footer.php';
?>