

<?php $__env->startSection('content'); ?>
    
    <div class="row">
        <div class="col-12">
            <div class="row">
        <div class="col-md-12">
          <div class="card">
            <div class="card-header pb-0">
              <div class="d-flex align-items-center">
                <p class="mb-0 font-weight-bolder">Edit Notification</p>
                <label class="btn btn-<?php echo e($errors->first('iserror') == 'false' ? 'success' : 'primary'); ?> btn-sm ms-auto"><?php echo e($errors->first('response')); ?></label>
                
              </div>
            </div>
            <div class="card-body">
                <!--<img src="<?php echo e(asset('storage/images/test.jpg')); ?>">-->
                <form method="post" action="<?php echo e(route('pushnotification.update',$notification->id)); ?>" id="addform" enctype="multipart/form-data" >
                    
                    <?php echo csrf_field(); ?>
                    <?php echo method_field('PUT'); ?>
                    
                    <div class="row">
                        <div class="col-md-6">
                          <div class="form-group">
                            <label for="example-text-input" class="form-control-label">Title <b style="color:red"><?php echo e($errors->first('title')); ?></b></label>
                            <input class="form-control" name="title" type="text" value="<?php echo e($notification->title); ?>" required>
                          </div>
                        </div>
                        <div class="col-md-6">
                          <div class="form-group">
                            <label for="example-text-input" class="form-control-label">Message <b style="color:red"><?php echo e($errors->first('message')); ?></b></label>
                            <input class="form-control" name="message" type="text" value="<?php echo e($notification->message); ?>" required>
                          </div>
                        </div>
                        <div class="col-md-6">
                          <div class="form-group" id="type_lay">
                            <label for="example-text-input" class="form-control-label">Select Type <b style="color:red"><?php echo e($errors->first('type')); ?></b></label>
                                <select class="form-control" id="type" name="type" onchange="onTypeChange()" required>
                                    <option value="custom" >Custom</option>
                                    <option value="category" <?php if($notification->action == "category"): ?> selected <?php endif; ?>>Category</option>
                                    <option value="subscription" <?php if($notification->action == "subscription"): ?> selected <?php endif; ?>>Subscription</option>
                                    <option value="url" <?php if($notification->action == "url"): ?> selected <?php endif; ?>>Url</option>
                                </select>
                          </div>
                        </div>
                        
                        <div class="col-md-6">
                          <div class="form-group">
                            <label for="example-text-input" class="form-control-label">Image <b style="color:red"><?php echo e($errors->first('image_posts')); ?></b></label>
                            <input class="form-control" type="file" id="image_posts" name="image" accept=".jpg, .png, jpeg, .PNG, .JPG, .JPEG" onchange="fileValidation()">
                          </div>
                        </div>
                        
                        <div class="col-md-6">
                          <div class="form-group" id="action_lay">
                               <?php if($notification->action == "category"): ?>
                                <label for="example-text-input" class="form-control-label">Select Category</label>
                                <select class="form-control" id="type" name="category" required>
                                    <?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $c): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($c->id); ?>" <?php if($c->id == $notification->action_item): ?> selected <?php endif; ?>><?php echo e($c->name); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                                
                                <?php elseif($notification->action == "subscription"): ?>
                                
                                <label for="example-text-input" class="form-control-label">Select Category</label>
                                <select class="form-control" id="type" name="category" required>
                                    <?php $__currentLoopData = $subscriptions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $c): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($c->id); ?>" <?php if($c->id == $notification->action_item): ?> selected <?php endif; ?>><?php echo e($c->name); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                                
                                <?php elseif($notification->action == "url"): ?>
                                
                                <label for="example-text-input" class="form-control-label">Url <b style="color:red"><?php echo e($errors->first("title")); ?></b></label>
                                <input class="form-control" name="url" type="text" value="<?php echo e($notification->action_item); ?>" required> 
                                <?php endif; ?>
                          </div>
                        </div>
                        
                        <div class="col-md-6 card-body mt-n3">
                            <div class="row mb" id="previewImages">
                                <?php if(!empty($notification->thumbnail)): ?>
                                <div class='imageCard col-xl-2 col-sm-3 mb-2'>
                                  <div class='avatar avatar-xxl position-relative'>
                                    <img src='<?php echo e(asset($notification->thumbnail)); ?>' id='imge' class='border-radius-md' alt='team-2'>
                                  </div>
                                </div>
                                <?php endif; ?>
                            </div>
                        </div>
                        <div class="col-md-12" >
                            <div class="form-check form-switch">
                              <input class="form-check-input" name="send_push" type="checkbox" id="rememberMe">
                              <label class="form-check-label" for="rememberMe">Send Push Notification Again</label>
                            </div>
                        </div>
                            
                        
                        
                        <div class="col-md-12 mt-2" >
                          <div class="form-group">
   
                            <?php if(Session::get('admin_type') == "Demo"): ?>
                              <div class="btn btn-primary col-md-6 demo_action">Submit</div>
                              <?php else: ?>
                              <input class="btn btn-primary col-md-6" type="submit" value="Submit">
                              <?php endif; ?>
                            
                          </div>
                        </div>
                     
                    </div>
                </form>
            </div>
          </div>
        </div>
        
      </div>
        </div>
    </div>
