<?php 
session_start(); 
if(!isset($_SESSION['linkarisecrm']))
	{
		header('Location: index.php');
		return;
	}
	$cmpmid=$_SESSION['linkarisecmpmid'];
include("connect.php");
$_SESSION['frompage']='jobworkdetail';
?>
<!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>Job Work Detail</title>
		<meta charset="utf-8" />
		
		<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" />
		<style>
		    body{
		        background-image: none !important;
    background-color: #F3F6F9;
		    }
		</style>
		<!--end::Global Stylesheets Bundle-->
	</head>
	<?php
					
	
	
	
	date_default_timezone_set("Asia/Singapore");
		$mdate1= date('Y-m-d H:i:s');
		$mdate= date('d-m-Y');
		if(isset($_POST['jobworkmid'])){
			$jobworkmid=$_POST['jobworkmid'];
			
		}
		else if(isset($_GET['id'])){
	$jobworkmid=$_GET['id'];

		}
	$eve = "select * from res_jobwork_master where jobworkmid=".$jobworkmid;
			$re = mysqli_query($conn, $eve);
			while($rt = mysqli_fetch_assoc($re))
			{
				
				$bumid=$rt['jobworkmid'];
						$tocompanymid=$rt['tocompanymid'];
						$jobworktype=$rt['jobworktype'];
						$jobworkstatus=$rt['jobworkstatus'];
						$jobworknofordisplay=$rt['jobworknofordisplay'];
						$dispatchedby=$rt['dispatchedby'];
						$dispatchedon=$rt['dispatchedon'];
						$receivedon=$rt['receivedon'];
						
						$jobworkdate=date("d-m-y",strtotime($rt['jobworkdate']));
						$receivedby=$rt['receivedby'];
						
				$cmpname="";    
				$cpname="";
				$cpmobile="";
				$cmpaddress="";
				$eve71="select * from res_company_master where companymid=$tocompanymid";
					$re71 = mysqli_query($conn, $eve71);
					while($rt71 = mysqli_fetch_assoc($re71))
					{
						$cmpname=$rt71['companyname'];
						$cpname=$rt71['companycontactperson'];
						$cpmobile=$rt71['companycontectno'];
						$cmpaddress=$rt71['companyaddress'];
						
					}
												
					if($jobworkstatus=="Dispatched")
				{
					
					$jobworkstatus1="<div class='badge badge-light-danger fw-bold'> <a href='jobworkstatusedit.php?id=$bumid'>Pending <i class='fa fa-pencil'></i></a></div>";
				}
				else if($jobworkstatus=="Received")
				{
					
					$jobworkstatus1="<div class='badge badge-light-primary fw-bold'>Received</div>";
				}

			}
			$receivedbyname="";
			$eve72="select * from res_user_master where usermid=$receivedby";
					$re72 = mysqli_query($conn, $eve72);
					while($rt72 = mysqli_fetch_assoc($re72))
					{
						$receivedbyname=$rt72['username'];
						
						
					}
			
			$dispatchedbyname="";
			$eve712="select * from res_user_master where usermid=$dispatchedby";
					$re712 = mysqli_query($conn, $eve712);
					while($rt712 = mysqli_fetch_assoc($re712))
					{
						$dispatchedbyname=$rt712['username'];
						
						
					}
			
			 $full_url = $_SERVER['REQUEST_URI'];

$hash_position = strpos($full_url, "#");

if (isset($_GET['tab'])) {
    $hash_value = $_GET['tab'];
   
} else {
   $hash_value = 'student_detail';
}
	
?>
	<!--end::Head-->
	<!--begin::Body-->
