<?php
ob_start();
error_reporting(0);
include("connect.php");
session_start(); 
$ver = $_SESSION["admin_id"];
$admin_id = $_SESSION["admin_id"];
$dis_id = $_SESSION["manager_id"];
$user_type = $_SESSION["user_type"];
$user_session = $_SESSION["user_session"];
 
$id1 = base64_decode($_GET['id']);
if(!isset($_SESSION["admin_id"])){
   header('location:http://www.btcover.appexperts.net');
}
date_default_timezone_set('Asia/Calcutta');
	$cdate  = date("Y-m-d");
	if(isset($_POST['sub']))
	{
			$type = $_POST['type'];
	$customer_name = $_POST['customer_name'];
	$com = $_POST['com'];
	$manager_id = $_POST['manager_id'];
	$unique_id = $_POST['unique_id'];
	$previous_policy = $_POST['previous_policy'];
	$phone_no = $_POST['phone_no'];
	$address = $_POST['address'];
	$email = $_POST['email'];
	$manager_id = $_POST['manager_id'];
	$customer_id=$_POST['customer_id'];
	$admin_id=$_POST['admin_id'];
	$agent_id=$_POST['agent_id'];
	$policy_no=$_POST['policy_no'];
	$company_id=$_POST['company_id'];
	$policy_date1=$_POST['policy_date'];
	
	$policy_type=$_POST['policy_type'];
	$vehicle_id=$_POST['vehicle_id'];
	$make_model=$_POST['make_model'];
	$idv=$_POST['idv'];
	$reg_no=$_POST['reg_no'];
	$engine_no=$_POST['engine_no'];
	$chassis_no=$_POST['chassis_no'];
	$mfg_year=$_POST['mfg_year'];
	$seating_cap=$_POST['seating_cap'];
	$body_type=$_POST['body_type'];
	$fuel_type=$_POST['fuel_type'];
	$hp=$_POST['hp'];
	$policy_term=$_POST['policy_term'];
	$term_value=$_POST['term_value'];
	$policy_date=date("Y-m-d", strtotime($policy_date1) );
	if($term_value=='year')
	$renewal_date=date('Y-m-d', strtotime($policy_date .'+'.$policy_term.'years'));
else
	$renewal_date=date('Y-m-d', strtotime($policy_date .'+'.$policy_term.'months'));
	//$renewal_date=$_POST['renewal_date'];
	$NCB=$_POST['NCB'];
	$NCB_value = isset($_POST['NCB_value']) ? $_POST['NCB_value'] : '0';
	$od=$_POST['od'];
	$discount=$_POST['discount'];
	$cover=$_POST['cover'];
	$pa=$_POST['pa'];
	$liabilities=$_POST['liabilities'];
	$passenger_assist=$_POST['passenger_assist'];
	$depreciation=$_POST['depreciation'];
	$dis=$_POST['od']*$discount/100.0;
	$totalA=$_POST['od']-$_POST['od']*$discount/100.0;
	$totalB=$_POST['cover']+$_POST['pa']+$_POST['liabilities'];
	$totalC=$_POST['passenger_assist']+$_POST['depreciation'];
	
	$total=$totalA+$totalB;
	//$cgst=$totalall*18/200.0;
	$cgstod=$totalA*18/200.0;
	$cgstli=$totalB*18/200.0;
	$cgstco=$totalC*18/200.0;
	$totalall=round($totalA+$totalB+$totalC);
	$totalGst=$cgstod+$cgstli+$cgstco+$cgstod+$cgstli+$cgstco;
	$net_amount=round($totalall+$cgstod+$cgstli+$cgstco+$cgstod+$cgstli+$cgstco);
	$net_pre_amount=round($totalall);
	

	}	
	
	
