<html>
    <head>
        <!-- Required meta tags -->
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        
        
        <!-- Fav icon -->
        <link rel="icon" href="<?php echo e(url('emr_assets/img/favicon.png')); ?>" type="image/png" sizes="16x16"> 
        
        <!--Bootstrap icons-->
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/font/bootstrap-icons.css">
        
        <!-- <link rel="stylesheet" href="https://cdn.datatables.net/1.11.4/css/jquery.dataTables.min.css"> -->
        <link rel="stylesheet" href="https://cdn.datatables.net/1.13.1/css/dataTables.bootstrap5.min.css">
        <!-- Bootstrap -->
        <!-- CSS only -->
        <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
        
         <!-- Custom CSS -->
        <link rel="stylesheet" href="<?php echo e(url('emr_assets/css/style.css')); ?>">
        <style type="text/css">
            .lbls
            {
              float: left;text-align: ;font-weight: 500;height: 45px;
            }
            .lbls_span
            {
                float: left;height: 45px;
            }
            .col-lg-1
            {
                width: 2%;
            }
            .col-lg-4
            {
                float: left;
            }
        </style>

        <script src="https://cdn.jsdelivr.net/npm/sweetalert2@7.12.15/dist/sweetalert2.all.min.js"></script>  
        <link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/sweetalert2@7.12.15/dist/sweetalert2.min.css'></link>
        
        <title>Meddbot</title>
    </head>
    <body>
      
       <main>
           <div class="sidebar">
               <div class="logo-section">
                   <img src="<?php echo e(url('emr_assets/img/logo.png')); ?>">
               </div>
               <div class="menu">
                   <ul>
                       <li>
                          <a class=" nav-link active " id="first" data-bs-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">
                            <img src="<?php echo e(url('emr_assets/img/hospital-icon.svg')); ?>">
                              <span> Hospitals</span>
                          </a>

                        <div class="collapse show" id="collapseExample">
                           <ul class="sub-menu" >
                               <li> <a href="<?php echo e(url('/api/district_hospital/dashboard')); ?>"><i class="bi bi-dash-lg"></i> PHC / CHC</a> </li>
                               <li> <a href="<?php echo e(url('/api/district_hospital/doctors')); ?>"><i class="bi bi-dash-lg"></i> Doctors</a> </li>
                               <li> <a class="active" href="<?php echo e(url('/api/district_hospital/medicines')); ?>"><i class="bi bi-dash-lg"></i> Medicines</a> </li>
                               <li> <a href="<?php echo e(url('/api/district_hospital/labs')); ?>"><i class="bi bi-dash-lg"></i> Labs</a> </li>
                               <!-- <li> <a href="<?php echo e(url('/api/district_hospital/lab_test_request')); ?>"><i class="bi bi-dash-lg"></i> Lab Test Request</a> </li> -->
                            </ul>
                        </div>
                       </li>
                       <li>
                           <a href="#" class="nav-link" >
                                <img src="<?php echo e(url('emr_assets/img/notifications-icon.svg')); ?>">
                              <span>Notifications</span>
                           </a>
                       </li>
                       <li>
                           <!-- <a href="#" class="nav-link" >
                                <img src="<?php echo e(url('emr_assets/img/pharmacy-icon.svg')); ?>">
                              <span>Pharmacy</span>
                           </a> -->
                           <a class=" nav-link  " id="second" data-bs-toggle="collapse" href="#collapseExample_1" role="button" aria-expanded="false" aria-controls="collapseExample">
                                <img src="<?php echo e(url('emr_assets/img/pharmacy-icon.svg')); ?>">
                              <span>Pharmacy</span>
                           </a>
                           <div class="collapse " id="collapseExample_1">
                           <ul class="sub-menu" >
                               <li> <a  href="<?php echo e(url('/api/district_hospital/pharmacy')); ?>"><i class="bi bi-dash-lg"></i>Pharmacy List</a> </li>
                               <li> <a  href="<?php echo e(url('/api/district_hospital/pharmacy_med_list')); ?>"><i class="bi bi-dash-lg"></i>Medicine Dispatch</a> </li>
                               <li> <a   href="<?php echo e(url('/api/district_hospital/pharmacy_med_list_low')); ?>"><i class="bi bi-dash-lg"></i>Stock Report</a> </li>
                               <li> <a   href="<?php echo e(url('/api/district_hospital/medicine_request_list')); ?>"><i class="bi bi-dash-lg"></i> Medicine Request List</a> </li>
                               <li> <a   href="<?php echo e(url('/api/district_hospital/others_request_list')); ?>"><i class="bi bi-dash-lg"></i> Other Request List</a> </li>
                               
                            </ul>
                        </div>
                       </li>
                       <li>
                           <a href="#" class="nav-link" >
                                <img src="<?php echo e(url('emr_assets/img/request-icon.svg')); ?>">
                              <span>Requests</span>
                           </a>
                       </li>
                   </ul>
               </div>
           </div>
           <div class="content-section">
               <header>
                   <div class="header-details">
                       <button class="btn-primary togg-sidebar" ><i class="bi bi-list"></i>  </button>
                       <h4>Medicines</h4>
                   </div>
                   <div class="header-itms">
                       <ul>
                           <li>
                               <a href="#"><button class="btn-settings btn header-buttons" ><i class="bi bi-gear-fill"></i></button></a>
                           </li>
                           <li>
                               <a href="#"><button class="btn-settings btn header-buttons" ><i class="bi bi-bell-fill"></i></button></a>
                           </li>
                       </ul>
                       <div class="user-section">
                           <h5>DH</h5>
                          
                           <div class="dropdown">
                                  <button class=" btn-secondary dropdown-toggle user-profile" type="button" data-bs-toggle="dropdown" aria-expanded="false">
                                    <span class="" >A</span>
                                  </button>
                                  <ul class="dropdown-menu">
                                    <li><a class="dropdown-item" href="#">Action</a></li>
                                    <li><a class="dropdown-item" href="#">User Profile</a></li>
                                    <li><a class="dropdown-item" href="#">Logout</a></li>
                                  </ul>
                                </div>
                           
                           
                       </div>
                   </div>
               </header>
               <div class="main-section">
                   <div class="action-sec d-flex justify-content-between">
                       <div class="search">
                           <input type="text" placeholder="Search Medicines"  id="search_medicine"class="form-control" >
                           <button class="btn-primary search-hos" id="search_medicine_button" > Submit</button>
                       </div>
                       <div class="actions">
                           
                           
                           <button class="btn-primary add-new" data-bs-toggle="modal" data-bs-target="#exampleModal"> Add new</button>
                       </div>
                       <!-- <div class="actions">
                           <button class="btn-primary add-new" data-bs-toggle="modal" data-bs-target="#"> Assign</button>
                       </div>
                       <div class="actions">
                           <button class="btn-primary add-new" data-bs-toggle="modal" data-bs-target="#exampleModal"> Add new</button>
                       </div> -->
                   </div>
                   <div class="medd-content shadow-sm p-4 mt-4" id="list_view">
                       
                       <div class="row align-items-center">
                           <div class="col-lg-8">
                               <h6 style="margin-bottom: 25px;">Medicines List</h6>
                           
                           </div>
                           <div class="col-lg-4">
                               <!-- <input type="text" style="    font-family: bootstrap-icons !important;" placeholder="&#xF52A; Search A Hospital" class="form-control rounded-5" > -->
                           </div>
                       </div>
                       
                       
                       
                      <!--  <div class="table table-responsive">
                           <table class="table mt-3 "> -->
                            <table id="example" class="table table-striped" style="width:100%">
                          <thead>
                            <tr>
                              <th scope="col">SL No</th>
                              <th scope="col">Medicine Type</th>
                              <th scope="col">Medicine Name</th>
                              <!-- <th scope="col">Dispatch Qty</th> -->
                              <th scope="col">Available Qty</th>
                              <th scope="col">Expiry Date</th>
                              <th scope="col">Batch No</th>
                              <th scope="col">Actions</th>
                            </tr>
                          </thead>
                          <tbody>
                            <?php $i=1;?>
                            <?php $__currentLoopData = $details; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $doctor): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                        
                        
                            <tr>
                              <td><?php echo e($i); ?></td>
                              <td><?php echo e($doctor->med_type); ?></td>
                              <td scope="row"><a href="#"><?php echo e($doctor->med_name); ?></a> </td>
                              <!-- <td><?php echo e($doctor->dispatch_qty); ?></td> -->
                              <td><?php echo e($doctor->avail_qty); ?></td>
                              <td><?php echo e($doctor->expiry_date); ?></td>
                              <td><?php echo e($doctor->batch_no); ?></td>
                              <td>
                                  <div class="action-buttons">
                                      <button class="edit" > <span><i class="bi bi-pencil-square"></i></span>Edit</button>
                                      <button class="delete" onclick="delete_medicines('<?php echo e($doctor->id); ?>');" > <span><i class="bi bi-trash3"></i></span>Delete</button>
                                  </div>
                                </td>
                            </tr>
                            <?php $i++;?>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                              
                              
                          </tbody>
                        </table>
                       <!-- </div> -->
                   </div>

                   <div class="medd-content shadow-sm p-4 mt-4" id="search_view" style="display:none;">
                       
                       <div class="row align-items-center">
                           <div class="col-lg-4" style="text-align:center ;margin-bottom: 40px;">
                               <h6>Medicine Details</h6>
                           
                           </div>
                           
                       </div>
                       
                       
                       
                       <div class="table table-responsive">
                           <div class="col-lg-2 lbls" >
                              Medicine Name 
                          </div>
                          <div class="col-lg-1 lbls" >: &nbsp;
                          </div>
                          <div class="col-lg-9 lbls_span">
                              <span id="med_name_view"></span>
                          </div>
                          <div class="col-lg-2 lbls">
                              Available Quantity 
                          </div>
                          <div class="col-lg-1 lbls" >: &nbsp;
                          </div>
                          <div class="col-lg-9 lbls_span">
                              <span id="avail_qty_view"></span>
                          </div>
                          <div class="col-lg-2 lbls">
                              Batch Number 
                          </div>
                          <div class="col-lg-1 lbls" >: &nbsp;
                          </div>
                          <div class="col-lg-9 lbls_span">
                              <span id="batch_no_view"></span>
                          </div>
                          
                          <div class="col-lg-2 lbls">
                              Dispatch Quantity
                          </div>
                          <div class="col-lg-1 lbls" >: &nbsp;
                          </div>
                          <div class="col-lg-9 lbls_span">
                              <span id="dispatch_qty_view"></span>
                          </div>
                          <div class="col-lg-2 lbls">
                             Expiry Date
                          </div>
                          <div class="col-lg-1 lbls" >: &nbsp;
                          </div>
                          <div class="col-lg-9 lbls_span">
                              <span id="expiry_date_view"></span>
                          </div>
                          <div class="col-lg-2 lbls">
                            Current available Quantity
                          </div>
                          <div class="col-lg-1 lbls" >: &nbsp;
                          </div>
                          <div class="col-lg-9 lbls_span">
                              <span id="current_avai_qty_view"></span>
                          </div>
                          
                       </div>
                   </div>
               </div>
               <div class="footer">
                   <span>Copyright © 2022, Meddbot</span>
               </div>
           </div>
        </main>
        
        
        
        


