

<?php $__env->startSection('title'); ?>
    <?php echo e($category); ?>

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

<?php $__env->startSection('content'); ?>
    <!-- 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.products'); ?>
  			    		<button class="btn btn-success" data-toggle="modal" data-target="#addProduct"><?php echo app('translator')->getFromJson('backend.new-product'); ?></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-product')): ?>
  							<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-product')); ?></p>
  							</div>
						  <?php endif; ?>
				    	<div class="table-responsive">
				    		<table id="productTable" class="table table-hover">
							    <thead>
								    <tr>
								    	<th class="text-center">#</th>
                      <th><?php echo app('translator')->getFromJson('backend.name'); ?></th>
                      <th class="text-center"><?php echo app('translator')->getFromJson('backend.image'); ?></th>
								      <th class="text-center"><?php echo app('translator')->getFromJson('backend.price'); ?></th>
                      <th class="text-center"><?php echo app('translator')->getFromJson('backend.featured'); ?></th>
								      <th class="text-center"><?php echo app('translator')->getFromJson('backend.options'); ?></th>
								    </tr>
							    </thead>
							    <tbody>
                    <?php $__currentLoopData = $products; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $val): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                      <tr>
                        <td class="text-center"><?php echo e($key+1); ?></td>
                        <td><?php echo e($val->product_name); ?></td>
                        <td class="text-center">
                          <img class="img img-responsive" alt="image" src="<?php echo e(asset($storage_url.'img/products/'.$val->product_code.'/'.$val->product_image)); ?>" style="max-height: 200px; height: 100%;margin: 0 auto; width: auto;">
                        </td>
                        <?php 
                          $currency = explode('|',$val->product_currency);
                         ?>
                        <?php 
                          if( $masterCurrency == "USD" ){
                            $price = number_format($val->product_price,2,".",",");
                          }elseif( $masterCurrency == "EUR" ){
                            $price = number_format($val->product_price,2,",",".");
                          }else{
                            $price = number_format($val->product_price,0,",",".");
                          }
                         ?>
                        <td class="text-center"><?php echo e($masterCurrency); ?> <?php echo e($price); ?></td>
                        <td class="text-center">
                          <a href="<?php echo e(route('backendProductFeatured', $val->id)); ?>" class="btn btn-xs <?php echo e($val->is_featured ? 'btn-warning' : 'btn-default'); ?>">
                            <i class="fa fa-star fa-fw"></i>
                          </a>
                        </td>
                        <td class="text-center">
                          <a href="<?php echo e(route('beViewDetailProduct',['id_category'=>$val->product_category,'code'=>$val->product_code])); ?>" class="btn btn-warning" title="Edit product"><i class="fa fa-pencil" aria-hidden="true"></i></a>
                          <button title="Delete product" class="btn btn-danger" data-toggle="modal" data-target="#deleteproduct<?php echo e($val->id); ?>"><i class="fa fa-trash" aria-hidden="true"></i></button>
                          <div id="deleteproduct<?php echo e($val->id); ?>" class="modal fade" role="dialog">
                            <div class="modal-dialog modal-sm">

                            <?php echo Form::open(['url' => route('beDeleteProduct',['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'); ?> <b>'<?php echo e($val->product_name); ?>'<b> ?</h3>
                                  <img class="img img-responsive" alt="image" src="<?php echo e(asset($storage_url.'img/products/'.$val->product_code.'/'.$val->product_image)); ?>">
                                  <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>
                        </td>
                      </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

							    </tbody>
							  </table>
				    	</div>

              
              <div id="addProduct" 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-product'); ?></h2>
    								</div>
    								<?php echo Form::open(['url' => route('beSaveProduct'),'method' => 'post','files'=>true, 'class' => 'image-form']); ?>

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

    								<div class="modal-body container-fluid">
    									<?php if(Session::has('message-addproduct')): ?>
    										<div id="message-addproduct" 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-addproduct')); ?></p>
    										</div>
    									<?php endif; ?>

    									<div class="col-xs-12 col-sm-4">
                      
                        <div class="" style="width: 250px; margin: 0 auto 20px auto;">
                          <div class="image-cropper" data-height="225" data-width="150" data-exportZoom="4">
                            <div class="cropit-preview">
                              <div class="caption">
                                <p><?php echo app('translator')->getFromJson('backend.minimum-resolution'); ?> 600x900 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 class="form-group">
                          <?php echo Form::label('product_category_text',__('backend.category'),['class'=>'control-label']); ?>

                          <?php echo Form::text('product_category_text',$category,['class'=>'form-control','readonly'=>'readonly']); ?>

                          <?php echo Form::hidden('product_category',$category_id,['class'=>'form-control']); ?>

                        </div>

                        <div class="form-group">
                          <label for="price" class="control-label"><?php echo app('translator')->getFromJson('backend.product-price'); ?></label>
                          <div class="input-group">
                            <span class="input-group-addon"><?php echo e(isset($masterCurrency) ? $masterCurrency : ''); ?></span>
                            <input type="number" class="form-control" name="product_price" value="0">
                          </div>
                          <div class="<?php echo e($errors->has('product_price') ? ' has-error' : ''); ?>">
                            <?php if($errors->has('product_price')): ?>
                                <span class="help-block">
                                    <strong><?php echo e($errors->first('product_price')); ?></strong>
                                </span>
                            <?php endif; ?>
                          </div>
                        </div>

                        <div class="form-group">
                          <label for="weight" class="control-label"><?php echo app('translator')->getFromJson('backend.product-weight'); ?></label>
                          <div class="input-group">
                            <input type="number" class="form-control" name="product_weight" value="0">
                            <span class="input-group-addon">kg</span>
                          </div>
                          <div class="<?php echo e($errors->has('product_weight') ? ' has-error' : ''); ?>">
                            <?php if($errors->has('product_weight')): ?>
                                <span class="help-block">
                                    <strong><?php echo e($errors->first('product_weight')); ?></strong>
                                </span>
                            <?php endif; ?>
                          </div>
                        </div>

                        <div class="form-group">
                          <label for="price" class="control-label"><?php echo app('translator')->getFromJson('backend.average-production-time'); ?></label>
                          <div class="input-group">
                            <input type="number" class="form-control" name="production_time" value="0">
                            <span class="input-group-addon">day(s)</span>
                          </div>
                          <div class="<?php echo e($errors->has('production_time') ? ' has-error' : ''); ?>">
                            <?php if($errors->has('production_time')): ?>
                                <span class="help-block">
                                    <strong><?php echo e($errors->first('production_time')); ?></strong>
                                </span>
                            <?php endif; ?>
                          </div>
                        </div>

                        <div class="form-group">
                          <label for="price" class="control-label"><?php echo app('translator')->getFromJson('backend.product-stock'); ?></label>
                          <div class="input-group">
                            <input type="number" class="form-control" name="product_stock" value="0">
                            <span class="input-group-addon">pcs</span>
                          </div>
                          <div class="<?php echo e($errors->has('product_stock') ? ' has-error' : ''); ?>">
                            <?php if($errors->has('product_stock')): ?>
                                <span class="help-block">
                                    <strong><?php echo e($errors->first('product_stock')); ?></strong>
                                </span>
                            <?php endif; ?>
                          </div>
                        </div>
                        
    									</div>
    									<div class="col-xs-12 col-sm-8">
    										<div class="row">
                          <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">
                                <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('product_name',__('backend.product-name'),['class'=>'control-label']); ?>

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

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

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

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

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

                                        <?php if($errors->has('product_content')): ?>
                                          <span class="help-block">
                                            <strong><?php echo e($errors->first('product_content')); ?></strong>
                                          </span>
                                        <?php endif; ?>
                											</div>
                										</div>
                                  </div>
                                </div>
                              </div>

                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                          </div>
                        </div>
                      </div>
    								</div>
    								<div class="modal-footer">
    									<button type="submit" class="btn btn-primary btn-image-submit"><?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>

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

    	</div>
    </div>

    
    <div id="reorder" class="modal fade" role="dialog">
      <div class="modal-dialog">

      <?php echo Form::open(['url' => route('beProductOrder'),'method'=>'post']); ?>

        <div class="modal-content">
          <div class="modal-header">
            <h2><?php echo app('translator')->getFromJson('backend.rearrange-order'); ?></h2>
          </div>
          <div class="modal-body">
            <ul class="sortable media-list">
              <?php $__currentLoopData = $products; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $x => $vals): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                  <?php 
                    $get = $vals->locales()->where('locale',config('app.locale'))->first();
                   ?>
                <li class="media">
                  <?php echo Form::hidden('reorder[]',$vals->id); ?>

                  <div class="media-left">
                    <a href="#">
                      <img class="media-object img-border" src="<?php echo e(asset($storage_url.'img/products/'.$vals->product_code.'/'.$vals->product_image)); ?>" alt="" height="64px">
                    </a>
                  </div>
                  <div class="media-body">
                    <h3 class="media-heading"><?php echo e(isset($get->product_name) ? $get->product_name : $vals->product_name); ?></h3>
                    <?php 
                      $currency = explode('|',$vals->product_currency);
                     ?>
                    <?php 
                      if( $masterCurrency == "USD" ){
                        $price = number_format($vals->product_price,2,".",",");
                      }elseif( $masterCurrency == "EUR" ){
                        $price = number_format($vals->product_price,2,",",".");
                      }else{
                        $price = number_format($vals->product_price,0,",",".");
                      }
                     ?>
                    <p><?php echo e($masterCurrency); ?> <?php echo e($price); ?></p>
                  </div>
                </li>
              <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </ul>
          </div>
          <footer class="modal-footer">
            <button type="submit" class="btn btn-primary"><?php echo app('translator')->getFromJson('backend.save'); ?></button>
            <button class="btn btn-default" data-dismiss="modal"><?php echo app('translator')->getFromJson('backend.cancel'); ?></button>
          </footer>
        </div>
      <?php echo Form::close(); ?>


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

<?php $__env->startSection('script'); ?>
<script type="text/javascript">
  $("#productTable").DataTable();
  $(".sortable").sortable();
  <?php if($errors->all()): ?>
      $("#addProduct").modal('show');
  <?php endif; ?>
</script>
<?php $__env->stopSection(); ?>

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