<?php
session_start(); 
		/*User Add Data page */

	
	if(!isset($_SESSION['linkarisecrm']))
	{
		header('Location: index.php');
		return;
	}
	$ftime=0;
	$ttime=23;
	$_SESSION['_token']=bin2hex(openssl_random_pseudo_bytes(16));
		$brmid=$_SESSION['linkarisebranchid'];
		$cmpmid=$_SESSION['linkarisecmpmid'];
	$umid = $_SESSION['linkariseumid'];
	 $lacrmcmpstate = $_SESSION['linkarisecmpstate'];
	
					date_default_timezone_set("Asia/Kolkata");
	$mdate= date('d-m-Y');
		$fdate= Date('d-m-Y', strtotime("+7 days"));
				
	
	
?>
<!DOCTYPE html>
<!--
Author: Keenthemes
Product Name: Metronic - Bootstrap 5 HTML, VueJS, React, Angular. Laravel, Asp.Net Core, Ruby on Rails, Spring Boot, Blazor, Django, Express Node.js & Flask Admin Dashboard Theme
Purchase: https://1.envato.market/EA4JP
Website: http://www.keenthemes.com
Contact: support@keenthemes.com
Follow: www.twitter.com/keenthemes
Dribbble: www.dribbble.com/keenthemes
Like: www.facebook.com/keenthemes
License: For each use you must have a valid license purchased only from above link in order to legally use the theme for your project.
-->
<html lang="en">
	<!--begin::Head-->
	<head>
		<title>Sales Order Generate</title>
		<meta charset="utf-8" />
		<meta name="description" content="The most advanced Bootstrap Admin Theme on Themeforest trusted by 100,000 beginners and professionals. Multi-demo, Dark Mode, RTL support and complete React, Angular, Vue, Asp.Net Core, Rails, Spring, Blazor, Django, Flask & Laravel versions. Grab your copy now and get life-time updates for free." />
		<meta name="keywords" content="metronic, bootstrap, bootstrap 5, angular, VueJs, React, Asp.Net Core, Rails, Spring, Blazor, Django, Flask & Laravel starter kits, admin themes, web design, figma, web development, free templates, free admin themes, bootstrap theme, bootstrap template, bootstrap dashboard, bootstrap dak mode, bootstrap button, bootstrap datepicker, bootstrap timepicker, fullcalendar, datatables, flaticon" />
		<meta name="viewport" content="width=device-width, initial-scale=1" />
		<meta property="og:locale" content="en_US" />
		<meta property="og:type" content="article" />
		<meta property="og:title" content="Metronic - Bootstrap 5 HTML, VueJS, React, Angular. Laravel, Asp.Net Core, Ruby on Rails, Spring Boot, Blazor, Django, Express Node.js & Flask Admin Dashboard Theme" />
		<meta property="og:url" content="https://keenthemes.com/metronic" />
		<meta property="og:site_name" content="Keenthemes | Metronic" />
		<link rel="canonical" href="https://preview.keenthemes.com/metronic8" />
		<link rel="shortcut icon" href="assets/media/logos/favicon.ico" />
		<!--begin::Fonts(mandatory for all pages)-->
		<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Inter:300,400,500,600,700" />
		<!--end::Fonts-->
		<!--begin::Vendor Stylesheets(used for this page only)-->
		<link href="assets/plugins/custom/datatables/datatables.bundle.css" rel="stylesheet" type="text/css" />
		<!--end::Vendor Stylesheets-->
		<!--begin::Global Stylesheets Bundle(mandatory for all pages)-->
		<link href="assets/plugins/global/plugins.bundle.css" rel="stylesheet" type="text/css" />
		<link href="assets/css/style.bundle.css" rel="stylesheet" type="text/css" />
		<!--end::Global Stylesheets Bundle-->
	</head>
	<?php

include("connect.php");
	include("removespecial.php");





		date_default_timezone_set("Asia/Kolkata");
				$mdate1= date('Y-m-d H:i:s');

				$par1 = $_SESSION['linkariseufullname'];
				$ipaddress = "";

				if (getenv('HTTP_CLIENT_IP'))
					$ipaddress = getenv('HTTP_CLIENT_IP');
				else if(getenv('HTTP_X_FORWARDED_FOR'))
					$ipaddress = getenv('HTTP_X_FORWARDED_FOR');
				else if(getenv('HTTP_X_FORWARDED'))
					$ipaddress = getenv('HTTP_X_FORWARDED');
				else if(getenv('HTTP_FORWARDED_FOR'))
					$ipaddress = getenv('HTTP_FORWARDED_FOR');
				else if(getenv('HTTP_FORWARDED'))
					$ipaddress = getenv('HTTP_FORWARDED');
				else if(getenv('REMOTE_ADDR'))
					$ipaddress = getenv('REMOTE_ADDR');
				else
					$ipaddress = 'UNKNOWN';

				$userserver=$_SERVER['HTTP_USER_AGENT'];
				$eve1 = "insert into res_user_log (lid,mobile,lastupdatedtime,pagename,taskname,ipaddress,useragentdetail) values(NULL,'$par1','$mdate1','Salesmen','Edit Salesmen','$ipaddress','$userserver')";
				$re1 = mysqli_query($conn, $eve1);





	$custid=0;
	$ordermid=0;
	$orderno1=0;
	$reviseorder=0;
	$copyorder=0;
	$ordershipto="";
	$qmid=0;
	$orderewaybillno="";
	$agentmid=0;
	$agentcommision=0;
	$agentcommisionamt=0;
	$title="Generate Sales Order";
	if(isset($_POST['ordermid']))
	{
		$ordermid=(int)mysqli_real_escape_string($conn,$_POST['ordermid']);
		$title="Update Sales Order:";
	}
	else if(isset($_GET['id']))
	{
		$title="Update Sales Order :".$_GET['id'];
		$ordermid=(int)mysqli_real_escape_string($conn,$_GET['id']);
	}
	else if(isset($_GET['qmid']))
	{
		$qmid=(int)mysqli_real_escape_string($conn,$_GET['qmid']);
		$title="Generate Sales Order from Quotation:";
	}
	else if(isset($_GET['rid']))
	{
		$ordermid=(int)mysqli_real_escape_string($conn,$_GET['rid']);
		$reviseorder=1;
		$title="Revised order from Quotation :".$_GET['rid'];
	}
	else if(isset($_GET['copyid']))
	{
		$title="Revised order from ".$_GET['copyid'];
		$ordermid=(int)mysqli_real_escape_string($conn,$_GET['copyid']);
		$copyorder=1;
	}
	else{
		$ordermid=0;
		$title="Generate Sales Order";
	}
	$ordergrossamount=0;
	$ordertotaltaxamount=0;
	$ordertotalamount=0;

	$orderdeliverylotno=0;
	$orderno=0;
	$orderdispatchthrough="";
	$orderdestination="";
	$orderremarks="";
	
	$orderyear='22-23';
	$orderprefix='SO-';
	$evelastyear = "select * from res_company_master where cmpmid=$cmpmid";
	$relastyear = mysqli_query($conn, $evelastyear);
	while($rtlastyear = mysqli_fetch_assoc($relastyear))
	{
		$orderyear=$rtlastyear['cmpyear'];
		$orderprefix=$rtlastyear['orderprefix'];
	}
	
	
	$evemaxq = "SELECT max( ordermno ) AS maxordermno FROM res_salesorder_master where cmpmid=$cmpmid and orderyear='$orderyear'";
	$remaxq = mysqli_query($conn, $evemaxq);
	while($rtmaxq = mysqli_fetch_assoc($remaxq))
	{
		$maxordermno=$rtmaxq['maxordermno'];
	}
	$maxordermno1=$maxordermno+1;
	$maxordermno2=$maxordermno1;	
	$orderfordisplay=$orderprefix.$maxordermno2;
	if($ordermid!=0)
	{
		$eve = "select * from res_salesorder_master where ordermid=$ordermid and  cmpmid=$cmpmid";
		$re = mysqli_query($conn, $eve);
		$orderfordisplay="";
		while($rt = mysqli_fetch_assoc($re))
		{
		$custid=$rt['customermid'];
		$ordermno=$rt['ordermno'];
		$orderfordisplay=$rt['orderfordisplay'];
		$terms=$rt['orderterms'];
		$ordertotaltaxamount=$rt['ordertotaltaxamount'];
		$ordertotalamount=$rt['ordertotalamount'];
		$ordergrossamount=$rt['ordergrossamount'];
		$ordernetamount=$rt['ordernetamount'];
		
		$ordershipto=removespecialchar($rt['ordershipto']);
		$mdate=date("d-m-Y", strtotime($rt['orderdate']));

		$orderrefno=$rt['orderrefno'];
		$orderdeliverylotno=$rt['orderdeliverylotno'];
		$orderdispatchthrough=removespecialchar($rt['orderdispatchthrough']);
		$orderno=$rt['orderno'];
		$orderdestination=$rt['orderdestination'];
		$orderremarks=$rt['orderremarks'];
		$orderewaybillno=$rt['orderewaybillno'];
		$agentmid=$rt['agentmid'];
		$agentcommision=$rt['agentcommision'];
		$agentcommisionamt=$rt['agentcommisionamt'];
		
		$createdby="";
		$kindatten="";

		$eve4="select * from res_party_master where partymid=$custid";
		$re4 = mysqli_query($conn, $eve4);
		while($rt4 = mysqli_fetch_assoc($re4))
		{
			$cname=removespecialchar($rt4['partyname']);
			$address=removespecialchar($rt4['partyaddress']);
			$city=$rt4['partycity'];
			$state=$rt4['partystate'];
			$email=$rt4['partyemail'];
			$cmobile=$rt4['partymobile'];
		}
	}
	
		if(isset($_GET['id']))
		{
			$title="Update Sales Order : $orderfordisplay";
		}
		else if(isset($_GET['rid']))
		{
			$title="Revised Quotation from order : $orderfordisplay";
		}
		else if(isset($_GET['copyid']))
		{
			$title="Copy order from order : $orderfordisplay";
		}
		else{
			$title="Generate Sales Order";
		}

	}
	else if($qmid!=0)
	{
		$eve = "select * from res_quotation_master where qmid=$qmid and  cmpmid=$cmpmid";
		$re = mysqli_query($conn, $eve);
		$qnofordisplay="";
		while($rt = mysqli_fetch_assoc($re))
		{
		$custid=$rt['partymid'];
		$ordermno=$rt['qmno'];
		$orderfordisplay=$rt['qnofordisplay'];
		$terms=$rt['qterms'];
		$ordertotaltaxamount=$rt['qtotaltaxamount'];
		$ordertotalamount=$rt['qtotalamount'];
		$ordergrossamount=$rt['qgrossamount'];
		$ordernetamount=$rt['qnetamount'];
		
	
		$mdate=date("d-m-Y", strtotime($rt['qdate']));

		$orderrefno=$rt['qrefno'];
		
	
	
		
		$createdby="";
		$kindatten="";

		 $eve4="select * from res_party_master where partymid=$custid";
		$re4 = mysqli_query($conn, $eve4);
		while($rt4 = mysqli_fetch_assoc($re4))
		{
			$cname=removespecialchar($rt4['partyname']);
			$address=removespecialchar($rt4['partyaddress']);
			$city=$rt4['partycity'];
			$state=$rt4['partystate'];
			$email=$rt4['partyemail'];
			$cmobile=$rt4['partymobile'];
		}
	}
	
		if(isset($_GET['id']))
		{
			$title="Update Sales Order : $orderfordisplay";
		}
		else if(isset($_GET['rid']))
		{
			$title="Revised Quotation from order : $orderfordisplay";
		}
		else if(isset($_GET['copyid']))
		{
			$title="Copy order from order : $orderfordisplay";
		}
		else{
			$title="Generate Sales Order";
		}

	}
	else{
		
		$evelastyear = "select * from res_company_master where cmpmid=$cmpmid";
	$relastyear = mysqli_query($conn, $evelastyear);
	while($rtlastyear = mysqli_fetch_assoc($relastyear))
	{
		$orderyear=$rtlastyear['fyear'];
		$orderprefix=$rtlastyear['orderprefix'];
		$terms=$rtlastyear['orderterms'];
		$orderremarks=$rtlastyear['orderdeclaration'];
	}
	
	
		


		$custid=0;
		$ordermno="";

		$orderrefno="";
		$createdby="";
		$kindatten="";
		$ordershipto="";
		
		$cname="";
		$address="";
		$city="";
		$state="";
		$email="";
		$cmobile="";
	}
