<?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>

<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="js/buf_loading_add_JS.js"></script>
<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>

<script type="text/javascript"> <!--THIS IS FOR CALCULATING TOTAL QTY AND DISPLAY IN THE TABLE HEADER-->
function get_tot_qty()
{
	var tot_qty = document.getElementById('tot_qty').value;
	document.getElementById('cnt_chk').value = tot_qty;
}
</script>

</head>

<body onload="document.getElementById('addpage').focus(),get_tot_qty();">

<!-- 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:">Buffing 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="buf_loading_add.php" id="addpage" title="Add Buffing Loading" 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="#" title="Check statistics" class="tipN"><img src="images/icons/middlenav/stats.png" alt="" /></a></li>-->
    	</ul>            
    
    	<!-- Chart --><!-- 6 + 6 -->

    	<div class="widget"> <!--style="width:600px; margin-left:150px;"-->
        <div class="whead"><h6>Buffing Loading List</h6><h6 style="float:right; margin-right:50px">Total Quantity : <input type="text" id="cnt_chk" name="cnt_chk" value="" readonly="readonly" disabled="disabled" style="width:50px; font-size:12px; text-align:center;" /></h6><div class="clear"></div></div>
        <div id="dyn" class="hiddenpars">
        	<a href="javascript:0" id="searchlink" onfocus="foc(this.id)" onblur="stnon(this.id)" class="tOptions" title="Options"><img src="images/icons/options.png" alt="" /></a>
            <table cellpadding="0" cellspacing="0" border="0" class="dTable" id="dynamic">
            <thead>
            <tr>
            <th width="26" align="center">S.No<span class="sorting" style="display: block;"></span></th>
            <th width="85" align="center">Loading Date</th>
            <th width="98" align="center">Loading Quantity</th>
            <th width="98" align="center">No of Master</th>
            <th width="98" align="center">Loading Weight</th>
            <th width="92" align="center">Pending Quantity</th>
            <th width="98" align="center">No of Master Pend</th>
            <th width="78" align="center">Pending Weight</th>
            <th width="93" align="center">View</th>
            <th width="61" align="center">Print</th>           
            </tr>
            </thead>
            <tbody>
            <?php
			$tot_qty = 0;
			$page_id= base64_encode(base64_encode(base64_encode(2))); //THIS IS FOR PAGE IDENTIFICATION IN BL FILE for active inactive
			
			$SLCT = "SELECT * FROM buf_loading GROUP BY loading_date ORDER BY STR_TO_DATE(`loading_date`,'%d-%m-%Y') DESC";
			//echo $SLCT;
			$QURY = mysqli_query($connect,$SLCT);
			$loop=1;
			$em_id="";
			if(mysqli_num_rows($QURY)>0)
			{			
			while($FTCH = mysqli_fetch_object($QURY))
			{
				
				$ddt	=	base64_encode(base64_encode(base64_encode($FTCH->loading_date)));
				
				$SLCT_t = "SELECT COUNT(buf_loading_id) AS tot_cnt, SUM(buf_weight) AS tot_wtt, SUM(master_pieces) AS mas_pic FROM buf_loading,design_det WHERE loading_date = '$FTCH->loading_date' AND design_det.design_det_id=buf_loading.design_det_id";				//echo $SLCT_t;
				$QURY_t = mysqli_query($connect,$SLCT_t);
				$FTCH_t = mysqli_fetch_object($QURY_t);
				
				$SLCT_d = "SELECT COUNT(sol_finishing_des_id) AS pen_cnt ,SUM(tot_weight) AS tot_wtt, IFNULL(SUM(master_pice),0) AS mas_pic FROM sol_finishing,sol_finishing_des WHERE sol_finishing.sol_finishing_id=sol_finishing_des.sol_finishing_id AND sol_fin_status = 'no' AND finishing_date = '$FTCH->loading_date'";
				//echo $SLCT_d;
				$QURY_d = mysqli_query($connect,$SLCT_d);
				$FTCH_d = mysqli_fetch_object($QURY_d);
				
				if($loop%2 != "0")
					$bg = "gradeX";
				else
					$bg = "class='gradeC'";
			?>
            <tr <?php echo $bg ?>>
            <td align="center" style="vertical-align:middle;"><?php echo $loop ?></td>
            <td align="center" style="vertical-align:middle;"><?php echo str_replace("-", "/", $FTCH->loading_date); ?></td>
            <td align="center" style="vertical-align:middle;"><?php echo $FTCH_t->tot_cnt; ?></td>
            <td align="center" style="vertical-align:middle;"><?php echo $FTCH_t->mas_pic; ?></td>
            <td align="center" style="vertical-align:middle;"><?php echo number_format($FTCH_t->tot_wtt,2)." g"; ?></td>
            <td align="center" style="vertical-align:middle;"><?php echo $FTCH_d->pen_cnt; ?></td>
            <td align="center" style="vertical-align:middle;"><?php echo $FTCH_d->mas_pic; ?></td>
            <td align="center" style="vertical-align:middle;"><?php echo number_format($FTCH_d->tot_wtt,2)." g"; ?></td>
            <td class="center" style="vertical-align:middle;"><a href="buf_loading_view.php?fin_dt=<?php echo $ddt; ?>" class="an_own" id="viewlink<?php echo $loop ?>" onfocus="foc(this.id)" onblur="stnon(this.id)">View</a></td>
           	<td align="center" style="vertical-align:middle;"><a href="javascript:0;"><span class="dataNumRed" style="margin-right:30%" onclick="each_imag_print('<?php echo base64_encode(base64_encode(base64_encode(17)))?>','<?php echo $ddt; ?>','0','0');">Print</span></a></td>
            </tr>
            
            <?php
			$tot_qty = $tot_qty + $FTCH_t->tot_cnt;
			$loop ++;
			 }
			 }
			 ?>
            </tbody>
            </table> 
			<input id="tot_qty" name="tot_qty" type="hidden" value="<?php echo $tot_qty; ?>" />
        </div>
        </div>    
        
        <div class="fluid"><!-- Media table --></div>
        
        
        
    </div>
    <!-- Main content ends -->
    
</div>
<!-- Content ends -->
<?php /*?><?php include "header_footer/footer.php"; ?><?php */?>
</body>
</html>