?>
<!DOCTYPE html>
<html dir="ltr" lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- Favicon icon -->
    <link rel="icon" type="image/png" sizes="16x16" href="assets/images/favicon.png">
    <title>BTCOVER : Admin Dashboard</title>
    <!-- Custom CSS -->
    <link rel="stylesheet" type="text/css" href="assets/libs/select2/dist/css/select2.min.css">
    <link rel="stylesheet" type="text/css" href="assets/libs/jquery-minicolors/jquery.minicolors.css">
    <link rel="stylesheet" type="text/css" href="assets/libs/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">
    <link rel="stylesheet" type="text/css" href="assets/libs/quill/dist/quill.snow.css">
    <link href="dist/css/style.min.css" rel="stylesheet">
	
		<script type="text/javascript">
		window.onload=function WindowLoad(event)
		{	
			 document.getElementById('igst1').style.display="none";	
			 document.getElementById('igstod1').style.display="none";	
			 document.getElementById('igstli1').style.display="none";	
			 document.getElementById('igstco1').style.display="none";	
			 
			 console.log(admin_id);
		}
		</script>
		<script>
	
		function myFunction() {
			var txt;
		
			var r = confirm("Are you sure to Cancel!");
			if (r == true) {
				window.location.href="add-policy2.php";
			} 
		}
		</script>
		<script>
		function calamountt(str)
		{
			var calculation_param=document.getElementById('calculation_param').value;
			var totalA=document.getElementById('net_premiumod').value;
			var totalB=document.getElementById('net_premiumli').value;
			var totalC=document.getElementById('net_premiumco').value;
			var gst_typeod=document.getElementById('gst_typeod').value;
			var gst_typeli=document.getElementById('gst_typeli').value;
			var gst_typeco=document.getElementById('gst_typeco').value;
			var igstod=document.getElementById('igstod').value;
			var igstli=document.getElementById('igstli').value;
			var igstco=document.getElementById('igstco').value;
			var cgstod=document.getElementById('cgstod').value;
			var cgstli=document.getElementById('cgstli').value;
			var cgstco=document.getElementById('cgstco').value;
			
			if(gst_typeod=='IGST')
			{
			document.getElementById('igstod1').style.display="block";		
			document.getElementById('cgstod1').style.display="none";		
			document.getElementById('sgstod1').style.display="none";		
			}
			else if(gst_typeod=='CGST/SGST')
			{
			document.getElementById('igstod1').style.display="none";		
			document.getElementById('cgstod1').style.display="block";		
			document.getElementById('sgstod1').style.display="block";	
			}

			
			if(gst_typeli=='IGST')
			{
			document.getElementById('igstli1').style.display="block";		
			document.getElementById('cgstli1').style.display="none";		
			document.getElementById('sgstli1').style.display="none";		
			}
			else if(gst_typeli=='CGST/SGST')
			{
			document.getElementById('igstli1').style.display="none";		
			document.getElementById('cgstli1').style.display="block";		
			document.getElementById('sgstli1').style.display="block";	
			}
			
			if(gst_typeco=='IGST')
			{
			document.getElementById('igstco1').style.display="block";		
			document.getElementById('cgstco1').style.display="none";		
			document.getElementById('sgstco1').style.display="none";		
			}
			else if(gst_typeco=='CGST/SGST')
			{
			document.getElementById('igstco1').style.display="none";		
			document.getElementById('cgstco1').style.display="block";		
			document.getElementById('sgstco1').style.display="block";	
			}
			var gst_percentageod=document.getElementById('gst_percentageod').value;
			var totalod='<?php echo $totalA?>';
			var gst_percentageli=document.getElementById('gst_percentageli').value;
			var totalli='<?php echo $totalB?>';
			var gst_percentageco=document.getElementById('gst_percentageco').value;
			var totalco='<?php echo $totalC?>';
			document.getElementById('net_premiumod').value=parseFloat(totalod).toFixed(2);
			document.getElementById('net_premiumli').value=parseFloat(totalli).toFixed(2);
			document.getElementById('net_premiumco').value=parseFloat(totalco).toFixed(2);
			if(gst_typeod=='CGST/SGST')
			{
				var gst_perod=parseFloat(gst_percentageod)/200.0;
				
				var cgstod=parseFloat(totalod)*parseFloat(gst_perod);
				totalod=parseFloat(totalod)+parseFloat(cgstod)+parseFloat(cgstod);
				document.getElementById('cgstod').value=parseFloat(cgstod).toFixed(2);
				document.getElementById('sgstod').value=parseFloat(cgstod).toFixed(2);
				document.getElementById('igstod').value=0;
				var igstod=0;
			}
		
			else if(gst_typeod=='IGST')
			{
				var gst_perod=parseFloat(gst_percentageod)/100.0;
				var igstod=parseFloat(totalod)*parseFloat(gst_perod);
				totalod=parseFloat(totalod)+parseFloat(igstod);
				document.getElementById('igstod').value=parseFloat(igstod).toFixed(2);
				document.getElementById('cgstod').value=0;
				document.getElementById('sgstod').value=0;
				var cgstod=0;
				var sgstod=0;
			}
			
			if(gst_typeli=='CGST/SGST')
			{
				var gst_perli=parseFloat(gst_percentageli)/200.0;
				
				var cgstli=parseFloat(totalli)*parseFloat(gst_perli);
				totalli=parseFloat(totalli)+parseFloat(cgstli)+parseFloat(cgstli);
				document.getElementById('cgstli').value=parseFloat(cgstli).toFixed(2);
			document.getElementById('sgstli').value=parseFloat(cgstli).toFixed(2);
			document.getElementById('igstli').value=0;
			var igstli=0;
			}
			else if(gst_typeli=='IGST')
			{
				
				var gst_perli=parseFloat(gst_percentageli)/100.0;
				var igstli=parseFloat(totalli)*parseFloat(gst_perli);
				totalli=parseFloat(totalli)+parseFloat(igstli);
				
			document.getElementById('igstli').value=parseFloat(igstli).toFixed(2);
			document.getElementById('cgstli').value=0;
			document.getElementById('sgstli').value=0;			
				var cgstli=0;
				var sgstli=0;			
			}
			
			
		
			
			if(gst_typeco=='CGST/SGST')
			{
				var gst_perco=parseFloat(gst_percentageco)/200.0;
				
				var cgstco=parseFloat(totalco)*parseFloat(gst_perco);
				totalco=parseFloat(totalco)+parseFloat(cgstco)+parseFloat(cgstco);
				document.getElementById('cgstco').value=parseFloat(cgstco).toFixed(2);
			document.getElementById('sgstco').value=parseFloat(cgstco).toFixed(2);
			document.getElementById('igstco').value=0;
			var igstco=0;
			}
			else if(gst_typeco=='IGST')
			{
				
				var gst_perco=parseFloat(gst_percentageco)/100.0;
				var igstco=parseFloat(totalco)*parseFloat(gst_perco);
				totalco=parseFloat(totalco)+parseFloat(igstco);
				document.getElementById('cgstco').value=0;
			document.getElementById('sgstco').value=0;
			document.getElementById('igstco').value=parseFloat(igstco).toFixed(2);
				var cgstco=0;
				var sgstco=0;				
			}
			
			
		
			var calculation_param=document.getElementById('calculation_param').value;
			var totalA=document.getElementById('net_premiumod').value;
			var totalB=document.getElementById('net_premiumli').value;
			var totalC=document.getElementById('net_premiumco').value;
			var totalall=parseFloat(totalA)+parseFloat(totalB)+parseFloat(totalC);
			var totalAB=parseFloat(totalA)+parseFloat(totalB);
			var totalgst=0;
			var ABC='<?php echo $totalall?>';
			var AB='<?php echo $total?>';
			if(calculation_param=='A+B+C')
			{
			var totalsum=parseFloat(totalall);
				if(gst_typeod=='CGST/SGST')
				{
				var totalgst=parseFloat(totalgst)+parseFloat(cgstod)+parseFloat(cgstod);	
				}
				else if(gst_typeod=='IGST' )
				{	
				var totalgst=parseFloat(totalgst)+parseFloat(igstod);	
				}		
				if(gst_typeli=='CGST/SGST')
				{
				var totalgst=parseFloat(totalgst)+parseFloat(cgstli)+parseFloat(cgstli);	
				}
				else if(gst_typeli=='IGST' )
				{	
				var totalgst=parseFloat(totalgst)+parseFloat(igstli);	
				}	
				if(gst_typeco=='CGST/SGST')
				{
				var totalgst=parseFloat(totalgst)+parseFloat(cgstco)+parseFloat(cgstco);	
				}
				else if(gst_typeco=='IGST' )
				{	
				var totalgst=parseFloat(totalgst)+parseFloat(igstco);	
				}
				document.getElementById('net_premium').value=parseFloat(ABC).toFixed(0);
				}
			else
			{
			var totalsum=parseFloat(totalAB);	
			if(gst_typeod=='CGST/SGST')
				{
				var totalgst=parseFloat(totalgst)+parseFloat(cgstod)+parseFloat(cgstod);	
				}
				else if(gst_typeod=='IGST' )
				{	
				var totalgst=parseFloat(totalgst)+parseFloat(igstod);	
				}		
				if(gst_typeli=='CGST/SGST')
				{
				var totalgst=parseFloat(totalgst)+parseFloat(cgstli)+parseFloat(cgstli);	
				}
				else if(gst_typeli=='IGST' )
				{	
				var totalgst=parseFloat(totalgst)+parseFloat(igstli);	
				}	
				document.getElementById('net_premium').value=parseFloat(AB).toFixed(0);
			}
			totalsum=totalsum+totalgst;
			document.getElementById('premium_amt').value=parseFloat(totalsum).toFixed(0);
			
			document.getElementById('totalGst').value=parseFloat(totalgst).toFixed(2);
		}
		</script>
	
		
		<script>
		/*function calamount(str)
		{
			var calculation_param=document.getElementById('calculation_param').value;
			var totalA=document.getElementById('net_premiumod').value;
			var totalB=document.getElementById('net_premiumli').value;
			var totalC=document.getElementById('net_premiumco').value;
			var gst_typeod=document.getElementById('gst_typeod').value;
			var gst_typeli=document.getElementById('gst_typeli').value;
			var gst_typeco=document.getElementById('gst_typeco').value;
			var igstod=document.getElementById('igstod').value;
			var igstli=document.getElementById('igstli').value;
			var igstco=document.getElementById('igstco').value;
			var cgstod=document.getElementById('cgstod').value;
			var cgstli=document.getElementById('cgstli').value;
			var cgstco=document.getElementById('cgstco').value;
			
			
			
			
			var totalall=parseFloat(totalA)+parseFloat(totalB)+parseFloat(totalC);
			var totalAB=parseFloat(totalA)+parseFloat(totalB);
			var totalgst=0;
			if(calculation_param=='A+B+C')
			{
			var totalsum=parseFloat(totalall);
				if(gst_typeod=='CGST/SGST')
				{
				var totalgst=parseFloat(totalgst)+parseFloat(cgstod)+parseFloat(cgstod);	
				}
				else if(gst_typeod=='IGST' )
				{	
				var totalgst=parseFloat(totalgst)+parseFloat(igstod);	
				}		
				if(gst_typeli=='CGST/SGST')
				{
				var totalgst=parseFloat(totalgst)+parseFloat(cgstli)+parseFloat(cgstli);	
				}
				else if(gst_typeli=='IGST' )
				{	
				var totalgst=parseFloat(totalgst)+parseFloat(igstli);	
				}	
				if(gst_typeco=='CGST/SGST')
				{
				var totalgst=parseFloat(totalgst)+parseFloat(cgstco)+parseFloat(cgstco);	
				}
				else if(gst_typeco=='IGST' )
				{	
				var totalgst=parseFloat(totalgst)+parseFloat(igstco);	
				}
				}
			else
			{
			var totalsum=parseFloat(totalAB);	
			if(gst_typeod=='CGST/SGST')
				{
				var totalgst=parseFloat(totalgst)+parseFloat(cgstod)+parseFloat(cgstod);	
				}
				else if(gst_typeod=='IGST' )
				{	
				var totalgst=parseFloat(totalgst)+parseFloat(igstod);	
				}		
				if(gst_typeli=='CGST/SGST')
				{
				var totalgst=parseFloat(totalgst)+parseFloat(cgstli)+parseFloat(cgstli);	
				}
				else if(gst_typeli=='IGST' )
				{	
				var totalgst=parseFloat(totalgst)+parseFloat(igstli);	
				}	
			}
			document.getElementById('net_premiumod').value=parseFloat(totalod1).toFixed(0);
				document.getElementById('net_premiumli').value=parseFloat(totalli1).toFixed(0);
					document.getElementById('net_premiumco').value=parseFloat(totalco1).toFixed(0);
			document.getElementById('premium_amt').value=totalsum.toFixed(2);
			document.getElementById('totalGst').value=totalgst.toFixed(2);
			
		
		}
		</script>
		<script>
		/*function calamount1(str)
		{
			
			if(str=='IGST')
			{
			document.getElementById('igstod1').style.display="block";		
			document.getElementById('cgstod1').style.display="none";		
			document.getElementById('sgstod1').style.display="none";		
			}
			else if(str=='CGST/SGST')
			{
			document.getElementById('igstod1').style.display="none";		
			document.getElementById('cgstod1').style.display="block";		
			document.getElementById('sgstod1').style.display="block";	
			}
			var gst_typeod=document.getElementById('gst_typeod').value;
			var gst_percentageod=document.getElementById('gst_percentageod').value;
			var totalod='<?php echo $totalA?>';
			
			if(gst_typeod=='CGST/SGST')
			{
				var gst_perod=parseFloat(gst_percentageod)/200.0;
				
				var cgstod=parseFloat(totalod)*parseFloat(gst_perod);
				totalod=parseFloat(totalod)+parseFloat(cgstod)+parseFloat(cgstod);
				document.getElementById('cgstod').value=parseFloat(cgstod).toFixed(2);
				document.getElementById('sgstod').value=parseFloat(cgstod).toFixed(2);
				document.getElementById('igstod').value=0;
				var igstod=0;
			}
		
			else if(gst_typeod=='IGST')
			{
				var gst_perod=parseFloat(gst_percentageod)/100.0;
				var igstod=parseFloat(totalod)*parseFloat(gst_perod);
				totalod=parseFloat(totalod)+parseFloat(igstod);
				document.getElementById('igstod').value=parseFloat(igstod).toFixed(2);
				document.getElementById('cgstod').value=0;
				document.getElementById('sgstod').value=0;
				var cgstod=0;
				var sgstod=0;
			}
			
			
			document.getElementById('net_premiumod').value=totalod.toFixed(2);
			
			
			
			var calculation_param=document.getElementById('calculation_param').value;
			var totalAA=parseFloat(totalod);
			var totalBB=document.getElementById('net_premiumli').value;
			var totalCC=document.getElementById('net_premiumco').value;
			var totalall=parseFloat(totalAA)+parseFloat(totalBB)+parseFloat(totalCC);
			var totalAB=parseFloat(totalAA)+parseFloat(totalBB);
			if(calculation_param=='A+B+C')
			{
			var totalsum=parseFloat(totalall);	
			}
			else
			{
			var totalsum=parseFloat(totalAB);	
			}
			
			
			var igstli=document.getElementById('igstli').value;
			var igstco=document.getElementById('igstco').value;
			var cgstli=document.getElementById('cgstli').value;
			var cgstco=document.getElementById('cgstco').value;
			var totalgst=0;
			if(gst_typeod=='CGST/SGST' || gst_typeli=='CGST/SGST' || gst_typeco=='CGST/SGST')
			{
				
				if(cgstli=='' || cgstli=='0' || cgstli==0)
				{
					cgstli=0;
				}
				if(cgstco=='' || cgstco=='0' || cgstco==0)
				{
					cgstco=0;
				}
				
			var totalgst=parseFloat(cgstod)+parseFloat(cgstli)+parseFloat(cgstco)+parseFloat(cgstod)+parseFloat(cgstli)+parseFloat(cgstco);	
			}
			else if(gst_typeod=='IGST' || gst_typeli=='IGST' || gst_typeco=='IGST')
			{
				
				if(igstli=='' || igstli=='0' || igstli==0)
				{
					igstli=0;
				}
				if(igstco=='' || igstco=='0' || igstco==0)
				{
					igstco=0;
				}
				
			var totalgst=parseFloat(igstod)+parseFloat(igstli)+parseFloat(igstco);	
			}
			
		
			
			document.getElementById('premium_amt').value=totalsum.toFixed(2);
			document.getElementById('totalGst').value=totalgst.toFixed(2);
			
		}
		</script>
		<script>
		function calamount2(str)
		{
			
			if(str=='IGST')
			{
			document.getElementById('igstli1').style.display="block";		
			document.getElementById('cgstli1').style.display="none";		
			document.getElementById('sgstli1').style.display="none";		
			}
			else if(str=='CGST/SGST')
			{
			document.getElementById('igstli1').style.display="none";		
			document.getElementById('cgstli1').style.display="block";		
			document.getElementById('sgstli1').style.display="block";	
			}
			var gst_typeli=document.getElementById('gst_typeli').value;
			var gst_percentageli=document.getElementById('gst_percentageli').value;
			var totalli='<?php echo $totalB?>';
		
			if(gst_typeli=='CGST/SGST')
			{
				var gst_perli=parseFloat(gst_percentageli)/200.0;
				
				var cgstli=parseFloat(totalli)*parseFloat(gst_perli);
				totalli=parseFloat(totalli)+parseFloat(cgstli)+parseFloat(cgstli);
				document.getElementById('cgstli').value=parseFloat(cgstli).toFixed(2);
			document.getElementById('sgstli').value=parseFloat(cgstli).toFixed(2);
			document.getElementById('igstli').value=0;
			var igstli=0;
			}
			else if(gst_typeli=='IGST')
			{
				
				var gst_perli=parseFloat(gst_percentageli)/100.0;
				var igstli=parseFloat(totalli)*parseFloat(gst_perli);
				totalli=parseFloat(totalli)+parseFloat(igstli);
				
			document.getElementById('igstli').value=parseFloat(igstli).toFixed(2);
			document.getElementById('cgstli').value=0;
			document.getElementById('sgstli').value=0;			
				var cgstli=0;
				var sgstli=0;			
			}
			
			
			document.getElementById('net_premiumli').value=totalli.toFixed(3);
			
			var calculation_param=document.getElementById('calculation_param').value;
			var totalAA=document.getElementById('net_premiumod').value;
			var totalBB=parseFloat(totalli);
			var totalCC=document.getElementById('net_premiumco').value;
			var totalall=parseFloat(totalAA)+parseFloat(totalBB)+parseFloat(totalCC);
			var totalAB=parseFloat(totalAA)+parseFloat(totalBB);
			if(calculation_param=='A+B+C')
			{
			var totalsum=parseFloat(totalall);	
			}
			else
			{
			var totalsum=parseFloat(totalAB);	
			}
			
			
			var igstod=document.getElementById('igstod').value;
		
			var igstco=document.getElementById('igstco').value;
			var cgstod=document.getElementById('cgstod').value;
		
			var cgstco=document.getElementById('cgstco').value;
			var totalgst=0;
			if(gst_typeod=='CGST/SGST')
				{
				var totalgst=parseFloat(totalgst)+parseFloat(cgstod)+parseFloat(cgstod);	
				}
				else if(gst_typeod=='IGST' )
				{	
				var totalgst=parseFloat(totalgst)+parseFloat(igstod);	
				}		
				if(gst_typeli=='CGST/SGST')
				{
				var totalgst=parseFloat(totalgst)+parseFloat(cgstli)+parseFloat(cgstli);	
				}
				else if(gst_typeli=='IGST' )
				{	
				var totalgst=parseFloat(totalgst)+parseFloat(igstli);	
				}	
				if(gst_typeco=='CGST/SGST')
				{
				var totalgst=parseFloat(totalgst)+parseFloat(cgstco)+parseFloat(cgstco);	
				}
				else if(gst_typeco=='IGST' )
				{	
				var totalgst=parseFloat(totalgst)+parseFloat(igstco);	
				}
				}
			
			var net_premium=parseFloat(totalsum)-parseFloat(totalgst);
			document.getElementById('premium_amt').value=totalsum.toFixed(2);
			document.getElementById('totalGst').value=totalgst.toFixed(2);
			
		}
		</script>
		<script>
		function calamount3(str)
		{
			
			if(str=='IGST')
			{
			document.getElementById('igstco1').style.display="block";		
			document.getElementById('cgstco1').style.display="none";		
			document.getElementById('sgstco1').style.display="none";		
			}
			else if(str=='CGST/SGST')
			{
			document.getElementById('igstco1').style.display="none";		
			document.getElementById('cgstco1').style.display="block";		
			document.getElementById('sgstco1').style.display="block";	
			}
			var gst_typeco=document.getElementById('gst_typeco').value;
			var gst_percentageco=document.getElementById('gst_percentageco').value;
			var totalco='<?php echo $totalB?>';
		
			if(gst_typeco=='CGST/SGST')
			{
				var gst_perco=parseFloat(gst_percentageco)/200.0;
				
				var cgstco=parseFloat(totalco)*parseFloat(gst_perco);
				totalco=parseFloat(totalco)+parseFloat(cgstco)+parseFloat(cgstco);
				document.getElementById('cgstco').value=parseFloat(cgstco).toFixed(2);
			document.getElementById('sgstco').value=parseFloat(cgstco).toFixed(2);
			document.getElementById('igstco').value=0;
			var igstco=0;
			}
			else if(gst_typeco=='IGST')
			{
				
				var gst_perco=parseFloat(gst_percentageco)/100.0;
				var igstco=parseFloat(totalco)*parseFloat(gst_perco);
				totalco=parseFloat(totalco)+parseFloat(igstco);
				document.getElementById('cgstco').value=0;
			document.getElementById('sgstco').value=0;
			document.getElementById('igstco').value=parseFloat(igstco).toFixed(2);
				var cgstco=0;
				var sgstco=0;				
			}
			
			
			document.getElementById('net_premiumco').value=totalco.toFixed(2);
			
			var calculation_param=document.getElementById('calculation_param').value;
			var totalAA=document.getElementById('net_premiumod').value;
			var totalBB=document.getElementById('net_premiumli').value;
			var totalCC=parseFloat(totalco);
			
			var totalall=parseFloat(totalAA)+parseFloat(totalBB)+parseFloat(totalCC);
			var totalAB=parseFloat(totalAA)+parseFloat(totalBB);
			if(calculation_param=='A+B+C')
			{
			var totalsum=parseFloat(totalall);	
			}
			else
			{
			var totalsum=parseFloat(totalAB);	
			}
			
			
			var igstod=document.getElementById('igstod').value;
			var igstli=document.getElementById('igstli').value;
			var cgstod=document.getElementById('cgstod').value;
			var cgstli=document.getElementById('cgstli').value;
			var totalgst=0;
			
			if(gst_typeod=='CGST/SGST' || gst_typeli=='CGST/SGST' || gst_typeco=='CGST/SGST')
			{
				if(cgstod=='' || cgstod=='0' || cgstod==0)
				{
					cgstod=0;
					
				}
				if(cgstli=='' || cgstli=='0' || cgstli==0)
				{
					cgstli=0;
				}
				
				
			}
			else if(gst_typeod=='IGST' || gst_typeli=='IGST' || gst_typeco=='IGST')
			{
				if(igstod=='' || igstod=='0' || igstod==0)
				{
					igstod=0;
				}
				if(igstli=='' || igstli=='0' || igstli==0)
				{
					igstli=0;
				}
			alert(igstli);	
			var totalgst=parseFloat(igstod)+parseFloat(igstli)+parseFloat(igstco);	
			}
			
			var net_premium=parseFloat(totalsum)-parseFloat(totalgst);
			document.getElementById('premium_amt').value=totalsum.toFixed(2);
			document.getElementById('totalGst').value=totalgst.toFixed(2);
			
		}*/
		</script>
		
		
