<?php include 'header.php';?>
<script>

      $(document).on('change',".gstinnumber", function(){    

        var inputvalues = $(this).val();

        var gstinformat = new RegExp('^[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$');

        

        if (gstinformat.test(inputvalues)) {

         return true;

        } else {

            alert('Please Enter Valid GSTIN Number');

            $(".gstinnumber").val('');

            $(".gstinnumber").focus();

        }

        

    });
 
	 



    </script>
<?php $querylogin = "select * from  mst_users where user_name = '". $_SESSION["LOGIN_NAME"]."' AND password = '".$_SESSION["EMPLOYEE_PASSWORD"]."'";

$resultlogin = mysqli_query($conn,$querylogin);

while($row=mysqli_fetch_array($resultlogin))

{

$user_name = $row['user_name'];

$user_id = $row['user_id'];

$first_name = $row['first_name'];

 $login_type_admin=$row['login_type']; 

}

$query1 = "select * from authority_staff_module where user_id='$user_id' and module_name='CUSTOMER' ";

$result1 = mysqli_query($conn,$query1);		

while($row=mysqli_fetch_array($result1))

{

$add_authority = $row['add_authority'];

$edit_authority = $row['edit_authority'];

$view_authority=$row['view_authority'];

}

?>
<? 

$queryls = "select * from finish_product_master where product_id = '".$_REQUEST['product_id']."'";
$resultls = mysqli_query($conn,$queryls);	
while($row=mysqli_fetch_array($resultls))
{
$product_id=$row['product_id'];
$billing_address=$row['billing_address'];
$bar_size=$row['bar_size'];
$material_name=$row['material_name'];
$item_code=$row['item_code'];
$description=$row['description'];
$bom_weight_kg=$row['bom_weight_kg'];
$bar_size_unit=$row['bar_size_unit'];
$finish_shaft_wt_kg=$row['finish_shaft_wt_kg'];
$old_labour_rate_rs = $row['old_labour_rate_rs'];
$revised_labour_rate_rs = $row['revised_labour_rate_rs'];
$row_id = $row['row_id'];
$difference=$row['difference'];
$add_kw_rate_mail=$row['add_kw_rate_mail'];
$add_bmst_kw_ext_rate=$row['add_bmst_kw_ext_rate'];
$final_i_c_rate=$row['final_i_c_rate'];

$turning_scrap_wt=$row['turning_scrap_wt'];
$category_name=$row['category_name'];
$category_id=$row['category_id'];


$DRAWING_NO=$row['DRAWING_NO'];
$CUT=$row['CUT'];
$FINISH=$row['FINISH'];
$DE=$row['DE'];
$NDE=$row['NDE'];


}



?>

<
<div class="content-page">
<div class="content">
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class="page-header-title">

<button type="button" class="btn btn-dark waves-effect waves-light" onclick="location.href='view_finish_product.php'">BACK </button>

<div class="clearfix"></div>
</div>
</div>
</div>
<form name="chkForm" id="chkForm" action="update_finish_product.php"  method="post" >
<input type="hidden" name="product_id" value="<?php echo $_REQUEST['product_id']?>"/>

<div class="row">
<div class="col-md-12">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">EDIT FINISH PRODUCT </h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-sm-12 col-xs-12">
<div class="m-t-20">
<table class="table table-striped table-bordered dt-responsive nowrap">
<tr style="color:#000000">
<td><strong>Category</strong></td>
<td>

<select name="category_id" class="form-control select2" required>
<option value="<?php echo $category_id?>" selected><?php echo $category_name ?></option>
<?php 
$qrybu = "select * from category_master ";
$rebu = mysqli_query($conn,$qrybu);
while($row=mysqli_fetch_array($rebu))
{
$category_name = $row['category_name'];
$$category_id = $row['category_id'];

?>
<option value="<?php echo $category_id?>"><?php echo $category_name?></option>
<?php }?>
</select>


</td>
</tr>
<tr style="color:#000000">
<td><strong>Material Name Bar Size</strong></td>
<td><select name="row_id" class="form-control select2"><?php if($row_id!=''){
$qry98 = "select * from rowmaterial_master where row_id='$row_id'";
$re98 = mysqli_query($conn,$qry98);
while($row=mysqli_fetch_array($re98))
{
$bar_size = $row['bar_size'];
$row_id = $row['row_id'];
$material_name = $row['material_name'];
}
?>

     <option value="<?php echo $row_id?>" selected="selected"><?php echo $material_name?> , Size - <?php echo $bar_size?></option><?php }else{?>
	 <option value=""  selected="selected">Select Material Name Bar Size</option><?php } ?>
