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

	include("connect.php");
	if(!isset($_SESSION['linkarisecrm']))
	{
		header('Location: index.php');
		return;
	}
	$ftime=0;
	$ttime=23;
	$_SESSION['_token']=bin2hex(openssl_random_pseudo_bytes(16));
	$cmpmid=$_SESSION['linkarisecmpmid'];
	$cmptype=$_SESSION['linkarisecmptype'];
	
				date_default_timezone_set("Asia/Singapore");
				$mdate1= date('Y-m-d H:i:s');
				$mdate= date('d-m-Y');
			
			 $eve = "select * from res_company_master where companymid=$cmpmid";

	$re = mysqli_query($conn, $eve);
				while($rt = mysqli_fetch_assoc($re))
		{
			 	$cmpname=$rt['companyname'];
			 	$cmpprefix=$rt['companyprefix'];
		}
	
	$totalnetweight=0;
	$trolleytareweight=0;
	$trolleygrossweight=0;
	$trolleynetweight=0;
	$jobworkmid=0;
	$jobworkdid=0;
	$customerid=0;
	
	$changeitem='disabled';
	if(isset($_POST['tocompanymid']))
	{
		$changeitem='';
		$_SESSION['currentcustomer']=$_POST['tocompanymid'];
		
		$customerid=$_SESSION['currentcustomer'];
		
	}
	else if(isset($_SESSION['currentcustomer']))
	{
		$changeitem='';
		$customerid=$_SESSION['currentcustomer'];
			
	}
	else
	{
		$changeitem='';
		unset($_SESSION['currentcustomer']);
		
	}
	
	$cpname="";
	$cmpmobile="";
	$cmpaddress="";
	
	if(isset($_GET['id']))
	{
		$jobworkdid=$_GET['id'];
		
		$query2 = "select * from res_jobwork_detail where jobworkdid=$jobworkdid";
		$stmt2=mysqli_query($conn,$query2);
															
			if(mysqli_num_rows($stmt2) > 0)
			{
												
				while($rt2 = mysqli_fetch_assoc($stmt2))
				{
					$trolleymid1=$rt2['trolleymid'];
					$trolleytareweight=$rt2['trolleytareweight'];
					$trolleygrossweight=$rt2['trolleygrossweight'];
					$trolleynetweight=$rt2['trolleynetweight'];
				
			
				}
		}
	}
