<?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 vendor_master where vendor_id = '".$_REQUEST['vendor_id']."'";

$resultls = mysqli_query($conn,$queryls);	

while($row=mysqli_fetch_array($resultls))

{ 



$billing_address=$row['billing_address'];
$vendor_name=$row['vendor_name'];
$gst_no=$row['gst_no'];
$email_id=$row['email_id'];
$contractor_name=$row['contractor_name'];
$contact_no=$row['contact_no'];
$product_wise_details=$row['product_wise_details'];
$address=$row['address'];
$product_specification = $row['product_specification'];
$vendor_source = $row['vendor_source'];



}



?>

<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_vendor_details.php'">BACK </button>
<div class="clearfix"></div>
</div>
</div>
</div>
<form name="chkForm" id="chkForm" action="update_vendor.php"  method="post" >
<input type="hidden" name="vendor_id" value="<?php echo $_REQUEST['vendor_id']?>"/>
<div class="row">
<div class="col-md-12">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">View Vendor </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 width="238">Vendor Name </td>
<td width="246"><input type="text" class="form-control"  name="vendor_name" value="<?php echo $vendor_name?>" ></td>
</tr>
<tr style="color:#000000">
<td>Vendor Source</td>
<td><input type="text" class="form-control"  name="vendor_source" value="<?php echo $vendor_source?>" ></td>
</tr>
<tr style="color:#000000">
<td>Address</td>
<td><textarea name="address" class="form-control"><?php echo $address?></textarea></td>
</tr>



<tr style="color:#000000">
<td>GST NO</td>
<td><input type="text" class="form-control"  name="gst_no" value="<?php echo $gst_no?>"/></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 class="row">
<div class="col-md-12">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Supply Products<a href="add_vendor_product.php?vendor_id=<?php echo $_REQUEST['vendor_id'];?>" class="btn btn-primary waves-effect waves-light" style="float:right;">Add More Products</a></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>
<td>Sr No </td>
<td>Product Name </td>
<td>Specification</td>
<td>Unit</td>
<td>Price</td>
<td>Action</td>
<td>Delete</td>
</tr>
<?php $i=1;
$querybill = "select * from  vendor_product_master where vendor_id = '".$_REQUEST['vendor_id']."'";
$resultbill = mysqli_query($conn,$querybill);	
while($row=mysqli_fetch_array($resultbill))
{
$product_name = $row['product_name'];
$product_details = $row['product_details'];
$unit = $row['unit'];
$price = $row['price'];
$product_id = $row['vproduct_id'];

?>
<tr>
<td><?php echo $i?></td>
<td><?php echo $product_name?></td>
<td><?php echo wordwrap($product_details,25,"<br>\n");?></td>
<td><?php echo $unit?></td>
<td><?php echo $price?></td>
<td><button type="submit" class="btn btn-danger btn-xs waves-effect waves-light" onclick="location.href='edit_vendor_product.php?vendor_id=<?php echo $_REQUEST['vendor_id']?>&&product_id=<?php echo $product_id?>'"> EDIT </button></td>
<td><button type="submit" class="btn btn-dark btn-xs waves-effect waves-light" onclick="location.href='delete_vendor_product.php?vendor_id=<?php echo $_REQUEST['vendor_id']?>&&vproduct_id=<?php echo $product_id?>'"> DEL </button></td>
</tr>
<?php $i++; } ?>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>




<div class="row">
<div class="col-md-12">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Kind Attention<a href="add_vcontact.php?vendor_id=<?php echo $_REQUEST['vendor_id'];?>" class="btn btn-primary waves-effect waves-light" style="float:right;">Add Contact</a></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">
<? 

$querycontact = "select * from vendor_contact where vendor_id = '".$_REQUEST['vendor_id']."'";
$resultcontact = mysqli_query($conn,$querycontact);	
while($row=mysqli_fetch_array($resultcontact))
{
$contact_name = $row['contact_name'];
$mobile_no = $row['mobile_no'];
$email_id = $row['email_id'];
$contact_id  = $row['contact_id'];

?>
<form name="chkForm" id="chkForm" action="update_vcontact.php"  method="post" >
<input type="hidden" name="contact_id" value="<?php echo $contact_id?>"/>
<input type="hidden"  name="vendor_id" value="<?php echo $_REQUEST['vendor_id']?>"/>
<tr style="color:#000000">
<td><strong>Contact Person Name</strong></td>
<td><input type="text" class="form-control"  name="contact_name" value="<?php echo $contact_name?>"/></td>
</tr>
<tr style="color:#000000">
<td><strong>Mobile no.</strong></td>
<td><input type="text" class="form-control"  name="mobile_no" value="<?php echo $mobile_no?>"/></td>
</tr>
<tr style="color:#000000">
<td><strong>Email</strong></td>
<td><input type="text" class="form-control"  name="email_id" value="<?php echo $email_id?>"/></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></td>
</tr>
</form>
<?php } ?>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>






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