Your IP : 216.73.216.26


Current Path : /home2/wtmwscom/public_html/admin/
Upload File :
Current File : /home2/wtmwscom/public_html/admin/product_sale_bill_old.php

<?php
include "header.php";
if(!isset ($_SESSION['fid'])) redirect('login.php');


$uid = $_GET['uid'];
    $fid = $_SESSION['fid'];
  
$usr = mysqli_fetch_object(mysqli_query($connection, "select name, City from user where uid = $uid"));
   $fra = mysqli_fetch_object(mysqli_query($connection, "select store_name, address, city, id_date from franchise where fid = $fid"));
   
   $pid_array = $_SESSION['pid'];
$qty_array = $_SESSION['qty'];
 $date = date('Y-m-d'); 
   $net_gross_amount = 0;
   $total_pv = 0;
   $sno = 1;
   //$usr = mysqli_fetch_object(mysqli_query($connection, "select name, City from user where uid = $uid"));
   ?>
<div align="center">
<table align="center" border="1" width="75%" style="border-collapse:collapse; font-weight: bold;" cellpadding="5" cellspacing="10">
<tr><td colspan="7" align="center" style="font-size: larger">Retail Invoice</td></tr>
<tr><td colspan="7" style="font-size: larger"> 
   <span>Invoice no  <span id="invoice-no"></span></span>
   <div align="center">
   <?php echo $fra->store_name;?><br/><?php echo $fra->address.' '.$fra->city;?></div>
    <div align="right" >Date <?php echo date('d/m/y'); ?></div>
    </td></tr>
<tr><td colspan="7" style="font-size: large"><?php echo $usr->name." ( $uid )";?><br/><?php echo $usr->City?></td></tr>
<tr> <td colspan="7">
<table width="100%" style="font:normal;">
    <tr style="font-size: large">
    <td>S.No.</td>
<td>Product name</td>


<td>Qty.</td>
<td>Rate</td>

<td>Amount</td>

<td>BV</td>
    
   
    <td>G. Amount</td>
    

</tr>


   <?php
foreach ($pid_array as $key=>$value) {
   $is_success = FALSE; 
   
   $qty = $qty_array[$key];
    $pid = $value;
    $query  = "select pcode, pname, pv, pcost from product where pid = '".$pid."'";
    $rs = mysqli_query($connection, $query);
    $row = mysqli_fetch_object($rs);
    $pv_amount = $qty * $row->pv;
    $product_cost = $qty * $row->pcost;
    mysqli_query($connection, "update user set total_purchase = total_purchase + '$product_cost' WHERE uid='$uid'");
    $is_success = mysqli_query($connection, "insert into product_sale (uid, pid, fid,quantity, pv_amount, pcost, date) values(
        $uid, $pid, $fid, $qty, $pv_amount, $product_cost, '".$date."'
        )");
    $invoice_no = mysql_insert_id();
    if($is_success){
        mysqli_query($connection, "update product_franchise set quantity = quantity - $qty where pid = $pid and fid = $fid ");
    }

if($is_success){
   
$amount = $qty * $row->pcost;
$pv  = $row->pv * $qty;
//$vat = 12.5;
//$vat_amount = $amount *$vat/100;
$gross_amount = $amount;// + $vat_amount;
$net_gross_amount = $net_gross_amount + $gross_amount;
$total_pv += $pv;

echo "<tr>
    <td>$sno</td>
<td>$row->pname</td>
        <td>$qty</td>
        <td>$row->pcost</td>
        <td>$amount</td>
        <td>$pv</td>
        
        <td>$gross_amount</td>
    </tr>";
}
$sno++;
}
?>
<tr><td colspan="2" align="center"> Total</td>
       <td></td>
       <td></td>
       <td></td>
       <td><?php echo $total_pv;?></td>
       <td><?php echo $net_gross_amount; ?></td>
       </tr>
    </table></td></tr>
       


</table>
<div>#Including all taxes</div>
<h2><button onclick="window.print()">Print</button></h2>

<h3>Total amount has to pay is INR. <?php echo $net_gross_amount; ?></h3>
<h2><button onclick="window.close()">Close this window</button></h2>
</div>
<script>
    $(document).ready(function(){
        $("#invoice-no").html(<?php echo $invoice_no;?>);
    }); 
</script>
<?php
include('footer.php');
?>