<?php
	include "db_connection/db_connection.php";
	include "config/config.php";
	//ini_set('max_execution_time', 1800);
	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 type="text/javascript" src="js/po_multi_fin_add_JS.js"></script>
<script type="text/javascript" src="js/cnt_chkbox_JS.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.dataTables1.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();">
	<!-- 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="home.php">Dashboard</a></li>
                    <li><a href="javascript:">Multiple Purchase Order Finishing</a></li>
                        
                </ul>
            </div>
			<?php include "menus/top_left_menu.php"; ?>
  		</div>
    	<!-- Main content -->
    	<div class="wrapper">
            <ul class="middleNavR">
                <!--<li><a href="#" title="Add an article" class="tipN"><img src="images/icons/middlenav/create.png" alt="" /></a></li>
                <li><a href="#" title="Upload files" class="tipN"><img src="images/icons/middlenav/upload.png" alt="" /></a></li>-->  
              	<!--<li><a href="design_add.php" title="Add Design" class="tipN"><img src="images/icons/middlenav/add.png" alt="" /></a></li>-->
                <!--<li><a href="#" title="Messages" class="tipN"><img src="images/icons/middlenav/dialogs.png" alt="" /></a><strong>8</strong></li>-->
                <li><a href="po_finishing_list.php" id="listpage" title="List Purchase Order Finishing" class="tipN"><img src="images/icons/middlenav/stats.png" alt="" /></a></li>
            </ul>            
			<?php
				$pg_id= base64_decode(base64_decode(base64_decode(base64_decode($_GET['page_no']))));
				$po_id= base64_decode(base64_decode(base64_decode($_GET['po_id'])));
				$page_id= base64_encode(base64_encode(base64_encode(2))); //THIS IS FOR PAGE IDENTIFICATION IN BL FILE for add		 
						 
            ?>
    		<!-- Chart --><!-- 6 + 6 -->
        	<form id="validate" name="check_list" class="main" method="post" action="bl/po_finishing_BL.php?pg_id=<?php echo $page_id; ?>" onsubmit="checkTheBox();">
        		<fieldset>
        			<div class="fluid">
            			<div class="widget">
                			<div class="formRow">
                            <?php
								$SLCT_po = "SELECT * FROM po_entry WHERE po_entry_id ='$po_id'";
								//echo $SLCT_po;
								$QURY_po = mysqli_query($connect,$SLCT_po);
								$FTCH_po = mysqli_fetch_object($QURY_po);
								
								$SLCT_tp = "SELECT * FROM party_det WHERE party_det_id = '$FTCH_po->party_det_id'";
								$QURY_tp = mysqli_query($connect,$SLCT_tp);
								$FTCH_tp = mysqli_fetch_object($QURY_tp);
							?>
                    			<div class="grid2"><label>PO No:<span class="req"></span></label></div>
                    			<div class="grid4">
                    			<input type="hidden" name="po_no" id="po_no" value="<?php echo $po_id; ?>" readonly="readonly"/>
                                <input type="hidden" name="po_n" id="po_n" value="<?php echo $FTCH_po->po_no; ?>" readonly="readonly"/>
                                <?php 
                                	if($admin_flagg==1)
	                                {                                
	                                	echo $FTCH_po->po_no." / ".$FTCH_tp->party_code." - ".$FTCH_tp->cmp_name; 
	                                }
	                                else 
	                                {
	                                	echo $FTCH_po->po_no." / ".$FTCH_tp->party_code;
	                                }
                                ?>
                                </div><div class="clear"></div>
                			</div>
                            
                            <input type="hidden" name="pagg_id" id="pagg_id" value="<?php echo $pg_id; ?>" />
                            <?php
							if($pg_id ==1)
							{
							?>
                            <input type="hidden" name="fin_type" id="fin_type_0" value="mul_fin" />
                            <div class="formRow">
                                <div class="grid2"><label>Packer Name:<span class="req">*</span></label></div>
                                <div class="grid4 searchDrop">
                                    <select data-placeholder="Choose an Employee..." class="select" name="pack_name" id="pack_name" style="width:350px;">
                                        <option value=""></option>
                                        <?php
											$SLCT_E = "SELECT * FROM emp_det WHERE master_dept_id REGEXP(CONCAT('(^|,)(',7,')(,|$)')) and statu_s='active'"; //HERE THE 7 IS REPRESENTS Packer ID 
											//echo $SLCT;
											$QURY_E = mysqli_query($connect,$SLCT_E);
											while($FTCH_E = mysqli_fetch_object($QURY_E))
											{
                                        ?>
                                       			<option value="<?php echo $FTCH_E->emp_det_id ?>"><?php echo $FTCH_E->name ?></option>
                                        <?php
                                        	}
                                        ?>                                    
                                    </select>
                                </div>
                                <div class="grid2"><label>Packing Date:<span class="req"></span></label></div>
                                <div class="grid4"><input type="text" value="" name="cut_dt" id="cut_dt" class="datepicker"/></div>
                                <div class="clear"></div>
                            </div>
                            
                            <div class="formRow">
                                <div class="grid2"><label>Cutter Name:<span class="req">*</span></label></div>
                                <div class="grid4 searchDrop">
                                    <select data-placeholder="Choose an Employee..." class="select"  name="cut_name" id="cut_name" style="width:350px;" tabindex="2">
                                        <option value=""></option>
                                        <?php
											$SLCT_E = "SELECT * FROM emp_det WHERE master_dept_id REGEXP(CONCAT('(^|,)(',8,')(,|$)')) and statu_s='active'"; //HERE THE 8 IS REPRESENTS cutter  ID 
											//echo $SLCT;
											$QURY_E = mysqli_query($connect,$SLCT_E);
											while($FTCH_E = mysqli_fetch_object($QURY_E))
											{
                                        ?>
                                        		<option value="<?php echo $FTCH_E->emp_det_id ?>"><?php echo $FTCH_E->name ?></option>
                                        <?php
                                        	}
                                        ?>
                                    </select>
                                </div>
                                <div class="grid2"><label>Cutting Date:<span class="req"></span></label></div>
                                <div class="grid4"><input type="text" value="" name="fin_dt" id="fin_dt" class="datepicker"/></div>
                                <div class="clear"></div>
                            </div>
                            <!--<div class="formRow">
                                <div class="grid2"><label>Finishing Date:<span class="req"></span></label></div>
                                <div class="grid4"><input type="text" value="" name="fin_dt" id="fin_dt" class="datepicker"/></div>
                            	<div class="grid2"><label>Cutting Date:<span class="req"></span></label></div>
                                <div class="grid4"><input type="text" value="" name="cut_dt" id="cut_dt" class="datepicker"/></div><div class="clear"></div>
                            </div>-->
                        </div>
                    </div>
                  
    	
        			<div class="widget"> <!--style="width:600px; margin-left:150px;"-->
        				<div class="whead"><span class="titleIcon check"><input type="checkbox" id="titleCheck" name="titleCheck" onclick="ckall()" onfocus="foc(this.id)" onblur="stnon(this.id)"/></span><h6>Multiple Finish</h6><h6 style="float:right; margin-right:50px;"><input type="text" id="cnt_chk" name="cnt_chk" value="" readonly="readonly" disabled="disabled" style="width:50px; 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>
                            <div style="max-height:700px; overflow-y:auto;">
                            <table cellpadding="0" width="100%" cellspacing="0" border="0" class="dTable check" id="checkAll">
                                <thead>
                                    <tr>
                                        <td width="5%"><img src="images/elements/other/tableArrows.png" alt="" /></td>
                                        <th width="10%">S.No<span class="sorting" style="display: block;"></span></th>
                                        <th width="10%">Design No</th>
                                        <th width="15%">No of Dies</th>
                                        <th width="15%">Image</th>
                                        <th width="50%">PO No</th>   
                                    </tr>
                                </thead>
                                <tbody>
                                
                                <?php
                                	$SLCT_SAM = "SELECT `design_det_id` FROM `piece_loading` WHERE `po_entry_id` = '".$po_id."' AND `piece_status` = 'loading' ORDER BY design_det_id ASC";
									$QURY_SAM = mysqli_query($connect,$SLCT_SAM);
									if(mysqli_num_rows($QURY_SAM)>0)
									{
										while($FTCH_SAM = mysqli_fetch_object($QURY_SAM))
										{
		                                	$SLCT_TST = "SELECT GROUP_CONCAT(po.`po_entry_id`) AS `po_entry_id`,GROUP_CONCAT(po.`po_no`) AS `po_no`,GROUP_CONCAT(po.`party_det_id`) AS `party_det_id`,GROUP_CONCAT(pod.`po_entry_det_id`) AS `po_entry_det_id`,pod.`design_det_id` FROM `po_entry` AS po,`po_entry_det` AS pod WHERE pod.`po_entry_id` = po.`po_entry_id` AND pod.`fin_status`='no' AND pod.`cancelled`='no' AND po.`po_entry_id`!='".$po_id."' AND pod.`design_det_id` = '$FTCH_SAM->design_det_id'";
											$QURY_TST = mysqli_query($connect,$SLCT_TST) or die("mySQL error: ". mysql_error());									
											$FTCH_TST = mysql_fetch_assoc($QURY_TST);
											
											$img_id = $FTCH_TST['design_det_id'];
											$sliderImags[$img_id] = $FTCH_TST;
										}
									}
									$loop=1;
                                    $SLCT_t = "SELECT * FROM po_entry_det WHERE `po_entry_id` = '$po_id' AND `fin_status` = 'no' AND `cancelled` = 'no' ORDER BY `master_cat_id`,`design_det_id` ASC "; 
                                    // LIMIT 0, 1500
                                    //die();
                                    //echo $SLCT_t."<br>";
                                    $QURY_t = mysqli_query($connect,$SLCT_t) or die("mySQL error: ". mysql_error());	
                                    if(mysqli_num_rows($QURY_t)>0)
                                    {
                                        while($FTCH_t = mysqli_fetch_object($QURY_t))
                                        {
                                        	$SLCT_CONT = "SELECT `design_det_id` FROM piece_loading WHERE `piece_status` = 'loading' AND `po_entry_id` = '$po_id' AND design_det_id = '$FTCH_t->design_det_id'";	
											//echo $SLCT_CONT."<br>";
											$QURY_CONT = mysqli_query($connect,$SLCT_CONT);
											if(mysqli_num_rows($QURY_CONT)>0)
											{												
											$SLCT_d = "SELECT  * FROM master_cat WHERE master_cat_id = '$FTCH_t->master_cat_id'";
											$QURY_d = mysqli_query($connect,$SLCT_d);
											$FTCH_d = mysqli_fetch_object($QURY_d);
											
											$SLCT_dt = "SELECT * FROM design_det WHERE design_det_id = '$FTCH_t->design_det_id'"; 
											$QURY_dt = mysqli_query($connect,$SLCT_dt);
											$FTCH_dt = mysqli_fetch_object($QURY_dt);
											
											if($loop%2 != "0")
												$bg = "gradeX";
											else
												$bg = "class='gradeC'";
											 if($FTCH_dt->mas_fin_ext!=''){ $imag = "../mas_fin_images/S.".$FTCH_dt->mas_fin_ext; $imag1 = "../mas_fin_images/L.".$FTCH_dt->mas_fin_ext;}
				
											else if($FTCH_dt->cad_fin_ext!=''){ $imag = "../cad_fin_images/S.".$FTCH_dt->cad_fin_ext; $imag1 = "../cad_fin_images/L.".$FTCH_dt->cad_fin_ext; }
											
											else if($FTCH_dt->imag_ext!=''){ $imag = "../design_images/S.".$FTCH_dt->imag_ext; $imag1 = "../design_images/L.".$FTCH_dt->imag_ext; }
                                ?>
                                            <tr <?php echo $bg ?>>
                                            	<td style="display:table-cell;vertical-align:middle;"><input type="checkbox" name="category[]" id="category<?php echo $loop ?>" onclick="cnt_chk_fn(<?php echo $loop ?>);" value="<?php echo $FTCH_t->design_det_id .",".$FTCH_t->po_entry_det_id?>" onfocus="foc(this.id)" onblur="stnon(this.id)"/></td>
                                                <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_d->master_cat_name." ".$FTCH_dt->design_no; ?></td>
                                                <td align="center" style="display:table-cell;vertical-align:middle"><?php echo $FTCH_dt->master_pieces; ?></td>
                                                <td class="center" align="center"><div class="body" align="center">
                								<a href="<?php echo $imag1; ?>" class="lightbox" rel="group" title="<?php echo $FTCH_d->master_cat_name." ".$FTCH_dt->design_no; ?>"><img src="<?php echo $imag; ?>" width="60" height="60"/></a></div></td>                            
                                           		<td align="left" style="display:table-cell;vertical-align:middle">
                                       			<?php
													$x=0;
													if(isset($sliderImags[$FTCH_t->design_det_id]))
													{
														//echo $po_entry_id_samp = $sliderImags[$FTCH_t->design_det_id]['po_entry_id'];
														$po_samp = explode(",",$sliderImags[$FTCH_t->design_det_id]['po_entry_id']);
														$part_samp = explode(",",$sliderImags[$FTCH_t->design_det_id]['party_det_id']);
														$num_samp = explode(",",$sliderImags[$FTCH_t->design_det_id]['po_no']);
														$ent_samp = explode(",",$sliderImags[$FTCH_t->design_det_id]['po_entry_det_id']);
														$max_rows  = count($po_samp);
														if($max_rows>3)
														{
															$height = 'style="height:80px; overflow-x: hidden; overflow-y: scroll;"';
														}
														else
														{
															$height = '';
														}
												?>
														<div <?php echo $height ?>;>
												   		<?php                                               			
															for($i1=0;$i1<$max_rows;$i1++)
															{	
																$party_id = $part_samp[$i1];
																$po_ent_id = $po_samp[$i1];
																$po_num = $num_samp[$i1];
																$po_en_id = $ent_samp[$i1];
																
																$SLCT_tp1 = "SELECT * FROM party_det WHERE party_det_id = '$party_id'";
																$QURY_tp1 = mysqli_query($connect,$SLCT_tp1);
																$FTCH_tp1 = mysqli_fetch_object($QURY_tp1);
																$po_no = $po_num." / ".$FTCH_tp1->party_code; 
												        
												        		if($x==$max_rows-1)
												                {										
												        ?>		
												                    <span width="33%" style="display:table-cell;vertical-align:top">
												                    	<input type="radio" name="po_num_<?php echo $FTCH_t->design_det_id; ?>" id="po_num_<?php echo $FTCH_t->design_det_id."_".$x; ?>" value="<?php echo $FTCH_t->master_cat_id.",".$po_ent_id.",".$party_id.",".$po_en_id.",".$po_no; ?>"/>&nbsp;&nbsp;<label for="po_num_<?php echo $FTCH_t->design_det_id."_".$x; ?>"><?php echo $po_no;?></label>&nbsp;&nbsp;
												                 	</span><br />
												        <?php
												                }
												                else if($x%3==2)
												                {
												        ?>
												                   	<span width="33%" style="display:table-cell;vertical-align:top">
												                   		<input type="radio" name="po_num_<?php echo $FTCH_t->design_det_id; ?>" id="po_num_<?php echo $FTCH_t->design_det_id."_".$x; ?>" value="<?php echo $FTCH_t->master_cat_id.",".$po_ent_id.",".$party_id.",".$po_en_id.",".$po_no; ?>"/>&nbsp;&nbsp;<label for="po_num_<?php echo $FTCH_t->design_det_id."_".$x; ?>"><?php echo $po_no;?></label>&nbsp;&nbsp;
												                 	</span><br />
												        <?php
												                }
												                else
												                {
												        ?>
												                   <span width="33%" style="display:table-cell;vertical-align:top">
												                   		<input type="radio" name="po_num_<?php echo $FTCH_t->design_det_id; ?>" id="po_num_<?php echo $FTCH_t->design_det_id."_".$x; ?>" value="<?php echo $FTCH_t->master_cat_id.",".$po_ent_id.",".$party_id.",".$po_en_id.",".$po_no; ?>"/>&nbsp;&nbsp;<label for="po_num_<?php echo $FTCH_t->design_det_id."_".$x; ?>"><?php echo $po_no;?></label>&nbsp;&nbsp;
												                   </span>                                           
												        <?php
												                }
												                $x++;
												        	}
												   		?>  
												   		</div>
												   		<input type="hidden" name="po_chk_<?php echo $FTCH_t->design_det_id; ?>" id="po_chk_<?php echo $FTCH_t->design_det_id; ?>" value="1"/>	
												<?php
												 	}
												 	else
												 	{
														echo "--";	
												?>
														<input type="hidden" name="po_chk_<?php echo $FTCH_t->design_det_id; ?>" id="po_chk_<?php echo $FTCH_t->design_det_id; ?>" value="2"/>	
												<?php
													}
												?>	
                                               	</td>
                                            </tr>
        
                                <?php
                                            $loop ++;
                                        }
                                        }
                                    }
                                ?>
                                </tbody>
                            </table> 
                            </div>
                        </div>
                    </div>
                    <?php
							}
							else
							{
							
						?>
                        
                            <input type="hidden" name="fin_type" id="fin_type_1" value="fin_frm_sto" />
                    <div class="widget"> <!--style="width:600px; margin-left:150px;"-->
        				
                     <div class="whead"><span class="titleIcon check"><input type="checkbox" id="titleCheck" name="titleCheck" onclick="ckall()" onfocus="foc(this.id)" onblur="stnon(this.id)"/></span><h6>Stock To Order Finish</h6><h6 style="float:right; margin-right:50px;"><input type="text" id="cnt_chk" name="cnt_chk" value="" readonly="readonly" disabled="disabled" style="width:50px; 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>
                        <div style="max-height:700px; overflow-y:auto;">
                        <table width="793" border="0" cellpadding="0" cellspacing="0" class="dTable check" id="checkAll">
                                <thead>
                                    <tr>
                                        <td width="20"><img src="images/elements/other/tableArrows.png" alt="" /></td>
                                        <th width="26">S.No<span class="sorting" style="display: block;"></span></th>
                                        <th width="95">Design No</th>
                                        <th width="15%">No of Masters</th>
                                        <th width="78">Image</th>  
                                    </tr>
                                </thead>
                                <tbody>
                                <?php
                                    $loop=1;
                                    $SLCT_t = "SELECT  * FROM po_entry_det WHERE po_entry_id = '$po_id' AND fin_status = 'no' AND cancelled = 'no' ORDER BY design_det_id ASC";
                                   // echo $SLCT_t;
                                    $QURY_t = mysqli_query($connect,$SLCT_t);
                                    if(mysqli_num_rows($QURY_t)>0)
                                    {
										while($FTCH_t = mysqli_fetch_object($QURY_t))
                                        {        
											$SLCT_d = "SELECT  * FROM master_cat WHERE master_cat_id = '$FTCH_t->master_cat_id'";
											$QURY_d = mysqli_query($connect,$SLCT_d);
											$FTCH_d = mysqli_fetch_object($QURY_d);
											
											$SLCT_st = "SELECT * FROM stock_det WHERE design_det_id = '$FTCH_t->design_det_id' AND st_fin_status='no'"; 
											//echo $SLCT_st;
											$QURY_st = mysqli_query($connect,$SLCT_st);
											if(mysqli_num_rows($QURY_st)>0)
											{
												$FTCH_st = mysqli_fetch_object($QURY_st);
												
												$SLCT_dt = "SELECT * FROM design_det WHERE design_det_id = '$FTCH_st->design_det_id'"; 
												$QURY_dt = mysqli_query($connect,$SLCT_dt);
												$FTCH_dt = mysqli_fetch_object($QURY_dt);
																																
												if($loop%2 != "0")
													$bg = "gradeX";
												else
													$bg = "class='gradeC'";
												 if($FTCH_dt->mas_fin_ext!=''){ $imag = "../mas_fin_images/S.".$FTCH_dt->mas_fin_ext; $imag1 = "../mas_fin_images/L.".$FTCH_dt->mas_fin_ext; }
					
												else if($FTCH_dt->cad_fin_ext!=''){ $imag = "../cad_fin_images/S.".$FTCH_dt->cad_fin_ext; $imag1 = "../cad_fin_images/L.".$FTCH_dt->cad_fin_ext; }
												 
												else if($FTCH_dt->imag_ext!=''){ $imag = "../design_images/S.".$FTCH_dt->imag_ext;  $imag1 = "../design_images/L.".$FTCH_dt->imag_ext; }
                                ?>
                                                <tr <?php echo $bg ?>>
                                                    <td style="display:table-cell;vertical-align:middle;"><input type="checkbox" name="category[]" id="category<?php echo $loop ?>"  value="<?php echo $FTCH_t->design_det_id .",".$FTCH_t->po_entry_det_id.",".$FTCH_st->stock_det_id.",".$FTCH_st->pack_emp_id.",".$FTCH_st->cut_emp_id.",".$FTCH_st->die_fin_date.",".$FTCH_st->cut_die_fin_date ?>" onchange="cnt_chk_fn(<?php echo $loop ?>);" onfocus="foc(this.id)" onblur="stnon(this.id)"/></td>
                                                    <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_d->master_cat_name." ".$FTCH_dt->design_no; ?></td>
                                                    <td align="center" style="display:table-cell;vertical-align:middle"><?php echo $FTCH_dt->master_pieces; ?></td>
                                                    <td class="center" align="center"><div class="body" align="center">
                									<a href="<?php echo $imag1; ?>" class="lightbox" title="<?php echo $FTCH_d->master_cat_name." ".$FTCH_dt->design_no; ?>" rel="group"><img src="<?php echo $imag; ?>" width="60" height="60"/></a></div></td>                            
                                               		
                                                </tr>
        
                                <?php
                                         		$loop ++;
											}
                                        }
                                    }
                                ?>
                                </tbody>
                            </table>
                            </div> 
                        </div>
                    </div>
                    <?php
							}
					?>
                    <div class="fluid">
                        <div class="widget">
                            <div class="formRow">
                                <input type="button" value="Submit" class="buttonM bBlack formSubmit" onclick="checkTheBox();" style="float: right; margin-left:20px;"/>
                                <input type="button" value="Reset" class="buttonM bRed" style="float: right; margin-left:20px;" onclick="form_rest();"/>
                                <div class="clear"></div>
                            </div>
                        </div>
                    </div>
                </fieldset>
            </form>
            <div class="fluid"><!-- Media table --></div>
        </div>
        <!-- Main content ends -->
    </div>
    <!-- Content ends -->
    <?php /*?><?php include "header_footer/footer.php"; ?><?php */?>
</body>
</html>
