<?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';
	}
	
	$check_acc  = check_access('48');
?>
<!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/stock_analize_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.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="tot_count();">

<!-- 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</a></li>
                <li><a href="javascript:">New Design Entry</a></li>
                    
            </ul>
        </div>
	<?php include "menus/top_left_menu.php"; ?>            
        
    </div>
    
    <!-- Main content -->
    <div class="wrapper">
    <?php if($check_acc==1){?>
    	   <?php
		   $flag = 0;
		   $sta_iden = '0';
		   // THIS IS FOR CHECKING THE STAGE NAME
				if(isset($_GET['sta_name']) && $_GET['sta_name']!='' ) 
				{
					$mas_stage_id = $_GET['sta_name'];
					$mas_stage_id1 =	base64_decode(base64_decode(base64_decode($_GET['sta_name']))); // this is for getting the value from url
				}
				else
				{
					$mas_stage_id = '';
				}

				$emp_qur_str = '';
				//THIS IS FOR CHECKING THE EMPLOYEE NAME
				if(isset($_GET['em_name']) && $_GET['em_name']!='' )
				{
					$emp_id_url = $_GET['em_name'];
					$emp_id_dec = base64_decode(base64_decode(base64_decode($_GET['em_name'])));  
					$emp_qur_str = "AND emp_det_id='$emp_id_dec'";
				}
				else
				{
					$emp_id_url = '';
					$emp_qur_str = '';
				}

				if(isset($_GET['fdate']) && $_GET['fdate']!='' ){ $fdate = $_GET['fdate'];	}else{ $fdate = ''; }
				//echo $fdate;
				if(isset($_GET['todate']) && $_GET['todate']!='' ){ $todate = $_GET['todate'];	}else{ $todate = ''; }

				if(isset($_GET['yea_r']) && $_GET['yea_r']!='' ){ $yea_r = 'checked="checked"';	}else{ $yea_r = ''; }
				if(isset($_GET['mont_h']) && $_GET['mont_h']!='' ){ $mont_h = 'checked="checked"';	}else{ $mont_h = ''; }
				if(isset($_GET['da_y']) && $_GET['da_y']!='' ){ $da_y = 'checked="checked"';	}else{ $da_y = ''; }

				$i=0;
				$SLCTsc = "SELECT COUNT(`design_det_id`) as des_cnt FROM `stock_det` WHERE st_fin_status='no' GROUP BY `design_det_id`";
				$QURYsc = mysqli_query($connect,$SLCTsc);
				while($FTCHsc = mysqli_fetch_object($QURYsc))
				{
					if($i==0)
					{
						$cont_array[$i]=0;
					}
					else
					{
						$cont_array[$i]=$FTCHsc->des_cnt;
					}
					$i++;
				}
				$cont_array1 = array_unique($cont_array);
				sort($cont_array1);

		?>

        <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="design_add.php" title="Add Design" id="addpage" class="tipN"><img src="images/icons/middlenav/add.png" alt="" /></a></li>-->
           <?php /*?><li><a href="design_cat_add.php?id=<?php echo base64_encode(base64_encode(base64_encode(2)));?>" title="Add Cad Finishing Design" class="tipN"><img src="images/icons/middlenav/upload.png" alt="" /></a></li>   <?php */?>         
          <?php /*?> <li><a href="design_cat_add.php?id=<?php echo base64_encode(base64_encode(base64_encode(1)));?>" title="Add Master Finishing Design" class="tipN"><img src="images/icons/middlenav/upload_color.png" alt="" /></a></li><?php */?>
           <!--<li><a href="#" title="Check statistics" class="tipN"><img src="images/icons/middlenav/stats.png" alt="" /></a></li>-->
    	</ul>
    		<form>

            <fieldset>
    		<div class="widget">
                			<div class="formRow" >
							<table width="100%">
								<tr>
									<td width="25%" style="display:table-cell; vertical-align:top;">Select Qty :</td>
									<td width="75%">
                            		<div class="searchDrop">
                               		 <select  data-placeholder="" class="select" name="sta_name" id="sta_name" style="width:350px;" onchange="reload_page()" onfocus="foc(this.id)" onblur="stnon(this.id)">
                                   		 <option selected="selected" value="">Choose a Qty...</option>
                                   			 <?php
												foreach($cont_array1 as $vl)
												{
												$ma_st_id = base64_encode(base64_encode(base64_encode($vl)));	
											?>
                                            <option <?php if($ma_st_id == $mas_stage_id){ ?> selected="selected" <?php }?> value="<?php echo $ma_st_id ?>"><?php echo $vl; ?></option>
                                            <?php
                                            	}
                                            ?>

                                </select>

                            </div> 
							</td>
							</tr>
							</table>
							</div>
				<?php if(isset($_GET['sta_name'])){ ?> 
					<input name="flag_js" id="flag_js" type="hidden" value="<?php echo $sta_iden; ?>" /> <!--THIS IS FOR JS FUNCTIONALITY-->

							<?php if($flag==1){ ?>

							<input name="emp_lable" id="emp_lable" type="hidden" value="<?php echo $FTCHs->emp_lable; ?>" /> <!--THIS IS FOR JS EMPLOYEE LABLE-->
							<div class="formRow" >
							<table width="100%">
								<tr>
									<td width="25%" style="display:table-cell; vertical-align:top;"><?php echo $empl_name; ?>:</td>
									<td width="75%">
                            		<div class="searchDrop">
                               		 <select  data-placeholder="" class="select" name="em_name" id="em_name" style="width:350px;" >
                                   		 <option selected="selected" value="">Choose a Stage...</option>
                                   			 <?php
												$SLCTse = "SELECT * FROM emp_det WHERE master_dept_id ='$FTCHs->master_dept_id'";
												$QURYse = mysqli_query($connect,$SLCTse);
												while($FTCHse = mysqli_fetch_object($QURYse))
												{
													$emp_id = base64_encode(base64_encode(base64_encode($FTCHse->emp_det_id)));	
											?>
                                            <option <?php if($emp_id_url == $emp_id){ ?> selected="selected" <?php }?>  value="<?php echo $emp_id ?>"><?php echo $FTCHse->name; ?></option>
                                            <?php
                                            	}
                                            ?>

                                </select>

                            </div> 
							</td>
							</tr>
							</table>
							</div>
							<?php } ?>

							<div class="formRow" >
							<table width="100%">
								<tr>
									<td width="9%" style="display:table-cell; vertical-align:top;">From Date:</td>
									<td width="22%"><div class="grid6"><input type="text" name="fdate" id="fdate" value="<?php echo $fdate ?>" class="datepicker" /></div></td>
							        <td width="9%" style="display:table-cell; vertical-align:top;">To Date:</td>
							        <td width="23%"><div class="grid6"><input type="text" name="todate" id="todate" value="<?php echo $todate ?>" class="datepicker" /></div></td>
							        <td width="10%" style="display:table-cell; vertical-align:top;">Filter:</td>
							        <td width="8%"><input id="yea_r"  name="filter" type="checkbox" value="y" <?php echo $yea_r ?> /> <label for="yea_r">Year</label></td>
							        <td width="8%"><input id="mont_h" name="filter2" type="checkbox" value="m" <?php echo $mont_h ?> /> <label for="mont_h">Month</label></td>
							        <td width="11%"><input id="da_y" name="filter3" type="checkbox" value="d" <?php echo $da_y ?> /> <label for="da_y">Day</label></td>
							  </tr>
							</table>
							</div>

							 <div class="formRow">
           						<input type="button" value="Submit" class="buttonM bBlack formSubmit" onclick="fom_validate();" 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>

							<?php } ?>

                        <div class="clear"></div>
                    </div> 

    	<!-- Chart --><!-- 6 + 6 -->
		<?php if(isset($_GET['fdate']) && $_GET['fdate']!='' || isset($_GET['todate']) && $_GET['todate']!=''){ ?>
		
		 <?php
			$design_date = ''; // THIS IS FOR ASIGNING THE COLUMN NAME DYNAMICALLY

			if($mas_stage_id1==1){ $design_date = "design_date";  }else if($mas_stage_id1==2){ $design_date = "loading_date"; }else if($mas_stage_id1==3){ $design_date = "finishing_date"; }else if($mas_stage_id1==4){ $design_date = "loading_date"; }else if($mas_stage_id1==5){ $design_date = "finishing_date"; }else if($mas_stage_id1==6){ $design_date = "loading_date"; }else if($mas_stage_id1==7){ $design_date = "finishing_date"; }else if($mas_stage_id1==8){ $design_date = "finishing_date"; }else if($mas_stage_id1==9){ $design_date = "finishing_date"; }else if($mas_stage_id1==10){ $design_date = "finishing_date"; }else if($mas_stage_id1==11){ $design_date = "finishing_date"; }else if($mas_stage_id1==12){ $design_date = "finishing_date"; }
			
			$dat_str = ''; //THIS IS FOR QUERY STRING
						
			if($fdate!='' && $todate!='')
			{
				if($yea_r!='' && $mont_h!='' && $da_y!=''){ $dat_str = "STR_TO_DATE(".$design_date.",'%d-%m-%Y') BETWEEN STR_TO_DATE('$fdate','%d/%m/%Y') AND STR_TO_DATE('$todate','%d/%m/%Y')"; }
				
				if($yea_r!='' && $mont_h!='' && $da_y==''){ $dat_str = "DATE_FORMAT(STR_TO_DATE(".$design_date.",'%d-%m-%Y'),'%m-%Y') BETWEEN DATE_FORMAT(STR_TO_DATE('$fdate','%d/%m/%Y'),'%m-%Y') AND DATE_FORMAT(STR_TO_DATE('$todate','%d/%m/%Y'),'%m-%Y')"; }
				
				if($yea_r!='' && $mont_h=='' && $da_y==''){ $dat_str = "YEAR(STR_TO_DATE(".$design_date.",'%d-%m-%Y')) BETWEEN YEAR(STR_TO_DATE('$fdate','%d/%m/%Y')) AND YEAR(STR_TO_DATE('$todate','%d/%m/%Y'))"; }
				
				if($yea_r=='' && $mont_h=='' && $da_y==''){ $dat_str = "STR_TO_DATE(".$design_date.",'%d-%m-%Y') BETWEEN STR_TO_DATE('$fdate','%d/%m/%Y') AND STR_TO_DATE('$todate','%d/%m/%Y')"; }
				
				if($yea_r=='' && $mont_h!='' && $da_y==''){ $dat_str = "DATE_FORMAT(STR_TO_DATE(".$design_date.",'%d-%m-%Y'),'%m-%Y') BETWEEN DATE_FORMAT(STR_TO_DATE('$fdate','%d/%m/%Y'),'%m-%Y') AND DATE_FORMAT(STR_TO_DATE('$todate','%d/%m/%Y'),'%m-%Y')"; }
				
				if($yea_r=='' && $mont_h=='' && $da_y!=''){ $dat_str = "STR_TO_DATE(".$design_date.",'%d-%m-%Y') BETWEEN STR_TO_DATE('$fdate','%d/%m/%Y') AND STR_TO_DATE('$todate','%d/%m/%Y')"; }
				
				if($yea_r!='' && $mont_h=='' && $da_y!=''){ $dat_str = "STR_TO_DATE(".$design_date.",'%d-%m-%Y') BETWEEN STR_TO_DATE('$fdate','%d/%m/%Y') AND STR_TO_DATE('$todate','%d/%m/%Y')"; }
				
				if($yea_r=='' && $mont_h!='' && $da_y!=''){ $dat_str = "STR_TO_DATE(".$design_date.",'%d-%m-%Y') BETWEEN STR_TO_DATE('$fdate','%d/%m/%Y') AND STR_TO_DATE('$todate','%d/%m/%Y')"; }
				
			}
			else if($fdate=='' && $todate!='')
			{
				if($yea_r!='' && $mont_h!='' && $da_y!=''){ $dat_str = "STR_TO_DATE(".$design_date.",'%d-%m-%Y') = STR_TO_DATE('$todate','%d/%m/%Y')"; }
				
				if($yea_r!='' && $mont_h!='' && $da_y==''){ $dat_str = "DATE_FORMAT(STR_TO_DATE(".$design_date.",'%d-%m-%Y'),'%m-%Y') = DATE_FORMAT(STR_TO_DATE('$todate','%d/%m/%Y'),'%m-%Y')"; }
				
				if($yea_r!='' && $mont_h=='' && $da_y==''){ $dat_str = "YEAR(STR_TO_DATE(".$design_date.",'%d-%m-%Y')) = YEAR(STR_TO_DATE('$todate','%d/%m/%Y'))"; }
				
				if($yea_r=='' && $mont_h=='' && $da_y==''){ $dat_str = "STR_TO_DATE(".$design_date.",'%d-%m-%Y') <= STR_TO_DATE('$todate','%d/%m/%Y')"; }
				
				if($yea_r=='' && $mont_h!='' && $da_y==''){ $dat_str = "DATE_FORMAT(STR_TO_DATE(".$design_date.",'%d-%m-%Y'),'%m-%Y') = DATE_FORMAT(STR_TO_DATE('$todate','%d/%m/%Y'),'%m-%Y')"; }
				if($yea_r=='' && $mont_h=='' && $da_y!=''){ $dat_str = "STR_TO_DATE(".$design_date.",'%d-%m-%Y') = STR_TO_DATE('$todate','%d/%m/%Y')"; }
				
				if($yea_r!='' && $mont_h=='' && $da_y!=''){ $dat_str = "STR_TO_DATE(".$design_date.",'%d-%m-%Y') = STR_TO_DATE('$todate','%d/%m/%Y')"; }
				
				if($yea_r=='' && $mont_h!='' && $da_y!=''){ $dat_str = "STR_TO_DATE(".$design_date.",'%d-%m-%Y') = STR_TO_DATE('$todate','%d/%m/%Y')"; }
			}
			
			if($mas_stage_id1==1)
			{
				$SLCT = "SELECT * FROM design_det WHERE ".$dat_str.$emp_qur_str. " ORDER BY design_det_id ASC";
			}
			else if($mas_stage_id1==2)
			{
				$SLCT = "SELECT * FROM cad_loading WHERE ".$dat_str." ORDER BY design_det_id ASC";
			}
			else if($mas_stage_id1==3)
			{
				$SLCT = "SELECT * FROM design_det WHERE ".$dat_str.$emp_qur_str. " ORDER BY design_det_id ASC";
			}
			else if($mas_stage_id1==4)
			{
				$SLCT = "SELECT * FROM cam_loading WHERE ".$dat_str." ORDER BY design_det_id ASC";
			}
			else if($mas_stage_id1==5)
			{
				$SLCT = "SELECT * FROM cam_finishing WHERE ".$dat_str." ORDER BY design_det_id ASC";
				$weigh_t = 'Cam Weight';
			}
			else if($mas_stage_id1==6)
			{
				$SLCT = "SELECT * FROM rtv_loading WHERE ".$dat_str." ORDER BY design_det_id ASC";
			}
			else if($mas_stage_id1==7)
			{
				$SLCT = "SELECT * FROM rtv_finishing_des,rtv_finishing WHERE rtv_finishing_des.rtv_finishing_id IN(SELECT rtv_finishing_id FROM rtv_finishing WHERE ".$dat_str.$emp_qur_str.") AND rtv_finishing.rtv_finishing_id = rtv_finishing_des.rtv_finishing_id ORDER BY design_det_id ASC";
			}
			else if($mas_stage_id1==8)
			{
				$SLCT = "SELECT * FROM wax_finishing WHERE ".$dat_str." ORDER BY design_det_id ASC";
			}
			else if($mas_stage_id1==9)
			{
				$SLCT = "SELECT * FROM casting_finishing WHERE ".$dat_str." ORDER BY design_det_id ASC";
			}
			else if($mas_stage_id1==10)
			{
				$SLCT = "SELECT * FROM sol_finishing_des,sol_finishing WHERE sol_finishing_des.sol_finishing_id IN(SELECT sol_finishing_id FROM sol_finishing WHERE ".$dat_str.$emp_qur_str.") AND sol_finishing.sol_finishing_id = sol_finishing_des.sol_finishing_id ORDER BY design_det_id ASC";
			}
			else if($mas_stage_id1==11)
			{
				$SLCT = "SELECT * FROM buf_finishing_des,buf_finishing WHERE buf_finishing_des.buf_finishing_id IN(SELECT buf_finishing_id FROM buf_finishing WHERE ".$dat_str.$emp_qur_str.") AND buf_finishing.buf_finishing_id = buf_finishing_des.buf_finishing_id ORDER BY design_det_id ASC";
			}
			else if($mas_stage_id1==12)
			{
				$SLCT = "SELECT * FROM mas_finishing WHERE ".$dat_str." ORDER BY design_det_id ASC";
				$weigh_t = 'Master Weight';
			}
			
			?>
		
    	<div class="widget" style="display: block"> <!--style="width:600px; margin-left:150px;"-->
        <div class="whead">
		
		<h6>Design List</h6>
		
		<h6 style="float:right; margin-right:50px; text-decoration:underline;"><a href="design_analize_print.php?sta_name=<?php echo $_GET['sta_name'] ?>&em_name=<?php echo $_GET['em_name'] ?>&fdate=<?php echo $_GET['fdate'] ?>&todate=<?php echo $_GET['todate'] ?>&yea_r=<?php echo $_GET['yea_r'] ?>&mont_h=<?php echo $_GET['mont_h'] ?>&da_y=<?php echo $_GET['da_y'] ?>&flg=wimg" target="_blank">With Image</a></h6>
		
		<h6 style="float:right; margin-right:20px;text-decoration:underline;"><a href="design_analize_print.php?sta_name=<?php echo $_GET['sta_name'] ?>&em_name=<?php echo $_GET['em_name'] ?>&fdate=<?php echo $_GET['fdate'] ?>&todate=<?php echo $_GET['todate'] ?>&yea_r=<?php echo $_GET['yea_r'] ?>&mont_h=<?php echo $_GET['mont_h'] ?>&da_y=<?php echo $_GET['da_y'] ?>&flg=womg" target="_blank">Print</a></h6>
		<h6 style="float:right; margin-right:20px">Total Dies : <input type="text" id="tot_die" name="tot_die" value="" readonly="readonly" disabled="disabled" style="width:50px; font-size:12px; text-align:center;" /></h6>
		<h6 style="float:right; margin-right:20px">Total Quantity : <input type="text" id="tot_qty" name="tot_qty" 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>
            <table cellpadding="0" cellspacing="0" border="0" class="dTable" id="dynamic">
            <thead>
            <tr>
            <th width="26" style="text-align:center; vertical-align:middle;">S.No<span class="sorting" style="display: block;"></span></th>
            <th width="100" style="text-align:left; vertical-align:middle;">Design No</th>
            <th width="100"  style="text-align:center; vertical-align:middle;">No of Dies</th>
			 <th width="92"  style="text-align:center; vertical-align:middle;"><?php echo  $design_date; ?> </th>
			<?php if($mas_stage_id1==5 || $mas_stage_id1==12){ ?><th width="134"  style="text-align:center; vertical-align:middle;"> <?php echo $weigh_t; ?></th><?php } ?> 
            <?php if($flag==1){ ?><th width="134"><?php echo $empl_name; ?></th><?php } ?>
            <th width="151"  style="text-align:center; vertical-align:middle;">Design Status</th>
            <th width="140"  style="text-align:center; vertical-align:middle;">Image</th>
          <!--  <th width="138">View/Update</th>-->
           <!-- <th width="146">Status</th>-->
            </tr>
            </thead>
            <tbody>

			<?php 
			//echo $SLCT;
			$QURY = mysqli_query($connect,$SLCT);
			$loop=1;
			$tot_pic =0;
			if(mysqli_num_rows($QURY)>0)
			{			
			while($FTCH = mysqli_fetch_object($QURY))
			{
				$design_id	=	base64_encode(base64_encode(base64_encode($FTCH->design_det_id)));
				
				$SLCT_dm = "SELECT  * FROM design_det WHERE design_det_id = '$FTCH->design_det_id'";
				$QURY_dm = mysqli_query($connect,$SLCT_dm);
				//$FTCH_dm = mysqli_fetch_object($QURY_dm);
				
				if(mysqli_num_rows($QURY_dm)>0){
					$FTCH_dm = mysqli_fetch_object($QURY_dm);
					$master_cat_id = $FTCH_dm->master_cat_id;
					$mas_fin_ext  = $FTCH_dm->mas_fin_ext;
					$cad_fin_ext = $FTCH_dm->cad_fin_ext;
					$imag_ext = $FTCH_dm->imag_ext;
					$design_no = $FTCH_dm->design_no;
					$design_status = $FTCH_dm->design_status;
					$up_status = $FTCH_dm->up_status;
					$master_pieces = $FTCH_dm->master_pieces;
					$no_of_tm_alt = $FTCH_dm->no_of_tm_alt;
				} else {
					$master_cat_id ='';
					$mas_fin_ext='';
					$cad_fin_ext = '';
					$imag_ext='';
					$design_no = '';
					$design_status = '';
					$up_status='';
					$master_pieces='';
					$no_of_tm_alt='';
				}
				
				
				
				$SLCT_d = "SELECT  * FROM master_cat WHERE master_cat_id = '$master_cat_id'";
				$QURY_d = mysqli_query($connect,$SLCT_d);
				$FTCH_d = mysqli_fetch_object($QURY_d);
				if($mas_stage_id1==1){ $dat_e = $FTCH->design_date; }else if($mas_stage_id1==2){ $dat_e = $FTCH->loading_date;  }else if($mas_stage_id1==3){ $dat_e = $FTCH->finishing_date;  }else if($mas_stage_id1==4){ $dat_e = $FTCH->loading_date; }else if($mas_stage_id1==5){ $dat_e = $FTCH->finishing_date; $we_ight = $FTCH->cam_weight;}else if($mas_stage_id1==6){ $dat_e = $FTCH->loading_date; }else if($mas_stage_id1==7){ $dat_e = $FTCH->finishing_date; }else if($mas_stage_id1==8){ $dat_e = $FTCH->finishing_date; }else if($mas_stage_id1==9){ $dat_e = $FTCH->finishing_date; }else if($mas_stage_id1==10){ $dat_e = $FTCH->finishing_date; }else if($mas_stage_id1==11){ $dat_e = $FTCH->finishing_date; }else if($mas_stage_id1==12){ $dat_e = $FTCH->finishing_date; $we_ight = $FTCH->mas_weight;}
				
				if($flag==1)
				{
					$SLCT_e = "SELECT * FROM emp_det WHERE emp_det_id = '$FTCH->emp_det_id'";
					$QURY_e = mysqli_query($connect,$SLCT_e);
					$FTCH_e = mysqli_fetch_object($QURY_e);
				}
				//echo $FTCH->emp_det_id."<br/>";
										
				
		 		if($loop%2 != "0")
					$bg = "gradeX";
				else
					$bg = "class='gradeC'";
					
				if($mas_fin_ext!=''){ $imag = "../mas_fin_images/S.".$mas_fin_ext; $imag1 = "../mas_fin_images/L.".$mas_fin_ext; }

				else if($cad_fin_ext!=''){ $imag = "../cad_fin_images/S.".$cad_fin_ext; $imag1 = "../cad_fin_images/L.".$cad_fin_ext; }

				else if($imag_ext!=''){ $imag = "../design_images/S.".$imag_ext; $imag1 = "../design_images/L.".$imag_ext; }
			?>
            <tr <?php echo $bg ?>>
            <td align="left" style="display:table-cell;vertical-align:middle"><?php echo $loop ?></td>
            <td align="left" style="display:table-cell;vertical-align:middle"><?php echo $FTCH_d->master_cat_name." ".$design_no; ?><?php if($up_status=="yes"){ echo " ( Old ".$no_of_tm_alt." )"; } ?></td>
			<td align="center" style="display:table-cell;vertical-align:middle"><?php echo $master_pieces; ?></td>
			<td align="center" style="display:table-cell;vertical-align:middle"><?php echo str_replace("-","/",$dat_e); ?></td>
			<?php if($mas_stage_id1==5 || $mas_stage_id1==12){ ?><td align="center" style="display:table-cell;vertical-align:middle"><?php echo $we_ight; ?></td><?php } ?>
           <?php if($flag==1){ ?> <td align="center" style="display:table-cell;vertical-align:middle"><?php echo $FTCH_e->name; ?></td><?php } ?>
            <td align="center" style="display:table-cell;vertical-align:middle"><?php echo $design_status; ?></td>
            <td class="center">
                <div class="body" align="center">
                	<a href="<?php echo $imag1; ?>" title="<h2><?php echo $FTCH_d->master_cat_name." ".$design_no; ?></h2>" class="lightbox" rel="group"><img src="<?php echo $imag; ?>" width="60" height="60"/></a> </div> </td>
            
            </tr>
            
            <?php
            
			$loop ++;
			$tot_pic = $tot_pic+$FTCH_dm->master_pieces;
			 }
			 }
			 ?>
            </tbody>
            </table> 
        </div>
        </div>   
	<?php } ?>
	<input name="tot_cnt" id="tot_cnt" type="hidden" value="<?php echo $loop-1; ?>" />	 
	<input name="mas_die" id="mas_die" type="hidden" value="<?php echo $tot_pic;  ?>" />
        </fieldset>
     </form>
        <div class="fluid"><!-- Media table --></div>
<?php } else {  echo ACCESS_MSG;} ?>

    </div>
    <!-- Main content ends -->
<script>
 document.getElementById("tot_die").value =  document.getElementById("mas_die").value;
</script>    
</div>
<!-- Content ends -->
<?php /*?><?php include "header_footer/footer.php"; ?><?php */?>
</body>
</html>
