ok

Mini Shell

Direktori : /home2/selectio/www/lilyexpresslive/expense-invoice/
Upload File :
Current File : /home2/selectio/www/lilyexpresslive/expense-invoice/vendor-invoice-payment-add.php

<?php  include "header.php"; 
    $ids=$_GET['id'];
    $inv_no=$_GET['inv_no'];
    $statement = $pdo->prepare("SELECT *,c.name,c.gst,c.mobile,c.address,(SELECT sum(amount) FROM `tbl_vendor_invoice_payment` WHERE invoice_id=".$ids.") as total FROM `tbl_vendor_invoice` inv inner JOIN tbl_client c on inv.client_id=c.id  where inv.id=".$ids);
    $statement->execute();
    $inv_data = $statement->fetchAll(PDO::FETCH_ASSOC);
    $totalData = $statement->rowCount();
    
    
    if(isset($_POST['add_invoice_payment'])){
        try{
            $date = date('Y-m-d h:i:s', time());
            
            
            
                        for($n=0;$n<sizeof($_POST['amount']);$n++){
                            $statement = $pdo->prepare("INSERT INTO `tbl_vendor_invoice_payment`(`invoice_id`, `amount`, `type`, `paid_method`, `paid_date`) VALUES (?,?,?,?,?)");
                            $result=$statement->execute(array($ids,$_POST['amount'][$n],1,$_POST['payment_method'][$n],$_POST['date'][$n]));
                        }
                        for($n=0;$n<sizeof($_POST['reduction_item_name']);$n++){
                            $statement = $pdo->prepare("INSERT INTO `tbl_vendor_invoice_payment`(`invoice_id`, `amount`, `type`, `paid_method`, `paid_date`) VALUES (?,?,?,?,?)");
                            $result=$statement->execute(array($ids,$_POST['reduction_item_amount'][$n],2,$_POST['reduction_item_name'][$n],$date));
                        }
            
                    if(isset($_POST['update_amount'])){    
                        for($n=0;$n<sizeof($_POST['update_amount']);$n++){
                            $statement = $pdo->prepare("UPDATE `tbl_vendor_invoice_payment` set amount=?, paid_method=?, paid_date=? where id=?");
                            $result=$statement->execute(array($_POST['update_amount'][$n],$_POST['update_amount_payment_method'][$n],$_POST['update_amount_date'][$n],$_POST['update_payment_id'][$n]));
                        }
                    } 
                    if(isset($_POST['update_reduction_item_id'])){    
                        for($n=0;$n<sizeof($_POST['update_reduction_item_id']);$n++){
                             $statement = $pdo->prepare("UPDATE `tbl_vendor_invoice_payment` set amount=?, paid_method=? where id=?");
                            $result=$statement->execute(array($_POST['update_reduction_item_amount'][$n],$_POST['update_reduction_item_name'][$n],$_POST['update_reduction_item_id'][$n]));
                        }
                    } 
        
                    
                    if($result){
                        $message = 'Invoice Payment is Updated successfully!';
                        unset($_POST);      
                    }else{
                        $warning="Something went wrong try again...";
                    }  
                }catch(Exception $e){
                    $error=$e;
                }   
    }
    
    
    if($inv_data[0]['total']==''){
        $rem=$inv_data[0]['invoice_amount'];
    }else{
        $rem=$inv_data[0]['invoice_amount']-$inv_data[0]['total'];
    }
