Mercurial > hg > batmud > misc
annotate prices.php @ 365:59b819986fd0 misc
Add a short comment about the configuration.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 30 Mar 2020 10:59:28 +0300 |
parents | 0b12af2c103a |
children | 02bacce48be0 |
rev | line source |
---|---|
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
1 <?php |
164
61327dee8e8c
Add copyright and information about PHP version requirement.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
2 /* Merchant/alchemist price calculator in PHP |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
3 * (C) Copyright 2009-2013,2020 Matti 'Ggr' Hamalainen <ccr@tnsp.org> |
166
63c932c1f037
More documentation, cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
4 * |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
5 * Requires PHP 5.4 or later, primarily tested on PHP 5.6.x. |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
6 * Also tested on PHP 7.3. |
166
63c932c1f037
More documentation, cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
7 * |
365
59b819986fd0
Add a short comment about the configuration.
Matti Hamalainen <ccr@tnsp.org>
parents:
363
diff
changeset
|
8 * See the "prices.config.php" for configuration (or change the filename below). |
164
61327dee8e8c
Add copyright and information about PHP version requirement.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
9 */ |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
10 $pageConfig = "prices.config.php"; |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
11 |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
12 if (!file_exists($pageConfig)) |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
13 { |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
14 echo "ERROR: Configuration file '".$pageConfig."' not found!"; |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
15 exit; |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
16 } |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
17 |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
18 require_once $pageConfig; |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
19 |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
20 if (!isset($pageIndex)) |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
21 { |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
22 $pageIndex = "prices.php"; |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
23 } |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
24 |
166
63c932c1f037
More documentation, cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
25 |
63c932c1f037
More documentation, cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
26 //============================================================================ |
63c932c1f037
More documentation, cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
27 // The code starts here - utility functions |
63c932c1f037
More documentation, cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
28 //============================================================================ |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
29 function convPrice($val) |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
30 { |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
31 if ($val > 1000000) |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
32 return round($val / 1000000.0, 4)."M"; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
33 elseif ($val > 1000) |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
34 return round($val / 1000.0, 2)."k"; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
35 else |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
36 return $val; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
37 } |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
38 |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
39 |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
40 function getVal($name, &$val) |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
41 { |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
42 if (isset($_REQUEST["num_".$name]) && |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
43 is_numeric($_REQUEST["num_".$name])) |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
44 { |
237 | 45 $val = $_REQUEST["num_".$name]; |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
46 if ($val != 0) |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
47 return TRUE; |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
48 } |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
49 else |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
50 $val = -1; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
51 |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
52 return FALSE; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
53 } |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
54 |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
55 |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
56 function getField($name) |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
57 { |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
58 if (getVal($name, $val)) |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
59 $s = " value=\"".$val."\""; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
60 else |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
61 $s = ""; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
62 |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
63 return "<input type=\"text\" name=\"num_".$name."\" size=\"10\" class=\"itext\"".$s." />"; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
64 } |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
65 |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
66 |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
67 function getDiscount($dfield, &$dfactor, &$dstr) |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
68 { |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
69 $dfactor = 1.0; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
70 $dstr = ""; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
71 |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
72 if (getVal($dfield."_discount", $dval)) |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
73 { |
196
de3bb01d602d
Reagent discount wasn't working, fixed. Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
195
diff
changeset
|
74 addVal($dfield."_discount", $dval); |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
75 |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
76 if ($dval > 0 && $dval <= 100) |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
77 { |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
78 $dfactor = $dval / 100.0; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
79 $dstr = " [".-(100 - $dval)."%]"; |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
80 } |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
81 elseif ($dval < 0 && $dval >= -100) |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
82 { |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
83 $dfactor = (100 + $dval) / 100.0; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
84 $dstr = " [".$dval."%]"; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
85 } |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
86 } |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
87 } |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
88 |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
89 |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
90 function printSectionHeader($sec) |
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
91 { |
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
92 echo "<h2>".$sec["title"]."</h2>\n"; |
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
93 |
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
94 if (isset($sec["desc"])) |
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
95 echo "<p>".$sec["desc"]."</p>\n"; |
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
96 |
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
97 echo "<table class=\"pritab\">\n"; |
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
98 } |
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
99 |
196
de3bb01d602d
Reagent discount wasn't working, fixed. Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
195
diff
changeset
|
100 |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
101 function printSectionFooter($sec) |
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
102 { |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
103 echo |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
104 "</table>\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
105 "<p>\n"; |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
106 |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
107 if ($sec["discount"]) |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
108 { |
195
c75ca644f2df
Sync; Fix HTML validation errors, add functionality for fetching current
Matti Hamalainen <ccr@tnsp.org>
parents:
167
diff
changeset
|
109 echo $sec["title"]." total discount %: ". |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
110 getField($sec["name"]."_discount")."<br />\n"; |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
111 } |
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
112 |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
113 echo |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
114 "<input type=\"submit\" value=\" Calculate \" class=\"isubmit\" />\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
115 "</p>\n\n"; |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
116 } |
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
117 |
197 | 118 |
166
63c932c1f037
More documentation, cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
119 //============================================================================ |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
120 |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
121 echo |
283 | 122 "<!DOCTYPE HTML>\n". |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
123 "<html>\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
124 "<head>\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
125 " <meta charset=\"".$pageCharset."\">\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
126 " <title>".htmlentities($pageTitle)."</title>\n"; |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
127 |
283 | 128 if (isset($pageCSS)) |
129 { | |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
130 echo "<link rel=\"stylesheet\" title=\"Default\" href=\"".$pageCSS."\" type=\"text/css\" />\n"; |
283 | 131 } |
132 else | |
133 { | |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
134 ?> |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
135 <style type="text/css"> |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
136 <!-- |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
137 body { background: black; color: white; font-family: Arial, Verdana, sans-serif; font-size: 10pt; } |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
138 th { background: gray; } |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
139 |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
140 table.pritab { width: 70%; } |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
141 table.pritab tr:hover td { background: green; } |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
142 tr.a td { background: #333; } |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
143 tr.b td { background: #444; } |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
144 |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
145 h1,h2,h3,h4 { color: #f00; border-bottom: 1px solid #c00; } |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
146 |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
147 .hide { display: none; } |
195
c75ca644f2df
Sync; Fix HTML validation errors, add functionality for fetching current
Matti Hamalainen <ccr@tnsp.org>
parents:
167
diff
changeset
|
148 |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
149 .phys { color: #ddd; } |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
150 .fire { color: #f00; } |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
151 .cold { color: #00f; } |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
152 .mana { color: #ff0; } |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
153 .asph { color: #8ff; } |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
154 .pois { color: #0f0; } |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
155 .elec { color: #08f; } |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
156 --> |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
157 </style> |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
158 <?php |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
159 } // if no defined user stylesheet |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
160 |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
161 echo |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
162 "</head>\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
163 "<body>\n"; |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
164 |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
165 //============================================================================ |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
166 // Data input mode |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
167 //============================================================================ |
283 | 168 if (!isset($_REQUEST["ok"])) |
169 { | |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
170 |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
171 echo "<h1>".$pageTitle."</h1>\n"; |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
172 |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
173 if (isset($global_desc)) |
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
174 echo $global_desc; |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
175 |
195
c75ca644f2df
Sync; Fix HTML validation errors, add functionality for fetching current
Matti Hamalainen <ccr@tnsp.org>
parents:
167
diff
changeset
|
176 echo "\n<form action=\"".$pageIndex."\" method=\"post\" autocomplete=\"off\">\n". |
c75ca644f2df
Sync; Fix HTML validation errors, add functionality for fetching current
Matti Hamalainen <ccr@tnsp.org>
parents:
167
diff
changeset
|
177 "<p><input type=\"hidden\" name=\"ok\" value=\"ok\" /></p>\n"; |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
178 |
283 | 179 if ($sections["services1"] || $sections["services2"]) |
180 { | |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
181 printSectionHeader($services); |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
182 |
283 | 183 if ($sections["services1"]) |
184 { | |
185 foreach ($services1_prices as $key => $item) | |
186 { | |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
187 $s = isset($item["extra"]) ? $item["extra"] : ""; |
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
188 echo |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
189 " <tr>\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
190 " <th>".$item["name"]."</th>\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
191 " <th>Cost</th>\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
192 " <th>#</th>\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
193 " <th class=\"hide\"></th>\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
194 " </tr>\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
195 " <tr><td>1-".($item["tresh"]-1)." ".$item["subj"]."s</td>". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
196 "<td>".convPrice($item["price1"])." / ".$item["subj"].$s."</td>". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
197 "<td>-</td><td class=\"hide\"></td></tr>\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
198 " <tr><td>".$item["tresh"]."+ ".$item["subj"]."s</td><td>"; |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
199 |
283 | 200 if (isset($item["base"])) |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
201 { |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
202 echo convPrice($item["base"])." initial fee + ".convPrice($item["price2"])." / ".$item["subj"].$s; |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
203 } |
283 | 204 else |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
205 { |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
206 echo convPrice($item["price2"])." / ".$item["subj"].$s; |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
207 } |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
208 |
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
209 echo "</td><td>".getField($key)."</td>"; |
195
c75ca644f2df
Sync; Fix HTML validation errors, add functionality for fetching current
Matti Hamalainen <ccr@tnsp.org>
parents:
167
diff
changeset
|
210 |
283 | 211 if (isset($item["extra"])) |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
212 { |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
213 echo "<td>+ ".getField($key."_extra")."</td>"; |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
214 } |
283 | 215 else |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
216 { |
195
c75ca644f2df
Sync; Fix HTML validation errors, add functionality for fetching current
Matti Hamalainen <ccr@tnsp.org>
parents:
167
diff
changeset
|
217 echo "<td class=\"hide\"></td>"; |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
218 } |
283 | 219 |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
220 echo "</tr>\n"; |
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
221 } |
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
222 } // services1 enabled |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
223 |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
224 |
283 | 225 if ($sections["services2"]) |
226 { | |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
227 echo |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
228 " <tr>\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
229 " <th>Service</th>\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
230 " <th>Cost</th>\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
231 " <th>#</th>\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
232 " <th class=\"hide\"></th>\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
233 " </tr>\n"; |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
234 |
283 | 235 foreach ($services2_prices as $key => $item) |
236 { | |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
237 echo |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
238 " <tr><td>".$item["name"]."</td>". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
239 "<td>".convPrice($item["price"])." / ".$item["subj"]."</td>". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
240 "<td>".getField($key)."</td>"; |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
241 |
283 | 242 if (isset($item["extra"])) |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
243 { |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
244 echo "<td>+ ".getField($key."_extra")."</td>"; |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
245 } |
283 | 246 else |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
247 { |
195
c75ca644f2df
Sync; Fix HTML validation errors, add functionality for fetching current
Matti Hamalainen <ccr@tnsp.org>
parents:
167
diff
changeset
|
248 echo "<td></td>\n"; |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
249 } |
283 | 250 |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
251 echo "</tr>\n"; |
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
252 } |
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
253 } // services2 enabled |
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
254 |
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
255 printSectionFooter($services); |
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
256 |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
257 } // services1 || services2 enabled |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
258 |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
259 |
283 | 260 if ($sections["reagents"]) |
261 { | |
197 | 262 $sec = $reagents; |
263 | |
195
c75ca644f2df
Sync; Fix HTML validation errors, add functionality for fetching current
Matti Hamalainen <ccr@tnsp.org>
parents:
167
diff
changeset
|
264 $showSupply = FALSE; |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
265 if (file_exists($sec["datafile"])) |
283 | 266 { |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
267 if (($data = @file_get_contents($sec["datafile"])) !== FALSE) |
283 | 268 { |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
269 $supply = []; |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
270 $lines = explode("\n", strtolower($data)); |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
271 foreach ($lines as $line) |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
272 { |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
273 $tmp = explode("|", $line); |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
274 if (count($tmp) >= 2) |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
275 $supply[$tmp[1]] = $tmp[0]; |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
276 } |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
277 $showSupply = TRUE; |
195
c75ca644f2df
Sync; Fix HTML validation errors, add functionality for fetching current
Matti Hamalainen <ccr@tnsp.org>
parents:
167
diff
changeset
|
278 } |
c75ca644f2df
Sync; Fix HTML validation errors, add functionality for fetching current
Matti Hamalainen <ccr@tnsp.org>
parents:
167
diff
changeset
|
279 } |
c75ca644f2df
Sync; Fix HTML validation errors, add functionality for fetching current
Matti Hamalainen <ccr@tnsp.org>
parents:
167
diff
changeset
|
280 |
197 | 281 printSectionHeader($sec); |
283 | 282 foreach ($sec["prices"] as $fkey => $flist) |
283 { | |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
284 echo |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
285 "<tr><th colspan=\"".($showSupply ? 6 : 5)."\">".$fkey."</th></tr>\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
286 " <tr>\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
287 " <th>Type</th>\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
288 " <th>Spell</th>\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
289 " <th>Reagent</th>\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
290 " <th>Price</th>\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
291 " <th>#</th>\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
292 ($showSupply ? " <th>Avail</th>\n" : ""). |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
293 " </tr>"; |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
294 |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
295 $row = 1; |
283 | 296 foreach ($flist as $key => $item) |
297 { | |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
298 $s = ($row % 2 == 1) ? "a" : "b"; |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
299 |
283 | 300 echo |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
301 " <tr class=\"".$s."\"><td class=\"".$item[0]."\">".$item[0]. |
283 | 302 "</td><td>".$item[1]."</td><td>".$item[2]."</td><td>".$item[3]."</td>". |
303 "<td>".getField($key)."</td>"; | |
304 | |
195
c75ca644f2df
Sync; Fix HTML validation errors, add functionality for fetching current
Matti Hamalainen <ccr@tnsp.org>
parents:
167
diff
changeset
|
305 $spell = strtolower($item[1]); |
c75ca644f2df
Sync; Fix HTML validation errors, add functionality for fetching current
Matti Hamalainen <ccr@tnsp.org>
parents:
167
diff
changeset
|
306 if ($showSupply && isset($supply[$spell])) |
c75ca644f2df
Sync; Fix HTML validation errors, add functionality for fetching current
Matti Hamalainen <ccr@tnsp.org>
parents:
167
diff
changeset
|
307 echo "<td>".$supply[$spell]."</td>"; |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
308 |
195
c75ca644f2df
Sync; Fix HTML validation errors, add functionality for fetching current
Matti Hamalainen <ccr@tnsp.org>
parents:
167
diff
changeset
|
309 echo "</tr>\n"; |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
310 $row++; |
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
311 } |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
312 } |
197 | 313 |
314 printSectionFooter($sec); | |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
315 } // reagents enabled |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
316 |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
317 |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
318 function printSection($sec) |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
319 { |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
320 printSectionHeader($sec); |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
321 |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
322 echo " <tr>\n"; |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
323 foreach ($sec["i_titles"] as $title) |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
324 echo " <th>".$title."</th>\n"; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
325 echo " </tr>\n"; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
326 |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
327 $name = $sec["name"]; |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
328 $base = isset($sec["base"]) ? $sec["base"] : 0; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
329 $row = 1; |
283 | 330 foreach ($sec["prices"] as $key => $item) |
331 { | |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
332 $s = ($row % 2 == 1) ? "a" : "b"; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
333 |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
334 echo " <tr class=\"".$s."\">"; |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
335 |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
336 for ($i = 0; $i < $sec["i_fields"]; $i++) |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
337 echo "<td>".$item[$i]."</td>"; |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
338 |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
339 $add = isset($sec["i_price"]) ? $item[$sec["i_price"]] : 0; |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
340 |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
341 echo "<td><b>".($base + $add)."</b></td>". |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
342 "<td>".getField($name."_".$key)."</td></tr>\n"; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
343 $row++; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
344 } |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
345 |
165
5b1b275e8b6b
Modularize, clean up indentation, add more options.
Matti Hamalainen <ccr@tnsp.org>
parents:
164
diff
changeset
|
346 printSectionFooter($sec); |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
347 } |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
348 |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
349 |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
350 if ($sections["arrows"]) printSection($arrows); |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
351 if ($sections["potions"]) printSection($potions); |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
352 if ($sections["salves"]) printSection($salves); |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
353 |
195
c75ca644f2df
Sync; Fix HTML validation errors, add functionality for fetching current
Matti Hamalainen <ccr@tnsp.org>
parents:
167
diff
changeset
|
354 echo "</form>\n"; |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
355 |
283 | 356 } |
357 else | |
358 { | |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
359 |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
360 //============================================================================ |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
361 // Billing result mode |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
362 //============================================================================ |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
363 function printLine($name, $num, $price, $header = FALSE) |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
364 { |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
365 global $billText; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
366 $td1 = $header ? "<th>" : "<td>"; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
367 $td2 = $header ? "</th>" : "</td>"; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
368 |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
369 echo " <tr>".$td1.$name.$td2.$td1.$num.$td2.$td1."<b>".convPrice($price)."</b>".$td2."</tr>\n"; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
370 |
196
de3bb01d602d
Reagent discount wasn't working, fixed. Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
195
diff
changeset
|
371 $s = sprintf("%-55s | %-6d | %s", $name, $num, convPrice($price)); |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
372 if ($header) |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
373 $billText .= str_repeat("-", 75)."\n".$s."\n\n"; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
374 else |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
375 $billText .= $s."\n"; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
376 } |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
377 |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
378 function addLine($name, $num, $price) |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
379 { |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
380 global $totalPrice, $subTotal; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
381 $totalPrice += $price; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
382 $subTotal += $price; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
383 printLine($name, $num, $price); |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
384 } |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
385 |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
386 function addVal($key, $val) |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
387 { |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
388 global $formText; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
389 $formText .= "<input type=\"hidden\" name=\"num_".$key."\" value=\"".$val."\" />\n"; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
390 } |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
391 |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
392 |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
393 //============================================================================ |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
394 // Services |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
395 //============================================================================ |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
396 echo |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
397 "<h1>Totals</h1>\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
398 "<table class=\"pritab\">\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
399 " <tr>\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
400 " <th>Item</th>\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
401 " <th>#</th>\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
402 " <th>Total</th>\n". |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
403 " </tr>\n"; |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
404 |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
405 $subTotal = $totalPrice = 0; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
406 $billText = ""; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
407 $formText = ""; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
408 |
196
de3bb01d602d
Reagent discount wasn't working, fixed. Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
195
diff
changeset
|
409 getDiscount("services", $factor, $str); |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
410 |
283 | 411 if ($sections["services1"]) |
412 { | |
237 | 413 foreach ($services1_prices as $key => $item) |
283 | 414 if (getVal($key, $val)) |
415 { | |
237 | 416 addVal($key, $val); |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
417 |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
418 if ($val >= $item["tresh"]) |
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
419 { |
237 | 420 if (isset($item["base"])) |
421 $total = $item["base"] + ($val * $item["price2"]); | |
422 else | |
423 $total = $val * $item["price2"]; | |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
424 |
237 | 425 $s = " (discount for >= ".$item["tresh"].")"; |
426 } else { | |
427 $total = $val * $item["price1"]; | |
428 $s = ""; | |
429 } | |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
430 |
237 | 431 addLine($item["name"].$s.$str, $val, $total * $factor); |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
432 |
237 | 433 // Extra does not get discount |
283 | 434 if (isset($item["extra"]) && getVal($key."_extra", $tmp)) |
435 { | |
237 | 436 addVal($key."_extra", $tmp); |
437 addLine("|".$item["extra"], $val, $tmp); | |
438 } | |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
439 } |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
440 } |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
441 |
283 | 442 if ($sections["services2"]) |
443 { | |
237 | 444 foreach ($services2_prices as $key => $item) |
283 | 445 if (getVal($key, $val)) |
446 { | |
237 | 447 addVal($key, $val); |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
448 |
237 | 449 $total = $val * $item["price"]; |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
450 |
237 | 451 addLine($item["name"].$str, $val, $total * $factor); |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
452 |
237 | 453 // Extra does not get discount |
283 | 454 if (isset($item["extra"]) && getVal($key."_extra", $tmp)) |
455 { | |
237 | 456 addVal($key."_extra", $tmp); |
457 addLine("|".$item["extra"], $val, $tmp); | |
458 } | |
283 | 459 } |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
460 } |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
461 |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
462 if ($subTotal > 0) |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
463 printLine("Services subtotal", "", $subTotal, TRUE); |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
464 |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
465 |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
466 //============================================================================ |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
467 // Reagents |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
468 //============================================================================ |
283 | 469 if ($sections["reagents"]) |
470 { | |
197 | 471 $sec = $reagents; |
472 getDiscount($sec["name"], $factor, $s); | |
166
63c932c1f037
More documentation, cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
473 $numReagents = 0; |
63c932c1f037
More documentation, cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
474 $subTotal = 0; |
197 | 475 foreach ($sec["prices"] as $fkey => $flist) |
283 | 476 foreach ($flist as $key => $item) |
477 { | |
478 if (getVal($key, $val) && $val > 0) | |
479 { | |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
480 addVal($key, $val); |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
481 addLine($item[2]." (".$item[1].")".$s, $val, $val * $item[3] * $factor); |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
482 $numReagents += $val; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
483 } |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
484 } |
166
63c932c1f037
More documentation, cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
485 if ($numReagents > 0) |
197 | 486 printLine("Total ".$sec["name"]."s", $numReagents, $subTotal, TRUE); |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
487 } |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
488 |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
489 //============================================================================ |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
490 // Generic sections |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
491 //============================================================================ |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
492 function calculateSection($sec) |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
493 { |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
494 $name = $sec["name"]; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
495 |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
496 if ($sec["discount"]) |
196
de3bb01d602d
Reagent discount wasn't working, fixed. Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
195
diff
changeset
|
497 getDiscount($name, $factor, $str); |
283 | 498 else |
499 { | |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
500 $str = ""; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
501 $factor = 1; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
502 } |
363
0b12af2c103a
Split prices.php configuration into a separate PHP file, do some cleanups in the code as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
283
diff
changeset
|
503 |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
504 $base = isset($sec["base"]) ? $sec["base"] : 0; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
505 $numItems = 0; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
506 $subTotal = 0; |
283 | 507 foreach ($sec["prices"] as $key => $item) |
508 { | |
509 if (getVal($name."_".$key, $val) && $val > 0) | |
510 { | |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
511 addVal($name."_".$key, $val); |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
512 |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
513 $add = isset($sec["i_price"]) ? $item[$sec["i_price"]] : 0; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
514 |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
515 addLine($item[0]." (".convPrice($base + $add)." / ".$name.")".$str, $val, |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
516 $val * ($base + $add) * $factor); |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
517 |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
518 $numItems += $val; |
198
9f79ddd5175d
Subtotals were not calculated in some cases. Fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
197
diff
changeset
|
519 $subTotal += $val * ($base + $add) * $factor; |
161
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
520 } |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
521 } |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
522 if ($numItems > 0) |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
523 printLine("Total ".$name."s", $numItems, $subTotal, TRUE); |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
524 } |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
525 |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
526 if ($sections["arrows"]) calculateSection($arrows); |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
527 if ($sections["potions"]) calculateSection($potions); |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
528 if ($sections["salves"]) calculateSection($salves); |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
529 |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
530 echo "</table>\n". |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
531 "<p>Final total: <b>".$totalPrice."</b> gold (".convPrice($totalPrice).")</p>\n". |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
532 "<hr />\n". |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
533 "<textarea rows=\"15\" cols=\"80\">\n". |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
534 "Services bill\n". |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
535 "=============\n\n". |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
536 addslashes($billText."\nFinal total: ".$totalPrice." gold (".convPrice($totalPrice).")\n"). |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
537 "</textarea>\n". |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
538 "<hr />\n<form action=\"".$pageIndex."\" method=\"post\">\n".$formText. |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
539 "<input type=\"submit\" value=\" Back \" class=\"isubmit\" />\n</form>\n"; |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
540 } |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
541 ?> |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
542 </body> |
b666a36d7655
Added PHP-based merchant price calculation page kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
543 </html> |