<?php
	include "db_connection/db_connection.php";
	include "config/config.php";
	
	if($_SESSION['admin_login_id'] == '')
	{
		echo "<script>window.location='index.php';</script>";
	}
	else // THIS IS FOR GETTING PARTY DET ID ROM LOAGIN DET AND PARTY DET TABLE
	{
		$admin_id = $_SESSION['admin_login_id'];
		
		$SLCT_log = "SELECT * FROM login_details,ac_party_det WHERE ac_party_det.party_det_id = login_details.party_det_id AND login_details.admin_id = '$admin_id'";
		//echo $SLCT_log;
		$QURY_log = mysqli_query($connect,$SLCT_log);
		$FTCH_log = mysqli_fetch_object($QURY_log);
		$party_id = '$FTCH_log->party_det_id';
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<title><?php echo $PROJECT_TITLE ?></title>
<script type="text/javascript" >
	function foc(ids)
	{
		document.getElementById(ids).style.border="2px solid #0099FF";
		
	}

	function stnon(ids)
	{
		document.getElementById(ids).style.border="thin solid #CCCCCC";
	}
	
</script>

<link href="css/styles.css" rel="stylesheet" type="text/css" />
<!--[if IE]> <link href="css/ie.css" rel="stylesheet" type="text/css"> <![endif]-->

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>

<script type="text/javascript" src="js/plugins/forms/ui.spinner.js"></script>
<script type="text/javascript" src="js/plugins/forms/jquery.mousewheel.js"></script>
 
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>

<script type="text/javascript" src="js/plugins/charts/excanvas.min.js"></script>
<script type="text/javascript" src="js/plugins/charts/jquery.flot.js"></script>
<script type="text/javascript" src="js/plugins/charts/jquery.flot.orderBars.js"></script>
<script type="text/javascript" src="js/plugins/charts/jquery.flot.pie.js"></script>
<script type="text/javascript" src="js/plugins/charts/jquery.flot.resize.js"></script>
<script type="text/javascript" src="js/plugins/charts/jquery.sparkline.min.js"></script>

<script type="text/javascript" src="js/plugins/tables/jquery.dataTables.js"></script>
<script type="text/javascript" src="js/plugins/tables/jquery.sortable.js"></script>
<script type="text/javascript" src="js/plugins/tables/jquery.resizable.js"></script>

<script type="text/javascript" src="js/plugins/forms/autogrowtextarea.js"></script>
<script type="text/javascript" src="js/plugins/forms/jquery.uniform.js"></script>
<script type="text/javascript" src="js/plugins/forms/jquery.inputlimiter.min.js"></script>
<script type="text/javascript" src="js/plugins/forms/jquery.tagsinput.min.js"></script>
<script type="text/javascript" src="js/plugins/forms/jquery.maskedinput.min.js"></script>
<script type="text/javascript" src="js/plugins/forms/jquery.autotab.js"></script>
<script type="text/javascript" src="js/plugins/forms/jquery.chosen.min.js"></script>
<script type="text/javascript" src="js/plugins/forms/jquery.dualListBox.js"></script>
<script type="text/javascript" src="js/plugins/forms/jquery.cleditor.js"></script>
<script type="text/javascript" src="js/plugins/forms/jquery.ibutton.js"></script>
<script type="text/javascript" src="js/plugins/forms/jquery.validationEngine-en.js"></script>
<script type="text/javascript" src="js/plugins/forms/jquery.validationEngine.js"></script>

<script type="text/javascript" src="js/plugins/uploader/plupload.js"></script>
<script type="text/javascript" src="js/plugins/uploader/plupload.html4.js"></script>
<script type="text/javascript" src="js/plugins/uploader/plupload.html5.js"></script>
<script type="text/javascript" src="js/plugins/uploader/jquery.plupload.queue.js"></script>

<script type="text/javascript" src="js/plugins/wizards/jquery.form.wizard.js"></script>
<script type="text/javascript" src="js/plugins/wizards/jquery.validate.js"></script>
<script type="text/javascript" src="js/plugins/wizards/jquery.form.js"></script>

<script type="text/javascript" src="js/plugins/ui/jquery.collapsible.min.js"></script>
<script type="text/javascript" src="js/plugins/ui/jquery.breadcrumbs.js"></script>
<script type="text/javascript" src="js/plugins/ui/jquery.tipsy.js"></script>
<script type="text/javascript" src="js/plugins/ui/jquery.progress.js"></script>
<script type="text/javascript" src="js/plugins/ui/jquery.timeentry.min.js"></script>
<script type="text/javascript" src="js/plugins/ui/jquery.colorpicker.js"></script>
<script type="text/javascript" src="js/plugins/ui/jquery.jgrowl.js"></script>
<script type="text/javascript" src="js/plugins/ui/jquery.fancybox.js"></script>
<script type="text/javascript" src="js/plugins/ui/jquery.fileTree.js"></script>
<script type="text/javascript" src="js/plugins/ui/jquery.sourcerer.js"></script>

<script type="text/javascript" src="js/plugins/others/jquery.fullcalendar.js"></script>
<script type="text/javascript" src="js/plugins/others/jquery.elfinder.js"></script>

<script type="text/javascript" src="js/plugins/ui/jquery.easytabs.min.js"></script>
<script type="text/javascript" src="js/files/bootstrap.js"></script>
<script type="text/javascript" src="js/files/functions.js"></script>

<script type="text/javascript" src="js/charts/chart.js"></script>
<script type="text/javascript" src="js/charts/hBar_side.js"></script>

<!-- Shared on MafiaShare.net  --><!-- Shared on MafiaShare.net  -->	
</head>
<body onload="document.getElementById('listpage').focus(),party_cst();">
	<!-- Top line begins -->
	<?php include "header_footer/header.php"; ?>
	<!-- Top line ends -->
	<!-- Sidebar begins -->
	<?php include "menus/left_menu.php"; ?>
	<!-- Sidebar ends -->
	<!-- Content begins -->
	<div id="content">    
		<?php include "menus/top_menu.php"; ?>    
	    <!-- Breadcrumbs line -->
	    <div class="breadLine">
	        <div class="bc">
	            <ul id="breadcrumbs" class="breadcrumbs">
	                <li><a href="dashboard.pgp">Dashboard</a></li>
	                <li><a href="javascript:">Piece Tracking</a></li>
	                    
	            </ul>
	        </div>
			<?php include "menus/top_left_menu.php"; ?> 
	    </div>    
	    <!-- Main content -->
	    <?php
	    	$pg_id = base64_decode(base64_decode(base64_decode(base64_decode($_GET['pg_id']))));
	    	$des_id = base64_decode(base64_decode(base64_decode(base64_decode($_GET['des_id']))));
			$cat_name = $_GET['cat_name'];
			$date_tod = $_GET['ser_to_dt'];
			$date_dec = $_GET['ser_dt'];
			$nam_dec  = $_GET['sta_name']; 
			
	    	if($pg_id==1)
	    	{
				$lbl = 'Selected';
				$SLCT_PICE = "SELECT `po_entry_det`.`po_entry_det_id`,`po_entry_det`.`design_det_id`,po_entry.party_det_id,po_entry.po_entry_id,po_entry.po_no,po_entry.po_date FROM `show_case`,`po_entry`,`po_entry_det` WHERE `po_entry`.`po_entry_id` = `po_entry_det`.`po_entry_id` AND `po_entry_det`.`design_det_id` = `show_case`.`design_det_id` AND `po_entry_det`.`design_det_id`='$des_id' AND `po_entry_det`.fin_status='no' AND `po_entry_det`.del_status='no' AND `po_entry_det`.cancelled='no' ORDER BY party_det_id ASC";									
			}
			else if($pg_id==2)
	    	{
				$lbl = 'Finished';
				$SLCT_PICE = "SELECT `po_entry_det`.`po_entry_det_id`,`po_entry_det`.`design_det_id`,po_entry.party_det_id,po_entry.po_entry_id,po_entry.po_no,po_entry.po_date FROM `show_case`,`po_entry`,`po_entry_det` WHERE `po_entry`.`po_entry_id` = `po_entry_det`.`po_entry_id` AND `po_entry_det`.`design_det_id` = `show_case`.`design_det_id` AND `po_entry_det`.`design_det_id`='$des_id' AND `po_entry_det`.fin_status='yes' AND `po_entry_det`.del_status='no' AND `po_entry_det`.cancelled='no' ORDER BY party_det_id ASC";									
			}
			else if($pg_id==3)
	    	{
				$lbl = 'Delivered';
				$SLCT_PICE = "SELECT `po_entry_det`.`po_entry_det_id`,`po_entry_det`.`design_det_id`,po_entry.party_det_id,po_entry.po_entry_id,po_entry.po_no,po_entry.po_date FROM `show_case`,`po_entry`,`po_entry_det` WHERE `po_entry`.`po_entry_id` = `po_entry_det`.`po_entry_id` AND `po_entry_det`.`design_det_id` = `show_case`.`design_det_id` AND `po_entry_det`.`design_det_id`='$des_id' AND `po_entry_det`.fin_status='yes' AND `po_entry_det`.del_status='yes' AND `po_entry_det`.cancelled='no' ORDER BY party_det_id ASC";									
			}
			
			$SLCT_DESIN = "SELECT design_det.`master_cat_id`,`master_cat_name`, `design_no`, master_pieces, `imag_ext`, `cad_fin_ext`, `mas_fin_ext` FROM `design_det`,`master_cat` WHERE `design_det`.`design_det_id` = '$des_id' AND `master_cat`.`master_cat_id` = `design_det`.`master_cat_id`";
			$QURY_DESIN = mysqli_query($connect,$SLCT_DESIN);
			$FTCH_DESIN = mysqli_fetch_object($QURY_DESIN);
			
			if($FTCH_DESIN->mas_fin_ext!=''){ $imag = "../mas_fin_images/S.".$FTCH_DESIN->mas_fin_ext; $imag1 = "../mas_fin_images/L.".$FTCH_DESIN->mas_fin_ext; }
			else if($FTCH_DESIN->cad_fin_ext!=''){ $imag = "../cad_fin_images/S.".$FTCH_DESIN->cad_fin_ext; $imag1 = "../cad_fin_images/L.".$FTCH_DESIN->cad_fin_ext; }												
			else if($FTCH_DESIN->imag_ext!=''){ $imag = "../design_images/S.".$FTCH_DESIN->imag_ext; $imag1 = "../design_images/L.".$FTCH_DESIN->imag_ext; }
	    ?>
	    <div class="wrapper">
	        <ul class="middleNavR">
	        	<li><a href="mov_non_mov_analyze_list.php?cat_name=<?php echo $cat_name; ?>&ser_to_dt=<?php echo $date_tod; ?>&ser_dt=<?php echo $date_dec; ?>&sta_name=<?php echo $nam_dec; ?>" title="Moving Non Moving List" id="listpage" class="tipN"><img src="images/icons/middlenav/stats.png" alt="" /></a></li>
	        </ul>            
			<form>			
		   		<fieldset>
	    			<div class="widget" style="display: block"> <!--style="width:600px; margin-left:150px;"-->
						<div class="whead">
							<h6><?php echo $lbl; ?> Design List</h6>&nbsp;&nbsp;&nbsp;&nbsp;
							<h6><?php echo "Design No : ".$FTCH_DESIN->master_cat_name." ".$FTCH_DESIN->design_no; ?></h6>&nbsp;&nbsp;&nbsp;&nbsp;
							<h6><?php echo "No of Dies : ".$FTCH_DESIN->master_pieces; ?></h6>
							<h6 style="float:right; margin-right:50px">Total Cost : <input type="text" id="tot_qty" name="tot_qty" value="" readonly="readonly" disabled="disabled" style="width:150px; font-size:12px; text-align:center;" /></h6>
							<div class="clear"></div>
						</div>
						<div id="dyn" class="hiddenpars">
							<a href="javascript:0" id="searchlink" onfocus="foc(this.id)" onblur="stnon(this.id)" class="tOptions" title="Options"><img src="images/icons/options.png" alt="" /></a>
							<table width="100%" border="0" cellpadding="0" cellspacing="0" class="dTable" id="dynamic">
								<thead>
									<tr>
										<th align="center" style="display:table-cell;vertical-align:middle" width="5%">S.No<span class="sorting" style="display: block;"></span></th>
										<th align="center" style="display:table-cell;vertical-align:middle" width="10%">Party Code</th>
										<th align="center" style="display:table-cell;vertical-align:middle" width="20%">Party Name</th>
										<th align="center" style="display:table-cell;vertical-align:middle" width="10%">Po No</th>
										<th align="center" style="display:table-cell;vertical-align:middle" width="10%">PO Date</th>
										<?php
										if($pg_id!=1)
										{
										?>
											<th align="center" style="display:table-cell;vertical-align:middle" width="10%">PO Fin Date</th>
											<?php
											if($pg_id==3)
											{
											?>
												<th align="center" style="display:table-cell;vertical-align:middle" width="10%">PO Del Date</th>
												<th align="center" style="display:table-cell;vertical-align:middle" width="15%">Bill No</th>
										<?php	
											}
										}
										?>
										<th align="center" style="display:table-cell;vertical-align:middle" width="10%">Cost</th>
										<th align="center" style="display:table-cell;vertical-align:middle" width="10%">Image</th>
									</tr>
								</thead>
								<tbody>
								<?php
									$QURY_PICE = mysqli_query($connect,$SLCT_PICE);
									$party_cst = 0;
									if(mysqli_num_rows($QURY_PICE)>0)
									{	
										$loop = 1;										
										while($FTCH_PICE = mysqli_fetch_object($QURY_PICE))	
										{		
											$SLCT_PARTY = "SELECT party_code,cmp_name,cost_val FROM party_det,party_cost_det WHERE party_det.`party_det_id` = '$FTCH_PICE->party_det_id' AND party_cost_det.party_det_id=party_det.party_det_id AND party_cost_det.updated='no' AND master_cat_id='$FTCH_DESIN->master_cat_id'";
											$QURY_PARTY = mysqli_query($connect,$SLCT_PARTY);
											$FTCH_PARTY = mysqli_fetch_object($QURY_PARTY);									
								?>
											<tr>
												<td align="center" style="display:table-cell;vertical-align:middle"><?php echo $loop; ?></td>
												<td align="center" style="display:table-cell;vertical-align:middle"><?php echo $FTCH_PARTY->party_code; ?></td>
						                        <td align="center" style="display:table-cell;vertical-align:middle"><?php echo $FTCH_PARTY->cmp_name; ?></td>
						                        <td align="center" style="display:table-cell;vertical-align:middle"><?php echo $FTCH_PICE->po_no; ?></td>
						                        <td align="center" style="display:table-cell;vertical-align:middle"><?php echo str_replace("-","/",$FTCH_PICE->po_date); ?></td>
						                        <?php
												if($pg_id!=1)
												{
													$SLCT_PO2 = "SELECT cut_die_fin_date FROM po_finish WHERE design_det_id='$des_id' AND po_entry_det_id='$FTCH_PICE->po_entry_det_id'";
													$QURY_PO2 = mysqli_query($connect,$SLCT_PO2);		
													$FTCH_PO2 = mysqli_fetch_object($QURY_PO2);
												?>
						                        	<td align="center" style="display:table-cell;vertical-align:middle"><?php echo str_replace("-","/",$FTCH_PO2->cut_die_fin_date); ?></td>
						                        	<?php
													if($pg_id==3)
													{
														$SLCT_PO3 = "SELECT delivery_date FROM po_delivery WHERE po_entry_id='$FTCH_PICE->po_entry_id'";
														$QURY_PO3 = mysqli_query($connect,$SLCT_PO3);		
														$FTCH_PO3 = mysqli_fetch_object($QURY_PO3);
														
														$SLCT_PO4 = "SELECT bill_no FROM billing_po_det,billing_det WHERE billing_po_det.po_entry_id='$FTCH_PICE->po_entry_id' AND billing_det.billing_det_id=billing_po_det.billing_det_id GROUP BY billing_det.billing_det_id";
														$QURY_PO4 = mysqli_query($connect,$SLCT_PO4);	
														if(mysqli_num_rows($QURY_PO4)>0)
														{															
															$FTCH_PO4 = mysqli_fetch_object($QURY_PO4);
															$bill_no = $FTCH_PO4->bill_no;
														}
														else
														{
															$bill_no = "---";
														}
													?>
								                        <td align="center" style="display:table-cell;vertical-align:middle"><?php echo str_replace("-","/",$FTCH_PO3->delivery_date); ?></td>
								                        <td align="center" style="display:table-cell;vertical-align:middle"><?php echo $bill_no; ?></td>
								                <?php	
													}
												}
												?>
												<td align="center" style="display:table-cell;vertical-align:middle"><?php echo $FTCH_PARTY->cost_val; ?></td>
						                        <td align="center" style="display:table-cell;vertical-align:middle">
						                        	<div class="body" align="center">
							                        	<a href="<?php echo $imag1; ?>" id="searchlink<?php echo $loop; ?>" onfocus="foc(this.id)" onblur="stnon(this.id)" title="<?php echo $FTCH_DESIN->master_cat_name." ".$FTCH_DESIN->design_no; ?>" class="lightbox" rel="group">
							                        		<img src="<?php echo $imag; ?>" width="60" height="60"/>
							                        	</a> 
						                        	</div>				                        	
						                        </td>
											</tr>
								<?php
											$party_cst = $party_cst + $FTCH_PARTY->cost_val;
											$loop++;
										}
									}
								?>
								</tbody>
							</table>
						</div>
					</div>	 
    				<input name="tot_cst" id="tot_cst" type="hidden" value="<?php echo number_format($party_cst,2); ?>" />
        		</fieldset>
     		</form>
        	<div class="fluid"><!-- Media table --></div>
    	</div>
    	<!-- Main content ends -->    
	</div>
	<script>
		function party_cst()
		{
			var tot_cst = document.getElementById("tot_cst").value.trim();
			document.getElementById("tot_qty").value = tot_cst;
		}
	</script>
	<!-- Content ends -->
	<?php /*?><?php include "header_footer/footer.php"; ?><?php */?>
</body>
</html>
