<?php namespace App\Http\Controllers;?>
<!DOCTYPE html>
<html>

<head>

    <title>Gallery | Dwarpaleshwor </title>
    <?php echo $__env->make('Admin.Parts.MetaCSS', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
    <style type="text/css">
         .img-wrap {
         position: relative;
         display: inline-block;
         border: 1px #e1e1e1 solid;
         font-size: 0;
         }
         .img-wrap .close {
         position: absolute;
         top: 2px;
         right: 2px;
         z-index: 100;
         background-color: #FFF;
         padding: 5px 2px 2px;
         color: #000;
         font-weight: bold;
         cursor: pointer;
         opacity: .2;
         text-align: center;
         font-size: 22px;
         line-height: 10px;
         border-radius: 50%;
         }
         .img-wrap:hover .close {
         opacity: 1;
         }
      </style>
      <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
   
      <script type="text/javascript">
         $(document).ready(function(){

           $('.close').on('click', function() {
           var id = $(this).siblings().data('id');
           var index = $(this).siblings().data('index');


                 $.ajax({
           url     : 'delgalleryimage',
           data : { token:id,index:index},
           method  : 'get',
           headers:
           {
           'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
           },
           success : function(response){

           } ,
           error:function(exception){;
           console.log(exception);
           }
           });
                   $(this).parent().css("display","none");
                   $(this).siblings().css("display","none");
         });

         });
      </script>
</head>

<body>

<!--====================================================
                     MAIN NAVBAR
======================================================-->
    <?php echo $__env->make('Admin.Parts.TopHeader', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

<!--====================================================
                    PAGE CONTENT
======================================================-->
    <div class="page-content d-flex align-items-stretch">

        <!--***** SIDE NAVBAR *****-->
        <?php echo $__env->make('Admin.Parts.LeftNav', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

        <div class="content-inner form-cont">
            <div class="row">
                <div class="col-md-12">
                    <div class="row">
                        <div class="col-md-6 col-lg-6">
                           <?php if(session('info')): ?>
                           <div class="alert alert-success" style="text-transform: capitalize;">
                              <?php echo e(session('info')); ?>

                           </div>
                           <?php endif; ?>
                           <?php
                               $gallery=session('avisd');
                           ?>
                           <?php if($errors->any()): ?>
                           <div class="alert alert-danger">
                              <ul>
                                 <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                 <li><?php echo e($error); ?></li>
                                 <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                              </ul>
                           </div>
                           <?php endif; ?>
                        </div>
                     </div>
                    <div class="card form" id="form1">
                        <div class="card-header">
                            <h3>Add gallery</h3>
                        </div>
                        <br>
                        <?php if(!$gallery): ?>
                        <form action="admin_gallery" method="post" enctype="multipart/form-data">
                            <?php else: ?>
                            <form action="<?php echo e(url('admin_gallery/update',array($gallery->id))); ?>" method="post" enctype="multipart/form-data">
                            <?php endif; ?>
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label for="title">Title</label>
                                        <input type="text" class="form-control" id="title" placeholder="Enter Title" name="title" value="<?php if($gallery) {echo $gallery->title;}?>">
                                        
                                    </div>
                                    
                                   
                                    


                                    <div class="form-group">
                                        <label for="exampleInputFile">File input</label>
                                       <?php if(!$gallery): ?>
                                        <input type="file" class="form-control-file" id="exampleInputFile" name="image[]" multiple required>
                                        
                                       
                                    </div>
                                    <?php else: ?>
                                    <input type="file" class="form-control-file" id="exampleInputFile" name="image[]" multiple >
                                    <div class="row" style="margin-left: 17%;margin-bottom: 1%;">
                                          <?php if($gallery): ?>
                                          <?php $__currentLoopData = AdminLogController::getimagefromtoken($gallery->token); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $dd): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                          <div class="img-wrap">
                                             <span class="close">&times;</span>
                                             <img src="img/Gallery/<?php echo e($dd->file_name); ?>" style="width: 200px;height: auto;float: left;" class="img-responsive "  data-index=<?php echo e($dd->file_name); ?> data-id=<?php echo e($dd->token); ?>>
                                          </div>
                                          <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                          <?php endif; ?>
                                       </div>
                                       <?php endif; ?>

                                    <div class="form-group">
                                        <label for="exampleTextarea">Description</label>
                                        <textarea class="form-control ckeditor" id="exampleTextarea" rows="3" name="description"><?php if($gallery) {echo $gallery->description;}?></textarea>
                                    </div>
                                   
                                    
                                </div>
                                
                            </div>
                            <input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>">
                            
                            <button type="reset" class="btn btn-general btn-white">Cancel</button>

                            <button type="submit" class="btn btn-general btn-blue mr-2"><?php if($gallery){echo "Update";}else {echo "Save";}?></button>
                        </form>
                    </div>

       <div class="card form" id="form1">           
        <div class="row">
          <div class="col-xs-12">
            <div class="box">
              <div class="box-header">
                <h3 class="box-title">Data Table</h3>
              </div>
             <!-- /.box-header -->
             <div class="box-body" >
              <table id="example2" class="table table-bordered table-hover">
                <thead>
                  <th width="5%">SN</th>
                
                  <th width="15%">Title</th>
               
                  <th width="60%">Description</th>
                  <th width="20%">Action</th>
                </tr>
                </thead>
                <tbody>
     
                  <tbody>
                  
                    <?php
                    echo AdminlogController::table_generator('galleries',array('title','description'), 'admin_gallery','Gallery');?>
  
           
                </tbody>
               
              </table>
            </div>
            <!-- /.box-body -->
            </div>
          </div>
        </div>
    </div>

                  
                
                </div>
            </div>
        </div>
    </div>

<?php echo $__env->make('Admin.Parts.Js', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
</body>

</html>
