-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject_view.php
261 lines (193 loc) · 9.79 KB
/
project_view.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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<div class="title"><h2>Projekt</h2></div>
<div class="container ">
<div class="wrapper">
<form id="contact-form" method="post" action="project_edit_send.php" role="form" novalidate="true">
<div class="messages"></div>
<div class="controls">
<div class="section_title">Kunde</div>
<?php
include "database.php";
require_once('functions/secondstohuman.php');
include('functions/calc_time_diff.php');
$sql = "SELECT projects.memos,project,rate,priceclass_name,company_id,position_name,company,start_date,deadline,hours,position_hours,priceclass,hours_worked,price,active,positions.id FROM priceclass,positions,kunden,projects WHERE projects.company_id = kunden.id AND positions.project_id = projects.id AND priceclass.id = positions.priceclass AND projects.id = {$_GET['id']} AND active = 'true' ORDER BY projects.id";
$result = mysqli_query($conn, $sql);
$show_title = true;
$hours_all = 0;
$hours_worked_all = 0;
$price_all = 0;
if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_assoc($result)){
$start_date_row = strtotime( $row[start_date] );
$start_date_formated = date( 'd.m.Y', $start_date_row );
$deadline_row = strtotime( $row[deadline] );
$deadline_formated = date( 'd.m.Y', $deadline_row );
$id = $row[id];
if($show_title){
?>
<div class="form_company">
<div class="form-group">
<label for="form_company">Firma</label>
<input disabled id="form_company" type="text" name="company" value="<?php echo $row[company] ?>" class="form-control disabled" data-error="Company is required.">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="form_names">
<div class="form-group">
<label for="form_name">Start Date</label>
<input disabled id="form_name" type="text" name="name" value="<?php echo $start_date_formated ?>" class="form-control disabled" required="required" data-error="Firstname is required.">
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label for="form_lastname">Deadline</label>
<input disabled id="form_lastname" type="text" name="surname" value="<?php echo $deadline_formated ?>" class="form-control disabled" required="required" data-error="Lastname is required.">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="section_title">Positionen</div>
<div class="messages"></div>
<div class="form_table_row_first">
<div class="form-group">
<label>Position</label>
</div>
<div class="form-group">
<label>Preisklasse</label>
</div>
<div class="form-group">
<label>Stunden</label>
</div>
<div class="form-group">
<label>Gesamtpreis</label>
</div>
<div class="form-group yellow_bg">
<label>Geleistet</label>
</div>
<div class="form-group yellow_bg">
<label>Zu berechnen</label>
</div>
</div>
<?php
$show_title = false;
}
$price_worked = 0;
$price_worked = number_format(calc_time_diff($id)/3600 * $row[rate],2,',','.');
?>
<div class="form_table_row">
<div class="form-group">
<textarea id="position_name" name="position_name" class="form-control disabled" required="required" data-error="Valid email is required." ><?php echo $row[position_name] ?></textarea>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<input disabled id="priceclass_name" type="text" name="priceclass_name" value="<?php echo $row[priceclass_name]; ?>" class="form-control disabled">
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<input disabled id="position_hours" type="text" name="position_hours" value="<?php echo $row[position_hours]; ?>" class="form-control disabled">
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<input disabled id="total_hours" type="text" name="total_hours" value="<?php echo number_format($row[position_hours] * $row[rate],2,',','.'); ?> €" class="form-control disabled">
<div class="help-block with-errors"></div>
</div>
<div class="form-group yellow_bg">
<input disabled id="calc_time_diff" type="text" name="calc_time_diff" value="<?php echo seconds2human(calc_time_diff($id)); ?>" class="form-control disabled">
<div class="help-block with-errors"></div>
</div>
<div class="form-group yellow_bg">
<input disabled id="worked_hours" type="text" name="worked_hours" value="<?php echo $price_worked; ?> €" class="form-control disabled">
<div class="help-block with-errors"></div>
</div>
</div>
<?php
$hours_all += $row[position_hours];
$hours_worked_all += calc_time_diff($row[id]);
$price_all += $row[position_hours] * $row[rate];
$price_worked_all += $price_worked;
$memos = $row[memos];
$company = $row[company];
$project = $row[project];
$sql_calc = "SELECT * FROM priceclass WHERE id = '{$row[priceclass]}'";
$result2 = mysqli_query($conn, $sql_calc);
if(mysqli_num_rows($result2) > 0){
while($row2 = mysqli_fetch_assoc($result2)){
$pos_price += calc_time_diff($row[id]) / 3600 * $row[rate];
}
}
}
}
?>
<div class="form_table_row form_table_last_row">
<div class="form-group">
Gesamt
</div>
<div class="form-group">
</div>
<div class="form-group">
<?php echo $hours_all; ?>
</div>
<div class="form-group">
<?php echo number_format($price_all,2,',','.'); ?> €
</div>
<div class="form-group yellow_bg">
<?php echo seconds2human($hours_worked_all); ?>
</div>
<div class="form-group yellow_bg">
<?php echo number_format($price_worked_all,2); ?> €
</div>
</div>
<div class="section_title">Weiteres</div>
<div class="row">
<div class="form-group">
<label form="form_memo">Memo</label>
<textarea disabled id="form_memo" name="memo" value="" class="form-control disabled" rows="5"><?php echo $memos; ?></textarea>
<div class="help-block with-errors"></div>
</div>
</div>
<div class="row form_checkboxes form-group">
<div>
<div class="help-block with-errors"></div>
</div>
</div>
<div class="section_title">Rechnungen</div>
<div class="row form-group">
<div class="project_view_invoice_table">
<div class="invoice_table_invoice_name">ID</div>
<div class="invoice_table_invoice_price">Summe</div>
<div class="invoice_table_invoice_id">Rechnungsnummer:</div>
<div class="invoice_table_invoice_link">Download</div>
</div>
<?php
$sql_invoices = "SELECT * FROM invoices WHERE project_id = {$_GET['id']}";
$result = mysqli_query($conn, $sql_invoices);
if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_assoc($result)){
?>
<div class="project_view_invoice_table">
<div class="invoice_table_invoice_name"><?php echo $row[project_id]; ?></div>
<div class="invoice_table_invoice_price"><?php echo number_format($row[summe],2); ?> €</div>
<div class="invoice_table_invoice_id"><?php echo $row[rn]; ?></div>
<div class="invoice_table_invoice_link"><a href="documents/invoice/invoice_<?php echo $row[rn]; ?>_<?php echo strtolower(str_replace(' ','_',$company)); ?>_<?php echo strtolower(str_replace(' ','_',$project)); ?>.pdf">Download</a></div>
</div>
<?php
$total_invoice += $row[summe];
}
}
$pos_price -= $total_invoice;
echo number_format($pos_price,2);
?>
</div>
<div class="button_row">
<input type="hidden" id="pos_price" value="<?php echo number_format($pos_price,2); ?>">
<div class="row">
<a href="index.php?page=project_edit&id=<?php echo $_GET['id']; ?>"><btn type="submit" class="btn btn-send btn-block disabled" value="Send message">Bearbeiten</button></btn></a>
</div>
<div class="row">
<a href="functions/generate_pdf.php?id=<?php echo $_GET['id']; ?>&action=save_file&type=quotation"><btn type="submit" class="btn btn-send btn-block disabled" value="Send message">Kostenvoranschlag erstellen</button></btn></a>
</div>
<div class="row">
<a href="functions/generate_pdf.php?id=<?php echo $_GET['id']; ?>&action=save_file&type=invoice" onclick="return create_invoice()"><btn type="submit" class="btn btn-send btn-block disabled" value="Send message">Rechnung erstellen</button></btn></a>
</div>
</div>
</div>
</form>
</div>
</div>