<body id="kt_app_body" data-kt-app-layout="dark-sidebar" data-kt-app-header-fixed="true" data-kt-app-sidebar-enabled="true" data-kt-app-sidebar-fixed="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-->
		<!--begin::Theme mode setup on page load-->
		<script>var defaultThemeMode = "light"; var themeMode; if ( document.documentElement ) { if ( document.documentElement.hasAttribute("data-bs-theme-mode")) { themeMode = document.documentElement.getAttribute("data-bs-theme-mode"); } else { if ( localStorage.getItem("data-bs-theme") !== null ) { themeMode = localStorage.getItem("data-bs-theme"); } else { themeMode = defaultThemeMode; } } if (themeMode === "system") { themeMode = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"; } document.documentElement.setAttribute("data-bs-theme", themeMode); }</script>
		<!--end::Theme mode setup on page load-->
		<!--begin::Main-->
		<!--begin::Root-->
		<div class="d-flex flex-column flex-root app-root" id="kt_app_root">
			<!--begin::Page-->
			<div class="app-page flex-column flex-column-fluid" id="kt_app_page">
				<!--begin::Header-->
				<?php include('header2.php'); ?>
				
				<!--end::Header-->
				<!--begin::Wrapper-->
				<div class="app-wrapper flex-column flex-row-fluid" id="kt_app_wrapper">
					<!--begin::Sidebar-->
				<?php include('sidebar2.php'); ?>
				<!--end::Sidebar-->
					<!--begin::Main-->
					<div class="app-main flex-column flex-row-fluid" id="kt_app_main">
						<!--begin::Content wrapper-->
						<div class="d-flex flex-column flex-column-fluid">
							<!--begin::Toolbar-->
							<div id="kt_app_toolbar" class="app-toolbar py-3 py-lg-6">
								<!--begin::Toolbar container-->
								<div id="kt_app_toolbar_container" class="app-container container-xxl d-flex flex-stack">
									<!--begin::Page title-->
									<div class="page-title d-flex flex-column justify-content-center flex-wrap me-3">
										<!--begin::Title-->
										<h1 class="page-heading d-flex text-dark fw-bold fs-3 flex-column justify-content-center my-0">Job Work Details</h1>
										<!--end::Title-->
										<!--begin::Breadcrumb-->
										<ul class="breadcrumb breadcrumb-separatorless fw-semibold fs-7 my-0 pt-1">
											<!--begin::Item-->
											<li class="breadcrumb-item text-muted">
												<a href="dashboard.php" class="text-muted text-hover-primary">Home</a>
											</li>
											<!--end::Item-->
											<!--begin::Item-->
											<li class="breadcrumb-item">
												<span class="bullet bg-gray-400 w-5px h-2px"></span>
											</li>
											<!--end::Item-->
											<!--begin::Item-->
											<li class="breadcrumb-item text-muted">Job Work Details</li>
											<!--end::Item-->
											<!--begin::Item-->
											
											<!--begin::Item-->
										
											<!--end::Item-->
										</ul>
										<!--end::Breadcrumb-->
									</div>
									<!--end::Page title-->
									<!--end::Actions-->
								</div>
								<!--end::Toolbar container-->
							</div>
							<!--end::Toolbar-->
							<!--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::Order details page-->
							
								<div class="d-flex flex-column gap-7 gap-lg-10">
								<!--begin::Tab content-->
								<div class="tab-content">
									<!--begin::Tab pane-->
									<div class="tab-pane fade <?php if($hash_value == 'student_detail'){ echo 'show active'; }?>" id="student_detail" role="tab-panel">
										<!--begin::Orders-->
										<div class="d-flex flex-column gap-7 gap-lg-10">
											<div class="d-flex flex-column flex-xl-row gap-7 gap-lg-10">
												<!--begin::Payment address-->
												<div class="card card-flush py-4 flex-row-fluid overflow-hidden">
													<!--begin::Background-->
													
													<!--end::Background-->
													<div class="card-toolbar">
										<!--begin::Toolbar-->
										<div class="d-flex justify-content-end" data-kt-user-table-toolbar="base">
											<!--begin::Export-->
											
											<a href="jobworkreceive.php" class="btn btn-light-primary me-3" >
													 Back 
												</a>
											<!--end::Export-->
											<!--begin::Add user-->
											
											
											<!--end::Add user-->
										</div>
										</div>
													<!--begin::Card header-->
													<div class="card-body pt-0">
													<div class="table-responsive">
													<table class="table align-middle table-row-dashed fs-6 gy-5 mb-0">
                
                <tr>
                  <th class="fw-bold"> Company Name
                  </th>
                  <td>
                    <?php echo $cmpname;?>
                  </td>
                 
				 <th class="fw-bold">Address
                  </th>
                  <td >
                    <?php echo $cmpaddress;?>
                  </td>
				  </tr>
				  <tr>
                  <th class="fw-bold">Contact Person
                  </th>
                  <td >
                    <?php echo $cpname;?>
                  </td>								
                 <th class="fw-bold">Mobile No.
                  </th>
                  <td>
                    <?php echo $cpmobile;?>
                  </td>
                </tr>
				 <tr >
                   <th class="fw-bold">Job Work No.
                  </th>
                  <td >
                    <?php echo $jobworknofordisplay;?>
                  </td>
				  <th class="fw-bold">Job Work Date
                  </th>
                  <td >
                    <?php echo $jobworkdate;?>
                  </td>
                </tr>
              
				 <tr >
                   <th class="fw-bold">Job Work Type
                  </th>
                  <td >
                    <?php echo $jobworktype;?>
                  </td>
				  <th class="fw-bold">Job Work Status
                  </th>
                  <td >
                    <?php echo $jobworkstatus1;?>
                  </td>
                </tr>
				 <tr >
                   <th class="fw-bold">Dispatched By
                  </th>
                  <td >
                    <?php echo $dispatchedbyname;?>
                  </td>
				  <th class="fw-bold">Dispatched On
                  </th>
                  <td >
                    <?php echo $dispatchedon;?>
                  </td>
                </tr>
				<?php if($receivedby!=0 && $receivedby!=""){?>
				 <tr >
                   <th class="fw-bold">Received By
                  </th>
                  <td >
                    <?php echo $receivedbyname;?>
                  </td>
				  <th class="fw-bold">Received On
                  </th>
                  <td >
                    <?php echo $receivedon;?>
                  </td>
                </tr>
			
				<?php }?>
               
				
               
              </table>
			  </div>
			  </div>
           
													<!--end::Card header-->
													<!--begin::Card body-->
													
													<!--end::Card body-->
												</div>
												<!--end::Payment address-->
												</div>
						
											<div class="card card-flush py-4 flex-row-fluid">
												<!--begin::Card header-->
												<div class="card-header">
													<div class="card-title text-uppercase">
														<h2>Trolley Details</h2>
													</div>
													<!--begin::Add user-->
											
											<!--end::Add user-->
												</div>
												
												<!--end::Card header-->
												<!--begin::Card body-->
												<div class="card-body pt-0">
													<div class="table-responsive">
														<!--begin::Table-->
														<table class="table align-middle table-row-dashed fs-6 gy-5 mb-0">
															<!--begin::Table head-->
															<thead>
																<tr class="text-start text-black-400 fw-bold fs-7 text-uppercase gs-0">
																	 <th>Sr No.
                          
                            </th>
							<th>Trolley No
                            </th>
							<th>Gross Weight (Kgs)
                            </th>
							<th> Tare Weight (Kgs)
                            </th>
							
							
							<th>Net Weight (Kgs)
                            </th>
							<th>Received
                            </th>
							<th>Verfied Trolley Weight
                            </th>
								<th>Trolley Items
                            </th>
																	
																	
																</tr>
															</thead>
															<!--end::Table head-->
															<!--begin::Table body-->
															<tbody class="fw-semibold text-gray-600">
															<?php
															$i=1;
															
															$evepay = "select * from res_jobwork_detail where jobworkmid=$jobworkmid";
															$repay = mysqli_query($conn, $evepay);
															$i=1;
															while($rtpay = mysqli_fetch_assoc($repay))
															{
													
									$jobworkdid=$rtpay['jobworkdid'];
									$barcode=$rtpay['trolleyqrcode'];
									$trolleymid=$rtpay['trolleymid'];
									$tareweight=$rtpay['trolleytareweight'];
									$grossweight=$rtpay['trolleygrossweight'];
									$netweight=$rtpay['trolleynetweight'];
									$trolleyreceived=$rtpay['trolleyreceived'];
									$trolleyreceivedgrossweight=$rtpay['trolleyreceivedgrossweight'];
									
									
									$trolleynumber="";
				$eve7="select * from res_trolley_master where trolleymid=$trolleymid";
					$re7 = mysqli_query($conn, $eve7);
					while($rt7 = mysqli_fetch_assoc($re7))
					{
						$trolleynumber=$rt7['trolleynumber'];
						
					}
									
									$view="<a href='#' data-bs-toggle='modal' data-id='".$jobworkdid."' data-bs-target='#kt_modal_followup' class='' id='gettrolleyitem'><span class='fa fa-eye fa-lg hidden-print'></span> </a>";
					
					if($trolleyreceived==0)
				{
					
					$trolleyreceived1="<div class='badge badge-light-danger fw-bold'> <a href='trolleyreceivedstatus.php?id=$jobworkdid&jobworkmid=$jobworkmid'>No <i class='fa fa-pencil'></i></a></div>";
				}
				else if($trolleyreceived==1)
				{
					
					$trolleyreceived1="<div class='badge badge-light-primary fw-bold'>Yes</div>";
				}
				
				if($trolleyreceivedgrossweight==0)
				{
					
					$trolleyreceivedgrossweight="<a href='#' data-bs-toggle='modal' data-id='$jobworkdid' data-bs-target='#kt_modal_trolleyitem' id='gettrolleyid'>Add Verfied Weight </a>";
				}
				else
				{
					
					$trolleyreceivedgrossweight=$trolleyreceivedgrossweight;
				}
							$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'];
																	
																}
															}
															?>
																<tr>
																	
																	 <td>
                              <?php echo $i++;?>
                            </td>
							
                            
							<td>
                              <?php echo $trolleynumber;?>
                            </td>
							 <td>
                              <?php echo $grossweight;?>
                            </td>
							<td>
                              <?php echo $tareweight;?>
                            </td> <td>
                              <?php echo $netweight;?>
                            </td> 
							<td><?php echo $trolleyreceived1;?></td>
							<td><?php echo $trolleyreceivedgrossweight;?></td>
							<td>
                              <?php echo $totalitem." ".$view;?>
                            </td> 
					
																	
																</tr>
															<?php } ?>
																</tbody>
															<!--end::Table head-->
														</table>
														<!--end::Table-->
													</div>
												</div>
												<!--end::Card body-->
											</div>
					
				
											
											
											</div>
										<!--end::Orders-->
									</div>
									<!--end::Tab pane-->
									
								</div>
								<!--end::Tab content-->
								
							</div>
							<!--end::Order details page-->
						</div>
						<!--end::Container-->
					</div>
					
							<!--end::Content-->
						</div>
						<!--end::Content wrapper-->
						<!--begin::Footer-->
						<?php include('footer.php'); ?>
						
						<!--end::Footer-->
					</div>
					<!--end:::Main-->
				</div>
				<!--end::Wrapper-->
			</div>
			<!--end::Page-->
		</div>
		<!--end::Root-->
		<!--begin::Drawers-->
			<!--begin::Modal - Common Document-->
						<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 ">
														<h2>Trolley Item Detail</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-->
														
											<div id="dynamic-content8"></div>
											
									
															<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-->
													
												</div>
															
															<!--end::Actions-->
													
														<!--end::Form-->
													</div>
										<!--end::Modal body-->
									</div>
									<!--end::Modal content-->
								</div>
								<!--end::Document-->
							
		<!--begin::Engage modals-->
		<!--end::Engage modals-->
		<!--begin::Modal - Add task-->
					<!--end::Modal - Student Course-->
						<!--begin::Modal - Student College Application-->
						
							<!--end::Modal - Student College Application-->
						
						
					
							
				
					
						
		<!--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/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-->
	
		<?php

if(isset($_SESSION['msg']))
{
	$tt = $_SESSION['msg'];
	echo "<input type=\"hidden\" id=\"mymsg\" value=\"$tt\"/>";
	unset($_SESSION['msg']);
	
	
?>	
								
		<script lang="javascript">

var a = [
    function () {
	

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

a[0]();
</script>


		
	
<?php
}

if(isset($_SESSION['msg1']))
{
	$tt1 = $_SESSION['msg1'];
	echo "<input type=\"hidden\" id=\"mymsg1\" value=\"$tt1\"/>";
	unset($_SESSION['msg1']);
	
	
	?>	
								
		<script lang="javascript">

var a = [
    function () {
	

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

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

}
?>	

	
	
		<!--end::Javascript-->
		
		<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-content8').html(''); // leave it blank before ajax call
			      // load ajax loader

			$.ajax({
				url: 'trolleyitemdetail.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>
		$(document).ready(function(){

		$(document).on('click', '#gettrolleyid', 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: 'trolleyid.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>