-
Notifications
You must be signed in to change notification settings - Fork 0
/
invoice.php
executable file
·181 lines (126 loc) · 5.55 KB
/
invoice.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
<!--
var counter = 0;
function init() {
document.getElementById('moreFields').onclick = moreFields;
moreFields();
}
function moreFields() {
counter++;
software_menu_counter=document.getElementById('software_menu_counter');
software_menu_counter.value=counter;
var newFields = document.getElementById('readroot').cloneNode(true);
newFields.id = '';
newFields.style.display = 'block';
var newField = newFields.childNodes;
for (var i=0;i<newField.length;i++) {
var theName = newField[i].name
if (theName)
newField[i].name = theName + counter;
}
var insertHere = document.getElementById('writeroot');
insertHere.parentNode.insertBefore(newFields,insertHere);
}
// -->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LIC - Devices</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.red {
color: #F00;
}
-->
</style>
</head>
<body onload="init()">
<?php
require_once('config.php');
require_once('func.php');
require_once('db_layer.php');
require_once('menu.php');
mb_internal_encoding("UTF-8");
if($_SERVER['REQUEST_METHOD'] == 'POST') {
$_POST = removeMagicQuotes($_POST);
}
// init db layer
$dd = new DB('', '', '', '', $db);
if(isset($_GET['id']) && is_num($_GET['id'])) {
if(isset($_GET['delete_dev']) && is_num($_GET['delete_dev'])) {
$dd->query('delete from devices where device_id='.escq($_GET['delete_dev']).' limit 1');
}
if(isset($_GET['delete_lic']) && is_num($_GET['delete_lic'])) {
$dd->query('delete from licenses where license_id='.escq($_GET['delete_lic']).' limit 1');
}
echo '<h2>Invoice info: </h2>';
$u = $dd->fetchRow('select *
from invoices
where invoice_id='.escq($_GET['id']).'
limit 1');
if($u) {
$pname = $dd->fetchArray('select * from party where party_id in ('.$u['supplier_id'].','.$u['customer_id'].')', 'party_id');
echo 'PPR: '.$u['set'] .' ' . $u['number'] . '<br />'.
'Date: '.$u['date'] . '<br />'.
'Supplier: '.$pname[$u['supplier_id']]['name']. '<br />'.
'Customer: '.$pname[$u['customer_id']]['name']. '<br /><br />';
$device_types = $dd->fetchArray('select * from device_type', 'id');
$items = $dd->fetchArray('select d.device_id,d.description,d.hostname,d.user_id,concat(u.name, \' \', u.surname) as user_name,d.device_type from devices d
left join users u on u.id=d.user_id
where d.invoice_id='.escq($_GET['id']));
if($items) {
echo '<h2>Devices: </h2>';
echo '<table border="1">';
echo '<tr><th>ID</th>
<th>Device Type</th>
<th>Description</th>
<th>Hostname</th>
<th>User</th>
<th>Edit</th>
</tr>';
foreach($items as $d) {
echo '<tr><td>'.$d['device_id'].'</td>
<td>'.($d['device_type']!=0?$device_types[$d['device_type']]['name']:'').'</td>
<td>'.$d['description'].'</td>
<td>'.$d['hostname'].'</td>
<td><a href="user_info.php?id='.$d['user_id'].'">'.$d['user_name'].'</a></td>
<td><a href="devices_edit.php?device_id='.$d['device_id'].'">Edit</a> | <a href="invoice.php?id='.$_GET['id'].'&delete_dev='.$d['device_id'].'" onclick="javascript:return confirm(\'Vai tiešām vēlaties dzēst?\')">Delete</a></td>
</tr>';
}
echo '</table>';
}
$items = $dd->fetchArray('select l.license_id, l.software_id, s.name as software_name, s.license_type, description, t.name as license_type_name
from licenses l
left join software s on l.software_id=s.software_id
left join license_type t on t.license_type_id=s.license_type
where l.invoice_id='.escq($_GET['id']));
if($items) {
echo '<h2>Licences: </h2>';
echo '<table border="1">';
echo '<tr><th>ID</th>
<th>Software</th>
<th>Licences tips</th>
<th>Description</th>
<th>Edit</th>
</tr>';
foreach($items as $d) {
echo '<tr><td>'.$d['license_id'].'</td>
<td>'.$d['software_name'].'</td>
<td>'.$d['license_type_name'].'</td>
<td>'.$d['description'].'</td>
<td><a href="licenses.php?license_id='.$d['license_id'].'">Edit</a> | <a href="invoice.php?id='.$_GET['id'].'&delete_lic='.$d['license_id'].'" onclick="javascript:return confirm(\'Vai tiešām vēlaties dzēst?\')">Delete</a></td>
</tr>';
}
echo '</table>';
}
}
else {
echo 'Invoice not found!';
}
}
?>
</body>
</html>