<style>
    #pdfViewer {
        width: 33%;
        height: 400px;
        overflow: auto;
        border-radius: 20px;
        border: 1px solid #9993;
        box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
        margin-top: 30px;
        background-image: url(pdf.png);
        background-size: cover;
        background-position: center;
    }
</style>




<?php $__env->startSection('content'); ?>
<div class="side-title">
    <h3><?php echo e($head ?? ''); ?></h3>
</div>

<div class="border-item">
    <form class="form-row"  enctype="multipart/form-data"  method="post" action="<?php echo e($action); ?>">
        <?php if($task ?? ''  && $task->id): ?>
            <?php echo method_field('PUT'); ?>
        <?php endif; ?>
        <?php echo csrf_field(); ?>

   <div class="form-group col-lg-12">
            <label><?php echo e(meta('name', getCurrentLocale()) ?? __('tasks.user')); ?> </label>

           <select multiple class="form-control <?php echo e($errors->has('user_id') ? 'is-invalid' : ''); ?>"  name="user_id[]" id="user_id">
               <option selected disabled><?php echo e(__('tasks.select')); ?></option>
            <?php $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <option value="<?php echo e($user['id']); ?>"
            <?php if($task ?? ''  && $task->id): ?>
            <?php if($user['id'] == $task->user_id): ?>
            selected=""
            <?php endif; ?>
            <?php endif; ?>
            ><?php echo e($user['name']); ?></option>
           <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
       </select>
        </div>
        <div class="form-group col-lg-6">
            <label><?php echo e(meta('title', getCurrentLocale()) ?? __('tasks.title')); ?> </label>
            <input type="text" class="form-control <?php echo e($errors->has('title') ? 'is-invalid' : ''); ?>" name="title" placeholder="<?php echo e(meta('title', getCurrentLocale()) ??__('tasks.title')); ?>" value='<?php echo e(old("title", $task->title ?? "")); ?>'/>
        </div>

    
           <div class="form-group col-lg-6">
            <label><?php echo e(meta('description', getCurrentLocale()) ?? __('tasks.description')); ?> </label>
            <textarea class="form-control <?php echo e($errors->has('description') ? 'is-invalid' : ''); ?>" name="description" placeholder="<?php echo e(meta('description', getCurrentLocale()) ?? __('tasks.description')); ?>"><?php echo e(old("description", $task->description ?? "")); ?></textarea> 
        </div>
           <div class="form-group col-lg-6">
            <label><?php echo e(meta('time', getCurrentLocale()) ?? __('tasks.time')); ?> </label>
            <input type="number" class="form-control <?php echo e($errors->has('time') ? 'is-invalid' : ''); ?>" name="time" placeholder="<?php echo e(meta('time', getCurrentLocale()) ?? __('tasks.time')); ?>" value='<?php echo e(old("time", $task->time ?? "")); ?>'/>
        </div>
          
          <div class="form-group col-lg-6">
            <label><?php echo e(meta('start', getCurrentLocale()) ?? __('tasks.start')); ?> </label>
            <input type="date" class="form-control <?php echo e($errors->has('start') ? 'is-invalid' : ''); ?>" name="start" placeholder="<?php echo e(meta('start', getCurrentLocale()) ?? __('tasks.start')); ?>" value='<?php echo e(old("start", $task->start ?? "")); ?>'/>
        </div>
       
          <div class="form-group col-lg-6">
            <label><?php echo e(meta('end', getCurrentLocale()) ?? __('tasks.end')); ?> </label>
            <input type="date" class="form-control <?php echo e($errors->has('end') ? 'is-invalid' : ''); ?>" name="end" placeholder="<?php echo e(meta('end', getCurrentLocale()) ?? __('tasks.end')); ?>" value='<?php echo e(old("end", $task->end ?? "")); ?>'/>
        </div>
        
       
        
        
        
              <div class="row pricing-list-item border-item mb-4 col-lg-12" <?php if(!($task ?? ''  && $task->id)): ?>  style="display:none" <?php endif; ?> id="files">
                 <?php if($task ?? ''  && $task->id): ?>
                    <?php $__currentLoopData = $task_files; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    
               <div class="form-group col-lg-12">
            <label><?php echo e(meta('file', getCurrentLocale()) ?? __('tasks.file')); ?> </label>
            <input id="image_thumbnail<?php echo e($key); ?>" class="<?php echo e($key); ?>" type="hidden" name="file" value="<?php echo e(old("file", $row->file ?? "")); ?>"/>

            <div class="images main_image<?php echo e($key); ?> <?php echo e(old('file', $row->file ?? '') ? ' wow fadeInUp' : 'hide'); ?>">
                <div class="col-lg-12">
                    <div class="items">
                        <div class="img">
                            <a href="#" id="lfm" data-input=".image_thumbnail<?php echo e($key); ?>" data-preview=".image_holder<?php echo e($key); ?>" class="lfm" data-hide=".pick_button">
                               <?php echo e($row->file); ?>

                            </a>
                        </div>
                        <a href="#" class="showHide resetImage close" data-empty=".image_thumbnail<?php echo e($key); ?>" data-hide=".main_image<?php echo e($key); ?>" data-show=".pick_button"><i class="fas fa-times"></i></a>
                    </div>
                </div>
            </div>

           
        </div>
            
             <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
             <?php endif; ?>
                </div>
