ok

Mini Shell

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

<?php  include "header.php";

            $statement = $pdo->prepare("SHOW TABLE STATUS WHERE name = 'tbl_vendor_invoice'");
			$statement->execute();
			$results = $statement->fetchAll(PDO::FETCH_ASSOC);
            
            
            
            $no=sprintf("%03d", $results[0]['Auto_increment']);
            $invoice_num="VENDOR".($no);

if(isset($_POST['add_invoice'])){
        try{
            $date = date('Y-m-d h:i:s', time());
            if(isset($_FILES['logo']['name']) && $_FILES['logo']['name']!=""){
    			$string1 = '0123456789';
    			$file1 = preg_replace("/\s+/", "_", $_FILES['logo']['name']);
    			$extension1 = end(explode(".", $_FILES["logo"]["name"]));
    			$menu_image1 = rand(10,1000000)."-".date("Y-m-d H-i-s") . "." . $extension1;
    
    			// upload new image
    			$upload_logo = move_uploaded_file($_FILES['logo']['tmp_name'], 'vendor-invoice/' . $menu_image1);
    
    			// insert new data to menu table
    			$upload_logo_image = 'vendor-invoice/' . $menu_image1;
            }else{
                $upload_logo_image='vendor-invoice/default-img.png';
            }
            if(isset($_FILES['logo1']['name']) && $_FILES['logo1']['name']!=""){
    			$string1 = '0123456789';
    			$file1 = preg_replace("/\s+/", "_", $_FILES['logo1']['name']);
    			$extension1 = end(explode(".", $_FILES["logo1"]["name"]));
    			$menu_image1 = rand(10,1000000)."-".date("Y-m-d H-i-s") . "." . $extension1;
    
    			// upload new image
    			$upload_logo1 = move_uploaded_file($_FILES['logo1']['tmp_name'], 'vendor-invoice/' . $menu_image1);
    
    			// insert new data to menu table
    			$upload_logo_image1 = 'vendor-invoice/' . $menu_image1;
            }else{
                $upload_logo_image1='vendor-invoice/default-img.png';
            }
            
            
             $statement = $pdo->prepare("SHOW TABLE STATUS WHERE name = 'tbl_vendor_invoice'");
			 $statement->execute();
			 $results = $statement->fetchAll(PDO::FETCH_ASSOC);
            
            $invoice_id=$results[0]['Auto_increment'];
            
            $statement = $pdo->prepare("INSERT INTO `tbl_vendor_invoice`(`inv_no`, `client_id`, `invoice_amount`, `date`, `period`, `year`, `gst_percentage`, `final_amount`, `submitted_status`, `remark`, `tax_type`,`type`,`image_1`,`image_2`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
            $result=$statement->execute(array($_POST['inv_no'],$_POST['client'],$_POST['invoice_amount'],$_POST['inv_date'],$_POST['period'],$_POST['year'],$_POST['tax_percentage'],$_POST['final_amount'],1,' ',$_POST['tax_type'],1,$upload_logo_image,$upload_logo_image1));
                    
                    $invoice_id = $pdo->lastInsertId();
                    if($result){
                      
                        for($n=0;$n<sizeof($_POST['item_description']);$n++){
                            $statement = $pdo->prepare("INSERT INTO `tbl_vendor_invoice_items`(`invoice_id`, `item_name`, `amount`,`type`) VALUES (?,?,?,?)");
                            $result=$statement->execute(array($invoice_id,$_POST['item_description'][$n],$_POST['item_amount'][$n],1));
                        }

                        $message = 'Vendor Invoice is added successfully!';
                        unset($_POST);      
                    }else{
                        $warning="Something went wrong try again...";
                    }  
                }catch(Exception $e){
                    $error=$e;
                }   
    }
    
?>



?>
<div class="content-wrapper">
        <section class="content-header">
            <h1>Add Invoice</h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
                <li class="active">Add Vendor Invoice</li>            </ol>
        </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 class="box box-primary">
                <div class="box-header">
                    <h3 class="box-title">Please fill in the information below</h3>
                </div>
                <div class="box-body">
                    <div class="col-lg-12">

                        <form action="" enctype="multipart/form-data" method="post" accept-charset="utf-8">
                                                                 
                        <div class="row">
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label class="required" for="email">Select Client</label>
                                      <select name="client" class="form-control" style="width:100%" id="client" required="required">
                                        <option value="">Select Client</option>
                                        <?php $statement = $pdo->prepare("SELECT * FROM `tbl_client` where type=2");
                                            $statement->execute();
                                            $location_result = $statement->fetchAll(PDO::FETCH_ASSOC); 
                                            foreach ($location_result as $result) {
                                                echo "<option value=".$result['id'].">".$result['name']."</option>";
                                            }?>
                                    </select>                                                                  
                                </div>
                            </div>
                            <div class="col-md-2">
                                <div class="form-group">
                                    <label class="required" for="location">Invoice Number</label>                                   
                                     <input type="text" name="inv_no" placeholder="Enter Invoice Number" value="<?=$invoice_num?>"  class="form-control tip" id="inv_no"   required="required"/>
                                </div>
                            </div>
                            <div class="col-md-2">
                                <div class="form-group">
                                    <label class="required" for="location">Bill Period</label>                                   
                                    <input type="text" name="period" placeholder="Enter Bill Period" value=""  class="form-control tip" id="period"  required="required" />
                                </div>
                            </div>
                            
                            <div class="col-md-2">
                                <div class="form-group">
                                    <label class="required" for="location">Financial Year</label>                                   
                                     <select name="year" class="form-control select2" id="year" data-placeholder="Payment Method" style="width:100%;">
<option value="">Select Financial Year</option>
<?php for($y=2020;$y<2035;$y++){ $f_y=$y."-".($y+1-2000);?>
<option value="<?=$f_y?>" <?php if(date("Y")==$y){ echo "selected";} ?>><?=$f_y?></option>
<?php } ?>
</select>
                                </div>
                            </div>
                            <div class="col-md-2">
                                <div class="form-group">
                                    <label class="required" for="location">Invoice Date</label>                                   
                                     <input type="text" name="inv_date" placeholder="Select Invoice Date" value="<?=date("Y-m-d")?>"  class="form-control datetimepicker tip" id="inv_date"  required="required" />
                                </div>
                            </div>
                            
                            
                            
                            
                            
 <div class="col-md-12" >
            <center><b style='font-size: 16px;color: crimson;'>Invoice Amount Details Update Or Add Here</b></center>
                <div class="col-md-6">
                                <div class="form-group">
                                    <label class="required" for="role">Description</label>   
                                    <input type="text" name="item_description[]" class="form-control tip" placeholder='item Description' required="required">
                                </div>
                </div>
                <div class="col-md-4">
                                <div class="form-group">
                                    <label class="required" for="role">Amount (Without Tax)</label>                                 
                                    <input type="text"  name="item_amount[]" value="0" onchange="calculatetaxamount()" onkeyup="calculatetaxamount()" class="form-control tip 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">Action</label> <br>
                            <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>
                    </div>
                </div>
            
            <div class="row"  id="variations">
    
            </div>
           

  </div>
  
 <div class="col-md-12" >  
 <hr>
              <div class="col-md-6" style="text-align: right;"><label class="required" for="role">Total Invoice Amount (Without Tax)</label></div>
            <div class="col-md-6"><input type="text" min="5" name="invoice_amount" value="" readonly onchange="calculatetaxamount()" onkeyup="calculatetaxamount()" class="form-control tip" id="invoice_amount"  onkeypress="return isNumberKey(this, event);" required="required" placeholder="Enter Invoice Amount" /></div>
            <br><br>
            <div class="col-md-6" style="text-align: right;"><label class="required" for="location">Tax Type</label></div>
            <div class="col-md-6"> <select name="tax_type" class="form-control select2" id="tax_type"  data-placeholder="Payment Method" style="width:100%;">
<option value="1">GST</option>
<option value="2">IGST</option>
</select></div>
            <br><br>
            <div class="col-md-6" style="text-align: right;"><label class="required" for="location">Tax %</label> </div>
            <div class="col-md-6">
            <select name="tax_percentage" class="form-control select2" id="tax_percentage" onchange="calculatetaxamount()" onkeyup="calculatetaxamount()" data-placeholder="Payment Method" style="width:100%;">
<option value="0">0 %</option>
<option value="5">5 %</option>
<option value="10">10 %</option>
<option value="12">12 %</option>
<option value="18">18 %</option>
<option value="28">28 %</option>
</select>
</div>
            <br><br>
            <div class="col-md-6" style="text-align: right;"><label class="required" for="role">Tax Amount</label></div>
            <div class="col-md-6"><input type="text"name="tax_amount" value=""  readonly class="form-control tip" id="tax_amount"  required="required" placeholder="Auto Calculate Based on Tax and Invoice Amount" /></div>
            
            <br><br>
            <div class="col-md-6" style="text-align: right;"><label class="required" for="role">Final Amount (With Tax)</label></div>
            <div class="col-md-6"><input type="text" min="5" name="final_amount" value="" readonly  class="form-control tip" id="final_amount"  required="required" placeholder="Auto Calculate Based on Tax and Invoice Amount" /></div>

                            <div class="col-md-4">
                                <div class="form-group">
                                    <label for="logo">Upload Invoice Copy-1</label>                                    
                                    <input type="file" id="logo" name="logo" accept="image/png, image/jpeg"  />
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label for="logo">Upload Invoice Copy -2</label>                                    
                                    <input type="file" id="logo1" name="logo1" accept="image/png, image/jpeg"  />
                                </div>
                            </div>
                            <div class="col-md-4"></div>
                            <br><br><br>
 <div class="form-group" style="text-align:center;">
                            <input type="submit" name="add_invoice" value="Add Vendor Invoice"  class="btn btn-success" />
                        </form>
                        </div>
            <div class="form-group" style="text-align:center;">
                            <a href="vendor-invoice-add.php"><button class="btn btn-primary" ><i class="fa fa-refresh"></i> Reset Form</button></a>
                            <a href="vendor-invoice.php" class="btn btn-warning" ><i class="fa fa-chevron-left"></i> Back to List</a>
                         </div>
 </div>   

    
</div>
                        

                        

                    </div>
                        
                    <div class="clearfix"></div>
                </div>
            </div>
        </div>
    </div>
</section>

<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();
    });
    
    
    $('#add_packate_variation').on('click', function() {
        html ='<div class="rows">'+
                '<div class="col-md-6">'+
                                '<div class="form-group">'+
                                    '<label class="required" for="role">Description</label>'+   
                                    '<input type="text" name="item_description[]" class="form-control tip" placeholder="item Description" required="required">'+
                                '</div>'+
                '</div>'+
                '<div class="col-md-4">'+
                                '<div class="form-group">'+
                                    '<label class="required" for="role">Amount (Without Tax)</label>  '+                               
                                    '<input type="text" name="item_amount[]" value="0" onchange="calculatetaxamount()" onkeyup="calculatetaxamount()" class="form-control tip 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"><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() { 
        calculatetaxamount();
    });
    function calculatetaxamount(){
          calculation_final_amt();
    }
    
    function calculation_final_amt(){
        var item_amount = 0;
            $('.item_amount').each(function(){
                item_amount += parseFloat(this.value);
            });
        $('#invoice_amount').val(item_amount);
        
         var reduction_item_amount = 0;
            $('.reduction_item_amount').each(function(){
                reduction_item_amount += parseFloat(this.value);
            });
        $('#final_reduction_amount').val(reduction_item_amount);
        
        
        
        var amount=$('#invoice_amount').val();
        var tax=$('#tax_percentage').val();
        if(tax!=0){
            $('#tax_amount').val(amount*tax/100);
            
            $('#final_amount').val(parseFloat(amount)+parseFloat(amount*tax/100));
           // $('#final_invoice_amount').val(parseFloat(amount)+parseFloat(amount*tax/100));
            
            $('#tax_text').text(tax+' % Tax Amount');
            
        }else{
           // $('#final_invoice_amount').val($('#invoice_amount').val());
            $('#final_amount').val($('#invoice_amount').val());
            $('#tax_text').text(tax+' % Tax Amount');
            $('#tax_amount').val(0);
        }
        
       // $('#final_payable_amount').val($('#final_invoice_amount').val()-$('#final_reduction_amount').val());
        
    }
    
    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