?>
<!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><?php if($_SESSION['linkarisecmptype']=='Hotel'){?>
                                  Add Linen Job Work
															<?php } else{?>
															Add Clean Clothes 
															<?php } ?></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>
	<!--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"><?php if($_SESSION['linkarisecmptype']=='Hotel'){?>
                                  Add Linen Job Work
															<?php } else{?>
															Add Clean Clothes 
															<?php } ?></h1>
									<!--end::Heading-->
									<!--begin::Breadcrumb-->
									<ul class="breadcrumb fw-semibold fs-8 my-1">
										<li class="breadcrumb-item text-muted">
											<a href="../../demo4/dist/index.html" class="text-muted">Home</a>
										</li>
									
										<li class="breadcrumb-item text-muted"><?php if($_SESSION['linkarisecmptype']=='Hotel'){?>
                                  Add Linen Job Work
															<?php } else{?>
															Add Clean Clothes 
															<?php } ?></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-->
										
										<!--end::Card header-->
										<!--begin::Card body-->
										<div class="card-body pt-5">
											<!--begin::Form-->
											<form method="POST" id="myForm2" class="form-horizontal" enctype="multipart/form-data" >
													
												<!--begin::Row-->
												<div class="row row-cols-1 row-cols-sm-2 rol-cols-md-1 row-cols-lg-2">
												
											
															<input type="hidden" class="form-control form-control-solid" name="fromcompanymid"  value="<?php echo $cmpmid;?>"  required readonly>
															<!--end::Input-->
													
												<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="required">To Company</span>
																
															</label>
															<!--end::Label-->
															<!--begin::Input-->
																<select class="form-select form-select-solid" data-control="select2"  name="tocompanymid" onchange="this.form.submit()" required>
													<option>Select</option>
													<?php 
																		if($cmptype=="Hotel"){
																			$eve11 = "select * from res_company_master where companytype='I-Wash'";
																		}
																		else
																		{
																			$eve11 = "select * from res_company_master where companytype='Hotel'";
																		}
																			$re11 = mysqli_query($conn, $eve11);
																			
																			while($rt11 = mysqli_fetch_assoc($re11))

																			{											
																				
																				$companymid=$rt11['companymid'];
																				$companyname=$rt11['companyname'];
																				
																				if($customerid==$companymid){
																					
																					$cpname=$rt11['companycontactperson'];
																					$cmpmobile=$rt11['companycontectno'];
																					$cmpaddress=$rt11['companyaddress'];
																					
																				echo "<option value='$companymid' selected>$companyname</option>";
																				}
																				else{
																					echo "<option value='$companymid'>$companyname</option>";
																				}
																			}
																			
																			
																			
																			
																	?>
													</select>
											
															<!--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="">Contact Person</span>
																
															</label>
															<!--end::Label-->
															
															<!--begin::Input-->
															<input type="text" class="form-control form-control-solid" name="" value="<?php echo $cpname;?>" readonly>
															<!--end::Input-->
														</div>
														<!--end::Input group-->
													</div>
													<!--end::Col-->
													
													</div>
												<!--end::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="">Mobile No</span>
																
															</label>
															<!--end::Label-->
															<!--begin::Input-->
															
												<input type="text" class="form-control form-control-solid"  name="" value="<?php echo $cmpmobile;?>" readonly>
															<!--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="">Address</span>
																
															</label>
															<!--end::Label-->
															
															<!--begin::Input-->
															<textarea type="text" class="form-control form-control-solid" readonly ><?php echo $cmpaddress;?></textarea>
															<!--end::Input-->
														</div>
														<!--end::Input group-->
													</div>
													</div>
												<!--end::Row-->
												
												</form>
												
											<!--begin::Row-->
											
												<!--begin::Separator-->
												<div class="separator mb-6"></div>
												<!--end::Separator-->
													<h3>Trolley 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" class="scroller" style="height:auto" data-rail-visible="1" data-rail-color="yellow" data-handle-color="#a1b2bd">
													<table  border="1" style="width:100%" class="table table-bordered table-hover">
											<tr> <th>Sr No.</th><th>Trolley QR Code</th> <th>Gross Weight (Kgs)</th> <th>Tare Weight (Kgs)</th><th>Net Weight (Kgs)</th><th>Item</th><th>Add</th></tr>
									
										<form action="jobworkadd2.php" method="POST" id="myForm" class="form-horizontal" enctype="multipart/form-data" >
												<input type="hidden" name="jobworkdid" value="<?php echo $jobworkdid; ?>">
												<input type="hidden" name="jobworkmid" value="<?php echo $jobworkmid; ?>">
												<tr>
													<td>0</td>
													<td>
														<select class="form-select" data-control="select2"name="trolleymid" id="trolleymid" <?php echo $changeitem; ?>>
															<option value="0">Select Trolley</option>
															<?php
															
															if(isset($_COOKIE['mepoc123']))
													{
														$no=$_COOKIE['mepoc123'];
													}
													else
													{
														$no=-555;
													}	
															
															$eve_main="select * from res_trolley_master where trolleymid not in (select trolleymid from res_jobwork_detail where orderdrandomid='$no')";
															$re_main=mysqli_query($conn,$eve_main);
															while($rt_main=mysqli_fetch_assoc($re_main))
															{
																$trolleymid=$rt_main['trolleymid'];
																$trolleyqrcode=$rt_main['trolleyqrcode'];
																
																if($trolleymid1==$trolleymid)
																{
																	echo "<option value='$trolleymid' selected>$rt_main[trolleynumber]</option>";
																}
																else
																{
																	echo "<option value='$trolleymid'>$rt_main[trolleynumber]</option>";
																}
															}
														?>
														</select>
													</td>
													<td>
														<input type="text" style="width:80px;" name="trolleygrossweight" id="grossweight" class="form-control" value="<?php echo $trolleygrossweight;?>" >
													</td>
													<td>
														<input type="text" style="width:100px;" name="trolleytareweight" id="itemsalesrate" class="form-control" onkeypress="return event.charCode >= 46 && event.charCode <= 57" value="<?php echo $trolleytareweight; ?>">
													</td>
												
													
													<td>
														<input type="text" style="width:80px;" name="trolleynetweight" id="netweight" class="form-control" value="<?php echo $trolleynetweight;?>" >
													</td>
												<td> </td>
													<td>
														<button type="submit" id="btnsave" class="btn btn-light-primary">Add <i class="fa fa-check"></i></button>
													</td>
												</tr>
												</form>
											<?php 
													if(isset($_COOKIE['mepoc123']))
													{
														$no=$_COOKIE['mepoc123'];
													}
													else
													{
														$no=-555;
													}	
													if($jobworkmid!=0)
													{
														 $query = "select * from res_jobwork_detail where jobworkmid=$jobworkmid";
													}
													else
													{
														 $query = "select * from res_jobwork_detail where orderdrandomid='$no'";
													}
													$stmt=mysqli_query($conn,$query);
															
													if(mysqli_num_rows($stmt) > 0)
													{
														$i=1;
													while($rt = mysqli_fetch_assoc($stmt))
														{
															$jobworkdid=$rt['jobworkdid'];
															$trolleymid=$rt['trolleymid'];
															
															$query1 = "select trolleyqrcode from res_trolley_master where trolleymid=$trolleymid";
															$stmt1=mysqli_query($conn,$query1);
															
															$trolleyqrcode="";
															
															if(mysqli_num_rows($stmt1) > 0)
															{
																while($rt1 = mysqli_fetch_assoc($stmt1))
																{
																	$trolleyqrcode=$rt1['trolleyqrcode'];
																	
																}
															}
															
																$query11 = "select count(jobworkdid) as cc from res_jobworkitem_detail where jobworkdid=$jobworkdid";
															$stmt11=mysqli_query($conn,$query11);
															
															$totalitem="";
															
															if(mysqli_num_rows($stmt11) > 0)
															{
																while($rt11 = mysqli_fetch_assoc($stmt11))
																{
																	$totalitem=$rt11['cc'];
																	
																}
															}
															
															
															
														$additem= "<a href='#' data-bs-toggle='modal' data-id='".$jobworkdid."' data-bs-target='#kt_modal_followup' class='btn btn-sm btn-light-danger align-self-center' id='getfollowup'>Add Item</a>";	
												?>
												<tr>
													<td><?php echo $i++;?></td>
													<td><?php echo $trolleyqrcode."&nbsp;&nbsp".$additem;?></td>
													<td><?php echo $rt['trolleygrossweight'];?></td>
													<td><?php echo $rt['trolleytareweight'];?></td>
													<td><?php echo $rt['trolleynetweight'];?></td>
												<td>	<a href="#" data-bs-toggle="modal" data-id="<?php echo $jobworkdid;?>" data-bs-target="#kt_modal_trolleyitem" id="gettrolleyitem"><?php echo $totalitem."&nbsp&nbsp";?><i class="fa fa-eye hidden-print"></i> </a></td>
													<td>
												
														<?php if($jobworkmid!=0){?>
														<a href="jobworkadd.php?jobworkmid=<?php echo $jobworkmid; ?>&id=<?php echo $jobworkdid; ?>"><i class="fa fa-edit"></i></a>
														<?php }else{?>
														<a href="jobworkadd.php?id=<?php echo $jobworkdid; ?>"><i class="fa fa-edit"></i></a>
														<?php } if($jobworkmid!=0){?>&nbsp;&nbsp;
														<a href="jobworkitemdelete.php?jobworkmid=<?php echo $jobworkmid; ?>&id=<?php echo $jobworkdid; ?>" onclick="return confirm(&#39;Are you sure you want to delete ?&#39;);"><i class="fa fa-trash"></i></a>
														<?php }else{?>
														<a href="jobworkitemdelete.php?id=<?php echo $jobworkdid; ?>" onclick="return confirm(&#39;Are you sure you want to delete ?&#39;);"><i class="fa fa-trash"></i></a>
														<?php } ?>
													</td>
												</tr>
											
												<?php } } 
												
												
												?>
											
												</table>
									
												</div>
														<!--end::Input group-->
													</div>
													<!--end::Col-->
													</div>
													
									
												<form action="jobworkadd3.php" method="POST" id="myForm1" class="form-horizontal" enctype="multipart/form-data" >	
												<input type="hidden" name="jobworkmid" value="<?php echo $jobworkmid;?>">
														<input type="hidden" name="tocompanymid" value="<?php echo $customerid;?>">
														<input type="hidden" name="fromcompanymid" value="<?php echo $cmpmid;?>">
														
														<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="">Job Work No.</span>
																
															</label>
															<!--end::Label-->
															<?php 
																			$eve12 = "select max(jobworknumber) as maxno from res_jobwork_master where fromcompanymid=$cmpmid";

																			$re12 = mysqli_query($conn, $eve12);
																			
																			while($rt12 = mysqli_fetch_assoc($re12))

																			{											
																				
																				$workno=$rt12['maxno']+1;
																				 
																				 $jobworkno=$cmpprefix.$workno;
																			}
																			
																	?>
															<!--begin::Input-->
															<input type="text" class="form-control form-control-solid" name="" value="<?php echo $jobworkno;?>" readonly>
															<!--end::Input-->
														</div>
														<!--end::Input group-->
													</div>
													<!--end::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="">Date</span>
																
															</label>
															<!--end::Label-->
															<!--begin::Input-->
															
												<input type="text" class="form-control form-control-solid" id="kt_daterangepicker_2" name="joworkdate" value="<?php echo $mdate;?>" >
															<!--end::Input-->
														</div>
														<!--end::Input group-->
													</div>
											
													
													</div>
												<!--end::Row-->
											
														
												<div class="d-flex justify-content-end">
													<!--begin::Button-->
													<a type="reset" href="jobwork.php"  class="btn btn-light me-3">Cancel</a>
													<!--end::Button-->
													<!--begin::Button-->
													<button type="submit"  id="btnsubmit" name="btnsubmit" 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-->
		<div class="modal fade" id="kt_modal_followup" tabindex="-1" aria-hidden="true">
								<!--begin::Modal dialog-->
								<div class="modal-dialog modal-dialog-centered mw-500px">
									<!--begin::Modal content-->
									<div class="modal-content rounded">
										<!--begin::Modal header-->
										<div class="modal-header pb-10 border-0 ">
										<div class="card-title text-uppercase ">
														<h2>Add Item </h2>
													</div>
											<!--begin::Close-->
											<div class="btn btn-sm btn-icon btn-active-color-primary justify-content-end" data-bs-dismiss="modal">
												<!--begin::Svg Icon | path: icons/duotune/arrows/arr061.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">
														<rect opacity="0.5" x="6" y="17.3137" width="16" height="2" rx="1" transform="rotate(-45 6 17.3137)" fill="currentColor" />
														<rect x="7.41422" y="6" width="16" height="2" rx="1" transform="rotate(45 7.41422 6)" fill="currentColor" />
													</svg>
												</span>
												<!--end::Svg Icon-->
											</div>
											<!--end::Close-->
										</div>
										<!--begin::Modal header-->
										<!--begin::Modal body-->
										<div class="modal-body scroll-y px-10 px-lg-15 pt-0 pb-15">
											<!--begin::Form-->
														<form id="kt_modal_add_user_form6" class="form" action="trolleyitemadd2.php" method="POST"  enctype="multipart/form-data">
													
															<!--begin::Scroll-->
															<!-- content will be load here -->
															<div id="dynamic-content8"></div>
																<!--begin::Actions-->
						
				<div class="fv-row mb-7">
															<!--begin::Label-->
															<label class="fs-6 fw-semibold form-label mt-3">
																<span class="">Item</span>
																
															</label>
															<!--end::Label-->
															<!--begin::Input-->
															
											<select class="form-select form-select-solid" data-control="select2"  name="itemmid" id="itemid" for="itemid" onchange="itemid">
											<option value="0">Select Item</option>
															<?php
															$eve_main="select * from res_item_master";
															$re_main=mysqli_query($conn,$eve_main);
															while($rt_main=mysqli_fetch_assoc($re_main))
															{
																$itemmid=$rt_main['itemmid'];
																$itemname=$rt_main['itemname'];
																
																
																	echo "<option value='$itemmid'>$itemname</option>";
																
															}
														?>
						
											</select>
											<input type="hidden" class="form-control form-control-solid" name="itemname" id="dcontact3" >
															<!--end::Input-->
														</div>
																				<!--begin::Input group-->
						<div class="fv-row mb-7">
															<!--begin::Label-->
															<label class="fs-6 fw-semibold form-label mt-3">
																<span class="">Item Detail</span>
																
															</label>
															<!--end::Label-->
															<!--begin::Input-->
															<textarea type="text" class="form-control form-control-solid" name="itemdetail" id="dcontact2" value="" ></textarea>
															<!--end::Input-->
														</div>
															
						
												
												<div class="fv-row mb-7">
															<!--begin::Label-->
															<label class="fs-6 fw-semibold form-label mt-3">
																<span class="">Item Qty</span>
																
															</label>
															<!--end::Label-->
															<!--begin::Input-->
																<input type="number" class="form-control form-control-solid" name="itemqty" value="1" >
															<!--end::Input-->
														</div>
												
															<div class="text-center pt-15">
																<button type="reset" class="btn btn-light me-3" data-kt-users-modal-action="cancel" data-bs-dismiss="modal" data-bs-dismiss="modal">Discard</button>
																<button type="submit" class="btn btn-primary" data-kt-users-modal-action="submit">
																	<span class="indicator-label">Submit</span>
																	<span class="indicator-progress">Please wait...
																	<span class="spinner-border spinner-border-sm align-middle ms-2"></span></span>
																</button>
															</div>
															
															<!--end::Actions-->
														</form>
														<!--end::Form-->
													</div>
										<!--end::Modal body-->
									</div>
									<!--end::Modal content-->
								</div>
								<!--end::Document-->
							</div>
							<div class="modal fade" id="kt_modal_trolleyitem" tabindex="-1" aria-hidden="true">
								<!--begin::Modal dialog-->
								<div class="modal-dialog modal-dialog-centered mw-500px">
									<!--begin::Modal content-->
									<div class="modal-content rounded">
										<!--begin::Modal header-->
										<div class="modal-header pb-10 border-0 ">
										<div class="card-title text-uppercase ">
														<h2>Add Item </h2>
													</div>
											<!--begin::Close-->
											<div class="btn btn-sm btn-icon btn-active-color-primary justify-content-end" data-bs-dismiss="modal">
												<!--begin::Svg Icon | path: icons/duotune/arrows/arr061.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">
														<rect opacity="0.5" x="6" y="17.3137" width="16" height="2" rx="1" transform="rotate(-45 6 17.3137)" fill="currentColor" />
														<rect x="7.41422" y="6" width="16" height="2" rx="1" transform="rotate(45 7.41422 6)" fill="currentColor" />
													</svg>
												</span>
												<!--end::Svg Icon-->
											</div>
											<!--end::Close-->
										</div>
										<!--begin::Modal header-->
										<!--begin::Modal body-->
										<div class="modal-body scroll-y px-10 px-lg-15 pt-0 pb-15">
											<!--begin::Form-->
														
													
															<!--begin::Scroll-->
															<!-- content will be load here -->
															<div id="dynamic-content9"></div>
											<!--begin::Form-->
											
									
															<div class="text-center pt-15">
																<button type="reset" class="btn btn-light-danger me-3" data-kt-users-modal-action="cancel" data-bs-dismiss="modal" data-bs-dismiss="modal">Cancel</button>
																
															</div>
															
															<!--end::Actions-->
													
														<!--end::Form-->
													</div>
										<!--end::Modal body-->
									</div>
									<!--end::Modal content-->
								</div>
								<!--end::Document-->
							</div>
		<!--end::Engage modals-->
		<!--begin::Engage toolbar-->
		<!--end::Engage toolbar-->
		<!--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-->
		<!--end::Javascript-->
		<?php
		if(isset($_SESSION['msg']))
{
	$tt1 = $_SESSION['msg'];
	echo "<input type=\"hidden\" id=\"mymsg\" value=\"$tt1\"/>";
	unset($_SESSION['msg']);
	
	
	?>	
								
		<script lang="javascript">

var a = [
    function () {
	

		var mymsg = document.getElementById("mymsg").value;
		toastr.success(mymsg, "Success")
		
    },
    function () {
        $('span').show();
    },
    function () {
        $('p').fadeIn(100);
    }
];		
					

a[0]();
</script>
	
<?php

}
?>	
		
		<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>
		$('#trolleymid').on('change',function()
		{
			var trolleytareweight=0;
			var trolleygrossweight=0;
			var trolleynetweight=0;
		
			$.get("trolleytareweightsearch.php", { trolleymid : $(this).val() }, function(response) 
			{
				
				$('#itemsalesrate').val( $.trim(response) );
				
				/*----sales rate change--*/
				var price = parseFloat($('#itemsalesrate').val());
				var orderamt = price;
				
				$('#netweight').val((orderamt).toFixed(2));
				
				$('#itemsalesrate').on('input', function() 
				{
				  var price = parseFloat($('#itemsalesrate').val());
				  var grossweight = parseFloat($('#grossweight').val());
				
				  var gstamt = grossweight-price;
				
				  $('#netweight').val((gstamt).toFixed(2));
				});
				/*----sales rate change--*/
				
				/*----sales qty change--*/
				$('#grossweight').on('input', function() 
				{
					var price = parseFloat($('#itemsalesrate').val());
					 var grossweight = parseFloat($('#grossweight').val());
					
				
				  var gstamt = grossweight-price;
					
					$('#netweight').val((gstamt).toFixed(2));
				});
				/*----sales qty change--*/
				
				
				
			});
			
		
		
		
		});
	$('#itemsalesrate, #grossweight').on('input', function() {
			
			  var price = parseFloat($('#itemsalesrate').val());
			  var grossweight = parseFloat($('#grossweight').val());
			 
			  var gstamt =grossweight-price;
			 $('#netweight').val((gstamt).toFixed(2));
			});
	</script>


