-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject_edit.php
211 lines (154 loc) · 7.85 KB
/
project_edit.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
<div class="title"><h2>Projekt bearbeiten</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');
$id = $_GET['id'];
$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'";
$result = mysqli_query($conn, $sql);
$show_title = true;
$hours_all = 0;
$hours_worked_all = 0;
$price_all = 0;
$counter = 0;
if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_assoc($result)){
$positions_id = $row[id];
$counter++;
if($show_title){
?>
<div class="form_company">
<div class="form-group">
<label for="form_company">Firma</label>
<input 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 id="form_name" type="date" name="form_start" value="<?php echo $row[start_date] ?>" class="form-control" required="required" data-error="Start date is required.">
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label for="form_lastname">Deadline</label>
<input id="form_lastname" type="date" name="form_deadline" value="<?php echo $row[deadline] ?>" class="form-control" data-error="Deadline 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">
<label>Geleistet</label>
</div>
</div>
<div id="positions">
<?php
$show_title = false;
} ?>
<div class="form_table_row" id="position_row_<?php echo $row[id]; ?>">
<div class="form-group">
<textarea id="position_name_<?php echo $row[id]; ?>" name="position_name_<?php echo $counter; ?>" class="form-control" required="required" data-error="" ><?php echo $row[position_name]; ?></textarea>
</div>
<div class="form-group">
<?php
$priceclass_id = $row[priceclass];
$sql2 = "SELECT * FROM priceclass";
$result2 = mysqli_query($conn, $sql2);
echo "<select id ='form_priceclass_" . $row[id] . "' name='form_priceclass_" . $counter . "' class='form-control' required='required' data-error='Firstname is required.' data-id='" . $row[id] . "'>";
while ($row2 = mysqli_fetch_assoc($result2)) {
if($priceclass_id == $row2['id']){
$selected = 'selected="selected"';
}
echo "<option " . $selected . " value='" . $row2['id'] . "'>" . $row2['priceclass_name'] . "</option>";
$selected = "";
}
echo "</select>";
?>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<input id="position_hours_<?php echo $row[id]; ?>" type="number" step="0.25" name="form_est_hours_<?php echo $counter; ?>" value="<?php echo $row[position_hours]; ?>" class="form-control" data-id="<?php echo $row[id]; ?>">
</div>
<div class="form-group">
<input id="total_price_<?php echo $row[id]; ?>" type="text" name="total_price_<?php echo $counter; ?>" value="<?php echo $row[position_hours] * $row[rate]; ?> €" class="form-control disabled">
<input type="hidden" name="position_id_<?php echo $counter; ?>" value="<?php echo $row[id]; ?>">
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<input id="hours_worked_<?php echo $row[id]; ?>" type="text" name="hours_worked_<?php echo $counter; ?>" value="<?php echo seconds2human(calc_time_diff($positions_id)); ?>" class="form-control" data-id="<?php echo $row[id]; ?>">
<input type="hidden" id="form_status_<?php echo $row[id]; ?>" name="form_status_<?php echo $counter; ?>" value="false">
<a class="btn_delete" id="<?php echo $row[id]; ?>">Delete</a>
<div class="help-block with-errors"></div>
</div>
</div>
<input type="hidden" name="delete_pos_<?php echo $counter; ?>" id="delete_pos_<?php echo $row[id]; ?>" value="">
<?php
$hours_all += $row[position_hours];
$hours_worked_all += calc_time_diff($row[id]);
$price_all += $row[position_hours] * $row[rate];
$memos = $row[memos];
}
}
?>
</div>
<div class="row">
<btn id="add_position_form" class="btn_add_position">Neue Position</button>
</div>
<div class="form_table_row form_table_last_row">
<div class="form-group">
</div>
<div class="form-group">
</div>
<div class="form-group">
</div>
<div class="form-group">
</div>
<div class="form-group">
</div>
</div>
<div class="section_title">Weiteres</div>
<div class="row">
<div class="form-group">
<label form="form_memo">Memo</label>
<textarea id="form_memo" name="memo" value="" class="form-control" 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="row">
<button type="submit" class="btn btn-send btn-block disabled" value="Send message">Speichern</button><br><br>
<a id="delete_project" data-id="<?php echo $id; ?>">Projekt löschen</a>
</div>
</div>
<input type="hidden" name="id" value="<?php echo $id; ?>">
<input type="hidden" name="action" value="edit_project">
<input type="hidden" name ="new_position_counter" id="new_position_counter" value="<?php echo $counter; ?>">
<input type="hidden" id="project_positions" name="project_positions" value="<?php echo $counter; ?>">
</form>
</div>
</div>