4f4872939569200581b8c850b2edbc1d91d6b0b2
Bernd Wurst Zwischenversion

Bernd Wurst authored 7 years ago

1) <?php
2) /*
3) This file belongs to the Webinterface of schokokeks.org Hosting
4) 
5) Written 2008-2014 by schokokeks.org Hosting, namely
6)   Bernd Wurst <bernd@schokokeks.org>
7)   Hanno Böck <hanno@schokokeks.org>
8) 
9) To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
10) 
11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see 
12) http://creativecommons.org/publicdomain/zero/1.0/
13) 
14) Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
15) */
16) 
17) require_once('session/start.php');
18) require_once('inc/icons.php');
19) require_once('inc/jquery.php');
20) javascript('more_storage.js');
21) 
22) require_once('invoice.php');
23) 
24) require_role(ROLE_CUSTOMER);
25) 
26) $_SESSION['more_storage_section'] = 'invoice_current';
27) if (isset($_GET['section'])) {
28)   $_SESSION['more_storage_section'] = $_GET['section'];
29) }
30) $section = $_SESSION['more_storage_section'];
31) 
32) title('Zusätzlichen Speicherplatz buchen');
33) 
34) $upcoming = upcoming_items();
35) $hosting = NULL;
36) foreach ($upcoming as $item) {
37)   if ($item['quelle'] == 'hosting') {
38)     $hosting = $item;
39)     break;
40)   }
41) }
42) if (!$hosting) {
43)   system_failure("Die Abrechnung für das normale Hosting konnte nicht ermittelt werden. Daher können Sie diese Funktion leider nicht benutzen. Wenden Sie sich bitte an die Administratoren um mehr Speicherplatz zu bestellen.");
44) }
45) if ($hosting['brutto'] == 0) {
46)   system_failure("Ihr Konto wird mit Nettopreisen abgerechnet. Bitte wenden Sie sich an den Support.");
47) }
48) 
49) $customerquota = get_customerquota();
50) 
51) $count = 1024;
Bernd Wurst Erlaube auch einen Get-Para...

Bernd Wurst authored 7 years ago

52) if (isset($_REQUEST['count']) && (int) $_REQUEST['count'] > 0) {
53)   $count = (int) $_REQUEST['count'];
Bernd Wurst Zwischenversion

Bernd Wurst authored 7 years ago

54) }
55) 
56) output("<p>Ihr aktuell zugeteilter Speicherplatz (ggf. inklusive Mitbenutzer) beträgt <strong>${customerquota} MB</strong>. Sie können weiteren Speicherplatz hinzubuchen.</p>");
57) 
58) $checked = '';
59) if ($count == 1024) {
60)   $checked = 'checked="checked" ';
61) }
62) $form = '<p class="buttonset"><input '.$checked.'type="radio" name="count" value="1024" id="count-1" /><label for="count-1">Zusätzlich <strong>1 GB</strong>, insgesamt also '.($customerquota+1024).' MB</label>';
63) if ($count == 2048) {
64)   $checked = 'checked="checked" ';
65) } else {
66)   $checked = '';
67) }
68) $form .= '<input '.$checked.'type="radio" name="count" value="2048" id="count-2" /><label for="count-2">Zusätzlich <strong>2 GB</strong>, insgesamt also '.($customerquota+2048).' MB</label>';
69) if ($count == 5120) {
70)   $checked = 'checked="checked" ';
71) } else {
72)   $checked = '';
73) }
74) $form .= '<input '.$checked.'type="radio" name="count" value="5120" id="count-5" /><label for="count-5">Zusätzlich <strong>5 GB</strong>, insgesamt also '.($customerquota+5120).' MB</label>';
75) 
76) $form .= '<input type="submit" value="Wählen" /></p>';
77) output(html_form("more_storage_selection", "more_storage", "", $form));
78) 
79) $new_item = $hosting;
80) unset($new_item['quelle']);
81) unset($new_item['id']);
82) $gb = $count/1024;
83) $new_item['beschreibung'] = 'Erweiterung Speicherplatz um '.$gb.' GB (Auftrag vom '.date('d.m.Y').')';
84) $new_item['betrag'] = $gb;
85) 
86) $startdate = $new_item['startdatum'];
87) $diff = date_diff(date_create("now"), date_create($startdate), true);
88) DEBUG('date_diff(now, '.$startdate.') => '.$diff->format('%y Year %m Month %d Day'));
89) $months = $diff->format("%m");
90) 
91) $stub_startdate = date_create($startdate);
92) date_sub($stub_startdate, date_interval_create_from_date_string($months.' months'));
93) $stub_enddate = date_create($startdate);
94) date_sub($stub_enddate, date_interval_create_from_date_string('1 day'));
95) 
96) $stub = $new_item;
97) $stub['startdatum'] = date_format($stub_startdate, 'Y-m-d');
98) $stub['enddatum'] = date_format($stub_enddate, 'Y-m-d');
99) $stub['anzahl'] = $months;
100) $stub['monate'] = $months;
101) 
102) $items = array();
103) $items[] = $stub;
104) $items[] = $new_item;
105) 
106) output('<p>Die Abrechnung erfolgt mit Ihrer nächsten turnusgemäßen Abrechnung und wird mit folgenden Rechnungsposten vorgemerkt.</p>');
107) output('<table><tr><th>Anzahl</th><th>Beschreibung</th><th>Zeitraum</th><th>Einzelpreis</th><th>Gesamtbetrag</th></tr>');
108) $counter = 0;
109) foreach($items AS $item)
110) {
111)   $counter++;
112)   if ($counter == 1 && ($item['anzahl'] > 0)) {
113)     output("<tr><td colspan=\"5\" style=\"border: none;\"><em>Einmaliger Posten:</em></td></tr>");
114)   }
115)   elseif ($counter == 2) {
116)     output("<tr><td colspan=\"5\" style=\"border: none;\"><em>Künftiger regelmäßiger Posten:</em></td></tr>");
117)   }
118)   if ($item['anzahl'] == 0) {
119)     continue;
120)   }
121) 	$desc = $item['startdatum'];
122) 	if ($item['enddatum'] != NULL)
123) 		$desc = $item['startdatum'].' - '.$item['enddatum'];
124) 	$epreis = $item['betrag'];
125) 	if ($item['brutto'] == 0)
126) 		$epreis = $epreis * (1 + ($item['mwst'] / 100));
127) 	$gesamt = round($epreis * $item['anzahl'], 2);
128) 	$epreis = round($epreis, 2);
129)   $einheit = ($item['einheit'] ? $item['einheit'] : '');
130) 	output("<tr><td>{$item['anzahl']} {$einheit}</td>");
131)   output("<td>{$item['beschreibung']}</td><td>{$desc}</td>");
132) 	output("<td>{$epreis} €</td><td>{$gesamt} €</td></tr>\n");
133) }
134) output('</table>');
135) 
136) output('<p>Wir behalten uns vor, diese Rechnungsposten mit anderen sinngleichen Posten zusammen zu führen.</p>');
137) 
Bernd Wurst random_string() verwendet u...

Bernd Wurst authored 7 years ago

138) $handle = random_string(10);