

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

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

<?php $__env->startSection('content'); ?>
    <!-- MAIN CONTENT -->
    <div class="col-xs-12" style="margin-bottom: 10px">
      <a href="<?php echo e(route('beViewProducts',['id'=>$product->product_category])); ?>" class="btn btn-primary"><?php echo app('translator')->getFromJson('backend.back'); ?></a>
    </div>
    <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.product-images'); ?>
                <?php if(count($product_detail)<3): ?>
  			    		  <button class="btn btn-success" data-toggle="modal" data-target="#addImage"><?php echo app('translator')->getFromJson('backend.new-images'); ?></button>
                <?php endif; ?>
              </h2>
			    	</div>
			    	<div class="panel-body">
				    	<?php if(Session::has('message-image')): ?>
  							<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-image')); ?></p>
  							</div>
						  <?php endif; ?>
				    	<div class="table-responsive">
				    		<table id="productDetailTable" class="table table-hover">
							    <thead>
								    <tr>
								    	<th class="text-center">#</th>
								      <th class="text-center"><?php echo app('translator')->getFromJson('backend.product-images'); ?></th>
								      <th class="text-center"><?php echo app('translator')->getFromJson('backend.options'); ?></th>
								    </tr>
							    </thead>
							    <tbody>
                    <?php $__currentLoopData = $product_detail; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $val): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                      <tr class="<?php echo e(($product->product_image == $val->detail_image)?'warning':''); ?>">
                        <td class="text-center"><?php echo e($key+1); ?></td>
                        <td class="text-center">
                          <img class="img img-responsive" alt="image" src="<?php echo e(asset($storage_url.'img/products/'.$val->detail_code.'/'.$val->detail_image)); ?>" style="max-height: 200px; height: 100%;margin: 0 auto; width: auto;">
                        </td>
                        <td class="text-center">
                          <?php if($product->product_image != $val->detail_image): ?>
                            <button title="Make Primary" class="btn btn-warning" data-toggle="modal" data-target="#makeprimary<?php echo e($val->id); ?>"><i class="fa fa-star" aria-hidden="true"></i></button>
                            <div id="makeprimary<?php echo e($val->id); ?>" class="modal fade" role="dialog">
                              <div class="modal-dialog modal-sm">

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

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

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

                                <div class="modal-content text-center">
                                  <div class="modal-body">
                                    <h3><?php echo app('translator')->getFromJson('backend.ask-set-as-primary'); ?></h3>
                                    <img class="img img-responsive" alt="image" src="<?php echo e(asset($storage_url.'img/products/'.$val->detail_code.'/'.$val->detail_image)); ?>">
                                    <br>
                                    <button type="submit" class="btn btn-primary"><?php echo app('translator')->getFromJson('backend.ok'); ?></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>
                            <button title="Update" class="btn btn-warning" data-target="#updateImage<?php echo e($val->id); ?>" data-toggle="modal"><i class="fa fa-pencil" aria-hidden="true"></i></button>
                            <button title="Delete detail" 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('beDeleteDetailImage',['id'=>$val->id]),'method'=>'delete']); ?>

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

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

                                <div class="modal-content text-center">
                                  <div class="modal-body">
                                    <h3><?php echo app('translator')->getFromJson('backend.ask-delete-image'); ?></h3>
                                    <img class="img img-responsive" alt="image" src="<?php echo e(asset($storage_url.'img/products/'.$val->detail_code.'/'.$val->detail_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>
                          <?php else: ?>
                            <button title="Make Primary" class="btn disabled" data-toggle="modal"><i class="fa fa-star" aria-hidden="true" style="color:#f0ad4e"></i></button>
                            <button title="Update" class="btn btn-warning" data-target="#updateImage<?php echo e($val->id); ?>" data-toggle="modal"><i class="fa fa-pencil" aria-hidden="true"></i></button>
                          <?php endif; ?>
                        </td>
                      </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

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

              <?php if(count($product_detail)<3): ?>
                
                <div id="addImage" class="modal fade" role="dialog">
      						<div class="modal-dialog">
      							<div class="modal-content">
      								<div class="modal-header">
      									<h2><?php echo app('translator')->getFromJson('backend.add-image'); ?></h2>
      								</div>
      								<?php echo Form::open(['url' => route('beSaveDetailImage'),'method' => 'post','files'=>true, 'class' => 'image-form']); ?>

                      <?php echo Form::hidden('code',$product->product_code); ?>

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

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

      									<div class="col-xs-12">

                          
                          <div class="" style="width: 500px; margin: 0 auto 20px auto;">
                            <div class="image-cropper" data-height="450" data-width="300" data-exportZoom="2">
                              <div class="cropit-preview">
                                <div class="caption">
                                  <p><?php echo app('translator')->getFromJson('backend.minimum-reslution'); ?> 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>
      								</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>
              <?php endif; ?>

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

                    <?php echo Form::hidden('code',$detail->detail_code); ?>

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

                    <?php 
                      if($product->product_image == $detail->detail_image){
                        $is_primary = 'yes';
                      }else{
                        $is_primary = 'no';
                      }
                     ?>
                    <?php echo Form::hidden('is_primary',$is_primary); ?>

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

                      <div class="col-xs-12">
                        
                        <div class="" style="width: 500px; margin: 0 auto 20px auto;">
                          <div class="image-cropper" data-height="450" data-width="300" data-exportZoom="2" data-src="<?php echo e(asset($storage_url.'img/products/'.$detail->detail_code.'/'.$detail->detail_image)); ?>">
                            <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>
                    </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>
              <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
			    	</div>
			    </div>
		    </div>

        <div class="col-xs-12">
			    <div class="panel panel-primary">
			    	<div class="panel-heading">
              <h2>
                <?php echo app('translator')->getFromJson('backend.product-detail'); ?>
              </h2>
			    	</div>

            <?php echo Form::open(['url'=>route('beUpdateProduct',['id'=>$product->id]),'method'=>'put']); ?>

			    	<div class="panel-body">
				    	<?php if(Session::has('message-detail')): ?>
  							<div id="message-detail" 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-detail')); ?></p>
  							</div>
						  <?php endif; ?>
              <div class="row">
                <div class="col-xs-12">
                  <div class="row">

                    <div class="form-group col-xs-12 col-sm-3">
                      <label for="category" class="control-label"><?php echo app('translator')->getFromJson('backend.category'); ?></label>
                      <input type="text" class="form-control" readonly value="<?php echo e(isset($product->category->category_name) ? $product->category->category_name : ''); ?>">
                    </div>

                    <div class="form-group col-xs-12 col-sm-3">
                      <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="<?php echo e(isset($product->product_price) ? $product->product_price : 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 col-xs-12 col-sm-3">
                      <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="<?php echo e(isset($product->product_weight) ? $product->product_weight : 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 col-xs-12 col-sm-3">
                      <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="<?php echo e(isset($product->production_time) ? $product->production_time : 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 col-xs-12 col-sm-3">
                      <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="<?php echo e(isset($product->product_stock) ? $product->product_stock : 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>
                <?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 = $product->locales()->where('locale',$lang)->first();
                    if(empty($get)){
                      $name = $product->product_name;
                      $alt = $product->product_alt;
                      $desc = $product->product_content;
                    }else{
                      $name = $get->product_name;
                      $alt = $get->product_alt;
                      $desc = $get->product_content;
                    }
                   ?>
                  <div class="col-xs-12 col-sm-6">
                    <div class="panel panel-info">
                      <header class="panel-heading">
                        <h3><?php echo e($lang_ext); ?></h3>
                      </header>
                      <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.']',$name,['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.']',$alt,['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.product_description'),['class'=>'control-label']); ?>

                          <div class="<?php echo e($errors->has('product_content') ? ' has-error' : ''); ?>">
                            <?php echo Form::textarea('product_content['.$lang.']',$desc,['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>
            <footer class="panel-footer text-center">
  						<button type="submit" class="btn btn-primary"><?php echo app('translator')->getFromJson('backend.update'); ?></button>
  					</footer>
            <?php echo Form::close(); ?>

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

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

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