
<?php include("sass/icon_for_datepicker_and_datatable.php");?>
        
   
        <?php
$errMsg=""; 
if(isset($_POST['submit'])) // To check 'submmited or not' by if(isset($_POST['submit'])) 
{
	
	$bank_id = $_POST['bank_id'];
	$lc_number = $_POST['lc_number'];
	$amount = $_POST['amount'];
	
	$date = $_POST['date'];
	if(!empty($date)) {
$date = date("Y-m-d", strtotime($date));
}
else {
$date = "";
}
	
	if(empty($errMsg))
	{
		$check=mysqli_query($connection,"select * from lc_taka where lc_number='$lc_number'");
		$checkrows=mysqli_num_rows($check);
		if($checkrows=0){$errMsg="Sorry!! No LC Created In This Number.";}
		
		else{
		
	mysqli_query($connection,"UPDATE bank_name_lc SET balance = balance - $amount WHERE bank_id = $bank_id")
				or die(mysqli_error());
		
		mysqli_query($connection,"INSERT INTO transaction (date, ref_id, ledger, debit, bank_id, hint, payment_type) VALUES ('$date','$lc_number','LC Bank Due Payment','$amount','$bank_id','LC Bank Due Payment','b_lc')")
		or die(mysqli_error());
		 
		$errMsg="LC Bank Due Paid successfully";
	}
}
}
?>
<!--For connect database end-->
<?php


$query_product = "SELECT * FROM product_setup";
$result_product = mysqli_query($connection,$query_product);

while($row_product=mysqli_fetch_array($result_product))
{
	$product_id = $row_product['product_id'];
	$product_name = $row_product['product_name'];
	
	
	
	$all_product[] = $product_id."-".$product_name;
}

  ?>

   <script>
  $(function() {
  
  var availableTags = JSON.parse('<?php echo json_encode($all_product); ?>');
  
    
    $( "#tags" ).autocomplete({
      source: availableTags
    });
  });
  </script>         
        
        <div class="wrapper row-offcanvas row-offcanvas-left">
            <!-- Left side column. contains the logo and sidebar -->
            <?php include("sass/sidebar.php");?>

            <!-- Right side column. Contains the navbar and content of the page -->
               <aside class="right-side">
                <!-- Content Header (Page header) -->
                <section class="content-header">
                    <h1>
                       <?php echo $company_name ; ?>
                        <small>Control panel</small>
                    </h1>
                    <ol class="breadcrumb">
                        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
                        <li class="active">Product Setup</li>
                    </ol>
                </section>
                 <section class="content">
                 <!---Main Content--->
                 
                     <div class="row">
                     
                         <div class="col-md-8 col-md-offset-2">
                   
                       
                        <?php
							if (!empty($errMsg))
							{echo "<div class='alert alert-warning alert-dismissible' role='alert'>$errMsg";
							echo "<button type='button' class='close' data-dismiss='alert'><span aria-hidden='false'>&times;</span><span class='sr-only'>		Close</span></button>
                        </div>";}
                        ?>
                        
                         <div class="box box-primary">
                                <div class="box-header">
                                    <h3 class="box-title">LC Bank Due Payment</h3>
                                </div><!-- /.box-header -->
                                <!-- form start -->
                                <form role="form"  action="<?php echo "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; ?>" method="post">
                                    <div class="box-body">
                                      
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">Bank Name</label>
                                            <select name="bank_id" class="form-control">
                                            <option value="">Select</option>
												<?php  
                                                $query_bank = "select * from bank_name_lc";
                                                $result_bank = mysqli_query($connection,$query_bank);
                                                
                                               
                                                while($row_bank=mysqli_fetch_array($result_bank))
                                                {
                                                
                                                echo "<option value='" . $row_bank['bank_id'] . "'>" . $row_bank['bank_name_lc'] . "</option>";}?> 
                                            
                                            </select>
                                        </div>
                                        
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">LC Number</label>
                                            <input type="text" class="form-control" name="lc_number" id="" placeholder="Enter LC Number">
                                        </div>
                                        
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">Amount</label>
                                            <input type="text" class="form-control" name="amount" id="" placeholder="Enter">
                                        </div>
                                       
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">Date</label>
                                            <input type="text" class="form-control datepicker" autocomplete="off" name="date" value="<?php echo date("d-m-Y");?>" placeholder="Enter">
                                        </div>
                                    </div><!-- /.box-body -->

                                    <div class="box-footer">
                                        <button type="submit" name="submit" class="btn btn-primary">Submit</button>
                                    </div>
                                   

  


                                </form>
                            </div>
                         
                         </div>
             
                     
                     </div>
                 
                 
                 
                 
                 </section>
                </aside>
                <!-- /.right-side -->
        </div><!-- ./wrapper -->

        <!-- add new calendar event modal -->

 <script>
function EditProduct(id) {
    window.open('edit_store.php?id='+id,'logos','width=500,height=500');}
</script>

  <!-- jQuery 2.0.2 -->
       
      <?php include("sass/footer_for_datepicker_and_datatable.php");?>

    </body>
</html>