?>
<div class="content-wrapper" style='background: white;'>
        <section class="content-header">
            <center>
                <a  href="vendor-invoice-payment.php?id=<?=$ids?>&inv_no=<?=$inv_no?>" class="btn btn-info btn-sm "><i class="fa fa-chevron-left"></i> Back to Invoice Payment Histry</a>
            </center>
        </section>
        
         <div class="col-lg-12 alerts">
            <div id="custom-alerts" style="display:none;">
                <div class="alert alert-dismissable">
                    <div class="custom-msg"></div>
                </div>
            </div>
            <?php if ($error)  { ?>
            <div class="alert alert-danger alert-dismissable">
                <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
                <h4><i class="icon fa fa-ban"></i> Error</h4>
                <?= $error; ?>
            </div>
            <?php $error=0;} if ($warning) { ?>
            <div class="alert alert-warning alert-dismissable">
                <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
                <h4><i class="icon fa fa-warning"></i> warning</h4>
                <?= $warning; ?>
            </div>
            <?php  $warning=0;} if ($message) { ?>
            <div class="alert alert-success alert-dismissable">
                <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
                <h4>    <i class="icon fa fa-check"></i> Success</h4>
                <?= $message; ?>
            </div>
            <?php $message=0; } ?>
        </div>
        <div class="clearfix"></div>
        
    <section class="content">
        <div class="row">
        <div class="col-xs-12">
            <div >
                
                
                
                
                
    <form action="" enctype="multipart/form-data" method="post" accept-charset="utf-8">            
                
                 <div class="col-md-12" >
                     <center style="padding:5px;"><b style="font-size:16px;">INVOICE PAYEMENT DETAILS</b></center>
            <table width="100%" style="font-weight:600;font-size:14px;padding-left:10%;padding-right:10%;">
                <tr>
                    <td width="50%" style="padding:2px;border:1px solid black;padding:2px;">
                        To,<br>
                        <? if($inv_data[0]['name']!="") {echo $inv_data[0]['name']."<br>"; }?>
                        <? if($inv_data[0]['address']!="") {echo nl2br($inv_data[0]['address'])."<br>"; }?>
                        
                        <? if($inv_data[0]['gst']!="") {echo "<b>GST NO : </b>".$inv_data[0]['gst']."<br>"; }?>
                    </td>
                    <td width="50%" style="vertical-align:top;padding:2px;border:1px solid black;padding:2px;">
                        <table width="100%" style="font-weight:600;font-size:14px;">
                            <tr>
                                <td width="40%" style="padding:2px;">Invoice Number</td><td>: <?=$inv_data[0]['inv_no']?></td>
                            </tr>
                            <tr>
                                <td width="40%" style="padding:2px;">Period</td><td>: <?=$inv_data[0]['period']?></td>
                            </tr>
                            <tr>
                                <td width="40%" style="padding:2px;">Invoice Date</td><td>: <?=date("d-M-Y", strtotime($inv_data[0]['date']))?></td>
                            </tr><tr>
                                <td width="40%" style="padding:2px;">GST IN No</td><td>: 29ALUPM9087C1ZB</td>
                            </tr>
                            <tr>
                                <td width="40%" style="padding:2px;">PAN NO</td><td>: ALUPM9087C</td>
                            </tr>
                            <tr>
                                <td width="40%" style="padding:2px;">HSN CODE</td><td>: 996812</td>
                            </tr>
                        </table>
                        
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <table style="width:100%;font-weight:bold;">
                            <tr>
                                <td style="padding:2px;padding-left: 5%;text-align:right;">Total Amount : </td>
                                <td style="padding-right:10px;padding:2px;"><?=number_format((float)$inv_data[0]['invoice_amount'], 2, '.', '')?></td>
                            </tr>
                <?php if($inv_data[0]['tax_type']==1){ ?>
                             <tr>
                    <td  style="padding:2px;text-align:right;padding-left: 5%;">GST <?=$inv_data[0]['gst_percentage']?>% : </td>
                    <td style="padding-right:10px;padding:2px;"><?=number_format((float)($inv_data[0]['invoice_amount']*$inv_data[0]['gst_percentage']/100), 2, '.', '')?></td>
                </tr>
                <?php }else{ ?>
                <tr>
                    <td  style="text-align:right;padding:2px;padding-left: 5%;">IGST <?=$inv_data[0]['gst_percentage']?>% : </td>
                    <td style="padding-right:10px;padding:2px;"><?=number_format((float)($inv_data[0]['invoice_amount']*$inv_data[0]['gst_percentage']/100), 2, '.', '')?></td>
                </tr>
                <?php } ?>
                 <tr>
                    <td  style="text-align:right;padding:2px;padding-left: 5%;">Total Amount (Inc Tax) : </td>
                    <td style="padding-right:10px;padding:2px;"><?=number_format((float)$inv_data[0]['final_amount'], 2, '.', '')?></td>
                </tr>
                <tr>
                    <td style="text-align:right;padding:2px;padding-left: 5%;">Grand Total : </td>
                    <td style="padding-right:10px;"><?=number_format((float)round($inv_data[0]['final_amount']), 2, '.', '')?></td>
                </tr>
                        </table>
                    </td>
                </tr>
            </table><br>