<!--<p class='remove pull-right bg-danger' style='cursor:pointer;position: absolute;top: 0px;right: 15px;padding: 6px 10px;' id='"+i+"'><i class='fa fa-close'></i></p>-->
<script type="text/javascript">

    
    function onTypeChange() {
        d = document.getElementById("type").value;
        // $('#type_lay').empty();
        // $('#type_lay').append(
        //         '<label for="example-text-input" class="form-control-label">Select Type</label>'+
        //         '<select name="subscription" onchange="onTypeChange()"  id="type" class="form-control" required>'+
        //         '<option value="custom">Custom</option>'+
        //         '<option value="category">Category</option>'+
        //         '<option value="subscription">Subscription</option>'+
        //         '<option value="url">Url</option>'+
        //         '</select>');
                
        if(d == 'custom'){
            $('#action_lay').empty();
        }else if(d == 'url'){
            $('#action_lay').empty();
            $('#action_lay').append(
            '<label for="example-text-input" class="form-control-label">Url <b style="color:red"><?php echo e($errors->first("title")); ?></b></label>'+
            '<input class="form-control" name="url" type="text" placeholder="www.google.com" required>');
        }else if(d == 'category'){
            $('#action_lay').empty();
            $('#action_lay').append(
                '<label for="example-text-input" class="form-control-label">Select Category</label>'+
                '<select name="category" class="form-control" required>'+
                '<option value="">Select Category</option><?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $c): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($c->id); ?>"><?php echo e($c->name); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select>');
        }else if(d == 'subscription'){
            $('#action_lay').empty();
            $('#action_lay').append(
                '<label for="example-text-input" class="form-control-label">Select Subscription</label>'+
                '<select name="subscription" class="form-control" required>'+
                '<option value="">Select Subscription</option><?php $__currentLoopData = $subscriptions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $c): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($c->id); ?>"><?php echo e($c->name); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select>');
        }
        create_custom_dropdowns();
    }

    function fileValidation(){
        var fileInput = document.getElementById('image_posts');
        if (fileInput.files && fileInput.files[0]) {
            var reader = new FileReader();
            reader.onload = function(e) {
                document.getElementById("previewImages").innerHTML = "";
                $('#previewImages').append(
                "<div class='imageCard col-xl-4 col-sm-4 mb-2'>"+
                  "<div class='avatar avatar-xxl position-relative'>"+
                    "<img src='"+e.target.result+"' id='imge' class='border-radius-md' alt='team-2'>"+
                  "</div>"+
                "</div>");
            };
            reader.readAsDataURL(fileInput.files[0]);
        }
    }
    
    $(document).ready(function () {
        create_custom_dropdowns();
    });

</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('main', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /www/wwwroot/application.posterbanao.com/resources/views/notification/edit.blade.php ENDPATH**/ ?>