?>
	<!--end::Head-->
	<!--begin::Body-->
<body id="kt_body" data-kt-app-layout="dark-sidebar" data-kt-app-header-fixed="true" data-kt-app-sidebar-enabled="true"  data-kt-app-sidebar-hoverable="true" data-kt-app-sidebar-push-header="true" data-kt-app-sidebar-push-toolbar="true" data-kt-app-sidebar-push-footer="true" data-kt-app-toolbar-enabled="true"  class="app-default">
		<!--begin::Theme mode setup on page load-->
		<script>var defaultThemeMode = "light"; var themeMode; if ( document.documentElement ) { if ( document.documentElement.hasAttribute("data-theme-mode")) { themeMode = document.documentElement.getAttribute("data-theme-mode"); } else { if ( localStorage.getItem("data-theme") !== null ) { themeMode = localStorage.getItem("data-theme"); } else { themeMode = defaultThemeMode; } } if (themeMode === "system") { themeMode = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"; } document.documentElement.setAttribute("data-theme", themeMode); }</script>
		<!--end::Theme mode setup on page load-->
		<!--begin::Main-->
		<!--begin::Root-->
		<div class="d-flex flex-column flex-root">
			<!--begin::Page-->
			<div class="page d-flex flex-row flex-column-fluid">
				<!--begin::Aside-->
				<?php include('sidebar.php'); ?>
				<!--end::Aside-->
				<!--begin::Wrapper-->
				<div class="wrapper d-flex flex-column flex-row-fluid" id="kt_wrapper">
					<!--begin::Header-->
					<div id="kt_header" style="" class="header align-items-stretch">
						<!--begin::Container-->
						<div class="container-fluid d-flex align-items-stretch justify-content-between">
							<!--begin::Aside mobile toggle-->
							<div class="d-flex align-items-center d-lg-none ms-n3 me-1" title="Show aside menu">
								<div class="btn btn-icon btn-active-color-primary w-40px h-40px" id="kt_aside_toggle">
									<!--begin::Svg Icon | path: icons/duotune/abstract/abs015.svg-->
									<span class="svg-icon svg-icon-1">
										<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
											<path d="M21 7H3C2.4 7 2 6.6 2 6V4C2 3.4 2.4 3 3 3H21C21.6 3 22 3.4 22 4V6C22 6.6 21.6 7 21 7Z" fill="currentColor" />
											<path opacity="0.3" d="M21 14H3C2.4 14 2 13.6 2 13V11C2 10.4 2.4 10 3 10H21C21.6 10 22 10.4 22 11V13C22 13.6 21.6 14 21 14ZM22 20V18C22 17.4 21.6 17 21 17H3C2.4 17 2 17.4 2 18V20C2 20.6 2.4 21 3 21H21C21.6 21 22 20.6 22 20Z" fill="currentColor" />
										</svg>
									</span>
									<!--end::Svg Icon-->
								</div>
							</div>
							<!--end::Aside mobile toggle-->
							<!--begin::Mobile logo-->
							<div class="d-flex align-items-center flex-grow-1 flex-lg-grow-0">
								<a href="../../demo4/dist/index.html" class="d-lg-none">
									<img alt="Logo" src="assets/media/logos/demo4-mobile.svg" class="h-25px" />
								</a>
							</div>
							<!--end::Mobile logo-->
							<div class="d-flex align-items-center" id="kt_header_wrapper">
								<!--begin::Page title-->
								<div class="page-title d-flex flex-column align-items-start justify-content-center flex-wrap me-lg-20 pb-5 pb-lg-0" data-kt-swapper="true" data-kt-swapper-mode="prepend" data-kt-swapper-parent="{default: '#kt_content_container', lg: '#kt_header_wrapper'}">
									<!--begin::Heading-->
									<h1 class="text-dark fw-bold my-1 fs-3 lh-1">Add Sales Order</h1>
									<!--end::Heading-->
									<!--begin::Breadcrumb-->
									<ul class="breadcrumb fw-semibold fs-8 my-1">
										<li class="breadcrumb-item text-muted">
											<a href="dashboard.php" class="text-muted">Home</a>
										</li>
										<li class="breadcrumb-item text-muted">Sales Management</li>
										<li class="breadcrumb-item text-muted">Add Sales Order</li>
									</ul>
									<!--end::Breadcrumb-->
								</div>
								<!--end::Page title=-->
							</div>
							<!--begin::Wrapper-->
							<?php include('header.php'); ?>
							<!--end::Wrapper-->
						</div>
						<!--end::Container-->
					</div>
					<!--end::Header-->
					<!--begin::Content-->
					<div class="content d-flex flex-column flex-column-fluid" id="kt_content">
						<!--begin::Container-->
						<div class="container-xxl" id="kt_content_container">
							<!--begin::Contacts App- Add New Contact-->
							<div class="row g-7">
							<div class="col-xl-2">
							</div>
						
								<!--begin::Content-->
								<div class="col-xl-12">
								
									<!--begin::Contacts-->
									<div class="card card-flush h-lg-100" id="kt_contacts_main">
									
										<!--begin::Card header-->
										<div class="card-header pt-7" id="kt_chat_contacts_header">
											<!--begin::Card title-->
											
											<div class="card-title">
												<!--begin::Svg Icon | path: icons/duotune/communication/com005.svg-->
												
												<!--end::Svg Icon-->
												<h2><span class="menu-icon">
													<i class="fas fa-user"></i>
												</span> Customer</h2>
											</div>
											<!--end::Card title-->
										</div>
										<!--end::Card header-->
						<!--begin::Card body-->
										<div class="card-body pt-5">
											<!--begin::Form-->
										<form id="myForm" class="form" action="salesordergenerate2.php" method="POST" enctype="multipart/form-data">
											<!--begin::Row-->
										<input type="hidden" name="ordermid" value="<?php echo $ordermid;?>">
														<input type="hidden" name="qmid" value="<?php echo $qmid;?>">
														<input type="hidden" name="custid" value="<?php echo $custid;?>">
														<input type="hidden" name="copyorder" value="<?php echo $copyorder;?>">
												<div class="row row-cols-1 row-cols-sm-2 rol-cols-md-1 row-cols-lg-2">
													<!--begin::Col-->
													<div class="col">
													<!--begin::Input group-->
														<div class="fv-row mb-7">
														<?php
															$tt="";
														if($_SESSION['linkariseutype']<>'Admin')
														{
															$tt=" and umid=$umid";
														}
															 $eve_category = "select * from res_party_master where partytype='Inquiry' and cmpmid=$cmpmid $tt";
															?>	<!--begin::Label-->
															<label class="fs-6 fw-semibold form-label mt-3">
																<span class="required">Customer Name</span>
																
															</label>
															<!--end::Label-->
															<!--begin::Input-->
															
													<select class="form-select form-select-solid"  name="cmid" id="skills" onchange="skills" for="skills" required>
													<option value="0">select Customer</option>
													<?php
													
															$re_category = mysqli_query($conn, $eve_category);
																while($rt_category = mysqli_fetch_assoc($re_category))
																{
																		$partyname=$rt_category['partyname'];
																$partymid=$rt_category['partymid'];
																$partymobile=$rt_category['partymobile'];
																$partycpname=$rt_category['partycpname'];
																	
																	if($partymid==$custid)
																{
																	echo "<option value='$partymid' selected>$partyname-$partycpname ($partymobile)</option>";
																	}
																else
																{
																	echo "<option value='$partymid'>$partyname-$partycpname ($partymobile)</option>";
																}
																}
															?>
													</select>
													<!--end::Input-->
														</div>
														<!--end::Input group-->
												</div>
													<!--end::Col-->
												<!--begin::Col-->
													<div class="col">
											<!--begin::Input group-->
														<div class="fv-row mb-7">
															<!--begin::Label-->
															<label class="fs-6 fw-semibold form-label mt-3">
																<span class="">Email Id</span>
																
															</label>
															<!--end::Label-->
															<!--begin::Input-->
															
												<input type="text" class="form-control form-control-solid" name="email" id="dcontact11" value="<?php echo $email; ?>" readonly>
															<!--end::Input-->
														</div>
														<!--end::Input group-->
												</div>
													<!--end::Col-->
														</div>
												<!--end::Row-->
												
											
											<!--begin::Row-->
												<div class="row row-cols-1 row-cols-sm-2 rol-cols-md-1 row-cols-lg-2">
													<!--begin::Col-->
													<div class="col">
											<!--begin::Input group-->
														<div class="fv-row mb-7">
															<!--begin::Label-->
															<label class="fs-6 fw-semibold form-label mt-3">
																<span class="">Mobile No.</span>
																
															</label>
															<!--end::Label-->
															<!--begin::Input-->
															<input type="text" class="form-control form-control-solid" name="mobile" id="dcontact12"  value="<?php echo $cmobile; ?>" readonly>
															<!--end::Input-->
														</div>
														<!--end::Input group-->
												</div>
													<!--end::Col-->
													<!--begin::Col-->
													<div class="col">
													<!--begin::Input group-->
														<div class="fv-row mb-7">
															<!--begin::Label-->
															<label class="fs-6 fw-semibold form-label mt-3">
																<span class="">Address</span>
																
															</label>
															<!--end::Label-->
															<!--begin::Input-->
															
												<textarea type="text" class="form-control form-control-solid" name="dcontact2" id="dcontact2"  value="" readonly><?php echo $address; ?></textarea>
															<!--end::Input-->
														</div>
														<!--end::Input group-->
													</div>
													<!--end::Col-->
												</div>
												<!--end::Row-->
											<!--begin::Row-->
												<div class="row row-cols-1 row-cols-sm-2 rol-cols-md-1 row-cols-lg-2">
													<!--begin::Col-->
													<div class="col">
														<!--begin::Input group-->
														<div class="fv-row mb-7">
															<!--begin::Label-->
															<label class="fs-6 fw-semibold form-label mt-3">
																<span class="">State</span>
																
															</label>
															<!--end::Label-->
															<!--begin::Input-->
															<input type="text" class="form-control form-control-solid" name="dcontact4" id="dcontact4" readonly value="<?php echo $state; ?>">
															<!--end::Input-->
														</div>
														<!--end::Input group-->
													</div>
													
												</div>
												<!--end::Row-->
											
											
												
												
												
													
												<!--begin::Separator-->
												<div class="separator mb-6"></div>
												<!--end::Separator-->
													<h3>Product Details</h3>
													
													
												<div class="row row-cols-1 row-cols-sm-1 rol-cols-md-1 row-cols-lg-1">
												<!--begin::Col-->
												<!--begin::Col-->
													<div class="col" >
														<!--begin::Input group-->
														<div class="fv-row mb-7" >
													<table id="items" border="0" style="width:100%">
											<tr> <th>Product Description </th> <th>Quantity </th> <th>Unit </th><th>Rate</th><th>Discount </th> <th>GST </th><th>Amount </th></tr>
										</table>
										
										
										<table id="items" border="0" cellspacing="5" cellpadding="5" class="table align-middle table-row-dashed">
											<tr> <th> <input type="button"  id="add_item" value="Add" class="btn btn-primary btn-sm"/> </th><th colspan="3"></th> <th width='15%'> Sub Amount</th> <th width='25%'><input type="text" name="total1" id="total1" readonly value="<?php echo $ordertotalamount;?>" required class="form-control "> </th></tr><tr> <th colspan="4"> </th> <th width='15%'>GST Amount</th> <th width='25%'><input type="text" name="gsttotal" id="gsttotal" readonly value="<?php echo $ordertotaltaxamount;?>" required class="form-control "> </th></tr><tr> <th colspan="4"> </th><th width='15%'> Grand Amount</th> <th width='25%'><input type="text" name="nettotal" id="nettotal" readonly value="<?php echo $ordergrossamount;?>" required class="form-control "> </th></tr>
<tr> <th colspan="4"> </th> <th>Follow-Up Date</th><td>
															<div class="" data-date-format="dd-mm-yyyy" >
																	<input type="text" id="kt_daterangepicker_2" name="fdate" class="form-control" value="<?php echo $fdate;?>">
																</div>
										  </td></tr>
										   
										</table>
												</div>
														<!--end::Input group-->
													</div>
													<!--end::Col-->
													</div>
													
									
													   	<span class="success"><?php if(isset($message)) { echo $message; }?></span>

										<input type="hidden" id="mycounter" name="mycounter" value="10">
										<input type="hidden" id="mycounter2" name="mycounter2" value="10">
											<!--end::Card body-->
										<div class="card-body pt-5">
											

											
												<h2>Other Details</h2>
											<!--begin::Row-->
												<div class="row row-cols-1 row-cols-sm-2 rol-cols-md-1 row-cols-lg-2">
												
												<!--begin::Col-->
													<div class="col">
														<!--begin::Input group-->
														<div class="fv-row mb-7">
															<!--begin::Label-->
															<label class="fs-6 fw-semibold form-label mt-3">
																<span class="">Order Number</span>
																
															</label>
															<!--end::Label-->
															<!--begin::Input-->
															<input  type="hidden" name="ordermno"  value="<?php echo $maxordermno2;?>" readonly><input type="text" class="form-control form-control-solid" name="" placeholder="Enter Invoice Number" value="<?php echo $orderfordisplay;?>" readonly>
															<!--end::Input-->
														</div>
														<!--end::Input group-->
													</div>
													<!--end::Col-->
													
												<!--begin::Col-->
													<div class="col">
														<!--begin::Input group-->
														<div class="fv-row mb-7">
															<!--begin::Label-->
															<label class="fs-6 fw-semibold form-label mt-3">
																<span class="">Eway Bill Number</span>
																
															</label>
															<!--end::Label-->
															<!--begin::Input-->
															<input type="text" class="form-control form-control-solid" name="orderewaybillno" placeholder="Enter Eway Bill Number" value="<?php echo $orderewaybillno;?>" >
															<!--end::Input-->
														</div>
														<!--end::Input group-->
													</div>
													<!--end::Col-->
													
													</div>
												<!--end::Row-->
												<!--begin::Row-->
												<div class="row row-cols-1 row-cols-sm-2 rol-cols-md-1 row-cols-lg-2">
												
												
													
												<div class="col">
														<!--begin::Input group-->
														<div class="fv-row mb-7">
															<!--begin::Label-->
															<label class="fs-6 fw-semibold form-label mt-3">
																<span class="">Order Date</span>
																
															</label>
															<!--end::Label-->
															<!--begin::Input-->
															
		<input class="form-control form-control-solid" placeholder="Select date" name="orderdate" id="kt_daterangepicker_1" value="<?php echo $mdate;?>" >
															<!--end::Input-->
														</div>
														<!--end::Input group-->
													</div>
													
														<!--begin::Col-->
													<div class="col">
														<!--begin::Input group-->
														<div class="fv-row mb-7">
															<!--begin::Label-->
															<label class="fs-6 fw-semibold form-label mt-3">
																<span class="">Reference Number / LOT Number </span>
																
															</label>
															<!--end::Label-->
															<!--begin::Input-->
															<input type="text" class="form-control form-control-solid" name="orderrefno" placeholder="Enter Reference Number" value="<?php echo $orderrefno;?>" >
															<!--end::Input-->
														</div>
														<!--end::Input group-->
													</div>
													<!--end::Col-->
													
													</div>
												<!--end::Row-->
												<!--begin::Row-->
												<div class="row row-cols-1 row-cols-sm-2 rol-cols-md-1 row-cols-lg-2">
												
											
														<!--begin::Col-->
													<div class="col">
														<!--begin::Input group-->
														<div class="fv-row mb-7">
															<!--begin::Label-->
															<label class="fs-6 fw-semibold form-label mt-3">
																<span class="">Delivery LOT Number </span>
																
															</label>
															<!--end::Label-->
															<!--begin::Input-->
															<input type="text" class="form-control form-control-solid" name="orderdeliverylotno" placeholder="Enter Delivery LOT Number" value="<?php echo $orderdeliverylotno;?>" >
															<!--end::Input-->
														</div>
														<!--end::Input group-->
													</div>
													<!--end::Col-->
														<!--begin::Col-->
													<div class="col">
														<!--begin::Input group-->
														<div class="fv-row mb-7">
															<!--begin::Label-->
															<label class="fs-6 fw-semibold form-label mt-3">
																<span class="">Destination</span>
																
															</label>
															<!--end::Label-->
															<!--begin::Input-->
															<input type="text" class="form-control form-control-solid" name="orderdestination" placeholder="Enter Destination" value="<?php echo $orderdestination;?>" >
															<!--end::Input-->
														</div>
														<!--end::Input group-->
													</div>
													<!--end::Col-->
													</div>
												<!--end::Row-->
															<!--begin::Row-->
												<div class="row row-cols-1 row-cols-sm-2 rol-cols-md-1 row-cols-lg-2">
												
											
														<!--begin::Col-->
													<div class="col">
														<!--begin::Input group-->
														<div class="fv-row mb-7">
															<!--begin::Label-->
															<label class="fs-6 fw-semibold form-label mt-3">
																<span class="">Dispatch Through</span>
																
															</label>
															<!--end::Label-->
															<!--begin::Input-->
															<input type="text" class="form-control form-control-solid" name="orderdispatchthrough" placeholder="Enter Dispatch Through" value="<?php echo $orderdispatchthrough;?>" >
															<!--end::Input-->
														</div>
														<!--end::Input group-->
													</div>
													<!--end::Col-->
														<!--begin::Col-->
													<div class="col">
														<!--begin::Input group-->
														<div class="fv-row mb-7">
															<!--begin::Label-->
															<label class="fs-6 fw-semibold form-label mt-3">
																<span class="">Ship To</span>
																
															</label>
															<!--end::Label-->
															<!--begin::Input-->
															<textarea type="text" class="form-control form-control-solid" placeholder="Enter Ship To" name="ordershipto" rows="3"><?php echo $ordershipto;?></textarea>
															<!--end::Input-->
														</div>
														<!--end::Input group-->
													</div>
													<!--end::Col-->	
													</div>
												<!--end::Row-->
													<!--begin::Row-->
												<div class="row row-cols-1 row-cols-sm-2 rol-cols-md-1 row-cols-lg-2">
												
												<!--begin::Col-->
													<div class="col">
														<!--begin::Input group-->
														<div class="fv-row mb-7">
															<!--begin::Label-->
															<label class="fs-6 fw-semibold form-label mt-3">
																<span class="">Sales Order Terms</span>
																
															</label>
															<!--end::Label-->
															<!--begin::Input-->
															<textarea type="text" class="form-control form-control-solid" name="orderterms" rows="3"><?php echo $terms;?></textarea>
															<!--end::Input-->
														</div>
														<!--end::Input group-->
													</div>
													<!--end::Col-->
														<!--begin::Col-->
													<div class="col">
														<!--begin::Input group-->
														<div class="fv-row mb-7">
															<!--begin::Label-->
															<label class="fs-6 fw-semibold form-label mt-3">
																<span class="">Declaration</span>
																
															</label>
															<!--end::Label-->
															<!--begin::Input-->
															<textarea type="text" class="form-control form-control-solid" name="orderremarks" rows="2"><?php echo $orderremarks;?></textarea>
															<!--end::Input-->
														</div>
														<!--end::Input group-->
													</div>
													<!--end::Col-->
													</div>
												
																									
											
													
													</div>
												
												
												
												<!--begin::Separator-->
												<div class="separator mb-6"></div>
												<!--end::Separator-->
												
												
												<!--begin::Action buttons-->
												<div class="d-flex justify-content-end">
													<!--begin::Button-->
													<a type="reset" href="salesorder.php"  class="btn btn-light me-3">Cancel</a>
													<!--end::Button-->
													<!--begin::Button-->
													<button type="submit"  class="btn btn-primary">
														<span class="indicator-label">Save</span>
														<span class="indicator-progress">Please wait...
														<span class="spinner-border spinner-border-sm align-middle ms-2"></span></span>
													</button>
													<!--end::Button-->
												</div>
												<!--end::Action buttons-->
											</form>
											<!--end::Form-->
										</div>
										<!--end::Card body-->
									</div>
									<!--end::Contacts-->
								</div>
								<!--end::Content-->
							</div>
							<!--end::Contacts App- Add New Contact-->
						</div>
						<!--end::Container-->
					</div>
					<!--end::Content-->
					<?php include('footer.php'); ?>
					</div>
				<!--end::Wrapper-->
			</div>
			<!--end::Page-->
		</div>
		<!--end::Root-->
		
		<!--end::Main-->
		
		<!--begin::Engage modals-->
		<!--end::Engage modals-->
		<!--begin::Scrolltop-->
		<div id="kt_scrolltop" class="scrolltop" data-kt-scrolltop="true">
			<!--begin::Svg Icon | path: icons/duotune/arrows/arr066.svg-->
			<span class="svg-icon">
				<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
					<rect opacity="0.5" x="13" y="6" width="13" height="2" rx="1" transform="rotate(90 13 6)" fill="currentColor" />
					<path d="M12.5657 8.56569L16.75 12.75C17.1642 13.1642 17.8358 13.1642 18.25 12.75C18.6642 12.3358 18.6642 11.6642 18.25 11.25L12.7071 5.70711C12.3166 5.31658 11.6834 5.31658 11.2929 5.70711L5.75 11.25C5.33579 11.6642 5.33579 12.3358 5.75 12.75C6.16421 13.1642 6.83579 13.1642 7.25 12.75L11.4343 8.56569C11.7467 8.25327 12.2533 8.25327 12.5657 8.56569Z" fill="currentColor" />
				</svg>
			</span>
			<!--end::Svg Icon-->
		</div>
		<!--end::Scrolltop-->
		
		<!--begin::Javascript-->
		<script>var hostUrl = "assets/";</script>
		<!--begin::Global Javascript Bundle(mandatory for all pages)-->
		<script src="assets/plugins/global/plugins.bundle.js"></script>
		<script src="assets/js/scripts.bundle.js"></script>
		<!--end::Global Javascript Bundle-->
		<!--begin::Vendors Javascript(used for this page only)-->
		<script src="assets/plugins/custom/datatables/datatables.bundle.js"></script>
		<!--end::Vendors Javascript-->
		<!--begin::Custom Javascript(used for this page only)-->
		<script src="assets/js/custom/apps/contacts/edit-contact.js"></script>
		<script src="assets/js/widgets.bundle.js"></script>
		<script src="assets/js/custom/widgets.js"></script>
		<script src="assets/js/custom/apps/chat/chat.js"></script>
		<script src="assets/js/custom/utilities/modals/upgrade-plan.js"></script>
		<script src="assets/js/custom/utilities/modals/users-search.js"></script>
		<!--end::Custom Javascript-->
		<script type="text/javascript">
		$(document).ready(function(){
			
			
 $("#kt_daterangepicker_1").flatpickr({
        enableTime:!1,dateFormat:"d-m-Y"
    }
   
);
	$("#kt_daterangepicker_2").flatpickr({
        enableTime:!1,dateFormat:"d-m-Y"
    }
   
);
		});
		</script>
<script type="text/javascript">
	$(document).ready(function(){
		$("#inqfdate").show();
		$("#inqfremarks").show();

        $("#followup").change(function () {
            if ($(this).val() == "Yes") {
                $("#inqfdate").show();
				$("#inqfremarks").show();
            } else {
                $("#inqfdate").hide();
				$("#inqfremarks").hide();
            }
        });
    });
</script>
<script>
				/* $(function() {
					$( "#skills" ).autocomplete({
						source: 'customersearch.php'
					});
				}); */
				$('#skills').on('change',function(){


				//make ajax call to action method to get the description for this value
				$.get("customersearch21.php", { skills : $(this).val() }, function(response) {

				//alert(response);
				//set the value of description text box
				$('#dcontact1').val( $.trim(response) );

				});
				$.get("customersearch22.php", { skills : $(this).val() }, function(response) {

				//alert(response);
				//set the value of description text box
				$('#dcontact2').val( $.trim(response) );

				});
				
				$.get("customersearch24.php", { skills : $(this).val() }, function(response) {

				//alert(response);
				//set the value of description text box
				$('#dcontact4').val( $.trim(response) );

				});
				$.get("customersearch25.php", { skills : $(this).val() }, function(response) {

				//alert(response);
				//set the value of description text box
				$('#dcontact5').val( $.trim(response) );

				});
				$.get("customersearch27.php", { skills : $(this).val() }, function(response) {

				//alert(response);
				//set the value of description text box
				$('#dcontact11').val( $.trim(response) );

				});
				$.get("customersearch28.php", { skills : $(this).val() }, function(response) {

				//alert(response);
				//set the value of description text box
				$('#dcontact12').val( $.trim(response) );

				});
				});
			</script>
<script src="js/jquery.cookie.js"></script>

<script type="text/javascript">
$(document).ready(function(){
	$('#skills').on('change',function(){
		var skills = $(this).val();

		//alert(skills);

		$.cookie("example", skills); // Sample 1

		//alert( $.cookie("example") );

		//$.cookie("skillstest", 1, { expires : 10 });
	});
});
</script>
<?php
				

			
			$gsttotal1=0;

			$eve="select * from res_salesorder_detail where ordermid=".$ordermid;
				$re = mysqli_query($conn, $eve);
			if(mysqli_num_rows($re) > 0)
			{
				while($rt = mysqli_fetch_assoc($re))
				{
					$pprice1=$rt['itemiprice'];
					$pqty1=$rt['itemqty'];
					$itemid=$rt['itemid'];
					$orderdid=$rt['orderdid'];
					$pgst=$rt['itemgstper'];
					$gsamount=(float)$rt['itemgstamount'];
					 $gsttotal1=$gsttotal1 + $gsamount;
					$pdesc1=removespecialchar($rt['itemdesc']);
					$pdiscper1=$rt['itemdiscper'];
					$pdiscamt1=$rt['itemdiscamt'];
					$amount1=$rt['itemamount'];
					$itemunit=$rt['itemunit'];
					$eve_category = "select * from res_item_master where itemid=$itemid";
					$re_category = mysqli_query($conn, $eve_category);
					$pname="";
					while($rt_category = mysqli_fetch_assoc($re_category))
					{
						$umid=$rt_category['iunitmaster'];
						$pname=$rt_category['itemname'];
						$itemunit=$rt_category['itemunit'];
					}
					$eve_category1 = "select * from res_item_master where cmpmid=$cmpmid";
					$re_category1 = mysqli_query($conn, $eve_category1);

			?>
<script>
$(document).ready(function(){
		$("#items").append(" <tr><td valign=\"top\">  <div style=\"margin-top:10px; margin-left:10px;\">  <select style=\"width:280px; margin-top:10px; margin-left:10px;\" class=\"form-select form-select-solid\" id=\"pname" + $('#mycounter').val()  + "\" name=\"itemid[]\"><option>Select</option><?php	while($rt_category1 = mysqli_fetch_assoc($re_category1)) { 	$itemid1=$rt_category1['itemid']; $itemname=$rt_category1['itemname'];$itemunit=$rt_category1['itemunit']; if($itemid1==$itemid) {   echo"<option value=\'$itemid1\' selected>$itemname</option>"; } else { echo"<option value=\'$itemid1\'>$itemname</option>"; } } ?> </select> </div><input type=\"hidden\" id=\"qdid" + $('#mycounter').val()  + "\" value=\"<?php echo $orderdid;?>\" name=\"qdid[]\"> <textarea  type=\"text\" rows=\"2\" style=\"margin-left:20px; margin-top:5px; width:300px;\"  class=\"form-control form-control-solid\" id=\"pdesc" + $('#mycounter').val() +  "\" name=\"pdesc[]\"><?php echo $pdesc1;?></textarea></td><td valign=\"top\"> <input type=\"text\" style=\"width:50px; margin-top:10px; margin-left:10px;\" value=\"<?php echo $pqty1;?>\" id=\"pqty" + $('#mycounter').val() + "\" name=\"pqty[]\" onkeypress=\"return event.charCode >= 46 && event.charCode <= 57\"></td><td valign=\"top\">   <div style=\"margin-top:10px; margin-left:10px;\" name=\"punit[]\" value=\"<?php echo $itemunit;?>\" ><?php echo $itemunit;?>  </div></td><td valign=\"top\"> <input  type=\"text\" style=\"width:80px; margin-top:10px; margin-left:10px;\" id=\"pprice" + $('#mycounter').val() +  "\" name=\"pprice[]\" value=\"<?php echo $pprice1;?>\" onkeypress=\"return event.charCode >= 46 && event.charCode <= 57\" min=\"1\"></td><td valign=\"top\"> <input type=\"text\" step=\"0.01\" style=\"width:80px; margin-top:10px; margin-left:10px;\" id=\"pdiscper" + $('#mycounter').val() + "\" name=\"pdiscper[]\" onkeypress=\"return event.charCode >= 46 && event.charCode <= 57\" value=\"<?php echo $pdiscper1;?>\"><br> <input type=\"text\" style=\"width:80px; margin-top:10px; margin-left:10px;\" id=\"pdiscamt" + $('#mycounter').val() + "\" name=\"pdiscamt[]\" value=\"<?php echo $pdiscamt1;?>\" readonly></td><td valign=\"top\"> <input type=\"text\" style=\"width:80px; margin-top:10px; margin-left:10px;\" id=\"pgst" + $('#mycounter').val() + "\" name=\"pgst[]\" onkeypress=\"return event.charCode <= 57\" value=\"<?php echo $pgst;?>\" > <br><input  type=\"text\" style=\"width:80px; margin-top:10px; margin-left:10px;\" id=\"gsamount" + $('#mycounter').val() +  "\" name=\"gsamount[]\" value=\"<?php echo $gsamount;?>\" readonly></td><td valign=\"top\"> <input  type=\"text\" style=\"width:80px; margin-top:10px; margin-left:10px;\" id=\"tpamount" + $('#mycounter').val() +  "\" name=\"tpamount[]\" value=\"<?php echo $amount1;?>\"></td></tr>.");
				$('.select2').select2();

				$(function() {
					$( "#pname" + $('#mycounter').val() ).autocomplete({
						source: 'quotationaddsearch_1.php'
					});
				});



				$('#pname' + $('#mycounter').val() ).keyup( function(){

				//alert($(this).attr("id"));

				
					$('#mycounter2').val($(this).attr("id").substr( $(this).attr("id").length-2)) ;
				

				$.get("quotationaddsearch2_4.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box


				$('#pgst' + $('#mycounter2').val()).val($.trim(response));

				});

//make ajax call to action method to get the description for this value
				$.get("getitemunit.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box
				$('#punit' + $('#mycounter2').val()).html(response);

				});

				//make ajax call to action method to get the description for this value
				$.get("quotationaddsearch2_1.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box

				if($.trim(response)=="0")
				{
					$('#pqty' + $('#mycounter2').val()).val("0");
				}
				else
				{
					$('#pqty' + $('#mycounter2').val()).val("1");
				}
				$('#pprice' + $('#mycounter2').val()).val( $.trim(response) );
				var amt=$.trim(response);

				$('#tpamount' + $('#mycounter2').val()).val(amt);
					var gsta=0;
				gsta=(amt * parseFloat($('#pgst' + $('#mycounter2').val()).val()))/100;
				$('#gsamount' + $('#mycounter2').val()).val(gsta);
				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);

				});

				//make ajax call to action method to get the description for this value
				$.get("quotationaddsearch2_2.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box
				$('#pdesc' + $('#mycounter2').val()).val( $.trim(response) );

				});


				//make ajax call to action method to get the description for this value
				$.get("quotationaddsearch2_3.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box
				$('#umid' + $('#mycounter2').val()).html( $.trim(response) );

				});

				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);


				});


				$('#pname' + $('#mycounter').val() ).on('change',function(){

				//alert($(this).attr("id"));

					$('#mycounter2').val($(this).attr("id").substr( $(this).attr("id").length-2)) ;
				

				$.get("quotationaddsearch2_4.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box


				$('#pgst' + $('#mycounter2').val()).val($.trim(response));

				});

				//make ajax call to action method to get the description for this value
				$.get("getitemunit.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box
				$('#iunit' + $('#mycounter2').val()).html(response);

				});


				//make ajax call to action method to get the description for this value
				$.get("quotationaddsearch2_1.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box

				if($.trim(response)=="0")
				{
					$('#pqty' + $('#mycounter2').val()).val("0");
				}
				else
				{
					$('#pqty' + $('#mycounter2').val()).val("1");
				}
				$('#pprice' + $('#mycounter2').val()).val( $.trim(response) );
				var amt=$.trim(response);

				$('#tpamount' + $('#mycounter2').val()).val(amt);
					var gsta=0;
				gsta=(amt * parseFloat($('#pgst' + $('#mycounter2').val()).val()))/100;
				$('#gsamount' + $('#mycounter2').val()).val(gsta);
				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);

				});

				//make ajax call to action method to get the description for this value
				$.get("quotationaddsearch2_2.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box
				$('#pdesc' + $('#mycounter2').val()).val( $.trim(response) );

				});


				//make ajax call to action method to get the description for this value
				$.get("quotationaddsearch2_3.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box
				$('#umid' + $('#mycounter2').val()).html( $.trim(response) );

				});

				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);


				});
				
								
				$('#iunit' + $('#mycounter').val() ).on('change',function(){

						$('#mycounter2').val($(this).attr("id").substr( $(this).attr("id").length-2)) ;
					
						
					//make ajax call to action method to get the description for this value
					$.get("quotationaddsearch2_11.php", { skills2 : $(this).val(),skills22 : $('#pname' + $('#mycounter2').val()).val() }, function(response) {

					if($.trim(response)=="0")
					{
						$('#pqty' + $('#mycounter2').val()).val("0");
					}
					else
					{
						$('#pqty' + $('#mycounter2').val()).val("1");
					}
					$('#pprice' + $('#mycounter2').val()).val( $.trim(response) );
					
					var amt=$.trim(response);
					
					$('#tpamount' + $('#mycounter2').val()).val(amt);
					var gsta=0;
					gsta=(amt * parseFloat($('#pgst' + $('#mycounter2').val()).val()))/100;
					$('#gsamount' + $('#mycounter2').val()).val(gsta);
					var i;
					var total=0;
					var totalgst=0;
					for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
						total = total + parseFloat($('#tpamount' +i).val());
						totalgst = totalgst + parseFloat($('#gsamount' +i).val());
					}
					$('#total1').val(total);
					$('#gsttotal').val(totalgst);
					$('#nettotal').val(totalgst+total);

					});


		//make ajax call to action method to get the description for this value
					var i;
					var total=0;
					var totalgst=0;
					for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
						total = total + parseFloat($('#tpamount' +i).val());
						totalgst = totalgst + parseFloat($('#gsamount' +i).val());
					}
					$('#total1').val(total);
					$('#gsttotal').val(totalgst);
					$('#nettotal').val(totalgst+total);


				});