<div class="col-md-6" > 
            <center><b style='font-size: 16px;color: crimson;'>Update Payment Info</b></center>
            <?php          
    $statement = $pdo->prepare("SELECT * FROM tbl_vendor_invoice_payment e where e.invoice_id=".$ids." and e.type=1");
    $statement->execute();
    $item_data = $statement->fetchAll(PDO::FETCH_ASSOC);
    $totalData = $statement->rowCount();
    if($totalData>0){
    foreach($item_data as $item){
    ?>
     <div class="col-md-3">
                                <div class="form-group">
                                    <label class="required" for="role">Amount</label>  
                                    <input type="text" name="update_payment_id[]" value="<?=$item['id']?>" hidden>
                                    <input type="text" name="update_amount[]" min="1" value="<?=$item['amount']?>" onchange="calculatetaxamount()" onkeyup="calculatetaxamount()"  placeholder="Enter the Amount" class="form-control tip inv_amount" id="amount"  onkeypress="return isNumberKey(this, event);" required="required" />
                                </div>
                </div>
                <div class="col-md-4">
                                <div class="form-group">
                                    <label class="required" for="role">Payment Mode</label>                                 
 <select class="form-control tip " id="payment_method" name="update_amount_payment_method[]" required>
                                        <option value="Cash" <?php if($item['payment_method']=="Cash"){ echo "selected";} ?>>Cash</option>
                                        <option value="UPI Transfer" <?php if($item['payment_method']=="UPI Transfer"){ echo "selected";} ?>>UPI Transfer</option>
                                        <option value="Acc Transfer" <?php if($item['payment_method']=="Acc Transfer"){ echo "selected";} ?>>Acc Transfer</option>
			                </select>
                                </div>
                </div>
                 <div class="col-md-3">
                    <div class="form-group">
                        <label for="role">Date</label> <br>
                           <input type="date" name="update_amount_date[]" value="<?=$item['paid_date']?>"  class="form-control" id="date" required="required" />
                    </div>
                </div>
                <div class="col-md-2">
                    <div class="form-group">
                        <label for="role">&nbsp;</label> <br>
                        <a title="" onclick="delete_item(<?=$item['id']?>)" class='btn btn-danger btn-sm' style="cursor: pointer;"><i class="fa fa-trash-o"> <b style='font-size:16px;'></b></i></a>
                        </div>
                 </div>
                
    <?php }}else{ ?>
                <div class="col-md-4">
                                <div class="form-group">
                                    <label class="required" for="role">Amount</label>   
                                    <input type="text" name="amount[]" min="1" value="0" onchange="calculatetaxamount()" onkeyup="calculatetaxamount()"  placeholder="Enter the Amount" class="form-control tip inv_amount" id="amount"  onkeypress="return isNumberKey(this, event);" required="required" />
                                </div>
                </div>
                <div class="col-md-4">
                                <div class="form-group">
                                    <label class="required" for="role">Payment Mode</label>                                 
 <select class="form-control tip " id="payment_method" name="payment_method[]" required>
                                        <option value="">Select Payment  Mode</option>
                                        <option value="Cash">Cash</option>
                                        <option value="UPI Transfer">UPI Transfer</option>
                                        <option value="Acc Transfer">Acc Transfer</option>
			                </select>
                                </div>
                </div>
                 <div class="col-md-4">
                    <div class="form-group">
                        <label for="role">Date</label> <br>
                           <input type="text" name="date[]" value="<?=date("Y-m-d")?>"  class="form-control datetimepicker" id="date" required="required" />
                    </div>
                </div>
    <?php }?>
            <div class="row"  id="variations">
    
            </div>
            <center> <a id="add_packate_variation" title="Add New Item" style="cursor: pointer;"><i class="fa fa-plus-square-o fa-2x"> <b style='font-size:16px;'></b></i></a></center>
           
