-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitemstoinvoice.php
142 lines (128 loc) · 5.55 KB
/
itemstoinvoice.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Items to invoice</title>
<style type="text/css">
hr.pme-hr { border: 0px solid; padding: 0px; margin: 0px; border-top-width: 1px; height: 1px; }
table.pme-main { border: #004d9c 1px solid; border-collapse: collapse; border-spacing: 0px; width: 100%; }
table.pme-navigation { border: #004d9c 0px solid; border-collapse: collapse; border-spacing: 0px; width: 100%; }
td.pme-navigation-0, td.pme-navigation-1 { white-space: nowrap; }
th.pme-header { border: #004d9c 1px solid; padding: 4px; background: #add8e6; }
td.pme-key-0, td.pme-value-0, td.pme-help-0, td.pme-navigation-0, td.pme-cell-0,
td.pme-key-1, td.pme-value-1, td.pme-help-0, td.pme-navigation-1, td.pme-cell-1,
td.pme-sortinfo, td.pme-filter { border: #004d9c 1px solid; padding: 3px; }
td.pme-buttons { text-align: left; }
td.pme-message { text-align: center; }
td.pme-stats { text-align: right; }
</style>
</head>
<body>
<?php
/*
* IMPORTANT NOTE: This generated file contains only a subset of huge amount
* of options that can be used with phpMyEdit. To get information about all
* features offered by phpMyEdit, check official documentation. It is available
* online and also for download on phpMyEdit project management page:
*
* http://platon.sk/projects/main_page.php?project_id=5
*
* This file was generated by:
*
* phpMyEdit version: 5.7.1
* phpMyEdit.class.php core class: 1.204
* phpMyEditSetup.php script: 1.50
* generating setup script: 1.50
*/
// MySQL host name, user name, password, database, and table
require_once("service-admin.inc.php");
$opts['tb'] = 'invoicelines';
$opts['cu'] = 'customers';
// Connect to database
mysql_connect($opts['hn'], $opts['un'], $opts['pw']);
mysql_select_db($opts['db']);
// Identify first free invoice number
$qry = "SELECT MAX(invoiceid) FROM ".$opts['tb'];
$result = mysql_query($qry);
$maxinvoice = mysql_fetch_row($result);
$nextinvoice = $maxinvoice[0]+1;
// Get all non-invoiced invoicelines
$qry = "SELECT * FROM ".$opts['tb']." LEFT JOIN customers ON ".$opts['tb'].".customerid=customers.customerid WHERE invoiceid IS NULL ORDER BY ".$opts['tb'].".customerid,invoicelinedate";
$result = mysql_query($qry) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $qry . "<br />\nError: (" . mysql_errno() . ") " . mysql_error());
$count = mysql_num_rows($result);
?>
<? if($count>0) { ?>
<h3>Items to invoice</h3>
<form class="pme-form" method="post" action="createinvoice.php" name="createinvoice">
<table class="pme-main" summary="invoicelines">
<tr class="pme-header">
<th class="pme-header" colspan="1"> </th>
<th class="pme-header">Customer</th>
<th class="pme-header">Description</th>
<th class="pme-header">Invoicelinedate</th>
<th class="pme-header">Amount</th>
<th class="pme-header">Charge</th>
</tr>
<?
// Loop through them
while ($invoiceline = mysql_fetch_array($result)) {
echo "<tr class=\"pme-row-0\">";
echo "<td class=\"pme-navigation-1\"><input type=\"checkbox\" name=\"submitlines[]\" value=\"".$invoiceline["invoicelineid"]."\"></td>";
echo "<td class=\"pme-cell-1\">".$invoiceline["customername"]."</td>";
echo "<td class=\"pme-cell-1\">".$invoiceline["description"]."</td>";
echo "<td class=\"pme-cell-1\">".$invoiceline["invoicelinedate"]."</td>";
echo "<td class=\"pme-cell-1\">".$invoiceline["amount"]."</td>";
echo "<td class=\"pme-cell-1\">".$invoiceline["charge"]."</td>";
echo "</tr>\n";
}
?>
</table>
<hr size="1" class="pme-hr" />
<table summary="navigation" class="pme-navigation">
<tr class="pme-navigation">
<td class="pme-buttons">
<b>Create invoice number </b><input name="invnr" type="text" value="<? echo $nextinvoice; ?>" size=10>
<input type="submit" class="pme-add" name="create" value="Go!" />
</td></tr></table>
</form>
<? } ?>
<h3>One-time invoice line</h3>
<form class="pme-form" method="post" action="newinvoiceline.php" name="newinvoiceline">
<table class="pme-main" summary="invoicelines">
<tr class="pme-header">
<th class="pme-header" colspan="1"> </th>
<th class="pme-header">Customer</th>
<th class="pme-header">Description</th>
<th class="pme-header">Invoicelinedate</th>
<th class="pme-header">Amount</th>
<th class="pme-header">Charge</th>
</tr>
<tr class="pme-row-0">
<td class="pme-navigation-1"> </td>
<td class="pme-cell-1"><select class="pme-input-0" name="customerid">
<option value="0">---Select---</option>
<?
// Get all customers
$qry = "SELECT * FROM ".$opts['cu']." ORDER BY customername";
$result = mysql_query($qry) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $qry . "<br />\nError: (" . mysql_errno() . ") " . mysql_error());
while($customer = mysql_fetch_array($result)) {
echo "<option value=\"".$customer["customerid"]."\">".$customer["customername"]."</option>\n";
}
?>
</select></td>
<td class="pme-cell-1"><input size=40 type="text" name="description" value=""></td>
<td class="pme-cell-1"><input size=10 type="text" name="invoicelinedate" value="<? echo date("Y-m-d"); ?>"></td>
<td class="pme-cell-1"><input size=5 type="text" name="amount" value="1"></td>
<td class="pme-cell-1"><input size=5 type="text" name="charge" value=""></td>
</tr>
</table>
<hr size="1" class="pme-hr" />
<table summary="navigation" class="pme-navigation">
<tr class="pme-navigation">
<td class="pme-buttons">
<b>Add new invoice line </b><input type="submit" class="pme-add" name="addinvline" value="Go!" />
</td></tr></table>
</form>
</body>
</html>