</head>

<body>
    <!-- ============================================================== -->
    <!-- Preloader - style you can find in spinners.css -->
    <!-- ============================================================== -->
  
	 <div id="main-wrapper">
   <?php include("header.php"); ?>
    
     <?php include("menu.php"); ?>
	
        <div class="page-wrapper">
            <!-- ============================================================== -->
            <!-- Bread crumb and right sidebar toggle -->
            <!-- ============================================================== -->
            <div class="page-breadcrumb">
                <div class="row">
                    <div class="col-12 d-flex no-block align-items-center">
                        <h4 class="page-title">Add Policy</h4>
                        <div class="ml-auto text-right">
                            <nav aria-label="breadcrumb">
                                <ol class="breadcrumb">
                                    <li class="breadcrumb-item"><a href="dashboard.php">Dashboard</a></li>
									<?php if($id1!='') 
									{ ?>
                                    <li class="breadcrumb-item"><a href="agent.php">View Policy</a></li>
									
                                    <?php } ?>
									
									<li class="breadcrumb-item active" aria-current="page">Add Policy</li>
                                </ol>
                            </nav>
                        </div>
                    </div>
                </div>
            </div>
            <!-- ============================================================== -->
            <!-- End Bread crumb and right sidebar toggle -->
            <!-- ============================================================== -->
            <!-- ============================================================== -->
            <!-- Container fluid  -->
            <!-- ============================================================== -->
            <div class="container-fluid">
                <!-- ============================================================== -->
                <!-- Start Page Content -->
                <!-- ============================================================== -->
				<div >
                <div class="row" >
                    <div class="col-md-12" style="float:left; width:100%; overflow-Y: auto; height: 500px;">
                        <div class="card" >
						<form class="form-horizontal" method="post" name="form1"  enctype="multipart/form-data">
                                <div class="card-body">
						 <div class="row" >
                    <div class="col-md-12">
                        <div class="card-body">
                            <table  border="2px;" width="100%" height="100%">
                                <thead>
								<tr><th colspan="2"><b><h5 class="card-title m-b-0" >Own Damage premium on vehicle and accessories</h5></b></th><tr>
								<tr><th colspan="2" style="text-align:center"><b><h4 class="card-title m-b-0" >Section I- Own Damage(A)</h4></b></th><tr>
                                    <tr>
                                        <th  colspan="2">Basic Cover</th>
                                        
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <td>Basic OD</td>
                                        <td><?php echo $od;?></td>
                                    </tr>
									<tr>
                                        <td>Discount (<?php echo $discount; ?>%)</td>
                                        <td><?php echo $dis;?></td>
                                    </tr>
                                    <tr>
                                        <td>Total Own-Damage Premium(A) </td>
                                        <td><b><?php echo $totalA;?></b></td>
                                    </tr>
                                    
                              </tbody>
                            </table>
							<br>
							<div class="form-group row">

								<div class="col-md-4">	
									<div class="form-group ">
                                        <label for="chassis" class=" text-left control-label col-form-label"><b>Total Own-Damage Premium(A)</b></label>
                                         <input type="text" class="form-control" id="net_premiumod" name="totalA" placeholder="Total Own-Damage Premium(A)" value="<?php echo $totalA?>" readonly required>
										 <input type="hidden" class="form-control"  name="od_discount" value="<?php echo $dis; ?>">
										 <input type="hidden" class="form-control"  name="od_discount_per" value="<?php echo $discount; ?>">
										  
									</div>
                                </div>
								<div class="col-md-4">	
									<div class="form-group ">
                                        <label  class=" text-left control-label col-form-label"><b>GST Type</b></label>
                                          <select class="select2 form-control custom-select" onchange="calamountt(this.value)" style="width: 100%; height:36px;" name="gst_typeod" id="gst_typeod"  required>
                                           <option value="CGST/SGST">CGST/SGST</option>	
											<option value="IGST">IGST</option>	
										</select>
									</div>
                                </div>
								<div class="col-md-4">	
									<div class="form-group ">
                                        <label for="chassis" class=" text-left control-label col-form-label"><b>GST Percentage</b></label>
                                        <select class="select2 form-control custom-select" style="width: 100%; height:36px;" name="gst_percentageod" onchange="calamountt(this.value)" id="gst_percentageod" required>
										<?php $query=mysqli_query($con,"select * from tbl_gst_percentage where admin_id='$ver' and status='Active'");
													while($agent=mysqli_fetch_assoc($query))
													{  
												if($agent['percentage_value']=='18%')
												{?>
													 <option value="<?php echo $agent['percentage_value']?>" selected ><?=$agent['percentage_value']?></option>	
												<?php }
												else
												{
												?>
												
													 <option value="<?php echo $agent['percentage_value']?>"><?=$agent['percentage_value']?></option>	
													 
														
												<?php }	}?>
                                          
										</select>
									</div>
                                </div>
								<div class="col-md-4" id="cgstod1">	
									<div class="form-group ">
                                        <label for="chassis" class=" text-left control-label col-form-label"><b>CGST</b></label>
                                         <input type="number" class="form-control" value="<?php echo $cgstod; ?>" id="cgstod" name="cgstod" placeholder="CGST" readonly required>
									</div>
                                </div>
								<div class="col-md-4" id="sgstod1">	
									<div class="form-group ">
                                        <label for="chassis" class=" text-left control-label col-form-label"><b>SGST</b></label>
                                         <input type="number" class="form-control" value="<?php echo $cgstod; ?>" id="sgstod" name="sgstod" placeholder="SGST" readonly required>
									</div>
                                </div>
								<div class="col-md-4" id="igstod1" style="display:none">	
									<div class="form-group ">
                                        <label for="chassis" class=" text-left control-label col-form-label"><b>IGST</b></label>
                                         <input type="number" class="form-control"  id="igstod" name="igstod" placeholder="IGST" readonly required>
									</div>
                                </div>
								
                                </div>
								
                            <table  border="2px;" width="100%">
                                <thead>
								<tr><th colspan="2" style="text-align:center"><b><h4 class="card-title m-b-0" >Section II- Liability(B)</h4></b></th><tr>
                                    <tr>
                                        <th  colspan="2"><b>Third Party Premium</b></th>
                                         </tr>
									  <tr>
                                         <th  colspan="2">Basic TP</th>
                                      </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <td>Basic Cover</td>
                                        <td><?php echo $cover?></td>
                                    </tr>
									<tr>
                                        <td colspan="2"><b>PA Benefits</b></td>
                                        
                                    </tr>
									<tr>
                                        <td>PA To Owner Driver</td>
                                        <td><?php echo $pa?></td>
                                    </tr>
									<tr>
                                        <td colspan="2"><b>Legal Liability</b></td>
                                        
                                    </tr>
									<tr>
                                        <td>LL To Paid Driver</td>
                                        <td><?php echo $liabilities?></td>
                                    </tr>
                                    <tr>
                                        <td>Total Liability Premium(B) </td>
                                        <td><b><?php echo $totalB?></b></td>
                                    </tr>
                                    
                              </tbody>
                            </table>
							
                       <br>
					<div class="form-group row">
								
								<div class="col-md-4">	
									<div class="form-group ">
                                        <label for="chassis" class=" text-left control-label col-form-label"><b>Total Liability Premium(B)</b></label>
                                         <input type="text" class="form-control" id="net_premiumli" name="totalB" placeholder="Total Liability Premium(B)" value="<?php echo $totalB?>" readonly required>
									</div>
                                </div>
								<div class="col-md-4">	
									<div class="form-group ">
                                        <label  class=" text-left control-label col-form-label"><b>GST Type</b></label>
                                          <select class="select2 form-control custom-select" style="width: 100%; height:36px;" name="gst_typeli" id="gst_typeli" onchange="calamountt(this.value);" required>
                                           <option value="CGST/SGST">CGST/SGST</option>	
											<option value="IGST">IGST</option>	
										</select>
									</div>
                                </div>
								<div class="col-md-4">	
									<div class="form-group ">
                                        <label for="chassis" class=" text-left control-label col-form-label"><b>GST Percentage</b></label>
                                        <select class="select2 form-control custom-select" style="width: 100%; height:36px;" name="gst_percentageli" onchange="calamountt(this.value)" id="gst_percentageli" required>
										<?php $query1=mysqli_query($con,"select * from tbl_gst_percentage where admin_id='$ver' and status='Active'");
													while($agent1=mysqli_fetch_assoc($query1))
													{  
												if($agent1['percentage_value']=='18%')
												{?>
													 <option value="<?php echo $agent1['percentage_value']?>" selected ><?=$agent1['percentage_value']?></option>	
												<?php }
												else
												{
												?>
												
													 <option value="<?php echo $agent1['percentage_value']?>"><?=$agent1['percentage_value']?></option>	
													 
														
												<?php }	}?>
                                          
										</select>
									</div>
                                </div>
                                </div>
								<div class="form-group row" >
								
								<div class="col-md-4" id="cgstli1">	
									<div class="form-group ">
                                        <label for="chas" class=" text-left control-label col-form-label"><b>CGST</b></label>
                                         <input type="number" class="form-control" value="<?php echo $cgstli; ?>" id="cgstli" name="cgstli" placeholder="CGST" readonly required>
									</div>
                                </div>
								<div class="col-md-4" id="sgstli1">	
									<div class="form-group ">
                                        <label for="chassis" class=" text-left control-label col-form-label"><b>SGST</b></label>
                                         <input type="number" class="form-control" value="<?php echo $cgstli; ?>" id="sgstli" name="sgstli" placeholder="SGST" readonly required>
									</div>
                                </div>
								<div class="col-md-4" id="igstli1" style="display:none">	
									<div class="form-group ">
                                        <label for="chassis" class=" text-left control-label col-form-label"><b>IGST</b></label>
                                         <input type="number" class="form-control"  id="igstli" name="igstli" placeholder="IGST" readonly required>
									</div>
                                </div>
                                </div>
								
                                
							<table class="table" border="2px;" width="100%">
                                <thead>
								
								<tr><th colspan="2" style="text-align:center"><b><h4 class="card-title m-b-0" >Section III- Add On Covers(C)</h4></b></th><tr>
                                
                                </thead>
                                <tbody>
                                    <tr>
                                        <td>Passenger assist</td>
                                        <td><?php echo $passenger_assist; ?></td>
                                    </tr>
									<tr>
                                        <td>Depreciation Cover</td>
                                        <td><?php echo $depreciation; ?></td>
                                    </tr>
                                    <tr>
                                        <td>Total Add On Cover Premium(C)</td>
                                        <td><b><?php echo $totalC; ?></b></td>
                                    </tr>
                                    
                              </tbody>
                            </table>
							<div class="form-group row">
								
								<div class="col-md-4">	
									<div class="form-group ">
                                        <label for="chassis" class=" text-left control-label col-form-label"><b>Total Add On Cover Premium(C)</b></label>
                                         <input type="text" class="form-control" id="net_premiumco" name="totalC" placeholder="Net Premium" value="<?php echo $totalC?>" readonly required>
									</div>
                                </div>
								<div class="col-md-4">	
									<div class="form-group ">
                                        <label  class=" text-left control-label col-form-label"><b>GST Type</b></label>
                                          <select class="select2 form-control custom-select" style="width: 100%; height:36px;" name="gst_typeco" id="gst_typeco" onchange="calamountt(this.value);" required>
                                           <option value="CGST/SGST">CGST/SGST</option>	
											<option value="IGST">IGST</option>	
										</select>
									</div>
                                </div>
								<div class="col-md-4">	
									<div class="form-group ">
                                        <label for="chassis" class=" text-left control-label col-form-label"><b>Passenger Assist</b></label>
                                        <select class="select2 form-control custom-select" style="width: 100%; height:36px;" name="gst_percentageco" onchange="calamountt(this.value)" id="gst_percentageco" required>
                                           <?php $query2=mysqli_query($con,"select * from tbl_gst_percentage where admin_id='$ver' and status='Active'");
													while($agent2=mysqli_fetch_assoc($query2))
													{  
												if($agent2['percentage_value']=='18%')
												{?>
													 <option value="<?php echo $agent2['percentage_value']?>" selected ><?=$agent2['percentage_value']?></option>	
												<?php }
												else
												{
												?>
												
													 <option value="<?php echo $agent2['percentage_value']?>"><?=$agent2['percentage_value']?></option>	
													 
														
												<?php }	}?>
										</select>
									</div>
                                </div>
								<div class="col-md-4" id="cgstco1">	
									<div class="form-group ">
                                        <label for="chassis" class=" text-left control-label col-form-label"><b>CGST</b></label>
                                         <input type="number" class="form-control" value="<?php echo $cgstco; ?>" id="cgstco" name="cgstco" placeholder="CGST" readonly required>
									</div>
                                </div>
								<div class="col-md-4" id="sgstco1">	
									<div class="form-group ">
                                        <label for="chassis" class=" text-left control-label col-form-label"><b>SGST</b></label>
                                         <input type="number" class="form-control" value="<?php echo $cgstco; ?>" id="sgstco" name="sgstco" placeholder="SGST" readonly required>
									</div>
                                </div>
								<div class="col-md-4" id="igstco1" style="display:none">	
									<div class="form-group ">
                                        <label for="chassis" class=" text-left control-label col-form-label"><b>IGST</b></label>
                                         <input type="number" class="form-control"  id="igstco" name="igstco" placeholder="IGST" readonly required>
									</div>
                                </div>
								
                                </div>
                        
					
					<hr>
					<div class="form-group row">
							
								<div class="col-md-4">	
									<div class="form-group ">
                                        <label for="number" class=" text-left control-label col-form-label"><b>Net Premium Type</b></label>
                                         <select class="select2 form-control custom-select" style="width: 100%; height:36px;" name="calculation_param" onchange="calamountt(this.value)" id="calculation_param" required>
                                           <option value="A+B+C">A+B+C</option>	
											<option value="A+B">A+B</option>	
										</select>
									</div>
                                </div>
								 <div class="col-md-4">	
									<div class="form-group ">
                                        <label for="chassis" class=" text-left control-label col-form-label"><b>Net Premium Amount</b></label>
                                         <input type="number" class="form-control" id="net_premium" name="net_premium" placeholder="Net Premium" value="<?php echo $net_pre_amount;?>" readonly required>
									</div>
                                </div>
								 <div class="col-md-4">	
									<div class="form-group ">
                                        <label for="chassis" class=" text-left control-label col-form-label"><b>Total GST</b></label>
                                         <input type="number" class="form-control" id="totalGst" name="totalGst" placeholder="Total GST" value="<?php echo $totalGst;?>" readonly required>
									</div>
                                </div>
                            <div class="col-md-4">	
									<div class="form-group ">
                                        <label for="chassis" class=" text-left control-label col-form-label"><b>Total Premium Amount</b></label>
                                         <input type="number" class="form-control" id="premium_amt" name="premium_amt" placeholder="Total Premium" value="<?php echo $net_amount;?>" readonly required>
									</div>
                                </div>
                                </div>
								
                                 
								     <div class="form-group row">
								<input type="hidden" class="form-control"  id="type" name="type" value="<?php echo $type; ?>">
								<input type="hidden" class="form-control"  id="customer_name" name="customer_name" value="<?php echo $customer_name; ?>">
								<input type="hidden" class="form-control"  id="address" name="address" value="<?php echo $address; ?>">
								<input type="hidden" class="form-control"  name="customer_id" value="<?php echo $customer_id; ?>">
								<input type="hidden" class="form-control"  name="agent_id" value="<?php echo $agent_id; ?>">
								<input type="hidden" class="form-control"  name="policy_no" value="<?php echo $policy_no; ?>">
								<input type="hidden" class="form-control"  name="company_id" value="<?php echo $company_id; ?>">
								<input type="hidden" class="form-control"  name="policy_date" value="<?php echo $policy_date; ?>">
								<input type="hidden" class="form-control"  name="policy_type" value="<?php echo $policy_type; ?>">
								<input type="hidden" class="form-control"  name="vehicle_id" value="<?php echo $vehicle_id; ?>">
								<input type="hidden" class="form-control"  name="make_model" value="<?php echo $make_model; ?>">
								<input type="hidden" class="form-control"  name="idv" value="<?php echo $idv; ?>">
								<input type="hidden" class="form-control"  name="reg_no" value="<?php echo $reg_no; ?>">
								<input type="hidden" class="form-control"  name="engine_no" value="<?php echo $engine_no; ?>">
								<input type="hidden" class="form-control"  name="chassis_no" value="<?php echo $chassis_no; ?>">
								<input type="hidden" class="form-control"  name="mfg_year" value="<?php echo $mfg_year; ?>">
								<input type="hidden" class="form-control"  name="seating_cap" value="<?php echo $seating_cap; ?>">
								<input type="hidden" class="form-control"  name="body_type" value="<?php echo $body_type; ?>">
								<input type="hidden" class="form-control"  name="fuel_type" value="<?php echo $fuel_type; ?>">
								<input type="hidden" class="form-control"  name="hp" value="<?php echo $hp; ?>">
								<input type="hidden" class="form-control"  name="policy_term" value="<?php echo $policy_term; ?>">
								<input type="hidden" class="form-control"  name="term_value" value="<?php echo $term_value; ?>">
								<input type="hidden" class="form-control"  name="NCB" value="<?php echo $NCB; ?>">
								<input type="hidden" class="form-control"  name="NCB_value" value="<?php echo $NCB_value; ?>">
								<input type="hidden" class="form-control"  name="od" value="<?php echo $od; ?>">
								<input type="hidden" class="form-control"  name="pa" value="<?php echo $pa; ?>">
								<input type="hidden" class="form-control"  name="renewal_date" value="<?php echo $renewal_date; ?>">
								<input type="hidden" class="form-control"  name="cover" value="<?php echo $cover; ?>">
								<input type="hidden" class="form-control"  name="liabilities" value="<?php echo $liabilities; ?>">
								<input type="hidden" class="form-control"  name="passenger_assist" value="<?php echo $passenger_assist; ?>">
								<input type="hidden" class="form-control"  name="depreciation" value="<?php echo $depreciation; ?>">
								<input type="hidden" class="form-control"  name="ta" value="<?php echo $totalA; ?>">
								<input type="hidden" class="form-control"  name="tb" value="<?php echo $totalB; ?>">
								<input type="hidden" class="form-control"  name="tc" value="<?php echo $totalC; ?>">
								<input type="hidden" class="form-control"  name="previous_policy" value="<?php echo $previous_policy; ?>">
								<input type="hidden" class="form-control"  name="unique_id" value="<?php echo $unique_id; ?>">
								<input type="hidden" class="form-control"  name="email" value="<?php echo $email; ?>">
								<input type="hidden" class="form-control"  name="phone_no" value="<?php echo $phone_no; ?>">
								<input type="hidden" class="form-control"  name="manager_id" value="<?php echo $manager_id; ?>">
								<!--<input type="hidden" class="form-control"  name="com" value="<?php //echo $com; ?>">-->
							</div>
                    </div>
                    </div>
                    </div>
								
                                </div>
								 </div> 
								<div class="form-group row">
                                 <div class="col-md-4">   
                                <div class="border-top">
                                    <div class="card-body">
                                       <div class="card-body">
									   <button type="submit" onclick="myFunction1()"  name="previous" class="btn btn-primary" style="display:none" >Previous</button>
									    <button type="submit" onclick="myFunction1()"  name="previous" class="btn btn-primary" style="display:none">Next</button>
                                    <button type="submit" name="sub1" class="btn btn-success">Save</button>
                                    
									<button type="button" onclick="myFunction()" name="subcancel" class="btn btn-primary">Cancel</button>
                                    
                                </div>
                                    </div>
                                </div>
                                </div>
                                </div>
                            </form>
							
							<?php 
			if(isset($_POST['previous']))
				{
					header('location:add-policy.php');
				}
			if(isset($_POST['sub1']))
				{
	$previous_policy = $_POST['previous_policy'];
	$customer_name = $_POST['customer_name'];
	$unique_id = $_POST['unique_id'];
	$phone_no = $_POST['phone_no'];
	$address = $_POST['address'];
	$email = $_POST['email'];
	$com = $_POST['com'];
	
	$customer_id=$_POST['customer_id'];
	$admin_id = $_SESSION["admin_id"];
$manager_id = $_POST["manager_id"];
	$com=$_POST['com'];
	$agent_id=$_POST['agent_id'];
	$policy_no=$_POST['policy_no'];
	$company_id=$_POST['company_id'];
	$policy_date=$_POST['policy_date'];
	$renewal_date=$_POST['renewal_date'];
	$policy_type=$_POST['policy_type'];
	$vehicle_id=$_POST['vehicle_id'];
	$make_model=$_POST['make_model'];
	//$shortPremium=$_POST['shortPremium'];
	$idv=$_POST['idv'];
	$reg_no=$_POST['reg_no'];
	$engine_no=$_POST['engine_no'];
	$chassis_no=$_POST['chassis_no'];
	$mfg_year=$_POST['mfg_year'];
	$seating_cap=$_POST['seating_cap'];
	$body_type=$_POST['body_type'];
	$fuel_type=$_POST['fuel_type'];
	$hp=$_POST['hp'];
	$policy_term=$_POST['policy_term'];
	$term_value=$_POST['term_value'];
	$NCB=$_POST['NCB'];
	$NCB_value = isset($_POST['NCB_value']) ? $_POST['NCB_value'] : '0';
	$od=$_POST['od'];
	$od_discount=$_POST['od_discount'];
	$od_discount_per=$_POST['od_discount_per'];
	$shortPremium=$_POST['shortPremium'];
	$cover=$_POST['cover'];
	$pa=$_POST['pa'];
	$liabilities=$_POST['liabilities'];
	$passenger_assist=$_POST['passenger_assist'];
	$depreciation=$_POST['depreciation'];
	$totalA=$_POST['ta'];
	$totalB=$_POST['tb'];
	$totalC=$_POST['tc'];
	$calculation_param=$_POST['calculation_param'];
	$net_premium=$_POST['net_premium'];
	$gst_typeA=$_POST['gst_typeod'];
	$gst_typeB=$_POST['gst_typeli'];
	$gst_typeC=$_POST['gst_typeco'];
	$gst_percentageA=$_POST['gst_percentageod'];
	$gst_percentageB=$_POST['gst_percentageli'];
	$gst_percentageC=$_POST['gst_percentageco'];
	$shortPremium=$_POST['shortPremium'];
	$cGstA=$_POST['cgstod'];
	$sGstA=$_POST['sgstod'];
	$iGstA=$_POST['igstod'];
	$uniqueId=uniqid();
	$cGstB=$_POST['cgstli'];
	$sGstB=$_POST['sgstli'];
	$iGstB=$_POST['igstli'];
	
	$cGstC=$_POST['cgstco'];
	$sGstC=$_POST['sgstco'];
	$iGstC=$_POST['igstco'];
	$totalGst=$_POST['totalGst'];
	$premium_amt=$_POST['premium_amt'];

	date_default_timezone_set('Asia/Calcutta');
	$cdate  = date("Y-m-d")." ".date('h:i:sa');
	$tdate  = date("Y-m-d");
	$ttime = date('h:i:s');
	/* if(isset($com))
	{
		
	$res_com= mysqli_query($con,"SELECT * FROM `tbl_insurance_company` where company_name  like '%$com%'");
	if(mysqli_num_rows($res_com)>0)
	{
		$q=mysqli_fetch_assoc($res_com);
		$company_id=$q['company_id'];
	}
	else
	{
		
		$insert_com=mysqli_query($con,"INSERT INTO `tbl_insurance_company`( `admin_id`, `status`, `company_name`, `insert_datetime`,  `insert_by`) VALUES ('$admin_id','Active','$com','$cdate','$dis_id')");
		$res_com1= mysqli_query($con,"SELECT * FROM `tbl_insurance_company` where company_name  like '%$com%'");
		if(mysqli_num_rows($res_com1)>0)
			{
		$q1=mysqli_fetch_assoc($res_com1);
		$company_id=$q1['company_id'];
			}
		
	}
	} */
	
	$res_product_stock = mysqli_query($con,"SELECT customer_id FROM  tbl_policy_master where policy_no='$policy_no'");
	if(mysqli_num_rows($res_product_stock)<=0)
	{		

	$query = mysqli_query($con,"INSERT INTO `tbl_policy_master`(`admin_id`, `manager_id`, `customer_id`, `policy_no`, `policy_type`, `company_id`, `policy_date`, `renewal_date`, `vehicle_id`, `make_model`, `idv`, `registration_no`, `engine_no`, `chassis_no`, `manufacturing_year`, `seating_capacity`, `body_type`, `fuel_type`, `hp_cc`, `policy_term`, `term_value`, `NCB`, `NCB_value`, `od`, `od_discount_per`, `od_discount`, `totalA`, `cover`, `pa`, `liabilities`, `totalB`, `passenger_assist`, `depreciation`, `totalC`, `gst_typeA`, `gst_percentageA`, `cGstA`, `sGstA`, `iGstA`, `gst_typeB`, `gst_percentageB`, `cGstB`, `sGstB`, `iGstB`, `gst_typeC`, `gst_percentageC`, `cGstC`, `sGstC`, `iGstC`, `calculation_param`, `net_premium`, `totalGst`, `premium_amt`, `status`, `insert_datetime`,`unique_id`) VALUES ('$admin_id', '$manager_id', '$customer_id', '$policy_no', '$policy_type', '$company_id', '$policy_date', '$renewal_date', '$vehicle_id', '$make_model', '$idv', '$reg_no', '$engine_no', '$chassis_no', '$mfg_year', '$seating_cap', '$body_type', '$fuel_type', '$hp', '$policy_term', '$term_value', '$NCB', '$NCB_value', '$od', '$od_discount_per', '$od_discount', '$totalA', '$cover', '$pa', '$liabilities', '$totalB', '$passenger_assist', '$depreciation', '$totalC', '$gst_typeA', '$gst_percentageA', '$cGstA', '$sGstA', '$iGstA', '$gst_typeB', '$gst_percentageB', '$cGstB', '$sGstB', '$iGstB', '$gst_typeC', '$gst_percentageC', '$cGstC', '$sGstC', '$iGstC', '$calculation_param', '$net_premium', '$totalGst', '$premium_amt', 'Pending', '$cdate','$unique_id')");

	// $query1 = mysqli_query($con,"INSERT INTO `tbl_customer_premium`(`manager_id`,`agent_id`,`customer_id`,`premium_amt`,`transaction_date`,`transaction_time`,`status`,`policy_no`,`agent_received_amt`,`complete_date`,`complete_time`) VALUES ('$manager_id','$agent_id','$customer_id','$premium_amt','$t_date','$t_time','Complete','$policy_no','$premium_amt','$t_date','$t_time')");	
$query = mysqli_query($con,"INSERT INTO `tbl_customer_premium`(`manager_id`,`agent_id`,`customer_id`,`premium_amt`,`transaction_date`,`transaction_time`,`status`,`policy_no`,`unique_id`) VALUES ('$manager_id','$agent_id','$customer_id','$premium_amt','$tdate','$ttime','Pending','$policy_no','$unique_id')");

		$query1 = mysqli_query($con,"UPDATE `tbl_policy_master` SET status = 'Renewal Pending' where policy_no = '$previous_policy'");
			
	
	if($query || $query1)
	{
		
		header('location:download_policy.php?id='.base64_encode($policy_no));
	header('location:/agent-pending-work.php');
	}
	
	}
	else
	{
	?>
	<script>
	alert("Policy Already Exist");
	</script>
	<?php
	}
	
		
	
			
				}	
				
							?>
							
							
                        </div>
                    
          

                    </div>
              
                </div>
                <!-- editor -->
               
                <!-- ============================================================== -->
                <!-- End PAge Content -->
                <!-- ============================================================== -->
                <!-- ============================================================== -->
                <!-- Right sidebar -->
                <!-- ============================================================== -->
                <!-- .right-sidebar -->
                <!-- ============================================================== -->
                <!-- End Right sidebar -->
                <!-- ============================================================== -->
            </div>
            </div>
            </div>
            <!-- ============================================================== -->
            <!-- End Container fluid  -->
            <!-- ============================================================== -->
            <!-- ============================================================== -->
            <!-- footer -->
            <!-- ============================================================== -->
             <footer class="footer text-center">
                  2019 &copy; All Rights Reserved by BTCOVER. Designed and Developed by <a href="http://www.belltechnology.in/">Bell Technology</a>.
            </footer>
          
            <!-- ============================================================== -->
            <!-- End footer -->
            <!-- ============================================================== -->
        </div>
        <!-- ============================================================== -->
        <!-- End Page wrapper  -->
        <!-- ============================================================== -->
    </div>
    <!-- ============================================================== -->
    <!-- End Wrapper -->
    <!-- ============================================================== -->
    <!-- ============================================================== -->
    <!-- All Jquery -->
    <!-- ============================================================== -->
    <script src="assets/libs/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap tether Core JavaScript -->
    <script src="assets/libs/popper.js/dist/umd/popper.min.js"></script>
    <script src="assets/libs/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- slimscrollbar scrollbar JavaScript -->
    <script src="assets/libs/perfect-scrollbar/dist/perfect-scrollbar.jquery.min.js"></script>
    <script src="assets/extra-libs/sparkline/sparkline.js"></script>
    <!--Wave Effects -->
    <script src="dist/js/waves.js"></script>
    <!--Menu sidebar -->
    <script src="dist/js/sidebarmenu.js"></script>
    <!--Custom JavaScript -->
    <script src="dist/js/custom.min.js"></script>
    <!-- This Page JS -->
    <script src="assets/libs/inputmask/dist/min/jquery.inputmask.bundle.min.js"></script>
    <script src="dist/js/pages/mask/mask.init.js"></script>
    <script src="assets/libs/select2/dist/js/select2.full.min.js"></script>
    <script src="assets/libs/select2/dist/js/select2.min.js"></script>
    <script src="assets/libs/jquery-asColor/dist/jquery-asColor.min.js"></script>
    <script src="assets/libs/jquery-asGradient/dist/jquery-asGradient.js"></script>
    <script src="assets/libs/jquery-asColorPicker/dist/jquery-asColorPicker.min.js"></script>
    <script src="assets/libs/jquery-minicolors/jquery.minicolors.min.js"></script>
    <script src="assets/libs/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
    <script src="assets/libs/quill/dist/quill.min.js"></script>
    <script>
        //***********************************//
        // For select 2
        //***********************************//
        $(".select2").select2();

        /*colorpicker*/
        $('.demo').each(function() {
        //
        // Dear reader, it's actually very easy to initialize MiniColors. For example:
        //
        //  $(selector).minicolors();
        //
        // The way I've done it below is just for the demo, so don't get confused
        // by it. Also, data- attributes aren't supported at this time...they're
        // only used for this demo.
        //
        $(this).minicolors({
                control: $(this).attr('data-control') || 'hue',
                position: $(this).attr('data-position') || 'bottom left',

                change: function(value, opacity) {
                    if (!value) return;
                    if (opacity) value += ', ' + opacity;
                    if (typeof console === 'object') {
                        console.log(value);
                    }
                },
                theme: 'bootstrap'
            });

        });
        /*datwpicker*/
        jQuery('.mydatepicker').datepicker();
        jQuery('#datepicker-autoclose').datepicker({
            autoclose: true,
            todayHighlight: true
        });
        var quill = new Quill('#editor', {
            theme: 'snow'
        });

    </script>
</body>

</html>