<!-- Modal -->
<div class="modal fade" id="exampleModal" data-bs-backdrop="static" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <div class="modal-header">
        <h1 class="modal-title fs-5" id="exampleModalLabel">Add Medicines</h1>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body addnew">
       <div class="row mb-3">
           <!--  <div class="col-lg-4">
                <select class="form-control custom-fields mt-3" id="Clinic">
                    <option value="">Clinic Name</option>
                    <?php $__currentLoopData = $clinics; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $clinic): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                        <option value="<?php echo e($clinic->name); ?>"><?php echo e($clinic->name); ?></option>
                                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>  -->
          <!--   <div class="col-lg-4" style="margin-top: 30px;">
                <input type="checkbox" id="d_hospital" name="" style="margin-right: 15px;">Self
            </div>  -->

            <div class="col-lg-4" style="margin-top: 30px;">
                 <select class="form-control custom-fields " style="margin-right: 25px;" id="med_type_id">
                              <option value="" >Select Medicine Type</option>
                              <option value="0" >ALL</option>
                              <?php $__currentLoopData = $Medicine_types; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $type): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                              <option value="<?php echo e($type->id); ?>" ><?php echo e($type->type); ?></option>
                              <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                              
                          </select>
            </div> 

            

            <div id="tab_logic">
                    <div class="col-lg-4 required-field">
                        <input type="text" class="form-control custom-fields mt-3 required-field" id="Medicine_name" placeholder="Medicine Name *">
                    </div> 
                    <div class="col-lg-4">
                        <input type="number" min="0" class="form-control custom-fields mt-3" id="Available_qty" placeholder="Available Qty *">
                    </div>
                     
                   <div class="col-lg-4">
                        <input type="text" class="form-control custom-fields mt-3" id="Batch_no" placeholder="Batch No *">
                    </div>
                    <div class="col-lg-4">
                        <input type="number" min="0" class="form-control custom-fields mt-3" id="Dispatch_qty" placeholder="Dispatch Qty *">
                    </div> 
                    <div class="col-lg-4" style="position:relative;" >
                        <input type="text" class="form-control custom-fields mt-3" id="datepicker" placeholder="Expiry Date *">
                        <img class="picker-icon" src="https://www.meddbot.com/emr_assets/img/calender.png" alt="img" >
                    </div> 
                   <div class="col-lg-4">
                        <input type="number" min="0" class="form-control custom-fields mt-3" id="Current_avail_qty" placeholder="Current Available Qty *">
                    </div>
            </div>
            <div class="more-feilds"></div>
            <!-- <div class="col-lg-12" style="margin-top: 15px;">
                <button type="button" class="btn btn-primary add-more">Add More</button>
            </div>  -->
       </div>
      </div>
      <div class="modal-footer" style="margin-top: 0px;">
        <button type="button" class="btn btn-primary save-button" id="save_medicine">Save Now</button>
      </div>
    </div>
  </div>
