<div class="content-wrapper">
   <div class="content-header">
      <div class="container-fluid">
         <div class="row mb-2">
            <div class="col-sm-6">
               <h1 class="m-0 text-dark">Edit Booking</h1>
            </div>
            <div class="col-sm-6">
               <ol class="breadcrumb float-sm-right">
                  <li class="breadcrumb-item"><a href="<?php echo base_url() ?>admin/admin/dashboard">Dashboard</a></li>
                  <li class="breadcrumb-item"><a href="#">Venue</a></li>
                  <li class="breadcrumb-item active">Edit Booking </li>
               </ol>
            </div>
         </div>
      </div>
   </div>
   <section class="content">
      <div class="container-fluid">
         <div class="card card-default">
            <div class="card-header">
               <h3 class="card-title">Edit Venue</h3>
               <div class="card-tools">
                  <a href="<?php echo base_url()?>/admin/venue/view_all_booking" class="btn btn-success btn-sm"><i class="fa fa-eye" aria-hidden="true"></i> View All Booking</a>
               </div>
            </div>
            <?php echo form_open_multipart('admin/venue/update_booking/'.$vanue->venue_id); ?>
            <div class="card-body">
               <div class="row">
                  <div class="col-md-4">
                     <div class="form-group">
                        <label for="inputEmail" class="col-sm-12 col-form-label">Booking For (किस के लिये बुकिंग)<span class="required">*</span></label>
                        <div class="col-sm-12">
                           <select type="text" class="form-control" onchange="booking_for(this.value)" name="venue_wedding_is_bride_or_groom"  required="required" >
                              <option value="">Select</option>
                              <option <?php if($vanue->venue_wedding_is_bride_or_groom =='Bride'){echo 'selected';}?> value="Bride">Bride</option>
                              <option <?php if($vanue->venue_wedding_is_bride_or_groom =='Groom'){echo 'selected';}?> value="Groom">Groom</option>
                              <option <?php if($vanue->venue_wedding_is_bride_or_groom =='Other Ocassions'){echo 'selected';}?> value="Other Ocassions">Other Ocassions</option>
                           </select>
                        </div>
                     </div>
                  </div>
                  <div class="col-md-8">
                     <div class="form-group">
                        <label for="inputEmail" class="col-sm-12 col-form-label" id="booking_for"> Name(नाम)<span class="required">*</span></label>
                        <div class="col-sm-12">
                           <input type="text" class="form-control"  name="venue_wedding_name"  required="required" placeholder="Enter Name" value="<?php echo $vanue->venue_wedding_name; ?>">
                        </div>
                     </div>
                  </div>
                  <div class="col-md-3 wedding">
                     <div class="form-group">
                        <label for="inputEmail" class="col-sm-12 col-form-label" > Age (उम्र)<span class="required">*</span></label>
                        <div class="col-sm-12">
                           <input type="number" class="form-control wedding_req" name="venue_wedding_age"  required="required" placeholder="Enter Age" value="<?php echo $vanue->venue_wedding_age; ?>">
                        </div>
                     </div>
                  </div>
                  <div class="col-md-3">
                     <div class="form-group">
                        <label for="inputEmail" class="col-sm-12 col-form-label" id="wed_date_title"> Wedding Date (शादी की तारीख)<span class="required">*</span></label>
                        <div class="col-sm-12">
                           <input type="date" class="form-control"  name="venue_wedding_date"  required="required" placeholder="Enter Age" value="<?php echo $vanue->venue_wedding_date; ?>">
                        </div>
                     </div>
                  </div>
                  <div class="col-md-6 wedding">
                     <div class="form-group">
                        <label for="inputEmail" class="col-sm-12 col-form-label"> Guardian Name (अभिभावक का नाम)<span class="required">*</span></label>
                        <div class="col-sm-12">
                           <input type="text" class="form-control wedding_req"  name="venue_wedding_guardian_name"  required="required" placeholder="Enter Guardian Name" value="<?php echo $vanue->venue_wedding_guardian_name; ?>">
                        </div>
                     </div>
                  </div>
                  <div class="col-md-4 wedding">
                     <div class="form-group">
                        <label for="inputEmail" class="col-sm-12 col-form-label"> Guardian Annual Income (संरक्षक वार्षिक आय)<span class="required">*</span></label>
                        <div class="col-sm-12">
                           <input type="number" class="form-control wedding_req"  name="venue_wedding_annual_income"  required="required" placeholder="Enter Guardian Annual Income" value="<?php echo $vanue->venue_wedding_annual_income; ?>">
                        </div>
                     </div>
                  </div>
                  <div class="col-md-5">
                     <div class="form-group">
                        <label for="inputEmail" class="col-sm-12 col-form-label"> Venue Booked By (द्वारा स्थान बुक किया गया)<span class="required">*</span></label>
                        <div class="col-sm-12">
                           <input type="text" class="form-control"  name="venue_wedding_who_booking_name"  required="required" placeholder="Enter Booked By Name" value="<?php echo $vanue->venue_wedding_who_booking_name; ?>">
                        </div>
                     </div>
                  </div>
                  <div class="col-sm-3">
                     <div class="form-group row">
                        <label for="inputName" class="col-sm-12 col-form-label"> Pin Code (पिन कोड)<span style="color:red">*</span></label>
                        <div class="col-sm-12">
                           <input type="number" name="venue_wedding_pin_code" id="pin_code" class="form-control" placeholder="Enter Pin Code" required value="<?php echo $vanue->venue_wedding_pin_code; ?>">
                        </div>
                     </div>
                  </div>
                  <div class="col-sm-12">
                     <div class="form-group row">
                        <label for="inputName" class="col-sm-12 col-form-label"> Address (पता)<span style="color:red">*</span></label>
                        <div class="col-sm-12">
                           <textarea type="text" name="venue_wedding_address" required class="form-control" placeholder="Enter Address" ><?php echo $vanue->venue_wedding_address; ?></textarea>
                        </div>
                     </div>
                  </div>
                  <div class="col-sm-4">
                     <div class="form-group row">
                        <label for="inputName" class="col-sm-12 col-form-label"> Post Office (डाक-घर)<span style="color:red">*</span></label>
                        <div class="col-sm-12">
                           <select name="venue_wedding_post_office" id="area" class="form-control" required>
                              <option value="">Enter Pin Code First</option>
                           </select>
                        </div>
                     </div>
                  </div>
                  <div class="col-sm-4">
                     <div class="form-group row">
                        <label for="inputName" class="col-sm-12 col-form-label"> Dist (जिला)<span style="color:red">*</span></label>
                        <div class="col-sm-12">
                           <input type="text" name="venue_wedding_dist" id="city" class="form-control" placeholder="Member Dist"  readonly="" required>
                        </div>
                     </div>
                  </div>
                  <div class="col-sm-4">
                     <div class="form-group row">
                        <label for="inputName" class="col-sm-12 col-form-label"> State (राज्य)<span style="color:red">*</span></label>
                        <div class="col-sm-12">
                           <input type="text" name="venue_wedding_state" id="state" class="form-control" placeholder="Member State" readonly="" required>
                        </div>
                     </div>
                  </div>
                  <div class="col-sm-3">
                     <div class="form-group row">
                        <label for="inputName" class="col-sm-12 col-form-label"> Booking Price (बुकिंग मूल्य)<span style="color:red">*</span></label>
                        <div class="col-sm-12">
                           <input type="radio" name="venue_wedding_price_status" onchange="handlePaymentSelection(this.value)" id="free" value="0"  <?php if($vanue->venue_wedding_price_status == 0){echo 'checked';}; ?>>
                           <label for="free">Free (मुक्त)</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                           <input type="radio" name="venue_wedding_price_status" onchange="handlePaymentSelection(this.value)" id="paid" value="1" <?php if($vanue->venue_wedding_price_status == 1){echo 'checked';}; ?>>
                           <label for="paid">Paid (प्रदत्त)</label>
                        </div>
                     </div>
                  </div>
                  <div class="col-sm-4" id="paid_amt">
                     <div class="form-group row">
                        <label for="inputName" class="col-sm-12 col-form-label"> Paid Amount (चुकाई गई राशि)<span style="color:red">*</span></label>
                        <div class="col-sm-12">
                           <input type="number" name="venue_wedding_price" id="wedding_price" class="form-control" placeholder="Enter Paid Amount" value="<?php echo $vanue->venue_wedding_price; ?>">
                        </div>
                     </div>
                  </div>
               </div>
               <div class="row">
                  <div class="col-sm-4 wedding">
                     <div class="form-group row">
                        <label for="inputName" class="col-sm-12 col-form-label"> Image (छवि)</label>
                        <div class="col-sm-12">
                           <input type="file" class="form-control" placeholder="Member State" name="venue_wedding_image">
                        </div>
                     </div>
                  </div>
                  <div class="col-sm-4 wedding">
                     <div class="form-group row">
                        <label for="inputName" class="col-sm-12 col-form-label"> wedding Card Image (शादी के कार्ड की छवि)</label>
                        <div class="col-sm-12">
                           <input type="file"  class="form-control" placeholder="Member State" name="venue_wedding_card_image">
                        </div>
                     </div>
                  </div>
                  <div class="col-sm-4">
                     <div class="form-group row">
                        <label for="inputName" class="col-sm-12 col-form-label"> Application Form </label>
                        <div class="col-sm-12">
                           <input type="file"  class="form-control" placeholder="Member State" name="venue_wedding_application_form">
                        </div>
                     </div>
                  </div>
                  <div class="col-sm-4 wedding">
                     <div class="form-group row">
                        <img src="<?php echo base_url(); ?><?php echo $vanue->venue_wedding_image; ?>" width="100px">
                     </div>
                  </div>
                  <div class="col-sm-4 wedding">
                     <div class="form-group row">
                        <img src="<?php echo base_url(); ?><?php echo $vanue->venue_wedding_card_image; ?>" width="100px">
                     </div>
                  </div>
                  <div class="col-sm-4">
                     <div class="form-group row">
                        <img src="<?php echo base_url(); ?><?php echo $vanue->venue_wedding_application_form; ?>" width="100px">
                     </div>
                  </div>
                  <div class="col-md-12">
                     <div class="form-group">
                        <button name="submit" style="float: right" type="submit" class="btn btn-success">Update</button>
                     </div>
                  </div>
                  <?php echo form_close() ?>
               </div>
            </div>
         </div>
      </div>
   </section>
