<link rel="stylesheet" href="<?php echo e(url('assets/css/chosen.css')); ?>" type="text/css">
          
        <!-- Custom CSS -->
       
        <link rel="stylesheet" href="<?php echo e(url('assets/css/style_new.css')); ?>">
<?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>Add Hospitals
                    </h6>
                </div>
            </div>

            <input name="_token" type="hidden" id="token_hosp" value="<?php echo e(csrf_token()); ?>">
            <div class="dashboard-cnts">
                <div class="row">
                    <div class="col-lg-5 d-flex align-items-center">
                        <select id="buyer"  name="buyer[]" data-placeholder="Choose a hospital..." class="chosen-select form-control mr-5" multiple style="width:350px;" tabindex="4">
                            <option value=""></option> 
                            
                                <?php $__currentLoopData = $allbuyers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $buyerlist): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($buyerlist['id']); ?>"><?php echo e($buyerlist['name']); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        <input type="submit" name="submit" id="submit" class="btn">
                    </div>
                    <span style="color:red" id="buyererror"></span>
                    
                    <div class="col-lg-2">
<!--                        <input type="submit" name="submit" id="submit" class="btn">-->
                    </div>
                </div>
            </div>
           
        </div>
 
    <?php $__env->stopSection(); ?>
    <?php $__env->startSection('scripts'); ?>
    <script src="<?php echo e(url('assets/css/chosen.jquery.min.js')); ?>"></script>  
        <script src="<?php echo e(URL::to('assets/js/buyernew.js')); ?>"></script>

        
<script>
    $(".chosen-select").chosen();
    $('button').click(function(){
            $(".chosen-select").val('').trigger("chosen:updated");
    });
</script>

        <script>
            $(document).on("click", "#submit", function (form,e) {
            
             var count = $("#buyer :selected").length;
     
              if(count==0){
                  $("#buyererror").html("This field is required");
                  
              }
              else{
                 $("#buyererror").html(" ");
                 var selected = $("#buyer :selected").map((_, e) => e.value).get();
                
                     var data = {
                     _token: $('#token_hosp').val(),
                     buyer:selected,
                    
                 }
                 $.ajax({
                     url: 'https://www.meddbot.com/buyers/buyerrequest',
                     type: "POST",
                     data: data,
                     success: function (res) {
     
                         console.log();
                         if(res==1){
                             swal({
                                     title: "",
                                     text: "Request successfully sent!",
                                     type: "success"
                                 },function () {
                                     location.reload();
                                 });
                         }
     
                     }
     
                 });
     
                
              }
             
           });
         </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/assign_buyer_proc.blade.php ENDPATH**/ ?>