$('#pdiscper' + $('#mycounter').val() ).keyup( function(){

				//alert($(this).attr("id"));
				
					$('#mycounter2').val($(this).attr("id").substr( $(this).attr("id").length-2)) ;
				
				var disc=0;
				disc=((parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val()))*parseFloat($('#pdiscper' + $('#mycounter2').val() ).val()))/100;
			//	alert($('#pprice' + $('#mycounter2').val() ).val());
				//alert(disc);
				var amt=0;
					amt=parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val())-disc;
				$('#pdiscamt' + $('#mycounter2').val()).val(disc);
				$('#tpamount' + $('#mycounter2').val()).val(amt);
					var gsta=0;
				gsta=(amt * parseFloat($('#pgst' + $('#mycounter2').val()).val()))/100;
				$('#gsamount' + $('#mycounter2').val()).val(gsta);
				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);

				});
				
				

				$('#pprice' + $('#mycounter').val() ).keyup( function(){

				//alert($(this).attr("id"));
				
					$('#mycounter2').val($(this).attr("id").substr( $(this).attr("id").length-2)) ;
				


			//	alert($('#pprice' + $('#mycounter2').val() ).val());

				var disc=0;
					disc=((parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val()))*parseFloat($('#pdiscper' + $('#mycounter2').val() ).val()))/100;
				var amt=0;
					amt=parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val())-disc;
				$('#pdiscamt' + $('#mycounter2').val()).val(disc);
				$('#tpamount' + $('#mycounter2').val()).val(amt);
					var gsta=0;
				gsta=(amt * parseFloat($('#pgst' + $('#mycounter2').val()).val()))/100;
				$('#gsamount' + $('#mycounter2').val()).val(gsta);
				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);


				});

				$('#pgst' + $('#mycounter').val() ).keyup( function(){

				//alert($(this).attr("id"));
				
					$('#mycounter2').val($(this).attr("id").substr( $(this).attr("id").length-2)) ;
				
				var disc=0;
				disc=((parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val()))*parseFloat($('#pdiscper' + $('#mycounter2').val() ).val()))/100;
			//	alert($('#pprice' + $('#mycounter2').val() ).val());
				//alert(disc);
				var amt=0;
					amt=parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val())-disc;
				$('#pdiscamt' + $('#mycounter2').val()).val(disc);
				$('#tpamount' + $('#mycounter2').val()).val(amt);
					var gsta=0;
				gsta=(amt * parseFloat($('#pgst' + $('#mycounter2').val()).val()))/100;
				$('#gsamount' + $('#mycounter2').val()).val(gsta);
				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);

				});
				$('#pqty' + $('#mycounter').val() ).keyup( function(){

				//alert($(this).attr("id"));

				
					$('#mycounter2').val($(this).attr("id").substr( $(this).attr("id").length-2)) ;
				

				//alert($('#pprice' + $('#mycounter2').val() ).val());
				var disc=0;
				disc=((parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val()))*parseFloat($('#pdiscper' + $('#mycounter2').val() ).val()))/100;
				var amt=0;
					amt=parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val())-disc;
				$('#pdiscamt' + $('#mycounter2').val()).val(disc);
				$('#tpamount' + $('#mycounter2').val()).val(amt);
					var gsta=0;
				gsta=(amt * parseFloat($('#pgst' + $('#mycounter2').val()).val()))/100;
				$('#gsamount' + $('#mycounter2').val()).val(gsta);
				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);


				});



				$('#mycounter').val( parseFloat($('#mycounter').val()) + 1);


});
</script>
<?php
				

			
			}}

			$gsttotal1=0;

				$eve="select * from res_quotation_detail where qmid=".$qmid;
				$re = mysqli_query($conn, $eve);
			if(mysqli_num_rows($re) > 0)
			{
				while($rt = mysqli_fetch_assoc($re))
				{
					$pprice1=$rt['itemiprice'];
					$pqty1=$rt['itemqty'];
					$itemid=$rt['itemid'];
					$invoicedid=0;
					$pgst=$rt['itemgstper'];
					$gsamount=(float)$rt['itemgstamount'];
					 $gsttotal1=$gsttotal1 + $gsamount;
					$pdesc1=urldecode($rt['itemdesc']);
					$pdiscper1=$rt['itemdiscper'];
					$pdiscamt1=$rt['itemdiscamt'];
					$amount1=$rt['itemamount'];
					$itemunit=$rt['itemunit'];
					$eve_category = "select * from res_item_master where itemid=$itemid";
					$re_category = mysqli_query($conn, $eve_category);
					$pname="";
					while($rt_category = mysqli_fetch_assoc($re_category))
					{
						$umid=$rt_category['iunitmaster'];
						$pname=urldecode($rt_category['itemname']);
						$itemunit=$rt_category['itemunit'];
					}
					$eve_category1 = "select * from res_item_master where cmpmid=$cmpmid";
					$re_category1 = mysqli_query($conn, $eve_category1);

			?>
<script>
$(document).ready(function(){
		$("#items").append(" <tr><td valign=\"top\">  <div style=\"margin-top:10px; margin-left:10px;\">  <select style=\"width:280px; margin-top:10px; margin-left:10px;\" class=\"form-select form-select-solid\" id=\"pname" + $('#mycounter').val()  + "\" name=\"itemid[]\"><option>Select</option><?php	while($rt_category1 = mysqli_fetch_assoc($re_category1)) { 	$itemid1=$rt_category1['itemid']; $itemname=$rt_category1['itemname'];$itemunit=$rt_category1['itemunit']; if($itemid1==$itemid) {   echo"<option value=\'$itemid1\' selected>$itemname</option>"; } else { echo"<option value=\'$itemid1\'>$itemname</option>"; } } ?> </select> </div><input type=\"hidden\" id=\"qdid" + $('#mycounter').val()  + "\" value=\"<?php echo $invoicedid;?>\" name=\"qdid[]\"> <textarea  type=\"text\" rows=\"2\" style=\"margin-left:20px; margin-top:5px; width:300px;\"  class=\"form-control form-control-solid\" id=\"pdesc" + $('#mycounter').val() +  "\" name=\"pdesc[]\"><?php echo $pdesc1;?></textarea></td><td valign=\"top\"> <input type=\"text\" style=\"width:50px; margin-top:10px; margin-left:10px;\" value=\"<?php echo $pqty1;?>\" id=\"pqty" + $('#mycounter').val() + "\" name=\"pqty[]\" onkeypress=\"return event.charCode >= 46 && event.charCode <= 57\"></td><td valign=\"top\">   <div style=\"margin-top:10px; margin-left:10px;\" name=\"punit[]\" value=\"<?php echo $itemunit;?>\" ><?php echo $itemunit;?>  </div></td><td valign=\"top\"> <input  type=\"text\" style=\"width:80px; margin-top:10px; margin-left:10px;\" id=\"pprice" + $('#mycounter').val() +  "\" name=\"pprice[]\" value=\"<?php echo $pprice1;?>\" onkeypress=\"return event.charCode >= 46 && event.charCode <= 57\" min=\"1\"></td><td valign=\"top\"> <input type=\"text\" step=\"0.01\" style=\"width:80px; margin-top:10px; margin-left:10px;\" id=\"pdiscper" + $('#mycounter').val() + "\" name=\"pdiscper[]\" onkeypress=\"return event.charCode >= 46 && event.charCode <= 57\" value=\"<?php echo $pdiscper1;?>\"><br> <input type=\"text\" style=\"width:80px; margin-top:10px; margin-left:10px;\" id=\"pdiscamt" + $('#mycounter').val() + "\" name=\"pdiscamt[]\" value=\"<?php echo $pdiscamt1;?>\" readonly></td><td valign=\"top\"> <input type=\"text\" style=\"width:80px; margin-top:10px; margin-left:10px;\" id=\"pgst" + $('#mycounter').val() + "\" name=\"pgst[]\" onkeypress=\"return event.charCode <= 57\" value=\"<?php echo $pgst;?>\" > <br><input  type=\"text\" style=\"width:80px; margin-top:10px; margin-left:10px;\" id=\"gsamount" + $('#mycounter').val() +  "\" name=\"gsamount[]\" value=\"<?php echo $gsamount;?>\" readonly></td><td valign=\"top\"> <input  type=\"text\" style=\"width:80px; margin-top:10px; margin-left:10px;\" id=\"tpamount" + $('#mycounter').val() +  "\" name=\"tpamount[]\" value=\"<?php echo $amount1;?>\"></td></tr>.");
				$('.select2').select2();

				$(function() {
					$( "#pname" + $('#mycounter').val() ).autocomplete({
						source: 'quotationaddsearch_1.php'
					});
				});



				$('#pname' + $('#mycounter').val() ).keyup( function(){

				//alert($(this).attr("id"));

				
					$('#mycounter2').val($(this).attr("id").substr( $(this).attr("id").length-2)) ;
				

				$.get("quotationaddsearch2_4.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box


				$('#pgst' + $('#mycounter2').val()).val($.trim(response));

				});

//make ajax call to action method to get the description for this value
				$.get("getitemunit.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box
				$('#punit' + $('#mycounter2').val()).html(response);

				});

				//make ajax call to action method to get the description for this value
				$.get("quotationaddsearch2_1.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box

				if($.trim(response)=="0")
				{
					$('#pqty' + $('#mycounter2').val()).val("0");
				}
				else
				{
					$('#pqty' + $('#mycounter2').val()).val("1");
				}
				$('#pprice' + $('#mycounter2').val()).val( $.trim(response) );
				var amt=$.trim(response);

				$('#tpamount' + $('#mycounter2').val()).val(amt);
					var gsta=0;
				gsta=(amt * parseFloat($('#pgst' + $('#mycounter2').val()).val()))/100;
				$('#gsamount' + $('#mycounter2').val()).val(gsta);
				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);

				});

				//make ajax call to action method to get the description for this value
				$.get("quotationaddsearch2_2.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box
				$('#pdesc' + $('#mycounter2').val()).val( $.trim(response) );

				});


				//make ajax call to action method to get the description for this value
				$.get("quotationaddsearch2_3.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box
				$('#umid' + $('#mycounter2').val()).html( $.trim(response) );

				});

				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);


				});


				$('#pname' + $('#mycounter').val() ).on('change',function(){

				//alert($(this).attr("id"));

					$('#mycounter2').val($(this).attr("id").substr( $(this).attr("id").length-2)) ;
				

				$.get("quotationaddsearch2_4.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box


				$('#pgst' + $('#mycounter2').val()).val($.trim(response));

				});

				//make ajax call to action method to get the description for this value
				$.get("getitemunit.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box
				$('#iunit' + $('#mycounter2').val()).html(response);

				});


				//make ajax call to action method to get the description for this value
				$.get("quotationaddsearch2_1.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box

				if($.trim(response)=="0")
				{
					$('#pqty' + $('#mycounter2').val()).val("0");
				}
				else
				{
					$('#pqty' + $('#mycounter2').val()).val("1");
				}
				$('#pprice' + $('#mycounter2').val()).val( $.trim(response) );
				var amt=$.trim(response);

				$('#tpamount' + $('#mycounter2').val()).val(amt);
					var gsta=0;
				gsta=(amt * parseFloat($('#pgst' + $('#mycounter2').val()).val()))/100;
				$('#gsamount' + $('#mycounter2').val()).val(gsta);
				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);

				});

				//make ajax call to action method to get the description for this value
				$.get("quotationaddsearch2_2.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box
				$('#pdesc' + $('#mycounter2').val()).val( $.trim(response) );

				});


				//make ajax call to action method to get the description for this value
				$.get("quotationaddsearch2_3.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box
				$('#umid' + $('#mycounter2').val()).html( $.trim(response) );

				});

				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);


				});
				
								
				$('#iunit' + $('#mycounter').val() ).on('change',function(){

						$('#mycounter2').val($(this).attr("id").substr( $(this).attr("id").length-2)) ;
					
						
					//make ajax call to action method to get the description for this value
					$.get("quotationaddsearch2_11.php", { skills2 : $(this).val(),skills22 : $('#pname' + $('#mycounter2').val()).val() }, function(response) {

					if($.trim(response)=="0")
					{
						$('#pqty' + $('#mycounter2').val()).val("0");
					}
					else
					{
						$('#pqty' + $('#mycounter2').val()).val("1");
					}
					$('#pprice' + $('#mycounter2').val()).val( $.trim(response) );
					
					var amt=$.trim(response);
					
					$('#tpamount' + $('#mycounter2').val()).val(amt);
					var gsta=0;
					gsta=(amt * parseFloat($('#pgst' + $('#mycounter2').val()).val()))/100;
					$('#gsamount' + $('#mycounter2').val()).val(gsta);
					var i;
					var total=0;
					var totalgst=0;
					for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
						total = total + parseFloat($('#tpamount' +i).val());
						totalgst = totalgst + parseFloat($('#gsamount' +i).val());
					}
					$('#total1').val(total);
					$('#gsttotal').val(totalgst);
					$('#nettotal').val(totalgst+total);

					});


		//make ajax call to action method to get the description for this value
					var i;
					var total=0;
					var totalgst=0;
					for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
						total = total + parseFloat($('#tpamount' +i).val());
						totalgst = totalgst + parseFloat($('#gsamount' +i).val());
					}
					$('#total1').val(total);
					$('#gsttotal').val(totalgst);
					$('#nettotal').val(totalgst+total);


				});


