

<?php $__env->startSection('title', __('product-and-category')); ?>

<?php $__env->startSection('content'); ?>
  <div class="container-fluid">
    <div class="row">
      <div class="col-xs-12 col-sm-8">
        <div class="panel panel-primary">
          <div class="panel-heading">
            <h2><?php echo app('translator')->getFromJson('backend.all-category-icon'); ?></h2>
          </div>
          <?php echo Form::open(['url' => route('saveCategoryIcon'),'method' => 'post','files'=>true, 'class' => 'image-form']); ?>

          <?php echo Form::hidden('image'); ?>

          <div class="panel-body">
            <?php if(Session::has('message-icon')): ?>
							<div class="alert <?php echo e(Session::get('alert-class')); ?> alert-dismissible" role="alert">
								<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
							 	<p><?php echo e(Session::get('message-icon')); ?></p>
							</div>
					  <?php endif; ?>

            
            <div class="" style="width: 250px; margin: 0 auto 20px auto;">
              <div class="image-cropper" data-height="200" data-width="200" data-exportZoom="1" data-src="<?php echo e(isset($icon)?asset($storage_url.'img/products/category/'.$icon->setting_value):asset($storage_url.'img/img1x1.jpg')); ?>">
                <div class="cropit-preview">
                  <div class="caption">
                    <p><?php echo app('translator')->getFromJson('backend.minimum-resolution'); ?> 200x200 px</p>
                  </div>
                </div>

                <div class="controls-wrapper">
                  <div class="rotation-btns">
                    <a class="rotate-ccw-btn"><i class="fa fa-undo"></i></a>
                    <a class="rotate-cw-btn"><i class="fa fa-repeat"></i></a>
                  </div>
                  <div class="slider-wrapper">
                    <i class="fa fa-picture-o" aria-hidden="true"></i>
                    <input type="range" class="cropit-image-zoom-input">
                    <i class="fa fa-picture-o fa-2x" aria-hidden="true"></i>
                  </div>
                </div>

                <input type="file" class="cropit-image-input" />
              </div>
            </div>
            

          </div>
          <div class="panel-footer text-center">
            <button type="submit" class="btn btn-primary btn-image-submit"><?php echo app('translator')->getFromJson('backend.update'); ?></button>
          </div>
          <?php echo Form::close(); ?>

        </div>
      </div>
      <div class="col-xs-12 col-sm-4">
        <div class="panel panel-primary">
          <div class="panel-heading">
            <h2><?php echo app('translator')->getFromJson('backend.currency'); ?></h2>
          </div>
          <?php echo Form::open(['url' => route('saveCurrency'),'method' => 'post','files'=>true]); ?>

          <div class="panel-body">
            <?php if(Session::has('message-currency')): ?>
							<div class="alert <?php echo e(Session::get('alert-class')); ?> alert-dismissible" role="alert">
								<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
							 	<p><?php echo e(Session::get('message-currency')); ?></p>
							</div>
					  <?php endif; ?>
            <?php 
              foreach ($currencies as $key => $value) {
                $c[$value->currency_code] = $value->currency_name." (".$value->currency_code.")";
              }
             ?>
            <div class="form-group">
              <div class="text-center well">
                <h3 class="h1"><?php echo e($masterCurrency); ?>.</h3>
                <?php 
                  $get = App\Currency::where('currency_code',$masterCurrency)->first();
                 ?>
                <span class="label label-default"><?php echo e(isset($get->currency_name) ? $get->currency_name : ""); ?></span>
              </div>
              <?php echo Form::select('select_currency',$c,$masterCurrency,['class'=>'form-control']); ?>

            </div>
          </div>
          <div class="panel-footer text-center">
            <button type="submit" class="btn btn-primary"><?php echo app('translator')->getFromJson('backend.update'); ?></button>
          </div>
          <?php echo Form::close(); ?>

        </div>
      </div>
    </div>
  </div>
  <!-- MAIN CONTENT -->
  <div class="container-fluid">
  	<div class="row">

      <div class="col-xs-12">
		    <div class="panel panel-primary">
		    	<div class="panel-heading">
            <h2>
              <?php echo app('translator')->getFromJson('backend.category'); ?>
			    		<button class="btn btn-success" data-toggle="modal" data-target="#addCategory"><?php echo app('translator')->getFromJson('backend.new-category'); ?></button>
              <button class="btn btn-warning" data-toggle="modal" data-target="#reorder"><?php echo app('translator')->getFromJson('backend.arrange-order'); ?></button>
            </h2>
		    	</div>
		    	<div class="panel-body">
			    	<?php if(Session::has('message-category')): ?>
							<div class="alert <?php echo e(Session::get('alert-class')); ?> alert-dismissible" role="alert">
								<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
							 	<p><?php echo e(Session::get('message-category')); ?></p>
							</div>
					  <?php endif; ?>
			    	<div class="table-responsive">
			    		<table id="categoryTable" class="table table-hover">
						    <thead>
							    <tr>
							    	<th class="text-center">#</th>
                    <th><?php echo app('translator')->getFromJson('backend.name'); ?></th>
                    <th><?php echo app('translator')->getFromJson('backend.products'); ?></th>
							      <th class="text-center"><?php echo app('translator')->getFromJson('backend.image'); ?> 1</th>
							      <th class="text-center"><?php echo app('translator')->getFromJson('backend.image'); ?> 2</th>
							      <th class="text-center"><?php echo app('translator')->getFromJson('backend.options'); ?></th>
							    </tr>
						    </thead>
						    <tbody>
                  <?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $val): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <?php 
                      $total = count(App\Product::where(['product_category'=>$val->id])->get());
                     ?>
                    <tr>
                      <td class="text-center"><?php echo e($key+1); ?></td>
                      <td><?php echo e($val->category_name); ?></td>
                      <td><?php echo e($total); ?> <?php echo app('translator')->getFromJson('backend.products'); ?></td>
                      <td>
                        <img class="img img-responsive" alt="image" src="<?php echo e(asset($storage_url.'img/products/category/'.$val->category_image1)); ?>" style="max-height: 200px; height: 100%;margin: 0 auto; width: auto;">
                      </td>
                      <td>
                        <img class="img img-responsive" alt="image" src="<?php echo e(asset($storage_url.'img/products/category/'.$val->category_image2)); ?>" style="max-height: 200px; height: 100%;margin: 0 auto; width: auto;">
                      </td>
                      <td class="text-center">
                        
                        <a class="btn btn-primary" href="<?php echo e(route('beViewProducts',['id'=>$val->id])); ?>">
                            <i class="fa fa-external-link fa-fw"></i></span>
                        </a>
                        
                        <button title="Update Category" class="btn btn-warning" data-toggle="modal" data-target="#updCategory<?php echo e($val->id); ?>"><i class="fa fa-pencil" aria-hidden="true"></i></button>

                        
                        <?php if($total == 0): ?>
                          <button title="Delete Category" class="btn btn-danger" data-toggle="modal" data-target="#deletecategory<?php echo e($val->id); ?>"><i class="fa fa-trash" aria-hidden="true"></i></button>
                          <div id="deletecategory<?php echo e($val->id); ?>" class="modal fade" role="dialog">
                            <div class="modal-dialog modal-sm">

                            <?php echo Form::open(['url' => route('beDeleteCategory',['id'=>$val->id]),'method'=>'delete']); ?>

                              <?php echo Form::hidden('id',$val->id); ?>

                              <div class="modal-content text-center">
                                <div class="modal-body">
                                  <h3><?php echo app('translator')->getFromJson('backend.delete-category'); ?> ?</h3>
                                  <img class="img img-responsive" alt="image" src="<?php echo e(asset($storage_url.'img/products/category/'.$val->category_image2)); ?>">
                                  <br>
                                  <button type="submit" class="btn btn-primary"><?php echo app('translator')->getFromJson('backend.delete'); ?></button>
                                <button class="btn btn-default" data-dismiss="modal"><?php echo app('translator')->getFromJson('backend.cancel'); ?></button>
                                </div>
                              </div>
                            <?php echo Form::close(); ?>


                            </div>
                          </div>
                        <?php endif; ?>
                      </td>
                    </tr>
                  <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
						    </tbody>
						  </table>
			    	</div>

            
            <div id="addCategory" class="modal fade" role="dialog">
  						<div class="modal-dialog modal-lg">
  							<div class="modal-content">
  								<div class="modal-header">
  									<h2><?php echo app('translator')->getFromJson('backend.add-category'); ?></h2>
  								</div>
  								<?php echo Form::open(['url' => route('beSaveCategory'),'method' => 'post','files'=>true, 'class' => 'image-form']); ?>

                  <?php echo Form::hidden('image1'); ?>

                  <?php echo Form::hidden('image2'); ?>


  								<div class="modal-body container-fluid">
  									<?php if(Session::has('message-addcategory')): ?>
  										<div id="message-addcategory" class="alert <?php echo e(Session::get('alert-class')); ?> alert-dismissible" role="alert">
  											<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  										 	<p><?php echo e(Session::get('message-addcategory')); ?></p>
  										</div>
  									<?php endif; ?>

  									<div class="col-xs-12 col-sm-6">
                      
                      <div class="" style="width: 320px; margin: 0 auto 20px auto;">
                        <div class="image-cropper category-1" data-height="320" data-width="320" data-exportZoom="2">
                          <div class="cropit-preview">
                            <div class="caption">
                              <p><?php echo app('translator')->getFromJson('backend.minimum-resolution'); ?> 640x640 px</p>
                            </div>
                          </div>

                          <div class="controls-wrapper">
                            <div class="rotation-btns">
                              <a class="rotate-ccw-btn"><i class="fa fa-undo"></i></a>
                              <a class="rotate-cw-btn"><i class="fa fa-repeat"></i></a>
                            </div>
                            <div class="slider-wrapper">
                              <i class="fa fa-picture-o" aria-hidden="true"></i>
                              <input type="range" class="cropit-image-zoom-input">
                              <i class="fa fa-picture-o fa-2x" aria-hidden="true"></i>
                            </div>
                          </div>

                          <input type="file" class="cropit-image-input" />
                        </div>
                      </div>
                      
  									</div>

  									<div class="col-xs-12 col-sm-6">
                      
                      <div class="" style="width: 400px; margin: 0 auto 20px auto;">
                        <div class="image-cropper category-2" data-height="80" data-width="400" data-exportZoom="4">
                          <div class="cropit-preview">
                            <div class="caption">
                              <p><?php echo app('translator')->getFromJson('backend.minimum-resolution'); ?> 1600x320 px</p>
                            </div>
                          </div>

                          <div class="controls-wrapper">
                            <div class="rotation-btns">
                              <a class="rotate-ccw-btn"><i class="fa fa-undo"></i></a>
                              <a class="rotate-cw-btn"><i class="fa fa-repeat"></i></a>
                            </div>
                            <div class="slider-wrapper">
                              <i class="fa fa-picture-o" aria-hidden="true"></i>
                              <input type="range" class="cropit-image-zoom-input">
                              <i class="fa fa-picture-o fa-2x" aria-hidden="true"></i>
                            </div>
                          </div>

                          <input type="file" class="cropit-image-input" />
                        </div>
                      </div>
                      
  									</div>

                    <div class="col-xs-12">
                      <?php $__currentLoopData = config('translatable.locales'); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lang => $language): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <?php 
                          if(count(config('translatable.locales')) > 1){
                            $lang_ext = $language;
                          }else{
                            $lang_ext = "";
                          }
                         ?>
                        <div class="col-xs-12 col-sm-6">
                          <div class="panel panel-info">
                            <div class="panel-heading">
                              <h3><?php echo e($lang_ext); ?></h3>
                            </div>
                            <div class="panel-body">
                              <div class="form-group">
          											<?php echo Form::label('category_alt',__('backend.image-alt'),['class'=>'control-label']); ?>

          											<div class="<?php echo e($errors->has('category_alt') ? ' has-error' : ''); ?>">
          												<?php echo Form::text('category_alt['.$lang.']','',['class'=>'form-control']); ?>

                                  <?php if($errors->has('category_alt')): ?>
                                      <span class="help-block">
                                          <strong><?php echo e($errors->first('category_alt')); ?></strong>
                                      </span>
                                  <?php endif; ?>
          											</div>
          										</div>
                              <div class="form-group">
          											<?php echo Form::label('category_name',__('backend.name'),['class'=>'control-label']); ?>

          											<div class="<?php echo e($errors->has('category_name') ? ' has-error' : ''); ?>">
          												<?php echo Form::text('category_name['.$lang.']','',['class'=>'form-control']); ?>

                                  <?php if($errors->has('category_name')): ?>
                                      <span class="help-block">
                                          <strong><?php echo e($errors->first('category_name')); ?></strong>
                                      </span>
                                  <?php endif; ?>
          											</div>
          										</div>
                            </div>
                          </div>
                        </div>
                      <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </div>
  								</div>
  								<div class="modal-footer">
  									<button type="submit" class="btn btn-primary btn-image-submit-extra"><?php echo app('translator')->getFromJson('backend.save'); ?></button>
  									<button class="btn btn-default" data-dismiss="modal"><?php echo app('translator')->getFromJson('backend.cancel'); ?></button>
  								</div>
  								<?php echo Form::close(); ?>

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

            
            <?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $val): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
              <div id="updCategory<?php echo e($val->id); ?>" class="modal fade" role="dialog">
                <div class="modal-dialog modal-lg">
                  <div class="modal-content">
                    <div class="modal-header">
                      <h2><?php echo app('translator')->getFromJson('backend.update-category'); ?></h2>
                    </div>
                    <?php echo Form::open(['url' => route('beUpdateCategory',['id'=>$val->id]),'method' => 'put','files'=>true, 'class' => 'image-form']); ?>

                    <?php echo Form::hidden('image1'); ?>

                    <?php echo Form::hidden('image2'); ?>

                  <div class="modal-body container-fluid">
                      <?php if(Session::has('message-addcategory')): ?>
                        <div id="message-addcategory" class="alert <?php echo e(Session::get('alert-class')); ?> alert-dismissible" role="alert">
                          <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                          <p><?php echo e(Session::get('message-addcategory')); ?></p>
                        </div>
                      <?php endif; ?>

                      <div class="col-xs-12 col-sm-6">
                        
                        <div class="" style="width: 320px; margin: 0 auto 20px auto;">
                          <div class="image-cropper category-1" data-height="320" data-width="320" data-exportZoom="2" data-src="<?php echo e(asset($storage_url.'img/products/category/'.$val->category_image1)); ?>">
                            <div class="cropit-preview">
                              <div class="caption">
                                <p><?php echo app('translator')->getFromJson('backend.minimum-resolution'); ?> 640x640 px</p>
                              </div>
                            </div>

                            <div class="controls-wrapper">
                              <div class="rotation-btns">
                                <a class="rotate-ccw-btn"><i class="fa fa-undo"></i></a>
                                <a class="rotate-cw-btn"><i class="fa fa-repeat"></i></a>
                              </div>
                              <div class="slider-wrapper">
                                <i class="fa fa-picture-o" aria-hidden="true"></i>
                                <input type="range" class="cropit-image-zoom-input">
                                <i class="fa fa-picture-o fa-2x" aria-hidden="true"></i>
                              </div>
                            </div>

                            <input type="file" class="cropit-image-input" />
                          </div>
                        </div>
                        
                      </div>

                      <div class="col-xs-12 col-sm-6">
                        
                        <div class="" style="width: 400px; margin: 0 auto 20px auto;">
                          <div class="image-cropper category-2" data-height="80" data-width="400" data-exportZoom="4" data-src="<?php echo e(asset($storage_url.'img/products/category/'.$val->category_image2)); ?>">
                            <div class="cropit-preview">
                              <div class="caption">
                                <p><?php echo app('translator')->getFromJson('backend.miminum-resolution'); ?> 1600x320 px</p>
                              </div>
                            </div>

                            <div class="controls-wrapper">
                              <div class="rotation-btns">
                                <a class="rotate-ccw-btn"><i class="fa fa-undo"></i></a>
                                <a class="rotate-cw-btn"><i class="fa fa-repeat"></i></a>
                              </div>
                              <div class="slider-wrapper">
                                <i class="fa fa-picture-o" aria-hidden="true"></i>
                                <input type="range" class="cropit-image-zoom-input">
                                <i class="fa fa-picture-o fa-2x" aria-hidden="true"></i>
                              </div>
                            </div>

                            <input type="file" class="cropit-image-input" />
                          </div>
                        </div>
                        
                      </div>

                      <div class="col-xs-12">
                        <?php $__currentLoopData = config('translatable.locales'); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lang => $language): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                          <?php 
                            if(count(config('translatable.locales')) > 1){
                              $lang_ext = $language;
                            }else{
                              $lang_ext = "";
                            }

                            $get = $val->locales()->where('locale',$lang)->first();
                            if(empty($get)){
                              $alt = $val->category_alt;
                              $name = $val->category_name;
                            }else{
                              $alt = $get->category_alt;
                              $name = $get->category_name;
                            }
                           ?>
                          <div class="col-xs-12 col-sm-6">
                            <div class="panel panel-info">
                              <div class="panel-heading">
                                <h3><?php echo e($lang_ext); ?></h3>
                              </div>
                              <div class="panel-body">
                                <div class="form-group">
                                  <?php echo Form::label('category_alt',__('backend.image-alt'),['class'=>'control-label']); ?>

                                  <div class="<?php echo e($errors->has('category_alt') ? ' has-error' : ''); ?>">
                                    <?php echo Form::text('category_alt['.$lang.']',$alt,['class'=>'form-control']); ?>

                                    <?php if($errors->has('category_alt')): ?>
                                        <span class="help-block">
                                            <strong><?php echo e($errors->first('category_alt')); ?></strong>
                                        </span>
                                    <?php endif; ?>
                                  </div>
                                </div>
                                <div class="form-group">
                                  <?php echo Form::label('category_name',__('backend.name'),['class'=>'control-label']); ?>

                                  <div class="<?php echo e($errors->has('category_name') ? ' has-error' : ''); ?>">
                                    <?php echo Form::text('category_name['.$lang.']',$name,['class'=>'form-control']); ?>

                                    <?php if($errors->has('category_name')): ?>
                                        <span class="help-block">
                                            <strong><?php echo e($errors->first('category_name')); ?></strong>
                                        </span>
                                    <?php endif; ?>
                                  </div>
                                </div>
                              </div>
                            </div>
                          </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                      </div>
                    </div>
                    <div class="modal-footer">
                      <button type="submit" class="btn btn-primary btn-image-submit-extra"><?php echo app('translator')->getFromJson('backend.save'); ?></button>
                      <button class="btn btn-default" data-dismiss="modal"><?php echo app('translator')->getFromJson('backend.cancel'); ?></button>
                    </div>
                    <?php echo Form::close(); ?>

                  </div>
                </div>
              </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
		    	</div>
		    </div>
	    </div>

  	</div>
  </div>

  <?php echo $__env->make('backend._components.order-modal', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('script'); ?>
<link href="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.4/css/select2.min.css" rel="stylesheet" />
<script src="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.4/js/select2.min.js"></script>
<script type="text/javascript">
  $(".sortable").sortable();
  $("#categoryTable").DataTable();
  <?php if($errors->has('category_image1')): ?>
      $("#addCategory").modal('show');
  <?php elseif($errors->has('category_image2')): ?>
      $("#addCategory").modal('show');
  <?php endif; ?>

  $('select[name="select_currency"]').select2();
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.masterBackend', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>