<?php 
	if(isset($_POST['tocompanymid']))
	{
		echo "<script>
				document.getElementById('btnsave').disabled = false;
			</script>";
	}
	else if($jobworkmid!=0)
	{
		echo "<script>
				document.getElementById('btnsave').disabled = false;
			</script>";
	}
	else if(isset($_SESSION['currentcustomer']))
	{
		echo "<script>
				document.getElementById('btnsave').disabled = false;
			</script>";
	}
	else
	{
		echo "<script>
				document.getElementById('btnsave').disabled = true;
			</script>";
	}
	
	if (mysqli_num_rows($stmt) > 0)
	{
		echo "<script>
				document.getElementById('btnsubmit').disabled = false;
				document.getElementById('btnview').disabled = false;
			</script>";
	}
	else
	{
		echo "<script>
				document.getElementById('btnsubmit').disabled = true;
				document.getElementById('btnview').disabled = true;
			</script>";
	}
?>

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

		$(document).on('click', '#getfollowup', function(e){

			e.preventDefault();

			var uid = $(this).data('id');   // it will get id of clicked row
			
			

			$('#dynamic-content8').html(''); // leave it blank before ajax call
			      // load ajax loader

			$.ajax({
				url: 'trolleyitemadd.php',
				type: 'POST',
				data: 'id='+uid,
				dataType: 'html'
			})
			.done(function(data){
				console.log(data);
				$('#dynamic-content8').html('');
				$('#dynamic-content8').html(data); // load response
						  // hide ajax loader
			})
			.fail(function(){
				$('#dynamic-content8').html('<i class="glyphicon glyphicon-info-sign"></i> Something went wrong, Please try again...');
				
			});

		});
	});

	

</script>	

<script>
				/* $(function() {
					$( "#skills" ).autocomplete({
						source: 'customersearch.php'
					});
				}); */
				$('#itemid').on('change',function(){


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

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

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

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

				});
				
				});
			</script>

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

		$(document).on('click', '#gettrolleyitem', function(e){

			e.preventDefault();

			var uid = $(this).data('id');   // it will get id of clicked row
			
			

			$('#dynamic-content9').html(''); // leave it blank before ajax call
			      // load ajax loader

			$.ajax({
				url: 'jobworktrolleyitemdetail.php',
				type: 'POST',
				data: 'id='+uid,
				dataType: 'html'
			})
			.done(function(data){
				console.log(data);
				$('#dynamic-content9').html('');
				$('#dynamic-content9').html(data); // load response
						  // hide ajax loader
			})
			.fail(function(){
				$('#dynamic-content9').html('<i class="glyphicon glyphicon-info-sign"></i> Something went wrong, Please try again...');
				
			});

		});
	});

	

</script>	


	</body>
	<!--end::Body-->
</html>