</div>
<script type="text/javascript">
function handlePaymentSelection(e) 
{
   if(e == 1)
   {  
      $('#paid_amt').show();
      $('#wedding_price').attr('required', true)
   }
   else
   {
      $('#paid_amt').hide();
      $('#wedding_price').attr('required', false)
   }
}
$( document ).ready(function() {
      booking_for('<?php echo $vanue->venue_wedding_is_bride_or_groom; ?>');
 });
function booking_for(e) 
{
   if(e == 'Other Ocassions')
   {
      $('#booking_for').html('Event Type (कार्यक्रम की प्रकार)<span class="required">*</span>');
      $('.wedding').hide();
      $('.wedding_req').attr('required', false);
      $('#wed_date_title').html('Event Date (कार्यक्रम की तिथि) <span class="required">*</span>');
   }
   else
   {
      $('#booking_for').html(e+' Name <span class="required">*</span>');
      $('.wedding').show();
      $('.wedding_req').attr('required', true);
      $('#wed_date_title').html('Wedding Date (शादी की तारीख) <span class="required">*</span>');
   }
   
}
$('body').on('change', '#pin_code', function () {
    let pin_code = $('#pin_code').val();
    if (pin_code == 0) {
            swal ( "Oops" ,  "Please Enter Pin Code!" ,  "warning" );
        return false;
    }
    $.ajax({
      beforeSend: function() {
         $(".loader").show();
      },
      type: "GET",
      dataType:"JSON",
      async: true,
      url: '<?php echo base_url(); ?>/admin/admin/get_aadress_detaile_by_pin_code/'+pin_code,
      success: function (data) 
      {
          $('#area').html(data.area);
          $('#city').val(data.city);
          $('#state').val(data.state);
          $(".loader").hide();
      },
      error: function () {
        $(".loader").hide();
      }
    });
});
<?php if($vanue->venue_wedding_pin_code): ?>
    $( document ).ready(function() {
         handlePaymentSelection(<?php echo $vanue->venue_wedding_price_status; ?>);
         get_address("<?php echo $vanue->venue_wedding_pin_code; ?>", "<?php echo $vanue->venue_wedding_post_office; ?>")
    });

    function get_address(id, post) {
       $.ajax({
          beforeSend: function() {
             $(".loader").show();
          },
          type: "GET",
          dataType:"JSON",
          async: true,
          url: '<?php echo base_url(); ?>/admin/admin/get_aadress_detaile_by_pin_code_for_update/'+id+'/'+post,
          success: function (data) 
          {
              $('#area').html(data.area);
              $('#city').val(data.city);
              $('#state').val(data.state);
              $(".loader").hide();
          },
          error: function (e) {
             console.log(e.responseText)
            $(".loader").hide();
          }
        });
    }
 <?php endif;?>
</script>
<style type="text/css">
   .required
   {
      color: red;
   }
   #paid_amt
   {
      display: none;
   }
</style>