<?php
	include "db_connection/db_connection.php";
	include "config/config.php";
	
	if($_SESSION['admin_login_id'] == '')
	{
		echo "<script>window.location='index.php';</script>";
	}
	
	$check_acc  = check_access('32');
?>
<!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/sol_loading_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" />
<style type="text/css">
	.timeEntry_control{
		margin-top:5px;	
	}
</style> 
<!--[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:">Soldering Loading</a></li>
                    
            </ul>
        </div>
	<?php include "menus/top_left_menu.php"; ?>            
        
    </div>
    
    <!-- Main content -->
    <div class="wrapper">
    <?php if($check_acc==1){?>
        <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="sol_loading_list.php" id="listpage" title="List Soldering Loading" class="tipN"><img src="images/icons/middlenav/stats.png" alt="" /></a></li>
    	</ul>            
  		<?php
		if(isset($_GET['des_name']))
		{
			$des_name = $_GET['des_name'];			
		}
		else
		{
			$des_name = '';
		}
		if(isset($_GET['dat']))
		{
			$dat = $_GET['dat'];
			$dat_chg = str_replace("-", "/", $dat);
			$tot_dis ="block";
		}
		else
		{
			$dat = '';
			$tot_dis ="none";
		}
		$page_id= base64_encode(base64_encode(base64_encode(1))); //THIS IS FOR PAGE IDENTIFICATION IN BL FILE for add		 
					 
		?>

    	<!-- Chart --><!-- 6 + 6 -->
        <form id="validate" name="checklist" class="main" method="post" action="bl/sol_loading_BL.php?page_id=<?php echo $page_id; ?>" onsubmit="checkTheBox();">
         <fieldset>
        <div class="fluid">
		<div class="widget">
		<div class="formRow">
			<table width="100%">
				<tr>
					<td width="20%" style="display:table-cell;vertical-align:middle"><label>Soldering Worker:<span style="color:#FF0000">*</span></label></td>
					<td width="30%" style="display:table-cell;vertical-align:middle">
						<div class="searchDrop ">
							<select data-placeholder="Choose an Employee..." class="select" name="hdes_name" id="hdes_name" style="width:350px;" onfocus="foc(this.id)" onblur="stnon(this.id)">
								<option value=""></option>
								<?php
								$SLCT_E = "SELECT  * FROM emp_det WHERE master_dept_id REGEXP(CONCAT('(^|,)(',5,')(,|$)')) and statu_s='active'"; //HERE THE 5 IS REPRESENTS Soldering DESIGNER ID 
								//echo $SLCT;
								$QURY_E = mysqli_query($connect,$SLCT_E);
								while($FTCH_E = mysqli_fetch_object($QURY_E))
								{
									$des_id= base64_encode(base64_encode(base64_encode(base64_encode($FTCH_E->emp_det_id))));
								?>
								<option <?php if($des_name == $des_id){ ?> selected="selected" <?php } ?> value="<?php echo $des_id ?>"><?php echo $FTCH_E->name ?></option>
								<?php
								}
								?>
									
							</select>
						</div>
					</td>
					<td colspan="2" style="display:table-cell;vertical-align:middle"></td>
				</tr>
			</table>
            <div class="clear"></div>
        </div>
                        
        <div class="formRow">
			<table width="100%">
				<tr>
					<td width="20%" style="display:table-cell;vertical-align:middle"><label>Loading Date:<span style="color:#FF0000">*</span></label></td>
					<td width="30%" style="display:table-cell;vertical-align:middle"><input type="text" name="lob" id="lob" value="<?php echo $dat;?>" class="datepicker" onchange="reload_page();" /></td>
					<td width="20%" style="display:table-cell;vertical-align:middle"><label>Loading Time:<span style="color:#FF0000">*</span></label></td>
					<td width="30%" style="display:table-cell;vertical-align:middle"><input type="text" class="timepicker" name="st_tim" id="st_tim" onfocus="foc(this.id)" onblur="stnon(this.id)" value="" /></td>
				</tr>
			</table>
			<div class="clear"></div>
			</div>
        </div>
        </div>
        
        
    	 <div class="widget" style="display:<?php echo $tot_dis ?>">
            <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>Soldering Loading Add</h6><h6 style="float:right; margin-right:50px"><input type="text" id="cnt_chk" name="cnt_chk" value="" readonly="readonly" style="width:50px; font-size:12px; text-align:center;" disabled="disabled"/></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" cellspacing="0" width="100%" class="dTable check" id="checkAll">
            <thead>
            <tr>
            <td width="20"><img src="images/elements/other/tableArrows.png" alt="" /></td>
            <th width="113">S.No<span class="sorting" style="display: block;"></span></th>
            <th width="117">Design No</th>
            <th width="104">Weight</th>
            <th width="124">Image</th>
            </tr>
            </thead>
            <tbody>
            <?php
			$loop=1;
			if(isset($_GET['dat']))
			{
			//$SLCT = "SELECT * FROM (SELECT casting_finishing.cast_weight AS sol_wght,design_det.design_det_id,design_det.master_cat_id,design_det.design_no,design_det.mas_fin_ext,design_det.cad_fin_ext,design_det.imag_ext FROM casting_finishing,design_det WHERE casting_finishing.cas_fin_status = 'no' AND STR_TO_DATE(casting_finishing.finishing_date,'%d-%m-%Y')<=STR_TO_DATE('$dat','%d/%m/%Y') AND design_det.design_det_id = casting_finishing.design_det_id AND design_det.statu_s='active' AND design_det.up_status='no' AND casting_finishing.up_status='no' ORDER BY casting_finishing.design_det_id ASC)
				//	UNION ALL (SELECT silver_finishing.silver_weight AS sol_wght,design_det.design_det_id,design_det.master_cat_id,design_det.design_no,design_det.mas_fin_ext,design_det.cad_fin_ext,design_det.imag_ext FROM silver_finishing,design_det WHERE silver_finishing.to_solder_load = 'no' AND STR_TO_DATE(silver_finishing.finishing_date,'%d-%m-%Y')<=STR_TO_DATE('$dat','%d/%m/%Y') AND design_det.design_det_id = silver_finishing.design_det_id AND design_det.statu_s='active' AND design_det.up_status='no' ORDER BY silver_finishing.design_det_id ASC)";
			$SLCT = "SELECT * FROM (SELECT CF.cast_weight AS tot_wgt, DD.design_det_id, DD.master_cat_id, DD.design_no, DD.mas_fin_ext, DD.cad_fin_ext, DD.imag_ext FROM casting_finishing AS CF,design_det AS DD WHERE CF.cas_fin_status = 'no' AND STR_TO_DATE(CF.finishing_date,'%d-%m-%Y')<=STR_TO_DATE('$dat','%d/%m/%Y') AND DD.design_det_id = CF.design_det_id AND DD.statu_s='active' AND DD.up_status='no' AND CF.up_status='no' UNION ALL SELECT SF.silver_weight AS tot_wgt, DD.design_det_id, DD.master_cat_id, DD.design_no, DD.mas_fin_ext, DD.cad_fin_ext, DD.imag_ext FROM silver_finishing AS SF,design_det DD WHERE SF.to_solder_load = 'no' AND STR_TO_DATE(SF.finishing_date,'%d-%m-%Y')<=STR_TO_DATE('$dat','%d/%m/%Y') AND DD.design_det_id = SF.design_det_id AND DD.statu_s='active' AND DD.up_status='no') AS TBL2 ORDER BY design_det_id ASC";
			//echo $SLCT;
			$QURY = mysqli_query($connect,$SLCT);
			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_d = "SELECT  * FROM master_cat WHERE master_cat_id = '$FTCH->master_cat_id'";
				$QURY_d = mysqli_query($connect,$SLCT_d);
				$FTCH_d = mysqli_fetch_object($QURY_d);
				
				
			
				if($loop%2 != "0")
					$bg = "gradeX";
				else
					$bg = "class='gradeC'";
				if($FTCH->mas_fin_ext!=''){ $imag = "../mas_fin_images/S.".$FTCH->mas_fin_ext; $imag1 = "../mas_fin_images/L.".$FTCH->mas_fin_ext;  }

				else if($FTCH->cad_fin_ext!=''){ $imag = "../cad_fin_images/S.".$FTCH->cad_fin_ext; $imag1 = "../cad_fin_images/L.".$FTCH->cad_fin_ext; }
				
				else if($FTCH->imag_ext!=''){ $imag = "../design_images/S.".$FTCH->imag_ext; $imag1 = "../design_images/L.".$FTCH->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->design_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->design_no; ?></td>
            <td align="center" style="display:table-cell;vertical-align:middle"><?php echo number_format($FTCH->tot_wgt,2)." g"; ?><input type="hidden" name="sol_wt[<?php echo $FTCH->design_det_id ?>]" id="sol_wt<?php echo $loop ?>" class="mas_weit_tx" value="<?php echo number_format($FTCH->tot_wgt,2); ?>"/></td>
			<td class="center" align="center"><div class="body" align="center">
                	<a href="<?php echo $imag1; ?>" title="<h2><?php echo $FTCH_d->master_cat_name." ".$FTCH->design_no; ?></h2>" class="lightbox" rel="group"><img src="<?php echo $imag; ?>" width="60" height="60"/></a>
                </div></td>
           </tr>
            
            <?php
			$loop ++;
		
			 }
			 }
			}
			 ?>			
				
            </tbody>
            </table> 
            </div>
			</div>
        </div>         
        
       <?php if(mysqli_num_rows($QURY)>0){ ?>
        
        <div class="fluid" style="display:<?php echo $tot_dis ?>">
		<div class="widget">
           <div class="formRow">
           		<span class="grid2">KDM Weight&nbsp;&nbsp;&nbsp;<span style="color:#FF0000">*</span></span>
                <span class="grid4"><input type="text" name="kdm_wgt" id="kdm_wgt" /></span>
                <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 class="clear"></div>
            </div>
        </div>
       
       <?php } ?>
       
        </fieldset>
        </form>
        
        <div class="fluid"><!-- Media table --></div>
<?php } else {  echo ACCESS_MSG;} ?>
    </div>
    <!-- Main content ends -->
    
</div>
<!-- Content ends -->
<?php /*?><?php include "header_footer/footer.php"; ?><?php */?>
</body>
</html>
