<?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/buf_finishing_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" />
<!--[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="#">Dashboard</a></li>
                <li><a href="javascript:">Buffing Finishing</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="buf_finishing_list.php" id="listpage" title="List Buffing Finishing" 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/buf_finishing_BL.php?page_id=<?php echo $page_id; ?>" onsubmit="checkTheBox();">
         <fieldset>
        <div class="fluid">
		<div class="widget">

        <div class="formRow">
            <div class="grid3"><label>Buffing Worker:<span class="req">*</span></label></div>
            <div class="grid6 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('(^|,)(',6,')(,|$)')) and statu_s='active'"; //HERE THE 7 IS REPRESENTS Buffing 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>
            <div class="clear"></div>
        </div>

        <div class="formRow">
            <div class="grid3"><label>Finishing Date:<span class="req">*</span></label></div>
            <div class="grid9"><input type="text" value="<?php echo $dat;?>" name="lob" id="lob" class="datepicker" onchange="reload_page();"/></div><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>Buffing Finishing 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>
            <th width="20"><img src="images/elements/other/tableArrows.png" alt="" /></th>
            <th width="113">S.No<span class="sorting" style="display: block;"></span></th>
            <th width="134">Design No</th>
            <th width="134">No of Master</th>
            <th width="135">Loading Weight</th>
            <th width="135">Finish Weight</th>
            <th width="135">Westage</th>
            <th width="133">Design Status</th>
            <th width="124">Image</th>
           <!-- <th width="71">View</th>
            <th width="149">Status</th>-->
            </tr>
            </thead>
            <tbody>
            <?php
			$loop=1;
			if(isset($_GET['dat']))
			{
			
			$SLCT_de = "SELECT * FROM buf_loading,design_det WHERE buf_loading.buf_status = 'no' AND STR_TO_DATE(buf_loading.loading_date,'%d-%m-%Y')<=STR_TO_DATE('$dat','%d/%m/%Y') AND design_det.design_det_id = buf_loading.design_det_id AND design_det.statu_s='active' AND design_det.up_status='no' ORDER BY buf_loading.design_det_id ASC";
			$QURY_de = mysqli_query($connect,$SLCT_de);
			if(mysqli_num_rows($QURY_de)>0)
			{
			while($FTCH = mysqli_fetch_object($QURY_de))
			{

				$design_id	=	base64_encode(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 align="center" 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 $FTCH->master_pieces ?></td>
            <td align="center" style="display:table-cell;vertical-align:middle"><?php echo number_format($FTCH->buf_weight,2)." g"; ?><input type="hidden" name="lod_wt[<?php echo $FTCH->design_det_id ?>]" id="lod_wt<?php echo $loop ?>" value="<?php echo number_format($FTCH->buf_weight,2); ?>" class="mas_weit_tx"/></td>
            <td align="center" style="display:table-cell;vertical-align:middle"><input type="text" name="fin_wt[<?php echo $FTCH->design_det_id ?>]" id="fin_wt<?php echo $loop ?>" class="mas_weit_tx" onkeyup="wastge_cal(this.value,<?php echo $loop ?>)"/></td>
            <td align="center" style="display:table-cell;vertical-align:middle"><span id="wastg<?php echo $loop ?>">0.00 g</span><input type="hidden" name="wst_wt[<?php echo $FTCH->design_det_id ?>]" id="wst_wt<?php echo $loop ?>" value="" class="mas_weit_tx"/></td>
            <td align="center" style="display:table-cell;vertical-align:middle"><?php echo $FTCH->design_status; ?></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 ++;
		
			 }
			 }
			//}
			}
			 ?>
            <?php /*?><?php if($loop==1){ ?>
            <tr>
              <td colspan="9" align="center">
              <div class="nNote nFailure">
                <p>Oops Sorry No Data Found...</p>
            </div>
              </td>
              </tr>
			<?php } ?>	<?php */?>			
				
            </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">
            <div class="grid3"><label>Usual radio :</label> </div>
            <div class="grid9">
                <input type="radio" id="radio1" name="question1" value="cam" /><label for="radio1"  class="mr20">Cam</label>
                <input type="radio" id="radio2" name="question1" value="rtv" /><label for="radio2"  class="mr20">RTV</label>
                
            </div>
            <div class="clear"></div>
        </div>-->
        
           <div class="formRow">
                <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>
        
        
        
    </div>
    <!-- Main content ends -->
    
</div>
<!-- Content ends -->
<?php /*?><?php include "header_footer/footer.php"; ?><?php */?>
</body>
</html>
