<?php
session_start();
include_once "../config.php";
require_once '../database1.php';
require_once "../check_admin.php";


class Index extends database
{
    public function getBannersLV()
    {
        return $this->fetchAll('tb_banners', ['cl_domain' => 'https://zillo.lv']);
    }
    
    public function getBannersLT()
    {
        return $this->fetchAll('tb_banners', ['cl_domain' => 'https://zillo.lt']);
    }
    
    public function getBannersEE()
    {
        return $this->fetchAll('tb_banners', ['cl_domain' => 'https://zillo.ee']);
    }
    
    public function getBannersFI()
    {
        return $this->fetchAll('tb_banners', ['cl_domain' => 'https://zillo.fi']);
    }
}

$obj = new Index();
$lvBanners = $obj->getBannersLV();
$ltBanners = $obj->getBannersLT();
$eeBanners = $obj->getBannersEE();
$fiBanners = $obj->getBannersFI();

$templateType = 'add';
include '../header.php';
?>

<link rel="stylesheet" href="<?php echo DOMAIN ?>/jquery_file_upload/css/style.css">
<link rel="stylesheet" href="<?php echo DOMAIN ?>/jquery_file_upload/css/jquery.fileupload.css">
<input type="hidden" class="file_url" value="<?php echo DOMAIN ?>/ajax/upload_banner" />
               <!-- MAIN CONTENT-->
            <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">Banners</h2>
                                    
                                </div>
                                
                              
                            </div>
                        </div>
                        
                        <div class="row m-t-25 m-row">
                    
                            <div class="col-lg-12">
                                <div class="card">
                                    <div class="card-header">
                                        Zillo.lv
                                    </div>
                                    <div class="card-body card-block">
                                        <table class="table table-striped">
                                            <thead>
                                                <tr>
                                                    <th>
                                                        Image
                                                    </th>
                                                    <th>
                                                        
                                                    </th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php
                                                
                                                if(!empty($lvBanners))
                                                {
                                                    foreach($lvBanners AS $lvBanner)
                                                    {
                                                    ?>
                                                        <tr>
                                                         <td>
                                                             <form method="post">
                                                                 <div class="form-group input-container file_upload_container">

                                                                         <input type="hidden" class="image file_url" name="image" value="<?php if(isset($lvBanner['cl_image'])){echo $lvBanner['cl_image'];}?>"/>
                                                                         <input type="hidden" class="name"   />
                                                                             <!-- The container for the uploaded files -->
                                                                             <span class="btn btn-success fileinput-button">
                                                                             <i class="glyphicon glyphicon-plus"></i>
                                                                             <span>Select file</span>
                                                                             <!-- The file input field used as target for the file upload widget -->
                                                                             <input class="fileupload" type="file" name="file" >
                                                                             </span>
                                                                             <br>
                                                                         <br>
                                                                         <!-- The global progress bar -->
                                                                         <div class="progress">
                                                                             <div class="progress-bar progress-bar-success"></div>
                                                                         </div>
                                                                         <!-- The container for the uploaded files -->
                                                                         <div class="files_area"><img src="<?php echo MAIN_DOMAIN ?>/uploads/banner/<?php echo $lvBanner['cl_image'] ?>" style="max-width:240px" /></div>
                                                                         <div class="file_name">

                                                                             </div>
                                                                          <div class="error_area"></div>


                                                                 <div class="error-input"></div>



                                                             </div>

                                                                 <input type="hidden" name="id" value="<?php echo $lvBanner['cl_id'] ?>" />
                                                             </form>
                                                         </td>
                                                         <td>
                                                             <button type="button" class="btn btn-success btn-add">Update Row</button>
                                                         </td>
                                                     </tr>
                                                    <?php
                                                    }
                                                }
                                                ?>
                                            </tbody>
                                            
                                        </table>
                                   </div>
                                </div>
                            </div>
                            
                            <div class="col-lg-12">
                                <div class="card">
                                    <div class="card-header">
                                        Zillo.lt
                                    </div>
                                    <div class="card-body card-block">
                                        <table class="table table-striped">
                                            <thead>
                                                <tr>
                                                    <th>
                                                        Image
                                                    </th>
                                                    <th>
                                                        
                                                    </th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php
                                                
                                                if(!empty($ltBanners))
                                                {
                                                    foreach($ltBanners AS $ltBanner)
                                                    {
                                                    ?>
                                            <tr>
                                                <td>
                                                    <form method="post">
                                                        <div class="form-group input-container file_upload_container">
                                                            
                                                                <input type="hidden" class="image file_url" name="image" value="<?php if(isset($ltBanner['cl_image'])){echo $ltBanner['cl_image'];}?>"/>
                                                                <input type="hidden" class="name"   />
                                                                    <!-- The container for the uploaded files -->
                                                                    <span class="btn btn-success fileinput-button">
                                                                    <i class="glyphicon glyphicon-plus"></i>
                                                                    <span>Select file</span>
                                                                    <!-- The file input field used as target for the file upload widget -->
                                                                    <input class="fileupload" type="file" name="file" >
                                                                    </span>
                                                                    <br>
                                                                <br>
                                                                <!-- The global progress bar -->
                                                                <div class="progress">
                                                                    <div class="progress-bar progress-bar-success"></div>
                                                                </div>
                                                                <!-- The container for the uploaded files -->
                                                                <div class="files_area"><img src="<?php echo MAIN_DOMAIN ?>/uploads/banner/<?php echo $ltBanner['cl_image'] ?>" style="max-width:240px" /></div>
                                                                <div class="file_name">

                                                                    </div>
                                                                 <div class="error_area"></div>


                                                        <div class="error-input"></div>
                                                        
                                                        
                                                   
                                                    </div>
                                                        
                                                       <input type="hidden" name="id" value="<?php echo $ltBanner['cl_id'] ?>" />
                                                    </form>
                                                </td>
                                                <td>
                                                    <button type="button" class="btn btn-success btn-add">Update Row</button>
                                                </td>
                                            </tr>
                                            <?php
                                                    }
                                                }
                                                ?>
                                            </tbody>
                                        </table>
                                   </div>
                                </div>
                            </div>
                            
                            <div class="col-lg-12">
                                <div class="card">
                                    <div class="card-header">
                                        Zillo.ee
                                    </div>
                                    <div class="card-body card-block">
                                        <table class="table table-striped">
                                            <thead>
                                                <tr>
                                                    <th>
                                                        Image
                                                    </th>
                                                    <th>
                                                        
                                                    </th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                             <?php
                                                
                                                if(!empty($eeBanners))
                                                {
                                                    foreach($eeBanners AS $eeBanner)
                                                    {
                                                    ?>
                                           <tr>
                                                <td>
                                                    <form method="post">
                                                        <div class="form-group input-container file_upload_container">
                                                            
                                                                <input type="hidden" class="image file_url" name="image" value="<?php if(isset($eeBanner['cl_image'])){echo $eeBanner['cl_image'];}?>"/>
                                                                <input type="hidden" class="name"   />
                                                                    <!-- The container for the uploaded files -->
                                                                    <span class="btn btn-success fileinput-button">
                                                                    <i class="glyphicon glyphicon-plus"></i>
                                                                    <span>Select file</span>
                                                                    <!-- The file input field used as target for the file upload widget -->
                                                                    <input class="fileupload" type="file" name="file" >
                                                                    </span>
                                                                    <br>
                                                                <br>
                                                                <!-- The global progress bar -->
                                                                <div class="progress">
                                                                    <div class="progress-bar progress-bar-success"></div>
                                                                </div>
                                                                <!-- The container for the uploaded files -->
                                                                <div class="files_area"><img src="<?php echo MAIN_DOMAIN ?>/uploads/banner/<?php echo $eeBanner['cl_image'] ?>" style="max-width:240px" /></div>
                                                                <div class="file_name">

                                                                    </div>
                                                                 <div class="error_area"></div>


                                                        <div class="error-input"></div>
                                                        
                                                        
                                                   
                                                    </div>
                                                        
                                                       <input type="hidden" name="id" value="<?php echo $eeBanner['cl_id'] ?>" />
                                                    </form>
                                                </td>
                                                <td>
                                                    <button type="button" class="btn btn-success btn-add">Update Row</button>
                                                </td>
                                            </tr>
                                            <?php
                                                    }
                                                }
                                                ?>
                                            </tbody>
                                        </table>
                                   </div>
                                </div>
                            </div>
                            
                            <div class="col-lg-12">
                                <div class="card">
                                    <div class="card-header">
                                        Zillo.fi
                                    </div>
                                    <div class="card-body card-block">
                                        <table class="table table-striped">
                                            <thead>
                                                <tr>
                                                    <th>
                                                        Image
                                                    </th>
                                                    <th>
                                                        
                                                    </th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                             <?php
                                                
                                                if(!empty($fiBanners))
                                                {
                                                    foreach($fiBanners AS $fiBanner)
                                                    {
                                                    ?>
                                           <tr>
                                                <td>
                                                    <form method="post">
                                                        <div class="form-group input-container file_upload_container">
                                                            
                                                                <input type="hidden" class="image file_url" name="image" value="<?php if(isset($fiBanner['cl_image'])){echo $fiBanner['cl_image'];}?>"/>
                                                                <input type="hidden" class="name"   />
                                                                    <!-- The container for the uploaded files -->
                                                                    <span class="btn btn-success fileinput-button">
                                                                    <i class="glyphicon glyphicon-plus"></i>
                                                                    <span>Select file</span>
                                                                    <!-- The file input field used as target for the file upload widget -->
                                                                    <input class="fileupload" type="file" name="file" >
                                                                    </span>
                                                                    <br>
                                                                <br>
                                                                <!-- The global progress bar -->
                                                                <div class="progress">
                                                                    <div class="progress-bar progress-bar-success"></div>
                                                                </div>
                                                                <!-- The container for the uploaded files -->
                                                                <div class="files_area"><img src="<?php echo MAIN_DOMAIN ?>/uploads/banner/<?php echo $fiBanner['cl_image'] ?>" style="max-width:240px" /></div>
                                                                <div class="file_name">

                                                                    </div>
                                                                 <div class="error_area"></div>


                                                        <div class="error-input"></div>
                                                        
                                                        
                                                   
                                                    </div>
                                                        
                                                       <input type="hidden" name="id" value="<?php echo $fiBanner['cl_id'] ?>" />
                                                    </form>
                                                </td>
                                                <td>
                                                    <button type="button" class="btn btn-success btn-add">Update Row</button>
                                                </td>
                                            </tr>
                                            <?php
                                                    }
                                                }
                                                ?>
                                            </tbody>
                                        </table>
                                   </div>
                                </div>
                            </div>
                          
                        </div>
                        
                        
                        <script>
                            $(document).ready(function(){
                                $('.btn-add').click(function(){
                                    var parent = $(this).parents('table').first();
                                    
                                    var html = '<tr>';
                                            html+= '<td>';
                                                    html+= '<input type="file" class="form-control" />';
                                            html+= '</td>';
                                            html+= '<td>';
                                                html+= '<button type="button" class="btn btn-danger btn-delete">Delete</button>';
                                            html+= '</td>';
                                        html+= '</tr>';
                                    $(parent).append(html);
                                });
                            });
                            </script>
                            
                            
                              <!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
<script src="<?php echo DOMAIN ?>/jquery_file_upload/js/jquery.iframe-transport.js"></script>
<!-- The basic File Upload plugin -->
<script src="<?php echo DOMAIN ?>/jquery_file_upload/js/jquery.fileupload.js"></script>
                        
                   <?php
				   include '../footer.php';
				   ?>