<?php $__env->startSection('content'); ?>
    <style>
        label.error {
            color: red;
        }
    </style>
    <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
    <div class="common-content">
        <div class="page-content">
            <div class="page-heading">
                <div class="headings">
                    <h6>Manage Buyer User
                    </h6>
                </div>
            </div>
            <div class="dashboard-cnts">
              <?php if(count($userlist) < 5): ?>
                  <button class="barcodeBtn mb-4" type="button" id="create_new_department"
                      style="display:block;height: 38px;margin-top: 25px;">
                      Add New Buyer User
                  </button>
              <?php endif; ?>
            </div>

        <?php if(count($userlist)!=0): ?>
            <div class="tableBox wraper">
                <table id="example" class="display table" cellspacing="0" width="100%">
                <thead>
                    <tr>
                        <th>No:
                        </th>
                        <th> Name
                        </th>
                        <th>Phone Number
                        </th>
                        <th>Email Id
                        </th>
                       
                        <th>Role
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <?php $i = 1; ?>
                    <?php $__currentLoopData = $userlist; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $list): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td><?php echo e($i); ?></td>
                            <td>
                                <?php echo e(ucfirst($list->name)); ?>

                            </td>
                            <td>
                                <?php echo e($list->phone_no); ?>

                            </td>
                            <td>
                                <?php echo e($list->email); ?>

                            </td>
                           
                            <td>
                                <?php if($list->subbuyer_role == '1'): ?>
                                    Purchase Admin
                                <?php elseif($list->subbuyer_role == '5'): ?>
                                    Store Admin
                                <?php elseif($list->subbuyer_role == '3'): ?>
                                    Accounts Admin
                                <?php elseif($list->subbuyer_role == '2'): ?>
                                    Biomedical Admin
                                <?php elseif($list->subbuyer_role == '4'): ?>
                                    GM Procurement
                                <?php else: ?>
                                <?php endif; ?>
                            </td>
                        </tr>
                        <?php $i++; ?>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </tbody>
            </table>
        </div>
        <?php endif; ?>
        </div>
        <!-- Modal -->
        <div class="modal fade" id="myModalaction" role="dialog">
            <div class="modal-dialog modal-dialog-centered">
                <!-- Modal content-->
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title" id="exampleModalLabel">Add New User
                        </h5>
                        <button type="button" class="close close_message" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;
                            </span>
                        </button>
                    </div>
                    <div class="modal-body">
                        <div class="col-sm-12 col-xs-12">
                            <div class="dashboard-cnts">
                                <form method="POST" action="<?php echo e(url('buyers/add_buyeruser')); ?>" id="addnewbuyeruser">
                                    <?php echo csrf_field(); ?>
                                    <div class="row">
                                        <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
                                            <div class="form-inputs">
                                                <div class="form-group">
                                                    <label>First Name
                                                    </label>
                                                    <input type="text" class="form-control" id="first_name"
                                                        name="first_name" value="">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
                                            <div class="form-inputs">
                                                <div class="form-group">
                                                    <label>Last Name
                                                    </label>
                                                    <input type="text" class="form-control" id="last_name"
                                                        name="last_name" value="">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
                                            <div class="form-inputs">
                                                <div class="form-group">
                                                    <label>Phone Number
                                                    </label>
                                                    <input type="number" minlength="10" maxlength="13" class="form-control" name="phone" id="phone"
                                                        value="">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
                                            <div class="form-inputs">
                                                <div class="form-group">
                                                    <label>Email
                                                    </label>
                                                    <input type="text" class="form-control" name="email" id="email"
                                                        value="">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
                                            <div class="form-inputs">
                                                <div class="form-group">
                                                    <label>Password
                                                    </label>
                                                    <input type="password" minlength="8" class="form-control" name="password"
                                                        id="password" value="">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
                                            <div class="form-inputs">
                                                <div class="form-group">
                                                    <label>Role
                                                    </label>
                                                    <select name="role" id="role" class="form-control">
                                                      <?php
                                                        $userRoles = [
                                                          '1' => 'Purchase Admin',
                                                          '5' => 'Store Admin',
                                                          '3' => 'Accounts Admin',
                                                          '2' => 'Biomedical Admin',
                                                          '4' => 'GM Procurement',
                                                        ];
                                                        foreach ($userlist as $h) {
                                                          if (in_array($h->subbuyer_role, [1,2,3,4,5]))
                                                            unset($userRoles[$h->subbuyer_role]);
                                                        }
                                                        echo "<option value=''>Select</option>";
                                                        foreach ($userRoles as $key=>$value) {
                                                          echo "<option value=" . $key . ">" . $value . "</option>";
                                                        }
                                                      ?>
                                                      
                                                    </select>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-12">
                                            <div class="green-button">
                                                <button>Add</button>
                                            </div>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- Modal -->
    <?php $__env->stopSection(); ?>
    <?php $__env->startSection('scripts'); ?>
        <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
        <script src="<?php echo e(URL::to('assets/js/buyernew.js')); ?>"></script>
        <script>
            $(function() {
                $(".invoiceselect").select2();
            });
            $(document).ready(function() {
                $('#example').DataTable();
                $('#example1').DataTable();
            });
            <?php if(Session::has('message')): ?>
                swal({
                    title: "",
                    text: "<?php echo e(Session::get('message')); ?>",
                    type: "success",
                    showCancelButton: false,
                    dangerMode: false,
                    confirmButtonText: 'OK',
                });
            <?php endif; ?>
            <?php if(Session::has('errormessage')): ?>
                swal({
                    title: "",
                    text: "<?php echo e(Session::get('errormessage')); ?>",
                    type: "error",
                    showCancelButton: false,
                    dangerMode: true,
                    confirmButtonText: 'OK',
                });
            <?php endif; ?>
        </script>
    <?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.main_assetmanage', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/meddbot/public_html/resources/views/buyers/manage_buyeruser.blade.php ENDPATH**/ ?>