<div class="col-lg-12">
       <a style="cursor: pointer;" <?php if($task ?? ''  && $task->id): ?> data-id="<?php echo e(count($task_files)); ?>" <?php else: ?> data-id="0" <?php endif; ?> onclick="addfiles(this)" class="btn_1 gray "><i class="fa fa-fw fa-plus-circle"></i><?php echo e(__("tasks.add_file")); ?></a>
                   
</div>
        
        
        
        
       <div class="border-item photos col-md-12 other_image_container">
            <div class="row">
                <?php if($task ?? false): ?>
                    <?php $__currentLoopData = $task_photos; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $photo): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <div class="col-md-4">
                            <div class="items">
                                <div class="img">
                                    <a href="<?php echo e(asset($photo->file ?? '')); ?>" data-fancybox="gallery"><img src="<?php echo e(asset($photo->file ?? '')); ?>" alt=""></a>
                                </div>
                                <input type="hidden" name="images[]" value="<?php echo e($photo->file ?? ""); ?>">
                                <a href="#" class="close"><i class="fas fa-times"></i></a>
                            </div>
                        </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                <?php endif; ?>
            </div>
            <div class="text-center">
                <input id="other_image_thumbnail" class="other_image_thumbnail" type="hidden"/>
                <div class="clearfix"></div>
                <span id="add">
                    <a id="lfm" data-width="" data-cache="article_gallery" data-input=".other_image_thumbnail" data-preview="" data-show="" data-hide="" class="lfm add">
                        Add New Image
                    </a>
                </span>
            </div>
        </div>
       
       
        

       


        <div class="text-center mt-5 col-12">
            <button class="butn"><span><?php echo e(__('dashboard.save')); ?></span></button>
        </div>
    </form>
</div>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('inner_js'); ?>
<script>
    function addfiles(elem){
        $("#files").css("display", "block");
        var num = $(elem).attr('data-id');
        
        var newrow = parseInt(num)+1; 
        $(elem).attr('data-id', newrow);
        
         $.ajax({
          url : urls+'/'+num,
          type : 'GET',
          data : 'nothing',
          dataType : 'json',
          success:function(data)
          {
            $('#files').append(data);
          }
        })
    }
</script>
    <!-- Editor JS files -->
        <script src="https://mozilla.github.io/pdf.js/build/pdf.js"></script>

    <script>
        // Loaded via <script> tag, create shortcut to access PDF.js exports.
        var pdfjsLib = window['pdfjs-dist/build/pdf'];
        // The workerSrc property shall be specified.
        pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://mozilla.github.io/pdf.js/build/pdf.worker.js';
        $("#myPdf").on("change", function(e) {
            var file = e.target.files[0]
            if (file.type == "application/pdf") {
                var fileReader = new FileReader();
                fileReader.onload = function() {
                    var pdfData = new Uint8Array(this.result);
                    // Using DocumentInitParameters object to load binary data.
                    var loadingTask = pdfjsLib.getDocument({
                        data: pdfData
                    });
                    loadingTask.promise.then(function(pdf) {
                        console.log('PDF loaded');

                        // Fetch the first page
                        var pageNumber = 1;
                        pdf.getPage(pageNumber).then(function(page) {
                            console.log('Page loaded');

                            var scale = 1.5;
                            var viewport = page.getViewport({
                                scale: scale
                            });

                            // Prepare canvas using PDF page dimensions
                            var canvas = $("#pdfViewer")[0];
                            var context = canvas.getContext('2d');
                            canvas.height = viewport.height;
                            canvas.width = viewport.width;

                            // Render PDF page into canvas context
                            var renderContext = {
                                canvasContext: context,
                                viewport: viewport
                            };
                            var renderTask = page.render(renderContext);
                            renderTask.promise.then(function() {
                                console.log('Page rendered');
                            });
                        });
                    }, function(reason) {
                        // PDF loading error
                        console.error(reason);
                    });
                };
                fileReader.readAsArrayBuffer(file);
            }
        });
        function remove(elem){
            $(elem).closest('.form-row').remove();
        }
    </script>

            <script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
    <script>
        let route_prefix = "<?php echo e(url(config('lfm.prefix'))); ?>",
            url = "<?php echo e(url('/')); ?>/",
            urls = "<?php echo e(url('/')); ?>/admin/addfile",
            imagePath = "<?php echo e(asset('')); ?>";
    </script>
    <script src="<?php echo e(asset('assets/admin/js/editor.js')); ?>"></script>
    <script src="<?php echo e(asset('assets/admin/js/lfm.js')); ?>"></script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.layouts.container', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/omaralyomhost/public_html/green_apple/resources/views/admin/tasks/form.blade.php ENDPATH**/ ?>