</div>

<div class="col-md-6" > 
            <center><b style='font-size: 16px;color: crimson;'>Update Reduction Info</b><br>
            <?php          
    $statement = $pdo->prepare("SELECT * FROM tbl_vendor_invoice_payment e where e.invoice_id=".$ids." and e.type=2");
    $statement->execute();
    $item_data = $statement->fetchAll(PDO::FETCH_ASSOC);
    $totalData = $statement->rowCount();
    if($totalData>0){
    foreach($item_data as $item){
    ?>
    <div class="col-md-6">
                                <div class="form-group">
                                    <label class="required" for="role">Description</label> 
                                    <input type="text" name="update_reduction_item_id[]" value="<?=$item['id']?>" hidden>
                                    <input type="text" name="update_reduction_item_name[]" value="<?=$item['paid_method']?>" class="form-control tip" placeholder="item Description" required="required">
                                </div>
                </div>
                <div class="col-md-3">
                                <div class="form-group">
                                    <label class="required" for="role">Amount</label>                               
                                    <input type="text"  name="update_reduction_item_amount[]" value="<?=$item['amount']?>" onchange="calculatetaxamount()" onkeyup="calculatetaxamount()" class="form-control tip reduction_item_amount" id="amount1"  onkeypress="return isNumberKey(this, event);" required="required" placeholder="Enter Invoice Amount" />
                                </div>
                </div>
                <div class="col-md-2">
                    <div class="form-group">
                        <label for="role">&nbsp;</label> <br>
                        <a title="" onclick="delete_item(<?=$item['id']?>)" class='btn btn-danger btn-sm' style="cursor: pointer;"><i class="fa fa-trash-o"> <b style='font-size:16px;'></b></i></a>
                        </div>
                 </div>
             
     <?php }} ?>       
            <div class="row"  id="variationss">
    
            </div>
           <center><a id="add_packate_variations" title="Add New Item" style="cursor: pointer;"><i class="fa fa-plus-square-o fa-2x"> <b style='font-size:16px;'></b></i></a> </center>
              </center>
</div> 
  </div>
  <center><b>Total Invoice Amount : <span id="total_inv_amt"><?=number_format((float)round($inv_data[0]['final_amount']), 2, '.', '')?></span></b><br>
  <b>Total Paid Amount : <span id="total_paid_amt">0.00</span></b><br>
  <b>Total Reduction Amount : <span id="total_reduction_amt">0.00</span></b><br>
  <b>Total Remaining Amount : <span id="total_remain_amt">0.00</span></b><br>
  </center>
  <br><br><br>
 <div class="form-group" style="text-align:center;">
                            <input type="submit" name="add_invoice_payment" value="Update Invoice Payment"  class="btn btn-success" />
                        </form>
                        </div>
           
                
                

            </div>
        </div>
    </div>
    </section>
</div>