<?php 
$qry97 = "select * from rowmaterial_master ORDER BY row_id ASC";
$re97 = mysqli_query($conn,$qry97);
while($row=mysqli_fetch_array($re97))
{
$bar_size = $row['bar_size'];
$row_id = $row['row_id'];
$material_name = $row['material_name'];
?>
      <option value="<?php echo $row_id?>"><?php echo $material_name?> , Size - <?php echo $bar_size?></option>
      <?php }?>
    </select></td>
</tr>
<tr style="color:#000000">
<td><strong>Item Code</strong></td>
<td><input type="text" class="form-control"  name="item_code" value="<?php echo $item_code?>"/></td>
</tr>

<tr style="color:#000000">
<td><strong>Description</strong></td>
<td><textarea name="description" class="form-control"><?php echo $description?></textarea></td>
</tr>

<tr style="color:#000000">
<td><strong> Unit</strong></td>
<td>

<select name="bar_size_unit" class="form-control select2">
<?php if($bar_size_unit!=''){?><option value="<?php echo $bar_size_unit?>"><?php echo $bar_size_unit?></option><?php }else{?>
<option value="" selected>Select Bar Size</option><?php }?>
<?php 
$qrybu = "select * from bar_unit_master ORDER BY bar_unit ASC";
$rebu = mysqli_query($conn,$qrybu);
while($row=mysqli_fetch_array($rebu))
{
$bar_unit = $row['bar_unit'];
?>
<option value="<?php echo $bar_unit?>"><?php echo $bar_unit?></option>
<?php }?>
</select>
</td>
</tr>
<tr style="color:#000000">
<td><strong>Turning Scrap Weight Unit</strong></td>
<td><input type="text" class="form-control" id="rate"  name="turning_scrap_wt" value="<?php echo $turning_scrap_wt?>"/></td>
</tr>
<tr style="color:#000000">
<td><strong>Finish Shaft Weight</strong></td>
<td><input type="text" class="form-control" id="qty" name="finish_shaft_wt_kg" value="<?php echo $finish_shaft_wt_kg?>"/></td>
</tr>
<tr style="color:#000000">
<td><strong>BOM Weight Kg</strong></td>
<td><input type="text" id="total" class="form-control" readonly="readonly"  name="bom_weight_kg" value="<?php echo $bom_weight_kg?>"/></td>
</tr><script>
$('#rate,#qty').on('input',function(){
    var qty = parseFloat($('#qty').val()) || 0;
	var rate = parseFloat($('#rate').val()) || 0;
    $('#total').val(rate + qty);   
	 
});</script>


<tr style="color:#000000">
<td><strong> Labour Rate RS</strong></td>
<td><input type="text" class="form-control"  name="revised_labour_rate_rs" value="<?php echo $revised_labour_rate_rs?>"/></td>
</tr>


<tr style="color:#000000">
<td><strong>DRAWING NO</strong></td>
<td><input type="text" class="form-control"  name="DRAWING_NO" value="<?php echo $DRAWING_NO?>"/></td>
</tr>
<tr style="color:#000000">
<td><strong> CUT</strong></td>
<td><input type="text" class="form-control"  name="CUT" value="<?php echo $CUT?>"/></td>
</tr>
<tr style="color:#000000">
<td><strong>FINISH</strong></td>
<td><input type="text" class="form-control"  name="FINISH" value="<?php echo $FINISH?>"/></td>
</tr>

<tr style="color:#000000">
<td><strong>DE</strong></td>
<td><input type="text" class="form-control"  name="DE" value="<?php echo $DE?>"/></td>
</tr>

<tr style="color:#000000">
<td><strong>NDE</strong></td>
<td><input type="text" class="form-control"  name="NDE" value="<?php echo $NDE?>"/></td>
</tr>





<tr style="color:#000000">
<td colspan="2"><div align="center">
<button type="submit" class="btn btn-primary waves-effect waves-light"> SAVE </button>
</div></td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>



</div>
</div>
<?php include 'footer1.php';?>
