<?php
defined('BASEPATH') OR exit('No direct script access allowed');
if($rsrcid>0) { $totalamt =  $info4edit->fld_amount; } else {
$totalamt = $this->main_model->getdayoffsale($this->outletid,$this->userid);
}
?>

      <div class="main my-0">
        <div class="row mt-3 mx-0">
          <div class="col-md-6">
            <h3>Day Close Receipt</h3>
          </div>
          <div class="col-md-5 text-right">
            &nbsp;
          </div>
        </div>
        
        <div class="container_fluid mt-2 px-3">
		<form name="frmgeneral" method="post" action="account/<?php echo $mgmtname;?>/managedata?<?php echo $_SERVER['QUERY_STRING'];?>" enctype="multipart/form-data" onsubmit="return validateFrm();">
		<input type="hidden" name="rsrcid" value="<?php echo $rsrcid;?>">                
        <table class="webforms mt-0 table-responsive-sm">
      
         <tr>
          <td width="20%"><label>Biller Name:</label></td>
          <td width="80%"><?php echo $this->session->userdata('operatorLoggedIn')['sessName'];?></td>
         </tr> 
           <tr>
          <td width="20%"><label>Total Amount:</label></td>
          <td width="80%"><input type="text" name="totalamt" id="totalamt" value="<?php  echo $totalamt;?>" required readonly></td>
         </tr> 
         <tr>
          <td width="100%" colspan="2"><h5>Payment Info:</h5><span id="errormsg"></span></td>

         </tr> 
         <tr>
          <td width="20%"><label>Cash:</label></td>
          <td width="80%"><input type="text" name="cash" id="cash" value="<?php if($info4edit) { echo $info4edit->fld_cash; }?>" required></td>
         </tr> 
		 
         <tr>
          <td width="20%"><label>Credit Card Slips:</label></td>
          <td width="80%"><input type="text" name="cc" id="cc" value="<?php if($info4edit) { echo $info4edit->fld_cc; }?>" required></td>
         </tr> 

         <tr>
          <td width="20%"><label>UPI:</label></td>
          <td width="80%"><input type="text" name="upi" id="upi" value="<?php if($info4edit) { echo $info4edit->fld_upi; }?>" required></td>
         </tr> 

        		

		 <tr>
             <td></td>
             <td><button class="btn btn-danger">Submit</button></td>
         </tr>
         </table>
         </form> 
	         <div class="clearfix"></div>          
        </div>
       </div>
<script>
function validateFrm()
{
		erroralert = 1;
		var totalamt = $("#totalamt").val();
		totalamt = parseInt(totalamt);
		var cash = $("#cash").val();
		cash = parseInt(cash);
		var cc = $("#cc").val();
		cc = parseInt(cc);
		var upi = $("#upi").val();
		upi = parseInt(upi);
		
		totclc = (cash+cc+upi);
		totclc = parseInt(totclc);
		if(totclc!=totalamt)
		{
			alert("Please enter payment info less then or equal to total amount");
				$("#errormsg").html('Please enter payment info less then or equal to total amount');
				$('#errormsg').css('color', 'red');
				$('#errormsg').css('border-color', 'red');
				setTimeout(function(){
				$("#errormsg").html("");
				$('#errormsg').css('color', '');
				$('#errormsg').css('border-color', '');
				},4000);
			return false;
		}
		if(totalamt==0)
		{
				alert("You have no payment to submit");
				$("#errormsg").html('You have no payment to submit');
				$('#errormsg').css('color', 'red');
				$('#errormsg').css('border-color', 'red');
				setTimeout(function(){
				$("#errormsg").html("");
				$('#errormsg').css('color', '');
				$('#errormsg').css('border-color', '');
				},4000);
			return false;
		}

}
</script>