<?php 
$query="SELECT id,name FROM ".$prefix."line ORDER BY name ASC";
$lineType=mysqli_query($linkid,$query);
?>
<div id="contentwrapper">
  <div class="main_content">
    <nav>
      <div id="jCrumbs" class="breadCrumb module">
        <ul>
          <li> <a href="#"><i class="icon-home"></i></a> </li>
          <li> <a href="index.php?tab=production">Timely Production Record</a> </li>
        </ul>
      </div>
    </nav>
    <div class="row-fluid">
      <div class="span12">
        <?php
		          	if(isset($_POST['submit']))
						{				
						for($i=0;$i<count($_POST['linenumber']);$i++)
							{
							//set the value for variable
							$lineno=$_POST['linenumber'][$i];
							$mydate=$_POST['mydate'];
						    $time=$_POST['mytime'];
							
							$lineday=$_POST['lineday'][$i];	
							$sewingday=$_POST['sewingday'][$i];	
							$fqcday=$_POST['fqcday'][$i];
							$getupday=$_POST['getupday'][$i];
							
							$linehourly=$_POST['linehourly'][$i];
							$sewinghourly=$_POST['sewinghourly'][$i];	
							$fqchourly=$_POST['fqchourly'][$i];
							$getuphourly=$_POST['getuphourly'][$i];
							
						    $query = "INSERT INTO ".$prefix."production_record values (null,'$lineno','$mydate','$time','$lineday','$sewingday','$fqcday','$getupday','$linehourly','$sewinghourly','$fqchourly','$getuphourly',CURDATE(),1,'$uid')";
						    $result=mysqli_query($linkid,$query) or die(mysqli_error());
							}		
							/*$lineno=$_POST['lineno'];						
							$lineday=$_POST['lineday'];
							$sewingday=$_POST['sewingday'];	
							$fqcday=$_POST['fqcday'];
							$getupday=$_POST['getupday'];
							
							$linehourly=$_POST['linehourly'];
							$sewinghourly=$_POST['sewinghourly'];	
							$fqchourly=$_POST['fqchourly'];
							$getuphourly=$_POST['getuphourly'];
							
							
							$query = "INSERT INTO ".$prefix."production_record values (null,'$lineno','$mydate','$time','$lineday','$sewingday','$fqcday','$getupday','$linehourly','$sewinghourly','$fqchourly','$getuphourly','$lineoutput','$sewingoutput','$fqcoutput','$getupoutput',CURDATE(),1,'$uid')";
							$result=mysqli_query($linkid,$query) or die(mysqli_error());*/						
							
					}
						if($result){
						?>
        <div class="alert alert-success"> <a data-dismiss="alert" class="close">x</a> <strong>Production Record</strong> is saved.&nbsp;&nbsp;</div>
        <script type="text/javascript" language="javascript">
							  setTimeout(function () {
								 window.location.href= 'index.php?tab=production'; // the redirect goes here
								},3000);
							  </script>
        <?php 
						}
							
					 //unlink($filename1);
					 
						 unset($_POST);
						 $_POST['submit']='';
						 $_POST='';
					?>
        <h3 class="heading">New Production Record</h3>
        <form class="form_validation_reg" id="form_validation_reg" action=""  method="post">
          <div class="formSep">
            <div class="row-fluid">
              <div class="span3">
                <label>DATE<span class="f_req">*</span></label>
                <input type="text" name="mydate" id="mydate" class="span12"  value="<?php echo date('Y-m-d');?>"/>
              </div>
              <div class="span3">
                <label>TIME<span class="f_req">*</span></label>
                <input type="text" name="mytime" id="mytime" class="span12"  value="<?php echo date("h:i:sa");?>"/>
              </div>
            </div>
          </div>
          <?php 
			  if($lineType)
				{
				while($mydata = mysqli_fetch_assoc($lineType))
				{
			  ?>
          <input type="hidden" name="linenumber[]" id="linenumber[]" class="span12" value="<?php echo $mydata['id'];?>"/>
          <div class="formSep">
            <div class="row-fluid">
              <div class="span3">
                <label>LINE NO</label>
                <input type="text" name="lineno[]" id="lineno[]" class="span12" value="<?php echo $mydata['id'];?>" disabled="disabled"/>
              </div>
              
            </div>
          </div>
          <div class="formSep">
            <div class="row-fluid">
              <div class="span2">
                <label>SECTION</label>
              </div>
              <div class="span2">
                <label>LINE ISSUE</label>
              </div>
              <div class="span2">
                <label>SEWING</label>
              </div>
              <div class="span2">
                <label>FQC</label>
              </div>
              <div class="span2">
                <label>GET UP</label>
              </div>
            </div>
          </div>
          <div class="formSep">
            <div class="row-fluid">
              <div class="span2">
                <label>DAY TARGET</label>
              </div>
              <div class="span2">
                <input type="text" name="lineday[]" id="amount1" class="span12"/>
              </div>
              <div class="span2">
                <input type="text" name="sewingday[]" id="amount1" class="span12"/>
              </div>
              <div class="span2">
                <input type="text" name="fqcday[]" id="amount1" class="span12"/>
              </div>
              <div class="span2">
                <input type="text" name="getupday[]" id="amount1" class="span12"/>
              </div>
            </div>
          </div>
          <div class="formSep">
            <div class="row-fluid">
              <div class="span2">
                <label>HOURLY TARGET</label>
              </div>
              <div class="span2">
                <input type="text" name="linehourly[]" id="amount1" class="span12"/>
              </div>
              <div class="span2">
                <input type="text" name="sewinghourly[]" id="amount1" class="span12"/>
              </div>
              <div class="span2">
                <input type="text" name="fqchourly[]" id="amount1" class="span12"/>
              </div>
              <div class="span2">
                <input type="text" name="getuphourly[]" id="amount1" class="span12"/>
              </div>
            </div>
          </div>
          <?php
		   }
		  
		  }
		  ?>
          <div class="form-actions">
            <input class="btn btn-inverse" name="submit" type="submit" value="SAVE TARGET" />
            <button class="btn">Cancel</button>
          </div>
        </form>
      </div>
    </div>
  </div>
</div>
