forked from SecareLupus/fc_pos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
invoices.php
93 lines (81 loc) · 2.67 KB
/
invoices.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/**
* @file invoices.php
* @brief invoices.php gives an active user with inventory privs the
* chance to put invoices into record for determining Purchase budget.
*
* This file includes:
* funcs.inc:
* - Used for the config.inc include
*
* Possible Arguments:
* SESSION:
* - inv - Used to determine whether the active user has inventory
* privs.
*
* POST:
* - vendor - The name of the vendor who sent the submitted invoice.
* - amount - The total price on the submitted invoice.
* - year - The year on the submitted invoice.
* - month - The month on the submitted invoice.
* - day - The day on the submitted invoice.
*
* @link http://www.worldsapartgames.org/fc/invoices.php @endlink
*
* @author Michael Whitehouse
* @author Creidieki Crouch
* @author Desmond Duval
* @copyright 2009-2014 Pioneer Valley Gaming Collective
* @version 1.8d
* @since Project has existed since time immemorial.
*/
$title = "Invoice Record";
$version = "1.8d";
require 'funcs.inc';
require 'header.php';
if ($_SESSION['inv'] != 1) {
echo "You must have Inventory Permission to use this application";
include 'footer.php';
die();
}
$cxn = open_stream();
extract($_POST);
if (isset($vendor) && isset($amount)) {
$date = $year . '-' . $month . '-' . $day;
$stmt = $cxn->prepare("INSERT INTO invoices (invdate, vendor, amount) VALUES (?,?,?)");
$stmt->bind_param("ssd", $date, $vendor, $amount);
if ($stmt->execute()) {
echo "Invoice submitted<hr>";
} else {
echo "Invoice FAILED<hr>";
}
}
// display stuff
$sql = "SELECT * FROM invoices ORDER BY invdate DESC";
$result = query($cxn, $sql);
$invsum = 0; // total invoices ever
$disp = ''; // string that will be displayed
while ($row = mysqli_fetch_assoc($result)) {
extract($row);
$invsum += $amount;
$disp .= "<tr><td>$invdate</td><td>$vendor</td><td>" . money($amount) . "</td></tr>";
}
$sql = "SELECT (SUM(price * qty)) FROM soldItem";
$result = query($cxn, $sql);
$row = mysqli_fetch_row($result);
$sales = $row[0];
$budget = ($sales * .6) - $invsum;
echo "Remaining Inventory Budget: " . money($budget) . "<br>
Total Sales: " . money($sales) . "<br>
Total Invoices: " . money($invsum) . "<p>";
echo "Insert Invoice Information<br>
<form action='invoices.php' method='post'>
Invoice Date: ";
echo selectInputDate('month', 'day', 'year', 2008, 2015, date('n'), date('j'), date('Y'));
echo "<br>
Invoice to: <input type='text' name='vendor' maxlength=40><br>
Invoice Amount: <input type='text' name='amount' maxlength=8><br>
<input type='submit' name='submit' value='submit'></form><p>\n";
echo "<table>$disp</table>";
require 'footer.php';
?>