<?php
error_reporting(0);
	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/sol_loading_add_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="document.getElementById('listpage').focus(),document.getElementById('tot_pce').innerHTML=document.getElementById('tot_pieces').value;">

<!-- 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">
    
        <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
		$loading_date	=	base64_decode(base64_decode(base64_decode($_GET['loading_date']))); //THIS IS PAGE ID
		$emp_id	=	base64_decode(base64_decode(base64_decode($_GET['emp_id']))); //THIS IS PAGE ID  
		$ld_tim = base64_decode(base64_decode(base64_decode($_GET['lod_tim']))); 
		$kdm_id	=	base64_decode(base64_decode(base64_decode($_GET['kdm_id'])));
		
		$page_id= base64_encode(base64_encode(base64_encode(1))); //THIS IS FOR PAGE IDENTIFICATION IN BL FILE for add
		
		$SLCT_em = "SELECT * FROM emp_det WHERE emp_det_id = '$emp_id'";
		$QURY_em = mysqli_query($connect,$SLCT_em);
		$FTCH_em = mysqli_fetch_object($QURY_em);
		
		$SLCT_KDM = "SELECT kdm_loading_weight FROM sol_loading_kdm WHERE emp_det_id = '$emp_id' AND sol_loading_kdm_id = '$kdm_id' AND STR_TO_DATE(loading_date,'%d-%m-%Y')= STR_TO_DATE('$loading_date','%d-%m-%Y')";
		$QURY_KDM = mysqli_query($connect,$SLCT_KDM);
		if(mysqli_num_rows($QURY_KDM)>0)
		{
			$FTCH_KDM = mysqli_fetch_object($QURY_KDM);
			$kdm_wght = $FTCH_KDM->kdm_loading_weight;
		}
		else
		{
			$kdm_wght = "0.00";
		}		
		
		?>

    	<!-- 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="widget">
            <div class="whead"><!--<span class="titleIcon check"><input type="checkbox" id="titleCheck" name="titleCheck" /></span>-->
            <h6>Soldering Loading View</h6><h6>Worker Name : <?php echo $FTCH_em->name; ?></h6><h6>Loading Date : <?php echo str_replace("-", "/",$loading_date)." ".$ld_tim; ?></h6><h6>KDM Weight : <?php echo number_format($kdm_wght,2)." g"; ?></h6><h6>Total Pieces : <span id='tot_pce'>0</span></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>
           <!-- <td width="79"><img src="images/elements/other/tableArrows.png" alt="" /></td>-->
            <th width="92" align="center">S.No<span class="sorting" style="display: block;"></span></th>
            <!--<td width="132">Category</td>-->
            <th width="126" align="center">Design No</th>
            <th width="98" align="center">No. of Pieces</th>
            <th width="114" align="center">Loading Weight</th>
            <th width="139" align="center">Image</th>
           <!-- <td width="71">View</td>
            <td width="149">Status</td>-->
           
            </tr>
            </thead>
            <tbody>
            <?php
			
			$tot_pieces = 0;
			$SLCT = "SELECT  * FROM soldering_loading WHERE loading_date = '$loading_date' AND sol_loading_kdm_id = '$kdm_id' AND emp_det_id = '$emp_id' ORDER BY soldering_loading_id ASC";
			//echo $SLCT;
			$QURY = mysqli_query($connect,$SLCT);
			$loop=1;
			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_t = "SELECT * FROM design_det WHERE design_det_id = '$FTCH->design_det_id'";
				$QURY_t = mysqli_query($connect,$SLCT_t);
				//$FTCH_t = mysqli_fetch_object($QURY_t);
				
				$FTCH_t_cnt = mysqli_num_rows($QURY_t);
				if($FTCH_t_cnt>0){
					$FTCH_t = mysqli_fetch_object($QURY_t);
					$master_cat_id	=$FTCH_t->master_cat_id;
					$ftch_t_mas_fin_ext = $FTCH_t->mas_fin_ext;
					$ftch_t_cad_fin_ext = $FTCH_t->cad_fin_ext;
					$ftch_t_imag_ext = $FTCH_t->imag_ext;
					$ftch_t_design_no = $FTCH_t->design_no;
					$ftch_t_up_status = $FTCH_t->up_status;
					$ftch_t_no_of_tm_alt = $FTCH_t->no_of_tm_alt;
					$ftch_t_no_of_pieces = $FTCH_t->no_of_pieces;
				}else {
					$master_cat_id=0;
					$ftch_t_mas_fin_ext = '';
					$ftch_t_cad_fin_ext = '';
					$ftch_t_imag_ext = '';
					$ftch_t_design_no = '';
					$ftch_t_up_status = '';
					$ftch_t_no_of_tm_alt = '';
					$ftch_t_no_of_pieces='';
				}
				
				$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);
				
				$SLCT_ld = "SELECT  * FROM silver_finishing WHERE design_det_id = '$FTCH->design_det_id'";
				$QURY_ld = mysqli_query($connect,$SLCT_ld);
				$FTCH_ld = mysqli_fetch_object($QURY_ld);
			
				if($loop%2 != "0")
					$bg = "gradeX";
				else
					$bg = "class='gradeC'";
					
					if($ftch_t_mas_fin_ext!=''){ $imag = "../mas_fin_images/S.".$ftch_t_mas_fin_ext; $imag1 = "../mas_fin_images/L.".$ftch_t_mas_fin_ext;}

					else if($ftch_t_cad_fin_ext!=''){ $imag = "../cad_fin_images/S.".$ftch_t_cad_fin_ext; $imag1 = "../cad_fin_images/L.".$ftch_t_cad_fin_ext;  }
					
					else if($ftch_t_imag_ext!=''){ $imag = "../design_images/S.".$ftch_t_imag_ext; $imag1 = "../design_images/L.".$ftch_t_imag_ext; }
			?>
            
            <tr <?php echo $bg ?>>
            <?php /*?><td><input type="checkbox" name="category[]" id="<?php echo $loop ?>" value="<?php echo $FTCH->design_det_id ?>" /></td><?php */?>
            <td align="center" style="display:table-cell;vertical-align:middle"><?php echo $loop ?></td>
            <?php /*?><td align="center"><?php echo $FTCH_d->master_cat_name; ?></td><?php */?>
            <td align="center" style="display:table-cell;vertical-align:middle"><?php echo $FTCH_d->master_cat_name." ".$ftch_t_design_no; ?><?php if($ftch_t_up_status=="yes"){ echo " ( Old ".$ftch_t_no_of_tm_alt." )"; } ?></td>
            <td align="center" style="display:table-cell;vertical-align:middle"><?php echo $ftch_t_no_of_pieces;  ?></td>
            <td align="center" style="display:table-cell;vertical-align:middle"><?php echo number_format($FTCH->solder_weight,2)." g"; ?></td>
            <td class="center" style="display:table-cell;vertical-align:middle">
            	<div class="body" align="center">
                	<a href="<?php echo $imag1; ?>" title="<?php echo $FTCH_d->master_cat_name." ".$ftch_t_design_no; ?>" class="lightbox" rel="group"><img src="<?php echo $imag; ?>" width="60" height="60"/></a>
                </div>
           </td>
           </tr>
            
            <?php
			$loop ++;
			$tot_pieces=$tot_pieces+$ftch_t_no_of_pieces;
			 }
			 }
			 ?>
            <?php if($loop==1){ ?>
            <tr>
              <td colspan="10" align="center">
              <div class="nNote nFailure">
                <p>Oops Sorry No Data Found...</p>
            </div>
              </td>
              </tr>
			<?php } ?>				
				
            </tbody>
            </table> 
            </div>
        </div>      
        <input  type="hidden" name="tot_pieces" id="tot_pieces" value="<?php echo $tot_pieces; ?>"/>
        </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>