</div> 
        
        
        
        <input type="text" id="DC_hospital" value='District Hospital'> 
        
        
        
        
      
        
      

     
    </body>
</html>


   <!-- JS Start -->

       <!-- jq script -->   
      <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

      <!-- bootstrap script --> 
      <!-- JavaScript Bundle with Popper -->
      <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>


<link rel="stylesheet" href="https://code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
  <link rel="stylesheet" href="https://jqueryui.com/resources/demos/style.css">

      <!-- fontawesome script -->   
      <script src="https://kit.fontawesome.com/c026154490.js" crossorigin="anonymous"></script>  
      <script src="https://cdn.datatables.net/1.13.1/js/jquery.dataTables.min.js" crossorigin="anonymous"></script>  
      <script src="https://cdn.datatables.net/1.13.1/js/dataTables.bootstrap5.min.js" crossorigin="anonymous"></script> 
      <script src="<?php echo e(url('emr_assets/js/myjs.js')); ?>"></script>  

      
  <script src="https://code.jquery.com/jquery-3.6.0.js"></script>
  <script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>

<script type="text/javascript">
    $(document).ready(function() 
    {
        $(".add-more").click(function(){ 
            var html = $("#tab_logic").html();
            $(".more-feilds").append(html);        
        });

       
    });

</script>
 <script>
  $( function() {
    //$( "#datepicker" ).datepicker();
    $( "#datepicker" ).datepicker({ minDate: new Date()});
  } );
