<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"> 
        

        <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDMSKOGGZK0R6RuqpTTrdj3uTu_k2LOGiM&libraries=places"></script>
        <!--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%;
            }
            .pac-target-input{
                z-index: 10000 !important;
                /*width: auto !important;*/
                position: initial !important;
                left: 0 !important;
                right: 0 !important;
                display: block !important;
            }
            /*.pac-container:empty{
                display: none !important;
            }*/
            .pac-container { z-index: 2000 !important;  }
        </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 class="active" 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 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" > -->
                            <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>Hospitals</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">
                    <!-- <form method="GET" action="<?php echo e(url('district_hospital/search_hospital')); ?>" enctype="multipart/form-data"> -->
                       <!--  <?php echo csrf_field(); ?> -->
                       <div class="search">
                        
                               <!--  <input type="text" name='search_hospital' id="search_hospital" placeholder="Search A Hospital" class="form-control" >
                           <button class="btn-primary search-hos" id="search_hospital_button"> Submit</button> -->
                        
                           
                       </div>
                       <!-- </form> -->
                       <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;">Hospital 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 style="width:10%;" scope="col">SL No</th>
                              <th style="width:20%;" scope="col">Establishment Name</th>
                              <th style="width:10%;" scope="col">PHC/CHC</th>
                              <!-- <th style="width:15%;" scope="col">Address</th> -->
                              <th style="width:20%;" scope="col">Contact Person Name</th>
                              <th style="width:15%;" scope="col">Contact Number</th>
                              <th style="width:15%;" scope="col">Date</th>
                              <th style="width:10%;" 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 scope="row"><a href="#"><?php echo e($doctor->name); ?></a> </td>
                              <td> <?php echo e($doctor->facility); ?></td>
                              <!-- <td> <?php echo e($doctor->address); ?></td> -->
                              <td><?php echo e($doctor->contact_name); ?></td>
                              <td><?php echo e($doctor->contact_phone_no); ?></td>
                              <td> <?php echo e($doctor->created_at); ?></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_hospital('<?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>Hospital Details</h6>
                           
                           </div>
                           
                       </div>
                       
                       
                       
                       <div class="table table-responsive">
                           <div class="col-lg-2 lbls" >
                              Establishment Name 
                          </div>
                          <div class="col-lg-1 lbls" >: &nbsp;
                          </div>
                          <div class="col-lg-9 lbls_span">
                              <span id="name_view"></span>
                          </div>
                          <div class="col-lg-2 lbls">
                              Establishment Type 
                          </div>
                          <div class="col-lg-1 lbls" >: &nbsp;
                          </div>
                          <div class="col-lg-9 lbls_span">
                              <span id="type_view"></span>
                          </div>
                          <div class="col-lg-2 lbls">
                              Establishment Address 
                          </div>
                          <div class="col-lg-1 lbls" >: &nbsp;
                          </div>
                          <div class="col-lg-9 lbls_span">
                              <span id="address_view"></span>
                          </div>
                          
                          <div class="col-lg-2 lbls">
                              Contact Person Name 
                          </div>
                          <div class="col-lg-1 lbls" >: &nbsp;
                          </div>
                          <div class="col-lg-9 lbls_span">
                              <span id="contact_person_view"></span>
                          </div>
                          <div class="col-lg-2 lbls">
                              Contact Number 
                          </div>
                          <div class="col-lg-1 lbls" >: &nbsp;
                          </div>
                          <div class="col-lg-9 lbls_span">
                              <span id="contact_number_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 Hospitals</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-8">
                <input type="text" class="form-control custom-fields mt-3" id="Establishment_name" placeholder="Establishment Name *">
            </div> 

            <div class="col-lg-4">
                <select class="form-control custom-fields mt-3" id="buyer_type">
                    <option value="">Buyer Type *</option>
                    
                                                                    
                                                                        
                                  <?php $__currentLoopData = $buyertypelist; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $buyerlist): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                      <option value="<?php echo e($buyerlist->buyertype); ?>">
                                          <?php echo e(ucfirst($buyerlist->buyertype)); ?>

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

                                                                        
                                                                        
                                                                    
                </select>
            </div>

            <div class="col-lg-4">
                <select class="form-control custom-fields mt-3" id="Type">
                    <option value="">Facility *</option>
                    
                                                                    
                                                                        <option value="CHC">CHC</option>
                                                                        <option value="PHC">PHC</option>
                                                                        <option value="MC">MC</option>
                                                                        <option value="DH">DH</option>
                                                                        
                                                                        
                                                                    
                </select>
            </div> 

            <div class="col-lg-4">
                <select class="form-control custom-fields mt-3" id="zone">
                    <option value="">Zone *</option>
                    
                                                                    
                                                                    <option value="C" >Central</option>
                                                                    <option value="N"  >North</option>
                                                                    <option value="E"  >East</option>
                                                                    <option value="S"  >South</option>
                                                                    <option value="W"  >West</option>
                                                                    <option value="NE"  >North East</option>
                                                                    <option value="SE"  >South East</option>
                                                                    <option value="SW"  >South West</option>
                                                                    <option value="NW"  >North West</option>
                                                                        
                                                                        
                                                                    
                </select>
            </div> 

            <div class="col-lg-4">
                <input type="text" class="form-control custom-fields mt-3" id="Address" placeholder="Address *">
            </div>
            <!-- <div class="col-lg-4">
                <select class="form-control custom-fields mt-3" id="country">
                    <option selected >Country</option>
                    
                                                                    <?php $__currentLoopData = $countries; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $country): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                        <option value="<?php echo e($country->id); ?>" ><?php echo e($country->name); ?></option>
                                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div> -->
            <div class="col-lg-4">
                <select class="form-control custom-fields mt-3" id="State">
                    <option  value="" >State *</option>
                    
                                                                    <?php $__currentLoopData = $states; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $state): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                        <option value="<?php echo e($state->id); ?>"><?php echo e($state->name); ?></option>
                                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div> 
            <div class="col-lg-4">
                <select class="form-control custom-fields mt-3" id="City">
                    <option value="">City *</option>
                    
                                                                    <?php $__currentLoopData = $districts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $district): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                        <option value="<?php echo e($district->districtid); ?>"><?php echo e($district->district_title); ?></option>
                                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div> 
           <div class="col-lg-4">
                <input type="text" class="form-control custom-fields mt-3" id="Pincode" maxlength="6" placeholder="Pincode *">
            </div>
            <div class="col-lg-4">
                <input type="text" class="form-control custom-fields mt-3" id="Contact_name" placeholder="Contact Person Name *">
            </div> 
            <div class="col-lg-4">
                <input type="text" class="form-control custom-fields mt-3" id="Contact_number" maxlength="10" placeholder="Contact Number *">
            </div> 
           <div class="col-lg-4">
                <input type="text" class="form-control custom-fields mt-3" id="email" placeholder="Email Id *">
            </div>
            <div class="col-lg-4">
                <input type="password" class="form-control custom-fields mt-3" id="Password" placeholder="Password *">
            </div>

            <div class="col-lg-8">
               <input id="searchTextField" type="text"  class="form-control custom-fields mt-3" name="searchTextField" placeholder="Location">

               <input type="hidden" id="cityLat" name="">
               <input type="hidden" id="cityLng" name="">

            </div> 
            
            

       </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-primary save-button" id="save_hospital">Save Now</button>
      </div>
    </div>
  </div>
