<?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 type="text/javascript" src="js/design_add_JS.js"></script>
 <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">
    <!--<div class="contentTop">
        <span class="pageTitle"><span class="icon-key-2"></span>Form validation engines</span>
        <ul class="quickStats">
            <li>
                <a href="" class="blueImg"><img src="images/icons/quickstats/plus.png" alt="" /></a>
                <div class="floatR"><strong class="blue">5489</strong><span>visits</span></div>
            </li>
            <li>
                <a href="" class="redImg"><img src="images/icons/quickstats/user.png" alt="" /></a>
                <div class="floatR"><strong class="blue">4658</strong><span>users</span></div>
            </li>
            <li>
                <a href="" class="greenImg"><img src="images/icons/quickstats/money.png" alt="" /></a>
                <div class="floatR"><strong class="blue">1289</strong><span>orders</span></div>
            </li>
        </ul>
        <div class="clear"></div>
    </div>-->
     <?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="#" 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="#" title="Add something" 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="design_list.php" id="listpage" title="List Design" class="tipN"><img src="images/icons/middlenav/stats.png" alt="" /></a></li>
        </ul>
    	<?php
		$design_id	=	base64_decode(base64_decode(base64_decode($_GET['design_id']))); //THIS IS PAGE ID  
		$page_id= base64_encode(base64_encode(base64_encode(3))); //THIS IS FOR PAGE IDENTIFICATION IN BL FILE for add		 
		
		//$SLCT = "SELECT  * FROM design_det WHERE design_det_id = '$design_id' AND up_status ='no'";
		$SLCT = "SELECT  * FROM design_det WHERE design_det_id = '$design_id'";
		$QURY = mysqli_query($connect,$SLCT);
		$FTCH = mysqli_fetch_object($QURY);	
		
		/*$SLCTcd = "SELECT  * FROM master_cad_cat WHERE master_cad_cat_id = '$FTCH->master_cad_cat_id'";
		$QURYcd = mysqli_query($connect,$SLCTcd);
		$FTCHcd = mysqli_fetch_object($QURYcd);	*/
		
		$SLCTt = "SELECT  * FROM master_cat WHERE master_cat_id = '$FTCH->master_cat_id'";
		//echo $SLCTt;
		$QURYt = mysqli_query($connect,$SLCTt);
		$FTCHt = mysqli_fetch_object($QURYt);
		
		$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);
		
		$SLCT_cl = "SELECT  * FROM cad_loading WHERE design_det_id = '$FTCH->design_det_id'"; 
		$QURY_cl = mysqli_query($connect,$SLCT_cl);
				
		$SLCT_cf = "SELECT  * FROM cad_finishing_des WHERE design_det_id = '$FTCH->design_det_id'"; 
		$QURY_cf = mysqli_query($connect,$SLCT_cf);
		$num = mysqli_num_rows($QURY_cf);
		$FTCH_cf = mysqli_fetch_object($QURY_cf);
						
		$SLCT_cm = "SELECT  * FROM cam_loading WHERE design_det_id = '$FTCH->design_det_id'"; 
		$QURY_cm = mysqli_query($connect,$SLCT_cm);
		
		$SLCT_cm1 = "SELECT  * FROM cam_finishing WHERE design_det_id = '$FTCH->design_det_id'"; 
		$QURY_cm1 = mysqli_query($connect,$SLCT_cm1);		
		
		$SLCT_rtv = "SELECT  * FROM rtv_finishing_des WHERE design_det_id = '$FTCH->design_det_id' AND up_status ='no'"; 
		$QURY_rtv = mysqli_query($connect,$SLCT_rtv);		
		
		$SLCT_wx = "SELECT  * FROM wax_finishing WHERE design_det_id = '$FTCH->design_det_id' AND up_status ='no'"; 
		$QURY_wx = mysqli_query($connect,$SLCT_wx);
				
		$SLCT_cs = "SELECT  * FROM casting_finishing WHERE design_det_id = '$FTCH->design_det_id' AND up_status ='no'"; 
		$QURY_cs = mysqli_query($connect,$SLCT_cs);
				
		$SLCT_so = "SELECT  * FROM sol_finishing_des WHERE design_det_id = '$FTCH->design_det_id' AND up_status ='no'"; 
		$QURY_so = mysqli_query($connect,$SLCT_so);		
		
		$SLCT_bu = "SELECT  * FROM buf_finishing_des WHERE design_det_id = '$FTCH->design_det_id' AND up_status ='no'"; 
		$QURY_bu = mysqli_query($connect,$SLCT_bu);
				
		$SLCT_ma = "SELECT  * FROM mas_finishing WHERE design_det_id = '$FTCH->design_det_id' AND up_status ='no'"; 
		$QURY_ma = mysqli_query($connect,$SLCT_ma);	
		
		$SLCT_sol_load = "SELECT  * FROM soldering_loading WHERE design_det_id = '$FTCH->design_det_id'"; 
		$QURY_sol_load = mysqli_query($connect,$SLCT_sol_load);		
		
		$SLCT_sil_lod = "SELECT  * FROM silver_loading WHERE design_det_id = '$FTCH->design_det_id'"; 
		$QURY_sil_lod = mysqli_query($connect,$SLCT_sil_lod);
				
		$SLCT_sil_fin = "SELECT  * FROM silver_finishing WHERE design_det_id = '$FTCH->design_det_id'"; 
		$QURY_sil_fin = mysqli_query($connect,$SLCT_sil_fin);	
		
		$SLCT_bu_lod = "SELECT  * FROM buf_loading WHERE design_det_id = '$FTCH->design_det_id'"; 
		$QURY_bu_lod = mysqli_query($connect,$SLCT_bu_lod);
		
		if($num>0)
		{
			$SLCT_emp_id = "SELECT  * FROM cad_finishing WHERE cad_finishing_id = $FTCH_cf->cad_finishing_id "; 
			//echo $SLCT_emp_id;
			$QURY_emp_id = mysqli_query($connect,$SLCT_emp_id);
			$FTCH_emp_id = mysqli_fetch_object($QURY_emp_id);
		}
		$SLCT_cur_des = "SELECT * FROM emp_current_design WHERE design_det_id = '$FTCH->design_det_id' "; 
		$QURY_cur_des = mysqli_query($connect,$SLCT_cur_des);
		if(mysqli_num_rows($QURY_cur_des))
		{
			$FTCH_cur_des 	= mysqli_fetch_object($QURY_cur_des);
			$emp_cur_id		= $FTCH_cur_des->emp_current_design_id;
			$des_id1		= base64_encode(base64_encode(base64_encode(base64_encode($FTCH_cur_des->design_det_id)))); 
			$emp_ad_id1		= base64_encode(base64_encode(base64_encode(base64_encode($FTCH_cur_des->emp_det_id)))); 
			$emp_cur_id1	= base64_encode(base64_encode(base64_encode(base64_encode($emp_cur_id))));
			$emp_flagg 		= 1;
		}
		else
		{
			$emp_flagg 		= 2;
		}
		?>

        <div class="fluid" style="width:800px; margin-left:50px;">
            <form id="validate" name="fm" class="main" method="post" action="bl/design_BL.php?page_id=<?php echo $page_id; ?>" 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>Design View</h6><div class="clear"></div></div>
                        <div class="formRow">
                        	<table width="100%">
                            	<tr>
                                	<td width="21%" style="vertical-align:top;"><label>Image :<span class="req"></span></label></td>
                                    <td width="25%" align="center" style="vertical-align:top;"><div style="border:double #BBBBBB; height:210px"><?php if($FTCH->imag_ext!='') { ?><img id="blah" name="" type="image" title="Design Image" src="../design_images/M.<?php echo $FTCH->imag_ext; ?>" /><?php } else { ?><img id="blah" name="" title="No Design Image" type="image" src="images/NoImg.png" /><?php } ?></div></td>
                                    <td width="2%">&nbsp;</td>
                                    <td width="25%" align="center" style="vertical-align:top;"><div style="border:double #BBBBBB; height:210px"><?php if($FTCH->cad_fin_ext!='') { ?><img id="blah" name="" type="image" title="Cad Finishing Image" src="../cad_fin_images/M.<?php echo $FTCH->cad_fin_ext; ?>" /><?php } else { ?><img id="blah" title="No Cad Finishing Image" name="" type="image" src="images/NoImg.png" /><?php } ?></div></td>
                                    <td width="2%">&nbsp;</td>
                                    <td width="25%" align="center" style="vertical-align:top;"><div style="border:double #BBBBBB; height:210px"><?php if($FTCH->mas_fin_ext!='') { ?><img id="blah" name="" type="image" title="Master Finishing Image" src="../mas_fin_images/M.<?php echo $FTCH->mas_fin_ext; ?>" /><?php } else { ?><img id="blah" title="No Master Finishing Image" name="" type="image" src="images/NoImg.png" /><?php } ?></div></td>
                             	</tr>
                         	</table>
                            <div class="clear"></div>
                        </div>                        
                        <div class="formRow">
                            <div class="grid2"><label>Design No :</label></div>
                            <div class="grid2"><?php echo $FTCHt->master_cat_name. " / " . $FTCH->design_no ?></div>
                            
                            <?php /*?><div class="grid2"><label>Design No :<span class="req"></span></label></div>
                            <div class="grid2"><?php echo $FTCH->design_no ?></div><?php */?>
                            
                            <div class="grid2"><label>Hand Designer :<span class="req"></span></label></div>
                            <div class="grid2"><?php echo $FTCH_E->name ?></div>
                            <div class="grid2"><label>Approximate Wght :<span class="req"></span></label></div>
                            <div class="grid2"><?php echo $FTCH->approximate_weight." g"; ?></div>
							<div class="clear"></div>
                        </div>
                        
                        <?php if(mysqli_num_rows($QURY_cl)>0){ $FTCH_cl = mysqli_fetch_object($QURY_cl); ?><!--FOR CAD-->
                        
                        <div class="formRow">
                            <div class="grid2"><label><?php if($FTCH->up_status=="no"){ ?><input type="radio" id="cad_upd" name="des_update" value="cad" onclick="reload_chk()" /><?php } ?> Cad Loading :</label></div>
                            <div class="grid2"><?php echo str_replace("-", "/",$FTCH_cl->loading_date); ?></div>
                            
                            <?php if(mysqli_num_rows($QURY_cf) > 0){ 
							$SLCT_cfd = "SELECT * FROM cad_finishing WHERE cad_finishing_id = '$FTCH_cf->cad_finishing_id'"; 
							$QURY_cfd = mysqli_query($connect,$SLCT_cfd);
							$FTCH_cfd = mysqli_fetch_object($QURY_cfd);
							
							$SLCT_cfdd = "SELECT  * FROM cad_finishing_des WHERE cad_finishing_id = '$FTCH_cf->cad_finishing_id' AND design_det_id ='$FTCH->design_det_id'"; 
							$QURY_cfdd = mysqli_query($connect,$SLCT_cfdd);
							if(mysqli_num_rows($QURY_cfdd)>0)
							{
								$FTCH_cfdd = mysqli_fetch_object($QURY_cfdd);
							}
							
							
							$SLCT_Ec = "SELECT  * FROM emp_det WHERE emp_det_id = '$FTCH_cfd->emp_det_id'"; 
							$QURY_Ec = mysqli_query($connect,$SLCT_Ec);
							$FTCH_Ec = mysqli_fetch_object($QURY_Ec);
							$catt_dtt = $FTCH_cfdd->cad_time;
							
							$SLCT_cu_design = "SELECT emp_current_design_id FROM emp_current_design WHERE emp_det_id = $FTCH_Ec->emp_det_id AND design_det_id = '$FTCH->design_det_id' "; 
							//echo $SLCT_cu_design;
							$QURY_cu_design = mysqli_query($connect,$SLCT_cu_design);
							if(mysqli_num_rows($QURY_cu_design)>0)
							{
							$FTCH_cu_design = mysqli_fetch_object($QURY_cu_design);	
							
							$des_id				= $FTCH->design_det_id;
							$emp_cur_id			= $FTCH_cu_design->emp_current_design_id;
							$des_id1			= base64_encode(base64_encode(base64_encode(base64_encode($des_id)))); 
							$emp_ad_id1			= base64_encode(base64_encode(base64_encode(base64_encode($FTCH_Ec->emp_det_id)))); 
							$emp_cur_id1		= base64_encode(base64_encode(base64_encode(base64_encode($emp_cur_id))));
							$des_flag=1;
							}
							else
							{
								$des_flag=2;
							}
							?>
                            
                            <div class="grid2"><label>Cad Finishing :<span class="req"></span></label></div>
                            <div class="grid2"><?php echo str_replace("-", "/",$FTCH_cfd->finishing_date); ?></div>
                            
                            <div class="grid2"><label>Cad Designer :<span class="req"></span></label></div>
                            <div class="grid2"><?php echo $FTCH_Ec->name ?></div>
                            
                            <?php $catt_flagg = 1;} else { $catt_dtt = ''; $catt_flagg = 0; } ?>
                            <div class="clear"></div>
                        </div>
                		
                        <?php } else { $catt_dtt = ''; $catt_flagg = 0; }?>
						
						                        
                        <div class="formRow">                                                        
                            <div class="grid2"><label>Points :<span class="req"></span></label></div>
                            <div class="grid2"> 
							<select name="cad_cat" onfocus="foc(this.id)" onblur="stnon(this.id)" onchange="reload_chk()">
                                    <option value="">--</option>
                                    <?php
									$SLCT_E = "SELECT  * FROM master_cad_cat WHERE statu_s = 'active' order by cad_cat_name"; 
									//echo $SLCT;
									$QURY_E = mysqli_query($connect,$SLCT_E);
									while($FTCH_E = mysqli_fetch_object($QURY_E))
									{
									?>
                                    <option <?php if($FTCH->master_cad_cat_id == $FTCH_E->master_cad_cat_id){ ?> selected="selected" <?php } ?> value="<?php echo $FTCH_E->master_cad_cat_id ?>"><?php echo $FTCH_E->cad_cat_name ?></option>
                                    <?php
									}
									?>
                                        
                                </select></div>
                            <?php
							if($catt_flagg == 1)
							{
							?>
                            <div class="grid2"><label>Time :<span class="req"></span></label></div>
                            <div class="grid2"><?php echo $catt_dtt; ?></div>
                           	<div class="grid2">
							No of pieces : <?php echo $FTCH_cfdd->no_of_pice; ?>
							</div>
                            <?php
							}
							else
							{
							?>
                            <div class="grid2">&nbsp;</div>
                            <div class="grid2">&nbsp;</div>
                            <div class="grid2">&nbsp;</div>
							<?php
							}
							?>
							
							<div class="grid2">
							<?php
                            if($emp_flagg==1)
							{
							?>
                            <a style="cursor:pointer; color:#FF0000;" onClick="cad_his_fun('<?php echo $des_id1?>','<?php echo $emp_ad_id1?>','<?php echo $emp_cur_id1?>')"><strong>View Cad History</strong></a>
                        	<?php
							}
                            ?>
                            </div>
                            <div class="clear"></div>
                        </div>
                		
                        
                        
                        <?php if(mysqli_num_rows($QURY_cm)>0){ $FTCH_cm = mysqli_fetch_object($QURY_cm1); ?><!--FOR CAM-->
                        
                        <div class="formRow">                                                        
                            <div class="grid2"><label>Cam Receive :<span class="req"></span></label></div>
                            <div class="grid2"><?php echo str_replace("-", "/",$FTCH_cm->finishing_date); ?></div>
                            
                            <div class="grid2"><label>Cam Weight :<span class="req"></span></label></div>
                            <div class="grid2"><?php echo $FTCH_cm->cam_weight." g" ?></div>
                            <?php 
	                            $SLCT_c = "SELECT  * FROM master_country WHERE master_country_id = '$FTCH->master_country_id'";
								$QURY_c = mysqli_query($connect,$SLCT_c);
								if(mysqli_num_rows($QURY_c)>0)
								{
									$FTCH_c = mysqli_fetch_object($QURY_c);
									$country_name=$FTCH_c->country_name;
									
								}else{
									$country_name='Nil';
								}
							?>
                            <div class="grid2"><label>Country :<span class="req"></span></label></div>
                            <div class="grid2"><?php echo $country_name ?></div>
                        
                            <div class="clear"></div>
                        </div>
                		
                        <?php } ?>
                        
                        <!--FOR RTV--> 
                        <?php if(mysqli_num_rows($QURY_rtv)>0){ 
						
						$FTCH_rtv = mysqli_fetch_object($QURY_rtv);
												
						$SLCT_cfd = "SELECT  * FROM rtv_finishing WHERE rtv_finishing_id = '$FTCH_rtv->rtv_finishing_id'"; 
						$QURY_cfd = mysqli_query($connect,$SLCT_cfd);
						$FTCH_cfd = mysqli_fetch_object($QURY_cfd);
						
						$SLCT_Ec = "SELECT  * FROM emp_det WHERE emp_det_id = '$FTCH_cfd->emp_det_id'"; 
						$QURY_Ec = mysqli_query($connect,$SLCT_Ec);
						$FTCH_Ec = mysqli_fetch_object($QURY_Ec);
						
						
						 ?>
                        
                        <div class="formRow">
                        
                            <div class="grid2"><label>Rtv Finishing :<span class="req"></span></label></div>
                            <div class="grid2"><?php echo str_replace("-", "/",$FTCH_cfd->finishing_date); ?></div>
                            
                            <div class="grid2"><label>Rtv Cutter :<span class="req"></span></label></div>
                            <div class="grid2"><?php echo $FTCH_Ec->name ?></div>
                            
                          	<div class="clear"></div>
                        </div>
                		
                        <?php } ?>
                        
                        <?php if(mysqli_num_rows($QURY_wx)>0){ $FTCH_wx = mysqli_fetch_object($QURY_wx); ?><!--FOR WAX-->
                        
                        <div class="formRow">                                                        
                            <div class="grid2"><label><?php if($FTCH->up_status=="no"){ $wax_flagg = 1; ?><input type="radio" id="wax_upd" name="des_update" value="wax" onclick="reload_chk()" /><?php } else { $wax_flagg = 0; } ?> Wax Finishing :<span class="req"></span></label></div>
                            <div class="grid2"><?php echo str_replace("-", "/",$FTCH_wx->finishing_date); ?></div>
                            
                            <div class="clear"></div>
                        </div>
                		
                        <?php } else {$wax_flagg = 2;} ?>
                        
                        
                        <?php if(mysqli_num_rows($QURY_cs)>0){ $FTCH_cs = mysqli_fetch_object($QURY_cs); ?><!--FOR WAX-->
                        
                        <div class="formRow">                                                        
                            <div class="grid2"><label>Casting Finishing :<span class="req"></span></label></div>
                            <div class="grid2"><?php echo str_replace("-", "/",$FTCH_cs->finishing_date); ?></div>
                            
                            <div class="clear"></div>
                        </div>
                		
                        <?php } ?>
						
						<!--FOR Silver Loading--> 
                        <?php if(mysqli_num_rows($QURY_sil_lod)>0){ 
						
						$FTCH_sil_lod = mysqli_fetch_object($QURY_sil_lod);
												
						$SLCT_cfd = "SELECT  * FROM silver_loading WHERE silver_loading_id = '$FTCH_sil_lod->silver_loading_id'"; 
						$QURY_cfd = mysqli_query($connect,$SLCT_cfd);
						$FTCH_cfd = mysqli_fetch_object($QURY_cfd);
						
						
						 ?>
                        
                        <div class="formRow">
                        
                            <div class="grid2"><label>Silver Loading :<span class="req"></span></label></div>
                            <div class="grid2"><?php echo str_replace("-", "/",$FTCH_cfd->loading_date); ?></div>
                            
                          	<div class="clear"></div>
                        </div>
                		
                        <?php } ?>
           
                         <!--FOR Silver Finishing--> 
                        <?php if(mysqli_num_rows($QURY_sil_fin)>0){ 
						
						$FTCH_sil_fin = mysqli_fetch_object($QURY_sil_fin);
												
						$SLCT_cfd = "SELECT  * FROM silver_finishing WHERE silver_finishing_id = '$FTCH_sil_fin->silver_finishing_id'"; 
						$QURY_cfd = mysqli_query($connect,$SLCT_cfd);
						$FTCH_cfd = mysqli_fetch_object($QURY_cfd);
						 ?>
                        
                        <div class="formRow">
                        
                            <div class="grid2"><label>Silver Rcv. Date :<span class="req"></span></label></div>
                            <div class="grid2"><?php echo str_replace("-", "/",$FTCH_cfd->finishing_date); ?></div>
							
							<div class="grid2"><label>CAM Weight :<span class="req"></span></label></div>
                            <div class="grid2"><?php echo $FTCH_cfd->cam_weight." g" ?></div>
                            
                            <div class="grid2"><label>Silver Rcv. Weight :<span class="req"></span></label></div>
                            <div class="grid2"><?php echo $FTCH_cfd->silver_weight." g" ?></div>
							
							
                            
                          	<div class="clear"></div>
                        </div>
                		
                        <?php } ?>
						
						 <!--FOR SOLDERING Loading--> 
                        <?php if(mysqli_num_rows($QURY_sol_load)>0){ 
						
						$FTCH_sol_lod = mysqli_fetch_object($QURY_sol_load);
												
						$SLCT_cfd = "SELECT  * FROM soldering_loading WHERE soldering_loading_id = '$FTCH_sol_lod->soldering_loading_id'"; 
						$QURY_cfd = mysqli_query($connect,$SLCT_cfd);
						$FTCH_cfd = mysqli_fetch_object($QURY_cfd);
						
						$SLCT_Ec = "SELECT  * FROM emp_det WHERE emp_det_id = '$FTCH_cfd->emp_det_id'"; 
						$QURY_Ec = mysqli_query($connect,$SLCT_Ec);
						$FTCH_Ec = mysqli_fetch_object($QURY_Ec);
						
						
						 ?>
                        
                        <div class="formRow">
                        
                            <div class="grid2"><label>Sol. Loading Dt:<span class="req"></span></label></div>
                            <div class="grid2"><?php echo str_replace("-", "/",$FTCH_cfd->loading_date); ?></div>
                            
                            <div class="grid2"><label>Sol. Worker Name :<span class="req"></span></label></div>
                            <div class="grid2"><?php echo $FTCH_Ec->name ?></div>
							
							<div class="grid2"><label>Sol. Loading Wt :<span class="req"></span></label></div>
                            <div class="grid2"><?php echo $FTCH_cfd->solder_weight." g" ?></div>
                            
                          	<div class="clear"></div>
                        </div>
                		
                        <?php } ?>
           
                         <!--FOR SOLDERING Finishing--> 
                        <?php if(mysqli_num_rows($QURY_so)>0){ 
						
						$FTCH_so = mysqli_fetch_object($QURY_so);
												
						$SLCT_cfd = "SELECT * FROM sol_finishing WHERE sol_finishing_id = '$FTCH_so->sol_finishing_id'"; 
						$QURY_cfd = mysqli_query($connect,$SLCT_cfd);
						$FTCH_cfd = mysqli_fetch_object($QURY_cfd);
						
						$SLCT_cfdd = "SELECT * FROM sol_finishing_des WHERE sol_finishing_des_id = '$FTCH_so->sol_finishing_des_id'"; 
						$QURY_cfdd = mysqli_query($connect,$SLCT_cfdd);
						$FTCH_cfdd = mysqli_fetch_object($QURY_cfdd);
						
						$SLCT_Ec = "SELECT  * FROM emp_det WHERE emp_det_id = '$FTCH_cfd->emp_det_id'"; 
						$QURY_Ec = mysqli_query($connect,$SLCT_Ec);
						$FTCH_Ec = mysqli_fetch_object($QURY_Ec);
						
						
						 ?>
                        
                        <div class="formRow">
                        
                            <div class="grid2"><label>Sol. Finishing Dt :<span class="req"></span></label></div>
                            <div class="grid2"><?php echo str_replace("-", "/",$FTCH_cfd->finishing_date); ?></div>
                            
                            <?php /*?><div class="grid2"><label>Soldering Worker :<span class="req"></span></label></div>
                            <div class="grid2"><?php echo $FTCH_Ec->name ?></div><?php */?>
							
							<div class="grid2"><label>Sol. Weight:<span class="req"></span></label></div>
                            <div class="grid2"><?php echo $FTCH_cfdd->sil_weight." g" ?></div>
                            
                            <div class="grid2"><label>Master Pieces:<span class="req"></span></label></div>
                            <div class="grid2"><?php echo $FTCH_cfdd->master_pice ?></div>
                            
                          	<div class="clear"></div>
                        </div>
						<div class="formRow">
                        
                            <div class="grid2"><label>Runner Weight:<span class="req"></span></label></div>
                            <div class="grid2"><?php echo $FTCH_cfdd->run_weight." g"; ?></div>
                            
                            <div class="grid2"><label>Total Weight :<span class="req"></span></label></div>
                            <div class="grid2"><?php echo $FTCH_cfdd->tot_weight." g" ?></div>
							
							<div class="grid2"><label>wastage:<span class="req"></span></label></div>
                            <div class="grid2"><?php echo $FTCH_cfdd->wastage." g" ?></div>
                            
                          	<div class="clear"></div>
                        </div>
                		
                        <?php } ?>
                        
                        <!--FOR BUFFING Loading--> 
                        <?php if(mysqli_num_rows($QURY_bu_lod)>0){ 
						
						$FTCH_bu_lod = mysqli_fetch_object($QURY_bu_lod);
												
						$SLCT_cfd = "SELECT  * FROM buf_loading WHERE buf_loading_id = '$FTCH_bu_lod->buf_loading_id'"; 
						$QURY_cfd = mysqli_query($connect,$SLCT_cfd);
						$FTCH_cfd = mysqli_fetch_object($QURY_cfd);	
						 ?>
                        
                        <div class="formRow">
                        
                            <div class="grid2"><label>Buff. Loading Dt :<span class="req"></span></label></div>
                            <div class="grid2"><?php echo str_replace("-", "/",$FTCH_cfd->loading_date); ?></div>
                            
                            <div class="grid2"><label>Buff. Loading Wt :<span class="req"></span></label></div>
                            <div class="grid2"><?php echo $FTCH_cfd->buf_weight." g" ?></div>
                            
                          	<div class="clear"></div>
                        </div>
                		
                        <?php } ?>
						
                        <!--FOR BUFFING--> 
                        <?php if(mysqli_num_rows($QURY_bu)>0){ 
						
						$FTCH_bu = mysqli_fetch_object($QURY_bu);
												
						$SLCT_cfd = "SELECT  * FROM buf_finishing WHERE buf_finishing_id = '$FTCH_bu->buf_finishing_id'"; 
						//echo $SLCT_cfd;
						$QURY_cfd = mysqli_query($connect,$SLCT_cfd);
						$FTCH_cfd = mysqli_fetch_object($QURY_cfd);
						
						$SLCT_Ec = "SELECT  * FROM emp_det WHERE emp_det_id = '$FTCH_cfd->emp_det_id'"; 
						$QURY_Ec = mysqli_query($connect,$SLCT_Ec);
						$FTCH_Ec = mysqli_fetch_object($QURY_Ec);
						
						 ?>
                        
                        <div class="formRow">
                        
                            <div class="grid2"><label>Buff. Finishing Dt:<span class="req"></span></label></div>
                            <div class="grid2"><?php echo str_replace("-", "/",$FTCH_cfd->finishing_date); ?></div>
                            
                            <div class="grid2"><label>Buff. Worker Name :<span class="req"></span></label></div>
                            <div class="grid2"><?php echo $FTCH_Ec->name ?></div>
                            
                            <div class="grid2"><label><b>Sub Cat Name :</b><span class="req"></span></label></div>
                            <div class="grid2 searchDrop">
                                <select  data-placeholder="" class="select" name="sub_cat_name" id="sub_cat_name" style="width:200px;" onfocus="foc(this.id)" onblur="stnon(this.id)" onchange="reload_chk()">
                                    <option value="">Choose a Sub Category...</option>
                                    <?php
									$SLCT_con = "SELECT master_sub_category_id,sub_category_name FROM master_sub_category WHERE statu_s='active' ORDER BY sub_category_name ASC";
									$QURY_con = mysqli_query($connect,$SLCT_con);
									while($FTCH_con = mysqli_fetch_object($QURY_con))
									{											
									?>
                                    <option <?php if($FTCH_con->master_sub_category_id==$FTCH->master_sub_category_id){ ?> selected="" <?php } ?> value="<?php echo base64_encode(base64_encode(base64_encode(base64_encode($FTCH_con->master_sub_category_id)))); ?>"><?php echo $FTCH_con->sub_category_name ?></option>
                                    <?php
									}
									?>
                                </select>
                            </div>

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

                        <?php } ?>

                         <!--FOR BUFFING--> 
                        <?php if(mysqli_num_rows($QURY_ma)>0){ 

						$FTCH_ma = mysqli_fetch_object($QURY_ma);

						$SLCT_cfd = "SELECT  * FROM master_mat WHERE master_mat_id = '$FTCH_ma->master_mat_id'"; 
						$QURY_cfd = mysqli_query($connect,$SLCT_cfd);
						$FTCH_cfd = mysqli_fetch_object($QURY_cfd);

						 ?>

                        <div class="formRow">

                            <div class="grid2"><label>Master Finishing Dt:<span class="req"></span></label></div>
                            <div class="grid2"><?php echo str_replace("Dt-", "/",$FTCH_ma->finishing_date); ?></div>

                            <div class="grid2"><label>Master Material :<span class="req"></span></label></div>
                            <div class="grid2"><?php echo $FTCH_cfd->master_mat_name ?></div>

                            <?php if($FTCH->up_status=="no"){ ?>
                            <div class="grid2"><label>Weight :<span class="req"></span></label></div>
                            <div class="grid2"><input name="wet_up" id="wet_up" value="<?php echo $FTCH_ma->mas_weight ?>" type="text" /></div>
							<?php } ?>
                          	<div class="clear"></div>
                        </div>

                        <?php } ?>
                        	<input type="hidden" name="remark" id="remark" value="" />

                        <div class="formRow" style="display:none" id="reld_btn_view">
						<?php if($FTCH->up_status=="no"){ ?>
                        <input type="button" value="Reset" class="buttonM bRed" style="float: right; margin-left:20px;" onclick="form_rest();"/>
                        <input type="button" value="Update" class="buttonM bBlack formSubmit" onclick="return update_validate(<?php echo $wax_flagg; ?>);"/>
						<?php } ?>

						<div class="clear"></div></div>
                        <div class="clear"></div>
                    </div>
                </fieldset>
            </form>
        </div>
    </div>
</div>
<div id="view_history" title="CAD History">
    <div id="logindiv">
    </div>
</div>
<!--<div id="dialog-modal" title="Basic modal dialog">
                            <p>Adding the modal overlay screen makes the dialog look more prominent because it dims out the page content.</p>
                        </div>-->
<!-- Content ends -->    

<script type="text/javascript">
//===== Modal =====//
	
    $('#view_history').dialog({
		autoOpen: false, 
		width: 1000,
		height: 800,
		modal: true,
		buttons: {
				"Close": function() {
					$( this ).dialog( "close" );
					$("#logindiv").html("");
				}
			}
		});
	function cad_his_fun(des_id,emp_ad_id,emp_cur_id)
	{
		$("#logindiv").load("cad_history_view.php?des_id="+des_id+"&emp_ad_id="+emp_ad_id+"&emp_cur_id="+emp_cur_id,function(response){
			$('#view_history').dialog('open');
			return false;
		});
	}
</script>
<script type="text/javascript">


</script>
        
</body>
</html>