//   $('body').on('focus',"#datepicker", function(){
//     $(this).datepicker();
// });​


  </script>


  <script>
        $(document).ready(function () 
        {
            $('#example').DataTable();
        });
        </script>
 
  <style type="text/css">
      .ui-datepicker-calendar td {
    padding: 2px 2px !important;
    
}
/*.required-field::after {
    content: "*";
    color: red;
}*/
  </style>

<script type="text/javascript">
    $("#save_medicine").click(function()
    {
        var baseurl='https://www.meddbot.com/api/district_hospital/';
        //swal();
        var doctor_type='District_hospital';
        // if ($('#d_hospital').is(':checked'))
        // {
        //    //swal('checked');
        //    var doctor_type='District_hospital';
        //    $("#DC_hospital").val('District Hospital');
        // }else{
        //    //swal('not checked');
        //    //var doctor_type='other_hospital';
        //    $("#DC_hospital").val('other_hospital');
        // }

       // var Clinic=$("#Clinic").val();
        var Medicine_name=$("#Medicine_name").val();
        var Available_qty=$("#Available_qty").val();
        var Batch_no=$("#Batch_no").val();
        var Dispatch_qty=$("#Dispatch_qty").val();
        var med_type_id=$("#med_type_id").val();
        // var Expiry_date=$("#Expiry_date").val();

        var date = $("#datepicker").datepicker("getDate");
      var datepicker=($.datepicker.formatDate("dd/mm/yy", date));
//swal(datepicker);
        //var datepicker=$("#Expiry_date").val();
        var Current_avail_qty=$("#Current_avail_qty").val();

        var doctor_type=$("#DC_hospital").val();
       
        if(Medicine_name=='')
        {
            swal('Please Enter Medicine Name');
            return false;
        }
        if(Available_qty=='')
        {
            swal('Please Enter Available Quantity');
            return false;
        }
        if(Math.sign(Available_qty)==-1)
        {
            swal(' Please Enter Valid Available Quantity');
            return false;
        }
        if(Batch_no=='')
        {
            swal('Please Enter Batch Number');
            return false;
        }
        if(Dispatch_qty=='')
        {
            swal('Please Enter Dispatch Quantity');
            return false;
        }
        if(Math.sign(Dispatch_qty)==-1)
        {
            swal('Please Enter Valid Dispatch Quantity');
            return false;
        }
        if(datepicker=='')
        {
            swal('Please Enter Expiry Date');
            return false;
        }
        if(Current_avail_qty=='')
        {
            swal('Please Enter Current Available Quantity');
            return false;
        }
        if(Math.sign(Current_avail_qty)==-1)
        {
            swal('Please Enter Valid Current Available Quantity');
            return false;
        }
        if(doctor_type=='other_hospital' && Clinic=='')
        {
            

                swal('Please Enter Clinic Name');
            
        }
        else
        {
            var DC_hospital=$("#DC_hospital").val();
            //swal(DC_hospital);
            if(DC_hospital=='other_hospital')
            {
                var Clinic_name=Clinic;
            }
            else
            {
                var Clinic_name=DC_hospital;
            }
           // swal(datepicker);
            var data = {

                         Clinic      :Clinic_name,
                         Medicine_name   :Medicine_name,
                         Available_qty : Available_qty,
                         Batch_no : Batch_no,
                         Dispatch_qty : Dispatch_qty,
                         Expiry_date : datepicker,
                         Current_avail_qty : Current_avail_qty,
                         hospital_type : doctor_type,
                         med_type_id:med_type_id
                      }

                 $.ajax({url:baseurl+'add_medicine',
                                type:"POST",
                                data:data,
                                success: function (res) {
                                    if(res!='')
                                    {
                                        swal('Medicine Added Successfully !!');
                                    }
                                    
                                    console.log(res);
                                    //location.reload();
                                    window.setTimeout(function(){ 
                                    location.reload();
                                } ,3000);
                                }
                            });
    }
    });
    function delete_medicines(id)
    {
       // swal(id);
        var baseurl='https://www.meddbot.com/api/district_hospital/';
        let text = "Are you sure to delete Medicine!";
          if (confirm(text) == true) 
          {
            var data = {

                     id      :id
                  }

             $.ajax({url:baseurl+'delete_medicines',
                            type:"POST",
                            data:data,
                            success: function (res) {
                                if(res!='')
                                {
                                    swal('Medicine Deleted!!');
                                }
                                
                                console.log(res);
                               // location.reload();
                               window.setTimeout(function(){ 
                                    location.reload();
                                } ,3000);
                                console.log(res);
                                
                            }
                        });  
          } 
          else 
          {
            
          }
    }
    $("#search_medicine_button").click(function()
    {
        
        var baseurl='https://www.meddbot.com/api/district_hospital/';
        var search_medicine=$("#search_medicine").val();
        //swal(search_hospital);
        if(search_medicine=='')
        {
            swal('Please Enter Medicine Name')
        }
        else
        {
            var data = {

                     search_medicine      :search_medicine
                  }

             $.ajax({url:baseurl+'search_medicine',
                            type:"POST",
                            data:data,
                            success: function (res) {
                                console.log(res);
                                if(res!='')
                                {
                                    res1=JSON.parse(res);
                                    
                                    var med_name= res1['search_medicine']['0'].med_name;
                                    $("#med_name_view").html(med_name);
                                    var avail_qty= res1['search_medicine']['0'].avail_qty;
                                    $("#avail_qty_view").html(avail_qty);
                                    var batch_no= res1['search_medicine']['0'].batch_no;
                                    $("#batch_no_view").html(batch_no);
                                    var dispatch_qty= res1['search_medicine']['0'].dispatch_qty;
                                    $("#dispatch_qty_view").html(dispatch_qty);
                                    var expiry_date= res1['search_medicine']['0'].expiry_date;
                                    $("#expiry_date_view").html(expiry_date);
                                    var current_avai_qty= res1['search_medicine']['0'].current_avai_qty;
                                    $("#current_avai_qty_view").html(current_avai_qty);
                                    $("#list_view").hide();
                                    $("#search_view").show();
                                }
                                
                                
                                
                            }
                        });
        }
        
    })
    $("#first").click(function()
    {
      $('#first').addClass('active');
      $('#collapseExample').addClass('show');
      $('#second').removeClass('active');
      $('#collapseExample_1').removeClass('show');
    });
    $("#second").click(function()
    {
      $('#second').addClass('active');
      $('#collapseExample_1').addClass('show');
      $('#first').removeClass('active');
      $('#collapseExample').removeClass('show');
    })
</script>
<?php /**PATH /home/meddbot/public_html/resources/views/district_hospital/medicines_list.blade.php ENDPATH**/ ?>