<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <title> Create  Sale Invoice</title>
    <meta name="apple-mobile-web-app-capable" content="yes">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="css/my-bootstrap.min.css?ver=1007202510072025" rel="stylesheet">
    <link href="css/bootstrap-responsive.min.css?ver=1007202510072025" rel="stylesheet">
    <link href="css/OpenSans.css?ver=1007202510072025" rel="stylesheet">
    <link href="css/font-awesome.css?ver=1007202510072025" rel="stylesheet">
    <link href="css/style.css?ver=1007202510072025" rel="stylesheet">
    <link href="css/fieldset.css?ver=1007202510072025" rel="stylesheet">
    <link href="../ui/jquery-ui.css?ver=1007202510072025" rel="stylesheet">
    <link href="css/dashboard.css?ver=1007202510072025" rel="stylesheet">
    <link href="css/bootstrap-tagsinput.css?ver=1007202510072025" rel="stylesheet">

    <link href="css/plans.css?ver=1007202510072025" rel="stylesheet">
    <link href="css/multi-select.css?ver=1007202510072025" rel="stylesheet" type="text/css">
    <link href="css/jquery-te-1.4.0.css?ver=1007202510072025" rel="stylesheet" type="text/css">
    <link href="css/select2.min.css?ver=1007202510072025" rel="stylesheet" type="text/css">
    <link href="css/footable.bootstrap.min.css?ver=1007202510072025" rel="stylesheet" type="text/css">
    <link href="js/dropzone/dropzone.min.css?ver=1007202510072025" rel="stylesheet" type="text/css">
    <link href="css/fancybox.css?ver=1007202510072025" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="js/editorjs/editorjs-inline-font-size-tool.css?ver=1007202510072025">

    <link rel="stylesheet" href="css/jquery-ui.css?ver=1007202510072025">
        <link href="css/custom.css?ver=1007202510072025" rel="stylesheet">
    <link href="css/animate.min.css?ver=1007202510072025" rel="stylesheet" />
    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
	<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
	<![endif]-->

        <script>
        var user_salt = '6ed349d37d553e2cafef';
        var start_of_finantial_year = 2025;
        var end_of_finantial_year = 2026;
        var barcode_scanner_length = '6';
        var ship_email_lable = 'Email';
    </script>
    <script src="js/jquery-1.12.4.min.js?ver=1007202510072025"></script>
    <script src="js/jquery-migrate-1.4.1.min.js?ver=1007202510072025"></script>
    <script src="js/sortable.min.js?ver=1007202510072025"></script>
    <script src="js/general.js?ver=1007202510072025"></script>
    <script src="js/exchangerate.js?ver=1007202510072025"></script>
    <script src="js/jquery.validate.js?ver=1007202510072025"></script>
    <script src="js/JsBarcode.js?ver=1007202510072025"></script>
    <script src="js/bootstrap.js?ver=1007202510072025"></script>
    <script src="js/bootstrap-tagsinput.js?ver=1007202510072025"></script>
    <script src="js/typeahead.js?ver=1007202510072025"></script>
    <script src="../ui/jquery-ui-new.js?ver=1007202510072025"></script>
    <script src="js/uiExtention.js?ver=1007202510072025"></script>
    <script src="js/jquery.multi-select.js?ver=1007202510072025"></script>
    <script src="js/grabzit.min.js?ver=1007202510072025"></script>
    <script src="js/jquery-te-1.4.0.min.js?ver=1007202510072025"></script>
    <script src="js/jquery.fileDownload.js?ver=1007202510072025"></script>
    <script src="js/jquery.table2excel.js?ver=1007202510072025"></script>
    <script src="js/tableToExcel.js?ver=1007202510072025"></script>
    <script src="js/select2.full.min.js?ver=1007202510072025"></script>
    <script src="js/jquery.popupoverlay.js?ver=1007202510072025"></script>
    <script src="js/footable.js?ver=1007202510072025"></script>
    <script src="js/drawer.min.js?ver=1007202510072025"></script>
    <script src="js/tipped.min.js?ver=1007202510072025"></script>
    <script src="js/sweetalert2.js?ver=1007202510072025"></script>
    <script src="js/dropzone/dropzone.min.js?ver=1007202510072025"></script>
    <script src="js/fancybox.js?ver=1007202510072025"></script>
    <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <script src="js/jquery.cookie.min.js?ver=1007202510072025"></script>
    <link rel="stylesheet" href="js/daterangepicker/daterangepicker.css??ver=1007202510072025">
    <script src="js/daterangepicker/moment.min.js?ver=1007202510072025"></script>
    <script src="js/daterangepicker/daterangepicker.js?ver=1007202510072025"></script>
    <script src="js/algebra.min.js?ver=1007202510072025"></script>
    <script src="js/math.min.js?ver=1007202510072025"></script>


    <script src="js/pdf.min.js?ver=1007202510072025"></script>
        <script>
        var Org_GSTIN_No = "";
                var session_start = 2025;
        var session_end = 2026;
        var shortcutBtn = false;
                    var shortcutBtn = true;
            shortkeys_fun();
        
        var gst_rates_options_igst = "<option value='0' >0</option><option value='0.1' >0.1</option><option value='0.25' >0.25</option><option value='0.5' >0.5</option><option value='1' >1</option><option value='1.5' >1.5</option><option value='3' >3</option><option value='5' >5</option><option value='6' >6</option><option value='7.5' >7.5</option><option value='12' >12</option><option value='18' >18</option><option value='28' >28</option>";
        var gst_rates_options_cgst = "<option value='0' >0 + 0</option><option value='0.05' >0.05 + 0.05</option><option value='0.125' >0.125 + 0.125</option><option value='0.25' >0.25 + 0.25</option><option value='0.5' >0.5 + 0.5</option><option value='0.75' >0.75 + 0.75</option><option value='1.5' >1.5 + 1.5</option><option value='2.5' >2.5 + 2.5</option><option value='3' >3 + 3</option><option value='3.75' >3.75 + 3.75</option><option value='6' >6 + 6</option><option value='9' >9 + 9</option><option value='14' >14 + 14</option>";
        var go_date_long = "dd-M-yy";
        var go_date_short = "dd-M-y";
        var go_date_month_year = "M yy";
        var go_date_month_years = "M-yy";
        var dateRangePicker_format = "DD-MMM-YYYY";
    </script>
    <script>
        var Toast = Swal.mixin({
            toast: true,
            position: 'top-end',
            showConfirmButton: false,
            timer: 3000,
            showClass: {
                popup: 'animate__animated animate__slideInRight'
            },
            hideClass: {
                popup: 'animate__animated animate__slideOutRight'
            },
            timerProgressBar: true,
        });
    </script>


</head>
<style>
    </style>

<body class="drawer drawer--left invoicebill member-basic">
<!--<div style="background: #F1A104;color: #fff;padding: 5px 0;text-align: center;font-size: 16px;">Website will be down from 05:00 AM to 05:50 AM for Schedule Maintenance.</div>
<div style="background: #F1A104;color: #fff;padding: 5px 0;text-align: center;font-size: 16px;">Due to Coronavirus (COVID-19) our phone support is offline for some time please create <a href="https://gogstbill.com/gogstbill-software-support/" style="color: #fff;text-decoration: underline;">Support Request</a> or send us email at <a href="mailto:help@gogstbill.com" style="text-decoration: underline;color: #fff;">help@gogstbill.com</a> Thank you.</div>-->
    <noscript>
    <style type="text/css">
        .noscript {
    position: fixed;
    height: 100%;
    width: 100%;
    display: table;
    background: 
    rgba(255,255,255,0.9);
    z-index: 1000000;
    text-align: center;
}
.noscriptmsg {
    display: table-cell;
    height: 100%;
    width: 100%;
    vertical-align: middle;
	font-size: 26px;
	font-weight: bold;
}
.noscriptmsg h1 {
    font-size: 35px;
    line-height: 1.4;
    margin-bottom: 20px;
	color: #ED541D;
}
.noscriptmsg p {
    font-size: 20px;
    line-height: 1.4;
}
    </style>
    <div class="noscript">
		<div class="noscriptmsg">
			<h1>JavaScript is disabled</h1><p>Your browser JavaScript seems to be disabled.<br> Please enable JavaScript to start using site features.</p>
		</div>
    </div>
</noscript>                <script>
                   async function lockUntilLocation() {
                        $(".locationreq").hide()
                                               
                    }
                    window.addEventListener("DOMContentLoaded", lockUntilLocation);

                </script>
           
                	<style>
	#rCMODluVEmXa {
		display: none;
		padding: 10px 10px;
		background: #FEF5F1;
		text-align: center;
		font-weight: bold;
		color: #000;
		border-radius: 5px;
		font-size: 26px;
		font-weight: bold;
	}
	#rCMODluVEmXa h1 {
		font-size: 24px;
		line-height: 1.4;
		margin-bottom: 10px;
		color: #ED541D;
	}
	#rCMODluVEmXa p {
		font-size: 16px;
		line-height: 1.4;
	}
	</style>
	
	<div id="rCMODluVEmXa">
	<h1>You're using an Ad Blocker</h1><p>To continue using Go GST Bill, You can either disable your ad blocker or join Premium Membership.</p>
	</div>
	<script src="js/ads.js" type="text/javascript"></script>
	<script type="text/javascript">
	var coockieval = null;
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf("gogstaccount=") == 0) coockieval= c.substring('gogstaccount='.length,c.length);
	}
	
	if(document.getElementById('jnrqZHKCRbhE')){
		if(coockieval != null)
		{
			document.cookie = 'gogstaccount=; Max-Age=-99999999;';  
		}
	} else {
		document.getElementById('rCMODluVEmXa').style.display='block';
		if(coockieval == null)
		{
			var expires = "";
			var date = new Date();
			date.setTime(date.getTime() + (1*24*60*60*1000));
			expires = "; expires=" + date.toUTCString();
			document.cookie = "gogstaccount=10594" + expires + "; path=/";
		}
	}
	</script>

    <header role="banner">
        <button type="button" class="drawer-toggle drawer-hamburger">
            <span class="sr-only">toggle navigation</span>
            <span class="drawer-hamburger-icon"></span>
        </button>

        <nav class="drawer-nav" role="navigation">
            <div class="mobile-nav-logo"><img src="img/inverted.png?update" alt="Smart GST Billing Software" title="Smart GST Billing Software"></div>
	<ul class="drawer-menu">
				<li  >
					<a href="home.php"><span class="fa-icon-svg"><svg><use href="svg-icon/icons.svg#dashboard-svg-icon"></use></svg></span>
					<span>Dashboard</span><span class="shortcut_key_ctrl">d</span></a>	    				
				</li>
				
								<li >
					<a href="list-company.php"><span class="fa-icon-svg"><svg><use href="svg-icon/icons.svg#customer-svg-icon"></use></svg></span>
					<span>Customer / Vendor</span><span class="shortcut_key_ctrl">o</span></a>	    				
				</li>
												<li class="drawer-dropdown 
					 
					 
					" >
					<a  class="dropdown-toggle" data-toggle="dropdown"><span class="fa-icon-svg"><svg><use href="svg-icon/icons.svg#product-svg-icon"></use></svg></span>
					<span style="line-height: 100%;">Products / Services</span></a>	   
					<ul class="drawer-dropdown-menu">
                        <li><a href="list-product.php">Products / Services<span class="shortcut_key_ctrl">r</span></a></li>
                        <li><a href="list-category.php">Product Group</a></li>
                        <li class="menu_sep_hr"><a><hr></a></li>
						<li><a href="manage-stock.php">Stock</a></li>
                    </ul>   					
				</li>
												<li 					class="active"				>
					<a href="invoicedetail.php"><span class="fa-icon-svg"><svg><use href="svg-icon/icons.svg#saleinvoice-svg-icon"></use></svg></span>
					<span style="line-height: 100%;">Sale Invoice</span><span class="shortcut_key">s</span></a>	    				
				</li>
												<li  
					   >
					<a href="purchaseinvoicedetail.php"><span class="fa-icon-svg"><svg><use href="svg-icon/icons.svg#purchase-svg-icon"></use></svg></span>
					<span style="line-height: 100%;">Purchase Invoice</span><span class="shortcut_key">p</span></a>	    				
				</li>
												<li class="drawer-dropdown 
					 "    >
					<a  class="dropdown-toggle" data-toggle="dropdown"><span class="fa-icon-svg"><svg><use href="svg-icon/icons.svg#payment-svg-icon"></use></svg></span>
					<span style="line-height: 100%;">Payment</span></a>	   
					<ul class="drawer-dropdown-menu">
                        <li><a href="list-paymentreceipt.php?type=inward">Inward Payment (Sales Inv.)<span class="shortcut_key">i</span></a></li>
						<li><a href="list-paymentreceipt.php?type=outward">Outward Payment (Purchase Inv.)<span class="shortcut_key">o</span></a></li>
                    </ul>   					
				</li>
												<li class="drawer-dropdown																				"
				>
					<a  class="dropdown-toggle" data-toggle="dropdown"><span class="fa-icon-svg"><svg><use href="svg-icon/icons.svg#expense-svg-icon"></use></svg></span>
					<span style="line-height: 100%;">Expense <br> Income</span></a>	   
					<ul class="drawer-dropdown-menu">
                        <li><a href="list-dailyexpense.php">Daily Expenses<span class="shortcut_key">d</span></a></li>							<li><a href="list-otherincome.php">Other Income<span class="shortcut_key">t</span></a></li>	                    </ul>   					
				</li>
								<li class="drawer-dropdown																																																																																								"
				>
					<a  class="dropdown-toggle" data-toggle="dropdown"><span class="fa-icon-svg"><svg><use href="svg-icon/icons.svg#otheredoc-svg-icon"></use></svg></span>
					<span style="line-height: 100%;">Other Documents</span></a>	   
					<ul class="drawer-dropdown-menu">
                        <li><a href="quotationdetail.php">Quotation<span class="shortcut_key">q</span></a></li>						<li><a href="proformadetail.php">Proforma<span class="shortcut_key">r</span></a></li>						<li><a href="challandetail.php">Delivery Challan<span class="shortcut_key">e</span></a></li>							<li><a href="purchaseorderdetail.php">Purchase Order<span class="shortcut_key">u</span></a></li>						<li><a href="saleorderdetail.php">Sale Order<span class="shortcut_key">i</span></a></li>						<li><a href="jobworkdetail.php">Job Work<span class="shortcut_key">j</span></a></li>						                        <li class="locked"><a data-toggle="modal" data-target="#addRemoveModal">Letters</a></li>                        <li class="locked"><a data-toggle="modal" data-target="#addRemoveModal">Bank Ledger</a></li>                        <li class="locked"><a data-toggle="modal" data-target="#addRemoveModal">Packing List &nbsp;</a></li>						<li class="locked"><a data-toggle="modal" data-target="#addRemoveModal">Manufacture &nbsp;<span class="label">Beta</span></a></li>
													<li class="menu_sep_hr"><a><hr></a></li>
												<li><a href="creditdetail.php">Credit Note<span class="shortcut_key">c</span></a></li>						<li><a href="debitdetail.php">Debit Note<span class="shortcut_key">b</span></a></li>						<li class="menu_sep_hr"><a><hr></a></li>												<li class="locked"><a  data-toggle="modal" data-target="#addRemoveModal">Multi Currency Invoice<span class="shortcut_key">m</span></a></li>						                    </ul>   					
				</li>
												
												<li class="drawer-dropdown last-header-option"     >
					<a  class="dropdown-toggle" data-toggle="dropdown"><span class="fa-icon-svg"><svg><use href="svg-icon/icons.svg#report-svg-icon"></use></svg></span>
					<span style="line-height: 100%;">Report</span></a>	   
					<ul class="drawer-dropdown-menu">
					                        <li class="menu_heading">Sales Reports</li>
						<li><a href="report-sales.php">Sales</a></li>	
						<li><a href="report-sales_outstanding.php?">Sales Outstanding</a></li>
						<li><a href="report-sales_product_report.php">Sales Product Report</a></li>						
						<li><a href="report-inward_payment.php">Inward Payment</a></li>
																		<li class="menu_heading">Purchase Reports</li>
						<li><a href="report-purchase.php">Purchase</a></li>
						<li><a href="report-purchase_outstanding.php">Purchase Outstanding</a></li>
						<li><a href="report-purchase_product_report.php">Purchase Product Report</a></li>						
						<li><a href="report-outward_payment.php">Outward Payment</a></li>
																		<li class="menu_heading">Other Reports</li>
																		<li><a href="report-customer_ledger.php">Company Ledger</a></li>
																		<li><a href="report-company_outstanding.php">Company Outstanding</a></li>
																		<li><a href="report-profit_loss.php">Profit & Loss Report</a></li>
																		<li><a href="report-stock.php">Stock Report</a></li>
																		<li><a href="report-product.php">Product Report</a></li>
																		<li><a href="report-daily_expense.php">Daily Expenses</a></li>
																		<li><a href="report-other_income.php">Other Income</a></li>
												<li class="menu_heading">GST Reports</li>
						<li><a href="gstr1.php">GSTR-1</a></li>							<li><a href="gstr2b.php">GSTR-2B</a></li>							<li><a href="gstr3b.php">GSTR-3B</a></li>                      </ul>
					
					
				</li>
												<li class="settings_menu_mobile drawer-dropdown 
																																																																																					" >
					<a  class="dropdown-toggle" data-toggle="dropdown"><span class="fa-icon-svg"><svg><use href="svg-icon/icons.svg#settings-svg-icon"></use></svg></span>
					<span style="line-height: 100%;">Settings</span></a>	   
					<ul class="drawer-dropdown-menu">
						<li><a href="list-setting.php">Membership</a></li>						<li class="locked"><a  data-toggle="modal" data-target="#addRemoveModal">Credits</a></li>						<li><a href="edit-userdetail.php">Login & Security</a></li>						<li><a href="edit-eway.php">E-way Bill & E-Invoice</a></li>						<li><a href="settings-whatsapp.php">WhatsApp Options</a></li>
                        <li><a href="edit-organisationdetail.php">Business Profile</a></li>						<li><a  data-toggle="modal" data-target="#addRemoveModal"> Staff Account</a></li>						
						<li ><a href="file-log.php">Go Drive</a></li>                        <li><a href="export-file.php">Export Data</a></li>								<li  ><a href="activity-log.php">Activity Log</a></li>
								                        <li class=' locked'><a href="settings-digital-signature.php">Digital Sign</a></li>						
                        <li><a href="smtp-email-settings.php">Email Options</a></li>                        
						<li class=" " ><a href="settings-general-option.php"> General Options</a></li>						<li class=" " ><a href="settings-product-option.php"> Product & Stock Options</a></li>						<li class=" " ><a href="settings-printtemplate-option.php"> Print Template</a></li>						<li class=" " ><a href="settings-print-option.php"> Print Options</a></li>						<li class=" " ><a href="settings-bank-detail.php"> Bank Details</a></li>						<li class=" " ><a href="settings-document-option.php"> Document Options</a></li>						<li class="locked"><a  data-toggle="modal" data-target="#addRemoveModal"> Shipping & Envelope Options</a></li>						<li class=" " ><a href="settings-termscondition-option.php"> Terms and Condition</a></li>						<li class="locked"><a  data-toggle="modal" data-target="#addRemoveModal">Translation Options</a></li>						<li class="locked"><a  data-toggle="modal" data-target="#addRemoveModal">Email & Whatsapp Templates</a></li>						<li class="locked"><a  data-toggle="modal" data-target="#addRemoveModal">Payment Reminder</a></li>						<li class="hide_unser_tab"><a href="edit-custom-header.php">Design Custom Header</a></li>						
																		
                    </ul>   					
				</li>
								<li class="notification_menu_mobile ">
					<a href="list-notifications.php" class="mobile-notification"><span class="fa-icon-svg"><svg><use href="svg-icon/icons.svg#notification-svg-icon"></use></svg></span>
					<span style="line-height: 22px;margin-left: 5px;">Notification</span>
											</a>	    				
				</li>
								
			
<li class="referafrnd mobile-nav-show list-sec " >
	<a href="refer-a-friend.php"><span class="fa-icon-svg"> <svg width="24" height="24">
                                        <use href="svg-icon/icons.svg#refere-svg-icon"></use>
                                    </svg></span><span style="line-height: 100%;"> Refer a friend</span></a>
</li>
<li class="mobile-nav-show mobile-nav-logout">
	<div class="session-and-logout">
		<div class="session-box">
			<form method="post" action="" name="myFormSession">
				<div class="dropdown bill-session-new-tab">
				<a data-toggle="dropdown" href="#" class="btn dropdown-toggle" style="padding-top: 10px;padding-bottom: 10px;">F.Y. 2025-2026</a>
					<ul class="dropdown-menu pull-right">
													<li style="text-align: left;"class="list-sec" ><a href="#" data-session="_2017_2018"  >F.Y. 2017-2018</a></li>
							<hr class="hrcl">									
												<li style="text-align: left;"class="list-sec" ><a href="#" data-session="_2018_2019"  >F.Y. 2018-2019</a></li>
							<hr class="hrcl">									
												<li style="text-align: left;"class="list-sec" ><a href="#" data-session="_2019_2020"  >F.Y. 2019-2020</a></li>
							<hr class="hrcl">									
												<li style="text-align: left;"class="list-sec" ><a href="#" data-session="_2020_2021"  >F.Y. 2020-2021</a></li>
							<hr class="hrcl">									
												<li style="text-align: left;"class="list-sec" ><a href="#" data-session="_2021_2022"  >F.Y. 2021-2022</a></li>
							<hr class="hrcl">									
												<li style="text-align: left;"class="list-sec" ><a href="#" data-session="_2022_2023"  >F.Y. 2022-2023</a></li>
							<hr class="hrcl">									
												<li style="text-align: left;"class="list-sec" ><a href="#" data-session="_2023_2024"  >F.Y. 2023-2024</a></li>
							<hr class="hrcl">									
												<li style="text-align: left;"class="list-sec" ><a href="#" data-session="_2024_2025"  >F.Y. 2024-2025</a></li>
							<hr class="hrcl">									
												<li style="text-align: left;"class="list-sec" ><a href="#" data-session="_2025_2026" class="active" >F.Y. 2025-2026</a></li>
																
										</ul>
				</div>
			</form>
		</div>
	</div>
</li>

<hr class="mobile-nav-show hrcl">
<h5 class="mobile-nav-show quicksupporttxt">Quick Support</h5>
<li class="mobile-nav-show list-sec">
	<div class="contact-info-section">
		<div class="contact-info-section-icon">
			<svg width="24" height="24" style="scale: 1.1;">
	            <use href="svg-icon/icons.svg#whatsapp-svg-icon"></use>
	        </svg>
		</div>
		<div class="contact-info-section-content">
			<a href="https://api.whatsapp.com/send/?phone=+917043146478&amp;text=Hi, I need help " target="__blank">+91 7043146478</a>
			<p>10 AM to 7 PM - Everyday</p>
		</div>
	</div>
</li>
<li class="mobile-nav-show list-sec">
	<div class="contact-info-section">
		<div class="contact-info-section-icon">
			 <svg width="24" height="24">
                <use href="svg-icon/icons.svg#message-svg-icon"></use>
            </svg>
		</div>
		<div class="contact-info-section-content">
			<a href="/cdn-cgi/l/email-protection#345c51584474535b534740565d58581a575b59"><span class="__cf_email__" data-cfemail="96fef3fae6d6f1f9f1e5e2f4fffafab8f5f9fb">[email&#160;protected]</span></a>
			<p>We usually reply within 1 working day</p>
		</div>
	</div>
</li>
<li class="mobile-nav-show list-sec">
	<div class="contact-info-section">
		<div class="contact-info-section-icon">
			<svg width="24" height="24">
                <use href="svg-icon/icons.svg#books-svg-icon"></use>
            </svg>
		</div>
		<div class="contact-info-section-content">

		<a class="ViewKnowledgeModal" data-baseLink="knowledge-base.php">Knowledge Base</a>
			<!-- <a href="https://gogstbill.com/knowledge-base/" target="_blank">Knowledge Base</a> -->
			<p>100+ Questions answered with Screenshots</p>
		</div>
	</div>
</li>
<li class="mobile-nav-show list-sec">
	<div class="seprator"></div>
	<div class="generate-pin-box">
		<a class="generate-support-pin">Generate Support PIN</a>
	</div>
	</li>
<li  class="mobile-nav-show mobile-nav-logout  btn-full ">
	<a class="logout-btn"  href="logout.php"><svg width="24" height="24"><use href="svg-icon/icons.svg#logout-svg-icon"></use></svg>Logout</a>
</li>
</ul>
        </nav>
    </header>
    <main role="main">
        <div class="preloader-overly">
            <svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
                xmlns:xlink="http://www.w3.org/1999/xlink" version="1.0" width="80px" height="80px"
                viewBox="0 0 128 128" xml:space="preserve">
                <g>
                    <path fill="#00ba8c" fill-opacity="1"
                        d="M109.25 55.5h-36l12-12a29.54 29.54 0 0 0-49.53 12H18.75A46.04 46.04 0 0 1 96.9 31.84l12.35-12.34v36zm-90.5 17h36l-12 12a29.54 29.54 0 0 0 49.53-12h16.97A46.04 46.04 0 0 1 31.1 96.16L18.74 108.5v-36z" />
                    <animateTransform attributeName="transform" type="rotate" from="0 64 64" to="360 64 64" dur="880ms"
                        repeatCount="indefinite"></animateTransform>
                </g>
            </svg>
        </div>
        <div class="draft-preloader-overly">
            <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
                style="margin: auto; background: none; display: block; shape-rendering: auto;" width="40px"
                height="40px" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid">
                <g transform="rotate(0 50 50)">
                    <rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#ffffff">
                        <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s"
                            begin="-0.9166666666666666s" repeatCount="indefinite"></animate>
                    </rect>
                </g>
                <g transform="rotate(30 50 50)">
                    <rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#ffffff">
                        <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s"
                            begin="-0.8333333333333334s" repeatCount="indefinite"></animate>
                    </rect>
                </g>
                <g transform="rotate(60 50 50)">
                    <rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#ffffff">
                        <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.75s"
                            repeatCount="indefinite"></animate>
                    </rect>
                </g>
                <g transform="rotate(90 50 50)">
                    <rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#ffffff">
                        <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s"
                            begin="-0.6666666666666666s" repeatCount="indefinite"></animate>
                    </rect>
                </g>
                <g transform="rotate(120 50 50)">
                    <rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#ffffff">
                        <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s"
                            begin="-0.5833333333333334s" repeatCount="indefinite"></animate>
                    </rect>
                </g>
                <g transform="rotate(150 50 50)">
                    <rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#ffffff">
                        <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.5s"
                            repeatCount="indefinite"></animate>
                    </rect>
                </g>
                <g transform="rotate(180 50 50)">
                    <rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#ffffff">
                        <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s"
                            begin="-0.4166666666666667s" repeatCount="indefinite"></animate>
                    </rect>
                </g>
                <g transform="rotate(210 50 50)">
                    <rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#ffffff">
                        <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s"
                            begin="-0.3333333333333333s" repeatCount="indefinite"></animate>
                    </rect>
                </g>
                <g transform="rotate(240 50 50)">
                    <rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#ffffff">
                        <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.25s"
                            repeatCount="indefinite"></animate>
                    </rect>
                </g>
                <g transform="rotate(270 50 50)">
                    <rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#ffffff">
                        <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s"
                            begin="-0.16666666666666666s" repeatCount="indefinite"></animate>
                    </rect>
                </g>
                <g transform="rotate(300 50 50)">
                    <rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#ffffff">
                        <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s"
                            begin="-0.08333333333333333s" repeatCount="indefinite"></animate>
                    </rect>
                </g>
                <g transform="rotate(330 50 50)">
                    <rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#ffffff">
                        <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="0s"
                            repeatCount="indefinite"></animate>
                    </rect>
                </g>
            </svg>
            Auto saving to draft
        </div>
        <div id="trialModal_gst" class="modal payment_modal_box modal-lg fade enter_gst_popup" role="dialog" style="display: none;">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="btn btn-default btn_close" data-dismiss="modal" ><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg></button>
				<h4 class="modal-title">Start Your Trial</h4>
			</div>
			<div class="modal-body">				
				<form method="post" id="">
					<div class="plan-actions">
											</div> <!-- /plan-actions -->
				</form>				
			</div>
		</div>
	</div>
</div>
<style>
div#trialModal_gst {
    width: 630px;
    max-width: 100%;
    margin: -330px 0 0 -310px;
}

@media screen and (max-width: 1024px) {
	div#trialModal_gst {
		margin: -200px 0 0 -384px;
	}
}

@media screen and (max-width: 767px) {
	div#trialModal_gst {
		margin: 70px 0 0 -207px;
	}
}
</style>        <script data-cfasync="false" src="/cdn-cgi/scripts/5c5dd728/cloudflare-static/email-decode.min.js"></script><script src="js/razorpay.js?ver=1007202510072025"></script>
<div id="addRemoveModal" class="modal payment_modal_box modal-lg fade" role="dialog" style="display: none;">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<a type="button" style="float: right;" class="btn btn_close" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg></a>
				<!-- <button type="button" class="close" data-dismiss="modal" >&times;</button> -->
				<h4 class="modal-title">Upgrade Now</h4>
			</div>
			<div class="modal-body">
				
			<div class="info-more-items" style="display:none;"></div>
			<div class="premium-plan">
				<div class="premium-membership-plans">
	<div class="premium-membership-plans-switcher">
		<p class="fieldset">
			<input type="radio" class="cd-switchmodal" name="membership-type" value="1year" id="1-year-cbmodal" checked data-price="1499" data-product-id="1">
			<label for="1-year-cbmodal">1 Year</label>
			<input type="radio" class="cd-switchmodal" name="membership-type" value="3year" id="3-year-cbmodal" data-price="3499" data-product-id="2">
			<label for="3-year-cbmodal">3 Year <span class="save-amount">SAVE RS. 998</span></label>
			<span class="cd-switch"></span>
		</p>
	</div>
</div>
	<h1 class="plan-amount-textmodal">RS. <span class="price">1499</span></h1>
		<div class="plan-gstrate price-additional">+ 18% GST</div>
	<form method="post">
		<input type="hidden" name="btnpay" />
		<input type="hidden" name="userID" value="10594" />
		<input type="hidden" name="name" value="KAVYA" />
		<input type="hidden" name="phone" value="" />
		<input type="hidden" name="email" value="gvaanand@outlook.com" />
		<input type="hidden" name="amount" id="plan-amountmodal" value="1499" />			
		<input type="hidden" name="product_id" id="plan-product_idmodal" value="1" />		
		<button type="submit" class="btn membership-btn upgradeNow" >Upgrade Now</button>
	</form>	
	<script>
		$(document).ready(function(){
			$('.cd-switchmodal').change(function() {
				$('.plan-amount-textmodal').find('.price').text($(this).attr('data-price'));
				$('#plan-amountmodal').val($(this).attr('data-price'));
				$('#plan-product_idmodal').val($(this).attr('data-product-id'));
			});
		});
	</script>
			</div>	
				<div class="terms-container" style="text-align: center;"><i class="fa fa-info-circle"></i>&nbsp;&nbsp;By clicking upgrade, you are agreeing to the <span style="white-space: nowrap;"><a href="https://gogstbill.com/terms/" target="_blank">Terms</a> and <a href="https://gogstbill.com/privacy/" target="_blank">Privacy Policy</a>.</span></div>
			</div>
		</div>
	</div>
</div>
<style>
.info-more-items {
	text-align: center;
}
.info-more-items span.upto {
    color: #888;
    font-size: 12px;
}
.info-more-items div {
    font-size: 20px;
    font-weight: bold;
}
.plan-heading {
    padding: 0px 26px 10px 26px;
}
.plan-features.remove-line {
    border: 0px;
	padding-bottom: 17px;
}
.plan-features-list li {
    text-align: left;
}
.plan-features-list li i {
    padding-right: 10px;
}
.pricing-plans.plans-2 {
    display: inline-block;
    width: 100%;
}
.pricing-plans-box {
    background: #f5f5f5;
    padding: 20px 30px 20px;
    border-radius: 4px;
	display: table;
	width: 100%;
	box-sizing: border-box;
	margin-bottom: 30px;
	position: relative;
}
.pricing-plans-box .plans-box-inner {
    display: table-cell;
	vertical-align: middle;
}
.pricing-plans-box .btn {
    text-transform: uppercase;
    background: #eba01e;
	border-color: #eba01e;
	color: #fff;
    padding: 1em 0;
    font-size: 16px;
    font-weight: bold;
    min-width: 250px;
}
.pricing-plans-box .plans-box-inner .control-group {
    margin-bottom: 0;
    margin-top: 5px;
}
.pricing-plans-box .plans-box-inner form {
    margin: 0;
}
.promocode-lbl {
    font-size: 12px;
    font-weight: bold;
	margin: 0;
}
.plan-actions .control-group {
    margin-bottom: 0;
    margin-top: 14px;
	padding: 0 20px;
}
.offer-label {
    position: absolute;
    top: 0;
    left: 0;
    background: red;
	color: #fff;
    font-size: 12px;
    padding: 0px 10px;
    line-height: 19px;
	margin-left: -15px;
	margin-top: 7px;
}
.offer-label::before {
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 10px 0px 0px 15px;
    border-color: red transparent transparent
    transparent;
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
}
.pricing-plans .terms-container {
    display: inline-block;
    width: 100%;
}
.modal-responsive.modal-lg.modal {
    margin: -250px 0 0 -360px;
}

@media screen and (max-width: 767px) {
	.mobile-hide {
		display: none;
	}
	.modal-responsive {
		max-width: 530px;
		margin: -265px 0px 0px -265px !important;
		max-height: 530px;
	}
	.modal-responsive .modal-body {
		max-height: 100% !important;
	}
	.pricing-plans-box .plans-box-inner {
		display: block;
		padding: 10px 0px 0px;
		text-align: center;
	}
	.pricing-plans .plan {
		margin-right: 0px;
	}
}
@media screen and (max-width: 530px) {
	.mobile-hide {
		display: none;
	}
	.modal-responsive {
		max-width: 480px;
		margin: -240px 0px 0px -240px !important;
		max-height: 480px;
	}
}
@media screen and (max-width: 480px) {
	.modal-responsive {
		max-width: 320px;
		margin: -160px 0px 0 -160px !important;
		position: fixed !important;
		left: 50% !important;
		top: 50% !important;
		max-height: 320px;
	}
	.modal-responsive .modal-header .close {
		padding: 0px 5px;
		margin: -3px 0px 0px !important;
	}
	.modal-responsive .modal-body {
		padding: 20px;
	}
	.pricing-plans-box .btn {
		min-width: 210px;
	}
	.pricing-plans-box {
		padding: 10px 20px 20px;
	}
}
input.not_valid_gst:focus {
    border-color: #e9322d;
    -webkit-box-shadow: 0 0 6px #f8b9b7;
    -moz-box-shadow: 0 0 6px #f8b9b7;
    box-shadow: 0 0 6px #f8b9b7;
}
span.error_msg {
    color: red;
    font-style: italic;
}
input.not_valid_gst + .error_msg {
    display: block !important;
    margin-top: -5px;
    margin-bottom: 5px;
}
.modal-lg.modal.enter_gst_popup {
    width: 450px;
    margin: -160px 0 0 -220px;
}
.enter_gst_popup .plan-actions {
    padding: 1.15em 0;
    background: unset;
    background-color: unset;
    border: unset;
    display: grid;
}
.enter_gst_popup input[type="text"] {
    width: 100%;
    margin-top: 8px;
}

.enter_gst_popup .plan-actions .btn {
    padding:2px 11px;
    margin: unset;
    display: unset;
    font-size: unset;
    font-weight: unset;
}
.enter_gst_popup input#with_gst_num {
    float: right;
}
.enter_gst_popup form {
    margin-bottom: 0;
}
.enter_gst_popup .modal-body {
    padding: 10px 30px 10px;
}
</style>
<script>
$(function(){
	$(".promocode-lbl").click(function(){
		$(this).parents(".control-group").find(".promocode-box").show();
	});
	$(".btnApply").click(function(e){
		e.preventDefault();
		var clickedele = $(this);
		var promocode = $(this).parents(".control-group").find(".promocode").val();
		if(promocode == ""){
			$(this).parents(".control-group").find(".result").html('<span style="color:red;">Error! Please Enter Promocode.</span>');
		}else{
			var data = {
				action: 'checkpromocode',
				promocode: promocode
			}
			$.ajax({  
				type: "POST",  
				url: "ajaxcall.php",
				ContentType : 'application/json',
				dataType: 'json',
				data: data,
				success: function(data){     
					if (data.status == 'APPLY')
					{ 
						clickedele.parents(".control-group").find(".promocode-box").hide();
						clickedele.parents(".control-group").find(".promocode-lbl").hide();
						clickedele.parents(".control-group").find(".result").html('<span style="color:green;">'+data.msg+'</span>');
						clickedele.parents(".control-group").find('.hidden_discount').val(data.value);
					} 
					else if (data.status == 'UNAPPLY')
					{ 
						clickedele.parents(".control-group").find(".result").html('<span style="color:red;">'+data.msg+'</span>');
						clickedele.parents(".control-group").find('.hidden_discount').val(data.value);
					} 
					else{
						clickedele.parents(".control-group").find(".result").html('<span style="color:red;">Error! Please try again.</span>');
					}
				},
				complete: function(data){
				}
			});
		}
	});
});

	

$(document).ready(function () {

    $('#enter_gst_pop  #with_gst_num').on('click', function() {		
		var gst_num = $('#enter_gst_pop input[name=gst_num]').val();	
		if(gst_num.length == 15) {						
			$('#enter_gst_pop input[name=gst_num]').removeClass('not_valid_gst');
			$('#enter_gst_pop input[name=gst_num]').val();
			return true;
		}else{
			$('#enter_gst_pop input[name=gst_num]').addClass('not_valid_gst');
			$('#enter_gst_pop input[name=gst_num]').focus();
			return false;	
		}
	});

	$('#enter_gst_pop_3yr #with_gst_num').on('click', function() {		
		var gst_num = $('#enter_gst_pop_3yr input[name=gst_num]').val();	
		if(gst_num.length == 15) {						
			$('#enter_gst_pop_3yr input[name=gst_num]').removeClass('not_valid_gst');
			$('#enter_gst_pop_3yr input[name=gst_num]').val();
			return true;
		}else{
			$('#enter_gst_pop_3yr input[name=gst_num]').addClass('not_valid_gst');
			$('#enter_gst_pop_3yr input[name=gst_num]').focus();
			return false;	
		}
	});

	$("[name='btnpay']").on('click', function() {		
		var targetmodal = $(this).data('target');
		var discount = $(this).parent().find('.hidden_discount').val();
		$(targetmodal).find('.hidden_discount').val(discount);
	});
	$("a[data-target='#addRemoveModal']").on('click', function() {		
		$("#addRemoveModal .info-more-items").hide();
	});

});

function alertAddMaxItems(document_item_allowed,action='add'){
	var member_type = 'basic';
	if(member_type === "premium"){
		if (action == 'edit') {
            var html = `<div>You can add Max ${document_item_allowed} items in Single document.</div>`;
        } else {
            var html = `<div>You can add Max ${document_item_allowed} items in Single document.</div>`;
        }
        Swal.fire({ title: 'Maximum Limit Reached', html: html, icon: 'warning', confirmButtonText: 'Ok', focusConfirm: false });
	}else{
		if(action == 'edit'){
			var html = `<div>To edit this invoice </div>
					<div>please upgrade your membership !</div>
					<span class="upto">(The free plan allows editing invoices with a maximum of ${document_item_allowed} items)</span>`;
		}else{
			var html = `<div>To add more items </div>
					<div>please upgrade your membership !</div>
					<span class="upto">(On Premium membership, you can add up to ${document_item_allowed} items)</span>`;
		}
		$('#addRemoveModal .info-more-items').html(html).show();
		$('#addRemoveModal').modal('show');
	}
	
}

</script>
                <!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-WKL66NX');</script>
<!-- End Google Tag Manager -->        
        <div class="navbar navbar-fixed-top">
            <div class="navbar-inner">
                <div class="container">
                    <a class="brand texttitle" href="home.php">
                        ANAND ASSOCIATES                    </a>

                    <div class="nav-collapse session-and-logout">

                        <ul class="nav pull-right">
                            <li>
                                <div class="session-box">
                                    <form method="post" action="" name="myFormSession">
                                        <div class="dropdown bill-session-new-tab">
                                            <a data-toggle="dropdown" href="#" class="btn dropdown-toggle" style="justify-content: space-between;">F.Y.
                                                2025-2026                                                <svg width="20" height="20" style="scale: 0.8;"><use href="svg-icon/icons.svg#caret-down-svg-icon"></use></svg>
                                            </a>
                                            <ul class="dropdown-menu pull-right">
                                                                                                    <li style="text-align: left;" class="list-sec"><a href="#"
                                                            data-session="_2017_2018" >F.Y.
                                                            2017-2018</a>
                                                    </li>
                                                    <hr class="hrcl">
                                                                                                    <li style="text-align: left;" class="list-sec"><a href="#"
                                                            data-session="_2018_2019" >F.Y.
                                                            2018-2019</a>
                                                    </li>
                                                    <hr class="hrcl">
                                                                                                    <li style="text-align: left;" class="list-sec"><a href="#"
                                                            data-session="_2019_2020" >F.Y.
                                                            2019-2020</a>
                                                    </li>
                                                    <hr class="hrcl">
                                                                                                    <li style="text-align: left;" class="list-sec"><a href="#"
                                                            data-session="_2020_2021" >F.Y.
                                                            2020-2021</a>
                                                    </li>
                                                    <hr class="hrcl">
                                                                                                    <li style="text-align: left;" class="list-sec"><a href="#"
                                                            data-session="_2021_2022" >F.Y.
                                                            2021-2022</a>
                                                    </li>
                                                    <hr class="hrcl">
                                                                                                    <li style="text-align: left;" class="list-sec"><a href="#"
                                                            data-session="_2022_2023" >F.Y.
                                                            2022-2023</a>
                                                    </li>
                                                    <hr class="hrcl">
                                                                                                    <li style="text-align: left;" class="list-sec"><a href="#"
                                                            data-session="_2023_2024" >F.Y.
                                                            2023-2024</a>
                                                    </li>
                                                    <hr class="hrcl">
                                                                                                    <li style="text-align: left;" class="list-sec"><a href="#"
                                                            data-session="_2024_2025" >F.Y.
                                                            2024-2025</a>
                                                    </li>
                                                    <hr class="hrcl">
                                                                                                    <li style="text-align: left;" class="list-sec"><a href="#"
                                                            data-session="_2025_2026" class="active">F.Y.
                                                            2025-2026</a>
                                                    </li>
                                                    
                                                                                            </ul>
                                        </div>
                                    </form>
                                </div>
                            </li>
                            <li>
                                <div>
                                    <a href="#ShortCutKeyModal" data-toggle="modal" class="viewShortKey pull-right">
                                        <svg width="24" height="24">
                                            <use href="svg-icon/icons.svg#keyboard-svg-icon"></use>
                                        </svg>
                                    </a>
                                </div>
                            </li>
                                                            <li>
                                    <div class=" dropdown notification-dropdown"
                                        style="float: right;padding:0;margin-left: 15px;">
                                        <a class=" viewNotifications pull-right  dropdown-toggle dropdown"
                                            data-toggle="dropdown">
                                            <svg width="24" height="24">
                                                <use href="svg-icon/icons.svg#notification-svg-icon"></use>
                                            </svg>
                                                                                    </a>
                                        <div class="dropdown-menu">
                                            <div class="dropdown-list">
                                                                                                        <div
                                                            class="dropdown-item   version_update">
                                                            <div class="icon">
                                                                <img src="assets/svgs/version_update.svg" alt="SVG Icon"
                                                                    class="svg-icon">
                                                            </div>
                                                            <div class="notification-content">
                                                                <p class="notification-title">New Update Available!</p>
                                                                <p class="notification-time">27-Feb-25 06:10 AM</p>
                                                                <p class="notification-msg">New UI and improvements have been released. Check out the full details in the <a target="_blank" href="https://bill.gogstbill.com/gst/change-log.php">Change Log</a>.</p>
                                                                <div class="notification-action-btn action-btn">
                                                                    </div>
                                                            </div>
                                                        </div>
                                                                                                            <div
                                                            class="dropdown-item   version_update">
                                                            <div class="icon">
                                                                <img src="assets/svgs/version_update.svg" alt="SVG Icon"
                                                                    class="svg-icon">
                                                            </div>
                                                            <div class="notification-content">
                                                                <p class="notification-title">New Update Available!</p>
                                                                <p class="notification-time">18-Feb-25 06:17 AM</p>
                                                                <p class="notification-msg">New features and improvements have been released. Check out the full details in the <a target="_blank" href="https://bill.gogstbill.com/gst/change-log.php">Change Log</a>.</p>
                                                                <div class="notification-action-btn action-btn">
                                                                    </div>
                                                            </div>
                                                        </div>
                                                                                                </div>
                                            <input type="hidden" name="last_notification_time" id="last_notification_time"
                                                value="">
                                            <div class="dropdown-footer">
                                                <a href="list-notifications.php" class="view-all-notification">View all</a>
                                            </div>
                                        </div>
                                    </div>
                                </li>
                                                        <li class="dropdown menu_account tmp">
                                <a href="#MenuSideBarModal" data-toggle="modal" class="pull-right">
                                    <svg width="24" height="24">
                                        <use href="svg-icon/icons.svg#user-svg-icon"></use>
                                    </svg>
                                </a>
                            </li>
                        </ul>
                        <div class="dropdown create-new-tab" style="float: right;">
                            <a data-toggle="dropdown" href="#" class="btn dropdown-toggle"
                                style="display:flex;align-items: center;justify-content: space-between;">
                                <div class="d-flex">
                                    <svg width="24" height="24">
                                        <use href="svg-icon/icons.svg#plus-icon-svg-icon"></use>
                                    </svg><span style="margin-left:5px;"> Create </span>
                                </div>
                                <svg width="20" height="20" style="scale: 0.8;"><use href="svg-icon/icons.svg#caret-down-svg-icon"></use></svg>
                            </a>
                            <ul class="dropdown-menu pull-right">
                                <li style="text-align: left;" class="list-sec"><a href="invoicebill.php">Sale
                                        Invoice</a></li>
                                <hr class="hrcl">
                                <li style="text-align: left;" class="list-sec"><a
                                        href="purchaseinvoicebill.php">Purchase Invoice </a></li>
                                <hr class="hrcl">
                                <li style="text-align: left;" class="list-sec"><a href="quotationbill.php">Quotation</a>
                                </li>
                                <hr class="hrcl">
                                <li style="text-align: left;" class="list-sec"><a href="challanbill.php">Delivery
                                        Challan</a></li>
                                <hr class="hrcl">
                                <li style="text-align: left;" class="list-sec"><a href="proformabill.php">Proforma</a>
                                </li>
                                <hr class="hrcl">
                                <li style="text-align: left;" class="list-sec"><a href="purchaseorderbill.php">Purchase
                                        Order</a></li>
                                <hr class="hrcl">
                                <li style="text-align: left;" class="list-sec"><a href="saleorderbill.php">Sale
                                        Order</a></li>
                                <hr class="hrcl">
                                <li style="text-align: left;" class="list-sec"><a href="jobworkbill.php">Job Work</a>
                                </li>
                                <hr class="hrcl">
                                <li style="text-align: left;" class="list-sec"><a href="creditbill.php">Credit Note</a>
                                </li>
                                <hr class="hrcl">
                                <li style="text-align: left;" class="list-sec"><a href="debitbill.php">Debit Note</a>
                                </li>
                            </ul>
                        </div>

                        <!-- <div class="shortcut-icon"><i class="fa fa-keyboard"></i></div> -->
                    </div>
                    <!--/.nav-collapse -->
                </div> <!-- /container -->
            </div> <!-- /navbar-inner -->
        </div> <!-- /navbar -->

        <div class="subnavbar"
            style="margin-bottom: 5px;"
            >
            <div class="subnavbar-inner">
                <div class="container">
                    <div class="mobile-nav-logo"><img src="img/inverted.png?update" alt="Smart GST Billing Software" title="Smart GST Billing Software"></div>
	<ul class="mainnav">
				<li  >
					<a href="home.php"><span class="fa-icon-svg"><svg><use href="svg-icon/icons.svg#dashboard-svg-icon"></use></svg></span>
					<span>Dashboard</span><span class="shortcut_key_ctrl">d</span></a>	    				
				</li>
				
								<li >
					<a href="list-company.php"><span class="fa-icon-svg"><svg><use href="svg-icon/icons.svg#customer-svg-icon"></use></svg></span>
					<span>Customer / Vendor</span><span class="shortcut_key_ctrl">o</span></a>	    				
				</li>
												<li class="dropdown subnavbar-open-right 
					 
					 
					" >
					<a  class="dropdown-toggle" data-toggle="dropdown"><span class="fa-icon-svg"><svg><use href="svg-icon/icons.svg#product-svg-icon"></use></svg></span>
					<span style="line-height: 100%;">Products / Services</span></a>	   
					<ul class="dropdown-menu">
                        <li><a href="list-product.php">Products / Services<span class="shortcut_key_ctrl">r</span></a></li>
                        <li><a href="list-category.php">Product Group</a></li>
                        <li class="menu_sep_hr"><a><hr></a></li>
						<li><a href="manage-stock.php">Stock</a></li>
                    </ul>   					
				</li>
												<li 					class="active"				>
					<a href="invoicedetail.php"><span class="fa-icon-svg"><svg><use href="svg-icon/icons.svg#saleinvoice-svg-icon"></use></svg></span>
					<span style="line-height: 100%;">Sale<br>Invoice</span><span class="shortcut_key">s</span></a>	    				
				</li>
												<li  
					   >
					<a href="purchaseinvoicedetail.php"><span class="fa-icon-svg"><svg><use href="svg-icon/icons.svg#purchase-svg-icon"></use></svg></span>
					<span style="line-height: 100%;">Purchase<br>Invoice</span><span class="shortcut_key">p</span></a>	    				
				</li>
												<li class="dropdown subnavbar-open-right 
					 "    >
					<a  class="dropdown-toggle" data-toggle="dropdown"><span class="fa-icon-svg"><svg><use href="svg-icon/icons.svg#payment-svg-icon"></use></svg></span>
					<span style="line-height: 100%;">Payment</span></a>	   
					<ul class="dropdown-menu">
                        <li><a href="list-paymentreceipt.php?type=inward">Inward Payment (Sales Inv.)<span class="shortcut_key">i</span></a></li>
						<li><a href="list-paymentreceipt.php?type=outward">Outward Payment (Purchase Inv.)<span class="shortcut_key">o</span></a></li>
                    </ul>   					
				</li>
												<li class="dropdown subnavbar-open-right																				"
				>
					<a  class="dropdown-toggle" data-toggle="dropdown"><span class="fa-icon-svg"><svg><use href="svg-icon/icons.svg#expense-svg-icon"></use></svg></span>
					<span style="line-height: 100%;">Expense <br> Income</span></a>	   
					<ul class="dropdown-menu">
                        <li><a href="list-dailyexpense.php">Daily Expenses<span class="shortcut_key">d</span></a></li>							<li><a href="list-otherincome.php">Other Income<span class="shortcut_key">t</span></a></li>	                    </ul>   					
				</li>
								<li class="dropdown subnavbar-open-right																																																																																								"
				>
					<a  class="dropdown-toggle" data-toggle="dropdown"><span class="fa-icon-svg"><svg><use href="svg-icon/icons.svg#otheredoc-svg-icon"></use></svg></span>
					<span style="line-height: 100%;">Other<br>Documents</span></a>	   
					<ul class="dropdown-menu">
                        <li><a href="quotationdetail.php">Quotation<span class="shortcut_key">q</span></a></li>						<li><a href="proformadetail.php">Proforma<span class="shortcut_key">r</span></a></li>						<li><a href="challandetail.php">Delivery Challan<span class="shortcut_key">e</span></a></li>							<li><a href="purchaseorderdetail.php">Purchase Order<span class="shortcut_key">u</span></a></li>						<li><a href="saleorderdetail.php">Sale Order<span class="shortcut_key">i</span></a></li>						<li><a href="jobworkdetail.php">Job Work<span class="shortcut_key">j</span></a></li>						                        <li class="locked"><a data-toggle="modal" data-target="#addRemoveModal">Letters</a></li>                        <li class="locked"><a data-toggle="modal" data-target="#addRemoveModal">Bank Ledger</a></li>                        <li class="locked"><a data-toggle="modal" data-target="#addRemoveModal">Packing List &nbsp;</a></li>						<li class="locked"><a data-toggle="modal" data-target="#addRemoveModal">Manufacture &nbsp;<span class="label">Beta</span></a></li>
													<li class="menu_sep_hr"><a><hr></a></li>
												<li><a href="creditdetail.php">Credit Note<span class="shortcut_key">c</span></a></li>						<li><a href="debitdetail.php">Debit Note<span class="shortcut_key">b</span></a></li>						<li class="menu_sep_hr"><a><hr></a></li>												<li class="locked"><a  data-toggle="modal" data-target="#addRemoveModal">Multi Currency Invoice<span class="shortcut_key">m</span></a></li>						                    </ul>   					
				</li>
												
												<li class="dropdown subnavbar-open-right last-header-option"     >
					<a  class="dropdown-toggle" data-toggle="dropdown"><span class="fa-icon-svg"><svg><use href="svg-icon/icons.svg#report-svg-icon"></use></svg></span>
					<span style="line-height: 100%;">Report</span></a>	   
					<ul class="dropdown-menu">
					                        <li class="menu_heading">Sales Reports</li>
						<li><a href="report-sales.php">Sales</a></li>	
						<li><a href="report-sales_outstanding.php?">Sales Outstanding</a></li>
						<li><a href="report-sales_product_report.php">Sales Product Report</a></li>						
						<li><a href="report-inward_payment.php">Inward Payment</a></li>
																		<li class="menu_heading">Purchase Reports</li>
						<li><a href="report-purchase.php">Purchase</a></li>
						<li><a href="report-purchase_outstanding.php">Purchase Outstanding</a></li>
						<li><a href="report-purchase_product_report.php">Purchase Product Report</a></li>						
						<li><a href="report-outward_payment.php">Outward Payment</a></li>
																		<li class="menu_heading">Other Reports</li>
																		<li><a href="report-customer_ledger.php">Company Ledger</a></li>
																		<li><a href="report-company_outstanding.php">Company Outstanding</a></li>
																		<li><a href="report-profit_loss.php">Profit & Loss Report</a></li>
																		<li><a href="report-stock.php">Stock Report</a></li>
																		<li><a href="report-product.php">Product Report</a></li>
																		<li><a href="report-daily_expense.php">Daily Expenses</a></li>
																		<li><a href="report-other_income.php">Other Income</a></li>
												<li class="menu_heading">GST Reports</li>
						<li><a href="gstr1.php">GSTR-1</a></li>							<li><a href="gstr2b.php">GSTR-2B</a></li>							<li><a href="gstr3b.php">GSTR-3B</a></li>                      </ul>
					
					
				</li>
												<li class="settings_menu_mobile dropdown subnavbar-open-right 
																																																																																					" >
					<a  class="dropdown-toggle" data-toggle="dropdown"><span class="fa-icon-svg"><svg><use href="svg-icon/icons.svg#settings-svg-icon"></use></svg></span>
					<span style="line-height: 100%;">Settings</span></a>	   
					<ul class="dropdown-menu">
						<li><a href="list-setting.php">Membership</a></li>						<li class="locked"><a  data-toggle="modal" data-target="#addRemoveModal">Credits</a></li>						<li><a href="edit-userdetail.php">Login & Security</a></li>						<li><a href="edit-eway.php">E-way Bill & E-Invoice</a></li>						<li><a href="settings-whatsapp.php">WhatsApp Options</a></li>
                        <li><a href="edit-organisationdetail.php">Business Profile</a></li>						<li><a  data-toggle="modal" data-target="#addRemoveModal"> Staff Account</a></li>						
						<li ><a href="file-log.php">Go Drive</a></li>                        <li><a href="export-file.php">Export Data</a></li>								<li  ><a href="activity-log.php">Activity Log</a></li>
								                        <li class=' locked'><a href="settings-digital-signature.php">Digital Sign</a></li>						
                        <li><a href="smtp-email-settings.php">Email Options</a></li>                        
						<li class=" " ><a href="settings-general-option.php"> General Options</a></li>						<li class=" " ><a href="settings-product-option.php"> Product & Stock Options</a></li>						<li class=" " ><a href="settings-printtemplate-option.php"> Print Template</a></li>						<li class=" " ><a href="settings-print-option.php"> Print Options</a></li>						<li class=" " ><a href="settings-bank-detail.php"> Bank Details</a></li>						<li class=" " ><a href="settings-document-option.php"> Document Options</a></li>						<li class="locked"><a  data-toggle="modal" data-target="#addRemoveModal"> Shipping & Envelope Options</a></li>						<li class=" " ><a href="settings-termscondition-option.php"> Terms and Condition</a></li>						<li class="locked"><a  data-toggle="modal" data-target="#addRemoveModal">Translation Options</a></li>						<li class="locked"><a  data-toggle="modal" data-target="#addRemoveModal">Email & Whatsapp Templates</a></li>						<li class="locked"><a  data-toggle="modal" data-target="#addRemoveModal">Payment Reminder</a></li>						<li class="hide_unser_tab"><a href="edit-custom-header.php">Design Custom Header</a></li>						
																		
                    </ul>   					
				</li>
								<li class="notification_menu_mobile ">
					<a href="list-notifications.php" class="mobile-notification"><span class="fa-icon-svg"><svg><use href="svg-icon/icons.svg#notification-svg-icon"></use></svg></span>
					<span style="line-height: 22px;margin-left: 5px;">Notification</span>
											</a>	    				
				</li>
								
			
<li class="referafrnd mobile-nav-show list-sec " >
	<a href="refer-a-friend.php"><span class="fa-icon-svg"> <svg width="24" height="24">
                                        <use href="svg-icon/icons.svg#refere-svg-icon"></use>
                                    </svg></span><span style="line-height: 100%;"> Refer a friend</span></a>
</li>
<li class="mobile-nav-show mobile-nav-logout">
	<div class="session-and-logout">
		<div class="session-box">
			<form method="post" action="" name="myFormSession">
				<div class="dropdown bill-session-new-tab">
				<a data-toggle="dropdown" href="#" class="btn dropdown-toggle" style="padding-top: 10px;padding-bottom: 10px;">F.Y. 2025-2026</a>
					<ul class="dropdown-menu pull-right">
													<li style="text-align: left;"class="list-sec" ><a href="#" data-session="_2017_2018"  >F.Y. 2017-2018</a></li>
							<hr class="hrcl">									
												<li style="text-align: left;"class="list-sec" ><a href="#" data-session="_2018_2019"  >F.Y. 2018-2019</a></li>
							<hr class="hrcl">									
												<li style="text-align: left;"class="list-sec" ><a href="#" data-session="_2019_2020"  >F.Y. 2019-2020</a></li>
							<hr class="hrcl">									
												<li style="text-align: left;"class="list-sec" ><a href="#" data-session="_2020_2021"  >F.Y. 2020-2021</a></li>
							<hr class="hrcl">									
												<li style="text-align: left;"class="list-sec" ><a href="#" data-session="_2021_2022"  >F.Y. 2021-2022</a></li>
							<hr class="hrcl">									
												<li style="text-align: left;"class="list-sec" ><a href="#" data-session="_2022_2023"  >F.Y. 2022-2023</a></li>
							<hr class="hrcl">									
												<li style="text-align: left;"class="list-sec" ><a href="#" data-session="_2023_2024"  >F.Y. 2023-2024</a></li>
							<hr class="hrcl">									
												<li style="text-align: left;"class="list-sec" ><a href="#" data-session="_2024_2025"  >F.Y. 2024-2025</a></li>
							<hr class="hrcl">									
												<li style="text-align: left;"class="list-sec" ><a href="#" data-session="_2025_2026" class="active" >F.Y. 2025-2026</a></li>
																
										</ul>
				</div>
			</form>
		</div>
	</div>
</li>

<hr class="mobile-nav-show hrcl">
<h5 class="mobile-nav-show quicksupporttxt">Quick Support</h5>
<li class="mobile-nav-show list-sec">
	<div class="contact-info-section">
		<div class="contact-info-section-icon">
			<svg width="24" height="24" style="scale: 1.1;">
	            <use href="svg-icon/icons.svg#whatsapp-svg-icon"></use>
	        </svg>
		</div>
		<div class="contact-info-section-content">
			<a href="https://api.whatsapp.com/send/?phone=+917043146478&amp;text=Hi, I need help " target="__blank">+91 7043146478</a>
			<p>10 AM to 7 PM - Everyday</p>
		</div>
	</div>
</li>
<li class="mobile-nav-show list-sec">
	<div class="contact-info-section">
		<div class="contact-info-section-icon">
			 <svg width="24" height="24">
                <use href="svg-icon/icons.svg#message-svg-icon"></use>
            </svg>
		</div>
		<div class="contact-info-section-content">
			<a href="/cdn-cgi/l/email-protection#731b161f0333141c140007111a1f1f5d101c1e"><span class="__cf_email__" data-cfemail="fd9598918dbd9a929a8e899f949191d39e9290">[email&#160;protected]</span></a>
			<p>We usually reply within 1 working day</p>
		</div>
	</div>
</li>
<li class="mobile-nav-show list-sec">
	<div class="contact-info-section">
		<div class="contact-info-section-icon">
			<svg width="24" height="24">
                <use href="svg-icon/icons.svg#books-svg-icon"></use>
            </svg>
		</div>
		<div class="contact-info-section-content">

		<a class="ViewKnowledgeModal" data-baseLink="knowledge-base.php">Knowledge Base</a>
			<!-- <a href="https://gogstbill.com/knowledge-base/" target="_blank">Knowledge Base</a> -->
			<p>100+ Questions answered with Screenshots</p>
		</div>
	</div>
</li>
<li class="mobile-nav-show list-sec">
	<div class="seprator"></div>
	<div class="generate-pin-box">
		<a class="generate-support-pin">Generate Support PIN</a>
	</div>
	</li>
<li  class="mobile-nav-show mobile-nav-logout  btn-full ">
	<a class="logout-btn"  href="logout.php"><svg width="24" height="24"><use href="svg-icon/icons.svg#logout-svg-icon"></use></svg>Logout</a>
</li>
</ul>                </div> <!-- /container -->
            </div> <!-- /subnavbar-inner -->
        </div> <!-- /subnavbar -->

        <div class="main">
            <div class="main-inner">
                                    <div class="container">
                        <div class="row">
                            <div class="span12">
                                <center>

                                                                                <!-- gst header after login -->
                                            <ins class="adsbygoogle" style="display:inline-block;width:728px;height:90px"
                                                data-ad-client="ca-pub-7485845865785659" data-ad-slot="9888667777">
                                            </ins>
                                            <script data-cfasync="false" src="/cdn-cgi/scripts/5c5dd728/cloudflare-static/email-decode.min.js"></script><script>
                                                (adsbygoogle = window.adsbygoogle || []).push({});
                                            </script>
                                                                        </center>
                            </div>
                        </div>
                    </div>
                
                



                <div class="container">
                    <div><div id="MenuSideBarModal" class="modal fade popup_right_slider " role="dialog" style="display: none;">
  <div class="modal-dialog">
    <form class="form-horizontal" method="post">
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <div class="header-section">
            <div class="logo">
              <div class="">
                                <span class="company-logo" >AN</span>

              </div>
              <div class="title">
                <span>ANAND ASSOCIATES</span>
                <p>Admin</p>
              </div>
            </div>
            <button type="button" class="btn btn-default btn_close" data-dismiss="modal"><svg width="20" height="20">
                <use href="svg-icon/icons.svg#closebtn-svg-icon"></use>
              </svg></button>
          </div>


        </div>
        <div class="modal-body">
          <div class="menu-header">
            <div class="main-info">
              <div style="justify-content: end;">
                                <a href="logout.php" class="logout-btn"><svg width="24" height="24">
                    <use href="svg-icon/icons.svg#logout-svg-icon"></use>
                  </svg> Log Out</a>
              </div>
              <hr>
              <a href="list-setting.php" class="plan">
                <span><svg width="24" height="24">
                    <use href="svg-icon/icons.svg#plan-svg-icon"></use>
                  </svg>
                  Plan</span>
                <span>Basic</span>
              </a>
              <hr>
              <a href="credits.php" class="credit">
                <span><svg width="24" height="24">
                    <use href="svg-icon/icons.svg#credit-svg-icon"></use>
                  </svg>
                  Credit</span>
                <span>0</span>
              </a>
              <hr>
                            <a href="file-log.php" class="storage">
                                <span><svg width="24" height="24">
                    <use href="svg-icon/icons.svg#folder-svg-icon"></use>
                  </svg>Go Storage</span>
                <span class="go_storage"><svg width="20" height="20" class="svg-icon" data-storage-toggle="tooltip"
                      title="Storage Full" ><use href="svg-icon/icons.svg#limit-warning-svg-icon"></use></svg>0KB / 0KB                </span>
              </a>
                          </div>
            <div class="actions">
              <a href="list-setting.php">
                <div><svg width="24" height="24">
                    <use href="svg-icon/icons.svg#settings-svg-icon"></use>
                  </svg></div><span>Setting</span>
              </a>
              <a href="list-staffAccount.php">
                <div><svg width="24" height="24">
                    <use href="svg-icon/icons.svg#staff-user-svg-icon"></use>
                  </svg></div>
                <sapn>Staff Account</sapn>
              </a>
              <a href="refer-a-friend.php">
                <div><svg width="24" height="24">
                    <use href="svg-icon/icons.svg#refere-svg-icon"></use>
                  </svg></div>
                <sapn>Refer a friend </sapn>
              </a>
            </div>
            <div>
              <h3>Quick Support</h3>
              <div class="support">
                <a href="https://api.whatsapp.com/send/?phone=+917043146478&amp;text=Hi, I need help " target="__blank" class="support-item">
                  <div><svg width="24" height="24">
                      <use href="svg-icon/icons.svg#whatsapp-svg-icon"></use>
                    </svg></div>
                  <p><span>+91 7043146478</span><br><small>10 AM to 7 PM - Everyday</small></p>
                </a>
                <a href="/cdn-cgi/l/email-protection#88e0ede4f8c8efe7effbfceae1e4e4a6ebe7e5" class="support-item">
                  <div><svg width="24" height="24">
                      <use href="svg-icon/icons.svg#message-svg-icon"></use>
                    </svg></div>
                  <p><span><span class="__cf_email__" data-cfemail="a4ccc1c8d4e4c3cbc3d7d0c6cdc8c88ac7cbc9">[email&#160;protected]</span></span><br><small class="">We usually reply within 1 working day</small></p>
                </a>
              </div>
              <a data-baselink="knowledge-base.php" class="knowledge-base-section ViewKnowledgeModal">
                <div><svg width="24" height="24">
                    <use href="svg-icon/icons.svg#books-svg-icon"></use>
                  </svg></div>
                <p><span>Knowledge Base</span><br><small>100+ Questions answered with Screenshots</small></p>
              </a>
                                      <div class="generate-pin-box">
                            <a class="generate-support-pin">Generate Support PIN</a>
                        </div>
                                              <div class="upgradelink">
                                                  </div>
              <div class="anydesk-section">
                <a class="socialicon" target="_blank" href="https://download.anydesk.com/AnyDesk.exe"><svg width="31" height="21">
                    <use href="svg-icon/icons.svg#anydesk-svg-icon"></use>
                  </svg><span>Download AnyDesk</span></a>
              </div>
            </div>
          </div>
          <div class="menu-footer">
            <div class="app-links">
              <div class="qr_container">
                <img src="img/all_new_svg/top-header/downloadappqr.svg" alt="" class="qr_img">
                <span>SCAN QR CODE</span>
              </div>
              <div class="verticalhr"></div>
              <div class="play-btn">
                <h4>Download App</h4>
                <div class="play-btn-1">
                  <a href="https://play.google.com/store/apps/details?id=com.ifox.gogstbill" target="blenk"><img src="img/all_new_svg/top-header/google-play-btn.svg" alt=""></a>
                </div>
                <div class="play-btn-2">
                  <a href="https://apps.apple.com/tr/app/go-gst-bill/id6446317558?platform=iphone" target="blenk"><img src="img/all_new_svg/top-header/app-store-btn.svg" alt=""></a>
                </div>
              </div>
            </div>
            <hr style="border-bottom:1px solid #00000026;">
            <div class="social-link">
              <h4>Follow Us</h4>
              <div class="sociallink-icon">
                <a href="https://www.facebook.com/gogstbill" target="_blank"><svg width="24" height="24">
                    <use href="svg-icon/icons.svg#facebook-svg-icon"></use>
                  </svg></a>
                <a href="https://www.youtube.com/channel/UCTp5ti6LFiVa887z0NQGG0A" target="_blank"><svg width="24" height="24">
                    <use href="svg-icon/icons.svg#youtube-svg-icon"></use>
                  </svg></a>
                <a href="https://api.whatsapp.com/send/?phone=+917043146478&text=Hi, I need help " target="_blank"><svg width="24" height="24">
                    <use href="svg-icon/icons.svg#whatsapp-social-svg-icon"></use>
                  </svg></a>
                <a href="https://www.twitter.com/gogstbill" target="_blank"><svg width="24" height="24">
                    <use href="svg-icon/icons.svg#twitter-svg-icon"></use>
                  </svg></a>
                <a href="https://www.linkedin.com/company/gogstbill/" target="_blank"><svg width="24" height="24">
                    <use href="svg-icon/icons.svg#linkedin-svg-icon"></use>
                  </svg></a>
                <a href="https://www.instagram.com/gogstbill" target="_blank"><svg width="24" height="24">
                    <use href="svg-icon/icons.svg#instagram-svg-icon"></use>
                  </svg></a>
              </div>
            </div>
          </div>

        </div>
        </div>
    </form>
  </div>
</div> </div>                                                       
                    <div><div id="ShortCutKeyModal" class="modal fade popup_right_slider " role="dialog" style="display: none;">
  <div class="modal-dialog">
  <form class="form-horizontal" method="post" id="ShortCutKeyModalForm"   >
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="btn btn-default btn_close" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg></button>
        <h4 class="modal-title">Shortcut Key</h4>
                      <input type="checkbox" class="checkbox shortctkeyoption" id="shortctkeyoption" checked="checked" name="shortctkeyoption">
              <label for="shortctkeyoption"><span></span></label>
              <input type="hidden"  class="keyactive" value="0" />
                    
      </div>
      <div class="modal-body">
      	    <div class="">
              <div class="view-control-label viewKeylist" style="display: block;">
                <div class="control-group">
                  <label for="name" class="control-label">Dashboard</label>
                  <div class="controls">
                    <span class="label">Ctrl</span>
                    <span class="label">d</span>
                  </div> 
                  <div class="control">
                    <label for="name" class="control-label">- Refresh Dashboard</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">f</span>
                    </div> <!-- /controls -->
                  </div><!-- /controls -->
                </div> <!-- /control-group -->
                <div class="control-group">
                  <label for="name" class="control-label">Customer / Vendor</label>
                  <div class="controls">
                    <span class="label">Ctrl</span>
                    <span class="label">o</span>
                  </div> <!-- /controls -->
                  <div class="control">
                    <label for="name" class="control-label">- Add Customer / Vendor</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">a</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->
                  <div class="control">
                    <label for="name" class="control-label">- Search Customer / Vendor</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">f</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->
                  
                </div> <!-- /control-group -->
                 <div class="control-group">
                  <label for="name" class="control-label">Product / Services</label>
                  <div class="controls">
                    <span class="label">Ctrl</span>
                    <span class="label">r</span>
                  </div> <!-- /controls -->
                  <div class="control">
                    <label for="name" class="control-label">- Add Product / Services</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">a</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->
                  <div class="control">
                    <label for="name" class="control-label">- Search Product / Services</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">f</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->
                </div> <!-- /control-group -->
                <div class="control-group">
                  <label for="name" class="control-label">Sale Invoice</label>
                  <div class="controls">
                    <span class="label">Alt</span>
                    <span class="label">s</span>
                  </div> <!-- /controls -->
               
                  <div class="control">
                    <label for="name" class="control-label">- Create Sale Invoice</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">a</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->
                  <div class="control">
                    <label for="name" class="control-label">- Search Sale Invoice</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">f</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->
                  <div class="control">
                    <label for="name" class="control-label">- Summary Sale Invoice</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">i</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->

                </div> <!-- /control-group -->
                <div class="control-group">
                  <label for="name" class="control-label">Purchase Invoice</label>
                  <div class="controls">
                    <span class="label">Alt</span>
                    <span class="label">p</span>
                  </div> <!-- /controls -->

                  <div class="control">
                    <label for="name" class="control-label">- Create Purchase Invoice</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">a</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->
                  <div class="control">
                    <label for="name" class="control-label">- Search Purchase Invoice</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">f</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->
                  <div class="control">
                    <label for="name" class="control-label">- Summary Purchase Invoice</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">i</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->

                </div> <!-- /control-group -->
                <div class="control-group">
                  <label for="name" class="control-label">Quotation</label>
                  <div class="controls">
                    <span class="label">Alt</span>
                    <span class="label">q</span>
                  </div> <!-- /controls -->

                  <div class="control">
                    <label for="name" class="control-label">- Create Quotation</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">a</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->
                  <div class="control">
                    <label for="name" class="control-label">- Search Quotation</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">f</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->
                  <div class="control">
                    <label for="name" class="control-label">- Summary Quotation</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">i</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->

                </div> <!-- /control-group -->
                <div class="control-group">
                  <label for="name" class="control-label">Job Work</label>
                  <div class="controls">
                    <span class="label">Alt</span>
                    <span class="label">j</span>
                  </div> <!-- /controls -->

                  <div class="control">
                    <label for="name" class="control-label">- Create Job Work</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">a</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->
                  <div class="control">
                    <label for="name" class="control-label">- Search Job Work</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">f</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->
                  <div class="control">
                    <label for="name" class="control-label">- Summary Job Work</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">i</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->

                </div> <!-- /control-group -->
                <div class="control-group">
                  <label for="name" class="control-label">Proforma Invoice</label>
                  <div class="controls">
                    <span class="label">Alt</span>
                    <span class="label">r</span>
                  </div> <!-- /controls -->

                  <div class="control">
                    <label for="name" class="control-label">- Create Proforma Invoice</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">a</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->
                  <div class="control">
                    <label for="name" class="control-label">- Search Proforma Invoice</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">f</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->
                  <div class="control">
                    <label for="name" class="control-label">- Summary Proforma Invoice</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">i</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->

                </div> <!-- /control-group -->
                <div class="control-group">
                  <label for="name" class="control-label">Delivery Challan</label>
                  <div class="controls">
                    <span class="label">Alt</span>
                    <span class="label">e</span>
                  </div> <!-- /controls -->

                  <div class="control">
                    <label for="name" class="control-label">- Create Delivery Challan</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">a</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->
                  <div class="control">
                    <label for="name" class="control-label">- Search Delivery Challan</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">f</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->

                </div> <!-- /control-group -->
                <div class="control-group">
                  <label for="name" class="control-label">Purchase Order</label>
                  <div class="controls">
                    <span class="label">Alt</span>
                    <span class="label">u</span>
                  </div> <!-- /controls -->

                  <div class="control">
                    <label for="name" class="control-label">- Create Purchase Order</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">a</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->
                  <div class="control">
                    <label for="name" class="control-label">- Search Purchase Order</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">f</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->
                  <div class="control">
                    <label for="name" class="control-label">- Summary Purchase Order</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">i</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->

                </div> <!-- /control-group -->
                <div class="control-group">
                  <label for="name" class="control-label">Sale Order</label>
                  <div class="controls">
                    <span class="label">Alt</span>
                    <span class="label">i</span>
                  </div> <!-- /controls -->

                  <div class="control">
                    <label for="name" class="control-label">- Create Sale Order</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">a</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->
                  <div class="control">
                    <label for="name" class="control-label">- Search Sale Order</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">f</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->
                  <div class="control">
                    <label for="name" class="control-label">- Summary Sale Order</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">i</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->

                </div> <!-- /control-group -->
                <div class="control-group">
                  <label for="name" class="control-label">Credit Note</label>
                  <div class="controls">
                    <span class="label">Alt</span>
                    <span class="label">c</span>
                  </div> <!-- /controls -->

                  <div class="control">
                    <label for="name" class="control-label">- Create Credit Note</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">a</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->
                  <div class="control">
                    <label for="name" class="control-label">- Search Credit Note</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">f</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->
                  <div class="control">
                    <label for="name" class="control-label">- Summary Credit Note</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">i</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->

                </div> <!-- /control-group -->
                <div class="control-group">
                  <label for="name" class="control-label">Debit Note</label>
                  <div class="controls">
                    <span class="label">Alt</span>
                    <span class="label">b</span>
                  </div> <!-- /controls -->

                  <div class="control">
                    <label for="name" class="control-label">- Create Debit Note</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">a</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->
                  <div class="control">
                    <label for="name" class="control-label">- Search Debit Note</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">f</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->
                  <div class="control">
                    <label for="name" class="control-label">- Summary Debit Note</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">i</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->

                </div> <!-- /control-group -->
                
                <div class="control-group">
                  <label for="name" class="control-label">Multi Currency Invoice</label>
                  <div class="controls">
                    <span class="label">Alt</span>
                    <span class="label">m</span>
                  </div> <!-- /controls -->

                  <div class="control">
                    <label for="name" class="control-label">- Create Multi Currency Invoice</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">a</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->
                  <div class="control">
                    <label for="name" class="control-label">- Search Multi Currency Invoice</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">f</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->

                </div> <!-- /control-group -->

                <div class="control-group">
                  <label for="name" class="control-label">Daily Expenses</label>
                  <div class="controls">
                    <span class="label">Alt</span>
                    <span class="label">d</span>
                  </div> <!-- /controls -->

                  <div class="control">
                    <label for="name" class="control-label">- Add Daily Expenses</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">a</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->
                  <div class="control">
                    <label for="name" class="control-label">- Search Daily Expenses</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">f</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->
                  <div class="control">
                    <label for="name" class="control-label">- Summary Daily Expenses</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">i</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->

                </div> <!-- /control-group -->


                <div class="control-group">
                  <label for="name" class="control-label">Other Income</label>
                  <div class="controls">
                    <span class="label">Alt</span>
                    <span class="label">t</span>
                  </div> <!-- /controls -->

                  <div class="control">
                    <label for="name" class="control-label">- Add Other Income</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">a</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->
                  <div class="control">
                    <label for="name" class="control-label">- Search Other Income</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">f</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->
                  <div class="control">
                    <label for="name" class="control-label">- Summary Other Income</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">i</span>
                    </div> <!-- /controls -->
                  </div> <!-- /controls -->

                </div> <!-- /control-group -->


                <div class="control-group">
                  <label for="name" class="control-label">Sales Report</label>
                  <div class="controls">
                  </div> <!-- /controls -->
                
                 <div class="control">
                    <label for="name" class="control-label">- Customize Report</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">f</span>
                    </div> <!-- /controls -->
                  </div> <!-- /control-group -->
                
                </div> <!-- /control-group -->
              
                <div class="control-group">
                  <label for="name" class="control-label">Sales Outstanding Report</label>
                  <div class="controls">
                  </div> <!-- /controls -->
                
                 <div class="control">
                    <label for="name" class="control-label">- Customize Report</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">f</span>
                    </div> <!-- /controls -->
                  </div> <!-- /control-group -->
                
                </div> <!-- /control-group -->
                
                <div class="control-group">
                  <label for="name" class="control-label">Purchase Report</label>
                  <div class="controls">
                  </div> <!-- /controls -->
                
                 <div class="control">
                    <label for="name" class="control-label">- Customize Report</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">f</span>
                    </div> <!-- /controls -->
                  </div> <!-- /control-group -->
                
                </div> <!-- /control-group -->
                
                <div class="control-group">
                  <label for="name" class="control-label">Purchase Outstanding Report</label>
                  <div class="controls">
                  </div> <!-- /controls -->
                
                 <div class="control">
                    <label for="name" class="control-label">- Customize Report</label>
                    <div class="controls">
                      <span class="label">Ctrl</span>
                      <span class="label">f</span>
                    </div> <!-- /controls -->
                  </div> <!-- /control-group -->
                
                </div> <!-- /control-group -->
                

              </div> <!-- /widget-content -->
            </div> <!-- /widget -->
  
      </div>
      <div class="modal-footer">
			   <button type="button" class="btn btn-default" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg>Close</button>
      </div>
    </div>
	</form>
  </div>
</div>
<script data-cfasync="false" src="/cdn-cgi/scripts/5c5dd728/cloudflare-static/email-decode.min.js"></script><script>
  $(document).on('change','.shortctkeyoption',function(){
    var keyactive = $('.keyactive').val();
    $.ajax({  
        type: "POST",  
        url: "ajaxcall.php",  
        ContentType : 'application/json',
        dataType: 'json',
        data: {action:'updateShortCutKey',isactive:keyactive},
        success: function(data){
          if(keyactive == 0){
            $('.keyactive').val(1);
            $('#ShortCutKeyModal .viewKeylist').css('display','none'); 
            $('.shortcut_key_ctrl').hide();
            $('.shortcut_key').hide();
            shortcutBtn = false;
            shortkeys_fun();
          }else{
            $('.keyactive').val(0);
            $('#ShortCutKeyModal .viewKeylist').css('display','block'); 
            $('.shortcut_key_ctrl').show();
            $('.shortcut_key').show();
            shortcutBtn = true;
            shortkeys_fun();
          } 
         
        },
    });
    
  });
</script></div>
	
	<script>
		var enable_serialno_strict = 1;
		var enable_invoice_in_other_currency = 0;
		var enable_payment_term_option = 0;

		var enable_product_mrp = 0;
		var enable_batch_no = 1;
		var enable_batch_model = 0;
		var enable_batch_size = 0;
		var enable_batch_mfg = 0;
		var enable_batch_expiry = 0;
		var enable_product_code = 0;
		
		var require_product_mrp = 0;
		var require_batch_no = 1;
		var require_batch_model = 0;
		var require_batch_size = 0;
		var require_batch_mfg = 0;
		var require_batch_expiry = 0;
		var require_product_code = 0;
		
		var label_product_mrp = 'MRP';
		var label_batch_no = 'Batch No.';
		var label_batch_model = 'Model No.';
		var label_batch_size = 'Size';
		var label_batch_mfg = 'Mfg. Date';
		var label_batch_expiry = 'Expiry Date';
		var label_product_code = 'Product Code';

		
		var datepicker_batch_mfg = 'monthyear_datepicker';
		var datepicker_batch_expiry = 'monthyear_datepicker';
		var enable_einvoice_options = '0';
		
		var enable_custom_column_formula = '0';
		var custom_column_formula = ``;
		var custom_column_formula_for = 'quantity';
        var custom_column_rounding_by = 2;
		var enableCustomColumnFields = {"enable_custom_column_field1":0,"enable_custom_column_field2":0,"enable_custom_column_field3":0};
		var formateCustomColumnFields = {"formate_custom_column_field1":0,"formate_custom_column_field2":0,"formate_custom_column_field3":0};
		var labelCustomColumnFields = {"label_custom_column_field1":"Custom 1","label_custom_column_field2":"Custom 2","label_custom_column_field3":"Custom 3"};
		var defaultValCustomColumnFields = {"default_value_custom_column_field1":"","default_value_custom_column_field2":"","default_value_custom_column_field3":""};
    	var positionCustomColumnFields = {"position_custom_column_field1":"quantity","position_custom_column_field2":"quantity","position_custom_column_field3":"quantity"};
    	var allowNumericCustomColumnFields = {"allow_number_custom_column1":"","allow_number_custom_column2":"","allow_number_custom_column3":""};
    	var barcode_scan_focus = 'next_row';
		var update_existing_barcode_product = '0';
		var item_detail_search = '0';

		
	


		
		var show_export_fields_for_all = false;
		var SaleInvoiceWithoutPriceChange = '';
		var price_from_last_invoice = false;
		var productAllowed = true;
		var is_edit_document = false;
		var document_item_allowed = 25;
		var default_product_note = "";
		var other_tax_1_after_Taxable = 0;
		var quantity_decimal_rounding = 100;
		var price_decimal_rounding = 100;
		var gst_decimal_rounding = 100;
		var gst_rate_decimal_rounding = 100;
		var taxable_decimal_rounding = 100;
		var currency_decimal_rounding = 100;
		
		var custom_column_rounding = decimal_roundings(2);
		var gst_decimal_rounding_by = 2;
		var gst_rate_decimal_rounding_by = 2;
		var quantity_decimal_rounding_by = 2;
		var price_decimal_rounding_by = 2;
		var inventory_enable = true;
		var allow_oversell = false;
		var discount_in = 'percentage';
		var discount_per_item = 0;
		var enable_round_off = 1;
		var availableProducts = [];
		var availableTransports = [];
		var einvoice_status = '';
		var dispatchOrgname = "";
		var always_show_general_discount = '0';
		var rounding_method = 'default';
		Org_GSTIN_No = ""; 		var stockout = false;
	</script>
				<script>
				availableProducts = [
					{
				value: "214464",
				label: "Assessment -Work ",
				attr1name: "",
				attr1val: "",
				attr2name: "",
				attr2val: "",
				attr3name: "",
				attr3val: "",
				attr4name: "",
				attr4val: "",
				sellprice: "2500.000000",
				customerprice: "2500.000000",
				purchaseprice: "0.000000",
				uom: "",
				items_available: "-2.00",
				items_available_formula: "-2.00000",
				cgst: "0.000",
				sgst: "0.000",
				igst: "0.000",
				cess: "0.00",
				cess_type: "0",
				cess_amount: "0.00",
				is_transport: "0",
				is_service_product: "0",
				non_salable_product: "0",
				name: "Assessment -Work ",
				product_note: "",
				hsn: "",
				stockType: "0",
				barcode_no: "",
				mrp: "",
				product_code: "",
				product_disc: "",
				product_disc_in: "",
				product_uom: ""

			},{
				value: "332928",
				label: "GST Annual Return",
				attr1name: "",
				attr1val: "",
				attr2name: "",
				attr2val: "",
				attr3name: "",
				attr3val: "",
				attr4name: "",
				attr4val: "",
				sellprice: "2500.000000",
				customerprice: "2500.000000",
				purchaseprice: "0.000000",
				uom: "",
				items_available: "-1.00",
				items_available_formula: "-1.00000",
				cgst: "0.000",
				sgst: "0.000",
				igst: "0.000",
				cess: "0.00",
				cess_type: "0",
				cess_amount: "0.00",
				is_transport: "0",
				is_service_product: "0",
				non_salable_product: "0",
				name: "GST Annual Return",
				product_note: "",
				hsn: "2500",
				stockType: "0",
				barcode_no: "",
				mrp: "",
				product_code: "",
				product_disc: "",
				product_disc_in: "",
				product_uom: ""

			},{
				value: "215227",
				label: "GST Deregistration Charges",
				attr1name: "",
				attr1val: "",
				attr2name: "",
				attr2val: "",
				attr3name: "",
				attr3val: "",
				attr4name: "",
				attr4val: "",
				sellprice: "1500.000000",
				customerprice: "1500.000000",
				purchaseprice: "0.000000",
				uom: "",
				items_available: "-1.00",
				items_available_formula: "-1.00000",
				cgst: "0.000",
				sgst: "0.000",
				igst: "0.000",
				cess: "0.00",
				cess_type: "0",
				cess_amount: "0.00",
				is_transport: "0",
				is_service_product: "0",
				non_salable_product: "0",
				name: "GST Deregistration Charges",
				product_note: "",
				hsn: "",
				stockType: "0",
				barcode_no: "",
				mrp: "",
				product_code: "",
				product_disc: "",
				product_disc_in: "",
				product_uom: ""

			},{
				value: "214445",
				label: "GST Monthly Filing Charges",
				attr1name: "",
				attr1val: "",
				attr2name: "",
				attr2val: "",
				attr3name: "",
				attr3val: "",
				attr4name: "",
				attr4val: "",
				sellprice: "1000.000000",
				customerprice: "1000.000000",
				purchaseprice: "0.000000",
				uom: "NOS",
				items_available: "-83.00",
				items_available_formula: "-83.00000",
				cgst: "0.000",
				sgst: "0.000",
				igst: "0.000",
				cess: "0.00",
				cess_type: "0",
				cess_amount: "0.00",
				is_transport: "0",
				is_service_product: "1",
				non_salable_product: "0",
				name: "GST Monthly Filing Charges",
				product_note: "",
				hsn: "",
				stockType: "0",
				barcode_no: "",
				mrp: "",
				product_code: "",
				product_disc: "",
				product_disc_in: "",
				product_uom: ""

			},{
				value: "214465",
				label: "GST Registration",
				attr1name: "",
				attr1val: "",
				attr2name: "",
				attr2val: "",
				attr3name: "",
				attr3val: "",
				attr4name: "",
				attr4val: "",
				sellprice: "4500.000000",
				customerprice: "4500.000000",
				purchaseprice: "0.000000",
				uom: "NOS",
				items_available: "-6.00",
				items_available_formula: "-6.00000",
				cgst: "0.000",
				sgst: "0.000",
				igst: "0.000",
				cess: "0.00",
				cess_type: "0",
				cess_amount: "0.00",
				is_transport: "0",
				is_service_product: "1",
				non_salable_product: "0",
				name: "GST Registration",
				product_note: "",
				hsn: "",
				stockType: "0",
				barcode_no: "",
				mrp: "",
				product_code: "",
				product_disc: "",
				product_disc_in: "",
				product_uom: ""

			},{
				value: "214467",
				label: "GST Service",
				attr1name: "",
				attr1val: "",
				attr2name: "",
				attr2val: "",
				attr3name: "",
				attr3val: "",
				attr4name: "",
				attr4val: "",
				sellprice: "0.000000",
				customerprice: "0.000000",
				purchaseprice: "0.000000",
				uom: "NOS",
				items_available: "-1.00",
				items_available_formula: "-1.00000",
				cgst: "0.000",
				sgst: "0.000",
				igst: "0.000",
				cess: "0.00",
				cess_type: "0",
				cess_amount: "0.00",
				is_transport: "0",
				is_service_product: "1",
				non_salable_product: "0",
				name: "GST Service",
				product_note: "",
				hsn: "",
				stockType: "0",
				barcode_no: "",
				mrp: "",
				product_code: "",
				product_disc: "",
				product_disc_in: "",
				product_uom: ""

			},{
				value: "215303",
				label: "IEC Registration",
				attr1name: "",
				attr1val: "",
				attr2name: "",
				attr2val: "",
				attr3name: "",
				attr3val: "",
				attr4name: "",
				attr4val: "",
				sellprice: "4500.000000",
				customerprice: "4500.000000",
				purchaseprice: "0.000000",
				uom: "",
				items_available: "-2.00",
				items_available_formula: "-2.00000",
				cgst: "0.000",
				sgst: "0.000",
				igst: "0.000",
				cess: "0.00",
				cess_type: "0",
				cess_amount: "0.00",
				is_transport: "0",
				is_service_product: "0",
				non_salable_product: "0",
				name: "IEC Registration",
				product_note: "",
				hsn: "",
				stockType: "0",
				barcode_no: "",
				mrp: "",
				product_code: "",
				product_disc: "",
				product_disc_in: "",
				product_uom: ""

			},{
				value: "167477",
				label: "Income Tax Filing",
				attr1name: "",
				attr1val: "",
				attr2name: "",
				attr2val: "",
				attr3name: "",
				attr3val: "",
				attr4name: "",
				attr4val: "",
				sellprice: "0.000000",
				customerprice: "0.000000",
				purchaseprice: "0.000000",
				uom: "NOS",
				items_available: "-554.00",
				items_available_formula: "-554.00000",
				cgst: "0.000",
				sgst: "0.000",
				igst: "0.000",
				cess: "0.00",
				cess_type: "0",
				cess_amount: "0.00",
				is_transport: "0",
				is_service_product: "0",
				non_salable_product: "0",
				name: "Income Tax Filing",
				product_note: "",
				hsn: "",
				stockType: "0",
				barcode_no: "",
				mrp: "",
				product_code: "",
				product_disc: "",
				product_disc_in: "",
				product_uom: ""

			},{
				value: "214468",
				label: "M S M E Registation",
				attr1name: "",
				attr1val: "",
				attr2name: "",
				attr2val: "",
				attr3name: "",
				attr3val: "",
				attr4name: "",
				attr4val: "",
				sellprice: "2500.000000",
				customerprice: "2500.000000",
				purchaseprice: "0.000000",
				uom: "NOS",
				items_available: "-2.00",
				items_available_formula: "-2.00000",
				cgst: "0.000",
				sgst: "0.000",
				igst: "0.000",
				cess: "0.00",
				cess_type: "0",
				cess_amount: "0.00",
				is_transport: "0",
				is_service_product: "1",
				non_salable_product: "0",
				name: "M S M E Registation",
				product_note: "",
				hsn: "",
				stockType: "0",
				barcode_no: "",
				mrp: "",
				product_code: "",
				product_disc: "",
				product_disc_in: "",
				product_uom: ""

			},{
				value: "224086",
				label: "MONTHLY ACCOUNTING CHARGES",
				attr1name: "",
				attr1val: "",
				attr2name: "",
				attr2val: "",
				attr3name: "",
				attr3val: "",
				attr4name: "",
				attr4val: "",
				sellprice: "4500.000000",
				customerprice: "4500.000000",
				purchaseprice: "0.000000",
				uom: "",
				items_available: "-12.00",
				items_available_formula: "-12.00000",
				cgst: "0.000",
				sgst: "0.000",
				igst: "0.000",
				cess: "0.00",
				cess_type: "0",
				cess_amount: "0.00",
				is_transport: "0",
				is_service_product: "0",
				non_salable_product: "0",
				name: "MONTHLY ACCOUNTING CHARGES",
				product_note: "",
				hsn: "",
				stockType: "0",
				barcode_no: "",
				mrp: "",
				product_code: "",
				product_disc: "",
				product_disc_in: "",
				product_uom: ""

			},{
				value: "225009",
				label: "other Service",
				attr1name: "",
				attr1val: "",
				attr2name: "",
				attr2val: "",
				attr3name: "",
				attr3val: "",
				attr4name: "",
				attr4val: "",
				sellprice: "300.000000",
				customerprice: "300.000000",
				purchaseprice: "0.000000",
				uom: "",
				items_available: "-6.00",
				items_available_formula: "-6.00000",
				cgst: "0.000",
				sgst: "0.000",
				igst: "0.000",
				cess: "0.00",
				cess_type: "0",
				cess_amount: "0.00",
				is_transport: "0",
				is_service_product: "0",
				non_salable_product: "0",
				name: "other Service",
				product_note: "",
				hsn: "",
				stockType: "0",
				barcode_no: "",
				mrp: "",
				product_code: "",
				product_disc: "",
				product_disc_in: "",
				product_uom: ""

			},{
				value: "215226",
				label: "PAN CARD",
				attr1name: "",
				attr1val: "",
				attr2name: "",
				attr2val: "",
				attr3name: "",
				attr3val: "",
				attr4name: "",
				attr4val: "",
				sellprice: "500.000000",
				customerprice: "500.000000",
				purchaseprice: "0.000000",
				uom: "",
				items_available: "-1.00",
				items_available_formula: "-1.00000",
				cgst: "0.000",
				sgst: "0.000",
				igst: "0.000",
				cess: "0.00",
				cess_type: "0",
				cess_amount: "0.00",
				is_transport: "0",
				is_service_product: "0",
				non_salable_product: "0",
				name: "PAN CARD",
				product_note: "",
				hsn: "",
				stockType: "0",
				barcode_no: "",
				mrp: "",
				product_code: "",
				product_disc: "",
				product_disc_in: "",
				product_uom: ""

			},{
				value: "167475",
				label: "Preparation Of Balance Sheet",
				attr1name: "",
				attr1val: "",
				attr2name: "",
				attr2val: "",
				attr3name: "",
				attr3val: "",
				attr4name: "",
				attr4val: "",
				sellprice: "0.000000",
				customerprice: "0.000000",
				purchaseprice: "0.000000",
				uom: "NOS",
				items_available: "-1.00",
				items_available_formula: "-1.00000",
				cgst: "0.000",
				sgst: "0.000",
				igst: "0.000",
				cess: "0.00",
				cess_type: "0",
				cess_amount: "0.00",
				is_transport: "0",
				is_service_product: "0",
				non_salable_product: "0",
				name: "Preparation Of Balance Sheet",
				product_note: "",
				hsn: "",
				stockType: "0",
				barcode_no: "",
				mrp: "",
				product_code: "",
				product_disc: "",
				product_disc_in: "",
				product_uom: ""

			},{
				value: "167476",
				label: "Preparation Of Profit & Loss Statement",
				attr1name: "",
				attr1val: "",
				attr2name: "",
				attr2val: "",
				attr3name: "",
				attr3val: "",
				attr4name: "",
				attr4val: "",
				sellprice: "0.000000",
				customerprice: "0.000000",
				purchaseprice: "0.000000",
				uom: "NOS",
				items_available: "-1.00",
				items_available_formula: "-1.00000",
				cgst: "0.000",
				sgst: "0.000",
				igst: "0.000",
				cess: "0.00",
				cess_type: "0",
				cess_amount: "0.00",
				is_transport: "0",
				is_service_product: "0",
				non_salable_product: "0",
				name: "Preparation Of Profit & Loss Statement",
				product_note: "",
				hsn: "",
				stockType: "0",
				barcode_no: "",
				mrp: "",
				product_code: "",
				product_disc: "",
				product_disc_in: "",
				product_uom: ""

			},{
				value: "332929",
				label: "Shops and Establishment Annual return",
				attr1name: "",
				attr1val: "",
				attr2name: "",
				attr2val: "",
				attr3name: "",
				attr3val: "",
				attr4name: "",
				attr4val: "",
				sellprice: "2500.000000",
				customerprice: "2500.000000",
				purchaseprice: "0.000000",
				uom: "",
				items_available: "-1.00",
				items_available_formula: "-1.00000",
				cgst: "0.000",
				sgst: "0.000",
				igst: "0.000",
				cess: "0.00",
				cess_type: "0",
				cess_amount: "0.00",
				is_transport: "0",
				is_service_product: "0",
				non_salable_product: "0",
				name: "Shops and Establishment Annual return",
				product_note: "",
				hsn: "",
				stockType: "0",
				barcode_no: "",
				mrp: "",
				product_code: "",
				product_disc: "",
				product_disc_in: "",
				product_uom: ""

			},{
				value: "214461",
				label: "Shops and Establishment Registration",
				attr1name: "",
				attr1val: "",
				attr2name: "",
				attr2val: "",
				attr3name: "",
				attr3val: "",
				attr4name: "",
				attr4val: "",
				sellprice: "4500.000000",
				customerprice: "4500.000000",
				purchaseprice: "0.000000",
				uom: "NOS",
				items_available: "-3.00",
				items_available_formula: "-3.00000",
				cgst: "0.000",
				sgst: "0.000",
				igst: "0.000",
				cess: "0.00",
				cess_type: "0",
				cess_amount: "0.00",
				is_transport: "0",
				is_service_product: "1",
				non_salable_product: "0",
				name: "Shops and Establishment Registration",
				product_note: "",
				hsn: "",
				stockType: "0",
				barcode_no: "",
				mrp: "",
				product_code: "",
				product_disc: "",
				product_disc_in: "",
				product_uom: ""

			},{
				value: "214462",
				label: "T D S Quarterly- Filing",
				attr1name: "",
				attr1val: "",
				attr2name: "",
				attr2val: "",
				attr3name: "",
				attr3val: "",
				attr4name: "",
				attr4val: "",
				sellprice: "0.000000",
				customerprice: "0.000000",
				purchaseprice: "0.000000",
				uom: "NOS",
				items_available: "-3.00",
				items_available_formula: "-3.00000",
				cgst: "0.000",
				sgst: "0.000",
				igst: "0.000",
				cess: "0.00",
				cess_type: "0",
				cess_amount: "0.00",
				is_transport: "0",
				is_service_product: "1",
				non_salable_product: "0",
				name: "T D S Quarterly- Filing",
				product_note: "",
				hsn: "",
				stockType: "0",
				barcode_no: "",
				mrp: "",
				product_code: "",
				product_disc: "",
				product_disc_in: "",
				product_uom: ""

			},{
				value: "215225",
				label: "Tally Software",
				attr1name: "",
				attr1val: "",
				attr2name: "",
				attr2val: "",
				attr3name: "",
				attr3val: "",
				attr4name: "",
				attr4val: "",
				sellprice: "4000.000000",
				customerprice: "4000.000000",
				purchaseprice: "0.000000",
				uom: "",
				items_available: "-1.00",
				items_available_formula: "-1.00000",
				cgst: "0.000",
				sgst: "0.000",
				igst: "0.000",
				cess: "0.00",
				cess_type: "0",
				cess_amount: "0.00",
				is_transport: "0",
				is_service_product: "0",
				non_salable_product: "0",
				name: "Tally Software",
				product_note: "",
				hsn: "",
				stockType: "0",
				barcode_no: "",
				mrp: "",
				product_code: "",
				product_disc: "",
				product_disc_in: "",
				product_uom: ""

			}				];
			</script>


					<script>
				availableTransports = [
					{
					value: "735",
					label: "Hand Delivery",
					vehicleno: "",
					transportID: "",
					name: "Hand Delivery"
				}				];
			</script>
		<script>
		$(document).ready(function() {

			$(".transport-combobox").autocomplete({
				source: availableTransports,
				change: function(event, ui) {
					if (ui.item == null || ui.item == undefined) {
						$(".transport-combobox").val("")
						$("#hidden-transport-id").val("");
						$("#hidden-transport-name").val("");
						$("#hidden-transport-transportID").val("");
						$("#hidden-transport-vehicleno").val("");
						$("#transport_id_label").val("");
						$("#vehicle_no_label").val("");
					} else {
						if (ui.item) {
							$(".transport-combobox").val(ui.item.label);
							$(event.target).attr("data-oldval", ui.item.label);
							$("#hidden-transport-id").val(ui.item.value);
							$("#hidden-transport-name").val(ui.item.name);
							$("#hidden-transport-transportID").val(ui.item.transportID);
							$("#hidden-transport-vehicleno").val(ui.item.vehicleno);
							$("#transport_id_label").val(ui.item.transportID);
							$("#vehicle_no_label").val(ui.item.vehicleno);

						}
					}
				},
				select: function(event, ui) {
					$(".transport-combobox").val(ui.item.label);
					$(event.target).attr("data-oldval", ui.item.label);
					$("#hidden-transport-id").val(ui.item.value);
					$("#hidden-transport-name").val(ui.item.name);
					$("#hidden-transport-transportID").val(ui.item.transportID);
					$("#hidden-transport-vehicleno").val(ui.item.vehicleno);
					$("#transport_id_label").val(ui.item.transportID);
					$("#vehicle_no_label").val(ui.item.vehicleno);
					return false;
				},
				minLength: 0
			}).focus(function() {
				$(this).autocomplete("search");
			}).blur(function() {
				if ($(this).val() == "") {
					$("#hidden-transport-id").val("");
					$("#hidden-transport-name").val("");
					$("#hidden-transport-transportID").val("");
					$("#hidden-transport-vehicleno").val("");
					$("#transport_id_label").val("");
				}
			});




		});
	</script>


	<script>
		var autoUOMList = [
			{
			value: "BAG",
			label: "Bags - BAG"
		},{
			value: "BGS",
			label: "BagsBGS - BGS"
		},{
			value: "BLS",
			label: "Bails - BLS"
		},{
			value: "BTL",
			label: "Bottles - BTL"
		},{
			value: "BOU",
			label: "Bou - BOU"
		},{
			value: "BOX",
			label: "Boxes - BOX"
		},{
			value: "BKL",
			label: "Buckles - BKL"
		},{
			value: "BLK",
			label: "Bulk - BLK"
		},{
			value: "BUN",
			label: "Bunches - BUN"
		},{
			value: "BDL",
			label: "Bundles - BDL"
		},{
			value: "CAN",
			label: "Cans - CAN"
		},{
			value: "CTS",
			label: "Carats - CTS"
		},{
			value: "CTN",
			label: "Cartons - CTN"
		},{
			value: "CAS",
			label: "Cases - CAS"
		},{
			value: "CMS",
			label: "Centimeter - CMS"
		},{
			value: "CHK",
			label: "Chauka - CHK"
		},{
			value: "CHI",
			label: "Chest - CHI"
		},{
			value: "CLS",
			label: "Coils - CLS"
		},{
			value: "COL",
			label: "Collies - COL"
		},{
			value: "CRI",
			label: "Crates - CRI"
		},{
			value: "CCM",
			label: "Cubic Centimeter - CCM"
		},{
			value: "CFT",
			label: "Cubic Feet - CFT"
		},{
			value: "CIN",
			label: "Cubic Inches - CIN"
		},{
			value: "CBM",
			label: "Cubic Meter - CBM"
		},{
			value: "CQM",
			label: "Cubic Meters - CQM"
		},{
			value: "CYL",
			label: "Cylinder - CYL"
		},{
			value: "DAY",
			label: "Days - DAY"
		},{
			value: "SDM",
			label: "Decameter Square - SDM"
		},{
			value: "DOZ",
			label: "Dozen - DOZ"
		},{
			value: "DRM",
			label: "Drums - DRM"
		},{
			value: "FTS",
			label: "Feet - FTS"
		},{
			value: "FLK",
			label: "Flasks - FLK"
		},{
			value: "GMS",
			label: "Grams - GMS"
		},{
			value: "GGR",
			label: "Great Gross - GGR"
		},{
			value: "TON",
			label: "Greate Britain Ton - TON"
		},{
			value: "GRS",
			label: "Gross - GRS"
		},{
			value: "GYS",
			label: "Gross Yards - GYS"
		},{
			value: "HBK",
			label: "Habbuck - HBK"
		},{
			value: "HKS",
			label: "Hanks - HKS"
		},{
			value: "HRS",
			label: "Hours - HRS"
		},{
			value: "INC",
			label: "Inches - INC"
		},{
			value: "IND",
			label: "Inch Dia - IND"
		},{
			value: "INM",
			label: "Inch Meter - INM"
		},{
			value: "JAR",
			label: "Jar - JAR"
		},{
			value: "JOB",
			label: "Job - JOB"
		},{
			value: "JTA",
			label: "Jotta - JTA"
		},{
			value: "KGS",
			label: "Kilograms - KGS"
		},{
			value: "KLR",
			label: "Kiloliter - KLR"
		},{
			value: "KME",
			label: "Kilometers - KME"
		},{
			value: "KMS",
			label: "Kilometers - KMS"
		},{
			value: "KW",
			label: "Kilowatt - KW"
		},{
			value: "LTR",
			label: "Liters - LTR"
		},{
			value: "LIN",
			label: "Lines - LIN"
		},{
			value: "LOAD",
			label: "Load - LOAD"
		},{
			value: "LOG",
			label: "Logs - LOG"
		},{
			value: "LOT",
			label: "Lots - LOT"
		},{
			value: "LS",
			label: "Lumpsum - LS"
		},{
			value: "MTR",
			label: "Meter - MTR"
		},{
			value: "MTS",
			label: "Metric Ton - MTS"
		},{
			value: "MGS",
			label: "Milli Grams - MGS"
		},{
			value: "MLT",
			label: "Milli Litre - MLT"
		},{
			value: "MMT",
			label: "Milli Meter - MMT"
		},{
			value: "MO",
			label: "Month - MO"
		},{
			value: "MIN",
			label: "Minute - MIN"
		},{
			value: "NOS",
			label: "Numbers - NOS"
		},{
			value: "ODD",
			label: "Odds - ODD"
		},{
			value: "OTH",
			label: "Others - OTH"
		},{
			value: "PKG",
			label: "Package - PKG"
		},{
			value: "PKT",
			label: "Packet - PKT"
		},{
			value: "PKD",
			label: "Peck - Dry Measure - PKD"
		},{
			value: "PAC",
			label: "Packs - PAC"
		},{
			value: "PAI",
			label: "Pails - PAI"
		},{
			value: "PRS",
			label: "Pairs - PRS"
		},{
			value: "PLT",
			label: "Pallets - PLT"
		},{
			value: "PCS",
			label: "Pieces - PCS"
		},{
			value: "LBS",
			label: "Pounds - LBS"
		},{
			value: "QTR",
			label: "Quarter - QTR"
		},{
			value: "QTL",
			label: "Quintal - QTL"
		},{
			value: "REL",
			label: "Reels - REL"
		},{
			value: "RIM",
			label: "RIM - RIM"
		},{
			value: "ROL",
			label: "Rolls - ROL"
		},{
			value: "RFT",
			label: "Running Feet - RFT"
		},{
			value: "RM",
			label: "Running Meter - RM"
		},{
			value: "SET",
			label: "Sets - SET"
		},{
			value: "SHT",
			label: "Sheets - SHT"
		},{
			value: "SLB",
			label: "Slabs - SLB"
		},{
			value: "SQC",
			label: "Sqaure Centimeters - SQC"
		},{
			value: "SQF",
			label: "Sqaure Feet - SQF"
		},{
			value: "SQI",
			label: "Square Inches - SQI"
		},{
			value: "SQM",
			label: "Square Meter - SQM"
		},{
			value: "SQY",
			label: "Square Yards - SQY"
		},{
			value: "BLO",
			label: "Steel Blocks - BLO"
		},{
			value: "STR",
			label: "Strings - STR"
		},{
			value: "TBL",
			label: "Tables - TBL"
		},{
			value: "TBS",
			label: "Tablets - TBS"
		},{
			value: "TGM",
			label: "Ten Gross - TGM"
		},{
			value: "THD",
			label: "Thousands - THD"
		},{
			value: "TIN",
			label: "Tins - TIN"
		},{
			value: "TOL",
			label: "Tola - TOL"
		},{
			value: "TRK",
			label: "Trunk - TRK"
		},{
			value: "TUB",
			label: "Tubes - TUB"
		},{
			value: "UGS",
			label: "US Gallons - UGS"
		},{
			value: "UNT",
			label: "Units - UNT"
		},{
			value: "VLS",
			label: "Vials - VLS"
		},{
			value: "CSK",
			label: "Wooden Cases - CSK"
		},{
			value: "YDS",
			label: "Yards - YDS"
		},{
			value: "YO",
			label: "Year - YO"
		}		];
	</script>


<script>
	var availableCustomer = [{"companyname":"A Murthy","companytype":"Customer","value":113585,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bangalore","label":"A Murthy (Bangalore, )"},{"companyname":"Amit Steel & Cement","companytype":"Customer","value":110529,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Amit, Bengaluru","label":"Amit Steel & Cement (Amit, Bengaluru, )"},{"companyname":"Babu Bcom","companytype":"Customer","value":118855,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"","label":"Babu Bcom"},{"companyname":"Beerav Enterprises","companytype":"Customer","value":110927,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bangalore","label":"Beerav Enterprises (Bangalore, )"},{"companyname":"Chamundeshwari enterprises","companytype":"Customer","value":110926,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"bangalore","label":"Chamundeshwari enterprises (bangalore, )"},{"companyname":"Chamundeshwari enterprises anjananagar","companytype":"Customer","value":112522,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Banglore","label":"Chamundeshwari enterprises anjananagar (Banglore, )"},{"companyname":"Chuckra engineering","companytype":"Customer","value":112726,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Banglore","label":"Chuckra engineering (Banglore, )"},{"companyname":"Dhanvi Enterprises","companytype":"Customer","value":110516,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"MANE SHIVAJI RAO VINOD KUMAR, bengaluru","label":"Dhanvi Enterprises (MANE SHIVAJI RAO VINOD KUMAR, bengaluru, )"},{"companyname":"Girish","companytype":"Customer","value":113528,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bangalore","label":"Girish (Bangalore, )"},{"companyname":"gopala Krishna","companytype":"Customer","value":113526,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bangalore","label":"gopala Krishna (Bangalore, )"},{"companyname":"Hemath kumar kadabagere","companytype":"Customer","value":113658,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"bangalore","label":"Hemath kumar kadabagere (bangalore, )"},{"companyname":"Indigo Productions","companytype":"Customer","value":113591,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"RAMPRASAD, Bangalore","label":"Indigo Productions (RAMPRASAD, Bangalore, )"},{"companyname":"JAGADEESH KODIGEHALLI","companytype":"Customer","value":110525,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bengaluru","label":"JAGADEESH KODIGEHALLI (Bengaluru, )"},{"companyname":"JAI AMBE HARDWARE AND PAINTS","companytype":"Customer","value":111998,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bangalore","label":"JAI AMBE HARDWARE AND PAINTS (Bangalore, )"},{"companyname":"M G  S Designs","companytype":"Customer","value":117505,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bangalore","label":"M G  S Designs (Bangalore, )"},{"companyname":"M K Aluminium","companytype":"Customer","value":111828,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bangalore","label":"M K Aluminium (Bangalore, )"},{"companyname":"Maharaja Fashion","companytype":"Customer","value":115092,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bnaglore","label":"Maharaja Fashion (Bnaglore, )"},{"companyname":"Manjunath Babu rao","companytype":"Customer","value":118172,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bangalore","label":"Manjunath Babu rao (Bangalore, )"},{"companyname":"Manjunatha basavaraju","companytype":"Customer","value":118173,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bangalore","label":"Manjunatha basavaraju (Bangalore, )"},{"companyname":"Manjunatha Gowda","companytype":"Customer","value":111821,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bangalore","label":"Manjunatha Gowda (Bangalore, )"},{"companyname":"MANJUNATHA MEDICALS MAGADI","companytype":"Customer","value":116628,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"MAGADI","label":"MANJUNATHA MEDICALS MAGADI (MAGADI, )"},{"companyname":"Mohan Kumar","companytype":"Customer","value":111825,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bangalore","label":"Mohan Kumar (Bangalore, )"},{"companyname":"Nagesh S H","companytype":"Customer","value":114753,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bangalore","label":"Nagesh S H (Bangalore, )"},{"companyname":"Naresh","companytype":"Customer","value":2426,"gstno":"","contactno1":"9964981033","customer_text_1":null,"customer_text_2":null,"customer_text_3":null,"address":"Naresh, Near Lake, bangalore","label":"Naresh (Naresh, Near Lake, bangalore, 9964981033)"},{"companyname":"Naveen Kumar C R","companytype":"Customer","value":90557,"gstno":"","contactno1":"974061211","customer_text_1":null,"customer_text_2":null,"customer_text_3":null,"address":"Naveen Kumar C R, Rajgopal Nagar, Bangalore","label":"Naveen Kumar C R (Naveen Kumar C R, Rajgopal Nagar, Bangalore, 974061211)"},{"companyname":"P M Sales Marketing","companytype":"Customer","value":114919,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bangalore","label":"P M Sales Marketing (Bangalore, )"},{"companyname":"Padma","companytype":"Customer","value":110572,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bengaluru","label":"Padma (Bengaluru, )"},{"companyname":"Pradeepa","companytype":"Customer","value":114319,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bangalore","label":"Pradeepa (Bangalore, )"},{"companyname":"Prasanna shet","companytype":"Customer","value":119565,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bangalore","label":"Prasanna shet (Bangalore, )"},{"companyname":"RAJ RATHNA ENTERPRISES","companytype":"Customer","value":110518,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Dr Rakesh, Bengaluru","label":"RAJ RATHNA ENTERPRISES (Dr Rakesh, Bengaluru, )"},{"companyname":"Ramesh panchayath","companytype":"Customer","value":112524,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Banglore","label":"Ramesh panchayath (Banglore, )"},{"companyname":"ranganatha industies","companytype":"Customer","value":122228,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"","label":"ranganatha industies"},{"companyname":"Raviraja","companytype":"Customer","value":119563,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bangalore","label":"Raviraja (Bangalore, )"},{"companyname":"Ravishnkar","companytype":"Customer","value":114318,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bangalore","label":"Ravishnkar (Bangalore, )"},{"companyname":"RUDRARADYA","companytype":"Customer","value":113529,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"BANGALORE","label":"RUDRARADYA (BANGALORE, )"},{"companyname":"Rudre Gowda","companytype":"Customer","value":115267,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bangalore","label":"Rudre Gowda (Bangalore, )"},{"companyname":"S K Pack World","companytype":"Customer","value":111824,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bangalore","label":"S K Pack World (Bangalore, )"},{"companyname":"SALEEM KHAN HABEEB","companytype":"Customer","value":115493,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"vinayfried, bangalore","label":"SALEEM KHAN HABEEB (vinayfried, bangalore, )"},{"companyname":"Samruddi Enterprises","companytype":"Customer","value":110526,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Sandeep, Mysuru","label":"Samruddi Enterprises (Sandeep, Mysuru, )"},{"companyname":"Samrudhi Foundation","companytype":"Customer","value":115562,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Rudraradya, Bangalore","label":"Samrudhi Foundation (Rudraradya, Bangalore, )"},{"companyname":"SF Studio","companytype":"Customer","value":110523,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Prabhakar, Bengaluru","label":"SF Studio (Prabhakar, Bengaluru, )"},{"companyname":"Shamai Data Solution","companytype":"Customer","value":110521,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Sharat Vajja, Bengaluru","label":"Shamai Data Solution (Sharat Vajja, Bengaluru, )"},{"companyname":"shivalila goudar","companytype":"Customer","value":122227,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"","label":"shivalila goudar"},{"companyname":"Shivanna","companytype":"Customer","value":114317,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bangalore","label":"Shivanna (Bangalore, )"},{"companyname":"sHIVANNA GOLLARAHATTI","companytype":"Customer","value":113532,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"BANGALORE","label":"sHIVANNA GOLLARAHATTI (BANGALORE, )"},{"companyname":"Shivaraja","companytype":"Customer","value":119562,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bangalore","label":"Shivaraja (Bangalore, )"},{"companyname":"Shree Chamundeshwari Enterprises","companytype":"Customer","value":110528,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Rakesh, Bengaluru","label":"Shree Chamundeshwari Enterprises (Rakesh, Bengaluru, )"},{"companyname":"Shree Lakshmi Enterprises","companytype":"Customer","value":110524,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Manjunatha, Bengaluru","label":"Shree Lakshmi Enterprises (Manjunatha, Bengaluru, )"},{"companyname":"SLR constructions","companytype":"Customer","value":119564,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bangalore","label":"SLR constructions (Bangalore, )"},{"companyname":"SLV Loans","companytype":"Customer","value":113879,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bangalore","label":"SLV Loans (Bangalore, )"},{"companyname":"SLV Loans","companytype":"Customer","value":110573,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Naveen, Bengaluru","label":"SLV Loans (Naveen, Bengaluru, )"},{"companyname":"Srinivasa Murthy","companytype":"Customer","value":111827,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bangalore","label":"Srinivasa Murthy (Bangalore, )"},{"companyname":"SRIVINAYAKA PHARMACEUTICALS","companytype":"Customer","value":110513,"gstno":"29HTLPS0505P1ZV","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"RASHMI G S, bengaluru","label":"SRIVINAYAKA PHARMACEUTICALS, 29HTLPS0505P1ZV (RASHMI G S, bengaluru, )"},{"companyname":"Srnivas T Kannalli","companytype":"Customer","value":111826,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bangalore","label":"Srnivas T Kannalli (Bangalore, )"},{"companyname":"STAR LOOKZ","companytype":"Customer","value":114953,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"PRAVEEN, BANGALORE","label":"STAR LOOKZ (PRAVEEN, BANGALORE, )"},{"companyname":"Sudarshan Texttails","companytype":"Customer","value":110925,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Arun, Bengaluru","label":"Sudarshan Texttails (Arun, Bengaluru, )"},{"companyname":"Syed Ismail","companytype":"Customer","value":110517,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bengaluru","label":"Syed Ismail (Bengaluru, )"},{"companyname":"TARSIER VIEW CONSULTING PRIVATE LIMITED","companytype":"Customer","value":110515,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"RAvi Shankar, BANGALORE","label":"TARSIER VIEW CONSULTING PRIVATE LIMITED (RAvi Shankar, BANGALORE, )"},{"companyname":"Vihaan Enterprises","companytype":"Customer","value":118171,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bangalore","label":"Vihaan Enterprises (Bangalore, )"},{"companyname":"vinay kashinath","companytype":"Customer","value":114734,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bangalore","label":"vinay kashinath (Bangalore, )"},{"companyname":"vinayaka medicals","companytype":"Customer","value":116626,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"renu kumar, bangalore","label":"vinayaka medicals (renu kumar, bangalore, )"},{"companyname":"Vinayaka Medicals","companytype":"Customer","value":110574,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Anand T C, Bengaluru","label":"Vinayaka Medicals (Anand T C, Bengaluru, )"},{"companyname":"Vinayaka packing","companytype":"Customer","value":119566,"gstno":"","contactno1":"","customer_text_1":"","customer_text_2":null,"customer_text_3":null,"address":"Bangalore","label":"Vinayaka packing (Bangalore, )"}];
</script>


	<div class="row">
		<div class="span12">
						<div class="widget-header open-header"> 
				<div>
					<svg width="20" height="20"><use href="svg-icon/icons.svg#edit-svg-icon"></use></svg>
					<h3> Create  Sale Invoice</h3>
				</div>
				<a href="invoicebill.php" target="_blank" class="btn btn-primary add_another_invoice_button pull-right"><svg width="20" height="20"><use href="svg-icon/icons.svg#plus-svg-icon"></use></svg>Create Another Invoice</a>
			</div>
			<div class="widget-create-document">

				<div class="">
					<form class="form-horizontal submit_for_draft" method="post" action="" id="product_invoice_form">
						<div class="row">
							<div class="span5  span-md-5 span-xs-12 span-sm-12"><!-- CompanyDetails-->
								<div class="widget">
									<div class="widget-header">
										<h3 class="customer-diff-title"><span class="desktop_only_label">Customer Information</span><span class="mobile_only_label">Customer Info</span></h3>
										<button type="button" class="btn btn-primary add_customer_modal_button pull-right" data-toggle="modal" data-target="#CustomerModal"><svg width="20" height="20"><use href="svg-icon/icons.svg#plus-svg-icon"></use></svg>Add Customer</button>
									</div>
									<hr>
									<div class="widget-content customer-information-invoice equal-height-divs"><!-- /CompanyDetailsContent-->

										<div class="control-group" style="position: relative;">
											<label for="firstname" class="control-label ">M/S.<span class="star_red">*</span></label>
											<div class="controls cmp" id="companybilling">
												<input type="hidden" value="Karnataka" id="business_state" name="business_state" />
												<input type="hidden" value="" id="business_gstno" name="business_gstno" />
												<input type="hidden" class="c_outstanding_amount" >
												<input type="hidden" class="c_limit_amount">
												<input type="hidden" class="companytype">
												<input type="hidden" id="hidden-invoice-state" data-value="" value="" name="hidden-invoice-state" />
																								<input type="text" class="span2 auto-complete-dropdown" id="autoCustomerField" name="autoCustomerField" value="" required />
												<input type="hidden" name="ms" id="customers" value="0" data-default="0"  />
												<input type="hidden" name="hidden_companyname" id="hidden_companyname" value="0" />
												<span class="shortcut_key" style="bottom: 48px;left: 47px;text-align: center;"> a</span>
												<label id="customers-error" class="error" for="customers"></label>
												<div class="customer_outstanding_value"></div>
											</div> <!--/ms-->

										</div>
										<div class="control-group">
											<label for="firstname" class="control-label">Address</label>
											<div class="controls cmp">
												<textarea name="address" class="CompanyDetailsAddress" id="address" rows="2" cols="2" readonly="true" data-value=" ">
												</textarea>
											</div> <!--/address-->
										</div>
										<input type="hidden" name="cmp_address1" id="cmp_address1" data-value="" value="">
										<input type="hidden" name="cmp_address2" id="cmp_address2" data-value="" value="">
										<input type="hidden" name="cmp_landmark" id="cmp_landmark" data-value="" value="">
										<input type="hidden" name="cmp_pincode" id="cmp_pincode" data-value="" value="">
										<input type="hidden" name="cmp_country" id="cmp_country" data-value="" value="">
										<input type="hidden" name="cmp_city" id="cmp_city" data-value="" value="">
										<input type="hidden" name="customerretail" id="customerretail" value="0">

										<div class="control-group ">
											<label for="firstname" class="control-label ">Contact Person</label>
											<div class="controls cmp">
												<input type="text" class="control-labe2" name="cmp_contactperson" id="cmp_contactperson" data-value="" value="" placeholder="Contact Person"/>
												<input type="hidden" name="hcontactperson" id="hcontactperson" />
											</div> <!-- /cst no -->
										</div>
										<div class="control-group ">
											<label for="firstname" class="control-label ">Phone No</label>
											<div class="controls cmp">
												<input type="text" class="control-labe2" name="cmp_contactno" id="phone" data-value="" value="" placeholder="Phone No"/>
												<input type="hidden" name="hphone" id="hphone" />
											</div> <!-- /cst no -->

										</div> <!-- control group -->
										<div class="control-group">
											<label for="firstname" class="control-label ">GSTIN / PAN</label>
											<div class="controls cmp" id="companybilling">
													<input type="text" class="control-labe2" name="cmp_gstno" id="cmp_gstno" data-value="" value="" />
													<input type="hidden" name="hgst" id="hgst" />
											</div> <!-- /cst no -->
										</div> <!-- control group -->
										<div class="control-group">
											<label for="firstname" class="control-label ">Rev. Charge</label>
											<div class="controls cmp">
												<select id="reverse_Charge" class="reverse_Charge" name="reverse_Charge">
													<option value="0" data-val="" >No</option>
													<option value="1" data-val="" >Yes</option>
												</select>

											</div> <!--/ms-->
										</div>

										


										<div id="dispatch_detail_drawer" class="open_dis_drwawer">
											<div class="control-group ">
												<label for="firstname" class="control-label ">Dispatch From</label>
												<div class="controls cmp">
													<select name="dispatch_address" id="dispatch_address" data-id="">
													</select>
												</div> <!-- /cst no -->
											</div> <!-- control group -->

											<button type="button" class="btn btn-text2 btn-small pull-right additionalBusiness" ><svg width="20" height="20"><use href="svg-icon/icons.svg#plus-svg-icon"></use></svg>&nbsp;Add New Dispatch From</button>
											
											<input type="hidden" value="0" name="dispatchAdd" id="dispatchAdd">
											<input type="hidden" value="" name="dispatchName" id="dispatchName">
											<input type="hidden" value="" name="dispatchPhone" id="dispatchPhone">
											<input type="hidden" value="" name="dispatchEmail" id="dispatchEmail">
											<input type="hidden" value="" name="dispatchGstin" id="dispatchGstin">
											<input type="hidden" value="" name="dispatchOrgname" id="dispatchOrgname">
											<input type="hidden" value="" name="dispatchPincode" id="dispatchPincode">
											<input type="hidden" value="" name="dispatchCity" id="dispatchCity">
											<input type="hidden" value="" name="dispatchCountry" id="dispatchCountry">
											<input type="hidden" value="" name="dispatchState" id="dispatchState">	
											<input type="hidden" value="" name="dispatchAddress1" id="dispatchAddress1">
											<input type="hidden" value="" name="dispatchAddress2" id="dispatchAddress2">

											<div class="control-group">
												<label for="dispatchAddress" class="control-label">Dispatch Address</label>
												<div class="controls cmp">
													<label class="dispatchAddress">-</label>
												</div>

											</div>
	
										</div>

										<div class="control-group">
											<label for="firstname" class="control-label ">Shipping Address</label>
											<div class="controls cmp" id="companyshippinh">


												<div class="form-check"><label class="form-check-label"><input type="checkbox" name="SameShippingAdd" class="SameShippingAdd" id="SameShippingAdd" checked />Use Same Shipping Address<i class="input-frame"></i></label></div>


											</div> <!-- /cst no -->
										</div> <!-- control group -->



										<div id="shipping_detail_drawer" class="">
											<div class="control-group ">
												<label for="firstname" class="control-label ">Ship To</label>
												<div class="controls cmp">
													<select name="shipping_address" id="shipping_address" class="select2-search-input">
														<option value="">--</option>
													</select>
												</div> <!-- /cst no -->
											</div> <!-- control group -->
											<button type="button" class="btn btn-text2 btn-small add_shipping_modal_button pull-right" data-toggle="modal" data-target="#ShippingModal"><svg width="20" height="20"><use href="svg-icon/icons.svg#plus-svg-icon"></use></svg>&nbsp;Add New Shipping</button>

											<div class="control-group ">
												<label for="firstname" class="control-label ">Ship. Name</label>
												<div class="controls cmp">
													<label class="shippingName">-</label>
													<input type="hidden" value="" name="shipping_address_id" id="shipping_address_id">
													<input type="hidden" value="" name="shippingName" id="shippingName">
													<input type="hidden" value="" name="shippingCperson" id="shippingCperson">
													<input type="hidden" value=""  name="shippingLandmark" id="shippingLandmark">
													<input type="hidden" value=""  name="shippingCity" id="shippingCity">
													<input type="hidden" value="" name="shippingPincode" id="shippingPincode">
													<input type="hidden" value="" name="shippingState" id="shippingState">
													<input type="hidden" value="" name="shippingCountry" id="shippingCountry">
												</div> <!-- /cst no -->
											</div> <!-- control group -->
											<div class="control-group">
												<label for="shippingAddress" class="control-label">Ship. Address</label>
												<div class="controls cmp">
													<label class="shippingAddress">-</label>
													<input type="hidden" value="" name="shippingAddress" id="shippingAddress">
													<!--<textarea  name="shippingAddress"  id="shippingAddress"  rows="3" cols="2"  placeholder="Enter Shipping Address" maxlength="500"  ></textarea>-->
												</div> <!--/address-->

											</div>

											<div class="control-group ">
												<label for="firstname" class="control-label ">Ship. Phone</label>
												<div class="controls cmp">
													<label class="shippingPhone">-</label>
													<input type="hidden" value="" name="shippingPhone" id="shippingPhone" placeholder="Enter Shipping Phone" maxlength="30">
												</div> <!-- /cst no -->
											</div> <!-- control group -->


											<div class="control-group ">
												<label for="firstname" class="control-label ">Ship. Email</label>
												<div class="controls cmp">
													<label class="shippingEmail">-</label>
													<input type="hidden" value="" name="shippingEmail" id="shippingEmail" placeholder="Enter Shipping Email">
												</div> <!-- /cst no -->
											</div> <!-- control group -->

											<div class="control-group ">
												<label for="firstname" class="control-label ">Ship. GSTIN</label>
												<div class="controls cmp">
													<label class="shippingGSTIN">-</label>
													<input type="hidden" value="" name="shippingGSTIN" id="shippingGSTIN" placeholder="Enter Shipping GSTIN" maxlength="30">
												</div> <!-- /cst no -->
											</div> <!-- control group -->
											
										</div>

										<div class="control-group control-group-PlaceofSupply">
											<label for="firstname" class="control-label ">Place of Supply<span class="star_red">*</span></label>
											<div class="controls cmp">
												<input type="text" data-value="" name="PlaceofSupply" class=" PlaceofSupply" id="PlaceofSupply" required />
											</div> <!-- /cst no -->
										</div> <!-- control group -->
										
										<div class="control-group control-group-lutno">
											<label for="firstname" class="control-label ">LUT No.</label>
											<div class="controls cmp">
												<input type="text" data-value="" value="" name="lut_no" class="lut_no" id="lut_no" />
												</div> <!-- /lut no -->
										</div> <!-- control group -->


									</div><!-- /CompanyDetailsContent-->
								</div><!-- /CompanyDetailsContent-->
							</div><!-- /CompanyDetails-->

							<div class="span7  span-md-7 span-xs-12 span-sm-12 custom-filed-outer"><!-- BillingDetails -->
								<div class="widget">
									<div class="widget-header">
										<h3>Invoice Detail</h3>
																					<a id="CustomFieldModal-btn" class="CustomFieldModal-btn pull-right" data-toggle="modal" data-target="#CustomFieldModal">
											<svg  width="20" height="24" data-toggle="tooltip" data-html="true" title="Custom Fields"><use href="svg-icon/icons.svg?ver=1007202510072025#custom-field-setting-svg-icon-new"></use></svg>
										</a>
																			</div>
									<hr>
									<div class="widget-content invoice-detail-invoice  equal-height-divs"><!-- CompanyDetailsContent-->
										
											<div class="minibox control-group" style='float:none;'>
												<label class="control-label billing-margin-date">Invoice Type</label>
												<div class="controls cmp">
													<select id="hidden-invoice-country" class="invoicetype" data-value="" data-default-value="" name="invoicetype">

													</select>
													<input class="diffrent_invoice_series_for_export" name="diffrent_invoice_series_for_export" id="hidden-diffrent_invoice_series_for_export" type="hidden" value="0" />
												</div>
											</div>
																					<input type="hidden" id="invoiceseries" name="invoiceseries" value="">
																				<div class="minibox control-group">
											<label class="control-label billing-margin-date">Invoice No.<span class="star_red">*</span></label>
											<div class="controls cmp invoice_pre_post">
												                                                        <input placeholder="Inv Pre." data-pre="" data-export-pre="" name="invoice_prefix" id="invoice_prefix" type="text" value="" class="text-width input_prepost" style="width: 30%;float: left;" >
                                                        <input placeholder="Inv No." name="invoice_id" id="invoice_id" type="text" data-value="" value="1" class="text-width decimal_numeric_only" style="width: 40%;float: left;" required >
                                                        <input placeholder="Inv Post." data-post="" data-export-post="" name="invoice_postfix" id="invoice_postfix" type="text" value="" class="text-width input_prepost" style="width: 30%;float: left;" >
                                                                                                    <input type="hidden" name="auto_select_invoice_id" id="auto_select_invoice_id" value="0">
												<input type="hidden" name="save_with_freeze_inv_id" id="save_with_freeze_inv_id" value="0" data-inv_id="1" data-bill_date="">
												<label id="invoice_id-error" class="error" for="invoice_id" style="width:100%;display:none;"></label>
											</div>

										</div><!-- bill no-->

										<div class="minibox control-group">
											<label class="control-label billing-margin-date">Date<span class="star_red">*</span></label>
											<div class="controls cmp">
												<input placeholder="dd/mm/yy" name="bill_date" type="text" class="text-width" id="datepicker_bill" value="17-Jul-2025" required autocomplete="off">
											</div>
										</div><!-- date-->
										<div style="clear:both;"></div>
										<div class="minibox control-group" >
											<label class="control-label billing-margin">Challan No. </label>
											<div class="controls cmp">
												<input placeholder="Challan No." id="challanno" name="challanno" type="text" class="text-width" value="" maxlength="50"  >
											</div>
										</div><!-- challan no-->

										<div class="minibox control-group" >
											<label class="control-label billing-margin-date">Challan Date</label>
											<div class="controls cmp">
												<input placeholder="dd/mm/yy" name="challan_date" type="text" class="text-width" id="datepicker_challan" value="" autocomplete="off" >
											</div>
										</div><!-- date-->
										<div style="clear:both;"></div>

										<div class="minibox control-group" >
											<label class="control-label billing-margin">P.O. No.</label>
											<div class="controls cmp">
												<input placeholder="P.O. No." id="orderno" name="orderno" value="" type="text" class="text-width" maxlength="50" >
											</div>
										</div><!-- ORDER NO-->

										<div class="minibox control-group" >
											<label class="control-label billing-margin-date">P.O. Date</label>
											<div class="controls cmp">
												<input placeholder="dd/mm/yy" name="orderno_date" type="text" class="text-width" id="datepicker_order" value="" autocomplete="off" >
											</div>
										</div><!-- date-->
										<div class="minibox control-group" >
											<label class="control-label billing-margin">L.R. No.</label>
											<div class="controls cmp">
												<input placeholder="L.R. No." id="lrno" name="lrno" type="text" value="" class="text-width" maxlength="50" >
											</div>
										</div>
										<div class="minibox control-group" >
											<label class="control-label billing-margin">E-Way No.</label>
											<div class="controls cmp">
												<input placeholder="E-Way No." id="eway" name="eway" type="text" value="" class="text-width" maxlength="50" >
											</div>
										</div>
										<div style="clear:both;"></div>
										<div class="minibox control-group" style="display:none !important;">
											<label class="control-label billing-margin">Detail 1</label>
											<div class="controls cmp">
												<input placeholder="Detail 1" id="extra_field3" name="extra_field3" value="" type="text" class="text-width" maxlength="50" >
											</div>
										</div><!-- ORDER NO-->

										<div class="minibox control-group" style="display:none !important;">
											<label class="control-label billing-margin-date">Detail 1 Date</label>
											<div class="controls cmp">
												<input placeholder="dd/mm/yy" name="extra_date_field3" type="text" class="text-width" id="datepicker_extra_date" value="" autocomplete="off" >
											</div>
										</div><!-- date-->
										<div style="clear:both;"></div>
										<div class="minibox control-group" style="display:none !important;">
											<label class="control-label billing-margin">Detail 2</label>
											<div class="controls cmp">
												<input placeholder="Detail 2" id="extra_field4" name="extra_field4" value="" type="text" class="text-width" maxlength="50" >
											</div>
										</div><!-- ORDER NO-->
										<div style="clear:both;"></div>
											<div  class="currency-fields" >
	<div  class="minibox control-group" >
		<label class="control-label billing-margin-date">Currency</label>
		<div class="controls cmp"  >
							<select class="currency" id="currency" name="currency"  >
					<option  >AED - UAE Dirham</option>
					<option  >AFN - Afghani</option>
					<option  >ALL - Lek</option>
					<option  >AMD - Armenian Dram</option>
					<option  >ANG - Netherlands Antillean Guilder</option>
					<option  >AOA - Kwanza</option>
					<option  >ARS - Argentine Peso</option>
					<option  >AUD - Australian Dollar</option>
					<option  >AWG - Aruban Florin</option>
					<option  >AZN - Azerbaijanian Manat</option>
					<option  >BAM - Convertible Mark</option>
					<option  >BBD - Barbados Dollar</option>
					<option  >BDT - Taka</option>
					<option  >BGN - Bulgarian Lev</option>
					<option  >BHD - Bahraini Dinar</option>
					<option  >BIF - Burundi Franc</option>
					<option  >BMD - Bermudian Dollar</option>
					<option  >BND - Brunei Dollar</option>
					<option  >BOB - Boliviano</option>
					<option  >BRL - Brazilian Real</option>
					<option  >BSD - Bahamian Dollar</option>
					<option  >BTN - Ngultrum</option>
					<option  >BWP - Pula</option>
					<option  >BYR - Belarussian Ruble</option>
					<option  >BZD - Belize Dollar</option>
					<option  >CAD - Canadian Dollar</option>
					<option  >CDF - Congolese Franc</option>
					<option  >CHF - Swiss Franc</option>
					<option  >CLP - Chilean Peso</option>
					<option  >CNY - Yuan Renminbi</option>
					<option  >COP - Colombian Peso</option>
					<option  >CRC - Costa Rican Colon</option>
					<option  >CUP - Cuban Peso</option>
					<option  >CVE - Cabo Verde Escudo</option>
					<option  >CZK - Czech Koruna</option>
					<option  >DJF - Djibouti Franc</option>
					<option  >DKK - Danish Krone</option>
					<option  >DOP - Dominican Peso</option>
					<option  >DZD - Algerian Dinar</option>
					<option  >EGP - Egyptian Pound</option>
					<option  >ERN - Nakfa</option>
					<option  >ETB - Ethiopian Birr</option>
					<option  >EUR - Euro</option>
					<option  >FJD - Fiji Dollar</option>
					<option  >FKP - Falkland Islands Pound</option>
					<option  >GBP - Pound Sterling</option>
					<option  >GEL - Lari</option>
					<option  >GHS - Ghana Cedi</option>
					<option  >GIP - Gibraltar Pound</option>
					<option  >GMD - Dalasi</option>
					<option  >GNF - Guinea Franc</option>
					<option  >GTQ - Quetzal</option>
					<option  >GYD - Guyana Dollar</option>
					<option  >HKD - Hong Kong Dollar</option>
					<option  >HNL - Lempira</option>
					<option  >HRK - Kuna</option>
					<option  >HTG - Gourde</option>
					<option  >HUF - Forint</option>
					<option  >IDR - Rupiah</option>
					<option  >ILS - New Israeli Sheqel</option>
					<option selected="selected" >INR - Indian Rupee</option>
					<option  >IQD - Iraqi Dinar</option>
					<option  >IRR - Iranian Rial</option>
					<option  >ISK - Iceland Krona</option>
					<option  >JMD - Jamaican Dollar</option>
					<option  >JOD - Jordanian Dinar</option>
					<option  >JPY - Yen</option>
					<option  >KES - Kenyan Shilling</option>
					<option  >KGS - Som</option>
					<option  >KHR - Riel</option>
					<option  >KMF - Comoro Franc</option>
					<option  >KPW - North Korean Won</option>
					<option  >KRW - Won</option>
					<option  >KWD - Kuwaiti Dinar</option>
					<option  >KYD - Cayman Islands Dollar</option>
					<option  >KZT - Tenge</option>
					<option  >LAK - Kip</option>
					<option  >LBP - Lebanese Pound</option>
					<option  >LKR - Sri Lanka Rupee</option>
					<option  >LRD - Liberian Dollar</option>
					<option  >LSL - Loti</option>
					<option  >LYD - Libyan Dinar</option>
					<option  >MAD - Moroccan Dirham</option>
					<option  >MDL - Moldovan Leu</option>
					<option  >MGA - Malagasy Ariary</option>
					<option  >MKD - Denar</option>
					<option  >MMK - Kyat</option>
					<option  >MNT - Tugrik</option>
					<option  >MOP - Pataca</option>
					<option  >MRO - Ouguiya</option>
					<option  >MUR - Mauritius Rupee</option>
					<option  >MVR - Rufiyaa</option>
					<option  >MWK - Kwacha</option>
					<option  >MXN - Mexican Peso</option>
					<option  >MYR - Malaysian Ringgit</option>
					<option  >MZN - Mozambique Metical</option>
					<option  >NAD - Namibia Dollar</option>
					<option  >NGN - Naira</option>
					<option  >NIO - Cordoba Oro</option>
					<option  >NOK - Norwegian Krone</option>
					<option  >NPR - Nepalese Rupee</option>
					<option  >NZD - New Zealand Dollar</option>
					<option  >OMR - Rial Omani</option>
					<option  >PAB - Balboa</option>
					<option  >PEN - Nuevo Sol</option>
					<option  >PGK - Kina</option>
					<option  >PHP - Philippine Peso</option>
					<option  >PKR - Pakistan Rupee</option>
					<option  >PLN - Zloty</option>
					<option  >PYG - Guarani</option>
					<option  >QAR - Qatari Rial</option>
					<option  >RUB - Russian Ruble</option>
					<option  >RWF - Rwanda Franc</option>
					<option  >SAR - Saudi Riyal</option>
					<option  >SBD - Solomon Islands Dollar</option>
					<option  >SCR - Seychelles Rupee</option>
					<option  >SEK - Swedish Krona</option>
					<option  >SGD - Singapore Dollar</option>
					<option  >SHP - Saint Helena Pound</option>
					<option  >SLL - Leone</option>
					<option  >SOS - Somali Shilling</option>
					<option  >SRD - Surinam Dollar</option>
					<option  >STD - Dobra</option>
					<option  >SVC - El Salvador Colon</option>
					<option  >SYP - Syrian Pound</option>
					<option  >SZL - Lilangeni</option>
					<option  >THB - Baht</option>
					<option  >TJS - Somoni</option>
					<option  >TND - Tunisian Dinar</option>
					<option  >TOP - Pa’anga</option>
					<option  >TRY - Turkish Lira</option>
					<option  >TTD - Trinidad and Tobago Dollar</option>
					<option  >TWD - New Taiwan Dollar</option>
					<option  >TZS - Tanzanian Shilling</option>
					<option  >UAH - Hryvnia</option>
					<option  >UGX - Uganda Shilling</option>
					<option  >USD - US Dollar</option>
					<option  >USN - US Dollar (Next day)</option>
					<option  >UYU - Peso Uruguayo</option>
					<option  >UZS - Uzbekistan Sum</option>
					<option  >VEF - Bolivar</option>
					<option  >VND - Dong</option>
					<option  >VUV - Vatu</option>
					<option  >WST - Tala</option>
					<option  >XAF - CFA Franc BEAC</option>
					<option  >XCD - East Caribbean Dollar</option>
					<option  >XOF - CFA Franc BCEAO</option>
					<option  >XPF - CFP Franc</option>
					<option  >YER - Yemeni Rial</option>
					<option  >ZAR - Rand</option>
					<option  >ZMW - Zambian Kwacha</option>
					<option  >ZWL - Zimbabwe Dollar</option>
				</select>
						</div>
	</div>
	<div  class="minibox control-group">
		<label class="control-label billing-margin">1 <span class="currency-factor-name">INR</span> = </label>
		<div class="controls cmp"  >
				<div class="input-append">
		<input  placeholder="Conversion Factor" id="currency_rate"  name="currency_rate" type="text"   value="1"  data-currency_rate = "1"   class="text-width"   maxlength="16" >
			<span class="add-on">INR</span></div>
					
		</div>
	</div>
	</div>
											<div style="clear:both;"></div>
										<div class="minibox control-group" style="display:none !important;">
											<label class="control-label billing-margin">Type</label>
											<div class="controls cmp">
																								<select id="extra_select_field_value" class="extra_select_field_value select2-dropdown-full" name="extra_select_field_value" >
													<option value="">Select Type</option><option value="Sale">Sale</option><option value="Service">Service</option><option value="Sale and Service">Sale and Service</option>	</select>											<label id="extra_select_field_value-error" class="error" for="extra_select_field_value" style="display: inline;"></label>
											</div>
										</div><!-- ORDER NO-->
										
										<div style="clear:both;"></div>
										<hr>
										<div class="transport-box control-group">
											<label for="firstname" class="control-label ">Delivery</label>
											<div class="controls" id="">
												<select id="transport_detils" class="select2-dropdown-full" name="transport_detils">
													<option value="">Select Delivery Mode</option>
													<option  value="Hand Delivery">Hand Delivery</option>
													<option  value="Transport / Road - Regular">Transport / Road - Regular</option>
													<option  value="Road - Over Dimensional Cargo">Road - Over Dimensional Cargo</option>
													<option  value="Rail">Rail</option>
													<option  value="Air">Air</option>
													<option  value="Ship">Ship</option>
													<option  value="Ship - Cum Road/Rail">Ship - Cum Road/Rail</option>
												</select>
											</div> <!--/ms-->

										</div>
										<div class="control-group transport-box trans_detil_old">
											<button type="button" class="btn btn-text2 btn-small add_transport_modal_button pull-right" data-toggle="modal" data-target="#TransportModal"><svg width="20" height="20"><use href="svg-icon/icons.svg#plus-svg-icon"></use></svg>&nbsp;Add Transport</button>
										</div>
										<div class="control-group transport-box trans_detil_old ">
											<label for="firstname" class="control-label ">Dispatch Through</label>
											<div class="controls ">
												<input type="text" name="dispatch_through" class="transport-combobox" placeholder="Enter transport name" value="" maxlength="255">
												<input value="" name="hidden-transport-id" id="hidden-transport-id" type="hidden">
												<input value="" name="hidden-transport-name" id="hidden-transport-name" type="hidden">
												<input value="" name="hidden-transport-transportID" id="hidden-transport-transportID" type="hidden">
												<input value="" name="hidden-transport-vehicleno" id="hidden-transport-vehicleno" type="hidden">
											</div>

										</div>
										<div class="minibox control-group trans_detil_old">
											<label class="control-label billing-margin">Transport ID</label>
											<div class="controls cmp">
												<input placeholder="Transport ID" value="" id="transport_id_label" name="transport_id_label" type="text" class="text-width" readonly="true">
											</div>
										</div>
										<div class="minibox control-group trans_detil_old">
											<label class="control-label billing-margin">Vehicle No.</label>
											<div class="controls cmp">
												<input placeholder="Vehicle No" value="" id="vehicle_no_label" name="vehicle_no_label" type="text" class="text-width">
											</div>
										</div>
										<div class="minibox control-group trans_detil_extra">
											<label class="control-label billing-margin">Trans.Doc NO</label>
											<div class="controls cmp">
												<input placeholder="Transport Document No" value="" id="transport_no_label" name="transport_no_label" type="text" class="text-width">
											</div>
										</div>
										<div class="minibox control-group trans_detil_extra">
											<label class="control-label">Trans.Doc Date</label>
											<div class="controls cmp">
												<input placeholder="dd/mm/yy" value="" id="transport_date_label" name="transport_date_label" type="text" class="text-width" autocomplete="off">
											</div>
										</div><!-- date-->
										<div class="minibox control-group trans_detil_extra">
											<label class="control-label">Distance for e-way bill (in km)</label>
											<div class="controls cmp" style="position:relative;">
												<input type="hidden" value="" id="shipping_distance_eway1">
												<input type="text" value="" name="shipping_distance_eway" id="shipping_distance_eway">
																									<div class="btn distance_autofill_manual div-inner-input" distance_for="shipping">Auto Fill</div>
													<input type="hidden" id="org_state" name="org_state" value="Karnataka">
													<input type="hidden" id="org_pincode" name="org_pincode" value="560091">
													<input type="hidden" value="10594" id="userid" name="userid" />
																							</div>
										</div>
										<div style="clear:both;"></div>
											<div  class="currency-fields export-fields" >
	<div  class="minibox control-group" >
		<label class="control-label billing-margin-date">Last State in India</label>
		<div class="controls cmp"  >
				<select class="actToState all_state_list" data-value="" id="actToState" name="actToState"  >
				</select>
		</div>
	</div>
	<div  class="minibox control-group">
		<label class="control-label billing-margin">Last Pincode in India</label>
		<div class="controls cmp"  >
		<input  placeholder="Last Pincode in India" id="actToPincode"  name="actToPincode" type="text"   value=""   class="text-width"   maxlength="6" >
		</div>
	</div>
	</div>
										</div><!-- CompanyDetailsContent-->
								</div>
							</div><!-- BillingDetails -->
							<!--class="widget widget-table action-table"-->

														<div id="shipping_data_drawer" class="">
								<div class="span12" style="margin-top:10px;">
									<div class="widget">
										<div class="widget-header">
											<h3>Export Shipping Detail</h3>
										</div>
										<hr>
										<div class="widget-content">
											<div class="minibox control-group">
												<label for="shippingBillNo" class=" control-label billing-margin">Ship. Bill no</label>
												<div class="controls">
													<input type="text" value="" name="shippingBillNo" id="shippingBillNo" placeholder="Ship. Bill no" maxlength="30">
												</div>
											</div> <!-- control group -->
											<div class="minibox control-group">
												<label for="shippingBillDate" class=" control-label billing-margin">Ship. Bill date</label>
												<div class="controls">
													<input placeholder="dd/mm/yy" name="shippingBillDate" type="text" class="text-width" id="datepicker_shippingBillDate" value="" autocomplete="off">
												</div>
											</div>
											<div class="minibox control-group">
												<label for="shippingPortCode" class=" control-label billing-margin">Ship. Port code</label>
												<div class="controls">
													<input type="text" value="" name="shippingPortCode" id="shippingPortCode" placeholder="Ship. Port code" maxlength="30">
												</div>
											</div> <!-- control group -->
											<div class="minibox control-group">
												<label for="precarriage_by" class=" control-label billing-margin">Pre-carriage by</label>
												<div class="controls">
													<input type="text" value="" name="precarriage_by" id="precarriage_by" placeholder="Pre-carriage by" maxlength="30">
												</div>
											</div> <!-- control group -->
											<div class="minibox control-group">
												<label for="place_of_precarriage" class=" control-label billing-margin">Place of Pre-carriage</label>
												<div class="controls">
													<input type="text" value="" name="place_of_precarriage" id="place_of_precarriage" placeholder="Place of Pre-carriage" maxlength="30">
												</div>
											</div> <!-- control group -->
											<div class="minibox control-group">
												<label for="vesselflight_no" class=" control-label billing-margin">Vessel/Flight No</label>
												<div class="controls">
													<input type="text" value="" name="vesselflight_no" id="vesselflight_no" placeholder="Vessel/Flight No" maxlength="30">
												</div>
											</div> <!-- control group -->
											<div class="minibox control-group">
												<label for="port_of_loading" class=" control-label billing-margin">Port of Loading</label>
												<div class="controls">
													<input type="text" value="" name="port_of_loading" id="port_of_loading" placeholder="Port of Loading" maxlength="30">
												</div>
											</div> <!-- control group -->
											<div class="minibox control-group">
												<label for="port_of_discharge" class=" control-label billing-margin">Port of Discharge</label>
												<div class="controls">
													<input type="text" value="" name="port_of_discharge" id="port_of_discharge" placeholder="Port of Discharge" maxlength="30">
												</div>
											</div> <!-- control group -->
											<div class="minibox control-group">
												<label for="final_destiantion" class=" control-label billing-margin">Final Destination</label>
												<div class="controls">
													<input type="text" value="" name="final_destiantion" id="final_destiantion" placeholder="Final Destination" maxlength="30">
												</div>
											</div> <!-- control group -->
											<div class="minibox control-group">
												<label for="shippingPortCode" class=" control-label billing-margin">Country of Origin</label>
												<div class="controls">
																											<select onchange='selct_country(this.value)' type="list" data-value="" name="country_of_origin" class="span4" id="country_of_origin"></select>
																									</div>
											</div> <!-- control group -->
											<div class="minibox control-group">
												<label for="shippingPortCode" class=" control-label billing-margin">Country of Final</label>
												<div class="controls">
																											<select onchange='selct_country(this.value)' type="list" data-value="" name="country_of_final" class="span4" id="country_of_final"></select>
																									</div>
											</div> <!-- control group -->
											<div class="minibox control-group">
												<label for="weight_kg" class=" control-label billing-margin">Weight(KG)</label>
												<div class="controls">
													<input type="text" value="" name="weight_kg" placeholder="Weight(KG)" class="span4" />
												</div>
											</div> <!-- control group -->
											<div class="minibox control-group">
												<label for="packeges" class=" control-label billing-margin">Packages</label>
												<div class="controls">
													<input type="text" value="" name="packeges" placeholder="Packages" class="span4" />
												</div>
											</div> <!-- control group -->
										</div>
									</div>
								</div>
							</div>

							<div class="span12 bill_main_table custom-columns-outer">
								<div class="widget">
									<div class="product_item_outer_header">
										<div class="widget-header _section_1">
											<h3>Product Items</h3>
											<div class="header_buttons">
												<button type="button" class="btn btn-primary add_product_modal_button addProduct"><svg width="20" height="20"><use href="svg-icon/icons.svg#plus-svg-icon"></use></svg>&nbsp;Add Product</button>
												<button type="button" class="btn btn-primary add_transport_charge_modal_button" data-toggle="modal" data-target="#TransportChargeModal" style="margin-left: 10px;"><svg width="20" height="20"><use href="svg-icon/icons.svg#plus-svg-icon"></use></svg>&nbsp;Add Additional Charges</button>
											</div>
										</div>
										<div class="_section_2">
											<div class="cd-pricing-switcher">
												<div class="switcher_label">Discount : </div>
												<p class="fieldset">
													<input type="radio" name="disc-type" value="1" id="disc-rs" >
													<label for="disc-rs">Rs</label>
													<input type="radio" name="disc-type" value="0" id="disc-p"  checked>
													<label for="disc-p">%</label>
													<span class="cd-switch"></span>
												</p>
											</div>
                                            <div class="CustomColumnsModalBlock">
                                                                                                    <a  class="pull-right CustomColumnsModal-btn" data-toggle="modal" data-target="#CustomColumnsModal" >
                                                    <svg  width="20" height="24"  data-toggle="tooltip" data-html="true" title="Custom Columns"><use href="svg-icon/icons.svg?ver=1007202510072025#custom-field-setting-svg-icon-new"></use></svg>
                                                </a>
                                                                                            </div>
											
										</div>
									</div>

									<div class="widget-content">
									  	<div class="div-invoice-product-items-table">	
										<table class="invoice-product-items-table table  table-bordered 
											 show_product_note																						 hide_last_invoice_price											 hide_product_mrp												 hide_product_code											 " id="document-item-list">
											<thead>
												<tr>
													<th><center>SR.</center></th>
													<th><center>Product / Other Charges</center></th>
																										<th class="enable_batch_no show-batch-column"><center>Batch No.</center></th>
																										<th class="show_product_mrp"><center>MRP</center></th>
													<th class="show_product_code"><center>Product Code</center></th>
													<th><center>HSN/SAC Code</center></th>
																										<th><center>Qty. / Stock</center></th>
													<th><center>UOM</center></th>
																										<th><center>Price (Rs)</center></th>
													<th class="discount_field"><center>Discount</center></th>
																										<th class="product_row_cgst_col"><center>CGST + SGST</center></th>
													<th class="product_row_igst_col"><center>IGST</center></th>
													<th><center>CESS</center></th>
													<th><center>Total</center></th>
													<th><center></center></th>
												</tr>
											</thead>
											<tbody>
												
																									<tr class="product-item-row">
														<td>
															<label class="product-item-row-number">1</label>
														</td>
														<td>
															<label class="product-item-row-number product-item-row-number-tab">1</label>
															<div class="inputlabel_wrapper">
																<input class="product-combobox" placeholder="Enter Product name" maxlength="500" name="product_name">
																<label for="product_name">Product Name</label>
															</div>
															<input class="hidden-item-product-id" name="hidden-item-product-id[]" type="hidden">
															<input class="hidden-item-detail-product-id" name="hidden-item-detail-product-id[]" type="hidden">
															<input class="hidden-item-product-name" name="hidden-item-product-name[]" type="hidden">
															<input class="hidden-item-product-uom" name="hidden-item-product-uom[]" type="hidden">
															<input class="hidden-item-product-primary-uom" name="hidden-item-product-primary-uom[]" type="hidden">
															<input class="hidden-item-product-uom-rates" name="hidden-item-product-uom-rates[]" type="hidden">
															<input class="hidden-item-product-is_transport" name="hidden-item-product-is_transport[]" type="hidden">
															<input class="hidden-item-product-cgst" name="hidden-item-product-cgst[]" type="hidden">
															<input class="hidden-item-product-sgst" name="hidden-item-product-sgst[]" type="hidden">
															<input class="hidden-item-product-igst" name="hidden-item-product-igst[]" type="hidden">
															
															<input class="hidden-item-product-att1-name" name="hidden-item-product-att1-name[]" type="hidden">
															<input class="hidden-item-product-att1-val" name="hidden-item-product-att1-val[]" type="hidden">
															<input class="hidden-item-product-att2-name" name="hidden-item-product-att2-name[]" type="hidden">
															<input class="hidden-item-product-att2-val" name="hidden-item-product-att2-val[]" type="hidden">
															<input class="hidden-item-product-att3-name" name="hidden-item-product-att3-name[]" type="hidden">
															<input class="hidden-item-product-att3-val" name="hidden-item-product-att3-val[]" type="hidden">
															<input class="hidden-item-product-att4-name" name="hidden-item-product-att4-name[]" type="hidden">
															<input class="hidden-item-product-att4-val" name="hidden-item-product-att4-val[]" type="hidden">
															<input class="hidden-item-product-stockType" name="hidden-item-product-stockType[]" type="hidden">
															<input class="hidden-item-product-batch-id" name="hidden-item-product-batch-id[]" type="hidden">
															<input class="hidden-item-product-batch-name" name="hidden-item-product-batch-name[]" type="hidden">
															<input type="hidden" name="model_no[]" class="hidden-batch-model">
															<input type="hidden" name="size[]" class="hidden-batch-size">
															<input type="hidden" name="manufacture_date[]" class="hidden-batch-mfg">
															<input type="hidden" name="expiry_date[]" class="hidden-batch-expiry" >
															<input value="" type="hidden" name="hidden_quantity[]">
															<input class="ref_saleorder_detail_item_id"	name="ref_saleorder_detail_item_id[]" type="hidden" >
															<input class="ref_jobwork_detail_item_id"	name="ref_jobwork_detail_item_id[]" type="hidden" >

																														<div class="inputlabel_wrapper has-serialno">
																<input type="text" name="serialno[]" class="serialno" placeholder="Serial No" autocomplete="off" value="" readonly>
																<div class="suggesstion-batch"></div>
																<label for="serialno[]">Serial No</label>
															</div>
															<div class="inputlabel_wrapper">
																<textarea class="product_note" placeholder="Item Note..." name="product_note[]"></textarea>
																<label for="product_note">Product Note</label>
															</div>
														</td>
														
																												<td class="enable_batch_no has-batchno show-batch-column">
															<div class="inputlabel_wrapper">
																<input type="text" name="batch_name[]" class="batch_name" placeholder="Batch No." maxlength="20" autocomplete="off" readonly>
																<div class="suggesstion-batch"></div>
																<label for="batch_name[]">Batch No.</label>
															</div>
														</td>
																																																																						<td class="show_product_mrp">
															<div class="inputlabel_wrapper">
																<input type="text" name="mrp[]"  data-mrp-val="" class="mrp decimal_numeric_only" placeholder="MRP"  autocomplete="off" maxlength="10">
																<label name="expiry_date[]">MRP</label>
															</div>
														</td>
														<td class="show_product_code">
															<div class="inputlabel_wrapper">
																<input type="text" name="product_code[]"   data-product_code-val="" class="product_code" placeholder="Product Code"  autocomplete="off" maxlength="50">
																<label name="expiry_date[]">Product Code</label>
															</div>
														</td>
														
														<td class="td-hsn">
															<div class="inputlabel_wrapper">
																<input type="text" onkeyup="this.setAttribute('value', this.value);" name="hsccode[]" class="hsccode" value="" placeholder="HSN/SAC" style="width:60px;" maxlength="20" >
																<label for="hsccode[]">HSN/SAC</label>
															</div>
														</td>
																												<td class="td-qty">
															<div class="inputlabel_wrapper qnt-wrapper">
																<label class="product-quantity-primary-uom"></label>
																<input type="text" value="" onkeyup="this.setAttribute('value', this.value);" name="quantity[]" class="quantity decimal_numeric_only" data-qty-val="" placeholder="Qty." style="width:50px;" maxlength="10" data-msg="Not enough stock!">
																<label for="quantity[]">Qty</label>
																<input type="hidden" class="old_quantity" name="old_quantity[]" value="">
																<input type="hidden" class="rem_quantity" name="rem_quantity[]" value="">
															</div>
															<label class="product-quantity-available"></label>
															<label class="product-quantity-available-secondery"></label>
														</td>
														<td class="td-uom">
															<div class="inputlabel_wrapper">
																<input type="text" name="uom" class="uom" placeholder="UOM" maxlength="20">
																<label>UOM</label>
															</div>
														</td>
																												<td class="td-rate">
															<center>
																<div class="inputlabel_wrapper">
																	<input type="text" value="" onkeyup="this.setAttribute('value', this.value);" name="rate[]" class="rate decimal_numeric_only" data-rate-val="" placeholder="Price" style="width:100px;" maxlength="10" >
																	<label for="rate[]">Price</label>
																</div>
																<div class="currency-fields">
																	<div class="currency-factor-symbol">Rs</div>
																	<div class="inputlabel_wrapper">
																		<input value="" type="text" class="rate_usd decimal_numeric_only" placeholder="Price" maxlength="10" >
																		<label>Price</label>
																	</div>
																</div>
																<label class="customer_rate_label"></label>
																<span class='last-price-tip'><svg width="12" height="12"><use href="svg-icon/icons.svg#info-dark-svg-icon"></use></svg></span>
															</center>
														</td>
														
														<td class="discount_field">
															<div class="inputlabel_wrapper">
																<input type="text" onkeyup="this.setAttribute('value', this.value);" name="disc[]" class="disc decimal_numeric_only" style="width:50px;" value="0" maxlength="10">
																<label for="disc[]">Disc</label>
															</div>
															<div class="currency-fields">
																<div class="currency-factor-symbol">Rs</div>
																<div class="inputlabel_wrapper">
																	<input value="" type="text" class="discount_usd decimal_numeric_only" placeholder="Discount" maxlength="10" >
																	<label>Disc</label>
																</div>
															</div>
															<input type="hidden" name="taxable_line_value[]" class="taxable_line_value"   data-taxable-val="">
															<input type="hidden" name="gd_taxable_line_value[]" class="gd_taxable_line_value">
															<input type="hidden" name="gd_discount_line_value[]" class="gd_discount_line_value">
														</td>
																												<td class="product_row_cgst_col">
															<div class="inputlabel_wrapper">
																<select name="cgst_select" class="cgst_select" >
																	<option value="">--</option>
																	<option value='0' >0 + 0</option><option value='0.05' >0.05 + 0.05</option><option value='0.125' >0.125 + 0.125</option><option value='0.25' >0.25 + 0.25</option><option value='0.5' >0.5 + 0.5</option><option value='0.75' >0.75 + 0.75</option><option value='1.5' >1.5 + 1.5</option><option value='2.5' >2.5 + 2.5</option><option value='3' >3 + 3</option><option value='3.75' >3.75 + 3.75</option><option value='6' >6 + 6</option><option value='9' >9 + 9</option><option value='14' >14 + 14</option>																</select>
																<!--<input type="text" name="cgst[]" class="cgst decimal_numeric_only"    placeholder="%"  style="width:30px;" maxlength="5" >-->
																<label for="cgst[]">CGST + SGST</label>
															</div>

															<input type="text" class="cgst_sgst_rate text_rate decimal_numeric_only" readonly="readonly" style="width:50px;" value="0">

															<input type="hidden" name="cgst_rate[]" class="cgst_rate text_rate decimal_numeric_only" readonly="readonly" style="width:50px;" value="0"> <input type="hidden" name="sgst_rate[]" class="sgst_rate text_rate decimal_numeric_only" readonly="readonly" style="width:50px;" value="0">
															<input type="hidden" name="cgst[]" class="cgst decimal_numeric_only"  placeholder="%" style="width:30px;" maxlength="5" >
															<input type="hidden" name="sgst[]" class="sgst decimal_numeric_only" placeholder="%" style="width:30px;" maxlength="5" >
														</td>





														<td class="product_row_igst_col">
															<div class="inputlabel_wrapper"> 
																<select name="igst[]" class="igst" data-product-gst="">
																	<option value="">--</option>
																	<option value='0' >0</option><option value='0.1' >0.1</option><option value='0.25' >0.25</option><option value='0.5' >0.5</option><option value='1' >1</option><option value='1.5' >1.5</option><option value='3' >3</option><option value='5' >5</option><option value='6' >6</option><option value='7.5' >7.5</option><option value='12' >12</option><option value='18' >18</option><option value='28' >28</option>																</select>
																<!-- <input type="text" name="igst[]"  value=""  onkeyup="this.setAttribute('value', this.value);"  class="igst decimal_numeric_only"    placeholder="%"  style="width:30px;" maxlength="5" >-->
																<label for="igst[]">IGST</label>
															</div>
															<input type="text" name="igst_rate[]" class="igst_rate text_rate decimal_numeric_only" readonly="readonly" style="width:50px;" value="0" data-gst-val="" >
														</td>
														<td>
															<div class="inputlabel_wrapper inputlabel_wrapper_half">
																<input type="text" name="cess[]" class="cess decimal_numeric_only" style="width:40px;" placeholder="%" >
																<label for="cess[]">Cess %</label>
															</div>
															<input value="" type="hidden" name="cessrate[]" class="cessrate" >
															<center class="hide_unser_tab">+</center>
															<div class="inputlabel_wrapper inputlabel_wrapper_half">
																<input type="text" name="cess_amount[]" class="cess_amount decimal_numeric_only" placeholder="Rs" style="width:40px;" >
																<label for="cess_amount[]">Cess Rs</label>
															</div>
															<input  type="hidden"  class="hidden-cess-type" >
															<input  type="hidden" class="hidden-cess-amount" >
														</td>
														<td>
															<center>
																<div class="inputlabel_wrapper">
																	<input type="text" name="line_total[]" data-old_line_total="" class="line_total decimal_numeric_only" placeholder="Total" style="width:80px;" >
																	<label>Total</label>
																</div>
																<div class="currency-fields">
																	<div class="currency-factor-symbol">Rs</div>
																	<div class="inputlabel_wrapper">
																		<input value="" type="text" class="line_total_usd" placeholder="Total in Currency" maxlength="10" >
																		<label>Total in Currency</label>
																	</div>
																</div>
															</center>
														</td>
														<td>
															<div class="addmore-section">
																<button type="button" value="" class="btn btn-primary btnadd-product-line btnadd-row-item btnaddmoreoption"><svg width="20" height="20"><use href="svg-icon/icons.svg#plus-svg-icon"></use></svg></button>
																<button type="button" value="" class="btn btn-danger btnremove-product-line btnremove-row-item btnaddmoreoption" style="display:none;"><svg width="20" height="20"><use href="svg-icon/icons.svg#minus-svg-icon"></use></svg></button>
															</div>
														</td>
														
													</tr>
																							</tbody>

											<tfoot>
												<tr class="all-row-totals">
													<td colspan="2" style="text-align:right;">&nbsp; Total Inv. Val </td>
													<td class="enable_batch_no show-batch-column"></td>																																																																	<td class="show_product_mrp">
														<input type="hidden" name="row_total_mrp" id="row_total_mrp" value="" />
														<label type="text" name="row_total_mrp_lable" id="row_total_mrp_lable" class="row_total_mrp_lable"></label>
													</td>
																										<td></td>
																										<td>
														<input type="hidden" name="row_total_qty" id="row_total_qty" value="" />
														<label type="text" name="row_total_qty_lable" id="row_total_qty_lable" class="row_total_qty_lable"></label>
													</td>
													<td></td>
																										<td>
														<input type="hidden" name="row_total_price" id="row_total_price" value="" />
														<label type="text" name="row_total_price_lable" id="row_total_price_lable" class="row_total_price_lable"></label>
													</td>
													<td class="discount_field">
														<input type="hidden" name="row_total_disc" id="row_total_disc" value="" />
														<label type="text" name="row_total_disc_lable" id="row_total_disc_lable" class="row_total_disc_lable"></label>
													</td>
																										<td class="product_row_cgst_col">
														<input type="hidden" name="row_total_cgst_rate" id="row_total_cgst_rate" value="" />
														<input type="hidden" name="row_total_sgst_rate" id="row_total_sgst_rate" value="" />
														<label type="text" name="row_total_cgst_rate_lable" id="row_total_cgst_rate_lable" class="row_total_cgst_rate_lable"></label>
													</td>
													<td class="product_row_igst_col">
														<input type="hidden" name="row_total_igst_rate" id="row_total_igst_rate" value="" />
														<label type="text" name="row_total_igst_rate_lable" id="row_total_igst_rate_lable" class="row_total_igst_rate_lable"></label>
													</td>
													<td>
														<input type="hidden" name="row_total_cess_rate" id="row_total_cess_rate" value="" />
														<label type="text" name="row_total_cess_rate_lable" id="row_total_cess_rate_lable" class="row_total_cess_rate_lable"></label>
													</td>
													<td>
														<input type="hidden" name="row_total_total" id="row_total_total" value="" />
														<label type="text" name="row_total_total_lable" id="row_total_total_lable" class="row_total_total_lable"></label>
													</td>
													<td></td>
												</tr>
											</tfoot>
										</table>
										</div>
										
										<div class="row">
											<div class="span5 span-md-6  span-sm-6 span-xs-12 row-span-right">
												<table class="table document-total-section">
													<tbody>
														<tr>
															<td  >
																Total Taxable
															</td>
															<td >
		
																<div class="total-controls">
																	<input type="hidden" name="total_taxable" id="total_taxable" value="" />
																	<input type="hidden" name="gd_total_taxable" id="gd_total_taxable" value="" />
																	<center><label type="text" name="total_taxable_lable" id="total_taxable_lable" class="total_taxable_lable"></label></center>
																</div>
															</td>
														</tr>
														
																												
																												<tr>
															<td  >
																<label class="reverse_charge_label_text">Total Tax</label>
															</td>
															<td >
																<div class="total-controls">
																	<input type="hidden" name="total_tax" id="total_tax" value="" />
																	<center><label type="text" name="total_tax_lable" id="total_tax_lable" class="total_tax_lable"></label></center>
																</div>
															</td>
														</tr>
														
																													<tr class="other-tax-amount-tr other_tax_1">
																<td  >
																	<div class="hidden_other_tax">
																		<label class="label-input"><input type="text" name="other_tax_label" id="other_tax_label" value="TCS" /></label>
																		<div class="cd-pricing-switcher">
																			<p class="fieldset">
																				<input type="radio" name="other_tax_in_rupee" id="other_tax_in_rupee-1" value="1" autocomplete="off" >
																				<label for="other_tax_in_rupee-1">Rs</label>
																				<input type="radio" name="other_tax_in_rupee" id="other_tax_in_rupee-0" value="0" autocomplete="off" checked>
																				<label for="other_tax_in_rupee-0">%</label>
																				<span class="cd-switch"></span>
																			</p>
																			<p class="fieldset">
																				<input type="radio" name="other_tax_type_minus" id="other_tax_type_minus-1" value="1" autocomplete="off" >
																				<label for="other_tax_type_minus-1">-</label>
																				<input type="radio" name="other_tax_type_minus" id="other_tax_type_minus-0" value="0" autocomplete="off" checked>
																				<label for="other_tax_type_minus-0">+</label>
																				<span class="cd-switch"></span>
																			</p>
																		</div>
																	</div>
																</td>
																<td >
																	<div class="hidden_other_tax">
																		<div class="total-controls">
																			<input type="text" name="other_tax_value" id="other_tax_value" value="" />
																			<input type="hidden" name="other_tax_amount" id="other_tax_amount" value="" />
																			<input type="hidden" name="other_tax_1_after_Taxable" id="other_tax_1_after_Taxable" value="0" />
																			<label class="other_tax_amount_label" id="other_tax_amount_label"></label>
																		</div>
																	</div>
																</td>
															</tr>
															<tr class="other-tax-amount-tr show_other_tax_1">
																<td colspan="2" style="width:100%;text-align: right;padding-right: 10px;">
																	<a>Add Other Tax</a>
																</td>
															</tr>
																												<tr class="other-tax-amount-tr show_other_tax_2 ">
															<td colspan="2" style="width:100%;text-align: right;padding-right: 10px;">
																<a>Add Other Amount</a>
															</td>
														</tr>
														<tr class="other-amount-tr  other_tax_2">
															<td  >
																<div class="hidden_other_tax">
																	<label class="label-input"><input type="text" name="total_discount_label" id="total_discount_label" value="Discount" /></label>
																	<div class="cd-pricing-switcher">
																		<p class="fieldset">
																			<input type="radio" name="total_discount_in_rupee" id="total_discount_in_rupee-1" value="1" autocomplete="off" checked>
																			<label for="total_discount_in_rupee-1">Rs</label>
																			<input type="radio" name="total_discount_in_rupee" id="total_discount_in_rupee-0" value="0" autocomplete="off" >
																			<label for="total_discount_in_rupee-0">%</label>
																			<span class="cd-switch"></span>
																		</p>
																		<p class="fieldset">
																			<input type="radio" name="total_discount_type_minus" id="total_discount_type_minus-1" value="1" autocomplete="off" checked>
																			<label for="total_discount_type_minus-1">-</label>
																			<input type="radio" name="total_discount_type_minus" id="total_discount_type_minus-0" value="0" autocomplete="off" >
																			<label for="total_discount_type_minus-0">+</label>
																			<span class="cd-switch"></span>
																		</p>
																	</div>
																</div>
															</td>
															<td >
																<div class="hidden_other_tax">
																	<div class="total-controls">
																		<input type="text" name="total_discount_value" id="total_discount_value" value="" />
																		<input type="hidden" name="total_discount_amount" id="total_discount_amount" value="" />
																		<label class="total_discount_amount_label" id="total_discount_amount_label"></label>
																	</div>
																</div>
															</td>
														</tr>
														<tr class="roundoff-tr">
															<td>
																<div class="cd-pricing-switcher">
																	<div class="roundoff-lbl">Round Off </div>
																	<p class="fieldset">
																		<input type="radio" name="roundoff" value="1" id="roundoff-1"  checked>
																		<label for="roundoff-1">Yes</label>
																		<input type="radio" name="roundoff" value="0" id="roundoff-0" >
																		<label for="roundoff-0">No</label>
																		<span class="cd-switch"></span>
																	</p>
																</div>
															</td>
															<td >
																<div class="total-controls">
																	<center><label type="text" id="roundoff_amount" class="total_tax_lable"></label></center>
																</div>
															</td>
														</tr>
														<tr class="grand-total-section">
															<td  >
																Grand Total
															</td>
															<td >
																<div class="total-controls">
																	<input type="hidden" name="grand_total" data-oldval="" id="grand_total" value="" />
																	<center><label type="text" name="grand_total_lable" id="grand_total_lable" class="grand_total_lable"></label></center>
																	<div class="currency-fields">
																		<center><label type="text" name="currency_grandtotal_lable" id="currency_grandtotal_lable" class="currency_grandtotal_lable"></label></center>
																	</div>
																	<input type="hidden" name="currency_grandtotal" id="currency_grandtotal" value="" />
																</div>
															</td>
														</tr>
																													<input type="hidden" name="subsidy_amount" id="subsidy_amount" value="" />
															<input type="hidden" name="cus_pay_grandtotal" id="cus_pay_grandtotal" value="" />
															<input type="hidden" name="currency_cus_pay_grandtotal" id="currency_cus_pay_grandtotal" value="" />
																												<tr>
															<td colspan="2" class="tdttlinwords">
																<label class="inner-widget-content-label">Total in words</label>
																<label for="firstname" id="grandtotalwords"></label>
																<input type="hidden" name="hidden_round_off_value" id="hidden_round_off_value" value="" />
																<input type="hidden" name="hidden_grandtotalwords" id="hidden_grandtotalwords" value="" />
																<input type="hidden" name="hidden_cust_pay_grandtotalwords" id="hidden_cust_pay_grandtotalwords" value="" />
																<input type="hidden" name="hidden_currency_total_in_words" id="hidden_currency_total_in_words" value="" />
																<input type="hidden" name="hidden_currency_cus_pay_total_in_words" id="hidden_currency_cus_pay_total_in_words" value="" />
															</td>
														</tr>
													</tbody>
												</table>
												<hr style="margin-top:0;">
												<div class="control-group">
													<input type="hidden" name="discount_in" id="discount_in" value="percentage" />
													<input type="hidden" name="discount_per_item" id="discount_per_item" value="0" />
													<input type="hidden" name="enable_inventory" id="enable_inventory" value="1" />
													<label for="payment" class="control-label">Payment Type<span class="star_red">*</span></label>
													<div class="controls">

														
																													<div class="payment-type-section">
																																		<input type="radio" id="CREDIT" value="CREDIT" class="payment" name="payment"  required >
															    		<label for="CREDIT" class="btn btn-payment-type btn-payment-type-credit">CREDIT</label>
																																		<input type="radio" id="CASH" value="cash" class="payment" name="payment"  required >
															    		<label for="CASH" class="btn btn-payment-type btn-payment-type-cash">CASH</label>
																																		<input type="radio" id="CHEQUE" value="cheque" class="payment" name="payment"  required >
															    		<label for="CHEQUE" class="btn btn-payment-type btn-payment-type-cheque">CHEQUE</label>
																																		<input type="radio" id="ONLINE" value="online_transfer" class="payment" name="payment"  required >
															    		<label for="ONLINE" class="btn btn-payment-type btn-payment-type-online_transfer">ONLINE</label>
																															</div>
															
																												<label id="payment-error" class="error" for="payment" style="width:100%;display:none;"></label>
													</div> <!-- /controls -->
												</div> <!-- /control-group -->
												<div class="control-group newpaymenttype" id="payment_received_row">
													<label for="check" class="control-label">Payment Received</label>
													<div class="controls">
														<input id="payment_received" name='payment_received' class="" maxlength="12" />
													</div> <!-- /controls -->
												</div> <!-- /control-group -->
												<div class="control-group newpaymenttype" id="payment_note">
													<label for="check" class="control-label">Payment Note</label>
													<div class="controls">
														<textarea id="payment_note" name='payment_note' class="" maxlength="255"></textarea>
													</div> <!-- /controls -->
												</div> <!-- /control-group -->

												<div class="control-group sez-box hide" id="check_no">
													<hr>
													<label for="check" class="control-label">Remark For Sez / Export Invoice </label>
													<div class="controls">
														<textarea id="remark_sez" name='remark_sez' class="Remark-4-XpoInvo" maxlength="255" data-id = "" data-value=""></textarea>
													</div> <!-- /controls -->
												</div> <!-- /control-group -->

																								<div class="widget-content inner-widget-content adjustPayment" style="display:none;">
													<label class="inner-widget-content-label-adjpay">This customer has an advance payment of <b>Rs: <span class="table-total-remaining"></span></b>, do you want to adjust the advance payment on this invoice?</label>
													<div class="cd-pricing-switcher">
														<p class="fieldset">
															<input type="radio" name="adjustpayoff" value="1" id="adjustpayoff-1">
															<label for="adjustpayoff-1">Yes</label>
															<input type="radio" name="adjustpayoff" value="0" id="adjustpayoff-0" checked>
															<label for="adjustpayoff-0">No</label>
															<span class="cd-switch"></span>
														</p>
													</div>
													<div class="curSessionInList adjpaytable" id="curSessionInList-container" style="height:200px;overflow:auto;display: inline-block;">
														<table class="table table-hover table-striped" id="curSessionInList"></table>
													</div>
													<table class="table-bordered payment_totals adjtotalpayment">
														<colgroup>
															<col style="width: 40%">
															<col style="width: 25%">
															<col style="width: 35%">
														</colgroup>
														<tr>
															<td rowspan="3">
																<input type="hidden" class="table-total-grandtotal" value="">
																<input type="hidden" class="table-total-remainingtotal" value="">
															</td>
															<td class="text-left-align">
																Total Advance
															</td>
															<td class="text-right-align">
																<span class="table-total-remaining">0</span>
															</td>
														</tr>
														<tr>
															<td class="text-left-align">
																Amount Adjusted
															</td>
															<td class="text-right-align">
																<span class="table-total-adjusted">0</span>
															</td>
														</tr>
														<tr>
															<td class="text-left-align">
																Advance after adjustment
															</td>
															<td class="text-right-align">
																<span class="table-total-pending tetxt-right-align">0</span>
															</td>
														</tr>

													</table>

												</div>
																																				

													<div class="smart_suggetion-main " >
												<div class="widget-header">
												<h3>Smart Suggestion</h3>
												<div class="smart_suggestion_checkbox">
													<div class="form-check">
													<label class="form-check-label"><input type="checkbox" id="smart_toggle" name="smart_suggetion_toggle" class="smart_suggetion_toggle"><svg width="20" height="20"><use href="svg-icon/icons.svg#plus-svg-icon"></use></svg></label>
														
													</div>
												</div>
												</div>
												<div class="widget-content  smart_suggestion_data" style="display: none;">
													<hr>
														
														<div class="control-group span6">
															<div class="controls cmp" id="companyshippinh">
																<div class="form-check"><label class="form-check-label"><input type="checkbox" name="share_email" class="share_email" id="share_email" />Share on Email<i class="input-frame"></i><svg width="20" height="20"><use href="svg-icon/icons.svg#email-svg-icon"></use></svg></i></label></div>
															</div> <!-- /cst no -->
														</div> <!-- control group -->

																																				
																								
													</div>
													</div>
												</div>							
											<div class="span5 span-md-6 span-sm-6 span-xs-12 row-span-left">
												<hr style="margin-top: 0;">
												<div class="control-group" id="due_date">
													<label for="check" class="control-label">Due Date</label>
													<div class="controls">
														<input placeholder="dd/mm/yy" name="due_date" data-main-default-due="15" data-default-due="15" type="text" class="" id="datepicker_lr" value="" data-value="" 
															autocomplete="off">
													</div> <!-- /controls -->
												</div> <!-- /control-group -->

												<div class="control-group">
													<label for="Bank" class="control-label">Bank</label>
													<div class="controls">
														<select name="bank" id="bank" class="">
															<option value="bank1" >Corporation Bank</option>															

															<option value="" >Hide Bank Details</option>
														</select>
													</div> <!-- /controls -->
												</div> <!-- /control-group -->
												<hr>
																								
												<h4>Terms &amp; Condition / Additional Note</h4>
												<div class="termConditionSection sortabletc ui-sortable">
																		<div class="tc_section tc_reapiter_banktc" data-section="1">
						<span class="sortabletc-handle"><svg width="20" height="20"><use href="svg-icon/icons.svg#maximize-svg-icon"></use></svg></span>
						<span class="btn_remove_tc" data-cls="banktc"><svg width="20" height="20"><use href="svg-icon/icons.svg#trash-svg-icon"></use></svg></span>
						<div class="control-group tc_counter">	
							<label class="control-label">Title</label>	
							<div class="controls">
								<input type="text"  value="Terms and Conditions" name="banktc[term_title][]"  class="span4"   maxlength="50"  >	
							</div>				
						</div>
						<div class="control-group tc_counter-1">			
							<label for="Address" class="control-label">Detail</label>
							<div class="controls">
								<textarea name="banktc[term_detail][]" class="span4"  >Subject to our home Jurisdiction.
Our Responsibility Ceases as soon as goods leaves our Premises.
Goods once sold will not taken back.
Delivery Ex-Premises.</textarea>
							</div>				
						</div>
					</div>
				
						<a class="add_tc btn btn-default" data-cls="banktc"><svg width="20" height="20"><use href="svg-icon/icons.svg#plus-svg-icon"></use></svg> Add Notes</a>
				
				<script>
					$( document ).ready(function() {
					    $(".sortabletc").sortable({
					          handle: ".sortabletc-handle",
					          placeholder: "portlet-placeholder",
					          update: function( event, ui ) {
					            var ordervalue = "";
					            var counter = 1;
					            $("[data-section]").each(function(){
					                if(counter > 1)
					                {
					                    ordervalue += ',';
					                }
					                ordervalue += $(this).attr("data-section");
					                counter++;
					            });
					          }
						});
					});
				</script>
				
												</div>
												<hr>
												<div class="control-group">
													<label for="document_note" class="control-label">Document Note / Remarks<span class="note" style="display:block;">Not Visible on Print</span></label>
													<div class="controls">
														<textarea id="document_note" name="document_note" class="Doc_Note" maxlength="450"></textarea>
													</div> <!-- /controls -->
												</div>

											</div>
										</div>

										<hr>
										<div class="row footer-section">
											<div class="span7 span-xs-12  span-md-6 span-sm-6">
											</div>
											<div class="span5 span-xs-12  span-md-6 span-sm-6">
												<div class="action-btn-container">
													<input type="hidden" name="enable_invoice_in_other_currency" value="0" />
													<input type="hidden" name="total_to_qty" id="total_to_qty" value="0" />
													<input type="hidden" name="ref_saleorder_id" id="ref_saleorder_id" value="" />
													<input type="hidden" name="ref_saleorder_session" id="ref_saleorder_session" value="_2025_2026" />
													<input type="hidden" name="ref_jobwork_id" id="ref_jobwork_id" value="" />
													<input type="hidden" name="ref_jobwork_session" id="ref_jobwork_session" value="_2025_2026" />
													<input type="hidden" name="hidden_grand_total" id="hidden_grand_total" value="" />
													<input type="hidden" name="auto_entry" id="auto_entry" value="0" />
													<input type="hidden" name="convert_from" id="convert_from" value="" />
													<input type="hidden" name="convert_from_id" id="convert_from_id" value="" />
													<input type="hidden" name="submittype" id="submittype" value="" />
													<input type="hidden" name="action" id="action" value="" />
													<input type="hidden" name="draft_id" id="draft_id" value="" />
													<input type="hidden" name="current_document_type" id="current_document_type" value="saleinvoice" />
													<input type="hidden" name="hidden_submit_form_data" id="hidden_submit_form_data" value="yes" />
													<input type="hidden" name="hmac" id="hmac" value="de1e4438203829fb4654" />
													<button type="submit" id="save" name="save" class="btn btn-primary pull-right"><svg width="20" height="20"><use href="svg-icon/icons.svg#save-svg-icon"></use></svg>Save<span class="shortcut_key_ctrl">s</span></button>
													<button id="save_print" name="save_print" value="save_print" class="btn btn-primary  pull-right"><svg width="20" height="20"><use href="svg-icon/icons.svg#print-svg-icon"></use></svg>Save & Print<span class="shortcut_key_ctrl">p</span></button>
													<a href="invoicedetail.php?" class="btn  pull-right pull-mobile-left bill_back_btn"><svg width="12" height="12"><use href="svg-icon/icons.svg#arrow-left-svg-icon"></use></svg>Back</a>
													<a class="btn  pull-left pull-mobile-left discard_btn" style=""><svg width="20" height="20"><use href="svg-icon/icons.svg#trash-svg-icon"></use></svg>Discard</a>
												</div><!--/save&&saveandpdf -->
											</div>
										</div>
									</div><!---widget content terminated -->
								</div>
							</div><!--span12  terminated -->
						</div>
						<div class="form-actions-invoice form-actions-floating-invoice">
							<div class="action-bar">
								<button type="submit" id="save" name="save" class="btn btn-primary" style="width: 100%;"><svg width="20" height="20"><use href="svg-icon/icons.svg#save-svg-icon"></use></svg> Save</button>
								<a class="dropdown-toggle dropup additional-dropdown-btn" id="dropdown-toggle">
									<svg width="20" height="20"><use href="svg-icon/icons.svg#caret-up-svg-icon"></use></svg>
								</a>
							</div>
							<div class="additional-actions">
								<button type="button" class="btn btn-primary addProduct"><svg width="20" height="20"><use href="svg-icon/icons.svg#plus-svg-icon"></use></svg> Product</button>
								<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#TransportChargeModal"><svg width="20" height="20"><use href="svg-icon/icons.svg#plus-svg-icon"></use></svg> Additional Charges</button>
								<button id="save_print" name="save_print" value="save_print" class="btn btn-primary"><svg width="20" height="20"><use href="svg-icon/icons.svg#print-svg-icon"></use></svg>Save & Print</button>
							</div>
						</div>
					</form><!--form terminated-->
				</div><!--row terminated -->
			</div><!---widget content terminated -->
		</div><!--span12 terminated -->
	</div><!--row terminated -->

	<script type="text/javascript">
	var availableCategory = [];
</script>

<!-- <div id="ShipRocketModal" class="modal popup_right_slider fade" role="dialog" style="display: none;">
    <div class="modal-dialog">
        <form class="form-horizontal" method="post" id="ShipRocketModalForm">
            
            <div class="modal-content steps-all" style="display: none;">
				<div class="modal-header">
					<button type="button" class="btn btn-default btn_close" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg></button>
					<h4 class="modal-title">Add ShipRocket Order</h4>
				</div>
				
                <div class="modal-body">
                    <fieldset>
                        <div class="step-1-success">
                            <h3>Step 1</h3>
                            <img src="assets/svgs/shiprocket_steps_complete.svg" class="quick-link-card-img" alt="">
                            <p>Order Created Successfully</p>
                            <p class="step-1-order-no">Your Order No. is <span>#856231471256</span></p>
                        </div>

                        <div class="step-2-success">
                            <h3>Step 2</h3>
                            <img src="assets/svgs/shiprocket_steps_complete.svg" class="quick-link-card-img" alt="" style="display: none;">
                            <p class="step-2-text">Select Your Delivery Partner</p>
                            <div class="step-2-text-details">
                                <p class="available-balance-lable">Available Balance</p>
                                <p class="available-balance">₹ 0000</p>
                            </div>
                            <p class="step-2-del-name">Delivery Partner Name</p>

                            <div class="shipping-selection"></div>
                        </div>

                        <div class="step-3-success">
                            <h3>Step 3</h3>
                            <img src="assets/svgs/shiprocket_steps_complete.svg" class="quick-link-card-img" alt="" style="display: none;">
                            <p class="step-3-text">Choose Pickup Date</p>

                            <div class="pickup-date-section"></div>

                            <div class="pick-del-info">
                                <div class="pick-del-blocks">
                                    <p class="pick-del-texts headings">Pickup Date:</p> 
                                    <p class="pick-del-texts pickup-date">10-11-2024</p> 
                                </div>
                                <div class="pick-del-blocks">
                                    <p class="pick-del-texts calculated-days">2 Days</p> 
                                </div>
                                <div class="pick-del-blocks">
                                    <p class="pick-del-texts headings">Approx Delivery Date:</p> 
                                    <p class="pick-del-texts delivery-date">12-11-2024</p> 
                                </div>
                            </div>
                        </div>
                        
                        <div class="shipment-successful" style="display: none;">
                            <img src="assets/svgs/shirocket_ship_selected.svg">
                            <p class="ship-success-text">Shipment Booked Successfully</p>
                            <p class="ship-awb-text">Your AWB No. is <span>#AWB45456</span></p>
                            <a class="btn btn-primary pull-right" id="print_shipping" download>Print Shipping Label</a>
                        </div>
                        
                    </fieldset>
                </div>
                <div class="modal-footer">
					
				</div>
                
                
            </div>
            <div class="modal-content step-1">
				<div class="modal-header">
					<button type="button" class="btn btn-default btn_close" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg></button>
					<h4 class="modal-title">Add ShipRocket Order</h4>
				</div>
				
                <div class="modal-body">
                    <fieldset>
                        <div class="shipping-details">
                            <input type="hidden" id="invoice_detail_id" name="invoice_detail_id">
                            <h4><img src="assets/svgs/shiprocket_customer.svg" alt="shiprocket_customer">Customer Details</h4>
                            <hr>
                            <p class="c_name">Customer Name Here</p>
                            <input type="hidden" id="c_name" name="c_name">
                            <p class="c_email">Customer Email Here</p>
                            <input type="hidden" id="c_email" name="c_email">
                            <p class="c_phone">Customer Phone Here</p>
                            <input type="hidden" id="c_phone" name="c_phone">
                            
                            <input type="hidden" id="shipping_is_billing" name="shipping_is_billing">

                            <div class="billing_address" style="display: none;">
                                <h5>Billing Address</h5>
                                <div class="address-blocks">
                                    <p class="c_address1">Address lines 1</p>
                                    <input type="hidden" id="c_address1" name="c_address1">
                                    <p class="c_address2">Address lines 2</p>
                                    <input type="hidden" id="c_address2" name="c_address2">
                                    <p class="c_merge">City, State, Country, Pin</p>
                                    <input type="hidden" id="c_city" name="c_city">
                                    <input type="hidden" id="c_state" name="c_state">
                                    <input type="hidden" id="c_country" name="c_country">
                                    <input type="hidden" id="c_pincode" name="c_pincode">
                                </div>
                            </div>

                            <div class="shipping-address">
                                <h5>Shipping Address</h5>
                                <div class="address-blocks">
                                    <p class="ship_address1">Address lines 1</p>
                                    <input type="hidden" id="ship_address1" name="ship_address1">
                                    <p class="ship_address2">Address lines 2</p>
                                    <input type="hidden" id="ship_address2" name="ship_address2">
                                    <p class="ship_merge">City, State, Country, Pin</p>
                                    <input type="hidden" id="ship_city" name="ship_city">
                                    <input type="hidden" id="ship_state" name="ship_state">
                                    <input type="hidden" id="ship_country" name="ship_country">
                                    <input type="hidden" id="ship_pincode" name="ship_pincode">
                                </div>
                            </div>

                        </div>
                        <div class="shipping-details">
                            <hr>
                            <h4><img src="assets/svgs/shiprocket_pickup.svg" alt="shiprocket_pickup">Pickup Details</h4>
                            <hr>
                            <div class="businessplace"></div>
                        </div>
                        <div class="shipping-details">
                            <hr>
                            <h4><img src="assets/svgs/shiprocket_order.svg" alt="shiprocket_order">Order Details</h4>
                            <hr>
                            <table class="table footable footable-1 table-striped" id="shiporderdetails">
                                <thead>
                                    <tr class="footable-header">
                                        <th style="text-align: left;">Name</th>
                                        <th style="text-align: center;">Quantity</th>
                                        <th style="text-align: right;">Price</th>
                                    </tr>
                                </thead>
                                <tbody></tbody>
                            </table>
                            <input type="hidden" id="product_title" name="product_title[]">
                            <input type="hidden" id="product_qty" name="product_qty[]">
                            <input type="hidden" id="product_price" name="product_price[]">
                            <input type="hidden" id="product_total" name="product_total">
                        </div>
                        <div class="shipping-details">
                            <hr>
                            <h4><img src="assets/svgs/shiprocket_payment.svg" alt="shiprocket_payment">Payment Details</h4>
                            <hr>
                            <div class="payment-options">
                                <label for="Company Type" class="control-label">Company Type</label>
                                <div class="controls input-prepend-small feedback-resolve">
                                    <label class="radio inline">
                                    <input type="radio" value="Prepaid" id="payment_type_prepaid" name="payment_type"> Prepaid </label>
                                    <label class="radio inline">
                                    <input type="radio" value="COD" id="payment_type_cod" name="payment_type"> Cash On Delivery </label>
                                </div>
                            </div>
                        </div>
                        <div class="shipping-details">
                            <hr>
                            <h4><img src="assets/svgs/shiprocket_package.svg" alt="shiprocket_package">Package Details</h4>
                            <hr>
                            <div class="controls-vol">
                                <label class="control-label"> Dead Weight (KG)</label>
                                <input type="number" id="ship_weight" name="ship_weight" min="0.50"> 
                            </div>
                            <div class="volumetric">
                                <div class="controls-vol">
                                    <label class="control-label-vol"> Length (CM) </label>
                                    <input type="number" id="ship_length" name="ship_length" min="0.50"> 
                                </div>
                                <div class="controls-vol">
                                    <label class="control-label-vol"> Breadth (CM) </label>
                                    <input type="number" id="ship_breadth" name="ship_breadth" min="0.50"> 
                                </div>
                                <div class="controls-vol">
                                    <label class="control-label-vol"> Height (CM) </label>
                                    <input type="number" id="ship_height" name="ship_height" min="0.50"> 
                                </div>
                            </div>

                            <p class="ship_volumetric"><span>Volumetric Weight: </span></p>
                            <p class="ship_weight_main"><span>Applicable Weight: </span></p>
                        </div>
                        <div class="shipping-details">
                            <hr>
                            <h4><img src="assets/svgs/shiprocket_secure.svg" alt="shiprocket_secure">Secure Your Shipment</h4>
                            <hr>
                            <div class="package-box">
                                <div class="form-check"><label class="form-check-label">
                                    <input type="checkbox" id="secure_package" name="secure_package" value="true"> Yes, Secure my shipment
                                    <i class="input-frame"></i></label>
                                </div>
                            </div>
                        </div>
                    </fieldset>
                </div>
                
                <div class="modal-footer">
					<button type="button" class="btn btn-default pull-left" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg>Close</button>
					<button class="btn btn-primary" name="btnsubmit" type="submit"><svg width="20" height="20"><use href="svg-icon/icons.svg#save-svg-icon"></use></svg>Add Order</button>
				</div>
            </div>
        </form>
    </div>
</div> -->

<script>
    /*function calculateVolumetricWeight() {
        var weight = parseFloat($(".shipping-details #ship_weight").val());
        var length = parseFloat($(".shipping-details #ship_length").val());
        var breadth = parseFloat($(".shipping-details #ship_breadth").val());
        var height = parseFloat($(".shipping-details #ship_height").val());

        if (length < 0.5 || isNaN(length)) {
            length = 0.5;
        }
        if (breadth < 0.5 || isNaN(breadth)) {
            breadth = 0.5;
        }
        if (height < 0.5 || isNaN(height)) {
            height = 0.5;
        }

        var volumetricWeight = (length * breadth * height) / 5000;
        volumetricWeight = volumetricWeight;

        $(".shipping-details .ship_volumetric").html("<span>Volumetric Weight: </span>"+volumetricWeight.toFixed(2));
        var vol_weight = parseFloat($(".ship_volumetric").clone().children("span").remove().end().text().trim());
        
        if (!isNaN(vol_weight) && vol_weight !== '' && !isNaN(weight) && weight !== '') {
            var largerWeight = Math.max(vol_weight, weight);
            $(".shipping-details .ship_weight_main").html("<span>Applicable Weight: </span>"+largerWeight.toFixed(2));
        }
    }

    $(document).ready(function() {
        $('#submit_pickup_date').hide();
        $(document).on('change', '.pickup-date-section input[type="radio"]', function() {
            if ($(this).is(':checked')) {
                $('#submit_pickup_date').slideDown(); 
            }
        });
        
        $(document).on("click", "#submit_pickup_date", function() {
            var selectedDate = $('input[name="pickup_date"]:checked').val();
            var shipment_id = $("#shipment_id_fpd").val();
            
            $.ajax({
                type: 'POST',
                url: "ajaxcall.php",
                data: {
                    action: 'ShipRocketAddPickup',
                    selected_date: selectedDate, 
                    shipment_id: shipment_id
                },
                dataType: 'json',
                beforeSend: function() {
                    $("body").addClass("is-loading");
                },
                success: function(data) {
                    if(data.status=='OK')
                    {
                        let invoice_detail_id = data.invoice_detail_id;
                        $.ajax({
                            url: 'ajaxcall.php', 
                            type: 'POST',        
                            data: {
                                action: 'ShipRocketFetchData', 
                                invoiceid: invoice_detail_id
                            },
                            success: function(response) {
                                ShipRocketFetchDataResponseHandle(response);               
                            },
                            error: function(xhr, status, error) {
                                console.error('AJAX Error:', error);
                            }
                        });
                    }
                },
                error: function(xhr, status, error) { 
                    var err = xhr.responseText;
                    var errTitle = 'Error In Saving Expense';
                    errorMessage(err.Message,errTitle,'','error');
                    $("body").removeClass("is-loading");
                },
                complete: function() {
                    
                }
            });
        });
        $(document).on('click','.getRow', function() {
            $('.getRow').removeClass('selected');
            $(this).addClass('selected');
        });
        $(document).on("input change",".shipping-details #ship_weight, .shipping-details #ship_length, .shipping-details #ship_breadth, .shipping-details #ship_height", function() {
            calculateVolumetricWeight();
        });

        $( "#ShipRocketModalForm" ).validate({
            rules: {
                field: {required: true},
                ignore: '[readonly=readonly],[readonly],[readonly=true]',
            },
            messages: {
            },
            
            submitHandler: function(form) {

                $('input[name="pick_phone"], input[name="pick_email"], input[name="pick_orgname"], input[name="pick_name"], input[name="pick_address1"], input[name="pick_address2"], input[name="pick_city"], input[name="pick_state"], input[name="pick_country"], input[name="pick_pincode"]').prop('disabled', true);
                var formData = $(form).serialize();

                var selectedAddressRow = $('.getRow.selected');
                
                var pick_orgname = selectedAddressRow.find('input[name="pick_orgname"]').val();
                var pick_name = selectedAddressRow.find('input[name="pick_name"]').val();
                var pick_phone = selectedAddressRow.find('input[name="pick_phone"]').val();
                var pick_email = selectedAddressRow.find('input[name="pick_email"]').val();
                var pick_address1 = selectedAddressRow.find('input[name="pick_address1"]').val();
                var pick_address2 = selectedAddressRow.find('input[name="pick_address2"]').val();
                var pick_city = selectedAddressRow.find('input[name="pick_city"]').val();
                var pick_state = selectedAddressRow.find('input[name="pick_state"]').val();
                var pick_country = selectedAddressRow.find('input[name="pick_country"]').val();
                var pick_pincode = selectedAddressRow.find('input[name="pick_pincode"]').val();
                var secure_package = $('#secure_package').is(':checked') ? 1 : 0;
                
                formData += '&pick_orgname=' + encodeURIComponent(pick_orgname);
                formData += '&pick_name=' + encodeURIComponent(pick_name);
                formData += '&pick_phone=' + encodeURIComponent(pick_phone);
                formData += '&pick_email=' + encodeURIComponent(pick_email);
                formData += '&pick_address1=' + encodeURIComponent(pick_address1);
                formData += '&pick_address2=' + encodeURIComponent(pick_address2);
                formData += '&pick_city=' + encodeURIComponent(pick_city);
                formData += '&pick_state=' + encodeURIComponent(pick_state);
                formData += '&pick_country=' + encodeURIComponent(pick_country);
                formData += '&pick_pincode=' + encodeURIComponent(pick_pincode);
                formData += '&secure_package=' + encodeURIComponent(secure_package);
                formData += '&action=ShipRocketAddOrder'; 

                var params = new URLSearchParams(formData);
                var queryArray = {};
                params.forEach(function(value, key) {
                    queryArray[key] = value;
                });
                $.ajax({
                    type: 'POST',
                    url: "ajaxcall.php",
                    data: formData,
                    dataType: 'json',
                    beforeSend: function() {
                        $("body").addClass("is-loading");
                    },
                    success: function(data) {
                        if(data.status=='OK')
                        {
                            let invoice_detail_id = data.invoice_detail_id;
                            $.ajax({
                                url: 'ajaxcall.php', 
                                type: 'POST',        
                                data: {
                                    action: 'ShipRocketFetchData', 
                                    invoiceid: invoice_detail_id
                                },
                                success: function(response) {
                                    ShipRocketFetchDataResponseHandle(response);               
                                },
                                error: function(xhr, status, error) {
                                    console.error('AJAX Error:', error);
                                }
                            });
                        }
                        else if(data.status=='ERROR')
                        {
                            console.log(data,'error');
                            var errTitle = 'Error Creating ShipRocket Order';
                            errorMessage('',errTitle,data.data,'warning');
                            $("body").removeClass("is-loading");
                        }
                    },
                    error: function(xhr, status, error) { 
                        var err = xhr.responseText;
                        var errTitle = 'Error In Saving Expense';
                        errorMessage(err.Message,errTitle,'','error');
                        $("body").removeClass("is-loading");
                    },
                    complete: function() {
                        
                    }
                });
            }
        });

        $(document).on('click','.shipping-button', function() {
            var shipment_id = $(this).closest('.shipping-block').find(".shipment-id span").html();
            var courier_id = $(this).closest('.shipping-block').find(".courier-id span").html();

            $.ajax({
                url: 'ajaxcall.php', 
                type: 'POST', 
                data: {
                    action: 'ShipRocketSelectCompany', 
                    shipment_id: shipment_id,         
                    courier_id: courier_id            
                },
                success: function(data) {
                    if(data.status=='OK')
                    {
                        let invoice_detail_id = data.invoice_detail_id;
                        $.ajax({
                            url: 'ajaxcall.php', 
                            type: 'POST',        
                            data: {
                                action: 'ShipRocketFetchData', 
                                invoiceid: invoice_detail_id
                            },
                            success: function(response) {
                                ShipRocketFetchDataResponseHandle(response);
                            },
                            error: function(xhr, status, error) {
                                console.error('AJAX Error:', error);
                            }
                        });
                    }
                    else if(data.status=='ERROR')
                    {
                        if(data.about_err == "Low Balance") {
                            var errTitle = data.about_err;
                            errorMessage('',errTitle,data.data,'warning');
                            $("body").removeClass("is-loading");
                        } else if(data.about_err == "KYC Verification Required") {
                            var errTitle = data.about_err;
                            errorMessage('',errTitle,data.data,'warning');
                            $("body").removeClass("is-loading");
                        }
                    }
                },
                error: function(xhr, status, error) {
                    console.log('Error:', error);
                }
            });
        });

    });*/
</script>

<div id="CustomerModal" class="popup_right_slider modal fade" role="dialog" style="display: none;">
	<div class="modal-dialog">
		<form class="form-horizontal" method="post" id="CustomerModalForm">

			<!-- Modal content-->
			<div class="modal-content">
				<div class="modal-header">
					<div class="modal-title-wrapper" style="display: flex;align-items: center;">
						<button type="button" style="top:unset;" class="btn btn-default btn_close" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg></button>
						<h4 class="modal-title">Add Customer / Vendor</h4>
											</div>
				</div>
				<div class="modal-body">
					<fieldset>
						<h4><svg width="24" height="24"><use href="svg-icon/icons.svg#note-detail-svg-icon"></use></svg> Customer / Vendor Detail</h4> <hr>
						<div class="control-group ">
							<label for="Company Type" class="control-label">Company Type</label>
							<div class="controls input-prepend-small feedback-resolve companyTypecls">
																	<label class="radio inline">
									<input type="radio" value="Customer" class="companytype" name="companytype" id="listBoxCompany-c" checked> Customer
                                    <span class="checkmark"></span>
									</label>
																								<label class="radio inline">
								<input type="radio" value="Customer-Vendor" class="companytype" name="companytype" id="listBoxCompany-cv"> Customer / Vendor
                                <span class="checkmark"></span>
								</label>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

						<div class="control-group">
							<label for="firstname" class="control-label">GSTIN</label>
							<div class="controls" style="position:relative;">
								<input type="text" name="gstno" id="gstno" class="span4" oninput="this.value = this.value.toUpperCase()" placeholder="Enter GSTIN" maxlength="15">
								<input type="hidden" name="old_gstno" id="old_gstno">
																	<div class="btn gstdata_autofill div-inner-input" >Auto Fill</div>
																	</div> <!-- /controls -->
								
						</div> <!-- /control-group -->
						<div class="control-group" style="display: none;">
							<label for="reputation" class="control-label" >Reputation</label>
							<div class="controls" style="position:relative;">
							<div class="progress" style="height: 21px;  border-radius: 15px; margin-top: 3px;margin-bottom:0;">
												<div class="progress-bar" id="progressbar" role="progressbar" aria-valuemin="0" aria-valuemax="100">
												</div>
											</div>
											<input type="hidden" name="cmp_reputation" id="cmp_reputation">
								</div> <!-- /controls -->
								
						</div> <!-- /control-group -->

						<div class="control-group update-gstinfield">											
							<label  class="control-label">Update GSTIN ?</label>
							<div class="controls">
								<div class="form-check"><label class="form-check-label"><input type="checkbox" name="update_gstno" value="1" id="update_gstno"> Update above GST number on all previous invoices.</input><i class="input-frame"></i></label></div>
							</div> <!-- /controls -->				
						</div> <!-- /control-group -->

						<div class="control-group">
							<label for="firstname" class="control-label">Company Name <span class="star_red">*</span></label>
							<div class="controls" style="position:relative;">
								<input type="text" value="" name="companyname" id="companyname" maxlength="150" class="span4" placeholder="Enter Company name" required>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->
						<div class="control-group" style="display:none;" >
							<!-- <div class="controls" style="position:relative;max-width:100%"> -->
								<div class="customer-exist">
									<div class="customer-exist-header">
										<h4>Company(s) Already Exists with matching Name/GSTIN.</h4>
									</div>
									<div class="customer-exist-header-content alredyExist" id="alredyExist">

									</div>
								</div>
							<!-- </div> -->
						</div>

						<div class="control-group">
							<label for="firstname" class="control-label">Contact Person</label>
							<div class="controls">
								<input type="text" value="" name="contactperson" id="contactperson" class="span4" placeholder="Enter contact person" maxlength="150">
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

						<div class="control-group">
							<label for="firstname" class="control-label">Contact No</label>
							<div class="controls">
								<input type="text" value="" name="contactno1" id="contactno1" class="span4" placeholder="Enter contact No." maxlength="50">
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

						<div class="control-group">
							<label for="firstname" class="control-label">Email</label>
							<div class="controls">
								<input type="text" placeholder="emailaddress@domain.com" name="email" id="email" class="span4" placeholder="Enter email address" maxlength="150">
								<div class="note">Note : Use comma(,) as address separator to enter Multiple Email.</div>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

						<div class="control-group">
							<label for="registration_type" class="control-label">Registration Type</label>
							<div class="controls">
								<select name="registration_type" class="span4">
									<option value="Unregistered">Unregistered</option>
									<option value="Regular">Regular</option>
									<option value="Regular-UIN">Regular-Embassy/UN Body</option>
									<option value="Regular-SEZ">Regular-SEZ</option>
									<option value="Composition">Composition</option>
								</select>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

						<div class="control-group">
							<label for="firstname" class="control-label">PAN</label>
							<div class="controls">
								<input type="text" name="pan" id="pan" class="span4" placeholder="Enter PAN" maxlength="10">
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

						

						<h4 class="has_modal_lbl"><svg width="24" height="24"><use href="svg-icon/icons.svg#billing-address-svg-icon"></use></svg> Billing Address</h4> <hr>

						<div class="control-group">
							<label for="firstname" class="control-label">Address</label>
							<div class="controls">
								<input type="text" value="" name="address1" id="address1" maxlength="100" class="span4" placeholder="Enter address1"></input>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

						<div class="control-group">
							<div class="controls">
								<input type="text" value="" name="address2" id="address2" maxlength="100" class="span4" placeholder="Enter address2"></input>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

						<div class="control-group">
							<label for="firstname" class="control-label">Landmark </label>
							<div class="controls">
								<input type="text" value="" name="landmark" class="span4" placeholder="Enter landmark" maxlength="30">
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

						<div class="control-group">
							<label for="firstname" class="control-label">City <span class="star_red">*</span></label>
							<div class="controls">
								<input type="text" id="city" name="city" class="span4" placeholder="Enter city" maxlength="50" required/>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

						<div class="control-group">
							<label for="Country" class="control-label">Country <span class="star_red">*</span></label>
							<div class="controls">
								<select onchange='selct_state_option(this.value,"listBox","newState","state")' type="list" data-value="India" name="country" class="span4 listBoxCountry1" id="listBoxCountry" required></select>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

						<div class="control-group">
							<label for="firstname" class="control-label">State <span class="star_red">*</span></label>
							<div class="controls">
								<select type="list" name="state" class="span4" id="listBox" required></select>
								<input type="text" name="newstate" id="newState" placeholder="Enter State" class="span4 hide" />
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

						<div class="control-group">
							<label for="firstname" class="control-label">Pincode</label>
							<div class="controls">
								<input type="text" value="" name="pincode" id="pincode" placeholder="Enter pincode" class="span4" maxlength="50">
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

						<div class="control-group">
							<label for="Distance for e-way bill (in km)" class="control-label">Distance for e-way bill (in km)</label>
							<div class="controls" style="position:relative;">
								<input type="text" value="" name="distance_eway" id="distance_eway" class="span4" placeholder="Enter Distance for e-way bill (in km)">
																	<div class="btn distance_autofill div-inner-input">Auto Fill</div>
									<input type="hidden" id="org_state" name="org_state" value="Karnataka">
									<input type="hidden" id="org_pincode" name="org_pincode" value="560091">
															</div> <!-- /controls -->
						</div> <!-- /controlgroup -->

                        <h4 class="has_modal_lbl"><svg width="24" height="24"><use href="svg-icon/icons.svg#address-svg-icon"></use></svg>Shipping Address
                            <div class="btn btn-primary add_shipping has_modal_lbl_btn"><svg width="20" height="20"><use href="svg-icon/icons.svg#plus-svg-icon"></use></svg>Add</div>
                            <a class="btn btn-primary manage_shipping has_modal_lbl_btn" target="_blank" style="display:none;">Manage</a>
                        </h4><hr>
                        <div class="shipping_address_section">

                        </div>


						<h4 class="has_modal_lbl"><svg width="24" height="24"><use href="svg-icon/icons.svg#balance-svg-icon"></use></svg> Opening Balance</h4> <hr>

						<div class="control-group control-balance-type-customer">
							<label for="Company Type" class="control-label">Customer Balance</label>
							<div class="controls input-prepend-small feedback-resolve">
									<label class="radio inline">
									<input type="radio" value="Credit" class="balance_type" name="balance_type"> Credit <span class="checkmark"></span></label>
									<label class="radio inline">
									<input type="radio" value="Debit" class="balance_type" name="balance_type"> Debit <span class="checkmark"></span></label>
							</div> <!-- /controls -->
						</div> <!-- /controlgroup -->

						<div class="control-group control-balance-type-customer">
							<label for="Account Number" class="control-label">Amount</label>
							<div class="controls">
								<input type="text" value="" name="balance_amount" onkeypress="return allowOnlyNumber(event);" class="balance_amount" placeholder="Enter Amount" class="span4">
								<span class="amountTextLbl"></span>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->
						
						
						<div class="control-group control-balance-type-vendor">
							<label for="Company Type" class="control-label">Vendor Balance</label>
							<div class="controls input-prepend-small feedback-resolve">
									<label class="radio inline">
									<input type="radio" value="Credit" class="balance_type_vendor" name="balance_type_vendor"> Credit <span class="checkmark"></span></label>
									<label class="radio inline">
									<input type="radio" value="Debit" class="balance_type_vendor" name="balance_type_vendor"> Debit <span class="checkmark"></span></label>
								</label>
							</div> <!-- /controls -->
						</div> <!-- /controlgroup -->

						<div class="control-group control-balance-type-vendor">
							<label for="Account Number" class="control-label">Amount</label>
							<div class="controls">
								<input type="text" value="" name="balance_amount_vendor" onkeypress="return allowOnlyNumber(event);" class="balance_amount_vendor" placeholder="Enter Amount" class="span4">
								<span class="amountTextLbl_vendor"></span>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->
						
						
                        <h4 class="has_modal_lbl bankdetailopt"><svg width="24" height="24"><use href="svg-icon/icons.svg#bank-detail-svg-icon"></use></svg> Vendor Bank Details</h4>
						<hr class="bankdetailopt">

						<div class="control-group bankdetailopt">
							<label for="Bank Name" class="control-label">Bank Name</label>
							<div class="controls">
								<input type="text" value="" name="bankname" id="bankname" placeholder="Enter bank name" class="span4" maxlength="50">
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

						<div class="control-group  bankdetailopt">
							<label for="IFSC Code" class="control-label">Bank IFSC Code</label>
							<div class="controls">
								<input type="text" value="" name="ifsccode" id="ifsccode" placeholder="Enter IFSC code" class="span4" maxlength="50">
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

						<div class="control-group  bankdetailopt">
							<label for="Account Number" class="control-label">Bank Account Number</label>
							<div class="controls">
								<input type="text" value="" name="accountno" id="accountno" placeholder="Enter account number" class="span4" maxlength="50">
							</div> <!-- /controls -->
						</div> <!-- /control-group -->
						
						<div class="control-group  bankdetailopt">
							<label for="Branch Name" class="control-label">Bank Branch Name</label>
							<div class="controls">
								<input type="text" value="" name="branchname" id="branchname" placeholder="Enter branch name" class="span4" maxlength="50">
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

                        <h4 class="has_modal_lbl"><svg width="24" height="24"><use href="svg-icon/icons.svg#custom-field-svg-icon"></use></svg> Custom Fields</h4> <hr>
						
						<div class="control-group">
							<label class="control-label">License No.</label>
							<div class="controls">
								<input type="text" value="" name="customer_text_1" id="customer_text_1" class="span4" placeholder="Enter License No." >
							</div> <!-- /controls -->
						</div> <!-- /controlgroup -->
						<div class="control-group">
							<label class="control-label">custom field 1</label>
							<div class="controls">
								<input type="text" value="" name="customer_text_2" id="customer_text_2" class="span4" placeholder="Enter custom field 1" >
							</div> <!-- /controls -->
						</div> <!-- /controlgroup -->
						<div class="control-group">
							<label class="control-label">custom field 2</label>
							<div class="controls">
								<input type="text" value="" name="customer_text_3" id="customer_text_3" class="span4" placeholder="Enter custom field 2" >
							</div> <!-- /controls -->
						</div> <!-- /controlgroup -->

						<h4  class="has_modal_lbl"><svg width="24" height="24"><use href="svg-icon/icons.svg#additional-note-svg-icon"></use></svg>Additional Details</h4> <hr>


						

						<div class="control-group">
							<label for="firstname" class="control-label">Fax No</label>
							<div class="controls">
								<input type="text" name="faxno" id="faxno" class="span4" placeholder="Enter fax No." maxlength="50">
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

						<div class="control-group">
							<label for="firstname" class="control-label">Website</label>
							<div class="controls">
								<input type="text" placeholder="www.sitename.com" name="website" id="website" class="span4" placeholder="Enter website name" maxlength="100">
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

						<div class="control-group">
							<label for="firstname" class="control-label">Credit Limit</label>
							<div class="controls">
								<input type="text" name="amount_limit" id="amount_limit" class="span4" placeholder="Enter amount">
								<div class="note">Note : A warning will be displayed if the customer’s credit limit is exceeded while generating an invoice</div>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

						<div class="control-group">
							<label class="control-label">Due Days</label>
							<div class="controls">
								<input type="text" value="" name="company_due_date" id="company_due_date" class="span4" placeholder="Enter due days">
								<div class="note">Note : Keep it blank to use the default due date from settings. Enter a number to set the due date as days from the invoice date. </div>
							</div> <!-- /controls -->
						</div> <!-- /controlgroup -->

						<div class="control-group">
							<label for="note" class="control-label">Note</label>
							<div class="controls">
								<textarea name="note" id="note" class="span4" placeholder="Enter note"></textarea>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

						<div class="control-group enableCompany"  style="display: none;">
							<label class="control-label">Enable</label>
							<div class="controls">
								<div class="form-check"><label class="form-check-label">
									<input type="checkbox" id="is_active" name="is_active" checked="checked"> Company will be visible on all document.</input>
									<i class="input-frame"></i></label></div>
							</div><!-- /controls -->
						</div><!-- /control-group -->
						<input type="hidden" name="company_id" class="company_id" value=""/>
						<input type="hidden" name="hmac" id="hmac" value="f9162a14367854650f5e" />
						<!--------------- -------------------------------------------------->
					</fieldset>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default pull-left" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg>Close</button>
					<button class="btn btn-primary" name="btnsubmit" type="submit"><svg width="20" height="20"><use href="svg-icon/icons.svg#save-svg-icon"></use></svg>Save</button>
				</div>
			</div>
		</form>
	</div>
</div>
<div id="addbom_modal" class=" popup_right_slider modal fade" role="dialog" style="display: none;">
<div class="modal-dialog">
		<form class="form-horizontal" method="post" id="bom_Modalform">
			<!-- Modal content-->
			<div class="modal-content">
				<div class="modal-header">
				<button type="button" class="btn btn-default btn_close" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg></button>
					<h4 class="modal-title">Manufacturing Stock</h4>
				</div>
				<div class="modal-body">
					<fieldset>
						<div class="bom-section" >
							<h4 class="productName">
								
							</h4>
							<hr>
							<input type="hidden" name="product_id" class="product_id">
							<input type="hidden" name="product_name" class="product_name">
							<input type="hidden" name="modalmode" class="modalmode">
							<div class="bomOpt">
								<table class="table  table-bordered bomtable">
									<thead>
										<tr>
											<th>Raw Material</th>
											<th>Qty</th>
											<th>UOM</th>
											<th>Purchase Price</th>
											<th>Estimated Cost</th>
											<th></th>
										</tr>
									</thead>
										<tbody>
											
										</tbody>
									</table>	
									<div id="total_estimated_cost"></div>
								</div>
								<hr>
								<h4>Other Outcomes</h4>	
								<div class="oc_bomOpt">
								<table class="table  table-bordered octable">
									<thead>
										<tr>
											<th>Other Outcomes</th>
											<th>Qty</th>
											<th>UOM</th>
											<th>Purchase Price</th>
											<th>Estimated Cost</th>
											<th></th>
										</tr>
									</thead>
										<tbody>
											
										</tbody>
									</table>	
								</div>
						</div>
					</fieldset>
					
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default pull-left" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg>Close</button>
					<button class="btn btn-primary Margin_Bottom_btn" name="btnsubmit" type="submit"><svg width="20" height="20"><use href="svg-icon/icons.svg#save-svg-icon"></use></svg>Save</button>
				</div>
			</div>
		</form>
	</div>
</div>


<div id="TransportModal" class="popup_right_slider modal fade" role="dialog" style="display: none;">
	<div class="modal-dialog">
		<form class="form-horizontal" method="post" id="TransportModalForm">
			<!-- Modal content-->
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="btn btn-default btn_close" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg></button>
					<h4 class="modal-title">Add Transport</h4>
				</div>
				<div class="modal-body">
					<fieldset>
						<div class="control-group">
							<label for="name" class="control-label">Transport ID / GSTIN</label>
							<div class="controls" style="position:relative;">
								<input type="text" name="transportid" id="transportid" class="span4" placeholder="Enter your transport id" maxlength="100">
																		<div class="btn transportgstdata_autofill div-inner-input" data-gstfor="shipping" >Auto Fill</div>
																</div> <!-- /controls -->
						</div> <!-- /control-group -->

						<div class="control-group">
							<label for="name" class="control-label">Transport Name<span class="star_red">*</span></label>
							<div class="controls">
								<input type="text" name="name" id="name" class="span4" placeholder="Enter your transport name" maxlength="255" required>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

						<div class="control-group">
							<label for="name" class="control-label">Vehicle No</label>
							<div class="controls">
								<input type="text" name="vehicleno" id="vehicleno" class="span4" placeholder="Enter your vehicle no" maxlength="50">
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

                        <div class="control-group">
                            <label for="tracking_link" class="control-label">Tracking Link</label>
                            <div class="controls">
                                <input type="text" name="tracking_link" id="tracking_link" class="span4" placeholder="Enter Tracking Link" />
                                <small class="text-muted">Use <code>{{LR No}}</code> as a placeholder in the tracking URL</small>
                            </div>
                        </div>

						<div class="control-group enableTransport" style="display: none;"> 	
							<label class="control-label">Enable</label>	
							<div class="controls">			
								<div class="form-check"><label class="form-check-label">
									<input type="checkbox" id="is_active" name="is_active" checked="checked"> Transport will be visiable on all document.	
									<i class="input-frame"></i></label></div>
							</div><!-- /controls -->	
						</div>
						<input type="hidden" name="hmac" id="hmac" value="7abe6deecacd50e9a275" />
					</fieldset>
				</div>
				<div class="modal-footer">
				<a href="list-transport.php" target="_blank" class="btn btn-primary Margin_Bottom_btn" style="float:left;"><svg width="20" height="20"><use href="svg-icon/icons.svg#save-svg-icon"></use></svg>View All Transport</a>					
					<a type="button" class="btn btn-default Margin_Bottom_btn pull-left" data-dismiss="modal" style="background:#D9D9D9;border-color:#D9D9D9;"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg>Close</a>
					<button class="btn btn-primary Margin_Bottom_btn" name="btnsubmit" type="submit"><svg width="20" height="20"><use href="svg-icon/icons.svg#save-svg-icon"></use></svg>Save</button>
				</div>
			</div>
		</form>
	</div>
</div>

<div id="ShippingModal" class="popup_right_slider modal fade" role="dialog" style="display: none;">
	<div class="modal-dialog">
		<form class="form-horizontal" method="post" id="ShippingModalForm">
			<!-- Modal content -->
			<div class="modal-content">
				<div class="modal-header">
					<div class="modal-title-wrapper" style="display: flex;align-items: center;">
						<button type="button" class="btn btn-default btn_close" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg></button>
						<h4 class="modal-title">Add Shipping Address </h4>
											</div>
				</div>
				<div class="modal-body">
					<div class="shipping_address_reapiter">
						<fieldset>
							<div class="control-group">
								<label for="SHIP. GSTIN" class="control-label">GSTIN</label>
								<div class="controls" style="position:relative;">
									<input type="text" oninput="this.value = this.value.toUpperCase()" id="gstno" name="ship_gstno[]" class="span4 ship_gstno" placeholder="Enter shipping GSTIN" maxlength="20">
																			<div class="btn gstdata_autofill div-inner-input" data-gstfor="shipping">Auto Fill</div>
																	</div> <!-- /controls -->
							</div> <!-- /control-group -->
							<input type="hidden" value="" name="shipping_address_id[]" class="span4 shipping_address_id">
							<div class="control-group">
								<label for="SHIP. Name" class="control-label">Name <span class="star_red">*</span></label>
								<div class="controls">
									<input type="text" value="" name="ship_name[]" class="span4 ship_name" placeholder="Enter shipping name">
								</div> <!-- /controls -->
							</div> <!-- /control-group -->

							<div class="control-group">
								<label for="SHIP. Cperson" class="control-label">Contact Person</label>
								<div class="controls">
									<input type="text" value="" name="ship_cperson[]" class="span4 ship_cperson" placeholder="Enter shipping contact person name">
								</div> <!-- /controls -->
							</div> <!-- /control-group -->

							<div class="control-group">
								<label for="SHIP. Phone" class="control-label">Phone</label>
								<div class="controls">
									<input type="text" value="" name="ship_phone[]" class="span4 ship_phone" placeholder="Enter shipping phone " maxlength="20">
								</div> <!-- /controls -->
							</div> <!-- /control-group -->

							<div class="control-group">
								<label for="SHIP. Email" class="control-label">Email</label>
								<div class="controls">
									<input type="text" value="" name="ship_email[]" class="span4 ship_email" placeholder="Enter Email">
								</div> <!-- /controls -->
							</div> <!-- /control-group -->

							<div class="control-group">
								<label for="Ship To" class="control-label">Address <span class="star_red">*</span></label>
								<div class="controls">
									<textarea name="ship_address[]" class="span4 ship_address" placeholder="Enter shipping address"></textarea>
								</div> <!-- /controls -->
							</div> <!-- /control-group -->
							<div class="control-group">
								<label for="firstname" class="control-label">Landmark <span class="star_red">*</span></label>
								<div class="controls">
									<input type="text" value="" name="ship_landmark[]" class="span4 ship_landmark" placeholder="Enter shipping landmark" maxlength="30">
								</div> <!-- /controls -->
							</div> <!-- /control-group -->
							<div class="control-group">
								<label for="ship_pincode" class="control-label">Pincode <span class="star_red">*</span></label>
								<div class="controls">
									<input type="text" value="" name="ship_pincode[]" class="span4 ship_pincode" placeholder="Enter shipping pincode" maxlength="20">
								</div> <!-- /controls -->
							</div> <!-- /control-group -->
							<div class="control-group">
								<label for="firstname" class="control-label">City <span class="star_red">*</span></label>
								<div class="controls">
									<input type="text" id="ship_city" name="ship_city[]" class="span4 ship_city" placeholder="Enter shipping city" maxlength="50" />
								</div> <!-- /controls -->
							</div> <!-- /control-group -->
							<div class="control-group">
								<label for="SHIP. State" class="control-label">State <span class="star_red">*</span></label>
								<div class="controls">
									<select type="list" data-value="" name="ship_state[]" class="span4 all_state_list"></select>
									<input type="text" name="ship_statex" id="newState1" placeholder="Enter State" value="" class="span4 hide newState1" />
								</div> <!-- /controls -->
							</div> <!-- /control-group -->

							<div class="control-group">
								<label for="ship_country" class="control-label">Country</label>
								<div class="controls">
									<select data-value="India" type="list" name="ship_country[]" class="span4 listBoxCountry1"></select>
								</div> <!-- /controls -->
							</div> <!-- /control-group -->

							<div class="control-group">
								<label for="Distance for e-way bill (in km)" class="control-label">Distance for e-way bill (in km)</label>
								<div class="controls" style="position:relative;">
									<input type="text" value="" name="shipping_distance_eway[]" class="span4 shipping_distance_eway" placeholder="Enter Distance for e-way bill (in km)">
																			<div class="btn distance_autofill div-inner-input" distance_for="shipping">Auto Fill</div>
																	</div> <!-- /controls -->
							</div> <!-- /controlgroup -->
							
						</fieldset>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default pull-left" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg>Close</button>
					<button class="btn btn-primary" name="btnsubmit" type="submit"><svg width="20" height="20"><use href="svg-icon/icons.svg#save-svg-icon"></use></svg>Save</button>
				</div>
			</div>
		</form>
	</div>
</div>

<!-- Invoice Upload Modal -->
<div id="invoice_upload_modal" class="popup_right_slider modal fade" role="dialog" style="display: none;">
    <div class="modal-dialog">
        <form class="form-horizontal" method="post" id="invoiceUploadForm" action="file-upload-ajaxcall.php">
            <div class="modal-content">
                <input type="hidden" name="reference_id" id="reference_id" />
                <input type="hidden" name="reference_type" id="reference_type" />
                <div class="modal-header">
                    <button type="button" class="btn btn-default btn_close" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg></button>
                    <h4 class="modal-title">Upload Document</h4>
                </div>
                <div class="modal-body">
                    <div class="invoice_wrapper">
                        <div class="invoice_container">

                        </div>
                        <div class="dropzone" id="invoice_dropzone"></div>
                        <p id="error_message" style="color: red"></p>
                    </div>
                </div>

                <div class="modal-footer">
                    <button type="button" class="btn btn-default pull-left" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg>Close</button>
                </div>
            </div>
        </form>
    </div>
</div>

<!-- Invoice Upload Modal -->

<script>
	const price_decimal_value = '2';
    $(document).ready(function (){

        let invoiceDropzone;
        let errorMessage = "";

        function fetchUserFiles(reference_id,reference_type){
            $.ajax({
                type: 'POST',
                url: 'ajaxcall.php',
                data: { action: 'fetch_user_files', reference_id: reference_id, reference_type: reference_type },
                success: function (response){

                    $('.upload_file_' + reference_id).attr('data-file-count', response.total_file_count)
                    if (response.files.length == 0){ $('.actions_detail_icons.upload_file_'+reference_id).hide() }

                    if (response.go_storage != undefined){ $('.go_storage').text(response.go_storage) }

                    var image_box = ""
                    $(".invoice_container").html("");
                    $.each(response.files, function(key,file) { image_box += file.html });
                    $(".invoice_container").append(image_box);

                    if(invoiceDropzone) invoiceDropzone.destroy()

                    const maxFilesAllowed = 5;
                    const currentFileCount = response.total_file_count;
                    const maxFiles = maxFilesAllowed - currentFileCount;

                    invoiceDropzone = new Dropzone("#invoice_dropzone", {
                        maxFiles: maxFiles,
                        maxFilesize: 5,
                        dictFileTooBig: "Upload failed: The uploaded file exceeds the maximum allowed size of 5 MB. Please upload a smaller file.",
                        dictMaxFilesExceeded: "Upload failed: Maximum 5 files can be attached per document.",
						dictDefaultMessage: "<div style='display-flex; flex-direction:column;'><img src='assets/svgs/image_icon.svg'><p style='font-weight:bold;'>Click To Upload</p></div>",
                        acceptedFiles: '.pdf,.png,.jpg,.jpeg,.doc,.docx,.xls,.xlsx,.xlsm,.csv,.ppt,.pptx,.ppsx,.one,.txt,.rtf',
                        url: "file-upload-ajaxcall.php",
                        params: function() { return { action: "upload_invoice_file", reference_id: $('#reference_id').val(), reference_type: $('#reference_type').val() }; },
                        init: function() {

                            const myDropzone = this;

                            errorMessage = "";

                            myDropzone.on("addedfile", function(file) {
                                if (myDropzone.files.length > myDropzone.options.maxFiles) {
                                    myDropzone.removeFile(file);
                                    errorMessage = "Upload failed: Maximum 5 files can be attached per document.";
                                }
                            });

                            myDropzone.on("sending", function(file, xhr, formData) {
                                $("body").addClass("is-loading");
                                $('.dz-message').show();
                            });

                            myDropzone.on("queuecomplete", function () {
                                $('.actions_detail_icons.upload_file_'+reference_id).show()
                                fetchUserFiles(reference_id, reference_type);
                                $('#error_message').text(errorMessage)
                            });

                            myDropzone.on("error", function(file, error) {
                                if (file.size > (5 * 1024 * 1024)) {
                                    errorMessage = "Upload failed: The uploaded file exceeds the maximum allowed size of 5 MB. Please upload a smaller file.";
                                } else if (myDropzone.files.length > myDropzone.options.maxFiles) {
                                    errorMessage = "Upload failed: Maximum 5 files can be attached per document.";
                                } else {
                                    errorMessage = error
                                }
                                myDropzone.removeFile(file);
                            });
                        },
                        success: function (file, response){
                            if (response.go_storage_limit_exceed && !response.success){
                                Swal.fire({
                                    icon: 'warning',
                                    title: "Your Go Drive storage is full.",
                                    text: "Upgrade your storage plan to continue uploading files.",
                                    showCancelButton: true,
                                    confirmButtonText: 'Upgrade',
                                    cancelButtonText: 'Cancel',
                                    reverseButtons: true
                                }).then((result) => {
                                    if (result.isConfirmed) {
                                        window.location.href = response.redirect_url;
                                    }
                                });
                            }else if(!response.success) {
								if(response.access_denied){
									Swal.fire({ icon: 'warning', title: "Access Denied", text: "You don’t have permission to complete this action."  });
								}else{
									Swal.fire({ icon: 'error', title: response.message });
								} 
                            }
                        },
                    });
                },
            })
        }

        Dropzone.autoDiscover = false;
        $(document).on('click', '.upload_invoice_btn', function (){
            const reference_id = $(this).data('reference-id');
            const reference_type = $(this).data('reference-type');

            $('#error_message').text('')
            $('#reference_id').val(reference_id)
            $('#reference_type').val(reference_type)
            $('#invoice_upload_modal').modal('show')

            fetchUserFiles(reference_id,reference_type)
        })

        $(document).on("click", ".invoice_icons .delete_file", function(e) {
            $('#error_message').text('');
            const user_file_id = $(this).data('id');
            const reference_id = $(this).data('reference-id');
            const reference_type = $(this).data('reference-type');
			Swal.fire({
				title: "Do you really want to delete this document?",
				icon: "warning",
				showCancelButton: true,
				confirmButtonText: "Delete",
				cancelButtonText: "Cancel",
				reverseButtons: true,
				customClass: {
					confirmButton: 'recodeDelete-btn',
					cancelButton: 'recodeCancel-btn'
				}
			}).then((result) => {
			if(result.isConfirmed){
				$.ajax({
					
					type: 'POST',
					url: 'ajaxcall.php',
					data: { action: 'delete_user_files', user_file_id: user_file_id, reference_id: reference_id, reference_type: reference_type },
					success: function (response){
						if(response.success){
                        fetchUserFiles(response.reference_id,response.reference_type)
						}else {
							if(response.access_denied){
								Swal.fire({ icon: 'warning', title: "Access Denied", text: "You don’t have permission to complete this action."  });
							}else{
								Swal.fire({ icon: 'error', title: "Delete User Files", text: response.message  });
							}
						}
					}
				})
			}
		});

        });

        $(document).on('click', '.invoice_icons .view_file', function (){
            var imageSrc = $(this).closest('.invoice_box').find('img').attr('src');
            var gallery = [{ src: imageSrc, thumb: imageSrc }];
            Fancybox.show(gallery);
        })
    })
</script>

<script>
	var autoUOMListModal = [
		{
			value: "BAG",
			label: "Bags - BAG"
		},{
			value: "BGS",
			label: "BagsBGS - BGS"
		},{
			value: "BLS",
			label: "Bails - BLS"
		},{
			value: "BTL",
			label: "Bottles - BTL"
		},{
			value: "BOU",
			label: "Bou - BOU"
		},{
			value: "BOX",
			label: "Boxes - BOX"
		},{
			value: "BKL",
			label: "Buckles - BKL"
		},{
			value: "BLK",
			label: "Bulk - BLK"
		},{
			value: "BUN",
			label: "Bunches - BUN"
		},{
			value: "BDL",
			label: "Bundles - BDL"
		},{
			value: "CAN",
			label: "Cans - CAN"
		},{
			value: "CTS",
			label: "Carats - CTS"
		},{
			value: "CTN",
			label: "Cartons - CTN"
		},{
			value: "CAS",
			label: "Cases - CAS"
		},{
			value: "CMS",
			label: "Centimeter - CMS"
		},{
			value: "CHK",
			label: "Chauka - CHK"
		},{
			value: "CHI",
			label: "Chest - CHI"
		},{
			value: "CLS",
			label: "Coils - CLS"
		},{
			value: "COL",
			label: "Collies - COL"
		},{
			value: "CRI",
			label: "Crates - CRI"
		},{
			value: "CCM",
			label: "Cubic Centimeter - CCM"
		},{
			value: "CFT",
			label: "Cubic Feet - CFT"
		},{
			value: "CIN",
			label: "Cubic Inches - CIN"
		},{
			value: "CBM",
			label: "Cubic Meter - CBM"
		},{
			value: "CQM",
			label: "Cubic Meters - CQM"
		},{
			value: "CYL",
			label: "Cylinder - CYL"
		},{
			value: "DAY",
			label: "Days - DAY"
		},{
			value: "SDM",
			label: "Decameter Square - SDM"
		},{
			value: "DOZ",
			label: "Dozen - DOZ"
		},{
			value: "DRM",
			label: "Drums - DRM"
		},{
			value: "FTS",
			label: "Feet - FTS"
		},{
			value: "FLK",
			label: "Flasks - FLK"
		},{
			value: "GMS",
			label: "Grams - GMS"
		},{
			value: "GGR",
			label: "Great Gross - GGR"
		},{
			value: "TON",
			label: "Greate Britain Ton - TON"
		},{
			value: "GRS",
			label: "Gross - GRS"
		},{
			value: "GYS",
			label: "Gross Yards - GYS"
		},{
			value: "HBK",
			label: "Habbuck - HBK"
		},{
			value: "HKS",
			label: "Hanks - HKS"
		},{
			value: "HRS",
			label: "Hours - HRS"
		},{
			value: "INC",
			label: "Inches - INC"
		},{
			value: "IND",
			label: "Inch Dia - IND"
		},{
			value: "INM",
			label: "Inch Meter - INM"
		},{
			value: "JAR",
			label: "Jar - JAR"
		},{
			value: "JOB",
			label: "Job - JOB"
		},{
			value: "JTA",
			label: "Jotta - JTA"
		},{
			value: "KGS",
			label: "Kilograms - KGS"
		},{
			value: "KLR",
			label: "Kiloliter - KLR"
		},{
			value: "KME",
			label: "Kilometers - KME"
		},{
			value: "KMS",
			label: "Kilometers - KMS"
		},{
			value: "KW",
			label: "Kilowatt - KW"
		},{
			value: "LTR",
			label: "Liters - LTR"
		},{
			value: "LIN",
			label: "Lines - LIN"
		},{
			value: "LOAD",
			label: "Load - LOAD"
		},{
			value: "LOG",
			label: "Logs - LOG"
		},{
			value: "LOT",
			label: "Lots - LOT"
		},{
			value: "LS",
			label: "Lumpsum - LS"
		},{
			value: "MTR",
			label: "Meter - MTR"
		},{
			value: "MTS",
			label: "Metric Ton - MTS"
		},{
			value: "MGS",
			label: "Milli Grams - MGS"
		},{
			value: "MLT",
			label: "Milli Litre - MLT"
		},{
			value: "MMT",
			label: "Milli Meter - MMT"
		},{
			value: "MO",
			label: "Month - MO"
		},{
			value: "MIN",
			label: "Minute - MIN"
		},{
			value: "NOS",
			label: "Numbers - NOS"
		},{
			value: "ODD",
			label: "Odds - ODD"
		},{
			value: "OTH",
			label: "Others - OTH"
		},{
			value: "PKG",
			label: "Package - PKG"
		},{
			value: "PKT",
			label: "Packet - PKT"
		},{
			value: "PKD",
			label: "Peck - Dry Measure - PKD"
		},{
			value: "PAC",
			label: "Packs - PAC"
		},{
			value: "PAI",
			label: "Pails - PAI"
		},{
			value: "PRS",
			label: "Pairs - PRS"
		},{
			value: "PLT",
			label: "Pallets - PLT"
		},{
			value: "PCS",
			label: "Pieces - PCS"
		},{
			value: "LBS",
			label: "Pounds - LBS"
		},{
			value: "QTR",
			label: "Quarter - QTR"
		},{
			value: "QTL",
			label: "Quintal - QTL"
		},{
			value: "REL",
			label: "Reels - REL"
		},{
			value: "RIM",
			label: "RIM - RIM"
		},{
			value: "ROL",
			label: "Rolls - ROL"
		},{
			value: "RFT",
			label: "Running Feet - RFT"
		},{
			value: "RM",
			label: "Running Meter - RM"
		},{
			value: "SET",
			label: "Sets - SET"
		},{
			value: "SHT",
			label: "Sheets - SHT"
		},{
			value: "SLB",
			label: "Slabs - SLB"
		},{
			value: "SQC",
			label: "Sqaure Centimeters - SQC"
		},{
			value: "SQF",
			label: "Sqaure Feet - SQF"
		},{
			value: "SQI",
			label: "Square Inches - SQI"
		},{
			value: "SQM",
			label: "Square Meter - SQM"
		},{
			value: "SQY",
			label: "Square Yards - SQY"
		},{
			value: "BLO",
			label: "Steel Blocks - BLO"
		},{
			value: "STR",
			label: "Strings - STR"
		},{
			value: "TBL",
			label: "Tables - TBL"
		},{
			value: "TBS",
			label: "Tablets - TBS"
		},{
			value: "TGM",
			label: "Ten Gross - TGM"
		},{
			value: "THD",
			label: "Thousands - THD"
		},{
			value: "TIN",
			label: "Tins - TIN"
		},{
			value: "TOL",
			label: "Tola - TOL"
		},{
			value: "TRK",
			label: "Trunk - TRK"
		},{
			value: "TUB",
			label: "Tubes - TUB"
		},{
			value: "UGS",
			label: "US Gallons - UGS"
		},{
			value: "UNT",
			label: "Units - UNT"
		},{
			value: "VLS",
			label: "Vials - VLS"
		},{
			value: "CSK",
			label: "Wooden Cases - CSK"
		},{
			value: "YDS",
			label: "Yards - YDS"
		},{
			value: "YO",
			label: "Year - YO"
		}	];
</script>
<script>
	var countuomsection = 0;
	var autoSecondUOMListModal = autoUOMListModal;
	$(document).ready(function() {

		$("#uommodal").autocomplete({
			source: autoUOMListModal,
			change: function(event, ui) {
				if (ui.item == null || ui.item == undefined) {} else {
					if (ui.item) {
						$("#uommodal").val(ui.item.value);
					}
				}
			},
			select: function(event, ui) {
				var olduom = $("#ProductModal #uommodal").attr('data-value');
				$("#uommodal").val(ui.item.value);
				$("#ProductModal #uommodal").attr('data-value',ui.item.value);
				$('#ProductModal').find('.uom-base-unit').text(ui.item.value);
				$('#ProductModal').find('[name="secoundry_unit[]"][value='+ui.item.value+']').closest('.conversion-uom-section').remove();
				var previousSection = $('#ProductModal .uom-conversion-section').find('.conversion-uom-section:last');
				previousSection.find('.removeUnitRates').after(`<div class="btn btn-primary right_modal_btn addUnitRates btnaddmoreoption"><svg width="20" height="20"><use href="svg-icon/icons.svg#plus-svg-icon"></use></svg></div>`);
				previousSection.find('.removeUnitRates').remove('.removeUnitRates');
				if(autoSecondUOMListModal != '' && autoSecondUOMListModal != undefined){
					autoSecondUOMListModal = $.grep(autoSecondUOMListModal, function (element, index) {
					    return element.value != ui.item.value;
					});
					if(olduom != ''){
						var adduom = $.grep(autoUOMListModal, function (element, index) {
						    return element.value == olduom;
						});
						if (adduom.length > 0) {
		                    autoSecondUOMListModal.push(adduom[0]);
		                    autoSecondUOMListModal.sort((a, b) => a.label.localeCompare(b.label));
		                }
					}
				}
			
				return false;
			},
			minLength: 0
		}).focus(function() {
			$(this).autocomplete("search");
		});


		$('.balance_amount,.balance_amount_vendor').keyup(function(){
			getBalanceAmount();
		});
		
		$('.balance_type,.balance_type_vendor').change(function(){
			getBalanceAmount();
		});
		
	});
	$('#CustomerModalForm .balance_type').trigger("change");
	function getBalanceAmount() {
			var balance_type = $('.balance_type:checked').val();	
			var balance_amount = $('.balance_amount').val();	
			var balance_type_vendor = $('.balance_type_vendor:checked').val();	
			var balance_amount_vendor = $('.balance_amount_vendor').val();	
			if(balance_type != undefined  && balance_amount != ''){
				var payText = '';
				var color = '';
				if(balance_type.trim() == 'Credit'){payText = 'You pay the customer';	color = 'red';}else{payText = 'Customer pays you';color = 'green';}
				$('.amountTextLbl').css('color',color).text('₹ '+balance_amount+' '+payText);
			}
			if(balance_type_vendor != undefined && balance_amount_vendor != ''){
				var payText = '';
				var color = '';
				if(balance_type_vendor.trim() == 'Credit'){payText = 'You pay the vendor';	color = 'red';}else{payText = 'Vendor pays you';color = 'green';}
				$('.amountTextLbl_vendor').css('color',color).text('₹ '+balance_amount_vendor+' '+payText);
			}
			

	}


</script>

<div id="ProductModal" class=" popup_right_slider modal fade" role="dialog" style="display: none;">
	<div class="modal-dialog">
		<form class="form-horizontal" method="post" id="ProductModalForm">
			<!-- Modal content-->
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="btn btn-default btn_close" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg></button>
					<h4 class="modal-title">Add Product / Service</h4>
				</div>
				<div class="modal-body">
					<script>
						var productVarient1 = [];
						var productVarient2 = [];
						var productVarient3 = [];
						var productVarient4 = [];
					</script>
										
					<script>
										</script>
					<script>
						$(document).ready(function() {

							if ($(".attrib-combobox-1").length > 0) {
								$(".attrib-combobox-1").autocomplete({
									source: productVarient1,
									change: function(event, ui) {
										if (ui.item == null || ui.item == undefined) {
											$("[name='hidden-attrib-1-val']").val("");
										} else {
											if (ui.item) {
												$("[name='hidden-attrib-1-val']").val(ui.item.label);
												$(event.target).val(ui.item.label);
											}
										}
									},
									select: function(event, ui) {
										$("[name='hidden-attrib-1-val']").val(ui.item.label);
										$(event.target).val(ui.item.label);
										return false;
									},
									minLength: 0
								}).focus(function() {
									$(this).autocomplete("search");
								});
							}
							if ($(".attrib-combobox-2").length > 0) {
								$(".attrib-combobox-2").autocomplete({
									source: productVarient2,
									change: function(event, ui) {
										if (ui.item == null || ui.item == undefined) {
											$("[name='hidden-attrib-2-val']").val("");
										} else {
											if (ui.item) {
												$("[name='hidden-attrib-2-val']").val(ui.item.label);
												$(event.target).val(ui.item.label);
											}
										}
									},
									select: function(event, ui) {
										$("[name='hidden-attrib-2-val']").val(ui.item.label);
										$(event.target).val(ui.item.label);
										return false;
									},
									minLength: 0
								}).focus(function() {
									$(this).autocomplete("search");
								});
							}
							if ($(".attrib-combobox-3").length > 0) {
								$(".attrib-combobox-3").autocomplete({
									source: productVarient3,
									change: function(event, ui) {
										if (ui.item == null || ui.item == undefined) {
											$("[name='hidden-attrib-3-val']").val("");
										} else {
											if (ui.item) {
												$("[name='hidden-attrib-3-val']").val(ui.item.label);
												$(event.target).val(ui.item.label);
											}
										}
									},
									select: function(event, ui) {
										$("[name='hidden-attrib-3-val']").val(ui.item.label);
										$(event.target).val(ui.item.label);
										return false;
									},
									minLength: 0
								}).focus(function() {
									$(this).autocomplete("search");
								});
							}
							if ($(".attrib-combobox-4").length > 0) {
								$(".attrib-combobox-4").autocomplete({
									source: productVarient4,
									change: function(event, ui) {
										if (ui.item == null || ui.item == undefined) {
											$("[name='hidden-attrib-4-val']").val("");
										} else {
											if (ui.item) {
												$("[name='hidden-attrib-4-val']").val(ui.item.label);
												$(event.target).val(ui.item.label);
											}
										}
									},
									select: function(event, ui) {
										$("[name='hidden-attrib-4-val']").val(ui.item.label);
										$(event.target).val(ui.item.label);
										return false;
									},
									minLength: 0
								}).focus(function() {
									$(this).autocomplete("search");
								});
							}
						});
					</script>

					<fieldset>
					<div class="control-group ">
                        <h4><svg width="24" height="24"><use href="svg-icon/icons.svg#note-detail-svg-icon"></use></svg> Product Detail</h4> <hr>
							<label for="Company Type" class="control-label">Item Type</label>
							<div class="controls input-prepend-small feedback-resolve">
									<label class="radio inline">
									   <input type="radio" value="Product" checked name="itemType" id="itemType-P"> Product 
                                       <span class="checkmark"></span>
                                    </label>
									<label class="radio inline">
    									<input type="radio" value="Service" name="itemType" id="itemType-S"> Service 
                                        <span class="checkmark"></span>
                                    </label>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->
						<div class="control-group">
							<label for="name" class="control-label">Name<span class="star_red">*</span></label>
							<div class="controls">
								<input type="text" name="name" id="name" class="span4" placeholder="Enter your product / service name" maxlength="490" required>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

						<div class="control-group">	
							<label class="control-label">Product Note</label>	
							<div class="controls">
								<textarea id="product_note" name="product_note" class="span4" ></textarea>					
							</div><!-- /controls -->	
						</div><!-- /control-group -->
												<div class="control-group generate_barcode-field">
						<label for="name" class="control-label">Barcode/Serial No.</label>
						<div class="controls" style="position:relative;">
							<input type="text" name="barcode_no" id="barcode_no" class="span4 valid" oninput="this.value = this.value.toUpperCase()" placeholder="Enter Barcode No. or Scan it" maxlength="40" aria-invalid="false">
						</div><!-- /controls -->
						</div><!-- /control-group -->
						<div class="control-group">
							<label for="name" class="control-label">HSN/SAC Code</label>
							<div class="controls hsn_field" style="position:relative;">
							<input type="text" name="hsn" id="hsn" class="span4" placeholder="Enter your HSN code" maxlength="20">
							 	<a class="ViewhsnFinder" data-baseLink="goods_service_finder.php"&backUrl=bGlzdC1wcm9kdWN0LnBocD8=><div class="btn div-inner-input">Find</div></a>
							</div>
						</div>

						<div class="control-group">
							<label for="name" class="control-label">Unit of Measurement</label>
							<div class="controls" style="position:relative;">
								<input type="text" name="uom" data-value="" id="uommodal" class="span4" placeholder="Enter Unit of Measurement" maxlength="20">
								<div class="btn uomconversionbtn div-inner-input" >Conversion</div>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

						<div class="controls uom-conversion-section addmore-section" style="display:none;">
							
						</div>

						<h4 class="has_modal_lbl"> <svg width="24" height="24"><use href="svg-icon/icons.svg#price-detail-svg-icon"></use></svg> Tax & Pricing</h4> <hr>


						<div class="control-group">
							<label for="name" class="control-label">Tax <span class="star_red">*</span></label>
							<div class="controls">
								<select name="gstval" id="gstval" class="span4" required>
									<option value="">Select Tax</option>
									<option value="0.1">0.1</option>
									<option value="0.25">0.25</option>
									<option value="0.5">0.5</option>
									<option value="1">1</option>
									<option value="1.5">1.5</option>
									<option value="3">3</option>
									<option value="5">5</option>
									<option value="6">6</option>
									<option value="7.5">7.5</option>
									<option value="12">12</option>
									<option value="18">18</option>
									<option value="28">28</option>		
									<option value="Nil Rated">Nil Rated</option>
									<option value="Exempt">Exempt</option>
									<option value="Non-GST">Non-GST</option>			
								</select>
								<input type="hidden" name="taxability" id="taxability"  class="span4">
								<input type="hidden" name="igst" id="igst" onkeypress="return allowOnlyNumber(event);" class="span4"  maxlength="5">
								<input type="hidden" name="cgst" id="cgst" onkeypress="return allowOnlyNumber(event);" class="span4"  maxlength="5">
								<input type="hidden" name="sgst" id="sgst" onkeypress="return allowOnlyNumber(event);" class="span4"  maxlength="5">
							</div> <!-- /controls -->
						</div> <!-- /control-group -->
						<div class="control-group">
							<label for="CESS" class="control-label">CESS %</label>
							<div class="controls">
								<input type="text" name="cess" id="cess" onkeypress="return allowOnlyNumber(event);" class="span4" placeholder="Enter your CESS " maxlength="5">
							</div> <!-- /controls -->
						</div> <!-- /control-group -->
						
						<div class="control-group">
							<label for="CESS Amount" class="control-label">CESS Amount</label>
							<div class="controls" style="display: flex; align-items: center; border: 1px solid #ccc; border-radius: 8px; overflow: hidden;">
								<input type="text" name="cess_amount" id="cess_amount" onkeypress="return allowOnlyNumber(event);" class="span4" placeholder="Enter your CESS Amount " maxlength="10" style="border:none; border-right: 1px solid #ccc;border-radius:0px">
								<select name="cess_type" id="cess_type" style="border: none; height: 100%; background: white;width: 185px;outline:none;">
									<option value="0">Fixed</option>
									<option value="1">Per Unit</option>
								</select>
							</div>
						</div>

						<div class="control-group">
							<label class="control-label">No-ITC</label>
							<div class="controls">
								<div class="form-check"><label class="form-check-label">
										<input type="checkbox" id="no_itc" name="no_itc"> Is Product ineligible for Input Credit?</input>
										<i class="input-frame"></i></label>
                                </div>
							</div><!-- /controls -->
						</div><!-- /control-group -->
						
						<div class="control-group MngstockOption" style="margin-bottom: 18px;">
						<h4 class="has_modal_lbl"><svg width="24" height="24"><use href="svg-icon/icons.svg#note-detail-svg-icon"></use></svg> Manage Stock</h4> <hr>
							<label for="name" class="control-label">Type</label>
							<div class="controls input-prepend-small feedback-resolve">
									<label class="radio inline">
									<input type="radio" value="Normal" checked name="stockType" > Normal <span class="checkmark"></span></label>
									<label class="radio inline not-allowed-batch">
									<input type="radio" value="Batch" name="stockType"> Batch <span class="checkmark"></span></label>
									<label class="radio inline not-allowed-batch">
									<input type="radio" value="Serial" name="stockType"> Serial No. <span class="checkmark"></span></label>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

						<div class="normal-section ">
							<!-- <h4 class="has_modal_lbl changeStockName">Normal Stock 
							</h4>
							<hr> -->
							
							<div class="serialno-section "   style="display: none;">
								<div class="control-group">
									<label for="name" class="control-label">Serial No(s).</label>
									<div class="controls">
										<input type="hidden" name="serialno" id="tagInputs" class="span4"/>
									</div> <!-- /controls -->
								</div>
							</div>

							<div class="normalOpt stockOption control-group ">
								<label for="name" class="control-label">Available Qty</label>
								<div class="controls">
									<input type="text" name="items_available" id="items_available" onkeypress="return allowOnlyNumber(event);" class="span4" placeholder="Enter your available qty " maxlength="8">
								</div> <!-- /controls -->
							</div>
							<div class="normalOpt">
								<hr class="hide-hr">
								<div class="control-group">
									<label for="Sell Price" class="control-label">Sell Price</label>
									<div class="controls">
										<input type="text" name="sellprice" id="sellprice" onkeypress="return allowOnlyNumber(event);" class="span4" placeholder="Enter your sell price" maxlength="10">
									</div> <!-- /controls -->
								</div> <!-- /control-group -->

								<div class="control-group">
									<label for="Sell Price" class="control-label">Sell Price (Incl. Tax)</label>
									<div class="controls">
										<input type="text" name="sellprice_incl_tax" id="sellprice_incl_tax" onkeypress="return allowOnlyNumber(event);" class="span4" placeholder="Enter your sell price (Incl. Tax)" maxlength="10">
									</div> <!-- /controls -->
								</div> <!-- /control-group -->
								<div class="control-group">
									<label for="Purchase Price" class="control-label">Purchase Price</label>
									<div class="controls">
										<input type="text" name="purchaseprice" id="purchaseprice" onkeypress="return allowOnlyNumber(event);" class="span4" placeholder="Enter your purchase price" maxlength="10">
									</div> <!-- /controls -->
								</div> <!-- /control-group -->
								<div class="control-group">
									<label for="Purchase Price" class="control-label">Purchase Price (Incl. Tax)</label>
									<div class="controls">
										<input type="text" name="purchaseprice_incl_tax" id="purchaseprice_incl_tax" onkeypress="return allowOnlyNumber(event);" class="span4" placeholder="Enter your purchase price (Incl. Tax)" maxlength="10">
									</div> <!-- /controls -->
								</div> <!-- /control-group -->	
								
								
								<div class="control-group">
									<label  class="control-label">Low Stock Alert</label>
										<div class="controls">			
											<label class="form-check-label">
												<input type="text" id="product_lsa" name="product_lsa" placeholder="Low Stock Alert"></input> 	
												<i class="input-frame"></i></label>
										</div><!-- /controls -->	
								</div> <!-- /control-group -->	
							</div> <!-- /control-group -->	
						</div>

						<div class="batch-section" style="display: none;">
							<h4 class="has_modal_lbl"><svg width="24" height="24"><use href="svg-icon/icons.svg#batch-svg-icon"></use></svg>Batch Stock
							</h4>
							<hr>
							<div class="batchOpt">
								<table class="table  table-bordered">
									<thead>
										<tr>
											<th>Batch No.</th>																																																							 <th class="batchQty">Quantity</th> 																						<th>Sale Price</th>
											<th>Sale Price (Incl. Tax)</th>
											<th>Purchase Price</th>
											<th>Purchase Price (Incl. Tax)</th>
											<th></th>
										</tr>
									</thead>
									<tbody>
										
									</tbody>
								</table>	
							</div>
							<div class="control-group">
								<label  class="control-label">Low Stock Alert</label>
									<div class="controls">			
										<label class="form-check-label">
											<input type="text" id="product_lsa_batch" name="product_lsa" placeholder="Low Stock Alert"></input> 	
											<i class="input-frame"></i></label>
									</div><!-- /controls -->	
							</div> <!-- /control-group -->
						</div>
                        <div class="has_modal_lbl">
						<h4 ><svg width="24" height="24"><use href="svg-icon/icons.svg#box-svg-icon"></use></svg> Product Group <div class="btn btn-primary right_modal_btn has_modal_lbl_btn addProductCategory"><svg width="24" height="24"><use href="svg-icon/icons.svg#plus-svg-icon"></use></svg>Add Product Group</div></div>
						</h4>
						<hr>

						<div class="control-group">											
							<label for="name" class="control-label">Product Group </label>
							<div class="controls">
								<select class="product_group_id" multiple="multiple" name="product_category_id[]">
								</select>
							</div> <!-- /controls -->	
						</div> <!-- /control-group -->

						<div class="controls cate_section categoryOpt" style="display:none;">
							<label for="categoryname" class="control-label">Product Group Name</label>
							<input type="text" class="categoryname" placeholder="Enter your product group name" maxlength="500" onkeydown="enterpressFunction(event.keyCode);">
							<input type="hidden" id="cathmac" value="8cbb6d841ec31ea692da" />
							<a class="btn btn-primary catesave">Save</a>
						</div>

                        <h4 class="has_modal_lbl"><svg width="24" height="24"><use href="svg-icon/icons.svg#additional-note-svg-icon"></use></svg> Additional Details </h4>
                        <hr>
                        
						
												
						<div class="control-group">
                            <label for="CESS Amount" class="control-label">Product Discount</label>
                            <div class="controls" style="display: flex; align-items: center; border: 1px solid #ccc; border-radius: 8px; overflow: hidden;">
                                <input type="text" name="product_disc" id="product_disc" class="span4" placeholder="Enter product discount " maxlength="10" style="border:none; border-right: 1px solid #ccc;border-radius:0px">
                                <select name="product_disc_in" id="product_disc_in" style="border: none; height: 100%; background: white;width: 185px;outline:none;">
                                    <option value="rupee">Rupee</option>
                                    <option value="percentage">Percentage</option>
                                </select>
                            </div>
                        </div>
						
						<div class="control-group product_dropzone">
							<label class="control-label">Product Images</label>
							<div class="controls product-dropzone">

                                    <div class="dropzone  lockeddrop" data-target="#addRemoveModal" " id="id_dropzone" ></div>
                                    <div id="product_error_msg" style="color: red"></div>
            
                                 
							</div><!-- /controls -->
						</div><!-- /control-group -->

                        <!-- <div class="control-group">
							<label for="product discount" class="control-label product_length">Product Length (CM)</label>
							<div class="controls product_len" style="position:relative;">
								<input type="text" class="span2" id="product_len" name="product_len" placeholder="Product Length">
							</div> 
						</div>

                        <div class="control-group">
							<label for="product discount" class="control-label product_breadth">Product Breadth (CM)</label>
							<div class="controls product_brdth" style="position:relative;">
								<input type="text" class="span2" id="product_brdth" name="product_brdth" placeholder="Product Breadth">
							</div>
						</div> 

                        <div class="control-group">
							<label for="product discount" class="control-label product_height">Product Height (CM)</label>
							<div class="controls product_ht" style="position:relative;">
								<input type="text" class="span2" id="product_ht" name="product_ht" placeholder="Product Height">
							</div>
						</div> 

                        <div class="control-group">
							<label for="product discount" class="control-label product_weight">Product Weight (KG)</label>
							<div class="controls product_wt" style="position:relative;">
								<input type="text" class="span2" id="product_wt" name="product_wt" placeholder="Product Weight">
							</div>
						</div>  -->
						<div class="control-group">
							<label class="control-label"> Manufacturing </label>
							<div class="controls">
								<div class="form-check">
									<label class="form-check-label">
										<input type="checkbox" id="is_manufacturing" name="is_manufacturing" 
											data-toggle="modal" data-target="#addRemoveModal">
										I Manufacture this product
										<i class="input-frame"></i>
									</label>
								</div>
							</div>
						</div>


						<div class="control-group">
							<label class="control-label">Non-Sellable Product</label>
							<div class="controls">
								<div class="form-check">
                                    <label class="form-check-label">
                                        <input type="checkbox" id="non_salable_product" name="non_salable_product"> Selling and inventory tracking for this product will be disabled</input>
                                        <i class="input-frame"></i>
                                        <span data-toggle="tooltip" title="Non-sellable items are not for direct sale but used internally, like packing materials, office supplies, or for internal processes." class='non-salable-tooltip' ><svg width="12" height="12"><use href="svg-icon/icons.svg#info-dark-svg-icon"></use></svg></span>
                                    </label>
                                </div>
							</div><!-- /controls -->
						</div><!-- /control-group -->
						<div class="control-group enableProduct" style="display:none;"> 	
							<label class="control-label">Enable</label>	
							<div class="controls">			
								<div class="form-check"><label class="form-check-label">
									<input type="checkbox" id="is_active" name="is_active" checked="checked"> Product will be visiable on all document.</input>	
									<i class="input-frame"></i></label></div>
							</div><!-- /controls -->	
						</div><!-- /control-group -->


												<input type="hidden" name="hmac" id="hmac" value="854c159899fdbe56f0a1" />
						<input type="hidden" name="oldstockType" class="oldstockType" value="" />
						<input type="hidden" name="totalStock" class="totalStock" value="" />
						<input type="hidden" name="NewStock" class="NewStock" value="0" />
					</fieldset>
					<div id="PrIntHsnModal" class="modal popup_right_slider fade" role="dialog" style="display: none;">
						<div class="modal-dialog">
								<div class="modal-content is-loading">
									<div id="iframeContainer">
										<iframe name="print_iframe" id="hsn_iframe" src="" frameborder="0" style="width:100%;height:100vh;float:left;"></iframe>
									</div>
									<div class="preloader-overly">
									<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.0" width="80px" height="80px" viewBox="0 0 128 128" xml:space="preserve"><g><path fill="#00ba8c" fill-opacity="1" d="M109.25 55.5h-36l12-12a29.54 29.54 0 0 0-49.53 12H18.75A46.04 46.04 0 0 1 96.9 31.84l12.35-12.34v36zm-90.5 17h36l-12 12a29.54 29.54 0 0 0 49.53-12h16.97A46.04 46.04 0 0 1 31.1 96.16L18.74 108.5v-36z"></path><animateTransform attributeName="transform" type="rotate" from="0 64 64" to="360 64 64" dur="880ms" repeatCount="indefinite"></animateTransform></g></svg>
									</div>
								</div>
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default pull-left" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg>Close</button>
					<button class="btn btn-primary" name="btnsubmit" type="submit"><svg width="20" height="20"><use href="svg-icon/icons.svg#save-svg-icon"></use></svg>Save</button>
				</div>
			</div>
		</form>
	</div>
</div>
<script>
	Dropzone.autoDiscover = false;
	$(document).ready(function () {
        $('.lockeddrop').click(function () { $('#addRemoveModal').modal('show').css('z-index', Math.max(...$('.modal').map((_, e) => +$(e).css('z-index'))) + 10); });
			
		var totalProductFiles = 0;
        var uploadedProductFiles = 0;

		arrayData = [];
		var image_box = "";
		$("#id_dropzone").dropzone({
			maxFiles: 5,
			maxFilesize: 2, 
			dictDefaultMessage: "<div style='display-flex; flex-direction:column;'><img src='assets/svgs/image_icon.svg'><p style='font-weight:bold;'>Click To Upload</p></div>",
			acceptedFiles: '.jpeg,.png,.jpg',
			url: "file-upload-ajaxcall.php",
			params: {
				upload_type: 1			},
			clickable: false,        });

            $(document).on("click", ".product_box .eye", function(e) {
			var imageSrc = $(this).closest('.product_box').find('img').attr('src');
			var gallery = [
				{
					src: imageSrc,
					thumb: imageSrc,
				},
			];
			Fancybox.show(gallery);
			
		});
		$(document).on("click", ".product_box .trash", function(e) {
			$(this).parent('.product_box').find('input[name="file_id[]"]').attr('name', 'deleted_file_id[]');
			$(this).parent('.product_box').find('input[name="file_name[]"]').attr('name', 'deleted_file_name[]');
			$(this).parent('.product_box').hide();
		});
	});
</script>

<div id="Get-whatsapp-email-Modal" class="modal fade" role="dialog" style="display: none;">
  <div class="modal-dialog">
  <form class="form-horizontal" method="post" id="PaymentModalForm" novalidate="novalidate">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="btn btn-default btn_close" data-dismiss="modal" ><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg></button>
        <h4 class="modal-title">Enter Mobile No</h4>
      </div>
      <div class="modal-body">
			<fieldset>
				<div class="control-group">											
					<label for="name" class="control-label">Mobile No</label>
					<div class="controls">
						<input type="text"  name="filed-input" id="filed-input" class="span4">
						<span id="error_message" style="color:red;"></span></div>				
				</div>
			</fieldset>
      </div>
      <div class="modal-footer">
			<button class="btn btn-primary" name="btnsubmit" type="submit"><svg width="20" height="20"><use href="svg-icon/icons.svg#send-svg-icon"></use></svg> Send</button> 
			<button type="button" class="btn btn-default" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg>Close</button>
      </div>
    </div>
	</form>
  </div>
</div>

<div id="TransportChargeModal" class="popup_right_slider modal fade" role="dialog" style="display: none;">
	<div class="modal-dialog">
		<form class="form-horizontal" method="post" id="TransportChargeModalForm">
			<!-- Modal content-->
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="btn btn-default btn_close" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg></button>
					<h4 class="modal-title">Add Additional Charges</h4>
				</div>
				<div class="modal-body">

					<fieldset>
						<div class="control-group">
							<label for="name" class="control-label">Name<span class="star_red">*</span></label>
							<div class="controls">
								<input type="text" name="name" id="name" class="span4" placeholder="Enter additional charge name" maxlength="500" required>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

						<div class="control-group">	
							<label class="control-label">Product Note</label>	
							<div class="controls">
								<textarea id="product_note" name="product_note" class="span4" ></textarea>					
							</div><!-- /controls -->
						</div><!-- /control-group -->

						<div class="control-group">
							<label for="Sell Price" class="control-label">Price</label>
							<div class="controls">
								<input type="text" name="sellprice" id="sellprice" onkeypress="return allowOnlyNumber(event);" class="span4" placeholder="Enter price" maxlength="10">
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

						<div class="control-group">
							<label for="name" class="control-label">HSN/SAC Code</label>
							<div class="controls">
								<input type="text" name="hsn" id="hsn" class="span4" placeholder="Enter your HSN code" maxlength="20">
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

						<div class="control-group">
							<label class="control-label">No-ITC</label>
							<div class="controls">
								<div class="form-check"><label class="form-check-label">
										<input type="checkbox" id="no_itc" name="no_itc"> Is Product ineligible for Input Credit?</input>
										<i class="input-frame"></i></label></div>
							</div><!-- /controls -->
						</div><!-- /control-group -->
						<div class="control-group">
							<label for="name" class="control-label">Tax <span class="star_red">*</span></label>
							<div class="controls">
								<select name="gstval" id="gstval" class="span4" required>
									<option value="">Select Tax</option>
									<option value="0.1">0.1</option>
									<option value="0.25">0.25</option>
									<option value="0.5">0.5</option>
									<option value="1">1</option>
									<option value="1.5">1.5</option>
									<option value="3">3</option>
									<option value="5">5</option>
									<option value="6">6</option>
									<option value="7.5">7.5</option>
									<option value="12">12</option>
									<option value="18">18</option>
									<option value="28">28</option>		
									<option value="Nil Rated">Nil Rated</option>
									<option value="Exempt">Exempt</option>
									<option value="Non-GST">Non-GST</option>			
								</select>
								<input type="hidden" name="taxability" id="taxability"  class="span4">
								<input type="hidden" name="igst" id="igst" onkeypress="return allowOnlyNumber(event);" class="span4"  maxlength="5">
								<input type="hidden" name="cgst" id="cgst" onkeypress="return allowOnlyNumber(event);" class="span4"  maxlength="5">
								<input type="hidden" name="sgst" id="sgst" onkeypress="return allowOnlyNumber(event);" class="span4"  maxlength="5">
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

						<div class="control-group">
							<label class="control-label">Service Item</label>
							<div class="controls">
								<div class="form-check"><label class="form-check-label">
										<input type="checkbox" id="is_service_product" name="is_service_product">Check if it is service, Ex - Computer Service, Consulting Services (No Stock Count)</input>
										<i class="input-frame"></i></label></div>
							</div><!-- /controls -->
						</div><!-- /control-group -->

						<div class="control-group enableAdditional" style="display:none;">	
							<label class="control-label">Enable</label>	
							<div class="controls">			
								<div class="form-check"><label class="form-check-label">
									<input type="checkbox" checked id="is_active" name="is_active" >Additional Charge will be visiable on all document.</input>	
								<i class="input-frame"></i></label></div>
							</div><!-- /controls -->	
						</div><!-- /control-group -->
						<input type="hidden" name="hmac" id="hmac" value="fdc1e3d7be5c9bad0d9b" />
					</fieldset>
				</div>
				<div class="modal-footer">
					<a href="list-transport-charges.php" target="_blank" class="btn btn-primary Margin_Bottom_btn" style="float:left;"><svg width="20" height="20"><use href="svg-icon/icons.svg#save-svg-icon"></use></svg>View All Additional Charges</a>					<a type="button" class="btn btn-default Margin_Bottom_btn pull-left" data-dismiss="modal" style="background: #D9D9D9;border-color: #D9D9D9;"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg>Close</a>
					<button class="btn btn-primary Margin_Bottom_btn" name="btnsubmit" type="submit"><svg width="20" height="20"><use href="svg-icon/icons.svg#save-svg-icon"></use></svg>Save</button>
				</div>
			</div>
		</form>
	</div>
</div>
<div id="ProductCategoryModal" class=" popup_right_slider modal fade" role="dialog" style="display: none;">
	<div class="modal-dialog">
		<form class="form-horizontal" method="post" id="ProductCategoryModalForm">
			<!-- Modal content-->
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="btn btn-default btn_close" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg></button>
					<h4 class="modal-title">Add Product Group</h4>
				</div>
				<div class="modal-body">
					<fieldset>
						<div class="control-group">
							<label for="name" class="control-label">Name<span class="star_red">*</span></label>
							<div class="controls">
								<input type="text" name="category_name" id="name" class="span4" placeholder="Enter your product group name" maxlength="500" required>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->
						<div class="control-group enableCategory" style="display: none;"> 	
							<label class="control-label">Enable</label>	
							<div class="controls">			
								<div class="form-check"><label class="form-check-label">
									<input type="checkbox" id="is_active" name="is_active" checked="checked"> Product Group will be visiable on all document.	
									<i class="input-frame"></i></label></div>
							</div><!-- /controls -->	
						</div>
						
												<input type="hidden" name="hmac" id="hmac" value="8cbb6d841ec31ea692da" />
					</fieldset>

				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default pull-left" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg>Close</button>
					<button class="btn btn-primary" name="btnsubmit" type="submit"><svg width="20" height="20"><use href="svg-icon/icons.svg#save-svg-icon"></use></svg>Save</button>
				</div>
			</div>
		</form>
	</div>
</div>
<div id="extendewaymodal" class="modal popup_right_slider fade" role="dialog" style="display: none;">
	<div class="modal-dialog">
		<form class="form-horizontal" method="post" id="extendewaymodalForm">
			<!-- Modal content-->
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="btn btn-default btn_close" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg></button>
					<h4 class="modal-title">Extend Eway Bill</h4>
				</div>
				<div class="modal-body">
					<fieldset>
						<div class="control-group">
							<label for="validtill" class="control-label">Eway Bill Valid till<span class="star_red">*</span></label>
							<div class="controls">
								<input type="text" name="valid_till" id="valid_till" class="span4"  required>
								<input type="hidden" name="ewayID" id="ewayID">
								<input type="hidden" name="invid" id="invid">
							</div> <!-- /controls -->
						</div> <!-- /control-group -->
						<div class="control-group">
							<label for="ext_reason" class="control-label">Extension Reason<span class="star_red">*</span></label>
							<div class="controls">
							<select type="list" name="ext_reason" class="span4 ext_reason"  required>
								<option value="">Select Extension Reason</option>
								<option value="1">Natural Calamity</option>
								<option value="2">Law and Order Situation</option>
								<option value="4">Transshipment</option>
								<option value="5">Accident</option>
								<option value="99">Others</option>
								</select>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->
						<div class="control-group">
							<label for="ext_remark" class="control-label">Extension Remarks<span class="star_red">*</span></label>
							<div class="controls">
								<input type="text" name="ext_remark" id="ext_remark" class="span4"  required>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->
						<div class="control-group">
							<label for="cur_place" class="control-label">Current Place<span class="star_red">*</span></label>
							<div class="controls">
								<input type="text" name="cur_place" id="cur_place" class="span4"  required>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->
						<div class="control-group">
							<label for="cur_pincode" class="control-label">Current Pincode<span class="star_red">*</span></label>
							<div class="controls">
								<input type="text" name="cur_pincode" id="cur_pincode" class="span4"  required>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->
						<div class="control-group">
							<label for="to_pincode" class="control-label">Destination Pincode<span class="star_red">*</span></label>
							<div class="controls">
								<label type="text" id="to_pincode_label" class="span4 to_pincode_label"></label>
								<input type="hidden" name="to_pincode" id="to_pincode" class="span4 to_pincode"></input>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->

						<div class="control-group">
						<label for="eway_distance" class="control-label">Approximate Distance </label>
							<div class="controls">
								<input type="text" name="eway_distance" id="eway_distance" class="span4" >
								<label for="auto-distance" class="">Auto Calculated Distance <span class="auto-distance"> </span></label>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->
						<div class="control-group">
						<label for="cur_state" class="control-label">Current State<span class="star_red">*</span></label>
							<div class="controls">
								<select type="list" name="cur_state" class="span4 all_state_list"  required></select>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->
						<div class="control-group">
						<label for="address_line_1" class="control-label">Address 1</label>
							<div class="controls">
								<input type="text"  name="address_line_1" class="span4 address_line_1" disabled></input>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->
						<div class="control-group">
						<label for="address_line_2" class="control-label">Address 2</label>
							<div class="controls">
								<input type="text"  name="address_line_2" class="span4 address_line_2" disabled></input>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->
						<div class="control-group">
						<label for="address_line_3" class="control-label">Address 3</label>
							<div class="controls">
								<input type="text"  name="address_line_3" class="span4 address_line_3" disabled></input>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->
						<div class="control-group">
							<label for="consignment_in" class="control-label">Consignment Is<span class="star_red">*</span></label>
							<div class="controls">
								<input type="hidden" name="consignment_in_hidden" class="consignment_in_hidden">
								<select type="list" name="consignment_in" class="span4 consignment_in"  required>
									<option value="M">in Movement</option>
									<option value="T">in Transit</option>
								</select>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->
						<div class="control-group">
							<label for="trans_mode" class="control-label">Transport Mode<span class="star_red">*</span></label>
							<div class="controls">
								<select type="list" name="trans_mode" class="span4 trans_mode"  required>
								<option value="">Select Transport Mode</option>
								<option value="1">Road</option>
								<option value="2">Rail</option>
								<option value="3">Air</option>
								<option value="4">Ship</option>
								<option value="5">in Transit</option>
								</select>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->
						<div class="control-group">
							<label for="transport_no" class="control-label">Transport No<span class="star_red">*</span></label>
							<div class="controls">
								<input type="text" name="transport_no" id="transport_no" class="span4" required>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->
						<div class="control-group">
							<label for="transit_type" class="control-label">Transmit Type<span class="star_red">*</span></label>
							<div class="controls">
								<select type="list" name="transit_type" class="span4 transit_type"  required>
								<option value="">Select Transmit Type</option>
								<option value="R">Road</option>
								<option value="W">Warehouse</option>
								<option value="O">Others</option>
								</select>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->
						<div class="control-group">
							<label for="vehicle_no" class="control-label">vehicle No<span class="star_red">*</span></label>
							<div class="controls">
								<input type="text" name="vehicle_no" id="vehicle_no" class="span4" placeholder="GJ01TR1234" required>
							</div> <!-- /controls -->
						</div> <!-- /control-group -->
					</fieldset>

				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default pull-left" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg>Close</button>
					<button class="btn btn-primary" name="btnsubmit" type="submit"><svg width="20" height="20"><use href="svg-icon/icons.svg#save-svg-icon"></use></svg>Save</button>
				</div>
			</div>
		</form>
	</div>
</div>
<div id="cancelEwayBillModal" class="modal fade" role="dialog" style="display: none;">
	<div class="modal-dialog">
		<form class="form-horizontal" method="post" id="cancelEwayBillForm" style="margin: 0;">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="btn btn-default btn_close" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg></button>
					<h4 class="modal-title">Cancel E-Way Bill</h4>
				</div>
				<div class="modal-body">
					<div class="control-group">											
						<label for="eway_cancel_reason" class="control-label">Reason<span class="star_red">*</span></label>
						<div class="controls">
							<select name="eway_cancel_reason" class="span4" id="eway_cancel_reason" required>
								<option value="">Select Reason</option>
								<option value="1">Duplicate</option>
								<option value="2" selected>Order Cancelled</option>
								<option value="3">Data Entry Mistake</option>
								<option value="4">Others</option>
							</select>
						</div>	
					</div> 
					<div class="control-group">											
						<label for="eway_cancel_remarks" class="control-label">Remarks</label>
						<div class="controls">
							<textarea name="eway_cancel_remarks" id="eway_cancel_remarks" class="span4" placeholder="Remarks"></textarea>
						</div>		
					</div>
				</div>
				<div class="modal-footer" style="display: flex; justify-content: end;">
					<button type="button" class="btn btn-default" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg>Close</button>
					<button class="btn btn-primary" id="cancel_eway_btn" type="submit"><svg width="20" height="20"><use href="svg-icon/icons.svg#ban-svg-icon"></use></svg>Cancel E-Way Bill</button> 
				</div>
			</div>
		</form>
	</div>
</div>

<script>
    
 
	var addCateArr = [];
	$(document).ready(function() {
		$('.AddCustomerModal, .add_customer_modal_button').click(function(e) {
            
			var businessState = 'Karnataka';
			var isPresent = handles.includes(businessState);
			if(isPresent){
				$("#listBox option[value='"+ businessState +"']").prop("selected", true);
			} 
            		});
		$('.add_transport_charge_modal_button').click(function(e) {
            		});
		$('.add_transport_modal_button').click(function(e) {
            		});
		$('#CustomerModal .update-gstinfield').hide();

		$(document).on("change blur keypress keyup", "#CustomerModal #gstno", function(e) {
			if ($(this).val() != "" && $('#CustomerModal select[name=registration_type]').val() == 'Unregistered') {
				$("#CustomerModal select[name=registration_type]").val("Regular").change();
			} else if ($(this).val() == "") {
				$("#CustomerModal select[name=registration_type]").val("Unregistered").change();
			}
		});

		$('#CustomerModalForm').on("blur",'#companyname',function(){

			var gstno = $('#gstno').val();
			var cmpName = $('#companyname').val();
			$.ajax({
					type: "POST",
					url: "ajaxcall.php",
					ContentType: 'application/json',
					dataType: 'json',
					data: {term: cmpName,action:'checkCustomerExist', gstno: gstno},
					beforeSend: function() {
						$("body").removeClass("is-loading");
					},
					success: function(data) {
						if (data.status == "OK") {
							var cmpExist = data.cmpExist;
							if(cmpExist != ""){
								$("#alredyExist").html("");
								$("#alredyExist").closest(".control-group").show();
								cmpExist.map(function(cmp) {
									var html = "";
									html = `<div class='span6 span-md-6 span-xs-12 span-sm-6 equal-height' style="padding:2px"><div class="getRow ">
												<h4>${cmp.companyname}</h4>
												<p>${cmp.gstno}</p>
												<p>${cmp.address}</p>
												<span class='label'>${cmp.companytype}</span>
											</div></div>`;
									$("#alredyExist").append(html);
								});
								equalheight('.equal-height');
							}else{
								$("#alredyExist").html("");
								$("#alredyExist").closest(".control-group").hide();
							}
						} 
					},
					complete: function(data) {}
				});
		});
		$.validator.addMethod("validateGSIN", function(value, element) {
			var gstinValid = true;
			var state = $("#listBox option:selected").text();
			if (value != "" && value.length == 15) {
				if (value.length != 15) {
					return false;
				}
				if (state != "") {
					state = state.replace("(New)", "");
					if (state.indexOf('(') !== -1) {
						state = state.split('(')[1];
						state = state.split(')')[0];
						state = state.trim();
						gstinValid = value.startsWith(state);
					}
				} else {
					gstinValid = true;
				}
			}
			return gstinValid;
		}, 'Entered GSTIN is invalid for the selected state.');

		jQuery.validator.addMethod("req_type_validate", function(value, element) {
			var valid_reg = false;
			var registration_type = $('select[name=registration_type]').val();
			var gstno = $('#gstno').val();
			if (registration_type == 'Unregistered' && gstno == "") {
				valid_reg = true;
			} else if (registration_type != 'Unregistered' && gstno != "") {
				valid_reg = true;
				if (registration_type != 'Regular-UIN' && gstno.length != 15) {
					valid_reg = false;
				}
			}
			return valid_reg;
		}, "Please enter valid registration type.");

		jQuery.validator.addMethod("validate_shipname", function(value, element) {
			var is_valid = true;
			if($('.shipping_address_section .shipping_address_reapiter').length > 0){
				$('.shipping_address_section .shipping_address_reapiter').each(function() {
					if ($(this).find('[name="ship_name[]"]').val() == "") {
						$(this).find('.ship_name_error').remove();
						$(this).find('[name="ship_name[]"]').after('<label class="error ship_name_error" >Please enter ship name</label>');
						is_valid = false;
					}
				});
			}	
			return is_valid;
	
		}, "");

		jQuery.validator.addMethod("validate_shipaddress", function(value, element) {
			var is_valid = true;
			if($('.shipping_address_section .shipping_address_reapiter').length > 0){
				$('.shipping_address_section .shipping_address_reapiter').each(function() {
					if ($(this).find('[name="ship_address[]"]').val() == "") {
						$(this).find('.ship_address_error').remove();
						$(this).find('[name="ship_address[]"]').after('<label class="error ship_address_error" >Please enter ship address</label>');
						is_valid = false;
					}
				});
			}	
			return is_valid;
	
		}, "");

		jQuery.validator.addMethod("validate_shiplandmark", function(value, element) {
			var is_valid = true;
			if($('.shipping_address_section .shipping_address_reapiter').length > 0){
				$('.shipping_address_section .shipping_address_reapiter').each(function() {
					if ($(this).find('[name="ship_landmark[]"]').val() == "") {
						$(this).find('.ship_landmark_error').remove();
						$(this).find('[name="ship_landmark[]"]').after('<label class="error ship_landmark_error" >Please enter ship landmark</label>');
						is_valid = false;
					}
				});
			}	
			return is_valid;
	
		}, "");

		jQuery.validator.addMethod("validate_shipcity", function(value, element) {
			var is_valid = true;
			if($('.shipping_address_section .shipping_address_reapiter').length > 0){
				$('.shipping_address_section .shipping_address_reapiter').each(function() {
					if ($(this).find('[name="ship_city[]"]').val() == "") {
						$(this).find('.ship_city_error').remove();
						$(this).find('[name="ship_city[]"]').after('<label class="error ship_city_error" >Please enter ship city</label>');
						is_valid = false;
					}
				});
			}	
			return is_valid;
	
		}, "");

		jQuery.validator.addMethod("validate_shippincode", function(value, element) {
			var is_valid = true;
			if($('.shipping_address_section .shipping_address_reapiter').length > 0){
				$('.shipping_address_section .shipping_address_reapiter').each(function() {
					if ($(this).find('[name="ship_pincode[]"]').val() == "") {
						$(this).find('.ship_pincode_error').remove();
						$(this).find('[name="ship_pincode[]"]').after('<label class="error ship_pincode_error" >Please enter ship landmark</label>');
						is_valid = false;
					}
				});
			}	
			return is_valid;
	
		}, "");

		jQuery.validator.addMethod("validate_shipstate", function(value, element) {
			var is_valid = true;
			if($('.shipping_address_section .shipping_address_reapiter').length > 0){
				$('.shipping_address_section .shipping_address_reapiter').each(function() {
					if ($(this).find('[name="ship_country[]"]').val() == "India" && $(this).find('[name="ship_state[]"]').val() == "") {
						$(this).find('.ship_state_error').remove();
						$(this).find('[name="ship_state[]"]').after('<label class="error ship_state_error" >Please enter ship state</label>');
						is_valid = false;
					}
				});
			}	
			return is_valid;
	
		}, "");
		
		$("#CustomerModal form").validate({
			rules: {
				field: {
					required: true
				},
				email : { multiplemail: true },
				state: {
					required: function(element) {
						return $("#listBoxCountry").val() == "India";
					}
				},
				'ship_name[]': {
					validate_shipname: true
				},
				'ship_state[]': {
					validate_shipstate: true
				},
				'ship_address[]': {
					validate_shipaddress: true
				},
				'ship_landmark[]': {
					validate_shiplandmark: true
				},
				'ship_city[]': {
					validate_shipcity: true
				},
				'ship_pincode[]': {
					validate_shippincode: true
				},
				'ship_email[]': {
					email: true
				},
				
				gstno: {
					validateGSIN: true
				},
				registration_type: {
					req_type_validate: true
				},
			},
			messages: {
				companyname: "Please enter customer / vendor name",
				contactperson: "Please select contactperson name",
				contactno1: "Please enter contact number",
				address1: "Please enter address1",
				city: "Please enter city",
				state: "Please enter state name",
				email : {validate_email: "Please enter a valid email address."}
			},
			submitHandler: function(form) {
				var data = $(form).serialize() + '&action=SubmitCustomerModel';
				$.ajax({
					type: "POST",
					url: "ajaxcall.php",
					ContentType: 'application/json',
					dataType: 'json',
					data: data,
					success: function(data) {

						if (data.status == 'OK') {
							var currentURL = window.location.href;
							pageURL = currentURL.replace(/^.*[\\\/]/, '');
							if (pageURL == "list-company.php" || pageURL.indexOf("list-company.php") != -1) {
								var mode = data.redirect.split('?')[1].split('=');
								if(mode == 'insert'){
									window.location.href = data.redirect;
								}else{
									window.location.href = data.redirect+'&'+ $("#url_string").val();
								}
							} else {
								var addressParts = [
									data.contactperson,
									data.landmark,
									data.city
								].filter(Boolean).map(part => part.trim());

								var list_address = addressParts.join(", ");
								var companyName = data.companyname?.trim() || "";
								var gst = data.gst?.trim();
								var custlabel = `${companyName}${gst ? ", " + gst : ""} (${companyName}${list_address ? ", " + list_address : ""})`;

								var newCustomer = {
									label: custlabel,
									value: data.id,
									companyname: companyName,
									companytype: data.companytype,
									gstno: gst,
									contactno1: data.phone,
									address: list_address
								};

								availableCustomer.push(newCustomer);

								$("#autoCustomerField").autocomplete("option", "source", (request, response) => {
									var term = request.term.toLowerCase();
									response(availableCustomer.filter(item => item.label.toLowerCase().includes(term)).slice(0, 500));
								});

								var match = availableCustomer.find(item => item.value === data.id);
								if (match) {
									$("#autoCustomerField").val(match.label).trigger('change');
									$("#customers").val(match.value).attr("data-type", match.companytype);
									$("#hidden_companyname").val(match.label);
								}

								$(".customer-information-invoice #cmp_contactperson").val(data.contactperson);
								$(".customer-information-invoice #cmp_address1").val(data.address1);
								$(".customer-information-invoice #cmp_address2").val(data.address2);
								$(".customer-information-invoice #cmp_landmark").val(data.landmark);
								$(".customer-information-invoice #cmp_pincode").val(data.pincode);
								$(".customer-information-invoice #cmp_country").val(data.country);
								$(".customer-information-invoice #cmp_city").val(data.city);
								$(".customer-information-invoice #address").html(data.address);
								$(".customer-information-invoice #phone").val(data.phone);
								$(".customer-information-invoice #cmp_gstno").val(data.gst);
								$(".customer-information-invoice #cmp_gstno[data-value='']").val(data.gst);
								$(".customer-information-invoice #hidden-invoice-state").attr("data-value", data.state).val(data.state);
								if (!pageURL.includes("purchaseinvoicebill.php") && !pageURL.includes("purchaseorderbill.php")) {
									console.log(pageURL);
									$(".customer-information-invoice .PlaceofSupply").val(data.state);
									$(".customer-information-invoice .PlaceofSupply[data-value='']").val(data.state);
								}
								$(".customer-information-invoice #amount_limit").val(data.amount_limit);


								if (data.gst == "") {
									$("#reverse_Charge").val("0");									$("#reverse_Charge").attr("disabled", true).trigger("change");
								} else {
									$("#reverse_Charge").attr("disabled", false).trigger("change");
								}

								InvoiceTypeSet(data.country, data.party_type);

								SetIGTS();



								if (data.country == "India") {
									$(".control-group-PlaceofSupply").show();
								} else {
									$(".customer-information-invoice .PlaceofSupply[data-value='']").val("");
									$(".control-group-PlaceofSupply").hide();
								}

								var shipping_options = '';
								var shipping_addresses_obj = jQuery.parseJSON(data.shipping_addresses);
								$.each(shipping_addresses_obj, function(i, ship_single) {
									shipping_options = shipping_options + '<option value="' + ship_single.ship_name + '" ship_address="' + ship_single.ship_address + '" ship_phone="' + ship_single.ship_phone +  '" ship_email="' + ship_single.ship_email + '" ship_pincode="' + ship_single.ship_pincode + '" ship_gstno="' + ship_single.ship_gstno + '" ship_country="' + ship_single.ship_country + '" ship_state="' + ship_single.ship_state + '" >' + ship_single.ship_name + '</option>';
								});
								if (shipping_options != "") {
									$("#shipping_address").html(shipping_options);
								} else {
									$("#shipping_address").html('<option value="">--</option>');
								}
								$("#shipping_address").trigger('change');
								
								var shipping_address_id = ''; 
								var ship_name = ''; 
								var ship_address = ''; 
								var ship_phone = ''; 
								var ship_email = ''; 
								var ship_pincode = ''; 
								var ship_gstno = ''; 
								var ship_country = ''; 
								var ship_state = ''; 
								var shipping_distance_eway = ''; 

								if(shipping_addresses_obj.length > 0){
									for (var i = 0; i < 1; i++) {
										shipping_address_id = shipping_addresses_obj[i].shipping_address_id; 
										ship_name = shipping_addresses_obj[i].ship_name; 
										ship_address = shipping_addresses_obj[i].ship_address; 
										ship_phone = shipping_addresses_obj[i].ship_phone; 
										ship_email = shipping_addresses_obj[i].ship_email; 
										ship_pincode = shipping_addresses_obj[i].ship_pincode; 
										ship_gstno = shipping_addresses_obj[i].ship_gstno; 
										ship_country = shipping_addresses_obj[i].ship_country; 
										ship_state = shipping_addresses_obj[i].ship_state; 
										shipping_distance_eway = shipping_addresses_obj[i].shipping_distance_eway; 
									}
								}
								$(".customer-information-invoice #shipping_address_id").val(shipping_address_id);
								$(".customer-information-invoice #shippingName").val(ship_name);
								$(".customer-information-invoice #shippingAddress").html(ship_address);
								$(".customer-information-invoice #shippingPhone").val(ship_phone);
								$(".customer-information-invoice #shippingEmail").val(ship_email);
								$(".customer-information-invoice #shippingPincode").val(ship_pincode);
								$(".customer-information-invoice #shippingGSTIN").val(ship_gstno);
								$(".customer-information-invoice [name='shippingCountry']").val(ship_country).trigger("change");
								$(".customer-information-invoice [name='shippingState']").val(ship_state);
								$(".customer-information-invoice [name='shipping_distance_eway']").val(shipping_distance_eway);
								
								
								$("#CustomerModal [name=balance_type][value=Credit]").prop('checked', true);
								$("#CustomerModal [name=balance_amount]").val(0);
								$("#CustomerModal form input[type='text']").val('');
								$("#CustomerModal form input[type='hidden']").val('');
								$("#CustomerModal form textarea").val('');
								$("#listBoxCountry").val('India').trigger("change");
								$("#listBox").val('Select State');
								$("#listBoxCountry2").val('India').trigger("change");
								$("#listBox2").val('Select State');
								$("#listBoxCompany").val('Customer');
								$("#customers").val(data.id);
								SetIGTS();
								if ($('#datepicker_lr').length > 0) {
									if (data.company_due_date != "") {
										$("#datepicker_lr").attr("data-default-due", data.company_due_date);
										$("#datepicker_bill").trigger("change");
									} else {
										$("#datepicker_lr").attr("data-default-due", $("#datepicker_lr").attr("data-main-default-due"));
										$("#datepicker_bill").trigger("change");
									}
								}

								$("#CustomerModal").modal("hide");
								if (pageURL == "pos-bill.php" || pageURL.indexOf("pos-bill.php") != -1) {
									$('#customers_modal').append($('<option>', {
										value: data.id,
										text: data.companyname
									}));
									$(".select_customer_modal_button").text(data.companyname);
									$('#customers').trigger('change');
								}
							}
						}
						if (data.status == "ERROR") {
							errorMessage(data.msg,'Error In Saving Detail','','error');
						}
					},
					complete: function(data) {}
				});
			}
		});

		
		
		$('#CustomerModalForm').on("click",'input[name="companytype"]',function(){
			if ($(this).is(':checked')) {
				if($(this).val() == 'Customer'){
					$('.bankdetailopt').hide();
				}
				else{
					$('.bankdetailopt').show();
				}
				if($(this).val() == 'Customer'){
					$('.control-balance-type-customer').show();
					$('.control-balance-type-vendor').hide();
				}
				else if($(this).val() == 'Vendor'){
					$('.control-balance-type-customer').hide();
					$('.control-balance-type-vendor').show();
				}
				else{
					$('.control-balance-type-customer').show();
					$('.control-balance-type-vendor').show();
				}
				
			}
		}).change();

		$('#CustomerModalForm input[name="companytype"]:checked ').trigger("click");

        $.validator.addMethod("customUrl", function(value, element) {
            // Allow URLs with {{LR No}} or similar placeholders
            return this.optional(element) || /^(http|https):\/\/[^\s$.?#].[^\s]*({{LR No}})?$/.test(value);
        }, "Please enter a valid tracking URL");

		$("#TransportModal form").validate({
			rules: {
				field: {
					required: true
				},
                customUrl: {
                    url: true,
                }
			},
			messages: {
				name: "Please enter your transport name",
                customUrl: {
                    url: "Please enter a valid tracking URL"
                }
			},
			submitHandler: function(form) {
				
				var data = $(form).serialize() + '&action=SubmitTransportModel';
				$.ajax({
					type: "POST",
					url: "ajaxcall.php",
					ContentType: 'application/json',
					dataType: 'json',
					data: data,
					success: function(data) {
						var currentURL = window.location.href;
							pageURL = currentURL.replace(/^.*[\\\/]/, '');
						if (pageURL == "list-transport.php" || pageURL.indexOf("list-transport.php") != -1) {
							var mode = data.redirect.split('?')[1].split('=');
							if(mode == 'insert'){
								window.location.href = data.redirect;
							}else{
								window.location.href = data.redirect+'&'+ $("#url_string").val();
							}
						}else {
							if (data.status == "OK") {
								$("#TransportModal form input").val('');
								availableTransports.push({
									value: data.value,
									label: data.label,
									vehicleno: data.vehicleno,
									transportID: data.transportID,
									name: data.name
								});
								$(".transport-combobox").val(data.label);
								$("#hidden-transport-id").val(data.value);
								$("#hidden-transport-name").val(data.name);
								$("#hidden-transport-transportID").val(data.transportID);
								$("#hidden-transport-vehicleno").val(data.vehicleno);

								$("#transport_id_label").val(data.transportID);
								$("#vehicle_no_label").val(data.vehicleno);
								$('#TransportModal').modal('toggle');
							} else if (data.status == "ERROR") {
								errorMessage(data.msg,'Error In Saving Detail','','error');
							}
							
						}
					},
					complete: function(data) {}
				});
			}
		});
		$("#ShippingModal form").validate({
			rules: {
				'ship_name[]': {
					required: true
				},
				'ship_state[]': {
					required: function(element) {
						return $("#ShippingModal .listBoxCountry1").val() == "India";
					}
				},
				'ship_address[]': {
					required: true
				},
				'ship_landmark[]': {
					required: true
				},
				'ship_city[]': {
					required: true
				},
				'ship_pincode[]': {
					required: true
				},
			},
			messages: {
				'ship_name[]': "Please enter your shipping name",
				'ship_state[]': "Please enter shipping state",
				'ship_address[]': "Please enter shipping address",
				'ship_landmark[]': "Please enter shipping landmark",
				'ship_city[]': "Please enter shipping city",
				'ship_pincode[]': "Please enter shipping pincode",
			},
			submitHandler: function(form) {
				var data = $(form).serialize() + '&action=SubmitShippingModel&customer='+$("#customers").val();
				$.ajax({
					type: "POST",
					url: "ajaxcall.php",
					ContentType: 'application/json',
					dataType: 'json',
					data: data,
					success: function(data) {
						if (data.status == "OK") {
							$("#customers").trigger('change');
							$("#ShippingModal form input").val('');
							$("#ShippingModal form textarea").val('');
							$('#ShippingModal').modal('toggle');
							if(data.shipurl != undefined){
								window.location.href = data.shipurl;
							}


						} else if (data.status == "ERROR") {
							errorMessage(data.msg,'Error In Saving Detail','','error');
						}
						
					},
					complete: function(data) {}
				});
			}
		});
		$('body').on('change', '#igst', function() {
			var igst = $(this).val();
			if (!isNaN(igst) && igst != "") {
				$(this).siblings('#cgst').val(igst / 2);
				$(this).siblings('#sgst').val(igst / 2);
			} else {
				$('#sgst').val("");
				$('#cgst').val("");
			}

		});
		$('body').on('change', '#gstval', function() {
			var gstval = $(this).val();
			
			if (!isNaN(gstval) && gstval != "") {
				
				$(this).siblings('#taxability').val('Taxable');
				$(this).siblings('#igst').val(gstval);
				$(this).siblings('#cgst').val(gstval / 2);
				$(this).siblings('#sgst').val(gstval / 2);
			} else {
				if(gstval ==  "Nil Rated" || gstval == "Exempt" || gstval == 'Non-GST'){
					$(this).siblings('#taxability').val(gstval);
					$(this).siblings('#igst').val('');
					$(this).siblings('#cgst').val('');
					$(this).siblings('#sgst').val('');
				}
			}

		});
		jQuery.validator.addMethod("tax_validate", function(value, element) {
			var tax_validate = true;
			var taxability = $('select[name=taxability]').val();
			var igst = $('#igst').val();
			var sgst = $('#sgst').val();
			var cgst = $('#cgst').val();
			if (taxability == "Taxable") {
				if ((igst == "" || igst == "0") || (sgst == "" || sgst == "0") || (cgst == "" || cgst == "0")) {
					tax_validate = false;
				}
			} else {
				if (!(igst == "" || igst == "0") || !(sgst == "" || sgst == "0") || !(cgst == "" || cgst == "0")) {
					tax_validate = false;
				}
			}
			return tax_validate;
		}, "Invalid product type for entered GST");

		jQuery.validator.addMethod("hsn_validate", function(value, element) {
			var hsn_validate = true;
			if(value != "" && jQuery.inArray(value, hsnCodes) === -1) 
			{
				hsn_validate = false;
			}
			return hsn_validate;
		}, "Invalid HSN/SAC code");
		
		jQuery.validator.addMethod("mrp_validate", function(value, element) {
			var mrp_validate = true;
			var require_product_mrp = 0;
			if(value == "" && require_product_mrp === 1) 
			{
				mrp_validate = false;
			}
			return mrp_validate;
		}, "Please Enter MRP");

		jQuery.validator.addMethod("product_code_validate", function(value, element) {
			var product_code_validate = true;
			var require_product_code = 0;
			if(value == "" && require_product_code === 1) 
			{
				product_code_validate = false;
			}
			return product_code_validate;
		}, "Please Enter Product Code");


		$("#ProductModal form").validate({
			rules: {
				field: {
					required: true
				},
				
				hsn: {
					hsn_validate: true
				},
				mrp: {
					mrp_validate: true
				},
				product_code: {
					product_code_validate: true
				},
				product_note: {
					maxlength: 1200
				}
			},
			messages: {
				name: "Please enter your product name",
				'batch_name[]': "Please enter batch no.",
				'quantity[]': "Please enter quantity",
				product_note: "Product description must be less than 1200 character."
			},
			submitHandler: function(form) {
				var data = $(form).serialize() + '&action=SubmitProductModel';
					
				var params = new URLSearchParams(data);
				var product_code = (params.has('product_code') ? params.get('product_code') : '');
				var product_id = (params.get('product_id'));

				checkProductCode(product_code,product_id, function(isAllowed) {
					if (isAllowed) {
				
					if (validateBatchRows()) {
				
					$.ajax({
						type: "POST",
						url: "ajaxcall.php",
						ContentType: 'application/json',
						dataType: 'json',
						data: data,
						success: function(data) {
							$("body").removeClass("is-loading");
							if (data.status == "OK") {

								var currentURL = window.location.href;
								pageURL = currentURL.replace(/^.*[\\\/]/, '');
								if (pageURL == "list-product.php" || pageURL.indexOf("list-product.php") != -1) {
									var mode = data.redirect.split('?')[1].split('=');
									if(mode == 'insert'){
										window.location.href = data.redirect;
									}else{
										window.location.href = data.redirect+'&'+ $("#url_string").val();
									}
								}else{



								$("#ProductModal form input[type='text']").val('');
								if (data.Attrib1New != "") {
									productVarient1.push(data.Attrib1New);
								}
								if (data.Attrib2New != "") {
									productVarient2.push(data.Attrib2New);
								}
								if (data.Attrib3New != "") {
									productVarient3.push(data.Attrib3New);
								}
								if (data.Attrib4New != "") {
									productVarient4.push(data.Attrib4New);
								}

								$("#ProductModal form input[name='hidden-attrib-1-val']").val('');
								$("#ProductModal form input[name='hidden-attrib-2-val']").val('');
								$("#ProductModal form input[name='hidden-attrib-3-val']").val('');
								$("#ProductModal form input[name='hidden-attrib-4-val']").val('');
								availableProducts.push({
									value: data.value,
									label: data.label,
									attr1name: data.attr1name,
									attr1val: data.attr1val,
									attr2name: data.attr2name,
									attr2val: data.attr2val,
									attr3name: data.attr3name,
									attr3val: data.attr3val,
									attr4name: data.attr4name,
									attr4val: data.attr4val,
									sellprice: data.sellprice,
									customerprice: data.sellprice,
									purchaseprice: data.purchaseprice,
									items_available: data.items_available,
									cgst: data.cgst,
									sgst: data.sgst,
									igst: data.igst,
									cess: data.cess,
									cess_amount: data.cess_amount,
									is_transport: '0',
									name: data.name,
									uom: data.uom,
									hsn: data.hsn,
									product_note: data.product_note,
									is_service_product: data.is_service_product,
									stockType: data.stockType,
									mrp: data.mrp,
									barcode_no: data.barcode_no,
									product_code: data.product_code

								});
								$('#ProductModal').modal('toggle');
								}
							} else if (data.status == "ERROR") {
								errorMessage(data.msg,'Error In Saving Detail','','error');
							}

						},
						complete: function(data) {}
					});
				
				}
			}
			});
		}
			
		});

		function checkProductCode(product_code,product_id, callback) {
			 product_code = ''; 			let lableProcode = 'Product Code';
					if(product_code!=""){		
						var data = {
							'product_code': product_code,
							'action': 'getProductCode',
							'product_id': product_id,
						};
					$.ajax({
						type: "POST",
						url: "ajaxcall.php",
						ContentType: 'application/json',
						dataType: 'json',
						data: data,
						success: function(data) {
							$("body").removeClass("is-loading");
							if (data.status == "OK") {
								Swal.fire({	
									title: lableProcode+ ' value already exists',
        							html: `This ${lableProcode} has already been used.<br> Do you want to save it with a duplicate value?`,
									icon: 'warning',
									showCancelButton: true,
									confirmButtonColor: '#3085d6',
									cancelButtonColor: '#d33',
									confirmButtonText: 'Continue',
									cancelButtonText: 'Cancel',
									customClass: {
										cancelButton: 'recodeCancel-btn'
									},
									reverseButtons: true
								}).then((result) => {
									if (result.isConfirmed) {
										callback(true);
									} 
								});
								
							} else {
								callback(true);

							}
						}
					})
				}
				else{
					callback(true);
				}
		}
		jQuery.validator.addMethod("transport_tax_validate", function(value, element) {
			var tax_validate = true;
			var taxability = $('#TransportChargeModal select[name=taxability]').val();
			var igst = $('#TransportChargeModal #igst').val();
			var sgst = $('#TransportChargeModal #sgst').val();
			var cgst = $('#TransportChargeModal #cgst').val();
			if (taxability == "Taxable") {
				if ((igst == "" || igst == "0") || (sgst == "" || sgst == "0") || (cgst == "" || cgst == "0")) {
					tax_validate = false;
				}
			} else {
				if (!(igst == "" || igst == "0") || !(sgst == "" || sgst == "0") || !(cgst == "" || cgst == "0")) {
					tax_validate = false;
				}
			}
			return tax_validate;
		}, "Invalid product type for entered GST");

		$("#TransportChargeModal form").validate({
			rules: {
				field: {
					required: true
				},
				product_note: {
					maxlength: 1200
				}
			},
			messages: {
				name: "Please enter additional charge name",
				product_note: "product description must be less than 1200 character."
			},
			submitHandler: function(form) {
				var data = $(form).serialize() + '&action=SubmitTransportChargeModel';
				$.ajax({
					type: "POST",
					url: "ajaxcall.php",
					ContentType: 'application/json',
					dataType: 'json',
					data: data,
					success: function(data) {
						if (data.status == "OK") {
							var currentURL = window.location.href;
							pageURL = currentURL.replace(/^.*[\\\/]/, '');
							if (pageURL == "list-transport-charges.php" || pageURL.indexOf("list-transport-charges.php") != -1) {
								var mode = data.redirect.split('?')[1].split('=');
								if(mode == 'insert'){
									window.location.href = data.redirect;
								}else{
									window.location.href = data.redirect+'&'+ $("#url_string").val();
								}
							}else{


							$("#TransportChargeModal form input[type='text']").val('');
							availableProducts.push({
								value: data.value,
								label: data.name,
								attr1name: "",
								attr1val: "",
								attr2name: "",
								attr2val: "",
								attr3name: "",
								attr3val: "",
								attr4name: "",
								attr4val: "",
								barcode_no: "",
								sellprice: data.sellprice,
								customerprice: data.sellprice,
								purchaseprice: "0.00",
								items_available: "0.00",
								cgst: data.cgst,
								sgst: data.sgst,
								igst: data.igst,
								cess: "",
								cess_amount: "",
								is_transport: "1",
								name: data.name,
								uom: "",
								hsn: data.hsn,
								is_service_product: data.is_service_product

							});
							$('#TransportChargeModal').modal('toggle');
							}
						} else if (data.status == "ERROR") {
							errorMessage(data.msg,'Error In Saving Detail','','error');
						}

					},
					complete: function(data) {}
				});
			}
		});

		$("#sellprice_incl_tax").on('keyup change blur', function() {
			var totaltax = 0;
			var sell = $("#sellprice").val();
			var sell_inc = $("#sellprice_incl_tax").val();
			var cgst = $("#cgst").val();
			var sgst = $("#sgst").val();
			var igst = $("#igst").val();
			var cess = $("#cess").val();
			var cess_amount = $("#cess_amount").val();
			if (sell_inc != "") {
				sell_inc = parseFloat(sell_inc);
				if (cess_amount != "") {
					cess_amount = parseFloat(cess_amount);
					sell_inc = sell_inc - cess_amount;
				}
				if (cgst != "" && sgst != "") {
					cgst = parseFloat(cgst);
					sgst = parseFloat(sgst);
					totaltax = totaltax + cgst + sgst;
				} else {
					if (igst != "") {
						igst = parseFloat(igst);
						totaltax = totaltax + igst;
					}
				}
				if (cess != "") {
					cess = parseFloat(cess);
					totaltax = totaltax + cess;
				}
				sell = (sell_inc * 100) / (100 + totaltax);
				sell = Math.round(sell * price_decimal_rounding) / price_decimal_rounding;
				$("#sellprice").val(sell);
			}

		});
		$("#sellprice,#cgst,#sgst,#igst,#cess").on('keyup change blur', function() {
			var totaltax = 0;
			var igstrate = 0;
			var cessrate = 0;
			var sell = $("#sellprice").val();
			var sell_inc = $("#sellprice_incl_tax").val();
			var cgst = $("#cgst").val();
			var sgst = $("#sgst").val();
			var igst = $("#igst").val();
			var cess = $("#cess").val();
			var cess_amount = $("#cess_amount").val();
			if (sell != "") {
				sell = parseFloat(sell);
				sell_inc = parseFloat(sell_inc);

				if (cgst != "" && sgst != "") {
					cgst = parseFloat(cgst);
					sgst = parseFloat(sgst);
					igstrate = (sell * (cgst + sgst)) / 100;
					igstrate = Math.round(igstrate * gst_decimal_rounding) / gst_decimal_rounding;
				} else {
					if (igst != "") {
						igstrate = (sell * igst) / 100;
						igstrate = Math.round(igstrate * gst_decimal_rounding) / gst_decimal_rounding;
					}
				}


				if (cess != "") {
					cessrate = (sell * cess) / 100;
					cessrate = Math.round(cessrate * gst_decimal_rounding) / gst_decimal_rounding;
				}
				sell_inc = sell + igstrate + cessrate;
				if (cess_amount != "") {
					cess_amount = parseFloat(cess_amount);
					sell_inc = sell_inc + cess_amount;
				}
				sell_inc = Math.round(sell_inc * price_decimal_rounding) / price_decimal_rounding;
				$("#sellprice_incl_tax").val(sell_inc);
			}

		});
		$("#purchaseprice_incl_tax").on('keyup change blur', function() {
			var totaltax = 0;
			var purc = $("#purchaseprice").val();
			var purc_inc = $("#purchaseprice_incl_tax").val();
			var cgst = $("#cgst").val();
			var sgst = $("#sgst").val();
			var igst = $("#igst").val();
			var cess = $("#cess").val();
			var cess_amount = $("#cess_amount").val();

			if (purc_inc != "") {
				purc_inc = parseFloat(purc_inc);
				if (cess_amount != "") {
					cess_amount = parseFloat(cess_amount);
					purc_inc = purc_inc - cess_amount;
				}
				if (cgst != "" && sgst != "") {
					cgst = parseFloat(cgst);
					sgst = parseFloat(sgst);
					totaltax = totaltax + cgst + sgst;
				} else {
					if (igst != "") {
						igst = parseFloat(igst);
						totaltax = totaltax + igst;
					}
				}
				if (cess != "") {
					cess = parseFloat(cess);
					totaltax = totaltax + cess;
				}
				purc = (purc_inc * 100) / (100 + totaltax);
				purc = Math.round(purc * price_decimal_rounding) / price_decimal_rounding;
				$("#purchaseprice").val(purc);
			}
		});
		$("#purchaseprice,#igst,#cess").on('keyup change blur', function() {
			var totaltax = 0;
			var igstrate = 0;
			var cessrate = 0;
			var purc = $("#purchaseprice").val();
			var purc_inc = $("#purchaseprice_incl_tax").val();
			var cgst = $("#cgst").val();
			var sgst = $("#sgst").val();
			var igst = $("#igst").val();
			var cess = $("#cess").val();
			var cess_amount = $("#cess_amount").val();
			if (purc != "") {
				purc = parseFloat(purc);
				if (cgst != "" && sgst != "") {
					cgst = parseFloat(cgst);
					sgst = parseFloat(sgst);
					igstrate = (purc * (cgst + sgst)) / 100;
					igstrate = Math.round(igstrate * gst_decimal_rounding) / gst_decimal_rounding;
				} else {
					if (igst != "") {
						igstrate = (purc * igst) / 100;
						igstrate = Math.round(igstrate * gst_decimal_rounding) / gst_decimal_rounding;
					}
				}
				if (cess != "") {
					cessrate = (purc * cess) / 100;
					cessrate = Math.round(cessrate * gst_decimal_rounding) / gst_decimal_rounding;
				}
				purc_inc = purc + igstrate + cessrate;
				if (cess_amount != "") {
					cess_amount = parseFloat(cess_amount);
					purc_inc = purc_inc + cess_amount;
				}
				purc_inc = Math.round(purc_inc * price_decimal_rounding) / price_decimal_rounding;
				$("#purchaseprice_incl_tax").val(purc_inc);
			}
		});



		$(document).on('keyup change blur',"[name='sellpriceincltax[]']", function() {
			var cgst = $("#cgst").val();
			var sgst = $("#sgst").val();
			var igst = $("#igst").val();
			var cess = $("#cess").val();
			var cess_amount = $("#cess_amount").val();
		
			$('#ProductModal table tr').each(function(i,val){
				var totaltax = 0;
				var sell = $(this).find("[name='price[]']").val();
				var sell_inc = $(this).find("[name='sellpriceincltax[]']").val();
				if (sell_inc != "" && sell_inc != undefined) {
					
					if((sell_inc.charAt(sell_inc.length -1) != '.'  && price_decimal_rounding_by > 0 && sell_inc.toString().indexOf('.') > -1)){
						sell_inc  = sell_inc.toString().substring(0, sell_inc.toString().indexOf('.') + 1 + price_decimal_rounding_by);
						$(this).find("[name='sellpriceincltax[]']").val(sell_inc);
						sell_inc = parseFloat(sell_inc);
					}else if(price_decimal_rounding_by == 0 && sell_inc.toString().indexOf('.') > -1 ){
						sell_inc  = sell_inc.toString().substring(0, sell_inc.toString().indexOf('.') + 1 + price_decimal_rounding_by);
						$(this).find("[name='sellpriceincltax[]']").val(sell_inc);
					}else{
						sell_inc = parseFloat(sell_inc);
					}
					

					if (cess_amount != "") {
						cess_amount = parseFloat(cess_amount);
						sell_inc = sell_inc - cess_amount;
					}
					if (cgst != "" && sgst != "") {
						cgst = parseFloat(cgst);
						sgst = parseFloat(sgst);
						totaltax = totaltax + cgst + sgst;
					} else {
						if (igst != "") {
							igst = parseFloat(igst);
							totaltax = totaltax + igst;
						}
					}
					if (cess != "") {
						cess = parseFloat(cess);
						totaltax = totaltax + cess;
					}
					sell = (sell_inc * 100) / (100 + totaltax);
					sell = Math.round(sell * price_decimal_rounding) / price_decimal_rounding;
					sell = sell.toFixed(price_decimal_value);
					$(this).find("[name='price[]']").val(sell);
				}
	   		});

			

		});


		$(document).on('keyup change blur',"[name='price[]'],#cgst,#sgst,#igst,#cess", function() {
			var cgst = $("#cgst").val();
			var sgst = $("#sgst").val();
			var igst = $("#igst").val();
			var cess = $("#cess").val();
			var cess_amount = $("#cess_amount").val();
			$('#ProductModal table tr').each(function(i,val){
				var totaltax = 0;
				var igstrate = 0;
				var cessrate = 0;
				var sell = $(this).find("[name='price[]']").val();
				var sell_inc = $(this).find("[name='sellpriceincltax[]']").val();
				if (sell != "" && sell != undefined) {
					if((sell.charAt(sell.length -1) != '.'  && price_decimal_rounding_by > 0 && sell.toString().indexOf('.') > -1)){
						sell  = sell.toString().substring(0, sell.toString().indexOf('.') + 1 + price_decimal_rounding_by);
						$(this).find("[name='price[]']").val(sell);
						sell = parseFloat(sell);
					}else if(price_decimal_rounding_by == 0 && sell.toString().indexOf('.') > -1 ){
						sell  = sell.toString().substring(0, sell.toString().indexOf('.') + 1 + price_decimal_rounding_by);
						$(this).find("[name='price[]']").val(sell);
					}else{
						sell = parseFloat(sell);
					}
					sell_inc = parseFloat(sell_inc);

					if (cgst != "" && sgst != "") {
						cgst = parseFloat(cgst);
						sgst = parseFloat(sgst);
						igstrate = (sell * (cgst + sgst)) / 100;
						igstrate = Math.round(igstrate * gst_decimal_rounding) / gst_decimal_rounding;
					} else {
						if (igst != "") {
							igstrate = (sell * igst) / 100;
							igstrate = Math.round(igstrate * gst_decimal_rounding) / gst_decimal_rounding;
						}
					}


					if (cess != "") {
						cessrate = (sell * cess) / 100;
						cessrate = Math.round(cessrate * gst_decimal_rounding) / gst_decimal_rounding;
					}
					sell_inc = sell + igstrate + cessrate;
					if (cess_amount != "") {
						cess_amount = parseFloat(cess_amount);
						sell_inc = sell_inc + cess_amount;
					}
					sell_inc = Math.round(sell_inc * price_decimal_rounding) / price_decimal_rounding;
					$(this).find("[name='sellpriceincltax[]']").val(sell_inc);
				}
			});

		});

		$(document).on('keyup change blur',"[name='purchasepriceincltax[]']", function() {
			var totaltax = 0;
			var cgst = $("#cgst").val();
			var sgst = $("#sgst").val();
			var igst = $("#igst").val();
			var cess = $("#cess").val();
			var cess_amount = $("#cess_amount").val();

			$('#ProductModal table tr').each(function(i,val){
				var totaltax = 0;
				var totaltax = 0;
				var purc = $(this).find("[name='purchase_price[]']").val();
				var purc_inc = $(this).find("[name='purchasepriceincltax[]']").val();
				
				if (purc_inc != "" && purc_inc != undefined) {
					if((purc_inc.charAt(purc_inc.length -1) != '.'  && price_decimal_rounding_by > 0 && purc_inc.toString().indexOf('.') > -1)){
						purc_inc  = purc_inc.toString().substring(0, purc_inc.toString().indexOf('.') + 1 + price_decimal_rounding_by);
						$(this).find("[name='purchasepriceincltax[]']").val(purc_inc);
						purc_inc = parseFloat(purc_inc);
					}else if(price_decimal_rounding_by == 0 && purc_inc.toString().indexOf('.') > -1 ){
						purc_inc  = purc_inc.toString().substring(0, purc_inc.toString().indexOf('.') + 1 + price_decimal_rounding_by);
						$(this).find("[name='purchasepriceincltax[]']").val(purc_inc);
					}else{
						purc_inc = parseFloat(purc_inc);
					}
					if (cess_amount != "") {
						cess_amount = parseFloat(cess_amount);
						purc_inc = purc_inc - cess_amount;
					}
					if (cgst != "" && sgst != "") {
						cgst = parseFloat(cgst);
						sgst = parseFloat(sgst);
						totaltax = totaltax + cgst + sgst;
					} else {
						if (igst != "") {
							igst = parseFloat(igst);
							totaltax = totaltax + igst;
						}
					}
					if (cess != "") {
						cess = parseFloat(cess);
						totaltax = totaltax + cess;
					}
					purc = (purc_inc * 100) / (100 + totaltax);
					purc = Math.round(purc * price_decimal_rounding) / price_decimal_rounding;
					$(this).find("[name='purchase_price[]']").val(purc);
				}
			});
		});

		$(document).on('keyup change blur',"[name='purchase_price[]'],#igst,#cess", function() {
			var cgst = $("#cgst").val();
			var sgst = $("#sgst").val();
			var igst = $("#igst").val();
			var cess = $("#cess").val();
			var cess_amount = $("#cess_amount").val();
			$('#ProductModal table tr').each(function(i,val){
				var totaltax = 0;
				var igstrate = 0;
				var cessrate = 0;
				var purc = $(this).find("[name='purchase_price[]']").val();
				var purc_inc = $(this).find("[name='purchasepriceincltax[]']").val();
				if (purc != "" && purc != undefined) {

					if((purc.charAt(purc.length -1) != '.'  && price_decimal_rounding_by > 0 && purc.toString().indexOf('.') > -1)){
						purc  = purc.toString().substring(0, purc.toString().indexOf('.') + 1 + price_decimal_rounding_by);
						$(this).find("[name='purchase_price[]']").val(purc);
						purc = parseFloat(purc);
					}else if(price_decimal_rounding_by == 0 && purc.toString().indexOf('.') > -1 ){
						purc  = purc.toString().substring(0, purc.toString().indexOf('.') + 1 + price_decimal_rounding_by);
						$(this).find("[name='purchase_price[]']").val(purc);
					}else{
						purc = parseFloat(purc);
					}
					if (cgst != "" && sgst != "") {
						cgst = parseFloat(cgst);
						sgst = parseFloat(sgst);
						igstrate = (purc * (cgst + sgst)) / 100;
						igstrate = Math.round(igstrate * gst_decimal_rounding) / gst_decimal_rounding;
					} else {
						if (igst != "") {
							igstrate = (purc * igst) / 100;
							igstrate = Math.round(igstrate * gst_decimal_rounding) / gst_decimal_rounding;
						}
					}
					if (cess != "") {
						cessrate = (purc * cess) / 100;
						cessrate = Math.round(cessrate * gst_decimal_rounding) / gst_decimal_rounding;
					}
					purc_inc = purc + igstrate + cessrate;
					if (cess_amount != "") {
						cess_amount = parseFloat(cess_amount);
						purc_inc = purc_inc + cess_amount;
					}
					purc_inc = Math.round(purc_inc * price_decimal_rounding) / price_decimal_rounding;
					$(this).find("[name='purchasepriceincltax[]']").val(purc_inc);
				}
			});
		});






		$(document).on('click', ".transportgstdata_autofill", function() {
			var gstno = $("#TransportModal #transportid").val();
			var regex = /^\d{2}/;
			if (gstno.substr(0, 2) !== "88") {
			if (gstno.length == 15 && regex.test(gstno)) {
				var data = {
					action: 'gstapicall',
					gstno: gstno,
					fromgstno: '',
					userid: '10594'				}
				$.ajax({
					type: 'POST',
					data: data,
					url: "ajaxcall.php",
					ContentType: 'application/json',
					dataType: 'json',
					beforeSend: function() {
						$("body").addClass("is-loading");
					},
					success: function(data) {
						if (data.status == 'OK') {
							var gstno = data.gstno.substr(0, 2);
							var data = data.gstapicall_data;
							if (jQuery.isEmptyObject(data)) {
								if ($("#TransportModal #gstno-error").length == 0) {
									$('#TransportModal #transportid').after('<label id="gstno-error" class="error" for="gstno">Invalid Transport ID/GSTIN.</label>');
								} else {
									$('#TransportModal #gstno-error').html('Invalid Transport ID/GSTIN.');
								}

							} else {
								$('#TransportModal #gstno-error').remove();
								arr = JSON.parse(JSON.stringify(data));
								$("#TransportModal #name").val(arr.cmpname);
							}

						} else {
							if(data.errorTitle)
							{
								var errTitle = data.errorTitle;
							}
							else{
								var errTitle = 'Error';
							}
							errorMessage('',errTitle,data.data,'error');
							$("body").removeClass("is-loading");
						}
					},
					complete: function() {

					}
				});
			} else {
				if ($("#TransportModal #gstno-error").length == 0) {
					$('#TransportModal #transportid').after('<label id="gstno-error" class="error" for="gstno">Invalid Transport ID/GSTIN.</label>');
				} else {
					$('#TransportModal #gstno-error').html('Invalid Transport ID/GSTIN.');
				}
				$('#TransportModal #gstno-error').show();
			}
		}else{
			Swal.fire({
				icon: 'warning',
				title: `Unable to fetch details for this GSTIN, please enter the details manually.`,
				confirmButtonColor: '#1399dc',
			});
		}
		});

		$(document).on('click', ".gstdata_autofill", function() {
			$('#gstno-error').text('');
			var gstfor = $(this).data('gstfor');
			if (gstfor != '' && gstfor == 'shipping') {
				var shipping_address_reapiter = $(this).closest('.shipping_address_reapiter');
				var gstno = $(this).closest('.shipping_address_reapiter').find(".ship_gstno").val();
				var pan = $(this).closest('.shipping_address_reapiter').find(".ship_gstno").val();
			} else {
				var gstno = $("#gstno").val();
				var pan = $("#gstno").val();
			}


			pan = pan.substring(2, 12);
			var regex = /^\d{2}/;
			if (gstno.length == 15 && regex.test(gstno)) {
				var data = {
					action: 'gstapicall',
					gstno: gstno,
					fromgstno: '',
					userid: '10594'				}
				$.ajax({
					type: 'POST',
					data: data,
					url: "ajaxcall.php",
					ContentType: 'application/json',
					dataType: 'json',
					beforeSend: function() {
						$("body").addClass("is-loading");
						$("#progressbar").css({"width":0 +"%","background-color": "#f7f7f7" ,"font-weight": "bold"});
						$("#progressbar").text("");
						$("#cmp_reputation").val("");
					},
					success: function(data) {
						if (data.status == 'OK') {
							var cmpExist = data.cmpExist;
							var gstno = data.gstno.substr(0, 2);
							var data = data.gstapicall_data;
							if (jQuery.isEmptyObject(data)) {
								if ($("#gstno-error").length == 0) {
									$('#gstno').after('<label id="gstno-error" class="error" for="gstno">Invalid GSTIN.</label>');
								} else {
									$('#gstno-error').html('Invalid GSTIN.');
								}

							} else {
								arr = JSON.parse(JSON.stringify(data));
								if (gstfor != '' && gstfor == 'shipping') {
									shipping_address_reapiter.find(".ship_name").val(arr.cmpname);
									shipping_address_reapiter.find(".ship_address").val(arr.address1 + '\r\n' + arr.address2);
									shipping_address_reapiter.find(".ship_pincode").val(arr.pincode);
									shipping_address_reapiter.find(".ship_landmark").val(arr.landmark);
									shipping_address_reapiter.find(".ship_city").val(arr.city);
									shipping_address_reapiter.find(".all_state_list option[data-statecode='"+ gstno +"']").attr("selected", true);
								} else {
									$("#companyname").val(arr.cmpname);
									$("#address1").val(arr.address1);
									$("#address2").val(arr.address2);
									$("input[name='landmark']").val(arr.landmark);
									$("#city").val(arr.city);
									$("#contactperson").val(arr.name);
									$("#pincode").val(arr.pincode);
									$("#listBox option").attr("selected", false);
									$("#listBox option[data-statecode='"+ gstno +"']").attr("selected", true);
									$("#pan").val(pan);
									if(cmpExist != ""){
										$("#alredyExist").html("");
										$("#alredyExist").closest(".control-group").show();
										cmpExist.map(function(cmp) {
											var html = "";
											html = `<div class='span6 span-md-6 span-xs-12 span-sm-6 equal-height' style="padding:2px"><div class="getRow ">
														<h4>${cmp.companyname}</h4>
														<p>${cmp.gstno}</p>
														<p>${cmp.address}</p>
														<span class='label'>${cmp.companytype}</span>
													</div></div>`;
											$("#alredyExist").append(html);
										});
										equalheight('.equal-height');
									}else{
										$("#alredyExist").html("");
										$("#alredyExist").closest(".control-group").hide();
									}
																	}
							}

						} else {
							if(data.errorTitle)
							{
								var errTitle = data.errorTitle;
							}
							else{
								var errTitle = 'Error';
							}
							errorMessage('',errTitle,data.data,'error');
							$("body").removeClass("is-loading");
						}
					},
					complete: function() {

					}
				});
			} else {
				if ($("#gstno-error").length == 0) {
					$('#gstno').after('<label id="gstno-error" class="error" for="gstno">Invalid GSTIN.</label>');
				} else {
					$('#gstno-error').html('Invalid GSTIN.');
				}
				$('#gstno-error').show();
			}
		});

		$(document).on("click", ".distance_autofill", function(e) {
			var org_state = $("#org_state").val();
			var org_pincode = $("#org_pincode").val();
			var current_ele = $(this);
			if (current_ele.attr('distance_for') == "shipping") {
				var pincode = current_ele.closest('.shipping_address_reapiter').find('input[name="ship_pincode[]"]').val();
				var state = current_ele.closest('.shipping_address_reapiter').find('select[name="ship_state[]"]').val();
				var listBoxCountry = current_ele.closest('.shipping_address_reapiter').find('select[name="ship_country[]"]').val();
			} else {
				var pincode = $("#pincode").val();
				var state = $("select[name='state']").val();
				var listBoxCountry = $("#listBoxCountry").val();
			}
			if (pincode.length > 0 && state.length > 0 && listBoxCountry.length > 0 && listBoxCountry == "India") {
				var data = {
					action: 'dist_apicall',
					from: org_pincode,
					to: pincode,
					tocookie: org_pincode + pincode + state,
					userid: '10594'				}
				$.ajax({
					type: 'POST',
					data: data,
					url: "ajaxcall.php",
					ContentType: 'application/json',
					dataType: 'json',
					beforeSend: function() {
						$("body").addClass("is-loading");
					},
					success: function(data) {
						if (data.status == 'OK') {
							if (current_ele.attr('distance_for') == "shipping") {
								current_ele.closest('.shipping_address_reapiter').find('.shipping_distance_eway').val(data.dist_apicall);
								$('.dist-error').hide();
							} else {
								$("#distance_eway").val(data.dist_apicall);
								$('#dist-error').hide();
							}
						} else {
							if(data.errorTitle)
							{
								var errTitle = data.errorTitle;
							}
							else{
								var errTitle = 'Error';
							}
							errorMessage('',errTitle,data.data,'error');
							$("body").removeClass("is-loading");
						}
					},
					complete: function() {

					}
				});
			} else {
				if (listBoxCountry != "India") {
					if (current_ele.attr('distance_for') == "shipping") {
						if (current_ele.closest('.shipping_address_reapiter').find(".dist-error").length == 0) {
							current_ele.after('<label class="dist-error error">Country must be india to calculate Distance for e-way bill.</label>');
						} else {
							current_ele.closest('.shipping_address_reapiter').find(".dist-error").html('Country must be india to calculate Distance for e-way bill.');
						}
					} else {
						if ($("#dist-error").length == 0) {
							$('#distance_eway').after('<label id="dist-error" class="error" for="gstno">Country must be india to calculate Distance for e-way bill.</label>');
						} else {
							$('#dist-error').html('Country must be india to calculate Distance for e-way bill.');
						}
					}
				} else {
					if (current_ele.attr('distance_for') == "shipping") {
						if (current_ele.closest('.shipping_address_reapiter').find(".dist-error").length == 0) {
							current_ele.after('<label class="dist-error error">Pincode, state and country required.</label>');
						} else {
							current_ele.closest('.shipping_address_reapiter').find(".dist-error").html('Pincode, state and country required.');
						}
					} else {
						if ($("#dist-error").length == 0) {
							$('#distance_eway').after('<label id="dist-error" class="error" for="gstno">Pincode, state and country required.</label>');
						} else {
							$('#dist-error').html('Pincode, state and country required.');
						}
					}
				}
				$('#dist-error').show();

			}
		});

		// Initialize form validation
		$('#bom_Modalform').validate({
			rules: {
				field: {
					required: true
				},
				ignore: ':hidden, [readonly=readonly],[readonly],[readonly=true]',
			},
			messages: {},
			submitHandler: function(form,event) {
				event.preventDefault();
				var isValid = validatebomRowsForSubmit();
				const formData = $(form).serialize();
				
				var bom_product_name = $('.bom-section').find(".product_name").val();
				var product_id = parseFloat($('.bom-section').find('.product_id').val());
				var mode = $('.bom-section').find(".modalmode").val();
				if(isValid){
					$.ajax({
						type: "POST",
						url: "ajaxcall.php",
						ContentType: 'application/json',
						dataType: 'json',
						data: formData + '&action=submit_manufacture',
						success: function(data) {
							if (data.status === 'OK') {
								$("body").removeClass("is-loading");
								$('#addbom_modal').modal('toggle');
								var path = window.location.pathname;
								var pageName = path.split("/").pop();
								if(pageName == "manufacture-product.php")
								{
									location.reload();		
								}else{
									Toast.fire({
										icon: 'success',
										title: 'Raw Material '+mode+' for '+bom_product_name
									});
									if(mode != "Updated")
									{
										$(".addbom_modal[data-id="+product_id+"]").closest("li").append('<a class="manufacture_product" target="_blank" href="manufacture-product.php?product_id='+ product_id +'">Manufacture Product</a>');
									}
									$(".addbom_modal[data-id="+product_id+"]").text("Edit Raw Material");
									$(".addbom_modal[data-id="+product_id+"]").data("mode", "Updated");
									
									
									
								}
								
							} else {
								const errTitle = data.errorTitle || 'Error In Saving Raw Material';
								const errMsg = data.data || data.msg;
								errorMessage(errMsg, errTitle, '', 'error');
							}
						},
						complete: function() {}
					});
				}
			}
		});
});


var addmorenormal = `<tr>
						<input type="hidden" name="product_batch_id[]">
						<td><input type="text" name="quantity[]"></td>
						<input type="hidden" name="mrp[]">						<td><input type="text" name="price[]" class="sellprice"></td>
						<td><input type="text" name="sellpriceincltax[]" class="sellpriceincltax"></td>
						<td><input type="text" name="purchase_price[]"></td>
						<td><input type="text" name="purchasepriceincltax[]"></td>
						<td>
							<div class="addmore-section">
								<a class="btn btn-primary addNormal btnaddmoreoption"><svg width="20" height="20"><use href="svg-icon/icons.svg#plus-svg-icon"></use></svg></a>
								<a class="btn btn-danger removeNormal btnaddmoreoption"><svg width="20" height="20"><use href="svg-icon/icons.svg#minus-svg-icon"></use></svg></a>
							</div>
						</td>
					</tr>`;

var addmorebatch = `<tr>
					<td>
						<div class="inputlabel_wrapper">
							<input type="text" name="batch_name[]" placeholder="Batch No." autocomplete="off" maxlength="20">
							<input type="hidden" name="product_batch_id[]">
														<input type="hidden" name="model_no[]"> 							<input type="hidden" name="size[]"> 							<input type="hidden" name="manufacture_date[]"> 							<input type="hidden" name="expiry_date[]"> 							<input type="hidden" name="mrp[]"> 							<label for="batch_name[]">Batch No.</label>
						</div></td>																				 					 	<td class="batchQty">
							<div class="inputlabel_wrapper">
								<input type="text" name="quantity[]" placeholder="Qty" onkeypress="return allowOnlyNumber(event);" maxlength="10">
								<label for="quantity[]">Qty.</label>
							</div>
						</td>
															<td>
						<div class="inputlabel_wrapper">
							<input type="text" name="price[]" autocomplete="off" placeholder="Sale Price" class="sellprice" onkeypress="return allowOnlyNumber(event);" maxlength="10">
							<label for="price[]">Sale Price</label>
						</div>
					</td>
					<td>
						<div class="inputlabel_wrapper">
							<input type="text" name="sellpriceincltax[]" autocomplete="off"  placeholder="Sale Price (Incl. Tax)" class="sellpriceincltax" onkeypress="return allowOnlyNumber(event);" maxlength="10">
							<label for="sellpriceincltax[]">Sale Price (Incl. Tax)</label>
						</div>
					</td>
					<td>
						<div class="inputlabel_wrapper">
							<input type="text" name="purchase_price[]" autocomplete="off"  placeholder="Purchase Price" onkeypress="return allowOnlyNumber(event);" maxlength="10">
							<label for="purchase_price[]">Purchase Price</label>
						</div>
					</td>
					<td>
						<div class="inputlabel_wrapper">
							<input type="text" name="purchasepriceincltax[]" autocomplete="off"  placeholder="Purchase Price (Incl. Tax)" onkeypress="return allowOnlyNumber(event);" maxlength="10">
							<label for="purchasepriceincltax[]">Purchase Price (Incl. Tax)</label>
						</div>
					</td>
					<td>
						<div class="addmore-section">
							<a class="btn btn-primary addBatch btnaddmoreoption"><svg width="20" height="20"><use href="svg-icon/icons.svg#plus-svg-icon"></use></svg></a>
							<a class="btn btn-danger removeBatch btnaddmoreoption"><svg width="20" height="20"><use href="svg-icon/icons.svg#minus-svg-icon"></use></svg></a>
						</div>
					</td>
					
				</tr>`;
					
var addmoreserial = `<div class="controls">
										<input type="text" class="mergeserialno" name="serialno[]" placeholder="Enter Serial No." style="width: 95%;" onkeypress="return allowOnlyNumber(event);">
										<div class="addmore-section" style="margin-left: 5px;">
											<a class="btn btn-primary addSerialNo btnaddmoreoptionserial"><svg width="20" height="20"><use href="svg-icon/icons.svg#plus-svg-icon"></use></svg></a>
											<a class="btn btn-danger removeSerialNo btnaddmoreoptionserial" style="display: none;"><svg width="20" height="20"><use href="svg-icon/icons.svg#minus-svg-icon"></use></svg></a>
										</div>
									</div>
								</div>`;
function bomrowhtml(type,rowarr = {}){
	 const defaults = {
			name: '',
			raw_stock_type: '',
			product_detail_id: '',
			is_transport: '',
			product_batch_id: '',
			batch_name: '',
			raw_uom: '',
			raw_uom_rates: '',
			serialno: '',
			quantity: '',
			purchaseprice: '',
			estimated_cost: '',
			product_type: (type == 'raw')?'1':'2',
		};
	const data = { ...defaults, ...rowarr };
		data.quantity = isNaN(parseFloat(data.quantity)) ? '' : parseFloat(data.quantity).toFixed(quantity_decimal_rounding_by);
		data.purchaseprice = isNaN(parseFloat(data.purchaseprice)) ? '' : parseFloat(data.purchaseprice).toFixed(price_decimal_rounding_by);
		data.estimated_cost = isNaN(parseFloat(data.estimated_cost)) ? '' : parseFloat(data.estimated_cost).toFixed(price_decimal_rounding_by);
	var productType = data.product_type ?? "1"; 
	var addmorebom = `<tr class="bom-row">
						<td>
							<div class="inputlabel_wrapper">
								<input type="text" name="product_name[]" id="bom-raw_product" class="bom-raw_product" placeholder="Product name" value="${data.name}" data-oldval="${data.name}" autocomplete="off">
								<input type="hidden" name="product_detail_id[]" class="bom-raw_product_id" value="${data.product_detail_id}">
								<input type="hidden" name="product_type[]" class="raw-product_type" value="${productType}">
								<label for="product_name[]"></label>
							<div> 
						</td>
							<td>
								<div class="inputlabel_wrapper">
									<input type="text" name="quantity[]" class="bom-raw_qty" placeholder="Quantity" autocomplete="off"  maxlength="20" value="${data.quantity}">
									<label for="quantity[]"></label>
								<div>
						</td>
							<td>
								<div class="inputlabel_wrapper">
									<input type="text" name="product_uom[]" placeholder="UOM" id="bom-raw_uom" class="bom-raw_uom" autocomplete="off"  maxlength="20" disabled="true" value="${data.raw_uom}" data-oldval="${data.raw_uom}">
									<input type="hidden" name="hidden_product_uom[]" class="hidden-bom-raw_uom" value="${data.raw_uom}">
									<input type="hidden" name="hidden-bom-product-uom-rates[]" class="hidden-bom-product-uom-rates" value="${data.raw_uom_rates}">
									<label for="product_uom[]"></label>
								<div>
						</td>
							<td>
								<div class="inputlabel_wrapper">
									<input type="text" name="pur_price[]" placeholder="Purchase Price" id="bom-raw_pur_price" class="bom-raw_pur_price" autocomplete="off"  maxlength="20" value="${data.purchaseprice}">
									<label for="pur_price[]"></label>
								<div>
						</td>
							<td>
								<div class="inputlabel_wrapper">
									<input type="text" name="estimated_cost[]" placeholder="Estimated Cost" class="bom-raw_estimated_cost" autocomplete="off"  maxlength="20" value="${data.estimated_cost}">
									<label for="estimated_cost[]"></label>
								<div>
						</td>
						<td>
							<div class="addmore-section">
								<a class="btn btn-primary addbom btnaddmoreoption"><i class="fa fa-plus"></i></a>
								<a class="btn btn-danger removebom btnaddmoreoption"><i class="fa fa-minus"></i></a>
							</div>
						</td>
					</tr>`;
	return addmorebom;
}


$(document).on('click','.addProduct',function(){
    
	autoSecondUOMListModal = autoUOMListModal;
	$("#ProductModal .product_id").remove();
	$('#ProductModal .modal-title').text('Add Products / Services');
	$("#ProductModal .product_category_id").remove();
	$('#ProductModal .categoryOpt').css('display','none');
	$('#ProductModalForm')[0].reset();
	getListCategory();
	$("#ProductModal .product_group_id").val('');
	if($('#ProductModal .stockOption').hasClass('hidestock'))
	{
		$('#ProductModal .stockOption').hide();
	}
	else
	{
		$('#ProductModal .stockOption').show();
	}
	$('#ProductModal .normal-section').show();
	$('#ProductModal [name="itemType"][value="Product"]').click();
	$('#ProductModal [name="stockType"][value="Normal"]').click();
	$('#ProductModal #tagInputs').tagsinput('removeAll');
	$('#ProductModal .bootstrap-tagsinput input').attr('maxlength','30');
	$("#ProductModal .oldstockType").val('');
	$("#ProductModal .totalStock").val('');
	$("#ProductModal .uom-conversion-section").html('');
	$("#ProductModal .uom-conversion-section").hide();
	$('#ProductModal').modal('show');
    });

$(document).on('click','.addProductCategory',function(){
	$('#catename-error').remove();
	if($('.categoryOpt').css('display') == 'none'){
		$('.categoryOpt').slideDown();
	}else{
		$('.categoryOpt').slideUp();
	}
});

$(document).on('click','.catesave',function(){
	$('#catename-error').remove();
	var catename = $('.categoryname').val();
	var cathmac = $('#cathmac').val();
	if(catename == ''){
		$('.categoryname').after(`<label id="catename-error" class="error">Please enter your product group name</label>`);
	}else{
		var data = {category_name:catename,hmac:cathmac,is_active:'on',action:'SubmitCategoryModel'};
		$.ajax({
			type: "POST",
			url: "ajaxcall.php",
			ContentType: 'application/json',
			dataType: 'json',
			data: data,
			success: function(data) {
				if (data.status == 'OK') {
					$("body").removeClass("is-loading");
					$('.categoryname').val('');
					$('.categoryOpt').slideUp();
					availableCategory.push({
						value: data.cateid,
						name: data.catename,
					});
					addCateArr.push(data.cateid);
					getListCategory(addCateArr);
				}else{
					if(data.errorTitle)
					{
						var errTitle = data.errorTitle;
						var errMsg = data.data;
					}
					else{
						var errTitle = 'Error In Saving Product Group';
						var errMsg = data.msg;
					}
					errorMessage(errMsg,errTitle,'','error');
				}
				
			},
			complete: function(data) {}
		});
	}
});

	
$(document).ready(function() {
	$("#ProductCategoryModal form").validate({
		rules: {
			field: {
				required: true
			},
		},
		messages: {
			category_name: "Please enter product group name",
		},
		submitHandler: function(form) {
			var data = $(form).serialize() + '&action=SubmitCategoryModel';
			$.ajax({
				type: "POST",
				url: "ajaxcall.php",
				ContentType: 'application/json',
				dataType: 'json',
				data: data,
				success: function(data) {
					if (data.status == 'OK') {
						$('#ProductCategoryModal').modal('toggle');
						var currentURL = window.location.href;
						pageURL = currentURL.replace(/^.*[\\\/]/, '');
						if (pageURL == "list-category.php" || pageURL.indexOf("list-category.php") != -1) {
							var mode = data.redirect.split('?')[1].split('=');
							if(mode == 'insert'){
								window.location.href = data.redirect;
							}else{
								window.location.href = data.redirect+'&'+ $("#url_string").val();
							}

						} else {
							$("body").removeClass("is-loading");
							availableCategory.push({
								value: data.cateid,
								name: data.catename
							});
							getListCategory(data.cateid);
						}
					}
					if (data.status == "ERROR") {
						errorMessage(data.msg,'Error In Saving Detail','','error');
					}
				},
				complete: function(data) {}
			});
		}
	});
	if($(window).width() < 768){
		 $('#ProductModal').on('shown.bs.modal', function() {
			$(this).find('.modal-body').on('scroll', function() {
				$('#ProductModal .product_group_id').select2('close');
			});
		});
	}
});


	function enterpressFunction(presskey){
		if (presskey === 13) {
			event.preventDefault();
	        $("#ProductModal .catesave").click();
	    }
	}

	function getListCategory(sel=''){

	   		var data = [];
	   		$.each(availableCategory,function(i,val){
	   				data.push({id:val.value, text:val.name});
	   		});
			$('#ProductModal .product_group_id').select2({
				data: data,
				dropdownParent: $('#ProductModal .product_group_id').parent()
			}).val(null).trigger("change"); 
			if(Array.isArray(sel))
	   		{
	   			try {
	  				$('#ProductModal .product_group_id').select2('destroy');
				}
				catch(err) {}

				$.each(sel, function(i,e){
	    			$("#ProductModal .product_group_id option[value='" + e + "']").attr("selected", "selected");
				});
				$('#ProductModal .product_group_id').select2({
					dropdownParent: $('#ProductModal .product_group_id').parent()
				});

				let productGroup = []
				$.each(data,function(i,val){
	   				if(sel.includes(val.id))
					{
						productGroup.push(val.text)
					}
					try {
						$('#ProdcutViewModal .prodcutgroup').text(productGroup.join())
					}
					catch(err) {}
					
	   			});
			}
	    }

	var membertype = 'basic';
	$(document).on('click','[name=stockType]',function(){ 
		$('#ProductModal .stockchangenote').remove();
		if($(this).val() == 'Batch'){
			$('#ProductModal .batchQty').show();
			if(membertype != "premium"){
				$('#ProductModal').modal('hide');
				$('#addRemoveModal').modal('show');

			}else{
				$('#ProductModal .changeStockName').text('Batch Stock');
				$('#ProductModal .normal-section').hide();
				$('#ProductModal .serialno-section').hide();
				$('#ProductModal .serialno-section [name="serialno[]"]').val('');
				$('#ProductModal .batchOpt table tbody').html(addmorebatch);
				$('.stockOption ').hide();
				$('#product_lsa_batch').attr('name', 'product_lsa');
				$('#product_lsa').attr('name', 'disabled_product_lsa');
				if($('.oldstockType').val() != $(this).val()){
					$('.batch-section').show();
					monthYearDatepicker();
					dayWiseDatepicker();
					addMoreButtonFn('Batch');	
				}

			}

		}else if($(this).val() == 'Serial'){
			if(membertype != "premium"){
				$('#ProductModal').modal('hide');
				$('#addRemoveModal').modal('show');
			}else{
				$('#ProductModal .changeStockName').text('Serial No.');
				$('.batch-section').hide();
				$('.stockOption ').hide();
				$('#product_lsa_batch').attr('name', 'disabled_product_lsa');
				$('#product_lsa').attr('name', 'product_lsa');
				$('#ProductModal .normal-section').show();
				if($('.oldstockType').val() != $(this).val()){
					$('#ProductModal .serialno-section').show();
					addMoreButtonFn('Serial');
				}
			}
			$('#ProductModal .uom-conversion-section').hide();
		}else{
			$('#ProductModal .changeStockName').text('Normal Stock');
			$('#ProductModal .batchOpt table tbody').html('');
			$('#ProductModal .normal-section').show();
			$('#ProductModal .serialno-section').hide();
			$('#ProductModal .serialno-section [name="serialno[]"]').val('');
			$('#product_lsa_batch').attr('name', 'disabled_product_lsa');
			$('#product_lsa').attr('name', 'product_lsa');
			$('.stockOption').show();
			$('.batch-section').hide();
		}
		var quantity_decimal_rounding_by = 2;
		if($("#ProductModal [name='product_id']").val() != '' && $("#ProductModal [name='product_id']").val() != undefined){
			$('.stockOption').hide();
            if(($(this).val() == 'Normal' || $(this).val() == 'Batch') && $('.oldstockType').val() == 'Serial'){
                Swal.fire({
                    html: "Do you really want to convert this product? <br> Once converted, all serial no. will be permanently deleted and cannot be restored.",
                    icon: "warning",
                    showCancelButton: true,
                    confirmButtonText: "OK",
                    cancelButtonText: "Cancel",
                    reverseButtons: true,
                  }).then((result) => {
                    if (result.isConfirmed) {
                        return true;
                    }else{
                        $("#ProductModal [name='stockType'][value='Serial']").click();
                    }
                });
			} else if(($(this).val() == 'Normal' || $(this).val() == 'Serial') && $('.oldstockType').val() == 'Batch'){
				Swal.fire({
					html: "Do you really want to convert this product? <br> Once converted, all batch related data will be permanently delete and cannot be restored and batch related invoice will be also converted to "+$(this).val(),
					icon: "warning",
					showCancelButton: true,
					confirmButtonText: "OK",
					cancelButtonText: "Cancel",
					reverseButtons: true,
					}).then((result) => {
					if (result.isConfirmed) {
						return true;
					}else{
						$("#ProductModal [name='stockType'][value='Batch']").click();
					}
				});
            } else if($(this).val() != 'Normal' && $('.oldstockType').val() != $(this).val()){
				if ($(this).val() != 'Batch') {
					$('#ProductModal [name="NewStock"]').val($('#ProductModal .totalStock').val());
				}
				$('#ProductModal .serialno-section .bootstrap-tagsinput').after(`<span class="stockchangenote">please enter ${$('#ProductModal .totalStock').val()} serial no. </span>`);
				var stocktype = $(this).val();
				$.ajax({  
					type: "POST",  
					url: "ajaxcall.php",  
					ContentType : 'application/json',
					dataType: 'json',
					data: {action:'getMigrateStock',product_id:$("#ProductModal [name='product_id']").val(),stockType:$(this).val()},
					beforeSend: function() {
 	  					$("body").addClass("is-loading");
 	  				},
					success: function(data){
						if(data.status=='OK')
						{
							if(data.htmldata != ''){
								var newStockTemp = 0;
								if(stocktype == 'Batch'){
									$(data.htmldata).each(function(i,v){
										newStockTemp += parseFloat(v.quantity);
										var quantity = v.quantity;
										quantity  = quantity.toString().substring(0, quantity.toString().indexOf('.') + 1 + quantity_decimal_rounding_by);
										$('#ProductModal .batchOpt [name="batch_name[]"]:last').val(v.batch_name);
										$('#ProductModal .batchOpt [name="model_no[]"]:last').val(v.model_no);
										$('#ProductModal .batchOpt [name="size[]"]:last').val(v.size);
										$('#ProductModal .batchOpt [name="manufacture_date[]"]:last').val(v.manufacture_date);
										$('#ProductModal .batchOpt [name="expiry_date[]"]:last').val(v.expiry_date);
										$('#ProductModal .batchOpt [name="quantity[]"]:last').val(quantity);
										$('#ProductModal .batchOpt [name="product_batch_id[]"]:last').val(v.product_batch_id);
										$('#ProductModal .batchOpt [name="price[]"]:last').val(v.price);
										$('#ProductModal .batchOpt [name="purchase_price[]"]:last').val(v.purchase_price).change();
										$('#ProductModal #cgst').change();
										$('.removeBatch:last').css({'visibility':'hidden'});
										$('.addBatch:last').click();
									});
								}else{
									var tags = data.htmldata;
									$.each(tags, function(i, el){
										newStockTemp ++;
										$('#ProductModal #tagInputs').tagsinput('add',el.serialno);
									});
								}	

								$('#ProductModal [name="NewStock"]').val(newStockTemp);
							}
							// $('#ProductModal .totalStock').val(data.data);
							// var totalitemavl = $('#ProductModal .totalStock').attr('totalitemavl');
							// if(totalitemavl != data.data){
							// 	$('#ProductModal .changeStockName').after(`<span class="stockchangenote">Note :- ${totalitemavl - data.data} quantity already use in invoice and please enter exact ${data.data} quantity </span>`);
							// }else{
							// 	$('#ProductModal .changeStockName').after(`<span class="stockchangenote">Note :- please enter exact ${data.data} quantity </span>`);
							// }

						}
					}
				});

			}
		}

		if($('#ProductModal .stockOption').hasClass('hidestock')){
			$('.hidestock').hide();	
		}

	});
	
	$('#ProductModal #tagInputs').tagsinput({
		confirmKeys: [13, 44],
		itemText: function(item) {
			return item.replace(/\b\w/g, l => l.toUpperCase());
		},
		maxTags: 250,
	});

	$('#ProductModal  input').on('keypress', function(e){
		if (e.keyCode == 13){
			e.keyCode = 188;
			e.preventDefault();
		};
	});

	$(document).on('click','.addNormal',function(){
		$('#ProductModal .normalOpt table tbody tr:last').after(addmorenormal);
	});	

	$(document).on('click','.addSerialNo',function(){
		$('#ProductModal .serialno-section .controls:last').after(addmoreserial);
		addMoreButtonFn('Serial');
	});	

function addMoreButtonFn(option=''){
	if(option == 'Batch'){
		var stockcls = '.batchOpt';
		var stockaddbtn = '.addBatch';
		var stockremovebtn = '.removeBatch';
		var row = $('#ProductModal '+stockcls+' table tbody tr');
	}else if(option == 'Serial'){
		var stockaddbtn = '.addSerialNo';
		var stockremovebtn = '.removeSerialNo';
		var row = $('#ProductModal .serialno-section .controls');
	}else if(option == 'bom'){
		var stockaddbtn = '.addbom';
		var stockremovebtn = '.removebom';
		var row = $('#addbom_modal .bom-section .bomOpt tr');		
	}else if(option == 'oc'){
		var stockaddbtn = '.addbom';
		var stockremovebtn = '.removebom';
		var row = $('#addbom_modal .bom-section .oc_bomOpt tr');		
	}else{
		var stockcls = '.normalOpt';
		var stockaddbtn = '.addNormal';
		var stockremovebtn = '.removeNormal';
		var row = $('#ProductModal '+stockcls+' table tbody tr');
	}
	var rowcounter = 1;
	var rowlength = row.length;
	row.each(function(){
		if(rowlength == rowcounter)
		{
			$(this).find(stockaddbtn).show();
			$(this).find(stockremovebtn).hide();
		}
		else
		{
			$(this).find(stockaddbtn).hide();
			$(this).find(stockremovebtn).show();
		}
		rowcounter += 1;
	});
}	 

$(document).on('click','.removeSerialNo',function(){
	$(this).closest('.controls').remove();
	addMoreButtonFn('Serial');
});

$(document).on('click','.addBatch',function(){
	$('#ProductModal .batchOpt table tbody tr:last').after(addmorebatch);
	addMoreButtonFn('Batch');	
	monthYearDatepicker();
	dayWiseDatepicker();					
});	 
var autorawProductList = [{"value":214464,"label":"Assessment -Work ","uom":"","purchaseprice":"0.000000"},{"value":332928,"label":"GST Annual Return","uom":"","purchaseprice":"0.000000"},{"value":215227,"label":"GST Deregistration Charges","uom":"","purchaseprice":"0.000000"},{"value":214445,"label":"GST Monthly Filing Charges","uom":"NOS","purchaseprice":"0.000000"},{"value":214465,"label":"GST Registration","uom":"NOS","purchaseprice":"0.000000"},{"value":214467,"label":"GST Service","uom":"NOS","purchaseprice":"0.000000"},{"value":215303,"label":"IEC Registration","uom":"","purchaseprice":"0.000000"},{"value":167477,"label":"Income Tax Filing","uom":"NOS","purchaseprice":"0.000000"},{"value":214468,"label":"M S M E Registation","uom":"NOS","purchaseprice":"0.000000"},{"value":224086,"label":"MONTHLY ACCOUNTING CHARGES","uom":"","purchaseprice":"0.000000"},{"value":225009,"label":"other Service","uom":"","purchaseprice":"0.000000"},{"value":215226,"label":"PAN CARD","uom":"","purchaseprice":"0.000000"},{"value":167475,"label":"Preparation Of Balance Sheet","uom":"NOS","purchaseprice":"0.000000"},{"value":167476,"label":"Preparation Of Profit & Loss Statement","uom":"NOS","purchaseprice":"0.000000"},{"value":332929,"label":"Shops and Establishment Annual return","uom":"","purchaseprice":"0.000000"},{"value":214461,"label":"Shops and Establishment Registration","uom":"NOS","purchaseprice":"0.000000"},{"value":214462,"label":"T D S Quarterly- Filing","uom":"NOS","purchaseprice":"0.000000"},{"value":215225,"label":"Tally Software","uom":"","purchaseprice":"0.000000"},{"value":3523,"label":"3 \" Fan Bell","uom":"NOS","purchaseprice":"2300.000000"},{"value":3527,"label":"Bend and Pipes","uom":"NOS","purchaseprice":"200.000000"},{"value":3526,"label":"Full Wall Pipes","uom":"NOS","purchaseprice":"1800.000000"},{"value":3522,"label":"Motor kirloskar (Diesel)","uom":"NOS","purchaseprice":"13200.000000"}]; 
$('#addbom_modal').on('shown.bs.modal', function () {
	var rawhtml = bomrowhtml('raw');
	var ochtml = bomrowhtml('oc');
    $('#addbom_modal .bomOpt table tbody').append(rawhtml);
    $('#addbom_modal .oc_bomOpt table tbody').append(ochtml);
	addMoreButtonFn('bom');
	addMoreButtonFn('oc');
	rowsupdate();
	calcestimatetotal();	
	
});
function calcestimatetotal(){
	var total = 0;
	var rowcounter = 1;
	var oc_rowcounter = 1;
	var rowlength = $(".bomtable .bom-row").length;
	var oc_rowlength = $(".octable .bom-row").length;
    $('#addbom_modal .bom-section table tbody tr').each(function(){
        var row = $(this);
        var estimatedCost = row.find('.bom-raw_estimated_cost').val();
        var raw_qty = row.find('.bom-raw_qty').val();
        var raw_pur_price = row.find('.bom-raw_pur_price').val();
        var product_type = row.find('.raw-product_type').val();
        total += parseFloat(estimatedCost);
		
		if (raw_pur_price != "" && raw_qty != "") {
			if (rowlength == rowcounter && product_type == 1) {
				$('#addbom_modal .bomtable .addmore-section .addbom:last').trigger('click');
			}
			if(oc_rowlength == oc_rowcounter && product_type == 2) {
				$('#addbom_modal .octable .addmore-section .addbom:last').trigger('click');
			}
		}
		if(product_type == 1){
			rowcounter += 1;
		}
		if(product_type == 2){
			oc_rowcounter += 1;
		}
    });
    $('#total_estimated_cost').val(total.toFixed(2));

}
function calculateEstimatedCost(row) {
	const qty = parseFloat(row.find('.bom-raw_qty').val()) || 0;
    const purchasePrice = parseFloat(row.find('.bom-raw_pur_price').val()) || 0;
    const estimatedCost = qty * purchasePrice;
    row.find('.bom-raw_estimated_cost').val(estimatedCost.toFixed(2));
}
function calculatePurchasePrice(row) {
    const qty = parseFloat(row.find('.bom-raw_qty').val()) || 0;
    const estimatedCost = parseFloat(row.find('.bom-raw_estimated_cost').val()) || 0;
    const purchasePrice = qty > 0 ? estimatedCost / qty : 0;
    row.find('.raw_pur_price').val(purchasePrice.toFixed(2));
}
$(document).on('input', '.bomtable .bom-raw_qty:last', function() {
	$('#addbom_modal .bomtable .addmore-section .addbom:last').trigger('click');

});
$(document).on('input change', '.bom-raw_qty, .bom-raw_pur_price', function() {
    const row = $(this).closest('.bom-row');
	$(this).attr('data-rate-val', $(this).val());
    calculateEstimatedCost(row);
});
$(document).on('input change', '.bom-raw_estimated_cost', function() {
    const row = $(this).closest('.bom-row');
    calculatePurchasePrice(row);
});
$(document).on('click','.addbom',function(){
	if($(this).closest('table').hasClass('bomtable')){
		var tr = bomrowhtml('raw');
		$(this).closest('table').find('tbody tr:last').after(tr);
	}else{
		var tr = bomrowhtml('oc');
		$(this).closest('.octable').find('tbody tr:last').after(tr);
	}
	addMoreButtonFn('bom');						
	addMoreButtonFn('oc');						
	rowsupdate();
	
});	 
$(document).on('click','.removebom',function(){
	var removeclass = $(this).closest('tr');	
	addMoreButtonFn('bom');	
	rowsupdate();					
	removeclass.remove();					
});	 
function rowsupdate(){
	var product_id = parseFloat($('.bom-section').find('.product_id').val());
	$('.bom-raw_product').autocomplete({
            source: function(request, response) {
                const results = $.grep(autorawProductList, function(item) {
			        return item.label.toLowerCase().includes(request.term.toLowerCase()) &&  item.value != product_id;
                });
                response(results.slice(0, 500));
            },
			change: function(event, ui) {
				if (ui.item == null || ui.item == undefined) {
					const row = $(this).closest('.bom-row');
					row.find('.bom-raw_product_id').val("");
					row.find('.bom-raw_product').val("");
					if(row.find('.bom-raw_qty').val() == ''){
						row.find('.bom-raw_qty').val(1);
					}
					row.find('.bom-raw_uom').val("");
					row.find('.hidden-bom-raw_uom').val("");
					row.find('.hidden-bom-product-uom-rates').val("");
					row.find('.bom-raw_uom').attr("base-uom","");
					row.find('.bom-raw_pur_price').val("price");
					row.find('.bom-raw_pur_price').attr("data-rate-val",price);	
				}
			},
            select: function(event, ui) {
                const row = $(this).closest('.bom-row');
				$(event.target).attr("data-oldval", ui.item.label);
				$(event.target).val(ui.item.label);
				var price = ui.item.purchaseprice;
				price = Math.round(price * price_decimal_rounding) / price_decimal_rounding;
				price = price.toFixed(price_decimal_value);
                row.find('.bom-raw_product_id').val(ui.item.value);
                row.find('.bom-raw_product').val(ui.item.label);
                if(row.find('.bom-raw_qty').val() == ''){
					row.find('.bom-raw_qty').val(1);
				}
                row.find('.bom-raw_uom').val(ui.item.uom);
                row.find('.hidden-bom-raw_uom').val(ui.item.uom);
                row.find('.hidden-bom-product-uom-rates').val(1);
				row.find('.bom-raw_uom').attr("base-uom",ui.item.uom);
                row.find('.bom-raw_pur_price').val(price);
				row.find('.bom-raw_pur_price').attr("data-rate-val",price);
				var $uomName = $(this).closest("tr").find(".bom-raw_uom");
				var product_id = ui.item.value;
				
				var base_unit = ui.item.uom;
				getUOMAutoComplete($uomName,product_id,price,base_unit);
				calcestimatetotal();
				calculateEstimatedCost(row);
                return false;
            },
            minLength: 0
        }).focus(function() {
            $(this).autocomplete("search");
        });
		$('#addbom_modal .bomOpt table tbody tr').each(function(){
			$(this).find(".bom-raw_uom").each(function(){
			var product_id = $(this).closest('tr').find(".raw_product_id").val();
			if(product_id != "" && product_id != undefined){
				var $uomName = $(this);
				var price = $(this).closest('tr').find(".bom-raw_pur_price").val();
				var base_unit = $(this).closest('tr').find('.bom-raw_uom').attr("base-uom");
				getUOMAutoComplete($uomName,product_id,price,base_unit);
			}
			
		});
	});

}
function fetchUOMData($uomName,product_id, price, base_unit) {
	return new Promise((resolve, reject) => {
    	 $.ajax({
            type: 'POST',
            url: "ajaxcall.php",
            dataType: "json",
            data: {
                action: 'getUOM',
                product_id: product_id,
                price: price,
                base_unit: base_unit
            },
            beforeSend: function () {
                $("body").removeClass("is-loading");
            },
            success: function (data) {
                if (data.uomdata && data.uomdata.length > 0) {
					$uomName.prop('disabled',false);
					$uomName.parents(".product-item-row").find(".hidden-bom-product-uom-rates").val(1);
                    resolve(true);
                } else {
					$uomName.prop('disabled',true);
                    resolve(false);
                }
            },
            error: function (xhr, status, error) {
                $("body").removeClass("is-loading");
                reject(false);
            }
        });
    });
}
function getUOMAutoComplete($uomName,product_id,price,base_unit){
	let staticValueDisplayed = false;
	fetchUOMData($uomName,product_id,price,base_unit)
    .then((result) => {
		 if (result) {
        	$uomName.autocomplete({
				source: function( request, response ) {
					$.ajax({
			          type:'POST',	
			          url: "ajaxcall.php",
			          dataType: "json",
			          data: {
			            q: request.term,action:'getUOM',product_id:product_id,price:price,base_unit:base_unit
			          },
			          beforeSend: function() {
					        $("body").removeClass("is-loading");
					  },
			          success: function( data ) {
			          	if(data.uomdata.length > 1){
			          		response( data.uomdata );
			          	}
			          }
			        });
			      },
			    select: function( event, ui ) {
					var $targetparnt = $(this).parents(".bom-row");
					var price = parseFloat($($targetparnt).find(".bom-raw_pur_price").attr('data-rate-val'));
					var uom_rates = parseFloat(ui.item.uom_rates);
					price = (price/ui.item.uom_rates).toFixed(price_decimal_rounding_by);		
					$($targetparnt).find(".bom-raw_uom" ).val( ui.item.label);			
					$($targetparnt).find(".hidden-bom-raw_uom" ).val( ui.item.label);			
					$($targetparnt).find(".hidden-bom-product-uom-rates" ).val( ui.item.uom_rates);			
					$($targetparnt).find(".bom-raw_pur_price" ).val(price);
					calculateEstimatedCost($targetparnt);
					calcestimatetotal();	
					return false;
				}, minLength:0
			}).focus(function(){            
			        $(this).autocomplete("search");
			})
			.autocomplete("instance")._renderItem = function (ul, item) {
				var base_unit = item.base_unit;
				var secoundry_unit = item.label;
				var uom_rates = item.uom_rates;
				
				var appendDiv = '<div class="table">';
			    appendDiv += `<div class="row">
			    				<div class="cell"><strong>${secoundry_unit}:</strong> ${uom_rates}</div>
			    			 </div>`;
				$("<li>")
			        .append(appendDiv)
			        .appendTo(ul);

			    return ul.children().last();    
			  };
	        }else{
	        	$($uomName).prop('disabled',true);
	        } 
    })
    .catch((error) => {
        console.error("Error or no data:", error);
    });
		
	
}
$(document).on('click','.removeBatch',function(){
	var removeclass = $(this).closest('tr');
	var batchid = $(this).closest('tr').find('[name="product_batch_id[]"]').val();
	if(batchid != ''){
		Swal.fire({
			  title: 'Do you really want to delete these batch?',
			  icon: 'warning',
			  showCancelButton: true,
			  confirmButtonColor: '#3085d6',
			  cancelButtonColor: '#d33',
			  cancelButtonText: 'No',
			  confirmButtonText: 'Yes',
			  reverseButtons: true
		}).then((result) => {
		  	if (result.isConfirmed) {
				var product_id = $('#ProductModal [name=product_id]').val();		
				
				var data = {
					action: 'deleteProductBatch',			
					id:batchid,
					product_id:product_id,
				}
				$.ajax({  
					type: "POST",  
					url: "ajaxcall.php",  
					ContentType : 'application/json',
					dataType: 'json',
					data: data,
					success: function(data){
						if(data.status=='OK')
						{
							removeclass.remove();					
						}else{
							errorMessage(data.message,'ERROR','','error');
						}
					}
				});
			}
		});
	
	}else{
		addMoreButtonFn('Batch');
		$(this).closest('tr').remove();
	} 
	calculateBatchQty();
});

$(document).on('change',"#ProductModal .batchOpt table tbody tr:last [name='price[]'] , #ProductModal .batchOpt table tbody tr:last [name='quantity[]'], #ProductModal .batchOpt table tbody tr:last [name='sellpriceincltax[]']",function(){
	if($(this).closest('tr').find("[name='quantity[]']").val() != '' && $(this).closest('tr').find("[name='price[]']").val() != ''
		&& $('#ProductModal [name="oldstockType"]').val() != $("#ProductModal input[name='stockType']:checked").val()){
		var sellprice = $(this).closest('tr').find("[name='price[]']").val();
		var sellpriceincltax = $(this).closest('tr').find("[name='sellpriceincltax[]']").val();
		$('#ProductModal .batchOpt table tbody').append(addmorebatch);	
		addMoreButtonFn('Batch');	
		monthYearDatepicker();
		dayWiseDatepicker();
		$("#ProductModal .batchOpt table tbody tr:last [name='price[]']").val(sellprice);	
		$("#ProductModal .batchOpt table tbody tr:last [name='sellpriceincltax[]']").val(sellpriceincltax);	
	}
});


$(document).on('change',"#ProductModal .batchOpt table tbody tr [name='quantity[]']",function(){
	calculateBatchQty();	
});

function calculateBatchQty(){
	var newStockTemp = 0;
	$("#ProductModal .batchOpt table tbody tr").each(function(){
		if($(this).find("[name='quantity[]']").val() != ''){
			newStockTemp += parseFloat($(this).find("[name='quantity[]']").val());
			$('#ProductModal [name="NewStock"]').val(newStockTemp);
		}
	});
}

function validateBatchRows(){
	var isValid = true;
	var productid = $("#ProductModal [name='product_id']").val();
	if(productid == '' || productid == undefined || ($('#ProductModal [name="product_id"]').val() != '' && $('#ProductModal [name="totalStock"]').val() != '')){
		var stockType = $("#ProductModal input[name='stockType']:checked").val();
		var totalStock = parseFloat($('#ProductModal [name="totalStock"]').val());
		if(stockType == 'Batch'){
			if($("#ProductModal .batchOpt table tbody tr").length>0)
			{
				var RowCounter = 1;
				var totalRowsData = $("#ProductModal .batchOpt table tbody tr");
				var counttotalRowsData = totalRowsData.length;
				totalRowsData.each(function(){
					if(counttotalRowsData == 1 || counttotalRowsData >= RowCounter){
						if(counttotalRowsData == RowCounter){
							var isPriceval = true;
							$(this).find("input").each(function(){
								var attrName = $(this).attr('name');
								var attrVal = $(this).val().trim();
								var colname = '';
								switch(attrName){
									case 'batch_name[]': colname = "Batch No."; if(attrVal != ''){
											isPriceval = false;
										} break;
																	case 'quantity[]': 
										colname = "Quantity";
										if(attrVal != ''){
											isPriceval = false;
										}
										break;
									case 'price[]': 
										colname = "Sale Price";
								}
							});	
							
							    if(isPriceval) {
									return false;
								}		
						}
						$(this).find("input").each(function(){
								var attrName = $(this).attr('name');
								var attrVal = $(this).val().trim();
								var colname = '';
								switch(attrName){
									case 'batch_name[]': colname = "Batch No."; break;
																	case 'quantity[]': 
										colname = "Quantity";
										break;
									case 'price[]': 
										colname = "Sale Price";
										break;
								}
								if( attrVal == "" && colname != '')
								{
									Swal.fire({
										icon: 'warning',
										title: 'Please Enter '+colname,
										didClose: (e) => {
											$(this).focus();
										}
									});
									isValid = false;
									return false;
								}
						});
						RowCounter++;
					}

				});
			}
			
			if($('#ProductModal [name="oldstockType"]').val() != stockType){
				if($('#ProductModal [name="product_id"]').val() != '' && $('#ProductModal [name="totalStock"]').val() != ''){
					var newStock = parseFloat($('#ProductModal [name="NewStock"]').val());
					if(totalStock != newStock){
						Swal.fire({
									icon: 'warning',
									title: 'Please Enter Exact '+totalStock+' Quantity',
									didClose: (e) => {
										$('#ProductModal .batchOpt [name="quantity[]"]:last').focus();
									}
								});
						isValid = false;
						return false;
					}
				}	
			}

		}else if(stockType == 'Serial' && $('#ProductModal [name="oldstockType"]').val() != 'Serial'){
									if(productid != '' && productid != undefined){
							if(totalStock != $("#ProductModal [name='serialno']").val().split(',').length){
								Swal.fire({
									icon: 'warning',
									title: 'Please Enter Exact '+totalStock+' Serial No.',
									didClose: (e) => {
										$('#ProductModal .bootstrap-tagsinput input').focus();
									}
								});
								isValid = false;
								return false;
							}
						}
								
		}
	}
	return isValid;
}

$(document).on('keyup',"#ProductModal [name='batch_name[]']",function(){
	var product_id = $('#ProductModal [name=product_id]').val();
	var curcls = $(this).closest('tr');
	$batchName = $(this);
	$batchName.autocomplete({
		source: function( request, response ) {
			$.ajax({
	          type:'POST',	
	          url: "ajaxcall.php",
	          dataType: "json",
	          data: {
	            q: request.term,action:'getBatch',product_id:product_id,quantity:1
	          },
	          beforeSend: function() {
			        $("body").removeClass("is-loading");
			  },
	          success: function( data ) {
	          	response( data.batchdata );
	          }
	        });
	      },
	      minLength: 1,
		change: function(event, ui) {
			if (ui.item == null || ui.item == undefined) {
				var $targetparnt = $(this).parents(".product-item-row");
			}
			else{
				if (ui.item) {
					var $targetparnt = $(this).parents(".product-item-row");
					$($targetparnt).find( ".batch_name" ).val( ui.item.batch_name);			
				}
			}
		},
		select: function( event, ui ) {
			curcls.find("[name='product_batch_id[]']").val(ui.item.product_batch_id);
			curcls.find("[name='batch_name[]']").val(ui.item.batch_name);
			curcls.find("[name='manufacture_date[]']").val(ui.item.manufacture_date);
			curcls.find("[name='expiry_date[]']").val(ui.item.expiry_date);
			curcls.find("[name='quantity[]']").val(ui.item.quantity);
			curcls.find("[name='mrp[]']").val(ui.item.mrp);
			curcls.find("[name='price[]']").val(ui.item.price);
			return false;
		}, minLength:0
	}).focus(function(){            
	        $(this).autocomplete("search");
	});

});

$(document).on('keyup change blur','#ProductModal .batchOpt .inputlabel_wrapper input',function(){
	$('#ProductModal .batchOpt .inputlabel_wrapper input[type="text"]').each(function(){
		var inputlabel_wrapper = $(this).closest('.inputlabel_wrapper');
		if($(this).val() || $(this).is(':focus')) {
			inputlabel_wrapper.addClass('active_inputlabel');
		}else{
			inputlabel_wrapper.removeClass('active_inputlabel');
		}
	});
});

$(document).on('click','[name=itemType]',function(){
	var itemType = $(this).val();
	$("#ProductModal [name='stockType'][value='Normal']").click();
	$("#ProductModal [name='stockType'][value='Batch']").closest('label').show();
	$("#ProductModal [name='stockType'][value='Serial']").closest('label').show();
	$("#ProductModal .stockOption").show();
	if(itemType == 'Service'){
		$("#ProductModal .stockOption").hide();
		$("#ProductModal [name='stockType'][value='Batch']").closest('label').hide();
		$("#ProductModal [name='stockType'][value='Serial']").closest('label').hide();
	}
});

function getProductBatch(productid){
	$.ajax({  
			type: "POST",  
			url: "ajaxcall.php",  
			ContentType : 'application/json',
			dataType: 'json',
			data: {action:'getProductBatch',productid:productid},
			beforeSend: function() {
				$("body").addClass("is-loading");
			},
			success: function(data){
				$('#ProductModal .batchQty').hide();
				if(data.status=='OK')
				{
					if(data.data != ''){
						$('#ProductModal .batchOpt tbody').html(data.data);
						$('#ProductModal #igst').change();
						monthYearDatepicker();
						dayWiseDatepicker();
					}
				}
				$('#ProductModal .batchOpt .addmore-section').show();

			}
		});	
}	

//for show goods and service finder model

	$(document).on("click", ".ViewhsnFinder", function() {
		var iframeSrc = $(this).attr("data-baselink");
		var hsncode =  $(this).closest('.hsn_field').find('#hsn').val();
		if(hsncode != ""){
			iframeSrc = iframeSrc+'?hsn='+hsncode;
		}
		if(iframeSrc != ""){
			$('#PrIntHsnModal').modal('show').on('shown', function() {
									parent.$("#PrIntHsnModal").css({"z-index":"200001"});
								$("#PrIntHsnModal iframe").attr("src", iframeSrc );
				$("#PrIntHsnModal .modal-content").removeClass("is-loading");
				if(window.innerHeight < $('#PrIntHsnModal iframe').height())
				{
					$('#PrIntHsnModal, #PrIntHsnModal #hsn_iframe').height(window.innerHeight);
				}
			});
		}
	
	});

$(document).on('click','#ProductModal .uomconversionbtn',function(){
	if($('#ProductModal [name="uom"]').val() != '' && $('#ProductModal [name="oldstockType"]').val() != 'Serial' && $("#ProductModal [name='stockType']:checked").val() != 'Serial'){
		var unitBase = $('#ProductModal [name="uom"]').val();
		$('#ProductModal .uom-conversion-section').html(`<div class="conversion-uom-section"> 1 <span class="uom-base-unit">${unitBase}</span> = <input type="text" name="uom_rates[]" class="decimal_numeric_only" maxlength="10" placeholder="Qty."> <input type="hidden" name="secoundry_unit[]" value="">
			<input type="text" class="secoundry_unit" placeholder="Select UOM">
			<div class="btn btn-primary right_modal_btn addUnitRates btnaddmoreoption "><svg width="20" height="20"><use href="svg-icon/icons.svg#plus-svg-icon"></use></svg></div></div>`);
		if($('#ProductModal .uom-conversion-section').css('display') == 'none'){
			$('#ProductModal .uom-conversion-section').slideDown();
			autocompleteUom(".secoundry_unit");
			countuomsection++;
		}else{
			$('#ProductModal .uom-conversion-section').slideUp();
		}
	}

});

function autocompleteUom(request){
	$(request).autocomplete({
		source: autoSecondUOMListModal,
		change: function(event, ui) {
			if (ui.item == null || ui.item == undefined) {} else {
				if (ui.item) {
					$(this).val(ui.item.value);
				}
			}
		},
		select: function(event, ui) {
			$(this).val(ui.item.value);
			$(this).closest('.conversion-uom-section').find('[name="secoundry_unit[]"]').val(ui.item.value);
			autoSecondUOMListModal = $.grep(autoSecondUOMListModal, function (element, index) {
			    return element.value != ui.item.value;
			});
			return false;
		},
		minLength: 0
	}).focus(function() {
		$(this).autocomplete("search");
	});
}

$(document).on('focus',"#ProductModal .secoundry_unit",function(){
	var dataValue = $(this).closest('.conversion-uom-section').find('[name="secoundry_unit[]"]').val();
	if(dataValue != '' && dataValue != undefined){
		var uomArr = [];
		$(this).closest('.uom-conversion-section').find('.conversion-uom-section').each(function(n,v){
			if($(this).find('[name="secoundry_unit[]"]').val() != ''){
				uomArr.push($(this).find('[name="secoundry_unit[]"]').val());
			}
		});
		if(uomArr.length > 0){
			autoSecondUOMListModal = $.grep(autoSecondUOMListModal, function (element, index) {
			    return $.inArray(element.value, uomArr) == -1;
			});
			var currentdata = $.grep(autoUOMListModal, function (element, index) {
			    return element.value == dataValue;
			});
			autoSecondUOMListModal.push(currentdata[0]);
			autoSecondUOMListModal.sort((a, b) => a.label.localeCompare(b.label));
		}
	}
	autocompleteUom($(this));
	

});

$(document).on('click','#ProductModal .addUnitRates',function(){
	if(countuomsection < 5){
		var i = $(this).closest('.conversion-uom-section').index();
		var unitBase = $('#ProductModal [name="uom"]').val();
		
		$('#ProductModal .uom-conversion-section .conversion-uom-section:last').after(`<div class="conversion-uom-section"> 1 <span class="uom-base-unit">${unitBase}</span> = <input type="text" name="uom_rates[]" class="decimal_numeric_only" maxlength="10" placeholder="Qty."> <input type="hidden" name="secoundry_unit[]" value="">
				<input type="text" class="secoundry_unit" placeholder="Select UOM">
				<div class="btn btn-primary right_modal_btn addUnitRates btnaddmoreoption "><svg width="20" height="20"><use href="svg-icon/icons.svg#plus-svg-icon"></use></svg></div></div>`);

		autocompleteUom('.secoundry_unit');      
		var previousSection = $('#ProductModal .uom-conversion-section').find('.conversion-uom-section:last').prev('.conversion-uom-section');
		previousSection.find('.addUnitRates').after(`<div class="btn btn-danger right_modal_btn removeUnitRates btnaddmoreoption "><svg width="20" height="20"><use href="svg-icon/icons.svg#minus-svg-icon"></use></svg></div>`);
		previousSection.find('.addUnitRates').remove('.addUnitRates');
	}
	countuomsection++;
});

$(document).on('click','#ProductModal .removeUnitRates',function(){
	var uomSection = $(this).closest('.conversion-uom-section');
	var dataValue = $(this).closest('.conversion-uom-section').find("[name='secoundry_unit[]']").val();
	if(dataValue != ''){
		var deleteuom = true;
		var productid = $('#ProductModal .product_id').val();
		if(productid != ''){
			var data = {
				action: 'deleteProductUOM',			
				uom:dataValue,
				product_id:productid,
			}
			$.ajax({  
				type: "POST",  
				url: "ajaxcall.php",  
				ContentType : 'application/json',
				dataType: 'json',
				data: data,
				beforeSend: function() {
                   $("body").removeClass("is-loading");
                },
				success: function(data){
					if(data.status=='OK')
					{
						var currentdata = $.grep(autoUOMListModal, function (element, index) {
							return element.value == dataValue;
						});
						autoSecondUOMListModal.push(currentdata[0]);
						autoSecondUOMListModal.sort((a, b) => a.label.localeCompare(b.label));
						uomSection.remove();
						countuomsection--;			
					}else{
						deleteuom = false;
						errorMessage(data.message,'ERROR','','error');
					}
				}
			});
		}else{
			var currentdata = $.grep(autoUOMListModal, function (element, index) {
				return element.value == dataValue;
			});
			autoSecondUOMListModal.push(currentdata[0]);
			autoSecondUOMListModal.sort((a, b) => a.label.localeCompare(b.label));
			uomSection.remove();
			countuomsection--;	
		}
		
	}else{
		uomSection.remove();
		countuomsection--;
	}
	
});
$(document).ready(function(){
	$(document).on('change','.trans_mode', function(){
		checkewayvalidation($(this));
	});
	$(document).on('input', '#cur_pincode', function() {
		var cur_pincode = $(this).val().replace(/\s+/g, '');
			if (/^\d{6}$/.test(cur_pincode)) {
				var org_pincode = cur_pincode;
				var pincode = $('#to_pincode').val();
				
					data = {
						action: 'dist_apicall',
						from: org_pincode,
						to: pincode
					}
					$.ajax({
						type: 'POST',
						data: data,
						url: "ajaxcall.php",
						ContentType: 'application/json',
						dataType: 'json',
						beforeSend: function() {
							$("body").addClass("is-loading");
						},
						success: function(data) {
							if (data.status == 'OK') {
								$('#eway_distance').val(data.dist_apicall);
								$('.auto-distance').text(data.dist_apicall);
							} else {
								if(data.errorTitle)
								{
									var errTitle = data.errorTitle;
								}
								else{
									var errTitle = 'Error';
								}
								errorMessage('',errTitle,data.data,'error');
								$("body").removeClass("is-loading");
							}
						},
						error: function(xhr, status, error) {
							var err = xhr.responseText;
							if(data.errorTitle)
							{
								var errTitle = data.errorTitle;
							}
							else{
								var errTitle = 'Error';
							}
							errorMessage('',errTitle,err.Message,'error');
							$("body").removeClass("is-loading");
						},
						complete: function() {

						}
					});
			}
	});

});
	$("#extendewaymodal form").validate({
			rules: {
				'ext_reason': {
					required: true
				},'ext_remark': {
					required: true
				},'vehicle_no': {
					required: true
				},'trans_mode': {
					required: true
				},'consignment_in': {
					required: true
				},'cur_state': {
					required: true
				},'cur_pincode': {
					required: true
				},'cur_place': {
					required: true
				},
				'address_line_1': {
					required: function() {
						return $('.trans_mode').val() == 5;
					}
				},
				'address_line_2': {
					required: function() {
						return $('.trans_mode').val() == 5;
					}
				},
				'address_line_3': {
					required: function() {
						return $('.trans_mode').val() == 5;
					}
				}
			},
			messages: {
				'ext_reason': "Please enter your Extenstion Reason",
				'ext_remark': "Please enter Extension Remark",
				'vehicle_no': "Please enter Vehical Number",
				'trans_mode': "Please enter Transport mode",
				'consignment_in': "Please enter Consignment",
				'cur_state': "Please enter Current state",
				'cur_pincode': "Please enter Current pincode",
				'cur_place': "Please enter Current place",
				'address_line_1': "Please enter Address 1",
				'address_line_2': "Please enter Address 2",
				'address_line_3': "Please enter Address 3",
			},
			submitHandler: function(form) {
						var cur_statecode = $('select[name="cur_state"] option:selected').data('statecode');
						var formData = $(form).serializeArray();
						var formDataObj = {};
						$.each(formData, function (i, field) {
							formDataObj[field.name] = field.value;
						});
						if(formDataObj.trans_mode != 5)
						{
							formDataObj.transit_type = '';
						}
						var ccdata = {
						"action": "EXTENDVALIDITY",
						"invid": formDataObj.invid,
						"ewbNo": formDataObj.ewayID,
						"vehicleNo": formDataObj.vehicle_no,
						"fromPlace": formDataObj.cur_place,
						"fromState": cur_statecode,
						"remainingDistance": formDataObj.eway_distance,
						"transDocNo": formDataObj.trans_mode,
						"transDocDate": "11/10/2024",
						"transMode": formDataObj.trans_mode,
						"extnRsnCode": 1,
						"extnRemarks": formDataObj.ext_remark,
						"fromPincode": formDataObj.cur_pincode,
						"consignmentStatus": formDataObj.consignment_in_hidden,
						"transitType": formDataObj.transit_type,
						"addressLine1": formDataObj.address_line_1,
						"addressLine2": formDataObj.address_line_2,
						"addressLine3": formDataObj.address_line_3
						}
						var data = {
							action: 'ExtendEwayBill',			
							data:ccdata
						};
						$.ajax({  
							type: "POST",  
							url: "eway_einvoice/eway.php",  
							ContentType : 'application/json',
							dataType: 'json',
							data: data,
							success: function(response) {
										if (response.status === 'OK') {
											if (response.data.ewayBillNo) {  // Check if ewayBillNo exists
												Swal.fire({
													icon: 'success',
													title: 'E-Way Bill Extend Successfully',
													text: `E-Way Bill No: ${response.data.ewayBillNo}, Updated Date: ${response.data.updatedDate}`
												})
												update_ewaydetail(response.data.ewayBillNo,response.data.updatedDate,response.data.validUpto);
											}
										} else if (response.status === 'ERROR') {
											errorMessage('', 'Error', response.data, 'error');
										}
									},
							});
				
			},
			error: function(data) {
			},
			complete: function(data) {}
		});

		function checkewayvalidation(curele){
			if (curele.val() == ''){
				$('select.transit_type').prop('disabled',false);
				$('.consignment_in').prop('disabled', false);
			}

			if (curele.val() >= 1 && curele.val() <= 4) {	
				$('select.consignment_in').val('M');
				$('input.consignment_in_hidden').val('M');
				$('select.transit_type').val('');
				$('select.transit_type option[value=""]').prop('selected',true);
				$('select.transit_type').prop('disabled',true);
				$('.consignment_in').prop('disabled', true);

				$('.address_line_1').prop('disabled', true);
				$('.address_line_1').val('');
				$('.address_line_2').prop('disabled', true);
				$('.address_line_2').val('');
				$('.address_line_3').prop('disabled', true);
				$('.address_line_3').val('');
			}else if(curele.val() == 5){
				$('select.consignment_in').val('T');
				$('input.consignment_in_hidden').val('T');
				$('select.transit_type').prop('disabled',false);
				$('.consignment_in').prop('disabled', true);
				
				$('.address_line_1').prop('disabled', false);
				$('.address_line_2').prop('disabled', false);
				$('.address_line_3').prop('disabled', false);
			}

		}
		function update_ewaydetail(ewayno,updated_on,new_validity,invid)
		{
			var invid = $('#extendewaymodalForm #invid').val();
			
			var data = {
				action: 'update_ewayvalidity',			
				invid:invid,
				ewayno:ewayno,
				updated_on:updated_on,
				new_validity:new_validity
			};
			$.ajax({  
					type: "POST",  
					url: "ajaxcall.php",  
					ContentType : 'application/json',
					dataType: 'json',
					data: data,
					success: function(response) {
					if(response.status=="OK")
					{
						$('.actions_detail_icons_eway[data-id='+invid+']').show();
						$('.actions_detail_icons_eway[data-id='+invid+']').attr('title',response.tooltip_msg);
						$('.actions_detail_icons_eway[data-id='+invid+'] i').removeClass('eway-einvoice-cancel').addClass('eway-einvoice-active');
						$('.extendEwayBill[data-id='+invid+']').attr('data-valid',new_validity);
						$('#extendewaymodal').modal('hide');
					}
					}
				});
		}

function validatebomRowsForSubmit(){
		var isValid = true;
		if($(".bom-row").length>1)
		{
			var RowCounter = oc_RowCounter = 1;
			var totalRowsData = $(".bomOpt .bom-row").length;
			var oc_totalRowsData = $(".oc_bomOpt .bom-row").length;
			$(".bom-row").each(function(){
				var quantity = $(this).find(".bom-raw_qty").val();
				var product_type = $(this).find(".raw-product_type").val();
				var product = $(this).find(".bom-raw_product").val();
				var rate = $(this).find(".bom-raw_pur_price").val();
				if((totalRowsData == RowCounter || oc_totalRowsData == oc_RowCounter) &&  product == "" &&  rate == "" &&  quantity == "")
				{
				
				}
				else
				{
					if( product == "")
					{
						Swal.fire({
							icon: 'warning',
							title: 'Please Select Product',
							didClose: (e) => {
								$(this).find(".bom-raw_product").focus();
							}
						});
						isValid = false;
						return false;
					}
					if( quantity == "")
					{
						Swal.fire({
							icon: 'warning',
							title:'Please Enter Quantity',
							didClose: (e) => {
								$(this).find(".bom-raw_qty").focus();
							}
						});
						isValid = false;
						return false;
					}
					if(  rate == "" )
					{
						Swal.fire({
							icon: 'warning',
							title:'Please Enter Price',
							didClose: (e) => {
								$(this).find(".bom-raw_pur_price").focus();
							}
						});
						isValid = false;
						return false;
					}
				}
				if(product_type == 1){
					RowCounter++;
				}
				if(product_type == 2){
					oc_RowCounter++;
				}
			});
		}
		else
		{
			$(".bom-row").each(function(){
				var quantity = $(this).find(".bom-raw_qty").val();
				var product = $(this).find(".bom-raw_product").val();
				var rate = $(this).find(".bom-raw_pur_price").val();
				if( product == "")
				{
					Swal.fire({
						icon: 'warning',
						title: 'Please Select Product',
						didClose: (e) => {
							$(this).find(".bom-raw_product").focus();
						}
					});
					isValid = false;
					return false;
				}
				if( quantity == "")
				{
					Swal.fire({
						icon: 'warning',
						title:'Please Enter Quantity',
						didClose: (e) => {
							$(this).find(".bom-raw_qty").focus();
						}
					});
					isValid = false;
					return false;
				}
				if(  rate == "" )
				{
					Swal.fire({
						icon: 'warning',
						title:'Please Enter Price',
						didClose: (e) => {
							$(this).find(".bom-raw_pur_price").focus();
						}
					});
					isValid = false;
					return false;
				}
			
			});
		}
		
		return isValid;
	}
</script>
<script>
	$(window).load(function() {
		equalheight('.equal-height');
	});
	$(window).resize(function() {
		equalheight('.equal-height');
	});
</script>
	<script>
		var validate_hsn_option = 1;
		var rev_charge_alert = 1;

		var invoice_pf_alert = 0;
		handleSmartSuggestions();


	</script>
	<script src="js/HSN-Codes.js?ver=1007202510072025"></script>
	<script src="js/bill.js?ver=1007202510072025"></script>
	<script src="js/company.js?ver=1007202510072025"></script>
	<script src="js/bootstrap-select.min.js?ver=1007202510072025"></script>
	<link rel="stylesheet" href="css/bootstrap-select.min.css?ver=1007202510072025" />


	<script type="text/javascript">
	var availableDispatchFrom = [];
</script>

<div id="AdditionalBusinessModal" class="popup_right_slider modal fade" role="dialog" style="display: none;">
  <div class="modal-dialog">
<form class="form-horizontal" method="post" id="AdditionalBusinessForm"   >
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <div class="modal-title-wrapper" style="display: flex;align-items: center;">
		    <button type="button" class="btn btn-default btn_close" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg></button>
            <h4 class="modal-title">Add Dispatch From Address</h4>
                    </div>
      </div>
      <div class="modal-body">
			<fieldset>
				<div class="control-group">
				<label for="name" class="control-label">GSTIN</label>
				<div class="controls" style="position:relative;">
					<input type="text" name="gstin" id="gstin" class="span4" placeholder="Enter Dispatch GSTIN" maxlength="100">
												<div class="btn dispachgstdata_autofill div-inner-input" data-gstfor="shipping">Auto Fill</div>
											</div> <!-- /controls -->
				</div> <!-- /control-group -->
				<div class="control-group">											
					<label for="firstname" class="control-label">Company Name <span class="star_red">*</span></label>
					<div class="controls" style="position:relative;">
						<input type="text" name="orgname" id="btxtorgname" class="span4 valid" placeholder="Enter company name" maxlength="100" required>
					</div> <!-- /controls -->				
				</div> <!-- /control-group -->
				<div class="control-group">											
					<label for="firstname" class="control-label">Name </label>
					<div class="controls"  style="position:relative;">
						<input type="text"  name="name" id="btxtname" class="span4 valid" placeholder="Enter name" maxlength="255" aria-invalid="false">
					</div> <!-- /controls -->	
				</div> <!-- /control-group -->
				
                <div class="control-group">
                    <label for="firstname" class="control-label">Phone</label>
                    <div class="controls">
                        <input type="text" value="" name="phone" class="span4 ship_phone" placeholder="Enter shipping phone " maxlength="20">
                    </div> <!-- /controls -->
                </div> <!-- /control-group -->

                <div class="control-group">
                    <label for="firsname" class="control-label">Email</label>
                    <div class="controls">
                        <input type="text" value="" name="email" class="span4 ship_email" placeholder="Enter Email">
                    </div> <!-- /controls -->
                </div> <!-- /control-group -->

				<div class="control-group">											
					<label for="firstname" class="control-label">Address Line 1 <span class="star_red">*</span></label>
					<div class="controls">
						<input type="text" name="address1" maxlength="100" id="btxtaddress" class="span4 valid" placeholder="Enter address line 1" required>
					</div> <!-- /controls -->				
				</div> <!-- /control-group -->
				
				<div class="control-group">											
					<label for="firstname" class="control-label">Landmark <span class="star_red">*</span></label>
					<div class="controls">
						<input type="text" name="address2" maxlength="100" id="btxtaddress2" class="span4 valid" placeholder="Enter landmark" aria-invalid="false" required>
					</div> <!-- /controls -->				
				</div> <!-- /control-group -->
				
				<div class="control-group">											
					<label for="firstname" class="control-label">City <span class="star_red">*</span></label>
					<div class="controls">
						<input type="text" id="bcity" class="span4 valid" name="city" placeholder="Enter city" maxlength="50" required>
					</div> <!-- /controls -->				
				</div> <!-- /control-group -->
				
				<div class="control-group">
					<label for="Country" class="control-label">Country <span class="star_red">*</span></label>
					<div class="controls">
						<select onchange='selct_state_option(this.value,"AdditionalBusinessModal #listBox1","AdditionalBusinessModal #newState","state")' type="list" data-value="India" name="country" class="span4 listBoxCountry1" id="listBoxCountry" required></select>
					</div> <!-- /controls -->
				</div> <!-- /control-group -->

				<div class="control-group">											
					<label for="firstname" class="control-label">State <span class="star_red">*</span></label>
					<div class="controls">
						<select type="list"  name="state" onchange='selct_district(this.value)'  class="span4"   id="listBox1"  required></select>						
						<input type="text" name="newstate" id="newState" placeholder="Enter State" class="span4 hide" />				
					</div> <!-- /controls -->				
				</div> <!-- /control-group -->
				
				<div class="control-group">											
					<label for="firstname" class="control-label">Pincode <span class="star_red">*</span></label>
					<div class="controls">
						<input type="text" name="pincode" id="btxtpincode" class="span4 valid" placeholder="Enter pincode" maxlength="6" required>
					</div> <!-- /controls -->				
				</div> <!-- /control-group -->
				<input type="hidden" name="additionalbusinessdetail_id">
				

				<!--------------- -------------------------------------------------->
			</fieldset>
      </div>
      <div class="modal-footer">
			<button type="button" class="btn btn-default pull-left" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg>Close</button>
			<button  class="btn btn-primary" name="btnsubmit" type="submit"><svg width="20" height="20"><use href="svg-icon/icons.svg#save-svg-icon"></use></svg>Save</button>
      </div>
    </div>
	</form>
  </div>
</div>

<script>
$(document).ready(function() {	

	$(document).on('click','.additionalBusiness',function(){
		$('#AdditionalBusinessModal .modal-title').text('Add Dispatch From Address ');
		$("#AdditionalBusinessModal label.error").remove();
		$('#AdditionalBusinessForm')[0].reset();
		$('#AdditionalBusinessForm [name=country]').val('India');
		$('#AdditionalBusinessModal #newState').attr('name', 'statex');
		$('#AdditionalBusinessModal #listBox1').attr('name', 'state');
		$('#AdditionalBusinessModal #newState').hide();
		$('#AdditionalBusinessModal [name=state]').show();
		$('#AdditionalBusinessModal [name=additionalbusinessdetail_id]').val('');
		$('#AdditionalBusinessModal').modal('show');
	});
	
	$("#AdditionalBusinessForm").validate({
			rules: {
				field: {required: true},
			},
			messages: {
				orgname: "Please enter organisation name",
				address1: "Please enter address",
				address2: "Please enter landmark",
				state: "Please enter state name",
				city: "Please enter city name",
				pincode: "Please enter pincode",
			},
	});
	$(document).on('click', ".dispachgstdata_autofill", function() {
			var gstno = $("#AdditionalBusinessModal #gstin").val();
			var regex = /^\d{2}/;
			if (gstno.length == 15 && regex.test(gstno)) {
				
				var data = {
					action: 'gstapicall',
					gstno: gstno,
					fromgstno: '',
					userid: '10594'				}
				$.ajax({
					type: 'POST',
					data: data,
					url: "ajaxcall.php",
					ContentType: 'application/json',
					dataType: 'json',
					beforeSend: function() {
						$("body").addClass("is-loading");
					},
					success: function(data) {
						if (data.status == 'OK') {
							var gstno = data.gstno.substr(0, 2);
							var data = data.gstapicall_data;
							if (jQuery.isEmptyObject(data)) {
								if ($("#AdditionalBusinessModal #gstin-error").length == 0) {
									$('#AdditionalBusinessModal #gstin').after('<label id="gstin-error" class="error" for="gstin">Invalid GSTIN.</label>');
								} else {
									$('#AdditionalBusinessModal #gstin-error').html('Invalid Transport ID/GSTIN.');
								}

							} else {
								$('#AdditionalBusinessModal #gstno-error').remove();
								arr = JSON.parse(JSON.stringify(data));
								$("#AdditionalBusinessModal #btxtorgname").val(arr.cmpname);
								$("#AdditionalBusinessModal #btxtname").val(arr.name);
								$("#AdditionalBusinessModal #btxtaddress").val(arr.address1);
								$("#AdditionalBusinessModal #btxtaddress2").val(arr.address2);
								$("#AdditionalBusinessModal #bcity").val(arr.city);
								
								$("#AdditionalBusinessModal #listBox1").val(arr.state);
								$("#AdditionalBusinessModal #btxtpincode").val(arr.pincode);
							}

						} else {
							if(data.errorTitle)
							{
								var errTitle = data.errorTitle;
							}
							else{
								var errTitle = 'Error';
							}
							errorMessage('',errTitle,data.data,'error');
							$("body").removeClass("is-loading");
						}
					},
					error: function(xhr, status, error) {
						var err = xhr.responseText;
						if(data.errorTitle)
						{
							var errTitle = data.errorTitle;
						}
						else{
							var errTitle = 'Error';
						}

						errorMessage('',errTitle,err.Message,'error');
						$("body").removeClass("is-loading");
					},
					complete: function() {

					}
				});
			} else {
				
				if ($("#AdditionalBusinessModal #gstin-error").length == 0) {
					$('#AdditionalBusinessModal #gstin').after('<label id="gstin-error" class="error" for="gstin">Invalid GSTIN.</label>');
				} else {
					$('#AdditionalBusinessModal #gstin-error').html('Invalid Transport ID/GSTIN.');
				}
				$('#AdditionalBusinessModal #gstin-error').show();
			}
		});

	$(document).on('submit','#AdditionalBusinessForm',function(e){
			e.preventDefault();
			var formData = $(this).serialize()+'&action=addadditionalbusinessplace';
				$.ajax({
					url: 'ajaxcall.php',
					type: 'POST',
					data: formData,
					ContentType : 'application/json',
					dataType: 'json',
					beforeSend: function() {
						$("body").addClass("is-loading");
					},
					success: function(data) {
						if(data.status=='OK')
						{	
							$('#AdditionalBusinessForm')[0].reset();
							$('#AdditionalBusinessModal').modal('hide');
							var currentURL = window.location.href;
							pageURL = currentURL.replace(/^.*[\\\/]/, '');
							if (pageURL == "edit-organisationdetail.php" || pageURL.indexOf("edit-organisationdetail.php") != -1) {
									getBusinessPlace();
									
									$("body").removeClass("is-loading");
									Toast.fire({
										icon: 'success',
										title: data.message
									});
							} else {
								availableDispatchFrom.push({
									value: data.additionalbusinessdetail_id,
									name: data.orgname,
								});
								 getDispatchFrom(data.additionalbusinessdetail_id);
							}
						}
						else
						{
							$("body").removeClass("is-loading");
							errorMessage(data.message,'','','error');
						}
					},
					complete: function() {
						
					}
				});
	});	
	
});	

function getDispatchFrom(id=''){
	var dispatch_options = '';
	var checkgetData = 0;
	var dispatch_deleted = false;
	for (var i = 0; i < availableDispatchFrom.length; i++) {
		if (availableDispatchFrom[i].value != id && dispatchOrgname != "") {
			dispatch_deleted = true;
		}else{
			dispatch_deleted = false;
			break;
		}
	}

	if(dispatch_deleted == true){
		availableDispatchFrom.push({
			value: id,
			name: dispatchOrgname,
		});
	}
	
	$.each(availableDispatchFrom, function (i,dispatch) {
		var selectVal = '';
		if(dispatch.value == id){
			selectVal = 'selected=selected';
		}
		checkgetData = (dispatch.value != '')?1:0;
		dispatch_options = dispatch_options + '<option value="'+dispatch.value+'" '+selectVal+' >'+dispatch.name+'</option>';
	});
	if(checkgetData == 1){
		$('#dispatch_address').html(dispatch_options);
		$('#dispatch_address').change();
	}else{
		$('#dispatch_detail_drawer').removeClass('open_dis_drwawer');
	}

}




$('#dispatch_address').change(function(){
	if($(this).val() != ''){
		$.ajax({
			url: 'ajaxcall.php',
			type: 'POST',
			data:{action:'getsinglebusinessplace',id:$(this).val()},
			ContentType : 'application/json',
			dataType: 'json',
			success: function(data) {
				if(data.status=='OK')
				{	
					$('#dispatchGstin').val(data.gstin);
					$('#dispatchAdd').val(1);
					$('#dispatchOrgname').val(data.orgname);
					$('#dispatchName').val(data.name);
					$('#dispatchPhone').val(data.phone);
					$('#dispatchEmail').val(data.email);
					var address = '';
					if(data.name != ''){
						address += data.name +'<br>';
					}
						address += data.address1;
					if(data.address2 != ''){
						address += '<br>'+data.address2;
					}
					address += '<br>'+data.city;
					if(data.state != ''){
						address += ', '+data.state;
					}
					address += ', '+data.country;
					if(data.pincode != ''){
						address += ' - '+data.pincode;
					}
					$('.dispatchAddress').html(address);
					$('#dispatchAddress1').val(data.address1);
					$('#dispatchAddress2').val(data.address2);
					$('#dispatchPincode').val(data.pincode);
					$('#dispatchCity').val(data.city);
					$('#dispatchCountry').val(data.country);
					$('#dispatchState').val(data.state);
					if($('#dispatch_detail_drawer #dispatch_address').val != undefined && $('#dispatch_detail_drawer #dispatch_address').val != ''){
						getDispatchDistance();
					}

				}
				
			},
		});
	}else{
		$('.dispatchAddress').text('-');
		$('#dispatch_detail_drawer input[type="hidden"]').val('');
		$('#dispatchAdd').val(0);
		if($('#dispatch_detail_drawer #dispatch_address').val != '' && $('#dispatch_detail_drawer #dispatch_address').val != undefined){
			getDispatchDistance();
		}
	}
});

getDispatchFrom($('#dispatch_address').data('id'));

function getDispatchDistance(){
	var SameShippingAdd = $('#SameShippingAdd:checked').val();
	if($('#dispatch_detail_drawer #dispatch_address option').length > 0 && $('#dispatch_detail_drawer #dispatch_address').val() != ''){
		var data = '';
		if(SameShippingAdd == 'on'){
			var org_pincode = $('#dispatchPincode').val();
			var pincode = $('#cmp_pincode').val();
			var state = $('#hidden-invoice-state').val();
			data = {
				action: 'dist_apicall',
				from: org_pincode,
				to: pincode,
				tocookie: org_pincode + pincode + state,
			}
		}else{
			var org_pincode = $('#dispatchPincode').val();
			var pincode = $('#shippingPincode').val();
			var state = $('#shippingState').val();
			data = {
				action: 'dist_apicall',
				from: org_pincode,
				to: pincode,
				tocookie: org_pincode + pincode + state,
			}
		}


		if(data != '' && org_pincode != '' && pincode != '' && 
			!(companyid == $("#customers").val() && dispatchName == $("#dispatchName").val() && shippingName == $("#shippingName").val())){
			$.ajax({
				type: 'POST',
				data: data,
				url: "ajaxcall.php",
				ContentType: 'application/json',
				dataType: 'json',
				beforeSend: function() {
					$("body").addClass("is-loading");
				},
				success: function(data) {
					if (data.status == 'OK') {
						$('#shipping_distance_eway').val(data.dist_apicall);
					} else {
						if(data.errorTitle)
						{
							var errTitle = data.errorTitle;
						}
						else{
							var errTitle = 'Error';
						}
						errorMessage('',errTitle,data.data,'error');
						$("body").removeClass("is-loading");
					}
				},
				complete: function() {

				}
			});
		}else{
			$('#shipping_distance_eway').val($('#shipping_distance_eway1').val());
		}
	}
}


</script>


<!-- Modal -->
<div id="PreviousPriceModal" class="popup_right_slider modal fade" role="dialog" style="display: none;">
	<div class="modal-dialog">
			<!-- Modal content-->
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="btn btn-default btn_close" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg></button>
					<h4 class="modal-title">Price History</h4>
				</div>
				<div class="modal-body">
					
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg>Close</button>
				</div>
			</div>
	</div>
</div><!-- Modal -->
<div id="PreviousPriceModal" class="popup_right_slider modal fade" role="dialog" style="display: none;">
	<div class="modal-dialog">
			<!-- Modal content-->
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="btn btn-default btn_close" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg></button>
					<h4 class="modal-title">Price History</h4>
				</div>
				<div class="modal-body">
					
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg>Close</button>
				</div>
			</div>
	</div>
</div><script type="text/javascript">
function confirm_rev_charges(callback){
	if(rev_charge_alert == 1){

		var rev_charge = $(".reverse_Charge").val();
		var disabled = $(".reverse_Charge").attr("disabled");

		if(rev_charge == "1" && disabled == undefined){
			Swal.fire({
				title: 'Reverse Charge Applied',
				text:'You are about to create an invoice with a reverse charge applied. Would you like to proceed?',
				icon: 'warning',
				showCancelButton: true,
				confirmButtonColor: '#3085d6',
				cancelButtonColor: '#ececec',
				confirmButtonText: 'Yes, Proceed',
				cancelButtonText: 'Cancel',
				customClass: {
	                cancelButton: 'recodeCancel-btn'
	            },
				reverseButtons: true
			}).then((result) => {
			if (result.isConfirmed) {
				callback(true);
			}else{
				$(".reverse_Charge").val(0);
				callback(true);
			}
			});
		}else{
			callback(true);
		}
	}else{
		callback(true);
	}
	
};

function extractOperators(formula, placeholder) {
    var regex = new RegExp(`([^\\s\\d{}]+)?\\s*\\{\\{${placeholder}\\}\\}\\s*([^\\s\\d{}]+)?`);
    var match = formula.match(regex);
    var before = match && match[1] ? match[1].trim() : null;
    var after = match && match[2] ? match[2].trim() : null;
    return { before, after };
}

function replacePlaceholders(formula, placeholders) {
    [placeholders].forEach(placeholder => {
        var operators = extractOperators(formula, placeholder);
        if (operators.before === '+' || operators.before === '-' || operators.after === '+' || operators.after === '-') {
            var regex = new RegExp(`\\{\\{${placeholder}\\}\\}`, 'g');
            formula = 0;
        } else if (operators.before === '*' || operators.before === '/' || operators.after === '*' || operators.after === '/') {
            var regex = new RegExp(`\\{\\{${placeholder}\\}\\}`, 'g');
            formula = 1;
        }
    });
    return formula;
}

function evaluateExpression(expression) {
    // Allowed characters: digits, +, -, *, /, ., and spaces
    let allowedChars = /^[0-9+\-*/.() ]*$/;

    if (!allowedChars.test(expression)) {
        throw new Error("Invalid characters in expression");
    }

    // Use Function constructor to evaluate safely
    return new Function('return ' + expression)();
}

function decimalToFraction(decimal) {
    let decimalStr = decimal.toString();
    if (decimalStr.indexOf('.') === -1) {
        return new algebra.Fraction(parseInt(decimal), 1);
    }

    let decimalParts = decimalStr.split('.');
    let decimalPlaces = decimalParts[1].length;
    let numerator = parseInt(decimalParts.join(''));
    let denominator = Math.pow(10, decimalPlaces);

    return new algebra.Fraction(numerator, denominator);
}

function reverseCalculationFormula(formula,total,quantity,price,discount,custom1,custom2,custom3,custom) {
	if(formula.indexOf('|') != -1){
		var parts = formula.split('|').map(part => part.trim());
		formula = parts[parts.length - 1]; 
	}
    var rightSide = formula.replaceAll('{{','').replaceAll('}}','');
    rightSide = rightSide.replace('custom1', custom1)
                             .replace('custom2', custom2)
                             .replace('custom3', custom3)
                             .replace('discount', discount)
    if(custom == 'price'){
    	rightSide = rightSide.replace('quantity', quantity);
    }                     

    if(custom == 'quantity'){
    	rightSide = rightSide.replace('price', price);
    }                         
                             
    rightSide = (math.simplify(rightSide)).toString();
    let leftSide = new algebra.Expression(decimalToFraction(total));
    var equation = new algebra.Equation(leftSide, algebra.parse(rightSide));
    var resultText = '';
    try {
        var result = equation.solveFor(custom);
        resultText = evaluateExpression(result.toString());
    } catch (err) {}
    return resultText;
}


function getAllUOMAutoComplete($uomName) {
    $uomName.autocomplete({
        source: autoUOMList,
        change: function(event, ui) {
            var $targetparnt = $(this).parents(".product-item-row");
            if (ui.item == null || ui.item == undefined) {
                var currentVal = $(this).val();
                $targetparnt.find(".uom").val(currentVal);
                $targetparnt.find(".hidden-item-product-uom").val(currentVal);
            } else {
                $targetparnt.find(".uom").val(ui.item.value);            
                $targetparnt.find(".hidden-item-product-uom").val(ui.item.value);            
            }
        },
        select: function(event, ui) {
            var $targetparnt = $(this).parents(".product-item-row");
            $targetparnt.find(".uom").val(ui.item.value);            
            $targetparnt.find(".hidden-item-product-uom").val(ui.item.value);            
            return false;
        },
        minLength: 0
    }).focus(function() {
        $(this).autocomplete("search");
    }).on('input', function() {
        var currentVal = $(this).val();
        var $targetparnt = $(this).parents(".product-item-row");
        $targetparnt.find(".uom").val(currentVal);
        $targetparnt.find(".hidden-item-product-uom").val(currentVal);
    });
}


function fetchUOMData($uomName,product_id, price, base_unit) {
    return new Promise((resolve, reject) => {
    	 $.ajax({
            type: 'POST',
            url: "ajaxcall.php",
            dataType: "json",
            data: {
                action: 'getUOM',
                product_id: product_id,
                price: price,
                base_unit: base_unit
            },
            beforeSend: function () {
                $("body").removeClass("is-loading");
            },
            success: function (data) {
                if (data.uomdata && data.uomdata.length > 0) {
                	$uomName.parents(".product-item-row").find(".uom").attr('disabled',false);
					$uomName.parents(".product-item-row").find(".hidden-item-product-uom-rates").val(1);
                    resolve(true);
                } else {
                    resolve(false);
                }
            },
            error: function (xhr, status, error) {
                $("body").removeClass("is-loading");
                reject(false);
            }
        });
    });
}


function getUOMAutoComplete($uomName,product_id,price,base_unit){
	let staticValueDisplayed = false;
	fetchUOMData($uomName,product_id,price,base_unit)
    .then((result) => {
    	 if (result) {
        	$uomName.autocomplete({
				source: function( request, response ) {
					$.ajax({
			          type:'POST',	
			          url: "ajaxcall.php",
			          dataType: "json",
			          data: {
			            q: request.term,action:'getUOM',product_id:product_id,price:price,base_unit:base_unit
			          },
			          beforeSend: function() {
					        $("body").removeClass("is-loading");
					  },
			          success: function( data ) {
			          	if(data.uomdata.length > 1){
			          		response( data.uomdata );
			          	}
			          }
			        });
			      },
			    select: function( event, ui ) {
					var $targetparnt = $(this).parents(".product-item-row");
					var price = parseFloat($($targetparnt).find(".rate").attr('data-rate-val'));
					var avilableqty = parseFloat($($targetparnt).find(".product-quantity-available").attr('qty-avl'));
					var oldqtymax = parseFloat($($targetparnt).find(".quantity" ).attr('oldqtymax'));
					var productuomrates = parseFloat($($targetparnt).find(".hidden-item-product-uom-rates").val());
					var uom_rates = parseFloat(ui.item.uom_rates);
					price = (price/ui.item.uom_rates).toFixed(price_decimal_rounding_by);		
					if(!(ui.item.uom_rates == 1 && oldqtymax != undefined ) && $($targetparnt).find(".quantity" ).attr('availableqnt') == undefined){
						$($targetparnt).find(".quantity" ).attr('availableqnt',avilableqty);
						avilableqty2 = avilableqty.toFixed(quantity_decimal_rounding_by);
					}else{
						avilableqty2 = parseFloat($($targetparnt).find(".quantity" ).attr('availableqnt')).toFixed(quantity_decimal_rounding_by);
					}
					let qntavl = (ui.item.uom_rates == 1 && oldqtymax != undefined ) ? oldqtymax : ((avilableqty*ui.item.uom_rates)/productuomrates);	
					avilableqty = (qntavl).toFixed(quantity_decimal_rounding_by);	
					$($targetparnt).find(".hidden-item-product-uom" ).val( ui.item.label);			
					$($targetparnt).find(".uom" ).val( ui.item.label);			
					$($targetparnt).find(".hidden-item-product-uom-rates" ).val( ui.item.uom_rates);			
					$($targetparnt).find(".rate" ).val(price);
					if (!isNaN(avilableqty) && avilableqty !== "NaN") {
					
						if(ui.item.base_unit != ui.item.value){
							$($targetparnt).find(".product-quantity-available" ).text(avilableqty+" "+ui.item.value).attr('qty-avl',qntavl);
							$($targetparnt).find(".product-quantity-available-secondery" ).text(avilableqty2+" "+ui.item.base_unit);
							
						}else{
							$($targetparnt).find(".product-quantity-available" ).text(avilableqty+" "+ui.item.value).attr('qty-avl',qntavl);
							$($targetparnt).find(".product-quantity-available-secondery" ).text("");
						}
					}
					$($targetparnt).find(".quantity" ).attr('qtymax',avilableqty);
					UpdateCalculations();
					return false;
				}, minLength:0
			}).focus(function(){            
			        $(this).autocomplete("search");
			})
			.autocomplete("instance")._renderItem = function (ul, item) {
				var base_unit = item.base_unit;
				var secoundry_unit = item.label;
				var uom_rates = item.uom_rates;
				
				var appendDiv = '<div class="table">';
			    appendDiv += `<div class="row">
			    				<div class="cell"><strong>${secoundry_unit}:</strong> ${uom_rates}</div>
			    			 </div>`;
				$("<li>")
			        .append(appendDiv)
			        .appendTo(ul);

			    return ul.children().last();    
			  };
	        }else{
	        	$($uomName).parents(".product-item-row").find(".uom").attr('disabled',true);
	        } 
    })
    .catch((error) => {
        console.error("Error or no data:", error);
    });
		
	
}
$(document).ready(function() {
  $(window).on('scroll', function() {
		var headerButtons = $('.header_buttons');
		var formActions = $('.form-actions-floating-invoice');
		var widgetContentRow = $('.widget-content .row');
		if(widgetContentRow.length > 0 && $(this).scrollTop() > widgetContentRow.offset().top){
			formActions.removeClass('show');
		}else if (headerButtons.length > 0 && $(this).scrollTop() > headerButtons.offset().top) {
			formActions.addClass('show');	
		} else {
			formActions.removeClass('show');
		}
	});
	
	$('#dropdown-toggle').on('click', function() {
		$('.form-actions-invoice').toggleClass('expanded');
	});
  $(document).on('click focusin change', function(event) {
    if (!$(event.target).closest('.form-actions-invoice, #dropdown-toggle').length) {
        $('.form-actions-invoice').removeClass('expanded');
    } 
  });
});
function checkValidLimit(callback) {
    var grand_total = parseFloat($("#grand_total").val()) || 0;
    var oldval_grand_total = parseFloat($("#grand_total").data('oldval')) || 0;
    var c_limit_amount = parseFloat($(".c_limit_amount").val()) || 0;
    var c_limit_amount_tmp = parseFloat($(".c_limit_amount").val());
    var c_outstanding_amount = parseFloat($(".c_outstanding_amount").val()) || 0;
	if(c_limit_amount!="" && c_limit_amount!=null){


    if (c_outstanding_amount < 0) {
        c_outstanding_amount = Math.abs(c_outstanding_amount);
        c_limit_amount += c_outstanding_amount * 2;
    }
    var newOutstandingAmount = c_outstanding_amount - oldval_grand_total + grand_total;
    if (newOutstandingAmount > c_limit_amount && grand_total!=0 && grand_total!='') {
        let formattedAmount = new Intl.NumberFormat('en-IN').format(c_limit_amount_tmp);
        Swal.fire({	
            title: 'Credit limit exceeded',
            text: 'The customer’s credit limit of ' + formattedAmount + ' has been exceeded. Do you still want to continue saving the invoice?',
            icon: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#3085d6',
            cancelButtonColor: '#d33',
            confirmButtonText: 'Continue',
            cancelButtonText: 'Cancel',
            customClass: {
                cancelButton: 'recodeCancel-btn'
            },
            reverseButtons: true
        }).then((result) => {
            if (result.isConfirmed) {
                return callback(true);
            } else {
                return callback(false);
            }
        });
    } else {
        return callback(true);
    }
}
	else{
		return callback(true);
	}
}

function setValueForCustomColumnField(target,arr){
	let [enable_custom_column_formula,custom_column_formula,custom_column_formula_for,is_transport,quantity,rate,DiskRs,mrp,cess,cess_amount,row_total,customfield1,customfield2,customfield3,total_custom_column1,total_custom_column2,total_custom_column3,customflag1,customflag2,customflag3] = arr;
            $(target).find('.customfield1, .customfield2, .customfield3').on('input', function () {
                let cc_value = $(this).val();
                if (cc_value.charAt(cc_value.length - 1) !== "." && custom_column_rounding_by > 0 && cc_value.includes('.')) {
                    cc_value = cc_value.substring(0, cc_value.indexOf('.') + 1 + custom_column_rounding_by);
                    $(this).val(cc_value);
                } else if (custom_column_rounding_by == 0 && cc_value.includes('.')) {
                    cc_value = cc_value.substring(0, cc_value.indexOf('.') + 1 + custom_column_rounding_by);
                    $(this).val(cc_value);
                } else {
                    cc_value = parseFloat(cc_value);
                }
            });
			var changeCustom = true;
			var customfield1Value = customfield2Value = customfield3Value = '';
			var setcustomfield1Value = setcustomfield2Value = setcustomfield3Value = '';
			var setcustomfield1Val = setcustomfield2Val = setcustomfield3Val = '';

			if($(target).find( ".customfield1" ).length > 0 && $(target).find('[name="customfield1[]"]').val() == ''){
				customfield1Value = $(target).find( ".customfield1" ).attr('default-value');
				if(customfield1Value != '' && $.inArray(customfield1Value, ['{get_purchase_price}','{get_sell_price}']) == -1){
					$(target).find('[name="customfield1[]"]').val(customfield1Value);
					customfield1.attr('data-customfield1',customfield1Value);
					changeCustom = true;
				}
			}
			if($(target).find( ".customfield2" ).length > 0 && $(target).find('[name="customfield2[]"]').val() == ''){
				customfield2Value = $(target).find( ".customfield2" ).attr('default-value');
				if(customfield2Value != '' && $.inArray(customfield2Value, ['{get_purchase_price}','{get_sell_price}']) == -1){
					$(target).find('[name="customfield2[]"]').val(customfield2Value);
					customfield2.attr('data-customfield2',customfield2Value);
					changeCustom = true;
				}
			}
			if($(target).find( ".customfield3" ).length > 0 && $(target).find('[name="customfield3[]"]').val() == ''){
				customfield3Value = $(target).find( ".customfield3" ).attr('default-value');
				if(customfield3Value != '' && $.inArray(customfield3Value, ['{get_purchase_price}','{get_sell_price}']) == -1){
					$(target).find('[name="customfield3[]"]').val(customfield3Value);
					customfield3.attr('data-customfield3',customfield3Value);
					changeCustom = true;
				}
			}
			
			if($(target).find('[name="customfield1[]"]').val() != undefined && $(target).find('[name="customfield1[]"]').val() != '' && custom_column_formula.indexOf('custom1') != -1){ 
				if(customfield1.attr('data-customfield1') != undefined && customfield1.attr('data-customfield1') != customfield1.val()){
					setcustomfield1Value = customfield1Value = customfield1.val();
					changeCustom = true;
				}else{
					 if(customfield1.attr('data-customfield1') != setcustomfield1Val){
						setcustomfield1Value = customfield1Value = customfield1.attr('data-customfield1');	
					}else{
						setcustomfield1Value = customfield1.attr('data-customfield1');	
						customfield1Value = replacePlaceholders(custom_column_formula, 'custom1');
					}
				}
			}else{
				if(customflag1 == false){
					if(!isNaN(customfield1.val())){
						customfield1Value = customfield1.val();
					}else{
						customflag1 = true;
					}
				}
			}

			if($(target).find('[name="customfield2[]"]').val() != undefined && $(target).find('[name="customfield2[]"]').val() != '' && custom_column_formula.indexOf('custom2') != -1){ 
				if(customfield2.attr('data-customfield2') != undefined && customfield2.attr('data-customfield2') != customfield2.val()){
					setcustomfield2Value = customfield2Value = customfield2.val();
					changeCustom = true;
				}else{
					if(customfield2.attr('data-customfield2') != setcustomfield2Val){
						setcustomfield2Value = customfield2Value = customfield2.attr('data-customfield2');	
					}else{
						setcustomfield2Value = customfield2.attr('data-customfield2');	
						customfield2Value = replacePlaceholders(custom_column_formula, 'custom2');
					}
				}
			}
			else{
				if(customflag2 == false){
					if(!isNaN(customfield2.val())){
						customfield2Value = customfield2.val();
					}else{
						customflag2 = true;
					}
				}
			}
			if($(target).find('[name="customfield3[]"]').val() != undefined && $(target).find('[name="customfield3[]"]').val() != '' && custom_column_formula.indexOf('custom3') != -1){ 
				if(customfield3.attr('data-customfield3') != customfield3.val()){
					setcustomfield3Value = customfield3Value = customfield3.val();
					changeCustom = true;
				}else{
					if(customfield3.attr('data-customfield3') != setcustomfield3Val){
						setcustomfield3Value = customfield3Value = customfield3.attr('data-customfield3');	
					}else{
						setcustomfield3Value = customfield3.attr('data-customfield3');	
						customfield3Value = replacePlaceholders(custom_column_formula, 'custom3');
					}
				}
			}
			else{
				if(customflag3 == false){
					if(!isNaN(customfield3.val())){
						customfield3Value = customfield3.val();
					}else{
						customflag3 = true;
					}
				}
			}
			var customfieldQty = $(target).find(".quantity").attr('data-qty-val'); 
			if($(target).find(".quantity").attr('data-qty-val') != quantity){
				changeCustom = true;
				customfieldQty = quantity;
			}
		
			var	customfieldRate = $(target).find(".rate").attr('data-rate-val');
			if($(target).find(".rate").attr('data-rate-val') != rate){
				changeCustom = true;
				customfieldRate = rate;
			}
			
			var	customfieldMrp = $(target).find(".mrp").attr('data-mrp-val');
			if($(target).find(".mrp").attr('data-mrp-val') != mrp){
				changeCustom = true;
				customfieldMrp = mrp;
			}

			var	customfieldTaxable = $(target).find(".taxable_line_value").attr('data-taxable-val');
			if($(target).find(".taxable_line_value").attr('data-taxable-val') != row_total && custom_column_formula_for == 'taxable'){
				changeCustom = true;
			}

			var	setcustomfieldGst = $(target).find("[name='igst_rate[]']").attr('data-gst-val');
			var customfieldGst = setcustomfieldGst;
			if($(target).closest('#document-item-list.tbl_igst').length != 0 && setcustomfieldGst != $(target).find(".igst").val()){
				changeCustom = true;
				customfieldGst = setcustomfieldGst = ($(target).find(".igst").val() == '' || $(target).find(".igst").val() == 0) ? '0.0000' : parseFloat($(target).find(".igst").val());
			}
			if($(target).closest('#document-item-list.tbl_cgst').length != 0 && setcustomfieldGst != $(target).find(".cgst_select").val()){
				changeCustom = true;
				customfieldGst = setcustomfieldGst = ($(target).find(".cgst_select").val() == '' || $(target).find(".cgst_select").val() == 0) ? '0.0000' : parseFloat($(target).find(".cgst_select").val()) * 2;
			}
			var customVal = 0;
			var workingformula = false;

			if(changeCustom && enable_custom_column_formula == 1 && custom_column_formula != '' && (customfield1Value || customfield2Value || customfield3Value || customfieldGst)){

				if(custom_column_formula.indexOf('|') != -1){
					var parts = custom_column_formula.split('|').map(part => part.trim());
					var i=0;
					parts.forEach(formulaPart => {
						i++;
						if(parts.length != i){
							var innerparts = formulaPart.split('=').map(innrpart => innrpart.trim());
					        var apply1field = innerparts[0].replace(/{{|}}/g, '');

					        var innerFormula = innerparts[1]
					            .replaceAll('{{quantity}}', customfieldQty)
					            .replaceAll('{{price}}', customfieldRate)
					            .replaceAll('{{mrp}}', customfieldMrp)
					            .replaceAll('{{discount}}', DiskRs)
					            .replaceAll('{{gst}}', customfieldGst)
					            .replaceAll('{{cess}}', cess)
					            .replaceAll('{{cess amount}}', cess_amount)
					            .replaceAll('{{custom1}}', customfield1Value)
					            .replaceAll('{{custom2}}', customfield2Value)
					            .replaceAll('{{custom3}}', customfield3Value);

					        try {
						        var innerSolFormula = evaluateExpression(innerFormula);
						        var custominnerVal = parseFloat(innerSolFormula);

						        switch (apply1field) {
						            case 'custom1': customfield1Value = custominnerVal; $(target).find(".customfield1").val(custominnerVal); break;
						            case 'custom2': customfield2Value = custominnerVal; $(target).find(".customfield2").val(custominnerVal); break;
						            case 'custom3': customfield3Value = custominnerVal; $(target).find(".customfield3").val(custominnerVal); break;
						            case 'discount': DiskRs = custominnerVal; $(target).find(".disc").val(custominnerVal); break;
						            case 'quantity': customfieldQty = custominnerVal; $(target).find(".quantity").val(custominnerVal); break;
						            case 'price': customfieldQty = custominnerVal; $(target).find(".rate").val(custominnerVal); break;
						            case 'mrp': customfieldQty = custominnerVal; $(target).find(".mrp").val(custominnerVal); break;
						        }
					        } catch (e) {}
						}
				    });

					custom_column_formula = parts[parts.length - 1]; 
				}

				var customFormula = custom_column_formula;
				customFormula = customFormula.replaceAll('{{quantity}}', customfieldQty)
											 .replaceAll('{{price}}', customfieldRate)
											 .replaceAll('{{mrp}}', customfieldMrp)
											 .replaceAll('{{discount}}', DiskRs)
											 .replaceAll('{{gst}}', customfieldGst)
											 .replaceAll('{{cess}}', cess)
					            			 .replaceAll('{{cess amount}}', cess_amount)
											 .replaceAll('{{custom1}}', customfield1Value)
											 .replaceAll('{{custom2}}', customfield2Value)
											 .replaceAll('{{custom3}}', customfield3Value);
				
				try {
					var customFormula = evaluateExpression(customFormula);
					if(!isNaN(customFormula))
					{
						workingformula = true;
						customVal = parseFloat(customFormula);
						customfield1.attr('data-customfield1',setcustomfield1Value);
						customfield2.attr('data-customfield2',setcustomfield2Value);
						customfield3.attr('data-customfield3',setcustomfield3Value);

						$(target).find("[name='igst_rate[]']").attr('data-gst-val',setcustomfieldGst);
						$(target).find("[name='mrp[]']").attr('data-mrp-val',customfieldMrp);
						

						var setcustomVal = parseFloat(customVal).toFixed(custom_column_rounding_by);
						if((is_transport == 1 || is_transport == "1") && custom_column_formula_for == 'quantity'){
							setcustomVal = 0;
						}					
						$(target).find("."+custom_column_formula_for).val(setcustomVal);

						if($.inArray(custom_column_formula_for, ['customfield1','customfield2','customfield3'])){
							switch(custom_column_formula_for){
								case 'customfield1': customfield1Value = setcustomVal; break;	
								case 'customfield2': customfield2Value = setcustomVal; break;	
								case 'customfield3': customfield3Value = setcustomVal; break;
							}
						}

						total_custom_column1 += parseFloat(customfield1Value);
						total_custom_column2 += parseFloat(customfield2Value);
						total_custom_column3 += parseFloat(customfield3Value);
					}
				} catch (e) {}
				
				if(custom_column_formula_for == 'taxable' && customVal){
					$(target).find(".taxable_line_value").attr('data-taxable-val',customVal);
				}
			}else{
				total_custom_column1 += parseFloat(customfield1Value);
				total_custom_column2 += parseFloat(customfield2Value);
				total_custom_column3 += parseFloat(customfield3Value);
			}
			if(!workingformula){
				switch(custom_column_formula_for){
					case 'quantity': customVal = quantity; break;	
					case 'rate': customVal = rate; break;	
					case 'taxable': customVal =	row_total; break;
				}
			}
			return [total_custom_column1,total_custom_column2,total_custom_column3,customVal,customflag1,customflag2,customflag3];


}
	$('body').on('click','#PreviousPriceModal .ViewPrintModal', function(){
		var iframeSrc  =  $(this).attr("data-baselink");
        if(iframeSrc != ""){
            $('#PrintInvoiceModal').modal('show').on('shown', function() {
                $("#PrintInvoiceModal iframe").attr("src", iframeSrc );
                $("#PrintInvoiceModal .modal-content").removeClass("is-loading");
                if(window.innerHeight < $('#PrintInvoiceModal iframe').height())
                {
                    $('#PrintInvoiceModal, #PrintInvoiceModal #Invoice_iframe').height(window.innerHeight);
                }
            });
        }
    });
    
    $(document).on("click", "#PrintInvoiceModal .btn_close", function() {
	    $('#PrintInvoiceModal').animate({
	        scrollLeft: window.innerWidth
	    }, 500, function() {
	        $('#PrintInvoiceModal').modal('hide');
	    });
	});
function checkGSTINrate(callback) {
	var state_gst_no = true;
	var noGstInvoiceTypes = [
		"ExportInvoiceWithoutIGST",
		"SEZInvoiceWithoutIGST",
		"ExportCreditNoteWithoutIGST",
		"SEZCreditNoteWithoutIGST",
		"ExportDebitNoteWithoutIGST",
		"SEZDebitNoteWithoutIGST"
	];
	var row = [];
	var counter = 0;
	var title = "";
	var Message = "";
	var invoiceType = $('#hidden-invoice-country').val();
	var gst_no = ``;
	if(gst_no=="" || noGstInvoiceTypes.includes(invoiceType)){
		return callback(true);
	}
	else{
		$(".product-item-row").each(function(index,value){
			counter++;
			if(index != $(".product-item-row").length -1 ){
				var targetparnt =$(this)
				var pro_id = $(targetparnt).find('.hidden-item-product-id').val();
				if(pro_id==""){
					
					var hidden_item_product_igst = $(targetparnt).find('[name="igst[]"]').val();
					var hidden_item_product_cgst_sgst = $(targetparnt).find('[name="cgst_select"]').val();
					var igstField = $(targetparnt).find('[name="igst[]"]');
					if (!igstField.is(":visible") && (hidden_item_product_cgst_sgst==0 || hidden_item_product_cgst_sgst=="" || hidden_item_product_cgst_sgst==null)) {
						state_gst_no =false;
						row.push(counter);
					} else if(igstField.is(":visible") && (hidden_item_product_igst==0 || hidden_item_product_igst=="" || hidden_item_product_igst==null)){
						state_gst_no =false;
						row.push(counter);
					}	
					title = "GST Rate Is Zero";
					var rowNumbers = row.join(', '); 
					Message = 'The GST rate in rows ' + rowNumbers + ' is zero. Do you want to continue?';
				}
				else if(pro_id!=""){
					var hidden_item_product_igst = parseFloat($(targetparnt).find('[name="igst[]"]').val()) || 0;
					var hidden_item_product_cgst_sgst = parseFloat($(targetparnt).find('[name="cgst_select"]').val()) || 0;
					var old_product = parseFloat($(targetparnt).find('[name="igst[]"]').data('product-gst'));
					var igstField = $(targetparnt).find('[name="igst[]"]');
					hidden_item_product_cgst_sgst = hidden_item_product_cgst_sgst*2;
					var igst = old_product;
					if(igstField.is(":visible") && (hidden_item_product_igst!=igst)){
						state_gst_no =false;
						row.push(counter);
					}
					else if(!igstField.is(":visible") && (hidden_item_product_cgst_sgst!=old_product)){
							state_gst_no =false;
							row.push(counter);
					}
			
					title = "Mismatched GST Rate";
					var rowNumbers = row.join(', '); 
					Message = 'The GST rate selected in row  ' + rowNumbers + ' differs from the rate specified in the product master. Do you want to continue?';

				}
		}
		});
		if(!state_gst_no){
			
			Swal.fire({	
				title: title,
				text: Message,
				icon: 'warning',
				showCancelButton: true,
				confirmButtonColor: '#3085d6',
				cancelButtonColor: '#d33',
				confirmButtonText: 'Continue',
				cancelButtonText: 'Cancel',
				customClass: {
					cancelButton: 'recodeCancel-btn'
				},
				reverseButtons: true
			}).then((result) => {
				if (result.isConfirmed) {
					return callback(true);
				} else {
					return callback(false);
				}
			});
		}else{
			return callback(true);
		}
		return callback(false);
	}
}
function checkcurrencyrate(callback){
	var is_enabled = $(".currency-fields").css('display') !== 'none';
    if (!is_enabled) {
		return callback(true);
	}
		var selectedCurrencyText = $('.currency-fields .currency option:selected').text();
		var selectedCurrencyText_edit = $('.currency-fields input[name="currency"]').val();
		var currency_rate = parseFloat($(".currency-fields input[name='currency_rate']").val());
		if (currency_rate !== 1 && (selectedCurrencyText === "INR - Indian Rupee" || selectedCurrencyText_edit=='INR - Indian Rupee')) {
			Swal.fire({
					title: 'Currency Mismatch',
					text:'You have entered a currency conversion rate, but the selected currency is INR. Please verify your selection before proceeding',
					icon: 'warning',
					showCancelButton: true,
					confirmButtonColor: '#3085d6',
					cancelButtonColor: '#d33',
					confirmButtonText: 'Continue',
					cancelButtonText: 'Cancel',
					customClass: {
						cancelButton: 'recodeCancel-btn'
					},
					reverseButtons: true
			}).then((result) => {
				if (result.isConfirmed) {
					 return callback(true);
				}
			});
		}
		else{
			return callback(true);
		}	
	
}

var docTypeArr = ["ExportInvoice", "ExportInvoiceWithoutIGST", "ExportCreditNote", "ExportCreditNoteWithoutIGST", "ExportDebitNote", "ExportDebitNoteWithoutIGST"];

$(document).ready(function() {


	var currency = $('#currency').val();

	var duplicate_invoice = 0;
	var billing_session = 0;
	var invoice_type = $('#hidden-invoice-country').attr("data-value")

	if(billing_session && ((typeof enable_invoice_in_other_currency !== 'undefined' && enable_invoice_in_other_currency == 1 && currency != 'INR - Indian Rupee') || docTypeArr.includes(invoice_type))){
		var currency_old_rate = parseFloat($('#currency_rate').val()).toFixed(2)
		var curreny_code = $('#currency').val()
		
		if(!isNaN(currency_old_rate) && currency_old_rate > 0 && curreny_code.trim() !== "" && !duplicate_invoice){
			$.ajax({
                url:'ajaxcall.php',
                method: 'POST',
                data: { action : 'getCurrencyCurrentRate', country_code: curreny_code },
                success: function(data) {
                    if(data.status == 'OK')
                    {
                        var currency_current_rate = parseFloat(1 / data.country_rate).toFixed(2);
						if(currency_old_rate !== currency_current_rate){
							Swal.fire({
								title: "Currency Conversion Rate Updated",
								html: `The conversion rate has changed. The previous rate was <strong>${currency_old_rate + " " + data.country_code}</strong>, and the new rate is <strong>${currency_current_rate + " " + data.country_code}</strong>.<br>Would you like to update the conversion rate to the latest value?`,
								icon: "warning",
								showCancelButton: true,			
								reverseButtons: true,
								confirmButtonText: "Yes, Update Conversion Rate",
								cancelButtonText: "No",
							}).then((result) => {
                                if (result.isConfirmed) { $('#currency_rate').val(currency_current_rate).trigger('change'); }
							});
						}
                    }
                }
            });
		}
	}


paymenttermoption();

var term_index = $('.add_payment_term').closest('.smart_suggetion-main').find('.smart_suggestion_data tr').length ?? 0; 
$(document).on("click", ".add_payment_term", function (e) {
  var index = $(this).closest('.smart_suggetion-main').find('.smart_suggestion_data tr.genneral-disc-tr').length + 1;
  term_index++;
  if(index <= 5){
  var tc_add = `<tr class="genneral-disc-tr">
                  <td>
                    <div class="">
                    <label class="label-input"><input type="text" name="payment_term_label[]" value="" class="paymentterm" /></label>
                      <div class="cd-pricing-switcher">
                        <p class="fieldset">
                          <input type="radio"  class="payment_term_rupee" name="payment_term_${term_index}_rupee" value="1" id="payment_term_${term_index}_rupee-1" checked>
                          <label for="payment_term_${term_index}_rupee-1">Rs</label>
                          <input type="radio"  class="payment_term_rupee" name="payment_term_${term_index}_rupee" value="0" id="payment_term_${term_index}_rupee-0">
                          <label for="payment_term_${term_index}_rupee-0">%</label>
                          <span class="cd-switch"></span>
                        </p>
                      </div>
                    </div>
                  </td>
                  <td>
  				  	<div class="addmore-section">
						<a class="btn btn-danger btnremove-payment-term btnaddmoreoption" style=""><svg width="20" height="20"><use href="svg-icon/icons.svg#minus-svg-icon"></use></svg></a>
					</div>
                    <div class="total-controls">
                      <input type="text" class="decimal_numeric_only" name="payment_term_value[]" value="" maxlength="10"/>
                      <input type="hidden" name="payment_term_amount[]" value="" />
                      <input type="hidden" name="payment_term_rupee[]" value="1" />
                      <label class="payment_term_amount_label"></label>
					  <label type="text" name="currency_payment_term_amount_label" class="currency_payment_term_amount_label"></label>
                    </div>
                  </td>
				  
                </tr>`;

	$(this).closest('.smart_suggetion-main').find('.smart_suggestion_data table .payment-term-total-section').before(tc_add);
  	paymenttermoption();
  }
});

$(document).on("click", ".btnremove-payment-term", function (e) {
  $(this).closest("tr").remove();
  $('.add_payment_term').show();
  PaymentTermTrigger();
});

function paymenttermoption(){
	var avlPaymentTerm = [{value: "Advance",label: "Advance"},{value: "Payable",label: "Payable"},{value: "Pending",label: "Pending"}];
	$(".paymentterm").autocomplete({
		source: avlPaymentTerm,
		minLength:0
	}).focus(function(){
        $(this).autocomplete("search");
    });
}

if($('#payment_term_toggle').is(':checked')){
	$('.add_payment_term').show();
}else{
	$('.add_payment_term').hide();
}

$('#payment_term_toggle').on('change', function() {
	if(this.checked) {
	  $('#payment_term_toggle').closest('.smart_suggestion_checkbox').find('svg use').attr('href','svg-icon/icons.svg#minus-svg-icon');
	  $('.add_payment_term').show();
	} else {
	  $('#payment_term_toggle').closest('.smart_suggestion_checkbox').find('svg use').attr('href','svg-icon/icons.svg#plus-svg-icon');
	  $('.add_payment_term').hide();
	}
	$('#payment_term_toggle').closest('.smart_suggetion-main').find('.smart_suggestion_data').slideToggle();
});

$(document).on('change input',".payment_term_rupee,[name='payment_term_value[]']",function(e){
	var target = $(this).closest('tr');
	if ($(e.target).hasClass("payment_term_rupee")) {
		$(this).closest('tr').find('[name="payment_term_rupee[]"]').val($(this).val());
	}
	PaymentTermTrigger(target);
});

});


function PaymentTermTrigger(target=''){
	var i = 0;
	var total = 0;
	var balance = 0;
	var currencycode = getCurrencyCodeFromName();
	var currencysymbol = cur_symbol[currencycode];
	var currency_rate = $("#currency_rate").val();
	var rupeeSymbole = cur_symbol["INR"];

	$("[name='payment_term_value[]']").each(function(){
		i++;
		var term_value = ($(this).val()).trim();	
		if(term_value != '' && !isNaN(term_value)){
			var term_name = $(this).closest('tr').find('input[type="radio"]').attr('name');
			var checkedValue = $(this).closest('tr').find(`input[name='${term_name}']:checked`).val();
			var amount = term_value;
			if(checkedValue == 0){
				amount = parseFloat(($('#grand_total').val() * amount)/100).toFixed(price_decimal_rounding_by);
			}
			total += parseFloat(amount);
			$(this).closest('tr').find('[name="payment_term_amount[]"]').val(amount);
			$(this).closest('tr').find('.payment_term_amount_label').text(amount);
			$('.payment-term-section').find('.grand_term_total').val(total);
			$('.payment-term-section').find('.grand_term_total_lable').text(rupeeSymbole + " " + total.toFixed(price_decimal_rounding_by));			
			
			$(this).closest('tr').find('.currency_payment_term_amount_label').text('');
			$('.payment-term-section').find('.currency_grand_term_total_lable').text("");
			if(currencycode !== "INR"){
				$(this).closest('tr').find('.currency_payment_term_amount_label').text(number_format_indian(conver_amount_with_factor(amount, currency_rate), currencycode));
				$('.payment-term-section').find('.currency_grand_term_total_lable').text(currencysymbol + " " + number_format_indian(conver_amount_with_factor(total, currency_rate), currencycode));			
			}

			if(total > parseFloat($('#grand_total').val())){
				if(target != ''){
					amount = target.find('[name="payment_term_amount[]"]').val();
				}

				target = (target != '') ? target : $(this).closest('tr');
				target.find('[name="payment_term_value[]"]').val('');
				target.find('[name="payment_term_amount[]"]').val('');
				target.find('.payment_term_amount_label').text('');
				total -= amount;
				$('.payment-term-section').find('.grand_term_total').val(total);
				$('.payment-term-section').find('.grand_term_total_lable').text(rupeeSymbole + " " +(total).toFixed(price_decimal_rounding_by));			
				if(currencycode !== "INR"){
					target.find('.currency_payment_term_amount_label').text('');
					$('.payment-term-section').find('.currency_grand_term_total_lable').text(currencysymbol + " " + conver_amount_with_factor(total,currency_rate));
				}
				errorMessage('','The total of the payment terms exceeds the grand total.','','warning');
			}			
		}else{
			$(this).closest('tr').find('[name="payment_term_amount[]"]').val('');
			$(this).closest('tr').find('.payment_term_amount_label').text('');
			$(this).closest('tr').find('.currency_payment_term_amount_label').text('');
		}

	});

	balance = parseFloat($('#grand_total').val()) - $('.payment-term-section').find('.grand_term_total').val();
	$('.payment-term-section').find('.grand_term_balance').val(balance);
	$('.payment-term-section').find('.grand_term_balance_lable').text(rupeeSymbole + " " + balance.toFixed(price_decimal_rounding_by));	
	$('.payment-term-section').find('.currency_grand_term_balance_lable').text("");
	if(currencycode !== "INR"){
		var currency_balance = Math.round(conver_amount_with_factor(balance,currency_rate ) * 100) / 100;
		$('.payment-term-section').find('.currency_grand_term_balance_lable').text(currencysymbol+ " " + currency_balance);			
	}

	if($("[name='payment_term_value[]']").length == 0){
		$('.payment-term-section').find('.grand_term_balance_lable').text(parseFloat($('#grand_total').val()));
		if(currencycode !== "INR"){
			$('.payment-term-section').find('.currency_grand_term_balance_lable').text(currencysymbol+ " " + number_format_indian(conver_amount_with_factor(parseFloat($('#grand_total').val()),currency_rate), currencycode));			

		}
	}

	if(total == 0){
		$('.payment-term-section').find('.grand_term_total_lable').text(0);
		$('.payment-term-section').find('.currency_grand_term_total_lable').text("");
		if(currencycode !== "INR"){
			$('.payment-term-section').find('.currency_grand_term_total_lable').text(currencysymbol+ " " + 0);
		}
	}

}
$(document).ready(function () {
    var $autoCustomerField = $("#autoCustomerField");
	if ($autoCustomerField.length > 0) {
    	var $customers = $("#customers");
    	var $hiddenCompanyName = $("#hidden_companyname");

		function updateCustomerFields(item) {
			if (!item) return;
			var { label, value, companytype } = item;
			$autoCustomerField.val(label).attr("data-oldval", label);
			$customers.val(value).attr("data-type", companytype);
			$hiddenCompanyName.val(label);
			$autoCustomerField.trigger('change');
		}

		$autoCustomerField.autocomplete({
			source: function (request, response) {
				var term = request.term.toLowerCase();
				var results = availableCustomer.filter(item =>
					item.label.toLowerCase().includes(term)
				);
				response(results.slice(0, 500));
			},
			change: function (event, ui) {
				var inputVal = $autoCustomerField.val().trim().toLowerCase();
				if(inputVal != ''){
					var match = availableCustomer.some(item =>
						item.label.trim().toLowerCase() === inputVal
					);
		
					if (!match) {
						errorMessage('','Please select a valid customer from the list.');
						$autoCustomerField.val("");
						$customers.val("").attr("data-type", "");
						$hiddenCompanyName.val("");
						$customers.trigger('change');
					}
				}
			},
			select: function (event, ui) {
				if (ui.item) {
					updateCustomerFields(ui.item);
					$customers.trigger('change');
				}
				return false;
			},
			minLength: 0,
			open: function () {
				$(this).addClass("open");
			},
			close: function () {
				$(this).removeClass("open");
			}
		}).focus(function () {
			$(this).autocomplete("search").select();
		}).on("change", function () {
			if (!$(this).val().trim()) {
				$customers.val("").attr("data-type", "");
				$hiddenCompanyName.val("");
				$customers.trigger('change');
				
			}
		});

		var autocompleteInstance = $autoCustomerField.autocomplete("instance");

		autocompleteInstance._renderItem = function (ul, item) {
			var gst = item.gstno?.trim();
			var contact = item.contactno1?.trim();
			var address = item.address?.trim();

            var text1 = item.customer_text_1?.trim();
            var text2 = item.customer_text_2?.trim();
            var text3 = item.customer_text_3?.trim();

			var gstContactLine = gst && contact ? `${gst} | ${contact}` : gst || contact || '';
			var gstHtml = gstContactLine ? `<div style="font-weight: bold;">${gstContactLine}</div>` : '';
			var addressHtml = address ? `<div>${address}</div>` : '';

            var extraTexts = [text1, text2, text3].filter(Boolean).join(" | ");
            var extraTextHtml = extraTexts ? `<div>${extraTexts}</div>` : "";

			return $("<li>").append(`
				<div style="padding: 8px; border-bottom: 1px solid #eee;">
					<div style="font-weight: bold;" class="customer-name">${item.companyname}</div>
					<div class="cust-detail-div">
						${gstHtml}
						${addressHtml}
                        ${extraTextHtml}
					</div>
				</div>
			`).appendTo(ul);
		};
		autocompleteInstance._renderMenu = function (ul, items) {
			$(ul).addClass("span2 customer-autocomplete");
			items.forEach(item => this._renderItemData(ul, item));
		};
		var initialVal = $customers.val().trim();
		var match = availableCustomer.find(({ value }) => value == initialVal);
		if (match) {
			$autoCustomerField.val(match.label);
			updateCustomerFields(match);
			$customers.trigger('change');
		} else {
			$autoCustomerField.val("");
			$customers.val("").attr("data-type", "");
			$hiddenCompanyName.val("");
		}
	}
});


function updateCurrencyClass() {
	var invoiceType = $('#hidden-invoice-country').val();
    var currency = $('#currency').val();

    if (typeof enable_invoice_in_other_currency !== 'undefined' && enable_invoice_in_other_currency == 1) {
        if (!docTypeArr.includes(invoiceType) && currency === 'INR - Indian Rupee') {
			$('body').addClass('is-inr');
        } else {
			$('body').removeClass('is-inr');
        }
    }
}

$('#hidden-invoice-country, #currency').off('change').on('change', function () {
    updateCurrencyClass();
});

$(document).ready(function () {
    updateCurrencyClass();
	if (typeof checkValidDate === "function" && typeof isExpense == 'undefined')  {
		checkValidDate(false);
	}
});
function productRenderer(ul, item) {
    var hsn = item.hsn?.trim();
    var qty = inventory_enable?item.items_available?.trim():"";
    var uom = inventory_enable?item.uom?.trim():"";
    var barcode = item.barcode_no != null && item.barcode_no != 0 ? String(item.barcode_no).trim() : "";
    var code = item.product_code?.trim();
    var productcode_lbl = "Product Code";
    var enabeleproductcode = "0";
    const codeLine = [
        typeof code !== "undefined" && enabeleproductcode == 1 ? `${productcode_lbl??"Product Code"} : ${code || "-"}` : "",
        typeof hsn !== "undefined" ? `HSN: ${hsn || "-"}` : "",
      	barcode ? `Barcode: ${barcode || "-"}` : "",
      	qty ? `Qty.: ${qty} ${uom || ""}` : "",
    ].filter(Boolean).join(" | ");

    var codeHtml = codeLine ? `<div>${codeLine}</div>` : "";

    return $("<li>")
        .append(`
            <div style="border-bottom: 1px solid #eee;">
                <div style="font-weight: bold;" class="product-name">${item.label}</div>
                <div class="product-detail-div">
                    ${codeHtml}
                </div>
            </div>
        `)
        .appendTo(ul);
}

function applyRounding(value, method="") {
    switch (method) {
        case "floor":
            return Math.floor(value);
        case "ceil":
            return Math.ceil(value);
        default:
            return Math.round(value);
    }
}
function checkValidDate(showfocus=true){
	var IsValidDate = true;
	var datestr = $("#datepicker_bill").val();
	var checkDate = "";
	if(datestr != "")
	{
		checkDate =  parseDate(datestr);	
		var minDate = new Date(session_start, 3,1);
		var maxDate = new Date(session_end, 2,31);
		var validDate = (checkDate >= minDate && checkDate <= maxDate)?true:false;
		if(!validDate)
		{
			errorMessage('','Please Select Valid Document Date');
			IsValidDate = false;
			if(showfocus){
				$("#datepicker_bill").focus();
			}
		}
	}
	else
	{
		errorMessage('','Please Select Valid Document Date');
		IsValidDate = false;
		$("#datepicker_bill").focus();
	}
	return IsValidDate;
}
</script>

<div id="CustomFieldModal" class="popup_right_slider modal fade " role="dialog" style="display: none;">
	<div class="modal-dialog">


		<form class="form-horizontal customfiledform custom-field-form" id="customfiledform" >
			<!-- Modal content-->
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="btn btn-default btn_close" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg></button>
					<h4 class="modal-title">Custom Field</h4>
				</div>
				<div class="modal-body">
						<div class="widget-content">
								<fieldset>
									<div id="PrintOptions">	
													                                        	<div id="SaleInvoice" class="custom-filed-section">
													<table class="table custom_field_table" data-footable data-toggle-column="last">
															<thead>
																<tr>
																	<th style="width:15px">No.</th>
																	<th class="custom-field-checkbox-label">Type</th>
																	<th data-breakpoints="md">Status</th>
																	<th data-breakpoints="md">Print</th>
																	<th data-breakpoints="md">Required</th>
																	<th data-breakpoints="md">Name</th>
																</tr>
															</thead><!-- /thead -->
															<tbody>
															<tr>
																<td >1</td>
																<td><div class="d-flex"><svg width="20" height="20"><use href="svg-icon/icons.svg#cursor-svg-icon"></use></svg> Text</div>
																<td>
																	<div class="custom_field_align_right">    
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="enable_lrNoLable" name="enable_lrNoLable" class="checkbox-toggle" checked>
																			<label for="enable_lrNoLable" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<div class="custom_field_align_right">
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="print_lrNoLable" name="print_lrNoLable" class="checkbox-toggle" checked >
																			<label for="print_lrNoLable" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<div class="custom_field_align_right">
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="required_lrNoLable" name="required_lrNoLable" class="checkbox-toggle"   >
																			<label for="required_lrNoLable" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<input type="text" value="L.R. No." name="lrNoLable" id="lrNoLable" class="span4" placeholder="Enter Field 1 Label"  maxlength="50"  >
																</td>
															</tr>

															<tr>
																<td >2</td>
																<td><div class="d-flex"><svg width="20" height="20"><use href="svg-icon/icons.svg#cursor-svg-icon"></use></svg> Text</div>
																<td>
																	<div class="custom_field_align_right">    
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="enable_ewaybill_no" name="enable_ewaybill_no" class="checkbox-toggle" checked>
																			<label for="enable_ewaybill_no" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<div class="custom_field_align_right">
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="print_ewaybill_no_lable" name="print_ewaybill_no_lable" class="checkbox-toggle" checked >
																			<label for="print_ewaybill_no_lable" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<div class="custom_field_align_right">
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="required_ewaybill_no_lable" name="required_ewaybill_no_lable" class="checkbox-toggle"  >
																			<label for="required_ewaybill_no_lable" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<input type="text" value="E-Way No." name="ewaybill_no_lable" id="ewaybill_no_lable" class="span4" placeholder="Enter Field 2 Label" maxlength="20"  >
																</td>
															</tr>

															<tr>
																<td >3</td>
																<td><div class="d-flex"><svg width="20" height="20"><use href="svg-icon/icons.svg#cursor-svg-icon"></use></svg> Text</div>
																<td>
																	<div class="custom_field_align_right">    
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="enable_challan" name="enable_challan" class="checkbox-toggle" checked>
																			<label for="enable_challan" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<div class="custom_field_align_right">
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="print_challan" name="print_challan" class="checkbox-toggle" checked >
																			<label for="print_challan" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<div class="custom_field_align_right">
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="required_challan" name="required_challan" class="checkbox-toggle" >
																			<label for="required_challan" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<input type="text" value="Challan No." name="challan_no_lable" id="challan_no_lable" class="span4" placeholder="Enter Field 3 Label" maxlength="20"  >
																</td>
															</tr>

															<tr>
																<td >4</td>
																<td><div class="d-flex"><svg width="20" height="20"><use href="svg-icon/icons.svg#calender-svg-icon"></use></svg> Date</div>
																<td>
																	<div class="custom_field_align_right">    
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="enable_challan_date" name="enable_challan_date" class="checkbox-toggle" checked>
																			<label for="enable_challan_date" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<div class="custom_field_align_right">
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="print_challan_date" name="print_challan_date" class="checkbox-toggle" checked >
																			<label for="print_challan_date" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<div class="custom_field_align_right">
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="required_challan_date" name="required_challan_date" class="checkbox-toggle" >
																			<label for="required_challan_date" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<input type="text" value="Challan Date" name="challan_date_lable" id="challan_date_lable" class="span4" placeholder="Enter Field 4 Label" maxlength="20"  >
																</td>
															</tr>

															<tr>
																<td >5</td>
																<td><div class="d-flex"><svg width="20" height="20"><use href="svg-icon/icons.svg#cursor-svg-icon"></use></svg> Text</div>
																<td>
																	<div class="custom_field_align_right">    
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="extra_text_field" name="extra_text_field" class="checkbox-toggle" checked>
																			<label for="extra_text_field" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<div class="custom_field_align_right">
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="print_extra_text_field" name="print_extra_text_field" class="checkbox-toggle" checked >
																			<label for="print_extra_text_field" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<div class="custom_field_align_right">
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="required_extra_text_field" name="required_extra_text_field" class="checkbox-toggle"  >
																			<label for="required_extra_text_field" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<input type="text" value="P.O. No." name="extra_text_field_lable" id="extra_text_field_lable" class="span4" placeholder="Enter Field 5 Label" maxlength="50"  >
																</td>
															</tr>

															<tr>
																<td >6</td>
																<td><div class="d-flex"><svg width="20" height="20"><use href="svg-icon/icons.svg#calender-svg-icon"></use></svg> Date</div>
																<td>
																	<div class="custom_field_align_right">    
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="extra_date_field" name="extra_date_field" class="checkbox-toggle" checked>
																			<label for="extra_date_field" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<div class="custom_field_align_right">
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="print_extra_date_field" name="print_extra_date_field" class="checkbox-toggle" checked >
																			<label for="print_extra_date_field" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<div class="custom_field_align_right">
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="required_extra_date_field" name="required_extra_date_field" class="checkbox-toggle"  >
																			<label for="required_extra_date_field" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<input type="text" value="P.O. Date" name="extra_date_field_lable" id="extra_date_field_lable" class="span4" placeholder="Enter Field 6 Label"  maxlength="50"  >
																</td>
															</tr>

															<tr>
																<td >7</td>
																<td><div class="d-flex"><svg width="20" height="20"><use href="svg-icon/icons.svg#cursor-svg-icon"></use></svg> Text</div>
																<td>
																	<div class="custom_field_align_right">    
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="extra_text_field_3" name="extra_text_field_3" class="checkbox-toggle" >
																			<label for="extra_text_field_3" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<div class="custom_field_align_right">
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="print_extra_text_field_3" name="print_extra_text_field_3" class="checkbox-toggle" checked >
																			<label for="print_extra_text_field_3" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<div class="custom_field_align_right">
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="required_extra_text_field_3" name="required_extra_text_field_3" class="checkbox-toggle"  >
																			<label for="required_extra_text_field_3" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<input type="text" value="Detail 1" name="extra_text_field_lable_3" id="extra_text_field_lable_3" class="span4" placeholder="Enter Field 7 Label" maxlength="50"  >
																</td>
															</tr>

															<tr>
																<td >8</td>
																<td><div class="d-flex"><svg width="20" height="20"><use href="svg-icon/icons.svg#calender-svg-icon"></use></svg> Date</div>
																<td>
																	<div class="custom_field_align_right">    
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="extra_date_field_3" name="extra_date_field_3" class="checkbox-toggle" >
																			<label for="extra_date_field_3" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<div class="custom_field_align_right">
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="print_extra_date_field_3" name="print_extra_date_field_3" class="checkbox-toggle" checked >
																			<label for="print_extra_date_field_3" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<div class="custom_field_align_right">
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="required_extra_date_field_3" name="required_extra_date_field_3" class="checkbox-toggle"  >
																			<label for="required_extra_date_field_3" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<input type="text" value="Detail 1 Date" name="extra_date_field_lable_3" id="extra_date_field_lable_3" class="span4" placeholder="Enter Field 8 Label"  maxlength="50"  >
																</td>
															</tr>

															<tr>
																<td >9</td>
																<td><div class="d-flex"><svg width="20" height="20"><use href="svg-icon/icons.svg#cursor-svg-icon"></use></svg> Text</div>
																<td>
																	<div class="custom_field_align_right">    
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="extra_text_field_4" name="extra_text_field_4" class="checkbox-toggle" >
																			<label for="extra_text_field_4" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<div class="custom_field_align_right">
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="print_extra_text_field_4" name="print_extra_text_field_4" class="checkbox-toggle" checked >
																			<label for="print_extra_text_field_4" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<div class="custom_field_align_right">
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="required_extra_text_field_4" name="required_extra_text_field_4" class="checkbox-toggle"  >
																			<label for="required_extra_text_field_4" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<input type="text" value="Detail 2" name="extra_text_field_lable_4" id="extra_text_field_lable_4" class="span4" placeholder="Enter Field 9 Label"  maxlength="50"  >
																</td>
															</tr>

															<tr>
																<td >10</td>
																<td><div class="d-flex"><svg width="20" height="20"><use href="svg-icon/icons.svg#bars-svg-icon"></use></svg> Dropdown</div></div>
																<td>
																	<div class="custom_field_align_right">    
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="extra_select_field" name="extra_select_field" class="checkbox-toggle" >
																			<label for="extra_select_field" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<div class="custom_field_align_right">
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="print_extra_select_field" name="print_extra_select_field" class="checkbox-toggle" checked >
																			<label for="print_extra_select_field" class="checkbox-toggle-label"></label>
																		</div>
																	</div>
																</td>
																<td>
																	<div class="custom_field_align_right">
																		<div class="checkbox-toggle-switch">
																			<input type="checkbox" id="required_extra_select_field" name="required_extra_select_field" class="checkbox-toggle"  >
																			<label for="required_extra_select_field" class="checkbox-toggle-label" ></label>
																		</div>
																	</div>
																</td>
																<td>
																	<input type="text" value="Type" name="extra_select_field_lable" id="extra_select_field_lable" class="span4" placeholder="Enter Field 10 Label" maxlength="30"  >
																</td>
															</tr>

														</tbody><!-- /tbody -->
														</table><!-- /table -->
														
														<div class="extra_select_field_data" style='display:none;'>
															<hr class="custom_field_hr">
															<div class="control-group ">											
																<label for="Address" class="control-label">Dropdown Options</label>
																<div class="controls">
																	<textarea id="extra_select_field_options" name="extra_select_field_options" class="span4" >Sale,Service,Sale and Service</textarea>					
																	<p class="note">Specify the list of options in a comma (,)separated list. </p>
																</div><!-- /controls -->				
															</div><!-- /control-group -->
														</div>
														<script>
															$(document).ready(function() {
																$('#extra_select_field').change(function() {
																	$('.extra_select_field_data').slideToggle();
																});
															});
														</script>
	                                   	 		</div>
																								
																						  
																							
											

											
											

										
											

										
											
											
											
											  											  
                                            											  
											
											
	                                  </div>
	                                </div> 
                              </fieldset>
                     	 </div>
                  </div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default pull-left" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg>Close</button>
					<input type="hidden" value="10594" name="select_id" id="select_id" >
					<input type="hidden" name="hidden_submit_form_data" id="hidden_submit_form_data" value="yes"/>
					<input type="hidden" value="invoice_options" name="submit_type">
					<button  class="btn btn-primary pull-mobile-right floate-right" id="submit-custom-filed" type="btn"><svg width="20" height="20"><use href="svg-icon/icons.svg#save-svg-icon"></use></svg>Save</button>
				</div>
			</div>
		</form>

			  <script>
				var pagename = 'invoicebill';
				var is_shipping_filed = '';
				function checkFirstCheckboxInRow(row) {
							var checkboxes = row.find('input[type="checkbox"]');
							var firstCheckbox = checkboxes.first();
							isChecked=false;
							var name = firstCheckbox.prop('name');
							if(!name.endsWith('_lable')  && !name.startsWith('print_customer_') && !name.startsWith('required_customer')){
									if (!firstCheckbox.is(':checked')) {
										firstCheckbox.prop('checked', true);
										isChecked=true;
									}
							}
							if (name.endsWith('extra_select_field') || name.endsWith('_extra_select_field')) {
								if (isChecked) {	
									$('.' + name + '_data').slideToggle();	
									return;
								}	
							}
						}

					function uncheckCheckboxInRow(row) {
							var checkboxes = row.find('input[type="checkbox"]');
							var firstCheckbox = checkboxes.first();
							var name = firstCheckbox.prop('name');
							if(!name.endsWith('_lable')  && !name.startsWith('print_customer_') && !name.startsWith('required_customer')){
							if (firstCheckbox.is(':not(:checked)')) {
								checkboxes.prop('checked', false);
								}	
							}			
							}
							$(document).ready(function() {  
								
						$('#CustomFieldModal input[type="checkbox"]').on('change', function() {
							var checkbox = $(this);
							var viewportWidth = window.innerWidth || document.documentElement.clientWidth;	
							if (viewportWidth <= 1200) {
								var row = checkbox.closest('#CustomFieldModal tbody');
							} else {
								var row = checkbox.closest('tr');
							}
							var checkboxesInRow = row.find('input[type="checkbox"]');
							var index = checkboxesInRow.index(checkbox); 
							if(index<1){		
								uncheckCheckboxInRow(row)
							}else{
								checkFirstCheckboxInRow(row);
							}
							
					});
				  });
				const url = new URL(window.location.href);
				  $('#customfiledform').on('submit', function(e) {
						e.preventDefault(); 
						var formData = $(this).serialize();
						formData += "&action=submitCustomFiled";
						$.ajax({
							url: 'custom_field_column.php',
							type: 'POST',
							data: formData,
							beforeSend: function() {
								$('#CustomFieldModal button[name="btnsubmit"]').prop('disabled', true);
							},
							success: function(response) {
								if(response.status=="SUCCESS"){
									const updateUrlParam = (param, value) => {
										url.searchParams.set(param, value);
										url.searchParams.set("custom_field", "update");
										window.location.href = url.toString();
									};
									if (pagename === "list-company") {
										let companyId = $('#CustomerModal').find(".company_id").val();
										updateUrlParam("open_que", companyId || 0);
									} 
									else if (pagename === "shipping_address" && is_shipping_filed!="") {
										let shipping_id = $('#ShippingModal').find(".shipping_address_id").val();
										updateUrlParam("open_que", shipping_id || 0);
									} 
									else if (pagename === "list-paymentreceipt") {
										let receiptNo = $("#PaymentRecieptModal .modal-body").find("input[name='id']").val()
										updateUrlParam("open_que", receiptNo || 0);
									} else {
										url.searchParams.set("custom_field", "update");
										window.location.href = url.toString();
									}	
								}
								else{
									Swal.fire({
										icon: 'error',
										title:response.status
									});
								}
								
							},
						});
					});	
					if (url.searchParams.get("custom_field") === "update") {
						url.searchParams.delete("custom_field");
						window.history.replaceState({}, document.title, url.toString());
						Toast.fire({
							icon: 'success',
							title:"Custom Field Details Updated successfully."
						});
					}
					$('#CustomFieldModal').on('shown.bs.modal', function () {
						$('.CustomFieldModal-btn svg').tooltip("close");
					});
			  </script>
			  
	</div>
	</div><div id="CustomColumnsModal" class="popup_right_slider modal fade " role="dialog" style="display: none;">
	<div class="modal-dialog">



<script>

$(document).on('click','#CustomColumnsModal .custom_column_formula_for',function(){
	var val = $(this).val();
	customColumnFormulaFor($(this),val);
});


function customColumnFormulaFor(current,val){
	var note = 'Selecting "Quantity" will adjust price based on the total amount.'; 
	if(val == 'rate'){
	    note = 'Selecting "Price" will adjust quantity based on the total amount.'; 
	}
	$(current).closest('.controls').find('.note').text(note);
}

$(document).on('click','#CustomColumnsModal .copyText',function(){
	var custom_column_formula = $(this).closest('.controls').find('textarea').val();
	var currentText = $(this).text();

	var cursorPos = $(this).closest('.controls').find('textarea').prop('selectionStart');
    var textBefore = custom_column_formula.substring(0, cursorPos);
    var textAfter  = custom_column_formula.substring(cursorPos, custom_column_formula.length);
    
	var setText = textBefore + currentText + textAfter;
	$(this).closest('.controls').find('textarea').val(setText);
	$(this).closest('.controls').find('textarea')[0].selectionStart = 
	$(this).closest('.controls').find('textarea')[0].selectionEnd = cursorPos + currentText.length;
});

</script>







		<form class="form-horizontal customcolumnform" id="customcolumnform" enctype="multipart/form-data" >
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="btn btn-default btn_close" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg></button>
					<h4 class="modal-title">Custom Column</h4>
				</div>
				<div class="modal-body">
				<div class="widget-content">
								<fieldset>
									<div id="PrintOptions">	

																					<div id="SaleInvoice">
												<div>
    <table class="table custom_column_table" data-footable data-toggle-column="last">
        <thead>
			
            <tr>
                <th>No.</th>
                <th data-breakpoints="xs">Status</th>
                <th data-breakpoints="sm">Print</th>
                <th data-breakpoints="sm">Num. Format</th>
                <th data-breakpoints="md">Custom Field Name</th>
                <th data-breakpoints="md">Default Value</th>
                <th data-breakpoints="md">Position</th>
            </tr>
        </thead><!-- /thead -->
        <tbody>
            <tr>
                <td>1</td>
                <td>
                    <div class="custom_field_align_right">    
                        <div class="checkbox-toggle-switch">
                            <input type="checkbox" id="enable_custom_column_field1" name="enable_custom_column_field1" class="checkbox-toggle" >
                            <label for="enable_custom_column_field1" class="checkbox-toggle-label"></label>
                        </div>
                    </div>
                </td>
                <td>
                    <div class="custom_field_align_right">
                        <div class="checkbox-toggle-switch">
                            <input type="checkbox" id="print_custom_column_field1" name="print_custom_column_field1" class="checkbox-toggle" >
                            <label for="print_custom_column_field1" class="checkbox-toggle-label"></label>
                        </div>
                    </div>
                </td>
				<td>
                    <div class="custom_field_align_right">
                        <div class="checkbox-toggle-switch">
                            <input type="checkbox" id="formate_custom_column_field1" name="formate_custom_column_field1" class="checkbox-toggle" >
                            <label for="formate_custom_column_field1" class="checkbox-toggle-label"></label>
                        </div>
                    </div>
                </td>
                <td>
                    <input type="text" value="Custom 1" name="label_custom_column_field1" id="label_custom_column_field1" placeholder="Enter Extra Column Label 1" class="span3" maxlength="20"  >
                </td>
                <td>
                    <input type="text" value="" name="default_value_custom_column_field1" id="default_value_custom_column_field1" placeholder="Enter Default Value 1" class="span3" maxlength="20"  >
                </td>
                <td>
                    <select name="position_custom_column_field1" class="span3">
						<option value="quantity" selected>Before Quantity</option><option value="price" >Before Price</option><option value="taxable" >Before GST</option>                       
                    </select>
                </td>
            </tr>

            <tr>
                <td>2</td>
                <td>
                    <div class="custom_field_align_right">    
                        <div class="checkbox-toggle-switch">
                            <input type="checkbox" id="enable_custom_column_field2" name="enable_custom_column_field2" class="checkbox-toggle" >
                            <label for="enable_custom_column_field2" class="checkbox-toggle-label"></label>
                        </div>
                    </div>
                </td>
                <td>
                    <div class="custom_field_align_right">
                        <div class="checkbox-toggle-switch">
                            <input type="checkbox" id="print_custom_column_field2" name="print_custom_column_field2" class="checkbox-toggle" >
                            <label for="print_custom_column_field2" class="checkbox-toggle-label"></label>
                        </div>
                    </div>
                </td>
				<td>
                    <div class="custom_field_align_right">
                        <div class="checkbox-toggle-switch">
                            <input type="checkbox" id="formate_custom_column_field2" name="formate_custom_column_field2" class="checkbox-toggle" >
                            <label for="formate_custom_column_field2" class="checkbox-toggle-label"></label>
                        </div>
                    </div>
                </td>
                <td>
                    <input type="text" value="Custom 2" name="label_custom_column_field2" id="label_custom_column_field2"  placeholder="Enter Extra Column Label 2"  class="span3" maxlength="20"  >
                </td>
                <td>
                    <input type="text" value="" name="default_value_custom_column_field2" id="default_value_custom_column_field2"  placeholder="Enter Default Value 2"  class="span3" maxlength="20"  >
                </td>
                <td>
                    <select name="position_custom_column_field2" class="span3">
                      <option value="quantity" selected>Before Quantity</option><option value="price" >Before Price</option><option value="taxable" >Before GST</option>                    </select>
                </td>
            </tr>

            <tr>
                <td>3</td>
                <td>
                    <div class="custom_field_align_right">    
                        <div class="checkbox-toggle-switch">
                            <input type="checkbox" id="enable_custom_column_field3" name="enable_custom_column_field3" class="checkbox-toggle" >
                            <label for="enable_custom_column_field3" class="checkbox-toggle-label"></label>
                        </div>
                    </div>
                </td>
                <td>
                    <div class="custom_field_align_right">
                        <div class="checkbox-toggle-switch">
                            <input type="checkbox" id="print_custom_column_field3" name="print_custom_column_field3" class="checkbox-toggle" >
                            <label for="print_custom_column_field3" class="checkbox-toggle-label"></label>
                        </div>
                    </div>
                </td>
				<td>
                    <div class="custom_field_align_right">
                        <div class="checkbox-toggle-switch">
                            <input type="checkbox" id="formate_custom_column_field3" name="formate_custom_column_field3" class="checkbox-toggle" >
                            <label for="formate_custom_column_field3" class="checkbox-toggle-label"></label>
                        </div>
                    </div>
                </td>
                <td>
                	<input type="text" value="Custom 3" name="label_custom_column_field3" id="label_custom_column_field3" class="span3" maxlength="20"  placeholder="Enter Extra Column Label 3" >
                </td>
                <td>
                	<input type="text" value="" name="default_value_custom_column_field3" id="default_value_custom_column_field3" class="span3" maxlength="20"  placeholder="Enter Default Value 3" >
                </td>
                <td>
                    <select name="position_custom_column_field3" class="span3">
                        <option value="quantity" selected>Before Quantity</option><option value="price" >Before Price</option><option value="taxable" >Before GST</option>                    </select>
                </td>
            </tr>
        </tbody><!-- /tbody -->
    </table><!-- /table -->
    <hr class="custom_field_hr">
	<div class="control-group ">
		<label for="custom_column_decimal_value" class="control-label">Decimal Value</label>
		<div class="controls">
			<select class="custom_column_decimal_value" name="custom_column_decimal_value">
				<option value="0" >0</option>
				<option value="1" >1</option>
				<option value="2" selected>2</option>
				<option value="3" >3</option>
				<option value="4" >4</option>
				<option value="5" >5</option>
			</select>
			<p class="note"></p>
		</div>
	</div>
		<div class="control-group ">											
		<label for="Address" class="control-label">Enable Calculation</label>
		<div class="controls">
            <div class="custom_field_align_right">    
                <div class="checkbox-toggle-switch">
                    <input type="checkbox" id="enable_custom_column_formula" name="enable_custom_column_formula" class="checkbox-toggle" >
                    <label for="enable_custom_column_formula" class="checkbox-toggle-label"></label>
                </div>
            </div>			
		</div><!-- /controls -->				
	</div><!-- /control-group -->
	<div class="enable_custom_column_data" style="display:none">
        <div class="control-group ">											
            <label for="Address" class="control-label">Calculation Formula</label>
                            <div class="controls">
                    <textarea id="custom_column_formula" class="span4" disabled></textarea>
                    <p class="note cg-mw-full">Please contact support team to modify the calculation formula. </p>
                    <input type="hidden" name="custom_column_formula" value="">
                </div><!-- /controls -->
                        

        </div><!-- /control-group -->
        <div class="control-group ">											
            <label for="Address" class="control-label">Calculation Applied Field </label>
            <div class="controls">
                    <select class="custom_column_formula_for" name="custom_column_formula_for">
                        <option value="quantity" selected>Quantity</option>	
                        <option value="rate" >Price</option>	
                        <option value="taxable" >Taxable</option>
                        <option value="customfield1" class="hide_custom_field_option" >Custom 1</option>
                        <option value="customfield2" class="hide_custom_field_option" >Custom 2</option>
                        <option value="customfield3" class="hide_custom_field_option" >Custom 3</option>
					</select>
                    <p class="note cg-mw-full"></p>
            </div><!-- /controls -->				
        </div><!-- /control-group -->
    </div>
	<script>
        $(document).ready(function() {
            $('#enable_custom_column_formula').change(function() {
                $('.enable_custom_column_data').slideToggle();
            });

            $(document).on('click','#CustomColumnsModal input[type="checkbox"]',function() {
            	const match = $(this).attr('id').match(/enable_custom_column_field(\d+)/);
            	if (match) {
				    const value = match[1];
				    if($(this).prop('checked')){
				    	$('[name="custom_column_formula_for"]').find('option[value="customfield'+value+'"]').removeClass('hide_custom_field_option');
				    }else{
				    	$('[name="custom_column_formula_for"]').find('option[value="customfield'+value+'"]').addClass('hide_custom_field_option');
				    }
				}
                
            });
        });
		customColumnFormulaFor($('[name="custom_column_formula_for"]'),'quantity');
	</script>
		
											</div>
										
										
																				  
										

										

										
										

										

										

										

																														

	                                  </div>
	                                </div> 
                              </fieldset>
                      </div>	

				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default pull-left" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg>Close</button>
					<input type="hidden" value="10594" name="select_id" id="select_id" >
					<input type="hidden" name="hidden_submit_form_data" id="hidden_submit_form_data" value="yes"/>
					<input type="hidden" value="invoice_options" name="submit_type">
					<button  class="btn btn-primary pull-mobile-right floate-right" id="submit-custom-filed" type="btn"><svg width="20" height="20"><use href="svg-icon/icons.svg#save-svg-icon"></use></svg>Save</button>
				</div>
			</div>
		</form>


<script type="text/javascript">
	$("#invoiceoptionform" ).submit(function(){
		
		return isValid;
	});
	const url_1 = new URL(window.location.href);
	$('#customcolumnform').on('submit', function(e) {
			e.preventDefault(); 
			var isValid = true;

			$(this).find("textarea").each(function(n,v){
			var invoicetype = $(this).closest('.AccordianOpen').find('.accordion-heading a').text();
			var formula = $(this).val();
        	var allowedTags = ["{{quantity}}","{{price}}","{{mrp}}","{{gst}}","{{discount}}","{{custom1}}", "{{custom2}}", "{{custom3}}", "{{cess}}", "{{cess amount}}"];
		    const tagsInString = formula.match(/{{\w+}}/g) || [];
		    const disallowedTags = tagsInString.filter(tag => !allowedTags.includes(tag));

		    if (disallowedTags.length > 0) {
		        var errorMessage = `Disallowed tags found in ${invoicetype}: ${disallowedTags.join(", ")}`;
		        Swal.fire({
					icon: 'error',
					title:errorMessage
				});
				isValid = false;
		    }
		});
		if(isValid){
			var formData = $(this).serialize();
			formData += "&action=submitCustomColumn";
			formData += "&only_update_in_invoice_table=" + 0;
			formData += "&detail_id=" + 0;
		
			$.ajax({
				url: 'custom_field_column.php',
				type: 'POST',
				data: formData,
				beforeSend: function() {
					$('button[name="btnsubmit"]').prop('disabled', true);
				},
				success: function(response) {
					if(response.status=="SUCCESS"){
						url_1.searchParams.set("custom_column", "update");
						window.location.href = url_1.toString();
					}
					else{
						Swal.fire({
							icon: 'error',
							title:response.status
						});
					}	
				},
			});
		}
		});	
		if (url_1.searchParams.get("custom_column") === "update") {
			url_1.searchParams.delete("custom_column");
			window.history.replaceState({}, document.title, url_1.toString());
			Toast.fire({
				icon: 'success',
				title:"Custom Columns Details Updated successfully.."
			});
		}
		$('#CustomColumnsModal').on('shown.bs.modal', function () {
			$('.CustomColumnsModal-btn svg').tooltip("close");
		});
</script>




	</div>
	</div></div> </div> </div>  <!-- /main -->
    
    
    
<div class="footer">
	<div class="footer-inner">
		<div class="container">
			<div class="row">
    			<div class="span12">
    				&copy; 2025 <a href="">Go GST Bill</a>&nbsp;
					
					
									</div> <!-- /span12 -->
    		</div> <!-- /row -->
		</div> <!-- /container -->
	</div> <!-- /footer-inner -->
</div> <!-- /footer -->

<script>

var refreshSn = function ()
{
    var time = 600000; 
    setTimeout(
        function ()
        {
        $.ajax({
           url: 'keep_alive.php',
           cache: false,
           complete: function () {refreshSn();}
        });
    },
    time
);
};


refreshSn();

			$(document).on("click", ".ViewKnowledgeModal", function() {
				var iframeSrc = $(this).attr("data-baselink");
				if(iframeSrc != ""){
					$('#ViewKnowledgeModal').modal('show').on('shown', function() {	
						$("#ViewKnowledgeModal iframe").attr("src", iframeSrc );
						$("#ViewKnowledgeModal .modal-content").removeClass("is-loading");
						if(window.innerHeight < $('#ViewKnowledgeModal iframe').height())
					    {
					    	$('#ViewKnowledgeModal, #ViewKnowledgeModal #ViewKnowledgeModal_iframe').height(window.innerHeight);
					    }
					});
				}
			
			});

</script>
<div id="gogst_popup" class="widget">
	<div class="widget-header">
		<i class="fa fa-info"></i>
		<h3 class="gogst_popup-header"></h3>
	</div>
	<div class="widget-content">
	<div class="gogst_popup-content">
	</div>
	<button class="gogst_popup_close btn btn-info"><i class="fa fa-remove"></i> Close</button>
	</div>
    
</div>
<div id="ViewKnowledgeModal" class="modal popup_right_slider fade" role="dialog" style="display: none;z-index: 99999;">
	<div class="modal-dialog">
			<div class="modal-content is-loading">
				<div id="iframeContainer">
				<div class="modal-header">
					<button type="button" class="btn btn-default btn_close" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg></button>
					<h4 class="modal-title">Knowledge Base</h4>
				</div>
					<iframe name="print_iframe" id="ViewKnowledgeModal_iframe" src="" frameborder="0" style="width:100%;height:100vh;float:left;"></iframe>
				<div class="modal-footer">
					<button type="button" class="btn btn-default pull-left" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg>Close</button>
				</div>	
				</div>
				<div class="preloader-overly">
				<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.0" width="80px" height="80px" viewBox="0 0 128 128" xml:space="preserve"><g><path fill="#00ba8c" fill-opacity="1" d="M109.25 55.5h-36l12-12a29.54 29.54 0 0 0-49.53 12H18.75A46.04 46.04 0 0 1 96.9 31.84l12.35-12.34v36zm-90.5 17h36l-12 12a29.54 29.54 0 0 0 49.53-12h16.97A46.04 46.04 0 0 1 31.1 96.16L18.74 108.5v-36z"></path><animateTransform attributeName="transform" type="rotate" from="0 64 64" to="360 64 64" dur="880ms" repeatCount="indefinite"></animateTransform></g></svg>
				</div>
			</div>
	</div>
</div>
<!-- Modal -->
<style>
    .jqte{
    border-color: #ccc !important;
    box-shadow: none !important;
    border-radius: 8px !important;
    }
    .jqte_tool_label:active , .jqte_tool_label:hover{
    text-decoration: none !important;
    } 
    .jqte_toolbar{
    background: #fff;
    border-bottom-color:#ccc ;
    }
    .jqte_tool:hover .jqte_tool_icon, .jqte_tool:hover .jqte_tool_label, .jqte_tool, .jqte_tool_icon, .jqte_tool_label{
    border: none !important;
    }
    #EmailModal .upload_file{
        background-color: #fafafa;
        text-align: center;
        padding: 15px 20px 25px 20px;
        border: 1px dashed #8A8A8A;
        cursor: pointer;
        font-size: 13px;
        color: #333333;
        border-radius: 8px;
    }
    #EmailModal .upload_file:hover{
        border: 1px dashed #00ba8b;
    }
    #EmailModal .modal-dialog .invoice_wrapper {
        display: flex;
        flex-direction: column;
        height: 100%;
    }
    #EmailModal .modal-dialog .invoice_wrapper .invoice_container {
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
        max-height: calc(100% - 60px);
        box-sizing: border-box;
        margin-bottom: 20px;
        overflow-y: auto;
        overflow: visible;
    }
    #EmailModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box,
    #WhatsappModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        position: relative;
        overflow: visible;
        border: 1px solid #ddd;
        border-radius: 5px;
        width: calc(25% - 10px);
        height: 50px;
        width: 220px;
        padding: 0 8px;
        box-sizing: border-box;
        margin: 0;
    }
    #EmailModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box img,
    #WhatsappModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box img {
        width: 40px;
        height: 40px;
        display: block;
        object-fit: contain;
    }
    #EmailModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box .invoice_content {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
        width: 100%;
        padding: 8px;
    }

    #EmailModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box .invoice_content .title {
        width: 100%;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        font-size: 12px;
        color: #333;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: normal;
        word-break: break-all;
        line-height: 1.3;
        margin: 0px;
    }
    #EmailModal .invoice_container .delete_btn,
    #WhatsappModal .invoice_container .delete_btn {
        position: absolute;
        bottom: -17px;
        right: 2px;
        transform: translate(50%, -50%); /* Moves 50% outside the box */
        background-color: #fff;
        color: white;
        border: 1px solid #ddd;
        border-radius: 50%;
        width: 20px;
        height: 20px;
        font-size: 14px;
        font-weight: bold;
        display: flex;
        justify-content: center;
        align-items: center;
        cursor: pointer;
        transition: background-color 0.3s ease;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
        z-index: 10; 
        padding: 0
    }
    #EmailModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box .svg_icon,
    #WhatsappModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box .svg_icon {
        width: auto;
        height: 40px;
        margin: auto;
        padding-top: 3px;
    }

    
    #invoice_upload_modal .invoice_wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    }

    #invoice_upload_modal .invoice_wrapper .invoice_container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    max-height: calc(100% - 60px);
    box-sizing: border-box;
    margin-bottom: 20px;
    overflow-y: auto;
    }

    #invoice_upload_modal .invoice_wrapper .invoice_container .invoice_box {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    border: 1px solid #ddd;
    border-radius: 5px;
    width: calc(25% - 10px);
    height: 180px;
    padding: 8px 8px 0 8px;
    box-sizing: border-box;
    margin: 0;
    }

    #invoice_upload_modal .invoice_wrapper .invoice_container .invoice_box img {
    width: 130px;
    height: 120px;
    display: block;
    object-fit: contain;
    }

    #invoice_upload_modal .invoice_wrapper .invoice_container .invoice_box .svg_icon {
    width: auto;
    height: 85px;
    margin: auto;
    }

    #invoice_upload_modal .invoice_wrapper .invoice_container .invoice_box .invoice_icons {
    position: absolute;
    top: 50%;
    left: 11.5%;
    display: flex;
    gap: 10px;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    }
    #invoice_upload_modal .invoice_wrapper .invoice_container .invoice_box .invoice_icons i  {
    color: white;
    font-size: 15px;
    background: rgba(0, 0, 0, 0.5);
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    }

   
    #invoice_upload_modal .invoice_wrapper .invoice_container .invoice_box .invoice_icons a  {
    color: white;
    font-size: 15px;
    background: rgba(0, 0, 0, 0.8);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: space-around;
    border-radius: 50%;
    cursor: pointer;
    svg{
        filter: brightness(0.5) invert(1);
    }
    }

    #invoice_upload_modal .invoice_wrapper .invoice_container .invoice_box:hover .invoice_icons {
    opacity: 1;
    }

    #invoice_upload_modal .invoice_wrapper #invoice_dropzone {
    text-align: center;
    min-height: 100px;
    display: inline-block;
    background-color: #fafafa;
    border: 1px dashed #aaa;
    border-radius: 2px;
    position: relative;
    bottom: 0;
    margin-top: auto;
    }

    #invoice_upload_modal .invoice_wrapper .invoice_container .invoice_box .invoice_content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    width: 100%;
    padding: 8px;
    height: 50px;
    }

    #invoice_upload_modal .invoice_wrapper .invoice_container .invoice_box .invoice_content .title {
    width: 100%;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    font-size: 12px;
    font-weight: bold;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    word-break: break-all;
    line-height: 1.3;
    }

    #invoice_upload_modal .invoice_wrapper #invoice_dropzone:hover {
    border-color: #07ad83;
    }

    @media (max-width: 480px) {
    #invoice_upload_modal .invoice_wrapper .invoice_container .invoice_box {
        width: calc(50% - 10px);
    }
    }

    @media (max-width: 400px) {
    #invoice_upload_modal .invoice_wrapper .invoice_container .invoice_box {
        height: 160px;
    }
    }
    #invoice_upload_modal .invoice_wrapper .invoice_container .invoice_box .invoice_icons i svg{
        filter: brightness(100);
    }
    #EmailModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box .svg_icon svg use,
    #WhatsappModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box .svg_icon svg use{
        scale: 0.37;
    }
     #invoice_upload_modal .invoice_wrapper .invoice_container .invoice_box{
        background-color: rgba(0, 0, 0, 0);    
        transition: background-color 0.3s ease-in-out;
    }
    #invoice_upload_modal .invoice_wrapper .invoice_container .invoice_box.pdf-preview:hover {
        background-color: rgb(0 0 0 / 12%);    
        cursor: pointer;
    }

    #EmailModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box .loader,
    #WhatsappModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box .loader {
        display: none; 
        position: absolute; 
        top: 25%; 
        left: 45%; 
        transform: translate(-50%, -50%);
        border: 4px solid #f3f3f3;
        border-top: 4px solid #555;
        border-bottom: 4px solid #555;
        border-radius: 50%;
        width: 30px;
        height: 30px;
        animation: spin 0.8s linear infinite;
        z-index: 10;
    }
    #EmailModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box.pdf-preview:not(.pdf-download-btn),
    #WhatsappModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box.pdf-preview:not(.pdf-download-btn),
    #EmailModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box.pdf-preview:not(.download-btn),
    #WhatsappModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box.pdf-preview:not(.download-btn) {
        background-color: #f5f5f5;
        cursor: unset;
    }
    #EmailModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box.pdf-preview:not(.pdf-download-btn) .invoice_content .title,
    #WhatsappModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box.pdf-preview:not(.pdf-download-btn) .invoice_content .title,
    #EmailModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box.pdf-preview:not(.download-btn) .invoice_content .title,
    #WhatsappModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box.pdf-preview:not(.download-btn) .invoice_content .title{
        color : #B1B1B1;
    }
    #EmailModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box.pdf-preview:not(.pdf-download-btn) .svg_icon,
    #WhatsappModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box.pdf-preview:not(.pdf-download-btn) .svg_icon,
    #EmailModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box.pdf-preview:not(.download-btn) .svg_icon,
    #WhatsappModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box.pdf-preview:not(.download-btn) .svg_icon{
        opacity: 0.5;
    }
    #EmailModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box.pdf-preview:not(.pdf-download-btn) .invoice_icons,
    #WhatsappModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box.pdf-preview:not(.pdf-download-btn) .invoice_icons,
    #EmailModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box.pdf-preview:not(.download-btn) .invoice_icons,
    #WhatsappModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box.pdf-preview:not(.download-btn) .invoice_icons{
        display: none;
    }
    
    
    #EmailModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box.pdf-preview:not(.pdf-download-btn) .loader,
    #WhatsappModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box.pdf-preview:not(.pdf-download-btn) .loader,
    #EmailModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box.pdf-preview:not(.download-btn) .loader,
    #WhatsappModal .modal-dialog .invoice_wrapper .invoice_container .invoice_box.pdf-preview:not(.download-btn) .loader{
        display: block;
    }
    @keyframes spin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
    }
    #EmailModal .invoice_container .delete_btn svg,
    #WhatsappModal .invoice_container .delete_btn svg{
        filter: brightness(0.3);
    }
    #EmailModal .invoice_container .delete_btn:hover ,
    #WhatsappModal .invoice_container .delete_btn:hover {
        background-color: #fb5454;
    }
    #EmailModal .invoice_container .delete_btn:hover svg,
    #WhatsappModal .invoice_container .delete_btn:hover svg{
        filter: brightness(1);
    }
</style><div id="EmailModal" class="popup_right_slider modal fade" role="dialog" style="display: none;">
  <div class="modal-dialog">
  <form class="form-horizontal" method="post" id="EmailModalForm"   >
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
		<button type="button" class="btn btn-default btn_close" data-dismiss="modal"><svg width="20" height="20"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg></button>
        <h4 class="modal-title">Email</h4>
      </div>
      <div class="modal-body">
        
			<fieldset>
				<div class="control-group">											
					<label for="To" class="control-label" style="width: 80px;">To<span class="star_red">*</span></label>
					<div class="controls" style="margin-left: 90px;">
						<input type="text" name="cmp_email" id="cmp_email" class="span4" value="" maxlength="150" required>
						<div class="note">Note : Use comma(,) as address separator to enter Multiple Email.</div>
						<div id="cmp_email_validate"></div>
					</div> <!-- /controls -->				
				</div> <!-- /control-group -->
				
				<div class="control-group">											
					<label for="cmp_cc" class="control-label" style="width: 80px;">Cc</label>
					<div class="controls" style="margin-left: 90px;">
						<input type="text" name="cmp_cc" id="cmp_cc" class="span4" value="" maxlength="150">
					</div> <!-- /controls -->				
				</div> <!-- /control-group -->
				
				<div class="control-group">											
					<label for="cmp_bcc" class="control-label" style="width: 80px;">Bcc</label>
					<div class="controls" style="margin-left: 90px;">
						<input type="text" name="cmp_bcc" id="cmp_bcc" class="span4" value="" maxlength="150">
					</div> <!-- /controls -->				
				</div> <!-- /control-group -->
				
				<div class="control-group">											
					<label for="Subject" class="control-label" style="width: 80px;">Subject<span class="star_red">*</span></label>
					<div class="controls" style="margin-left: 90px;">
						<input type="text" name="subject" id="subject" class="span4" value="Report from {{org-name}}" maxlength="100" required>
						<div id="subject_validate"></div>
					</div> <!-- /controls -->				
				</div> <!-- /control-group -->
				
				<div class="control-group">											
					<label for="name" class="control-label" style="width: 80px;">Body<span class="star_red">*</span></label>
					<div class="controls" style="margin-left: 90px;">
						<textarea name="body" id="body" class="span4 jqte-test1" required >Dear {{company}},<br><br>Please find the attached report.<br><br>Feel free to reach out if you have any questions or need clarification.<br><br>Best regards,<br>{{org-name}}</textarea>
						<div id="body_validate"></div>
						<input type="hidden" name="cmp_name" id="cmp_name" value="" >
						<input type="hidden" name="inv_id" id="inv_id" value="" >
						<input type="hidden" name="po_date" id="po_date" value="" >
						<input type="hidden" name="po_no" id="po_no" value="" >
						<input type="hidden" name="inv_detail_id" id="inv_detail_id" value="" >
						<input type="hidden" name="inv_date" id="inv_date" value="" >
						<input type="hidden" name="completion_date" id="completion_date" value="" >
						<input type="hidden" name="inv_amount" id="inv_amount" value="" >
						<input type="hidden" name="replay_email" id="replay_email" value="gvaanand@outlook.com" >
						<input type="hidden" name="filename" id="filename" value="" >
						<input type="hidden" name="baseLink" id="baseLink" value="" >
						<input type="hidden" name="fromdate" id="fromdate" value="" >
						<input type="hidden" name="todate" id="todate" value="" >
						<input type="hidden" name="template" id="template" value="" >
						<input type="hidden" name="template_size" id="template_size" value="" >
						<input type="hidden" name="template_orientation" id="template_orientation" value="" >
						<input type="hidden" name="v_data" id="v_data" value="" >
					</div> <!-- /controls -->				
				</div> <!-- /control-group -->
				<div class="control-group" id="invoice_upload_modal">											
					<label for="Subject" class="control-label" style="width: 90px;">Attachments</label>
					<div class="controls" style="margin-left: 90px;">
						<div class="invoice_wrapper">
							<div class="invoice_container">
								<div class="invoice_box download-btn pdf-download-btn pdf-preview" id="pdf-preview" data-pdfpreview = "1">
									<div class="loader"></div>
									<div class="invoice_icons" ><a style="color: black"><svg width="20" height="20" style="margin:0"><use href="svg-icon/icons.svg#eye-svg-icon"></use></svg></a></div>
									<div class="svg_icon"><svg width="40" height="40" style="margin-top:auto"><use href="svg-icon/upload_file_icons.svg#pdf-svg-icon"></use></svg></div>
									<div class="invoice_content" id="pdf-preview-name"><p class="title"></p></div>
								</div>
							</div>
						</div>
					</div>			
				</div>	

							</fieldset>
		
      </div>
      <div class="modal-footer">
            <input type="hidden" class="isexcel" name="isexcel" value="">
			<button  class="btn btn-primary pull-right" name="btnsubmit" id="btnSubmit" type="submit"><svg width="20" height="20"><use href="svg-icon/icons.svg#send-svg-icon"></use></svg>Send</button> 
			<button type="button" class="btn btn-default pull-left " data-dismiss="modal"><svg width="20" height="20" style="filter: brightness(1);"><use href="svg-icon/icons.svg#closebtn-svg-icon"></use></svg>Close</button>
      </div>
    </div>
	</form>
  </div>
</div>

<script>
	$('.jqte-test1').jqte();
$(document).ready(function() {

	var organisationName = "ANAND ASSOCIATES";
	let totalSize = 0;
	let all_attached_files = [];
	var enable_custom_field1= '';
	var enable_custom_field2= '';
	var enable_custom_field3= '';
	var enable_custom_field4= '';
	var enable_custom_field5= '';
	var enable_custom_field6= '';
	var enable_custom_field7= '';
	var enable_custom_field8= '';
	var enable_custom_field9= '';
	var enable_custom_field10= '';

    $('.upload_file').click(function(){
        $("#attached_files").click();
    });

    $("#attached_files").change(function(event) {
        let files = event.target.files;

		for (let i = 0; i < files.length; i++) {
			let file = files[i];
			let fileType = file.type;
			let fileSize = file.size / 1024 / 1024;

			if (fileType !== "application/pdf" && fileType !== "image/jpeg" && fileType !== "image/jpg" && fileType !== "image/png" ) {
				$('#attach_file_error').text("Only PDF and JPG files are allowed!");
				continue;
			}

			if (fileSize > 10) {
				$('#attach_file_error').text(`Maximum file size 10 MB.`);
				continue;
			}

			if (totalSize + fileSize > 10) {
				$('#attach_file_error').text(`Total file size limit exceeded (Max 10MB).`);
				continue;
			}

			let reader = new FileReader();
			reader.onload = function(event) {
				let preview_img_svg= "";
				let fileData = event.target.result; 
				let is_image = fileType === "application/pdf" ? false : true;

				all_attached_files.push({ name: file.name, data: fileData, type: fileType });
				totalSize += fileSize;

				if(is_image){
					preview_img_svg = `<img src="${fileData}" width="100">`;
				}else{
					preview_img_svg = `<div class="svg_icon"><svg width="40" height="40" style="margin-top:auto"><use href="svg-icon/upload_file_icons.svg#pdf-svg-icon"></use></svg></div>`;
				}

				$(".invoice_container").append(`
					<div class="invoice_box">
						${preview_img_svg}
						<div class="invoice_content"><p class="title">${file.name}</p></div>
						<button class="delete_btn" data-name="${file.name}" data-size="${fileSize}"><svg width="14" height="14"><use href="svg-icon/icons.svg#trash-svg-icon" style="scale: 0.74"></use></svg></i></button>
					</div>
				`);
			};

			if (fileType === "application/pdf") {
				reader.readAsDataURL(file);
			} else {
				reader.readAsDataURL(file);
			}
			$('#attach_file_error').text('')	
		}
    });

	$(document).on("click", ".delete_btn", function() {
		let fileName = $(this).data("name");
		let fileSize = parseFloat($(this).data("size"));
		all_attached_files = all_attached_files.filter(file => file.name !== fileName);
		totalSize -= fileSize;
		$('#attach_file_error').text('')
		$(this).parent().remove();
	});

    function sendInvoiceEmail(ajax_data, callback){
        $.ajax({
            type: "POST",
            url: "ajaxcall.php",
            ContentType : 'application/json',
            dataType: 'json',
            data: ajax_data,
            beforeSend: function() {
                $("#EmailModal #btnSubmit").html('Sending ...');
                $("#EmailModal #btnSubmit").prop('disabled', true);
            },
            success: function(data){
                $("#EmailModal #btnSubmit").html('<svg width="20" height="20"><use href="svg-icon/icons.svg#send-svg-icon"></use></svg>Send');
                $("#EmailModal #btnSubmit").prop('disabled', false);
                if(data.status == "ERROR")
                {

                    if (data.failed_via_go_gst == 0){
                        Swal.fire({
                            title: 'Unable to Send Email',
                            html: "We couldn't send the email using your account.  <br>Please check your email settings and try again, <br>or send it from Go GST Bill account.",
                            icon: 'warning',
                            showDenyButton: true,
                            confirmButtonColor: '#3085d6',
                            confirmButtonText: 'Send Via Go GST Bill',
                            denyButtonText: 'View Settings ',
                            reverseButtons: true,
                            customClass: { denyButton: 'recodeCancel-btn' }
                        }).then((result) => {
                            if (result.isConfirmed) {
                                ajax_data = {...ajax_data, go_gst_bill_mode: 1};
								sendInvoiceEmail(ajax_data, callback); 
                            }else if (result.isDenied) {
                                window.location.replace('smtp-email-settings.php?mail_error=1');
                            }
                        });
                    }else{
                        errorMessage('', data.msg, '', 'error')
                    }
					if (callback) callback(false);
                }
                else if(data.status == "OK")
                {
                    $('#EmailModal').modal('hide');
                    var Toast = Swal.mixin({
                        toast: true,
                        position: 'top-end',
                        showConfirmButton: false,
                        timer: 3000,
                        showClass: {popup: 'animate__animated animate__slideInRight'},
                        hideClass: {popup: 'animate__animated animate__slideOutRight'},
                        timerProgressBar: true,
                    });

                    Toast.fire({
                        icon: 'success',
                        title: data.msg
                    }).then((result) => {
                        $('.actions_detail_icons_email[data-id='+data.inv_detail_id+']').show();
                        $('.actions_detail_icons_email[data-id='+data.inv_detail_id+']').attr('title',data.tooltip_msg);
                    });
					if (callback) callback(true); 
                }
            },
        });
    }

	try{

	$('#EmailModal input').on('keypress', function(e) {
		if (e.key === 'Enter') {
			e.preventDefault();
			$("#EmailModal form").submit();
		}
	});
	$.validator.addMethod("containsOrganisationName", function(value, element) {
		if (typeof organisationName !== 'string' || organisationName.trim() === '') return true;

		const decodeHtml = html => $('<textarea/>').html(html).text();
		const stripHtml = html => decodeHtml($('<div>').html(html).text());

		const normalize = str =>
			stripHtml(str)
				.toLowerCase()
				.replace(/\s+/g, ' ')
				.trim();

		const normalizedBody = normalize(value);
		const normalizedOrgName = normalize(organisationName);

		return normalizedBody.includes(normalizedOrgName);
	}, "The email body must contain the organisation name.");

	$( "#EmailModal form" ).validate({
		ignore: [],
		rules: {
			field: {required: true},
			cmp_email: {
					multiplemail: true
				},
			subject: { required: true },
			body: {
				required: true,
				containsOrganisationName: true
			}
		},
		errorPlacement: function (error, element) {
			var name = $(element).attr("name");
			error.appendTo($("#" + name + "_validate"));	
		},
		messages: {
			cmp_email: {
            required: "Please enter customer email address.",
            validate_email: "Please enter a valid email address.",
        },
			subject: "Please enter subject",
			body: {
				required: "Please enter body some text",
				containsOrganisationName: `The email body must contain the organisation name: ${organisationName}.`
			}

		},
		invalidHandler: function(event, validator) {
			var bodyField = validator.errorMap["body"];
			if (bodyField && bodyField.includes(organisationName)) {
				errorMessage('','Missing Organisation Name',`The email body must contain the organisation name: <b>${organisationName}</b>.`,'error');
			}
		},
		submitHandler: function(form) {
			var data = {
				action: 'SubmitEmailModel',
				cmp_email:$("#EmailModal form input[name='cmp_email']").val(),
				cmp_cc:$("#EmailModal form input[name='cmp_cc']").val(),
				cmp_bcc:$("#EmailModal form input[name='cmp_bcc']").val(),
				subject:$("#EmailModal form input[name='subject']").val(),
				body:$("#EmailModal form textarea[name='body']").val(),
				cmp_name:$("#EmailModal form input[name='cmp_name']").val(),
				inv_id:$("#EmailModal form input[name='inv_id']").val(),
				inv_detail_id:$("#EmailModal form input[name='inv_detail_id']").val(),
				inv_date:$("#EmailModal form input[name='inv_date']").val(),
				completion_date:$("#EmailModal form input[name='completion_date']").val(),
				inv_amount:$("#EmailModal form input[name='inv_amount']").val(),
				po_no:$("#EmailModal form input[name='po_no']").val(),
				po_date:$("#EmailModal form input[name='po_date']").val(),
				replay_email:$("#EmailModal form input[name='replay_email']").val(),
				filename:$("#EmailModal form input[name='filename']").val(),
				baseLink:$("#EmailModal form input[name='baseLink']").val(),
				fromdate:$("#EmailModal form input[name='fromdate']").val(),
				todate:$("#EmailModal form input[name='todate']").val(),
				template:$("#EmailModal form input[name='template']").val(),
				template_size:$("#EmailModal form input[name='template_size']").val(),
				template_orientation:$("#EmailModal form input[name='template_orientation']").val(),
				isexcel:$("#EmailModal form input[name='isexcel']").val()
				,isEway:$("#EmailModal form input[name='inv_id']").attr('data-isEway')
				,v_data:$("#EmailModal #v_data").val()
			}
			const filename = $("#EmailModal form input[name='filename']").val(); 
			const template = $("#EmailModal form input[name='template']").val(); 
			const template_size = $("#EmailModal form input[name='template_size']").val(); 
			const template_orientation = $("#EmailModal form input[name='template_orientation']").val(); 
			const baselink = $("#EmailModal form input[name='baseLink']").val(); 
			const digitalsign = $(".pdf-download-form input[name='digital_sign']").val(); 
			const hasLetter  = $("body").hasClass("printletter"); 

			if((digitalsign == 'true' && template != '') && hasLetter != true){
				digitalsignature(filename, template, template_size, template_orientation, baselink, '', JSON.stringify({...data, all_attached_files: all_attached_files}), function(response) {
					if (response.status === "OK") {
						$("#EmailModal #btnSubmit").html('<svg width="20" height="20"><use href="svg-icon/icons.svg#send-svg-icon"></use></svg>Send');
						$("#EmailModal #btnSubmit").prop('disabled', false);	
							var Toast = Swal.mixin({
								toast: true,
								position: 'top-end',
								showConfirmButton: false,
								timer: 3000,
								showClass: {popup: 'animate__animated animate__slideInRight'},
								hideClass: {popup: 'animate__animated animate__slideOutRight'},
								timerProgressBar: true,
							});

							Toast.fire({
								icon: 'success',
								title: response.msg
							}).then((result) => {
								$('.actions_detail_icons_email[data-id='+response.inv_detail_id+']').show();
								$('.actions_detail_icons_email[data-id='+response.inv_detail_id+']').attr('title',response.tooltip_msg);
							});
							totalSize = 0;
							$('.invoice_container').html('')
							all_attached_files = [];
							
						} else {
							errorMessage('',response.msg,'','error');
							$("#EmailModal #btnSubmit").html('<svg width="20" height="20"><use href="svg-icon/icons.svg#send-svg-icon"></use></svg>Send');
							$("#EmailModal #btnSubmit").prop('disabled', false);
						}
						$('#EmailModal').modal('toggle');
				});
				return;
			}else{
                sendInvoiceEmail({...data, all_attached_files: all_attached_files}, function(success){
					if (success) {
						totalSize = 0;
						$('.invoice_container').html('')
						all_attached_files = []; 
					}
				})
			}
		}
	})
	
	$(document).on("click", ".email-btn", function () {
		$('#attach_file_error').text('')
		var cmp_email = $(this).attr('data-email')??"";
		var cmp_bcc = 'gvaanand@outlook.com';
		var cmp_cc = '';
		var cmp_name = $(this).attr('data-name');
		var cmp_contactperson = $(this).attr('data-contactperson');
		var inv_id = $(this).attr('data-id');
		var inv_detail_id = $(this).attr('data-detail-id');
		var is_Eway = $(this).attr('data-isEway');
		var inv_date = $(this).attr('data-date');
		var completion_date = $(this).attr('data-completion-date');
		var inv_amount = $(this).attr('data-amount');
		var filename = $(this).attr('data-filename');
		var baseLink = $(this).attr('data-baseLink');
		var custom_field1 = $(this).attr("data-custom_field1") || "";
		var custom_field2 = $(this).attr("data-custom_field2") || "";
		var custom_field3 = $(this).attr("data-custom_field3") || "";
		var custom_field4 = $(this).attr("data-custom_field4") || "";
		var custom_field5 = $(this).attr("data-custom_field5") || "";
		var custom_field6 = $(this).attr("data-custom_field6") || "";
		var custom_field7 = $(this).attr("data-custom_field7") || "";
		var custom_field8 = $(this).attr("data-custom_field8") || "";
		var custom_field9 = $(this).attr("data-custom_field9") || "";
		var custom_field10 = $(this).attr("data-custom_field10") || "";
		var template = $(this).attr("data-template");
		var template_size = $(this).attr("data-template-size");
		var template_orientation = $(this).attr("data-template-orientation");
        var tracking_link = $(this).attr('data-tracking-link');
		var mySubject = $(this).attr('data-subject') || `Report from {{org-name}}`;
		var myBody = $(this).attr('data-body') || `Dear {{company}},<br><br>Please find the attached report.<br><br>Feel free to reach out if you have any questions or need clarification.<br><br>Best regards,<br>{{org-name}}`;

        if($(this).attr('data-isexcel') == "true") {
            $(".isexcel").val($(this).attr('data-isexcel'));
            $.getJSON(baseLink, function(response) {
                $('.modal-body #baseLink').val(response.baseLink);
            });
            $(".note.last").html("Note: Document Excel file will attached with mail body.");
        }
		var myBody = myBody.replaceAll('{{company}}',cmp_name)
												.replaceAll('{{contact-person}}',cmp_contactperson)
												.replaceAll('{{invoice-no}}',inv_id)
												.replaceAll('{{amount}}',inv_amount)
												.replaceAll('{{invoice-date}}',inv_date)
												.replaceAll('{{completion-date}}',completion_date)
												.replaceAll('{{org-name}}',`ANAND ASSOCIATES`);
												if (custom_field1 !== "" && enable_custom_field1==1) { myBody = myBody.replaceAll(/{{cf-1}}/g, custom_field1);} else { myBody = myBody.replaceAll(/{{cf-1}}/g, ''); }
												if (custom_field2 !== "" && enable_custom_field2==1) { myBody = myBody.replaceAll(/{{cf-2}}/g, custom_field2); } else { myBody = myBody.replaceAll(/{{cf-2}}/g, ''); }
												if (custom_field3 !== "" && enable_custom_field3==1) { myBody = myBody.replaceAll(/{{cf-3}}/g, custom_field3); } else { myBody = myBody.replaceAll(/{{cf-3}}/g, ''); }
												if (custom_field4 !== "" && enable_custom_field4==1) { myBody = myBody.replaceAll(/{{cf-4}}/g, custom_field4); } else { myBody = myBody.replaceAll(/{{cf-4}}/g, ''); }
												if (custom_field5 !== "" && enable_custom_field5==1) { myBody = myBody.replaceAll(/{{cf-5}}/g, custom_field5); } else { myBody = myBody.replaceAll(/{{cf-5}}/g, ''); }
												if (custom_field6 !== "" && enable_custom_field6==1) { myBody = myBody.replaceAll(/{{cf-6}}/g, custom_field6); } else { myBody = myBody.replaceAll(/{{cf-6}}/g, ''); }
												if (custom_field7 !== "" && enable_custom_field7==1) { myBody = myBody.replaceAll(/{{cf-7}}/g, custom_field7); } else { myBody = myBody.replaceAll(/{{cf-7}}/g, ''); }
												if (custom_field8 !== "" && enable_custom_field8==1) { myBody = myBody.replaceAll(/{{cf-8}}/g, custom_field8); } else { myBody = myBody.replaceAll(/{{cf-8}}/g, ''); }
												if (custom_field9 !== "" && enable_custom_field9==1) { myBody = myBody.replaceAll(/{{cf-9}}/g, custom_field9); } else { myBody = myBody.replaceAll(/{{cf-9}}/g, ''); }
												if (custom_field10 !== "" && enable_custom_field10==1) { myBody = myBody.replaceAll(/{{cf-10}}/g, custom_field10); } else { myBody = myBody.replaceAll(/{{cf-10}}/g, ''); }

        if (tracking_link) {
            myBody = myBody.replaceAll('{{tracking-link}}', 'Tracking Link : ' + tracking_link);
        } else {
            myBody = myBody.replaceAll('{{tracking-link}}', '');
        }

        var products = [];

        if(products.length > 0){
            myBody = myBody.replaceAll(/{{product}}(.*?){{--product}}/gs, function(_, match) {
                return products.map(product => {
                    return match.replaceAll(/{{(p-[\w-]+)(?::([^}]+))?}}/g, function(_, key, label) {
                        let value = '';

                        if (key === 'p-name') {
                            value = product.name;
                        } else if (key === 'p-quantity') {
                            value = product.qty;
                        } else if (key === 'p-price') {
                            value = product.price;
                        } else if (key === 'p-taxable-amount') {
                            value = product.taxable_amount;
                        } else if (key === 'p-total') {
                            value = product.grand_total;
                        }

                        if (label) {
                            if (label.includes('|')) {
                                const parts = label.split('|');
                                const prefix = parts[0] ? parts[0].trim() + ' ' : '';
                                const suffix = parts[1] ? ' ' + parts[1].trim() : '';
                                return `${prefix}${value}${suffix}`.trim();
                            } else {
                                return `${label} ${value}`;
                            }
                        } else {
                            return `${value}`;
                        }
                    });
                }).join('');
            });
        }

		mySubject = mySubject.replaceAll('{{invoice-no}}',inv_id)
												 .replaceAll('{{org-name}}',`ANAND ASSOCIATES`);
		
		if (cmp_email && cmp_email.trim() !== "") {
			$(".modal-body #cmp_email").val( cmp_email.split(' ').join('') );
		}
		$(".modal-body #cmp_cc").val(cmp_cc);
		$(".modal-body #cmp_bcc").val(cmp_bcc);
		$(".modal-body #subject").val( mySubject );
		$(".modal-body .jqte_editor").html( myBody );
        $(".modal-body #body").html( myBody );
        $(".modal-body #cmp_name").val( cmp_name );
		$(".modal-body #inv_id").val( inv_id );
		$(".modal-body #inv_id").attr('data-isEway',is_Eway);
		$(".modal-body #po_date").val( po_date );
		$(".modal-body #po_no").val( po_no );
		$(".modal-body #inv_detail_id").val( inv_detail_id );
		$(".modal-body #inv_date").val( inv_date );
		$(".modal-body #completion_date").val( completion_date );
		$(".modal-body #inv_amount").val( inv_amount );
		$(".modal-body #filename").val( filename );
		$(".modal-body #baseLink").val( baseLink );
		$(".modal-body #template").val( template );
		$(".modal-body #template_size").val( template_size );
		$(".modal-body #template_orientation").val( template_orientation );
		$(".modal-body #to_validate").html( "" );
		$(".modal-body #subject_validate").html( "" );
		$(".modal-body #body_validate").html( "" );
		$(".modal-body #pdf-preview-name .title").html( filename );
		$("#pdf-preview").attr('data-template', template);
		$("#pdf-preview").attr('data-template-size', template_size);
		$("#pdf-preview").attr('data-template-orientation', template_orientation);
		$("#pdf-preview").attr('data-baseLink', baseLink);
		$("#pdf-preview").attr('data-filename', filename);
		$("#EmailModal form #subject").trigger('input');
	});
	
	}
	catch(error) {
  
}

	$('#EmailModal').find('#cmp_email, #cmp_cc, #cmp_bcc, #subject, .jqte_editor').on('input keyup', function(){
		generateFormToken('EmailModalForm',['cmp_email','cmp_cc','cmp_bcc','subject']).then((token) => {$("#EmailModal #v_data").val(token);});

	});
});
</script>
<div id="PrintInvoiceModal" class="modal popup_right_slider fade" role="dialog" style="display: none;">
	<div class="modal-dialog">
		<form class="form-horizontal" method="post" id="PrintInvoiceModalForm">
			<!-- Modal content-->
			<div class="modal-content is-loading">
				<div id="iframeContainer">
					<iframe name="print_iframe" id="Invoice_iframe" src="" frameborder="0" style="width:100%;height:100vh;float:left;"></iframe>
				</div>
				<div class="preloader-overly">
				<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.0" width="80px" height="80px" viewBox="0 0 128 128" xml:space="preserve"><g><path fill="#00ba8c" fill-opacity="1" d="M109.25 55.5h-36l12-12a29.54 29.54 0 0 0-49.53 12H18.75A46.04 46.04 0 0 1 96.9 31.84l12.35-12.34v36zm-90.5 17h36l-12 12a29.54 29.54 0 0 0 49.53-12h16.97A46.04 46.04 0 0 1 31.1 96.16L18.74 108.5v-36z"></path><animateTransform attributeName="transform" type="rotate" from="0 64 64" to="360 64 64" dur="880ms" repeatCount="indefinite"></animateTransform></g></svg>
				</div>
				
			</div>
		</form>
	</div>
</div>

</main>
</body>
</html>

From above Create a GST invoice Creator page