<?php 
include_once("header-footer/header.php")
?>

<link rel="stylesheet" href="//code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>
 <script>
  $( function() {
    $( "#datepicker" ).datepicker();
    $( "#datepicker1" ).datepicker();
  } );
  </script>
<script>
        $(document).ready(function()
        {   
            
               $("#submit").hide();
               $("#Calc").show();  
              if( ($(window).width()) > 599) 
             window.location.href  = URL+'/error/default.php';
          
        	$("#_frm").validate({
        		
        		errorElement:'div',
        		rules:{ 
        		    
        		    
        		    Title:{
        				required:true,
        				maxlength:300,
        				minlength:3 
        			}, 
        			AggNo:{
        				required:true 
        			},
        			workOrder:{
        				required:true 
        			}, 
        			workcomm:{
        				required:true 
        			},
        			cost:{
        				required:true,
        				maxlength:10,
        			} 
        			
        		},
        		messages:{
                   
        			Title:{
        				required:"Enter project title",
        				maxlength:"Maximum  300 charaters allow",
        				minlength:"Minimum 3 charaters required"  
        			},
        			AggNo:{
        				required:"Enter agreement no "
        			},
        			workOrder:{
        				required:"Select date of work order "
        			},
        			workcomm:{
        				required:"Select date : order of commencement  "
        			},
        			cost:{
        				required:"Enter project cost",
    					maxlength:"Maximum  19 digits allow",
        			}      
        			 
        		}
        	}); 
        }); 
        
                    function GetGst()
                    {
                     
                        var X1 = parseInt(($("#Title").val()  *  $("#Gst").val()/100));
                        var X2 =  parseInt(($("#Title").val()  *  $("#Sgst").val()/100));
                        
                         var invoiceGst = parseInt($("#invoiceGst").val());
                         var setOffPayable = parseInt($("#setOffPayable").val());  
                        $("#FinalVal").val( (X1+X2) - (setOffPayable+invoiceGst) );
                        
                        $("#submit").show();
                        $("#Calc").hide();  
                        
                    }
        </script>
        
        <style>
          .FormRegister
          {
              border: 1px solid #c2c2c2;
              margin: 1px;
              border-radius: 3px;
          }
        </style>
        
    	<link href="<?php echo ROOTPATH;?>/view/css/screen-600.css" rel="stylesheet" type="text/css">
               <?php 
	    include_once(ABS_PATH."/menu.php");
	?> 
               
                <div class="container mt-35">
                    <div class="row justify-content-center FormRegister">
                            <div class="col-12 p-3 text-center"> 
                                    <h3 class="card-title"> Gst Calculator</h3>
                                    <?php 
                                        if(isset($_SESSION['Saved'])) {
                                    ?>
                                    <h5 class="card-title"> Your Records Has Been Saved</h5>
                                    <?php } ?>
                            </div>    
                                  <form method="post" autocomplete="off" id="_frm" >   
                                            <div class="row"> 
                                                    
                                                    <div class="col-md-12 mb-1"> 
                                                        <input  class="form-control" id="Title" name="Title" value="<?php echo $FechVal->billRec;?>" placeholder="Total Bill Received">
                                                    </div>
                                                    
                                                    <div class="col-md-12 text-center"> 
        										    	<input  name="Gst" id="Gst"  class="form-control mb-1"  value="<?php echo $FechVal->gst;?>" placeholder="GST in %"/>
        										    </div>
        										    
                                                    <div class="col-md-12 text-center"> 
        										    	<input  name="Sgst" id="Sgst"  class="form-control mb-1"  value="<?php echo $FechVal->sgst;?>" placeholder="SGST in %"/>
        										    </div>
        										    
        										    
        										     <div class="col-md-12 text-center"> 
        										    	<input  name="invoiceGst" id="invoiceGst"  class="form-control mb-1"  value="<?php echo $FechVal->invoce;?>" placeholder="Invoice GST"/>
        										    </div>
        										    
        										    <div class="col-md-12 text-center"> 
        										    	<input  name="setOffPayable" id="setOffPayable"  class="form-control mb-1" value="<?php echo $FechVal->setOff;?>" placeholder="SetOff Payable"/>
        										    </div>
        										    
        										     <div class="col-md-12 text-center">  
        										    	<input  name="datepicker" id="datepicker"  readonly class="form-control mb-1"   value="<?php echo $FechVal->datePicker;?>" placeholder="Select Date"/>
        										    </div>
        										    
        										    
        										     <div class="col-md-12 text-center"> 
        										    	<input   id="FinalVal" name="FinalVal" class="form-control mb-1" value="<?php echo $FechVal->FinalVal;?>" readonly placeholder="TOTAL"/>
        										    </div>
        										    
        										    <?php 
        										         if(!isset($_REQUEST['id']))  
                                                         {
        										    ?> 
                                                    <div class="col-md-12 text-center">
        										    	<input  type="button"   id="Calc" onclick="GetGst();" class="btn btn-primary mb-2" name="submitLogin" value="Calculcate" > 
        										    		<input  type="submit"   id="submit" class="btn btn-primary mb-2" name="submitLogin" value="Save Accounting" > 
        										    </div> 
        										    <?php }else { ?> 
        										    
                                                    <div class="col-md-12 text-center">
        										    	<a   href="gstCalc.php" class="btn btn-primary mb-2">Go To New Record</a>
        										    		 
        										    </div> 
        										    
        										    <?php } ?> 
                                            </div>  
                                    </form>  
                    </div>
                </div>
                
                
                <div class="container">
                    <div class="row">
                        <?php 
                             $sr=1;
                            foreach($FinalResult as $dt)
                            {
                        ?>
                            <p style="font-weight:bold;background:#0d6efd;margin:10px 15px 2px 15px;width:92%;padding:3px;font-size:15px;border-radius:5px"><a href="gstCalc.php?id=<?php echo $dt->id;?>" style="color:#fff"><?php echo $dt->datePicker.' (Total:'.$dt->FinalVal.')';?></a></p>  
                        <?php } ?>                            
                </div>
 
              
       
<?php 
unset($_SESSION['Saved']);
include_once("header-footer/footer.php")
?> 