-
Notifications
You must be signed in to change notification settings - Fork 0
/
vat.php
102 lines (76 loc) · 2.46 KB
/
vat.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
<?php
/**
* Created by PhpStorm.
* User: Daniel
* Date: 23.08.2016
* Time: 09:49
*/
require_once('includes/bootstrap.inc.php');
User::checkLogin();
$content = "<h2>Steuersätze</h2>";
// Set the Step var
if(isset($_GET['id']))
$id = $_GET['id'];
else
$id = '';
if($id == '1')
{
// Update VAT Form
$VAT = VatMapper::findById(intval($_GET['vatid']));
$content .= VAT::getForm($VAT);
} else if($id == '2') {
// Process the VAT post data by calling the formMapper
$VAT = VAT::formMapper($_POST);
if ($VAT instanceof VAT) {
// If the Mapper passed correctly, the data will be given to database
if ($_POST['action'] == 'update') {
VatMapper::update($VAT);
} else {
VatMapper::add($VAT);
}
$content .= "<div class=\"alert alert-success\">
<a href=\"#\" class=\"close\" data-dismiss=\"alert\" aria-label=\"close\">×</a>
Datensatz erfolgreich eingefügt.
</div>";
$content .= VAT::getTable(VatMapper::getAllVats());
}
else {
// The formMapper failed
$content .= $VAT;
}
} else if($id == '3') {
// The add new VAT form is called
$content .= "<h3>Neuer Mehrwertsteuersatz</h3>";
$content .= VAT::getForm();
} else if($id == '4')
{
// Delete VAT is called
if(empty($_GET['sure']))
{
// ask the User if he is sure
$content .= "<div class=\"alert alert-warning\"><p>Wirklich löschen?</p>
<p><button class='btn update' onclick=\"window.location.href='?id=4&vatid=" . $_GET['vatid'] . "&sure=true'\">Ja</button>
<button class='btn delete' onclick=\"window.location.href='?'\">Nein</button></p>
</div>";
$content .= VAT::getTable(VatMapper::getAllVats());
} else {
// If the user is sure, delete the VAT in database
$VAT = new VAT();
$VAT->setId(intval($_GET['vatid']));
VatMapper::delete($VAT);
$content .= "<div class=\"alert alert-success\">
<a href=\"#\" class=\"close\" data-dismiss=\"alert\" aria-label=\"close\">×</a>
Datensatz erfolgreich gelöscht.
</div>";
$content .= VAT::getTable(VatMapper::getAllVats());
}
} else {
// show the VAT table
$content .= VAT::getTable(VatMapper::getAllVats());
}
// Initialize Page
$page = new Page();
$page->setTitle("tinyERP - VAT");
$page->setRightArea($page->getMasterDataNav());
$page->setContent($content);
$page->run();