<?php
	include "db_connection/db_connection.php";
	include "config/config.php";
	
	if($_SESSION['admin_login_id'] == '')
	{
		echo "<script>window.location='index.php';</script>";
	}
?>
<!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 src="https://code.jquery.com/jquery-1.9.1.js"></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>
<!-- Shared on MafiaShare.net  --><!-- Shared on MafiaShare.net  --></head>

<body onload="document.getElementById('listpage').focus();">

<!-- 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="index.html">Dashboard</a></li>
                <li><a href="javascritp:">Design History</a></li>
            </ul>
        </div>        
        <?php include "menus/top_left_menu.php"; ?>  
    </div>
    
    <!-- Main content -->
    <div class="wrapper">
        <ul class="middleNavR">
            <li><a href="piece_loading_list.php?master_cat_id=<?php echo $_GET['mas_cat']; ?>" id="listpage" title="List Design" class="tipN"><img src="images/icons/middlenav/stats.png" alt="" /></a></li>
        </ul>
    	<?php
		$piece_id	=	base64_decode(base64_decode(base64_decode($_GET['piece_id']))); 
		$des_id	=	base64_decode(base64_decode(base64_decode($_GET['des_id']))); 
		$SLCT = "SELECT imag_ext,cad_fin_ext,mas_fin_ext,master_cat_name,design_no,master_pieces FROM piece_loading,master_cat,design_det WHERE piece_loading_id = '$piece_id' AND design_det.design_det_id=piece_loading.design_det_id AND piece_loading.master_cat_id=master_cat.master_cat_id ORDER BY piece_loading_id DESC";
		$QURY = mysqli_query($connect,$SLCT);
		$FTCH = mysqli_fetch_object($QURY);
		
		if($FTCH->mas_fin_ext!=''){ $img_lbl="Master Finish Image"; $imag = "../mas_fin_images/M.".$FTCH->mas_fin_ext; $imag1 = "../mas_fin_images/L.".$FTCH->mas_fin_ext; }

		else if($FTCH->cad_fin_ext!=''){ $img_lbl="Cad Finish Image"; $imag = "../cad_fin_images/M.".$FTCH->cad_fin_ext; $imag1 = "../cad_fin_images/L.".$FTCH->cad_fin_ext; }
		
		else if($FTCH->imag_ext!=''){ $img_lbl="Design Image"; $imag = "../design_images/M.".$FTCH->imag_ext; $imag1 = "../design_images/L.".$FTCH->imag_ext; }
		?>

        <div class="fluid" style="">
            <form id="validate" name="fm" class="main" method="post" action="" enctype="multipart/form-data">
                <fieldset>
                <input name="design_id" id="design_id" type="hidden" value="<?php echo $_GET['design_id']; ?>" />
                	<div class="widget">
                        <div class="whead"><h6>Piece Loading History</h6>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<h6>Design No&nbsp;&nbsp;:&nbsp;&nbsp;<?php echo $FTCH->master_cat_name. " / " . $FTCH->design_no ?></h6><h6>No of Masters&nbsp;&nbsp;:&nbsp;&nbsp;<?php echo $FTCH->master_pieces; ?></h6><div class="clear"></div></div>                                               
                        <div class="formRow">
                        	<table width="100%">
                            	<tr>
                                	<td width="100%" align="center" style="vertical-align:top;"><div style="height:210px"><img id="blah" name="" type="image" title="<?php $img_lbl; ?>" src="<?php echo $imag; ?>" </div></td>                                    
                             	</tr>
                         	</table>
                            <div class="clear"></div>
                        </div> 
                        <div class="clear"></div>
						<div class="whead"><h6>History List</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 cellpadding="0" width="100%" cellspacing="0" border="0" class="dTable" id="dynamic">
								<thead>
								<tr>
									<th width="8%">S.No<span class="sorting" style="display: block;"></span></th>
									<th width="12%">Loading Type</th>
									<th width="10%">PO No</th>
									<th width="22%">Party Code</th>
									<th width="12%">Loading Dt</th>
									<th width="12%">Finishing Dt</th>
									<th width="12%">Cancel Dt</th>
									<th width="12%">Cancel Type</th>
									</tr>
								</thead>
								<tbody>
        						<?php
        						    //echo
									$SLCT = "SELECT * FROM piece_loading_history WHERE design_det_id='$des_id' ORDER BY piece_loading_history_id DESC";
									//echo "<br>";
									$QURY = mysqli_query($connect,$SLCT);
									$loop=1;
									if(mysqli_num_rows($QURY)>0)
									{			
										while($FTCH = mysqli_fetch_object($QURY))
										{
											if($FTCH->loading_type=='PO')
											{
												//echo 
												$SLCT_HIS2 = "SELECT po_no,party_code,cmp_name FROM po_entry,party_det WHERE po_entry_id='$FTCH->po_entry_id' AND po_entry.party_det_id=party_det.party_det_id";
												//echo "<br>";
												$QURY_HIS2 = mysqli_query($connect,$SLCT_HIS2);
												$FTCH_HIS2 = mysqli_fetch_object($QURY_HIS2);
												
												$pcs_type = "PO";
												$po_num = $FTCH_HIS2->po_no;
												if($admin_flagg==1)
				                                {                                
				                                	$party_nm = $FTCH_HIS2->party_code." - ".$FTCH_HIS2->cmp_name;
				                                }
				                                else 
				                                {
				                                	$party_nm = $FTCH_HIS2->party_code;
				                                }												
											}
											else
											{
												$pcs_type = "Stock";
												$party_nm = "--";
												$po_num	  = "--";	
											}
											
											if($loop%2 != "0")
												$bg = "gradeX";
											else
												$bg = "class='gradeC'";
								?>
								            <tr <?php echo $bg ?>>
									            <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 $pcs_type; ?></td>
									            <td align="center" style="display:table-cell;vertical-align:middle"><?php echo $po_num; ?></td>
									            <td align="center" style="display:table-cell;vertical-align:middle"><?php echo $party_nm; ?></td>
									            <td align="center" style="display:table-cell;vertical-align:middle"><?php echo str_replace("-","/",$FTCH->loading_dt); ?></td>
									            <td align="center" style="display:table-cell;vertical-align:middle"><?php if($FTCH->finish_dt!=''){ echo str_replace("-","/",$FTCH->finish_dt); }else{ echo "--"; } ?></td>
									            <td align="center" style="display:table-cell;vertical-align:middle"><?php if($FTCH->cancel_dt!=''){ echo str_replace("-","/",$FTCH->cancel_dt); }else{ echo "--"; } ?></td>
									            <td align="center" style="display:table-cell;vertical-align:middle"><?php if($FTCH->cancel_type!=''){ echo $FTCH->cancel_type; }else{ echo "--"; } ?></td>
								            </tr>
        						<?php
											$loop ++;
		 								}
		 							}
								?>
        						</tbody>
        					</table> 
    					</div>
    				</div>
                </fieldset>
            </form>
        </div>
    </div>
</div>        
</body>
</html>