
<?php $__env->startSection('title'); ?> Supplier | Beauty Parlour <?php $__env->stopSection(); ?>
<?php $__env->startSection('supplier'); ?> active <?php $__env->stopSection(); ?>
<?php $__env->startSection('supplier.index'); ?> active <?php $__env->stopSection(); ?>
<?php $__env->startSection('styles'); ?>
<?php $__env->stopSection(); ?>


<?php $__env->startSection('main_content_section'); ?>
<div class="row py-3 ps-2">
    <div class="heading d-flex justify-content-start align-items-center">
        <h3 class="mb-0"><span> Supplier List</span></h3>
    </div>
</div>

<div class="table_wrapper py-1 card">
    <div class="row my-2 aggregate-section-div">
        <div class="px-3 ">
            <div class=" d-flex justify-content-between align-items-center aggregate-section border">
                <div class="d-flex align-items-center">
                    <p class="mb-0"><a href="<?php echo e(route('supplier.index')); ?>"
                            class="text-primary py-2 px-3 active">All(<?php echo e($allSupplierCount); ?>)</a>
                    </p>
                </div>
                <div class="d-none d-sm-block">
                    <?php if(Auth::user()->can('supplier-create')): ?>
                    <a href="javascript:void(0)"
                        class="btn btn-success rounded-0 d-flex align-items-center px-2 border-0" data-bs-toggle="modal"
                        data-bs-target="#addSupplier"><span class="">New Supplier</span></a>
                    <?php endif; ?>
                </div>
            </div>

            <?php if(Auth::user()->can('supplier-create')): ?>
            <div class="mt-2 btn btn-success d-block rounded-0 d-sm-none" data-bs-toggle="modal"
                data-bs-target="#addSupplier">
                New Supplier</div>
            <?php endif; ?>
        </div>
    </div>



    <div class="row px-3">
        <div class="table-container table-responsive">
            <table id="" class="table table-bordered">
                <thead class="text-uppercase">
                    <tr class="me-3">
                        <th class="text-center" scope="col"><span>Serial</span></th>
                        <th class="text-center" scope="col"><span>Customer</span></th>
                        <th class="text-center" scope="col"><span>Details</span></th>
                    </tr>
                </thead>
                <tbody>

                    <?php $__currentLoopData = $supplierData; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <?php if(isset($item) && $item != null): ?>
                    <tr class="">
                        <td class="text-center">
                            <b><?php echo e($key+1); ?></b>
                        </td>
                        <td class="text-start w-50">
                            <div class="row_title">
                                <b>Name: </b> <?php echo e($item->supplier_name); ?> <br>
                                <b>Phone: </b> <?php echo e($item->supplier_phone); ?>

                            </div>
                            <div class="row-actions mt-2">

                                <?php if(Auth::user()->can('supplier-edit')): ?>
                                <span><a class="fw-bolder text-success" href="<?php echo e(route('supplier-profile', $item->id)); ?>">Profile</a>
                                </span>

                                <span> | <button class="fw-bolder text-primary edit_class_modal border-0 bg-transparent"
                                        value="<?php echo e($item->id); ?>" onclick="updateSupplier(<?php echo e($item->id); ?>)"> Edit
                                    </button></span>
                                <?php endif; ?>
                                <?php if(Auth::user()->can('supplier-delete')): ?>
                                <span> | <a class="fw-bolder text-danger row-delete"
                                        href="<?php echo e(route('supplier-delete', $item->id)); ?>">Delete</a>
                                </span>
                                <?php endif; ?>
                            </div>
                        </td>
                        <td class="text-left">
                            <b>Company: </b> <?php echo e($item->company_name); ?> <br>
                            <b>Address: </b> <?php echo e($item->supplier_address); ?>

                        </td>
                    </tr>

                    
                    <div class="modal fade" id="updateSupplier<?php echo e($item->id); ?>" tabindex="-1"
                        aria-labelledby="oneInputModalLabel" aria-hidden="true" data-bs-backdrop='static'>
                        <div class="modal-dialog modal-dialog-centered max-width-900px">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <h1 class="modal-title fs-5" id="oneInputModalLabel">Update Supplier</h1>
                                    <button type="button" class="btn-close" data-bs-dismiss="modal"
                                        aria-label="Close"></button>
                                </div>
                                <form action="<?php echo e(route('supplier.update', $item->id)); ?>" method="post"
                                    enctype="multipart/form-data">
                                    <?php echo csrf_field(); ?>
                                    <?php echo method_field('put'); ?>
                                    <div class="modal-body p-0">
                                        <div class="row px-4 my-4">
                                            <div class="col-md-6 mb-2">
                                                <div>
                                                    <div class="form-group">
                                                        <label for="supplier_name">Supplier Name<span
                                                                class="text-danger">*</span>
                                                        </label>
                                                        <input type="text" name="supplier_name" required
                                                            class="form-control form-control-solid" value="<?php echo e($item->supplier_name); ?>"
                                                            placeholder="Supplier Name">
                                                    </div>

                                                    <?php $__errorArgs = ['supplier_name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                                    <span class=text-danger><?php echo e($message); ?></span>
                                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                                </div>
                                            </div>

                                            <div class="col-md-6 mb-2">
                                                <div>
                                                    <div class="form-group">
                                                        <label for="supplier_phone">Supplier Phone<span class="text-danger">*</span>
                                                        </label>
                                                        <input type="number" name="supplier_phone" id="supplier_phone<?php echo e($item->id); ?>" class="form-control form-control-solid" 
                                                            value="<?php echo e($item->supplier_phone); ?>" placeholder="Supplier Phone" required>
                                                    </div>
                                            
                                                    <?php $__errorArgs = ['supplier_phone'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                                    <span class=text-danger><?php echo e($message); ?></span>
                                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                                </div>
                                            </div>

                                            <div class="col-md-6 mb-2">
                                                <div>
                                                    <div class="form-group">
                                                        <label for="supplier_email">Supplier Email<span class="text-danger"></span>
                                                        </label>
                                                        <input type="email" name="supplier_email"
                                                            class="form-control form-control-solid" value="<?php echo e($item->supplier_email); ?>" placeholder="Supplier Email">
                                                    </div>

                                                    <?php $__errorArgs = ['supplier_email'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                                    <span class=text-danger><?php echo e($message); ?></span>
                                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                                </div>
                                            </div>

                                            <div class="col-md-6 mb-2">
                                                <div>
                                                    <div class="form-group">
                                                        <label for="company_name">Company Name<span class="text-danger"></span>
                                                        </label>
                                                        <input type="text" name="company_name" class="form-control form-control-solid" 
                                                            value="<?php echo e($item->company_name); ?>" placeholder="Company Name">
                                                    </div>
                                            
                                                    <?php $__errorArgs = ['company_name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                                    <span class=text-danger><?php echo e($message); ?></span>
                                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                                </div>
                                            </div>
                                            
                                            <div class="col-md-12 mb-2">
                                                <div>
                                                    <div class="form-group">
                                                        <label for="note">Note<span class="text-danger"></span>
                                                        </label>
                                                        <input type="text" name="note" class="form-control form-control-solid" 
                                                            value="<?php echo e($item->note); ?>" placeholder="Note">
                                                    </div>
                                            
                                                    <?php $__errorArgs = ['note'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                                    <span class=text-danger><?php echo e($message); ?></span>
                                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                                </div>
                                            </div>

                                            <div class="col-md-12 mb-2">
                                                <div>
                                                    <div class="form-group">
                                                        <label for="supplier_address"
                                                            class="form-label required">Address</label>

                                                        <textarea class="form-control" name="supplier_address"
                                                            id="supplier_address<?php echo e($item->id); ?>" cols="3" rows="2"
                                                            placeholder="Address"><?php echo e($item->supplier_address); ?></textarea>

                                                        <?php $__errorArgs = ['supplier_address'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                                        <span class=text-danger><?php echo e($message); ?></span>
                                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                                    </div>
                                                </div>
                                            </div>

                                        </div>
                                    </div>
                                    <div class="modal-footer">
                                        <button type="submit" class="btn btn-success" onclick="return checkValidateFU(<?php echo e($item->id); ?>)">Update</button>
                                        <button type="button" class="btn btn-danger"
                                            data-bs-dismiss="modal">Cancel</button>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>

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


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

        <?php if(isset($allSupplierCount) && $allSupplierCount >= 10): ?>
        <div class="clearfix d-flex">
            <div class="float-left">
                <p class="text-muted">
                    <?php echo e(__('Showing')); ?>

                    <span class="font-weight-bold"><?php echo e($supplierData->firstItem()); ?></span>
                    <?php echo e(__('to')); ?>

                    <span class="font-weight-bold"><?php echo e($supplierData->lastItem()); ?></span>
                    <?php echo e(__('of')); ?>

                    <span class="font-weight-bold"><?php echo e($supplierData->total()); ?></span>
                    <?php echo e(__('results')); ?>

                </p>
            </div>

            <div class="float-right custom-table-pagination">
                <?php echo $supplierData->links('pagination::bootstrap-4'); ?>

            </div>
        </div>
        <?php endif; ?>
    </div>
</div>



<div class="modal fade" id="addSupplier" tabindex="-1" aria-labelledby="oneInputModalLabel" aria-hidden="true"
    data-bs-backdrop='static'>
    <div class="modal-dialog modal-dialog-centered max-width-900px">
        <div class="modal-content">
            <div class="modal-header">
                <h1 class="modal-title fs-5" id="oneInputModalLabel">New Supplier</h1>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <form action="<?php echo e(route('supplier.store')); ?>" method="post" enctype="multipart/form-data">
                <?php echo csrf_field(); ?>
                <div class="modal-body p-0">
                    <div class="row px-4 my-4">
                        <div class="col-md-6 mb-2">
                            <div>
                                <div class="form-group">
                                    <label for="supplier_name">Supplier Name<span class="text-danger">*</span>
                                    </label>
                                    <input type="text" name="supplier_name" required
                                        class="form-control form-control-solid" value="" placeholder="Supplier Name">
                                </div>

                                <?php $__errorArgs = ['supplier_name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <span class=text-danger><?php echo e($message); ?></span>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                            </div>
                        </div>

                        <div class="col-md-6 mb-2">
                            <div>
                                <div class="form-group">
                                    <label for="supplier_phone">Supplier Phone<span class="text-danger">*</span>
                                    </label>
                                    <input type="number" name="supplier_phone" id="supplier_phone" class="form-control form-control-solid" value=""
                                        placeholder="Supplier Phone" required>
                                </div>
                        
                                <?php $__errorArgs = ['supplier_phone'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <span class=text-danger><?php echo e($message); ?></span>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                            </div>
                        </div>

                        <div class="col-md-6 mb-2">
                            <div>
                                <div class="form-group">
                                    <label for="supplier_email">Supplier Email<span class="text-danger"></span>
                                    </label>
                                    <input type="email" name="supplier_email" class="form-control form-control-solid"
                                        value="" placeholder="Supplier Email">
                                </div>

                                <?php $__errorArgs = ['supplier_email'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <span class=text-danger><?php echo e($message); ?></span>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                            </div>
                        </div>
                        
                        <div class="col-md-6 mb-2">
                            <div>
                                <div class="form-group">
                                    <label for="company_name">Company Name<span class="text-danger"></span>
                                    </label>
                                    <input type="text" name="company_name" class="form-control form-control-solid"
                                        value="" placeholder="Company Name">
                                </div>

                                <?php $__errorArgs = ['company_name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <span class=text-danger><?php echo e($message); ?></span>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                            </div>
                        </div>

                        <div class="col-md-12 mb-2">
                            <div>
                                <div class="form-group">
                                    <label for="note">Note<span class="text-danger"></span>
                                    </label>
                                    <input type="text" name="note" class="form-control form-control-solid" value=""
                                        placeholder="Note">
                                </div>
                        
                                <?php $__errorArgs = ['note'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <span class=text-danger><?php echo e($message); ?></span>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                            </div>
                        </div>

                        <div class="col-md-12 mb-2">
                            <div>
                                <div class="form-group">
                                    <label for="supplier_address" class="form-label required">Address</label>

                                    <textarea class="form-control" name="supplier_address" id="supplier_address" cols="3"
                                        rows="2" placeholder="Address"></textarea>

                                    <?php $__errorArgs = ['supplier_address'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <span class=text-danger><?php echo e($message); ?></span>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-success" onclick="return checkValidate()">Save</button>
                    <button type="button" class="btn btn-danger" data-bs-dismiss="modal">Cancel</button>
                </div>
            </form>
        </div>
    </div>
</div>

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

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

<script>
    $(document).ready(function(){
        $("#customer_group_id").select2({
            dropdownParent: $('#addSupplier')
        })
    });

    //To show update modal...
    function updateSupplier(id) {
        $("#customer_group_id"+id).select2({
            dropdownParent: $('#updateSupplier'+id)
        })

        $("#updateSupplier"+id).modal('show');

    }

    function checkValidate() {
        var mobileNumber = $("#supplier_phone").val();

        if (mobileNumber != '' && mobileNumber.length != 11) { 
            event.preventDefault();
            toastr.error("Mobile number must be 11 digit."); 
        }

        return true;
    }
    
    //For update...
    function checkValidateFU(id) {
        var mobileNumber = $("#supplier_phone"+id).val();

        if (mobileNumber != '' && mobileNumber.length != 11) { 
            event.preventDefault();
            toastr.error("Mobile number must be 11 digit."); 
        }

        return true;
    }
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH E:\Project\Personal-Project\Office-Project\update\skin-care\resources\views/admin/productManage/supplier/index.blade.php ENDPATH**/ ?>