

<?php
  $title = "Add Package";
  $button_text = "Add";
  if(!empty($package)) {
    $title = "Edit Package";
    $button_text = "Update";
  }
?>

<?php $__env->startSection('title', $title); ?>

<?php $__env->startSection('content'); ?>

<div class="content-wrapper">
            <!-- Content -->

            <div class="container-xxl flex-grow-1 container-p-y">
              <h4 class="fw-bold py-3 mb-4"><span class="text-muted fw-light">Dashboard /</span> <?php echo e($title); ?></h4>

              <div class="row">
                 <div class="col-xl-12 col-lg-12">
				 <div class="card shadow mb-4">

 <?php if(!empty($package)): ?>  
      <form action="<?php echo e(route('packages.update', $package)); ?>" method="post" enctype="multipart/form-data">
        <?php echo method_field('put'); ?>
 <?php else: ?>        
      <form action="<?php echo e(route('packages.store')); ?>" method="post" enctype="multipart/form-data">
<?php endif; ?>
    <?php echo csrf_field(); ?>

             <?php if(Session::has('success')): ?>
                <div class="alert alert-dismissable alert-success">
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                  <span aria-hidden="true">&times;</span> </button>
                  <?php echo e(Session::get('success')); ?></div>
               <?php endif; ?>
               <?php if(Session::has('fail')): ?>
              <div class="alert alert-danger"><?php echo e(Session::get('fail')); ?></div>
                 <?php endif; ?>
                                <div class="card-body">
                                    <div class=" pb-2">
                                        <div class="row">    

    <div class="col-lg-12 col-md-12 mb-4 element-title">
        <h4 class="mb-4">Add Package</h4>

         <div class="row"> 
          <div class="col-lg-6 col-md-6 col-12 mb-2">
            <label>Category</label>
                  <select class="form-control" name="category" value="<?php echo e(!empty($package->category_id) ? $package->category_id : ""); ?>" >
                        <option value="" hidden>Select Category</option>
                        <?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $category): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                           <option value="<?php echo e($category->id); ?>" <?php if(!empty($package->category_id)): ?> <?php if($category->id == $package->category_id): ?> selected <?php endif; ?> <?php endif; ?>><?php echo e($category->name); ?></option>
                         <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        
                    </select>
            </div>
          
          </div>

            <div class="row"> 
            <div class="col-lg-6 col-md-6 col-12 mb-2">
                  <label>Package Name</label>
                  <input type="text" class="form-control" placeholder="Package Name" name="name" value="<?php echo e(!empty($package->name) ? $package->name : ""); ?>">
          </div>
          <div class="col-lg-6 col-md-6 col-12 mb-2">
            <label>Time Period</label>
                  <select class="form-control" name="period" value="<?php echo e(!empty($package->period) ? $package->period : ""); ?>">
                        <option value="">Months / Year</option>
                        <option value="1 month">Per Month</option>
                        <option value="1 year">One Year</option>
                        <option value="2 year">Two Year</option>
                        <option value="3 year">Three Year</option>
                    </select>
            </div>
          
          </div>
          <div class="row"> 
            <label>Package Description</label>
            <div class="col-lg-12 col-md-12 col-12 mb-2">
                <Textarea name="description" class="form-control" placeholder="Enter Package description" id="editor" value=""><?php echo e(!empty($package->description) ? $package->description : ""); ?></Textarea>
            </div>
          </div>

           <div>
        
              <table class="table mt-3">
                <thead>
                  <tr>
                    <th>Quantity</th>
                    <th>Price(excl. tax)</th>
                    
                    <th></th>
                  </tr>
                </thead>
                <tbody id="tbody">
                  <?php if($variants->count() > 0): ?>
                    <?php $__currentLoopData = $variants; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $variant): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                     <tr>
                          <td><input type="text" name="qty[]" class="form-control" value="<?php echo e($variant->qty); ?>" placeholder="Enter qty" /></td>
                          <td><input type="text" name="price[]" class="form-control" value="<?php echo e($variant->price); ?>" placeholder="Enter price" /></td>
                          <td>
                          <button type="button" class="btn btn-danger btn-sm btn-remove-row">x</button>
                          </td>
                          <td>
                          <button type="button" class="btn btn-info btn-sm btn-add-row">+</button>
                          </td>
                      </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                  <?php else: ?>
                      <tr>
                        <td><input type="text" name="qty[]" class="form-control" placeholder="Enter qty" /></td>
                        <td><input type="text" name="price[]" class="form-control" placeholder="Enter price" /></td>
                        <td>
                        <button type="button" class="btn btn-danger btn-sm btn-remove-row">x</button>
                        </td>
                        <td>
                        <button type="button" class="btn btn-info btn-sm btn-add-row">+</button>
                        </td>
                        </tr>
                  <?php endif; ?>
                </tbody>
              </table>
            </div>

          <div class="row mt-3"> 
            <div class="col-lg-6 col-md-6 col-12 mb-2">
              <label>Price</label>
                <input type="text" class="form-control" placeholder="Price" name="total" value="<?php echo e(!empty($package->price) ? $package->price : ""); ?>">
          </div>
          <div class="col-lg-6 col-md-6 col-12 mb-2">
            <label>Image</label>
          <input type="file" class="form-control" name="image">
          </div>
          
          </div>
		 
    </div>

    

                     <div class="d-flex justify-content-end">
													<button type="submit" class="add-btn" ><?php echo e($button_text); ?></button>
												</div>