$('#pdiscper' + $('#mycounter').val() ).keyup( function(){

				//alert($(this).attr("id"));
				
					$('#mycounter2').val($(this).attr("id").substr( $(this).attr("id").length-2)) ;
				
				var disc=0;
				disc=((parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val()))*parseFloat($('#pdiscper' + $('#mycounter2').val() ).val()))/100;
			//	alert($('#pprice' + $('#mycounter2').val() ).val());
				//alert(disc);
				var amt=0;
					amt=parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val())-disc;
				$('#pdiscamt' + $('#mycounter2').val()).val(disc);
				$('#tpamount' + $('#mycounter2').val()).val(amt);
					var gsta=0;
				gsta=(amt * parseFloat($('#pgst' + $('#mycounter2').val()).val()))/100;
				$('#gsamount' + $('#mycounter2').val()).val(gsta);
				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);

				});
				
				

				$('#pprice' + $('#mycounter').val() ).keyup( function(){

				//alert($(this).attr("id"));
				
					$('#mycounter2').val($(this).attr("id").substr( $(this).attr("id").length-2)) ;
				


			//	alert($('#pprice' + $('#mycounter2').val() ).val());

				var disc=0;
					disc=((parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val()))*parseFloat($('#pdiscper' + $('#mycounter2').val() ).val()))/100;
				var amt=0;
					amt=parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val())-disc;
				$('#pdiscamt' + $('#mycounter2').val()).val(disc);
				$('#tpamount' + $('#mycounter2').val()).val(amt);
					var gsta=0;
				gsta=(amt * parseFloat($('#pgst' + $('#mycounter2').val()).val()))/100;
				$('#gsamount' + $('#mycounter2').val()).val(gsta);
				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);


				});

				$('#pgst' + $('#mycounter').val() ).keyup( function(){

				//alert($(this).attr("id"));
				
					$('#mycounter2').val($(this).attr("id").substr( $(this).attr("id").length-2)) ;
				
				var disc=0;
				disc=((parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val()))*parseFloat($('#pdiscper' + $('#mycounter2').val() ).val()))/100;
			//	alert($('#pprice' + $('#mycounter2').val() ).val());
				//alert(disc);
				var amt=0;
					amt=parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val())-disc;
				$('#pdiscamt' + $('#mycounter2').val()).val(disc);
				$('#tpamount' + $('#mycounter2').val()).val(amt);
					var gsta=0;
				gsta=(amt * parseFloat($('#pgst' + $('#mycounter2').val()).val()))/100;
				$('#gsamount' + $('#mycounter2').val()).val(gsta);
				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);

				});
				$('#pqty' + $('#mycounter').val() ).keyup( function(){

				//alert($(this).attr("id"));

				
					$('#mycounter2').val($(this).attr("id").substr( $(this).attr("id").length-2)) ;
				

				//alert($('#pprice' + $('#mycounter2').val() ).val());
				var disc=0;
				disc=((parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val()))*parseFloat($('#pdiscper' + $('#mycounter2').val() ).val()))/100;
				var amt=0;
					amt=parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val())-disc;
				$('#pdiscamt' + $('#mycounter2').val()).val(disc);
				$('#tpamount' + $('#mycounter2').val()).val(amt);
					var gsta=0;
				gsta=(amt * parseFloat($('#pgst' + $('#mycounter2').val()).val()))/100;
				$('#gsamount' + $('#mycounter2').val()).val(gsta);
				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);


				});



				$('#mycounter').val( parseFloat($('#mycounter').val()) + 1);


});
</script>
<?php
				}
				}
				if($ordermid==0 && $qmid==0)
				{
				$eve_category11 = "select * from res_item_master where cmpmid=$cmpmid";
				$re_category11 = mysqli_query($conn, $eve_category11);

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

		$("#items").append(" <tr><td valign=\"top\">  <div style=\"margin-top:10px; margin-left:10px;\"><select style=\"width:280px; margin-top:10px; margin-left:10px;\" class=\"form-select form-select-solid\" id=\"pname" + $('#mycounter').val()  + "\" name=\"itemid[]\"><option>Select</option><?php	while($rt_category11 = mysqli_fetch_assoc($re_category11)){	$itemname=removespecialchar($rt_category11['itemname']);$itemid=$rt_category11['itemid']; echo"<option value=\'$itemid\'>$itemname</option>";}		?>	</select> </div> <input type=\"hidden\" id=\"qdid" + $('#mycounter').val()  + "\" value=\"0\" name=\"qdid[]\"> <input type=\"hidden\" style=\"width:200px; margin-top:5px; margin-left:5px;\" id=\"pname1" + $('#mycounter').val()  + "\" name=\"pname1[]\">  <textarea  type=\"text\" rows=\"2\" style=\"margin-left:15px; margin-top:5px; width:300px;\" class=\"form-control form-control-solid\" id=\"pdesc" + $('#mycounter').val() +  "\" name=\"pdesc[]\"></textarea></td><td valign=\"top\"> <input type=\"text\" style=\"width:50px; margin-top:10px; margin-left:10px;\" id=\"pqty" + $('#mycounter').val() + "\" name=\"pqty[]\" onkeypress=\"return event.charCode >= 46 && event.charCode <= 57\" value=\"0\"></td><td valign=\"top\">   <div style=\"margin-top:10px; margin-left:10px;\" class=\"form\" id=\"punit" + $('#mycounter').val()  + "\" name=\"punit[]\">  </div></td><td valign=\"top\"> <input  type=\"text\" style=\"width:80px; margin-top:10px; margin-left:10px;\" id=\"pprice" + $('#mycounter').val() +  "\" name=\"pprice[]\" value=\"0\" onkeypress=\"return event.charCode >= 46 && event.charCode <= 57\" min=\"1\"></td><td valign=\"top\"> <input type=\"text\" step=\"0.01\" style=\"width:80px; margin-top:10px; margin-left:10px;\" id=\"pdiscper" + $('#mycounter').val() + "\" name=\"pdiscper[]\" onkeypress=\"return event.charCode >= 46 && event.charCode <= 57\"value=\"0\"><br> <input type=\"text\" style=\"width:80px; margin-top:10px; margin-left:10px;\" id=\"pdiscamt" + $('#mycounter').val() + "\" name=\"pdiscamt[]\"  value=\"0\" readonly></td><td valign=\"top\"> <input type=\"text\" style=\"width:80px; margin-top:10px; margin-left:10px;\" id=\"pgst" + $('#mycounter').val() + "\" name=\"pgst[]\" onkeypress=\"return event.charCode >= 46 && event.charCode <= 57\" value=\"0\" > <br><input  type=\"text\" style=\"width:80px; margin-top:10px; margin-left:10px;\" id=\"gsamount" + $('#mycounter').val() +  "\" name=\"gsamount[]\" value=\"0\" readonly></td><td valign=\"top\"> <input  type=\"text\" style=\"width:80px; margin-top:10px; margin-left:10px;\" id=\"tpamount" + $('#mycounter').val() +  "\" name=\"tpamount[]\" value=\"0\"> </td></tr>.");
		
		$(function() {
					$( "#pname" + $('#mycounter').val() ).autocomplete({
						source: 'quotationaddsearch_1.php'
					});
				});

				$('#pname' + $('#mycounter').val() ).keyup( function(){

				//alert($(this).attr("id"));

				
					$('#mycounter2').val($(this).attr("id").substr( $(this).attr("id").length-2)) ;
				

				$.get("quotationaddsearch2_4.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box


				$('#pgst' + $('#mycounter2').val()).val($.trim(response));

				});
				
				//make ajax call to action method to get the description for this value
				$.get("getitemunit.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box
				$('#punit' + $('#mycounter2').val()).html($.trim(response));

				});

				//make ajax call to action method to get the description for this value
				$.get("quotationaddsearch2_1.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box

				if($.trim(response)=="0")
				{
					$('#pqty' + $('#mycounter2').val()).val("0");
				}
				else
				{
					$('#pqty' + $('#mycounter2').val()).val("1");
				}
				$('#pprice' + $('#mycounter2').val()).val( $.trim(response) );

				var amt=$.trim(response);

				$('#tpamount' + $('#mycounter2').val()).val(amt);
					var gsta=0;
				gsta=(amt * parseFloat($('#pgst' + $('#mycounter2').val()).val()))/100;
				$('#gsamount' + $('#mycounter2').val()).val(gsta);
				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);

				});

				//make ajax call to action method to get the description for this value
				$.get("quotationaddsearch2_2.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box
				$('#pdesc' + $('#mycounter2').val()).val( $.trim(response) );

				});


				//make ajax call to action method to get the description for this value
				$.get("quotationaddsearch2_3.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box
				$('#umid' + $('#mycounter2').val()).html( $.trim(response) );

				});