<script>
    $(document).on('click', '.remove_variation', function() {
        $(this).closest('.rows').remove();
        calculation_final_amt();
    });
    
    $(document).on('click', '.remove_variations', function() {
        $(this).closest('.rowss').remove();
        calculation_final_amt();
    });
    
    $(document).ready(function() { 
        calculatetaxamount();
    });
    
    function calculatetaxamount(){
          calculation_final_amt();
    }
    
    function delete_item(id){
          let text = "If Confirm you want to Delete this row!";
              if (confirm(text) == true) {
                 $.ajax({
                    type: 'POST',
                    url: 'api/delete.php',
                    data: {type:'invoice_payment_delete',delete_id:id},                  
                    success: function(response) {
                        console.log(response); 
                        location.reload();
                    }
                });
              } 
    }
    
    function calculation_final_amt(){
        var inv_amount = 0;
            $('.inv_amount').each(function(){
                inv_amount += parseFloat(this.value);
            });
        $('#total_paid_amt').text(inv_amount);
        
         var reduction_item_amount = 0;
            $('.reduction_item_amount').each(function(){
                reduction_item_amount += parseFloat(this.value);
            });
        $('#total_reduction_amt').text(reduction_item_amount);
        
        
        $('#total_remain_amt').text(<?=$inv_data[0]['final_amount']?>-(reduction_item_amount+inv_amount));
 
    }
    
    $('#add_packate_variation').on('click', function() {
        html ='<div class="rows">'+
                '<div class="col-md-3">'+
                                '<div class="form-group">'+
                                    '<label class="required" for="role">Amount</label>  '+ 
                                    '<input type="text" name="amount[]"  min="1" value="0" onchange="calculatetaxamount()" onkeyup="calculatetaxamount()"  placeholder="Enter the Amount" class="form-control tip inv_amount" id="amount"  onkeypress="return isNumberKey(this, event);" required="required" />'+
                                '</div>'+
                '</div>'+
                '<div class="col-md-4">'+
                                '<div class="form-group">'+
                                    '<label class="required" for="role">Payment Mode</label>'+                              
 '<select class="form-control tip " id="payment_method" name="payment_method[]" required>'+
                                        '<option value="">Select Payment  Mode</option>'+
                                        '<option value="Cash">Cash</option>'+
                                        '<option value="UPI Transfer">UPI Transfer</option>'+
                                        '<option value="Acc Transfer">Acc Transfer</option>'+
			                '</select>'+
                                '</div>'+
                '</div>'+
                 '<div class="col-md-4">'+
                    '<div class="form-group">'+
                        '<label for="role">Date</label> <br>'+
                           '<input type="date" name="date[]" value="<?=date("Y-m-d")?>"  class="form-control datetimepicker" id="date" required="required" />'+
                   '</div>'+
                '</div>'+
                '<div class="col-md-1"><div class="form-group"><br><a class="remove_variation text-danger" title="Remove variation of product" style="cursor: pointer;"><i class="fa fa-times fa-2x"></i></a></div></div></div>';
        $('#variations').append(html);
    });
    
    $('#add_packate_variations').on('click', function() {
        html ='<div class="rowss">'+
                '<div class="col-md-6">'+
                                '<div class="form-group">'+
                                    '<label class="required" for="role">Description</label>'+   
                                    '<input type="text" name="reduction_item_name[]" class="form-control tip" placeholder="item Description" required="required">'+
                                '</div>'+
                '</div>'+
                '<div class="col-md-3">'+
                                '<div class="form-group">'+
                                    '<label class="required" for="role">Amount</label>  '+                               
                                    '<input type="text"  name="reduction_item_amount[]" value="0" onchange="calculatetaxamount()" onkeyup="calculatetaxamount()" class="form-control tip reduction_item_amount" id="amount1"  onkeypress="return isNumberKey(this, event);" required="required" placeholder="Enter Invoice Amount" />'+
                                '</div>'+
                '</div>'+
                '<div class="col-md-1"><div class="form-group"><br><a class="remove_variations text-danger" title="Remove variation of product" style="cursor: pointer;"><i class="fa fa-times fa-2x"></i></a></div></div></div>';
        $('#variationss').append(html);
    });
</script>

<script type="text/javascript">
    $(document).ready(function() { 
        
    });
    
    function isNumberKey(txt, evt) {
      var charCode = (evt.which) ? evt.which : evt.keyCode;
      if (charCode == 46) {
        //Check if the text already contains the . character
        if (txt.value.indexOf('.') === -1) {
          return true;
        } else {
          return false;
        }
      } else {
        if (charCode > 31 &&
          (charCode < 48 || charCode > 57))
          return false;
      }
      return true;
    }
</script>
<?php
    include "footer.php";?>

Zerion Mini Shell 1.0