</div> 
        
        
        
        
        
        
        
        
       <!-- 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>

      <!-- 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>  
      
        
      

     
    </body>
</html>
<script>
        $(document).ready(function () 
        {
            $('#example').DataTable();
        });

        function initialize() {
  // var input = document.getElementById('searchTextField');
  // new google.maps.places.Autocomplete(input);

  var input = document.getElementById('searchTextField');
          var autocomplete = new google.maps.places.Autocomplete(input);
        //  swal(autocomplete);
            google.maps.event.addListener(autocomplete, 'place_changed', function () {
                var place = autocomplete.getPlace();
                // swal('sec');
                // swal(place.name);
                // swal(place.geometry.location.lat());
                // swal(place.geometry.location.lng());
                $("#cityLat").val(place.geometry.location.lat());
                $("#cityLng").val(place.geometry.location.lng());
               // document.getElementById('city2').value = place.name;
               // document.getElementById('cityLat').value = place.geometry.location.lat();
                //document.getElementById('cityLng').value = place.geometry.location.lng();
            });


}

google.maps.event.addDomListener(window, 'load', initialize);

        </script>
<script type="text/javascript">
    $("#save_hospital").click(function()
    {
        var baseurl='https://www.meddbot.com/api/district_hospital/';
        
        var Establishment_name=$("#Establishment_name").val();
        var Address=$("#Address").val();
        var State=$("#State").val();
        var City=$("#City").val();
        var Pincode=$("#Pincode").val();
        var Contact_name=$("#Contact_name").val();
        var Contact_number=$("#Contact_number").val();
        var email=$("#email").val();
        var buyer_type=$("#buyer_type").val();
        var facility=$("#Type").val();
        var zone=$("#zone").val();
        var Password=$("#Password").val();

        var indexWith=email.indexOf("@");
        var indexWithDot=email.lastIndexOf(".");

        var phoneno = /^\d{10}$/;
        var pincode_digit = /^\d{6}$/;

         var locattion=$("#searchTextField").val();
        var cityLat=$("#cityLat").val();
        var cityLng=$("#cityLng").val();

        if(Establishment_name=='')
        {
            swal('Please Enter Establishment Name');
            return false;
        }
        if(buyer_type=='')
        {
            swal('Please Enter Clinic Type');
            return false;
        }
        if(facility=='')
        {
            swal('Please Enter Facility Type');
            return false;
        }
        if(zone=='')
        {
            swal('Please Enter Zone');
            return false;
        }
        if(Address=='')
        {
            swal('Please Enter Address');
            return false;
        }
        if(State=='')
        {
            swal('Please Enter State');
            return false;
        }
        if(City=='')
        {
            swal('Please Enter City');
            return false;
        }
        if(Pincode=='')
        {
            swal('Please Enter Pincode');
            return false;
        }
        if(!Pincode.match(pincode_digit))
        {
                swal("invalid Pincode");
                return false;
        }
        if(Contact_name=='')
        {
            swal('Please Enter Contact Name');
            return false;
        }
        if(Contact_number=='')
        {
            swal('Please Enter Contact Number');
            return false;
        }
        if(!Contact_number.match(phoneno))
        {
                swal("invalid Contact Number");
                return false;
        }
        if(email=='')
        {
            swal('Please Enter Email');
            return false;
        }
        if(indexWith<1 || indexWithDot<indexWith+2 || indexWithDot+2>=email.length)
        {
            swal("Please make sure email address contains @ and .com");
            return false;
        }
        if (Password.length < 6) 
        {
            swal("Your password needs a minimum of six characters");
            return false;
        }
        if (Password.search(/[a-z]/) == -1)
        {
            swal("Your password needs a lower case letter");
            return false;
        }
        if (Password.search(/[A-Z]/) == -1) 
        {
            swal("Your password needs an uppser case letter");
            return false;
        }
        if(Password.search (/[0-9]/) == -1) 
        {
            swal("Your password needs a number");
            return false;
        }
        else
        {
          var data = {

                     Establishment_name      :Establishment_name,
                     Address   :Address,
                     State : State,
                     City : City,
                     Pincode : Pincode,
                     Contact_name : Contact_name,
                     Contact_number : Contact_number,
                     email : email,
                     facility : facility,
                     buyer_type : buyer_type,
                     zone : zone,
                     Password : Password,
                     locattion:locattion,
                     latitude:cityLat,
                     longitude:cityLng
                  }

             $.ajax({url:baseurl+'add_hospitals',
                            type:"POST",
                            data:data,
                            success: function (res) {
                                if(res!='')
                                {
                                    //swal('Hospital Added Successfully!!');
                                    swal({
                                 title: "Success!",
                                 text: "Hospital Added Successfully!!",
                                 type: "success",
                                 timer: 4000,
                                 // showConfirmButton: false
                                 });
                                 
                                }
                                
                                console.log(res);
                               
                                // swal({
                                //  title: "Success!",
                                //  text: "Hospital Added Successfully!!",
                                //  type: "success",
                                //  timer: 3000
                                //  });
                                //  function () {
                                //     location.reload(true);
                                    
                                //  };
                                // setTimeout(location.reload(), 3000);
                                console.log(res);
                                window.setTimeout(function(){ 
                                    location.reload();
                                } ,3000);
                                
                            }
                        });  
        }
        

        
    });


    const validateEmail = (email) => 
    {
      return email.match(
        /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
      );
    };

    // $("#country").change(function()
    // {
    //         var country_id=$("#country").val();
    //         swal(country_id);

    //         var baseurl='https://www.meddbot.com/api/district_hospital/';
        
       
    //         var data = 
    //             {
    //                  country_id : country_id
    //             }

    //             $.ajax({url:baseurl+'find_state',
    //                         type:"POST",
    //                         data:data,
    //                         success: function (res) 
    //                         {
    //                             if(res!='')
    //                             {
    //                                $.each( res, function( key, value ) 
    //                                {
    //                                   swal( key + ": " + value );
    //                                }); 
    //                             }
                                
    //                             console.log(res);
                                
                                
    //                         }
    //                 });
    // });

    $("#State").change(function()
    {
            var state_id=$("#State").val();
            //swal(state_id);

            var baseurl='https://www.meddbot.com/api/district_hospital/';
        
       
            var data = 
                {
                     state_id : state_id
                }

                $.ajax({url:baseurl+'find_district',
                            type:"POST",
                            data:data,
                            success: function (res) 
                            {
                                if(res!='')
                                {
                                   $.each( res, function( key, value ) 
                                   {
                                      swal( key + ": " + value );
                                   }); 
                                }
                                
                                console.log(res);
                                
                                
                            }
                    });
    });
    function delete_hospital(id)
    {
       // swal(id);
        var baseurl='https://www.meddbot.com/api/district_hospital/';
        let text = "Are you sure to delete Hospital!";
          if (confirm(text) == true) 
          {
            var data = {

                     id      :id
                  }

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

                     search_hospital      :search_hospital
                  }

             $.ajax({url:baseurl+'search_hospital',
                            type:"POST",
                            data:data,
                            success: function (res) {
                                res1=JSON.parse(res);
                                console.log(res);
                                console.log(res1);
                                if(res1['search_hospital']['0']=='')
                                {
                                    console.log('no');
                                }
                                //if(res!='')
                                if(res1['search_hospital']['0']!='')
                                {
                                    res1=JSON.parse(res);
                                    var address = res1['search_hospital']['0'].address;
                                    $("#address_view").html(address);
                                    var contact_number= res1['search_hospital']['0'].contact_number;
                                    $("#contact_number_view").html(contact_number);
                                    var contact_person= res1['search_hospital']['0'].contact_person;
                                    $("#contact_person_view").html(contact_person);
                                    var email= res1['search_hospital']['0'].email;
                                    $("#email_view").html(email);
                                    var name= res1['search_hospital']['0'].name;
                                    $("#name_view").html(name);
                                    var pincode= res1['search_hospital']['0'].pincode;
                                    $("#pincode_view").html(pincode);
                                    var type= res1['search_hospital']['0'].type;
                                    $("#type_view").html(type);
                                    $("#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/district_hospial_dashboard.blade.php ENDPATH**/ ?>