//make ajax call to action method to get the description for this value
				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);


				});


				$('#pname' + $('#mycounter').val() ).on('change',function(){

				$('#mycounter2').val($(this).attr("id").substr( $(this).attr("id").length-2)) ;				
				$.get("quotationaddsearch2_4.php", { skills2 : $(this).val() }, function(response) {
				$('#pgst' + $('#mycounter2').val()).val($.trim(response));
				});


				//make ajax call to action method to get the description for this value
				$.get("quotationaddsearch2_1.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box
				$('#pprice' + $('#mycounter2').val()).val( $.trim(response) );
				if($.trim(response)=="0")
				{
					$('#pqty' + $('#mycounter2').val()).val("0");
				}
				else
				{
					$('#pqty' + $('#mycounter2').val()).val("1");
				}
				var amt=$.trim(response);

				$('#tpamount' + $('#mycounter2').val()).val(amt);
					var gsta=0;
				gsta=(amt * parseFloat($('#pgst' + $('#mycounter2').val()).val()))/100;
				$('#gsamount' + $('#mycounter2').val()).val(gsta);
				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);

				});

				//make ajax call to action method to get the description for this value
				$.get("quotationaddsearch2_2.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box
				$('#pdesc' + $('#mycounter2').val()).val( $.trim(response) );

				});
				//make ajax call to action method to get the description for this value
				$.get("getitemunit.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box
				$('#punit' + $('#mycounter2').val()).html( $.trim(response) );

				});

				//make ajax call to action method to get the description for this value
				$.get("quotationaddsearch2_3.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box
				$('#umid' + $('#mycounter2').val()).html( $.trim(response) );

				});
				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);


				});


				$('#punit' + $('#mycounter').val() ).on('change',function(){

						$('#mycounter2').val($(this).attr("id").substr( $(this).attr("id").length-2)) ;
					
						
					//make ajax call to action method to get the description for this value
					$.get("quotationaddsearch2_11.php", { skills2 : $(this).val(),skills22 : $('#pname' + $('#mycounter2').val()).val() }, function(response) {

					if($.trim(response)=="0")
					{
						$('#pqty' + $('#mycounter2').val()).val("0");
					}
					else
					{
						$('#pqty' + $('#mycounter2').val()).val("1");
					}
					$('#pprice' + $('#mycounter2').val()).val( $.trim(response) );
					
					var amt=$.trim(response);
					
					$('#tpamount' + $('#mycounter2').val()).val(amt);
					var gsta=0;
					gsta=(amt * parseFloat($('#pgst' + $('#mycounter2').val()).val()))/100;
					$('#gsamount' + $('#mycounter2').val()).val(gsta);
					var i;
					var total=0;
					var totalgst=0;
					for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
						total = total + parseFloat($('#tpamount' +i).val());
						totalgst = totalgst + parseFloat($('#gsamount' +i).val());
					}
					$('#total1').val(total);
					$('#gsttotal').val(totalgst);
					$('#nettotal').val(totalgst+total);

					});


		//make ajax call to action method to get the description for this value
					var i;
					var total=0;
					var totalgst=0;
					for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
						total = total + parseFloat($('#tpamount' +i).val());
						totalgst = totalgst + parseFloat($('#gsamount' +i).val());
					}
					$('#total1').val(total);
					$('#gsttotal').val(totalgst);
					$('#nettotal').val(totalgst+total);


				});


