<div class="container-fluid py-5" style="background:rgb(244,244,244)">
    
     <h3 class="text-center py-2">Setting</h3>
    
         <?php 
	$success=$this->session->flashdata('message_name');
	$error=$this->session->flashdata('error');
	
	if(!empty($success)) { ?>

	<div class="alert alert-success col-md-6 mx-auto py-1 rounded-0 mb-3">
	<strong>Success!</strong> <?php echo $this->session->flashdata('message_name'); ?>
	</div>

	<?php } ?>
	<?php if(!empty($error)) { ?>

	<div class="alert alert-danger col-md-6 mx-auto py-1 rounded-0 mb-3">
	<strong>Error!</strong> <?php echo $this->session->flashdata('error'); ?>
	</div>

	<?php } ?>
	
	
	
	<div class="d-flex justify-content-end gap-3">
	   <!-- Button trigger modal -->
<!--<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#chargeModal">-->
<!--  Add Charges-->
<!--</button>-->

<div>
   
    <?php
      
      $sql = $this->Login_model->Select('tbl_cod_sts', '*', array());
  $st = '3' ;
   if(!empty($sql)){
       $st = $sql[0]->status;
  if($st == '0'){
      $clr = 'success';
      $contnet = 'COD ON' ;
  }else{
      $clr = 'danger';
      $contnet = 'COD OFF' ;
  }
   }else{
       
        $clr = 'danger';
      $contnet = 'ADD COD STATUS' ;
   }
      ?>
    
  
    <a role="button" href="<?=base_url()?>Admin/cod_status/<?=$st?>" class="btn btn-<?=$clr;?>" >
  <?=$contnet;?>
</a>
    
</div>

	</div>
    
    <?php
      
      $sql = $this->Login_model->Select('tbl_conv_charge', '*', array());
        $amt = $sql[0]->amt;
         $id = $sql[0]->id;
         
         if($sql[0]->status == 0){
             $st= '<span class="text-success" style="font-size:18px">Active</span>';
         }else{
             $st= '<span class="text-warning" style="font-size:18px" >InActive</span>';
         }
      ?>
      
      


   <div class="d-flex justify-content-center align-items-center" style="min-height: 8vh;">
    <div class="col-md-4">
        <form action="<?= base_url() ?>Admin/update_conven_charge" method="post" enctype="multipart/form-data">
            <div class="form-group">
                <label for="input_charge" class="control-label">Enter Conv. Charge</label>
                <div class="d-flex align-items-center">
                    <!-- Input field for charge -->
                    <input class="form-control me-2" id="input_charge" name="charge" 
                           value="<?= $amt; ?>" type="number" required>
                    <span class="ms-2"><?= $st; ?></span>
                </div>
                <span id="error-message" style="color: red; display: none;">Charge cannot be greater than 100</span>
                <input id="id" name="ch_id" value="<?= $id; ?>" type="hidden" required>
            </div>
            <div class="modal-footer">
                <button type="submit" class="btn btn-primary" style="margin-right: 50%;">Submit</button>
            </div>
        </form>
    </div>
</div>
</div>


<script>
$(document).ready(function () {
  
    function validateNightFare() {
        let value = parseFloat($('#input_charge').val());
        if (isNaN(value) || value < 0 || value > 100) {
            $('#error-message').show(); 
            $('#input_charge').val(''); 
            $('#input_charge').addClass('is-invalid');
        } else {
            $('#error-message').hide(); 
            $('#input_charge').removeClass('is-invalid'); 
        }
    }

   
    $('#input_charge').on('input', function () {
        validateNightFare();
    });
});

</script>


