-
Notifications
You must be signed in to change notification settings - Fork 0
/
invoice.php
78 lines (73 loc) · 3.03 KB
/
invoice.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
// Includng configuration file
include 'config/config.php';
//Check user is already login or not
checkAuthentication();
$id = $_SESSION['adminid'];
$order = new invoice();
$customer = new customer();
if(isset($_GET['action']) && $_GET['action'] == 'new'){
$smarty->assign('content', $smarty->fetch('searchchalaninvoice.tpl'));
}elseif(isset($_GET['action']) && $_GET['action'] == 'viewinvoice'){
$id = $_GET['id'];
$orderdet = $order->getOrder($id);
$orderitems = $order->getOrderItems($orderdet['id']);
$customer = $order->getCustomer($orderdet['customer_id']);
$smarty->assign('order', $orderdet);
$smarty->assign('orderitem', $orderitems);
$smarty->assign('customer', $customer);
$smarty->assign('billing', $order->getCustomerBilling($customer['id']));
$smarty->assign('shipping', $order->getCustomerShipping($customer['id']));
$smarty->assign('content', $smarty->fetch('invoiceview.tpl'));
}elseif(isset($_GET['action']) && $_GET['action'] == 'printinvoice'){
$id = $_GET['id'];
$orderdet = $order->getOrder($id);
$orderitems = $order->getOrderItems($orderdet['id']);
$customer = $order->getCustomer($orderdet['customer_id']);
$smarty->assign('order', $orderdet);
$smarty->assign('orderitem', $orderitems);
$smarty->assign('customer', $customer);
$smarty->assign('billing', $order->getCustomerBilling($customer['id']));
$smarty->assign('shipping', $order->getCustomerShipping($customer['id']));
$smarty->assign('content', $smarty->fetch('printinvoice.tpl'));
$smarty->display('print.html');
exit;
}elseif(isset($_GET['action']) && $_GET['action'] == 'search'){
$keyword = $_POST['keywords'];
$page = 1;
if(isset($_GET['page'])){
$page = $_GET['page'];
}
$result = $order->getSearchInvoice($keyword,$page, $offset=10);
$smarty->assign('ordercount', count($result));
$smarty->assign('page', $page);
$smarty->assign('pagecount', ceil(count($result)/$offset));
$smarty->assign('orders', $result);
$smarty->assign('content', $smarty->fetch('invoice.tpl'));
}elseif(isset($_GET['action']) && $_GET['action'] == 'deleteinvoice'){
$id = $_GET['id'];
$chalan_no = $_GET['chalan_no'];
$order->deleteInvoice($id, $chalan_no);
header('Location: '.FRONTEND.'invoice.php');
exit;
}elseif(isset($_GET['action']) && $_GET['action'] == 'paidinvoice'){
$id = $_GET['id'];
$order->markInvoicedPaid($id);
header('Location: '.FRONTEND.'invoice.php');
exit;
}else{
$page = 1;
if(isset($_GET['page'])){
$page = $_GET['page'];
}
$orders = $order->getOrders($page, $offset=10);
$smarty->assign('ordercount', $order->getInvoiceCount());
$smarty->assign('page', $page);
$smarty->assign('pagecount', ceil($order->getInvoiceCount()/$offset));
$smarty->assign('orders', $orders);
$smarty->assign('content', $smarty->fetch('invoice.tpl'));
}
$smarty->assign('action', 'invoice');
$smarty->assign('toolbar', $smarty->fetch('toolbar.tpl'));
$smarty->display('two-column-left.html');
?>