$('#pdiscper' + $('#mycounter').val() ).keyup( function(){

				//alert($(this).attr("id"));
				
					$('#mycounter2').val($(this).attr("id").substr( $(this).attr("id").length-2)) ;
				
				var disc=0;
				disc=((parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val()))*parseFloat($('#pdiscper' + $('#mycounter2').val() ).val()))/100;
			//	alert($('#pprice' + $('#mycounter2').val() ).val());
				//alert(disc);
				var amt=0;
					amt=parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val())-disc;
				$('#pdiscamt' + $('#mycounter2').val()).val(disc);
				$('#tpamount' + $('#mycounter2').val()).val(amt);
					var gsta=0;
				gsta=(amt * parseFloat($('#pgst' + $('#mycounter2').val()).val()))/100;
				$('#gsamount' + $('#mycounter2').val()).val(gsta);
				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);

				});



				$('#pprice' + $('#mycounter').val() ).keyup( function(){

				
					$('#mycounter2').val($(this).attr("id").substr( $(this).attr("id").length-2)) ;
				


			//	alert($('#pprice' + $('#mycounter2').val() ).val());

				var disc=0;
					disc=((parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val()))*parseFloat($('#pdiscper' + $('#mycounter2').val() ).val()))/100;
					var amt=0;
					amt=parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val())-disc;
				$('#pdiscamt' + $('#mycounter2').val()).val(disc);
				$('#tpamount' + $('#mycounter2').val()).val(amt);
					var gsta=0;
				gsta=(amt * parseFloat($('#pgst' + $('#mycounter2').val()).val()))/100;
				$('#gsamount' + $('#mycounter2').val()).val(gsta);
				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);

				});

				$('#pgst' + $('#mycounter').val() ).keyup( function(){

				
					$('#mycounter2').val($(this).attr("id").substr( $(this).attr("id").length-2)) ;
				
				var disc=0;
				disc=((parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val()))*parseFloat($('#pdiscper' + $('#mycounter2').val() ).val()))/100;
				$('#pdiscamt' + $('#mycounter2').val()).val(disc);
				var amt=0;
					amt=parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val())-disc;
				$('#tpamount' + $('#mycounter2').val()).val(amt);
					var gsta=0;
				gsta=(amt * parseFloat($('#pgst' + $('#mycounter2').val()).val()))/100;
				$('#gsamount' + $('#mycounter2').val()).val(gsta);
				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);


				});
				$('#pqty' + $('#mycounter').val() ).keyup( function(){

				//alert($(this).attr("id"));

				
					$('#mycounter2').val($(this).attr("id").substr( $(this).attr("id").length-2)) ;
				

				//alert($('#pprice' + $('#mycounter2').val() ).val());
				var disc=0;
				disc=((parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val()))*parseFloat($('#pdiscper' + $('#mycounter2').val() ).val()))/100;
				var amt=0;
					amt=parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val())-disc;
				$('#pdiscamt' + $('#mycounter2').val()).val(disc);
				$('#tpamount' + $('#mycounter2').val()).val(amt);
					var gsta=0;
				gsta=(amt * parseFloat($('#pgst' + $('#mycounter2').val()).val()))/100;
				$('#gsamount' + $('#mycounter2').val()).val(gsta);
				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);

				});

		$('#mycounter').val( parseInt($('#mycounter').val()) + 1);
});
</script>
				<?php }
 $eve_category11 = "select * from res_item_master where cmpmid=$cmpmid";
