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

<?php $__env->startPush('css'); ?>

<?php $__env->stopPush(); ?>
<!-- page content -->
<?php $__env->startSection('content'); ?>
    <div class="right_col" role="main">
        <div class="">
            <div class="clearfix"></div>
            <?php if(Session::has('success')): ?>
                <div class="alert alert-success">
                    <?php echo e(Session::get('success')); ?>

                </div>
            <?php endif; ?>
            <?php if(Session::has('error')): ?>
                <div class="alert alert-danger">
                    <?php echo e(Session::get('error')); ?>

                </div>
            <?php endif; ?>
            <div class="row">
                <div class="col-md-12 col-sm-12 col-xs-12">
                    <div class="x_panel">
                        <div class="x_title">
                            <h2>Product Management 
                                <a href="<?php echo e(route('product.create')); ?>" class="btn btn-xs btn-primary">Create Product</a>
                            </h2> 
                            <ul class="nav navbar-right panel_toolbox">
                                <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                                </li>
                                <li class="dropdown">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                                    <ul class="dropdown-menu" role="menu">
                                        <li><a href="#">Settings 1</a>
                                        </li>
                                        <li><a href="#">Settings 2</a>
                                        </li>
                                    </ul>
                                </li>
                                <li><a class="close-link"><i class="fa fa-close"></i></a>
                                </li>
                            </ul>
                            <div class="clearfix"></div>
                        </div>
                        <div class="">
                            <div class="row search-section">
								<form action="<?php echo e(route('product.list')); ?>" id="searchForm" method="Get">
									<div class="col-sm-2">
										<select class="form-control" name="show" id="show">
											<option value="<?php echo e($products->count()); ?>"><?php echo e($products->count()); ?></option>
											<?php $__currentLoopData = explode(",",setting()->pdl); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $d): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
    										<option value="<?php echo e($d); ?>"><?php echo e($d); ?></option>
    										<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    										<option value="<?php echo e($products->total()); ?>">All</option>
										</select>
									</div>
									<div class="col-sm-7"></div>
									<div class="col-sm-3">
										<div class="input-group">
											<input type="text" id="myInput" class="form-control" placeholder="Search">
											<span class="input-group-btn">
												<button type="button" class="btn btn-primary">
												<span class="ace-icon fa fa-search icon-on-right bigger-110"></span></button>
											</span>
										</div>
									</div>
								</form> 
							</div>
							<div class="x_content table-responsive"> 
                                <table  class="table table-bordered table-condensed" id="">
                                    <thead>
                                    <tr class="bg-primary">
                                        <th>SL</th>
                                        <th>Product</th>
                                        <th>Category</th>
                                        <th>Unit</th>
                                        <th>Code</th>
                                        <th>Square Foot</th>
                                        <th>Rate</th>
                                        <th>Sale Price</th>
                                        <th>Wage</th>
                                        <th>Order Label</th>
                                        <th>Stock</th>
                                        <th>Status</th>
                                        <th>Action</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <?php $i=1 ?>
                                    <?php $__currentLoopData = $products; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $pc): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <tr class="<?php echo e($pc->re_order_label > $pc->pdetail->sum('now_stock') ? 'bg-warning' : ''); ?>">
                                            <th> <?php echo e($i++); ?></th>
                                            <td><?php echo e($pc->product_name); ?> </td>
                                            <td><?php echo e($pc->productcategory_id != '' ? $pc->category->name : ''); ?> </td>
                                            <td><?php echo e($pc->unit != '' ? $pc->unit->name : ''); ?> </td>
                                            <td><?php echo e($pc->code); ?> </td>
                                            <td><?php echo e($pc->square_foot); ?> </td>
                                            <td><?php echo e($pc->supplier_price); ?></td>
                                            <td><?php echo e($pc->sale_price); ?></td>
                                            <td><?php echo e($pc->worker_wage); ?></td>
                                            <td><?php echo e($pc->re_order_label); ?></td>
                                            <td><?php echo e($pc->pdetail->sum('now_stock')); ?></td>
                                            <td>
                                                <?php if($pc->status == 1): ?>
                                                    <span class="label label-success"> Active </span>
                                                <?php else: ?>
                                                    <span class="label label-danger">DeActive</span>
                                                <?php endif; ?>
                                            </td>
                                            <td>
                                                <div class="row">
                                                    <div class="col-md-2">
                                                        <a href="<?php echo e(route('product.edit',$pc->id)); ?>" class="btn btn-xs btn-warning"><i class="fa fa-pencil"></i></a>
                                                    </div>
                                                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('product-delete')): ?>
                                                    <div class="col-md-2">
                                                        <form action="<?php echo e(route('product.delete' ,$pc->id)); ?>" method="post">
                                                            <input type="hidden" name="_method" value="DELETE">
                                                            <?php echo e(csrf_field()); ?>

                                                            <button type="submit" class="btn btn-xs btn-danger" onclick="return confirm('are you sure to delete?')" ><i class="fa fa-trash-o"></i></button>
                                                        </form>
                                                    </div>
                                                    <?php endif; ?>
                                                </div>
                                            </td>
                                        </tr>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </tbody>
                                </table>
                            </div>
                            <div class="text-center">
                                <?php echo e($products->links()); ?>

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

<?php $__env->startPush('js'); ?>

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