</div>          
                               
                            </div>
                        </div>

</form>
                        <!-- Area -->
                       

                       
                    </div>
						
					
					
</div>
              </div>
            </div>
            <!-- / Content -->

            <!-- Footer -->
            <footer class="content-footer footer bg-footer-theme">
              <div class="container-xxl d-flex flex-wrap justify-content-between py-2 flex-md-row flex-column">
                <div class="mb-2 mb-md-0">
                  © 2022
                </div>
                
              </div>
            </footer>
            <!-- / Footer -->
          </div>

<?php $__env->stopSection(); ?>
<?php $__env->startSection('script'); ?>
<script src="https://cdn.tiny.cloud/1/qagffr3pkuv17a8on1afax661irst1hbr4e6tbv888sz91jc/tinymce/5/tinymce.min.js"></script>

    <script>
        tinymce.init({
            selector:'#editor',
            menubar: false,
            statusbar: false,
            plugins: 'autoresize anchor autolink charmap code codesample directionality fullpage help hr image imagetools insertdatetime link lists media nonbreaking pagebreak preview print searchreplace table template textpattern toc visualblocks visualchars',
            toolbar: 'h1 h2 bold italic strikethrough blockquote bullist numlist backcolor | link image media | removeformat help fullscreen ',
            skin: 'bootstrap',
            toolbar_drawer: 'floating',
            min_height: 200,           
            autoresize_bottom_margin: 16,
            setup: (editor) => {
                editor.on('init', () => {
                    editor.getContainer().style.transition="border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out"
                });
                editor.on('focus', () => {
                    editor.getContainer().style.boxShadow="0 0 0 .2rem rgba(0, 123, 255, .25)",
                    editor.getContainer().style.borderColor="#80bdff"
                });
                editor.on('blur', () => {
                    editor.getContainer().style.boxShadow="",
                    editor.getContainer().style.borderColor=""
                });
            }
        });
    </script>

    <script>

          $(document).on('click', '.btn-add-row', function() {
            // $(this).hide();
            $("#tbody").append(`<tr>
              <td><input type="text" name="qty[]" class="form-control" placeholder="Enter qty" /></td>
                <td><input type="text" name="price[]" class="form-control" placeholder="Enter price" /></td>
                <td>
                        <button type="button" class="btn btn-danger btn-sm btn-remove-row">x</button>
                        </td>
                        <td>
                        <button type="button" class="btn btn-info btn-sm btn-add-row">+</button>
                        </td>
              </tr>`);
          });

          $(document).on("click", ".btn-remove-row", function(){
            $(this).parent().parent().remove();
          });

    </script>

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




<?php echo $__env->make('admin.layouts.header', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/603031.cloudwaysapps.com/pvusfnxuud/public_html/suymedia/resources/views/admin/create-package.blade.php ENDPATH**/ ?>