$re_category11 = mysqli_query($conn, $eve_category11);
				?>
				
<script>
$(document).ready(function(){
	$("#add_item").click(function(){

		$("#items").append(" <tr><td valign=\"top\">  <div style=\"margin-top:10px; margin-left:10px;\"><select style=\"width:280px; margin-top:10px; margin-left:10px;\" class=\"form-select form-select-solid\" id=\"pname" + $('#mycounter').val()  + "\" name=\"itemid[]\"><option>Select</option><?php	while($rt_category11 = mysqli_fetch_assoc($re_category11)){	$itemname=removespecialchar($rt_category11['itemname']);$itemid=$rt_category11['itemid']; echo"<option value=\'$itemid\'>$itemname</option>";}		?>	</select> </div> <input type=\"hidden\" id=\"qdid" + $('#mycounter').val()  + "\" value=\"0\" name=\"qdid[]\"> <input type=\"hidden\" style=\"width:200px; margin-top:5px; margin-left:5px;\" id=\"pname1" + $('#mycounter').val()  + "\" name=\"pname1[]\">  <textarea  type=\"text\" rows=\"2\" style=\"margin-left:15px; margin-top:5px; width:300px;\" class=\"form-control form-control-solid\" id=\"pdesc" + $('#mycounter').val() +  "\" name=\"pdesc[]\"></textarea></td><td valign=\"top\"> <input type=\"text\" style=\"width:50px; margin-top:10px; margin-left:10px;\" id=\"pqty" + $('#mycounter').val() + "\" name=\"pqty[]\" onkeypress=\"return event.charCode >= 46 && event.charCode <= 57\" value=\"0\"></td><td valign=\"top\">   <div style=\"margin-top:10px; margin-left:10px;\" class=\"form\" id=\"punit" + $('#mycounter').val()  + "\" name=\"punit[]\">  </div></td><td valign=\"top\"> <input  type=\"text\" style=\"width:80px; margin-top:10px; margin-left:10px;\" id=\"pprice" + $('#mycounter').val() +  "\" name=\"pprice[]\" value=\"0\" onkeypress=\"return event.charCode >= 46 && event.charCode <= 57\" min=\"1\"></td><td valign=\"top\"> <input type=\"text\" step=\"0.01\" style=\"width:80px; margin-top:10px; margin-left:10px;\" id=\"pdiscper" + $('#mycounter').val() + "\" name=\"pdiscper[]\" onkeypress=\"return event.charCode >= 46 && event.charCode <= 57\"value=\"0\"><br> <input type=\"text\" style=\"width:80px; margin-top:10px; margin-left:10px;\" id=\"pdiscamt" + $('#mycounter').val() + "\" name=\"pdiscamt[]\"  value=\"0\" readonly></td><td valign=\"top\"> <input type=\"text\" style=\"width:80px; margin-top:10px; margin-left:10px;\" id=\"pgst" + $('#mycounter').val() + "\" name=\"pgst[]\" onkeypress=\"return event.charCode >= 46 && event.charCode <= 57\" value=\"0\" > <br><input  type=\"text\" style=\"width:80px; margin-top:10px; margin-left:10px;\" id=\"gsamount" + $('#mycounter').val() +  "\" name=\"gsamount[]\" value=\"0\" readonly></td><td valign=\"top\"> <input  type=\"text\" style=\"width:80px; margin-top:10px; margin-left:10px;\" id=\"tpamount" + $('#mycounter').val() +  "\" name=\"tpamount[]\" value=\"0\"> </td></tr>.");
		
		$(function() {
					$( "#pname" + $('#mycounter').val() ).autocomplete({
						source: 'quotationaddsearch_1.php'
					});
				});

				$('#pname' + $('#mycounter').val() ).keyup( function(){

				//alert($(this).attr("id"));

				
					$('#mycounter2').val($(this).attr("id").substr( $(this).attr("id").length-2)) ;
				

				$.get("quotationaddsearch2_4.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box


				$('#pgst' + $('#mycounter2').val()).val($.trim(response));

				});
				
				//make ajax call to action method to get the description for this value
				$.get("getitemunit.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box
				$('#punit' + $('#mycounter2').val()).html($.trim(response));

				});

				//make ajax call to action method to get the description for this value
				$.get("quotationaddsearch2_1.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box

				if($.trim(response)=="0")
				{
					$('#pqty' + $('#mycounter2').val()).val("0");
				}
				else
				{
					$('#pqty' + $('#mycounter2').val()).val("1");
				}
				$('#pprice' + $('#mycounter2').val()).val( $.trim(response) );

				var amt=$.trim(response);

				$('#tpamount' + $('#mycounter2').val()).val(amt);
					var gsta=0;
				gsta=(amt * parseFloat($('#pgst' + $('#mycounter2').val()).val()))/100;
				$('#gsamount' + $('#mycounter2').val()).val(gsta);
				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);

				});

				//make ajax call to action method to get the description for this value
				$.get("quotationaddsearch2_2.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box
				$('#pdesc' + $('#mycounter2').val()).val( $.trim(response) );

				});


				//make ajax call to action method to get the description for this value
				$.get("quotationaddsearch2_3.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box
				$('#umid' + $('#mycounter2').val()).html( $.trim(response) );

				});
//make ajax call to action method to get the description for this value
				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);


				});


				$('#pname' + $('#mycounter').val() ).on('change',function(){

				$('#mycounter2').val($(this).attr("id").substr( $(this).attr("id").length-2)) ;				
				$.get("quotationaddsearch2_4.php", { skills2 : $(this).val() }, function(response) {
				$('#pgst' + $('#mycounter2').val()).val($.trim(response));
				});


				//make ajax call to action method to get the description for this value
				$.get("quotationaddsearch2_1.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box
				$('#pprice' + $('#mycounter2').val()).val( $.trim(response) );
				if($.trim(response)=="0")
				{
					$('#pqty' + $('#mycounter2').val()).val("0");
				}
				else
				{
					$('#pqty' + $('#mycounter2').val()).val("1");
				}
				var amt=$.trim(response);

				$('#tpamount' + $('#mycounter2').val()).val(amt);
					var gsta=0;
				gsta=(amt * parseFloat($('#pgst' + $('#mycounter2').val()).val()))/100;
				$('#gsamount' + $('#mycounter2').val()).val(gsta);
				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);

				});

				//make ajax call to action method to get the description for this value
				$.get("quotationaddsearch2_2.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box
				$('#pdesc' + $('#mycounter2').val()).val( $.trim(response) );

				});
				//make ajax call to action method to get the description for this value
				$.get("getitemunit.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box
				$('#punit' + $('#mycounter2').val()).html( $.trim(response) );

				});

				//make ajax call to action method to get the description for this value
				$.get("quotationaddsearch2_3.php", { skills2 : $(this).val() }, function(response) {

				//alert($(this).attr("id").substr( $(this).attr("id").length-1 )  );

				//alert($aa);

				//set the value of description text box
				$('#umid' + $('#mycounter2').val()).html( $.trim(response) );

				});
				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);


				});


				$('#punit' + $('#mycounter').val() ).on('change',function(){

						$('#mycounter2').val($(this).attr("id").substr( $(this).attr("id").length-2)) ;
					
						
					//make ajax call to action method to get the description for this value
					$.get("quotationaddsearch2_11.php", { skills2 : $(this).val(),skills22 : $('#pname' + $('#mycounter2').val()).val() }, function(response) {

					if($.trim(response)=="0")
					{
						$('#pqty' + $('#mycounter2').val()).val("0");
					}
					else
					{
						$('#pqty' + $('#mycounter2').val()).val("1");
					}
					$('#pprice' + $('#mycounter2').val()).val( $.trim(response) );
					
					var amt=$.trim(response);
					
					$('#tpamount' + $('#mycounter2').val()).val(amt);
					var gsta=0;
					gsta=(amt * parseFloat($('#pgst' + $('#mycounter2').val()).val()))/100;
					$('#gsamount' + $('#mycounter2').val()).val(gsta);
					var i;
					var total=0;
					var totalgst=0;
					for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
						total = total + parseFloat($('#tpamount' +i).val());
						totalgst = totalgst + parseFloat($('#gsamount' +i).val());
					}
					$('#total1').val(total);
					$('#gsttotal').val(totalgst);
					$('#nettotal').val(totalgst+total);

					});


		//make ajax call to action method to get the description for this value
					var i;
					var total=0;
					var totalgst=0;
					for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
						total = total + parseFloat($('#tpamount' +i).val());
						totalgst = totalgst + parseFloat($('#gsamount' +i).val());
					}
					$('#total1').val(total);
					$('#gsttotal').val(totalgst);
					$('#nettotal').val(totalgst+total);


				});


$('#pdiscper' + $('#mycounter').val() ).keyup( function(){

				//alert($(this).attr("id"));
				
					$('#mycounter2').val($(this).attr("id").substr( $(this).attr("id").length-2)) ;
				
				var disc=0;
				disc=((parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val()))*parseFloat($('#pdiscper' + $('#mycounter2').val() ).val()))/100;
			//	alert($('#pprice' + $('#mycounter2').val() ).val());
				//alert(disc);
				var amt=0;
					amt=parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val())-disc;
				$('#pdiscamt' + $('#mycounter2').val()).val(disc);
				$('#tpamount' + $('#mycounter2').val()).val(amt);
					var gsta=0;
				gsta=(amt * parseFloat($('#pgst' + $('#mycounter2').val()).val()))/100;
				$('#gsamount' + $('#mycounter2').val()).val(gsta);
				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);

				});



				$('#pprice' + $('#mycounter').val() ).keyup( function(){

				
					$('#mycounter2').val($(this).attr("id").substr( $(this).attr("id").length-2)) ;
				


			//	alert($('#pprice' + $('#mycounter2').val() ).val());

				var disc=0;
					disc=((parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val()))*parseFloat($('#pdiscper' + $('#mycounter2').val() ).val()))/100;
					var amt=0;
					amt=parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val())-disc;
				$('#pdiscamt' + $('#mycounter2').val()).val(disc);
				$('#tpamount' + $('#mycounter2').val()).val(amt);
					var gsta=0;
				gsta=(amt * parseFloat($('#pgst' + $('#mycounter2').val()).val()))/100;
				$('#gsamount' + $('#mycounter2').val()).val(gsta);
				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);

				});

				$('#pgst' + $('#mycounter').val() ).keyup( function(){

				
					$('#mycounter2').val($(this).attr("id").substr( $(this).attr("id").length-2)) ;
				
				var disc=0;
				disc=((parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val()))*parseFloat($('#pdiscper' + $('#mycounter2').val() ).val()))/100;
				$('#pdiscamt' + $('#mycounter2').val()).val(disc);
				var amt=0;
					amt=parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val())-disc;
				$('#tpamount' + $('#mycounter2').val()).val(amt);
					var gsta=0;
				gsta=(amt * parseFloat($('#pgst' + $('#mycounter2').val()).val()))/100;
				$('#gsamount' + $('#mycounter2').val()).val(gsta);
				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);


				});
				$('#pqty' + $('#mycounter').val() ).keyup( function(){

				//alert($(this).attr("id"));

				
					$('#mycounter2').val($(this).attr("id").substr( $(this).attr("id").length-2)) ;
				

				//alert($('#pprice' + $('#mycounter2').val() ).val());
				var disc=0;
				disc=((parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val()))*parseFloat($('#pdiscper' + $('#mycounter2').val() ).val()))/100;
				var amt=0;
					amt=parseFloat($('#pprice' + $('#mycounter2').val() ).val()) * parseFloat($('#pqty' + $('#mycounter2').val() ).val())-disc;
				$('#pdiscamt' + $('#mycounter2').val()).val(disc);
				$('#tpamount' + $('#mycounter2').val()).val(amt);
					var gsta=0;
				gsta=(amt * parseFloat($('#pgst' + $('#mycounter2').val()).val()))/100;
				$('#gsamount' + $('#mycounter2').val()).val(gsta);
				var i;
				var total=0;
				var totalgst=0;
				for (i = 10; i < parseFloat($('#mycounter').val()); i++) {
					total = total + parseFloat($('#tpamount' +i).val());
					totalgst = totalgst + parseFloat($('#gsamount' +i).val());
				}
				$('#total1').val(total);
				$('#gsttotal').val(totalgst);
				$('#nettotal').val(totalgst+total);

				});

		$('#mycounter').val( parseInt($('#mycounter').val()) + 1);
	});
});
</script>
	</body>
	<!--end::Body-->
</html>