Subversion-Projekte lars-tiefland.ci

Revision

Revision 1323 | Revision 1329 | Zur aktuellen Revision | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1131 lars 1
<?php
2
 
3
/**
4
 * User
5
 *
6
 * @package
7
 * @author WebanOS CI
8
 * @copyright Lars Tiefland
9
 * @version 2016
10
 * @access public
11
 */
12
class Order extends CI_Controller
13
{
14
 
15
	public function __construct()
16
	{
17
		parent::__construct();
18
		$this->load->model('order_model', 'order');
19
	}
20
	/**
21
	 * User::index()
22
	 *
23
	 * @return
24
	 */
25
	public function index()
26
	{
1133 lars 27
		$orders = $this->order->get_list();
1131 lars 28
		$this->smarty->assign('orders', $orders);
29
		$this->smarty->view('orders.tpl');
30
	}
31
 
32
	/**
33
	 * User::edit()
34
	 *
35
	 * @param mixed $id
36
	 * @return void
37
	 */
38
	public function edit($id = null)
39
	{
1271 lars 40
		$daten["artikel_stati"] = array(
41
			array(
42
				"name" => "offen",
43
				"short" => "O",
44
				"class" => "status_red"),
45
			array(
46
				"name" => "in Bearbeitung",
47
				"short" => "B",
48
				"class" => "status_yellow",
49
				),
50
			array(
51
				"name" => "reserviert",
52
				"short" => "R",
53
				"class" => "status_blue",
54
				),
55
			array(
56
				"name" => "erledigt",
57
				"short" => "E",
58
				"class" => "status_green",
59
				),
60
			array(
61
				"name" => "abgeschlossen",
62
				"short" => "A",
63
				"class" => "status_white",
64
				),
65
			);
66
		$daten["rechnung_stati"] = array(
67
			array(
68
				"name" => "schreiben",
69
				"short" => "S",
70
				"class" => "status_red"),
71
			array(
72
				"name" => "geschrieben",
73
				"short" => "G",
74
				"class" => "status_yellow",
75
				),
76
			array(
77
				"name" => "bezahlt",
78
				"short" => "B",
79
				"class" => "status_green",
80
				),
81
			);
82
		$daten["lieferschein_stati"] = array(
83
			array(
84
				"name" => "schreiben",
85
				"short" => "S",
86
				"class" => "status_yellow"),
87
			array(
88
				"name" => "geschrieben",
89
				"short" => "G",
90
				"class" => "status_green",
91
				),
92
			array(
93
				"name" => "offen",
94
				"short" => "O",
95
				"class" => "status_red",
96
				),
97
			);
98
		$daten["mahnung_stati"] = array(
99
			array(
100
				"name" => "mahnung1",
101
				"short" => "1",
102
				"class" => "status_green"),
103
			array(
104
				"name" => "mahnung2",
105
				"short" => "2",
106
				"class" => "status_yellow",
107
				),
108
			array(
109
				"name" => "mahnung3",
110
				"short" => "3",
111
				"class" => "status_red",
112
				),
113
			);
114
		$daten["garantie_stati"] = array(
115
			array(
116
				"name" => "eingereicht",
117
				"short" => "E",
118
				"class" => "status_red"),
119
			array(
120
				"name" => "abgeschlossen",
121
				"short" => "A",
122
				"class" => "status_green",
123
				),
124
			);
125
		// Modul dokumente
1288 lars 126
		$preise_anzeigen = 1;
127
		if (isset($GLOBALS["user_rechte"]["Warenwirtschaft"]["bestellung"]["preise_anzeigen"]))
128
		{
129
			if (!isset($GLOBALS["user_rechte"]["Warenwirtschaft"]["bestellung"]["preise_anzeigen"]))
130
			{
131
				// "<br>für bestimmte user preis verbergen";
132
				$preise_anzeigen = 0;
133
			}
134
		}
1172 lars 135
		$order = $this->order->get($id);
1293 lars 136
		$this->smarty->assign('title', 'Bestellung bearbeiten');
1289 lars 137
		$this->smarty->assign('preise_anzeigen', $preise_anzeigen);
1172 lars 138
		$this->smarty->assign('order', $order);
1271 lars 139
		$this->smarty->assign('daten', $daten);
1172 lars 140
		$this->smarty->view('single_order.tpl');
1131 lars 141
	}
142
 
143
	public function save()
144
	{
1323 lars 145
		$Bestellung = $this->input->post('Bestellung');
146
		if ((isset($_GET["update"]) && $_GET["update"]) || (isset($_POST["update"]) && $_POST["update"]))
147
		{
148
 
149
			if ($_POST["update"])
150
			{
151
				$update = $_POST["update"];
152
			}
153
			else
154
			{
155
				$update = $_GET["update"];
156
			}
157
 
158
			if ($_POST["cmd"])
159
			{
160
				foreach (array_keys($_POST["cmd"]) as $table)
161
				{
162
					foreach (array_keys($_POST["cmd"][$table]) as $primaryKeyValue)
163
					{
164
						$changed_id = "artikel_".$primaryKeyValue."_changed";
165
						if ($_POST[$changed_id] == 1)
166
						{
167
							foreach (array_keys($_POST["cmd"][$table][$primaryKeyValue]) as $tablefield)
168
							{
169
								$query = "
170
									UPDATE
171
										".$table."
172
									SET
173
										".$tablefield." = '".$GLOBALS["order_db"]->escape(html_entity_decode($_POST["cmd"][$table][$primaryKeyValue][$tablefield],
174
									ENT_COMPAT, $_SESSION["charset"]))."'
175
									WHERE
176
										ID = '".$primaryKeyValue."'
177
								";
178
								$result = $GLOBALS["order_db"]->query($query);
179
							}
180
						}
181
					}
182
				}
183
			}
184
			$upd_fields[] = "Bemerkung='".$GLOBALS["order_db"]->escape($_POST["Bemerkung"]).
185
				"'";
186
 
187
			if (isset($user_rechte["Warenwirtschaft"]["bestellung"]["shortline1"]))
188
			{
189
				$upd_fields[] = "shortline1 = '".$GLOBALS["order_db"]->escape($_POST["shortline1"]).
190
					"'";
191
			}
192
			if (isset($user_rechte["Warenwirtschaft"]["bestellung"]["shortline2"]))
193
			{
194
				$upd_fields[] = "shortline2 = '".$GLOBALS["order_db"]->escape($_POST["shortline2"]).
195
					"'";
196
			}
197
			if (isset($user_rechte["Warenwirtschaft"]["bestellung"]["status1"]))
198
			{
199
				$upd_fields[] = "status1 = '".$GLOBALS["order_db"]->escape($_POST["status1"]).
200
					"'";
201
			}
202
			if (isset($user_rechte["Warenwirtschaft"]["bestellung"]["Bemerkung_extern"]))
203
			{
204
				$upd_fields[] = "Bemerkung_extern='".$GLOBALS["order_db"]->escape($_POST["Bemerkung_extern"]).
205
					"'";
206
			}
207
			if (isset($user_rechte["Warenwirtschaft"]["bezahlstatus"]["bezahlstatus"]))
208
			{
209
				$upd_fields[] = "bezahlt='".$GLOBALS["order_db"]->escape($_POST["bezahlt"])."'";
210
				$upd_fields[] = "bezahlt_bemerkung='".$GLOBALS["order_db"]->escape($_POST["bezahlt_bemerkung"]).
211
					"'";
212
			}
213
			if (isset($_POST['fremd_id']))
214
			{
215
				$upd_fields[] = "fremd_id='".$GLOBALS["order_db"]->escape($_POST["fremd_id"]).
216
					"'";
217
			}
1324 lars 218
			$sql = "
1323 lars 219
				SELECT
220
					erstellt_von
221
				FROM
222
					Bestellung
223
				WHERE
224
					ID=".$Bestellung."
225
			";
226
 
227
			$result = $GLOBALS["order_db"]->query($sql);
228
			$zeile = $result->unbuffered_row('array');
229
			if ($zeile["erstellt_von"] == '')
230
			{
231
				$upd_fields[] = "erstellt_von='".$_SERVER["PHP_AUTH_USER"]."'";
232
			}
233
			if ($_POST["s_changed"] == 1)
234
			{
235
				$upd_fields[] = "shops_ID=".$_POST["s_id"];
236
			}
237
			$sql = "
238
				UPDATE
239
					Bestellung
240
				SET
241
					letzte_Aenderung_von='".$_SERVER["PHP_AUTH_USER"]."',
242
					".implode(",", $upd_fields)."
243
				WHERE
244
					ID=".$Bestellung."
245
			";
246
			$GLOBALS["order_db"]->query($sql);
247
			if (isset($_POST["logistiker_id"]))
248
			{
249
				if ($_POST["logistiker_id"])
250
				{
251
					$sql_bl = "
252
						REPLACE INTO
253
							bestellung_logistiker
254
						SET
255
							bestellung=".$Bestellung.",
256
							logistiker=".$_POST["logistiker_id"]."
257
					";
258
 
259
					$GLOBALS["order_db"]->query($sql_bl);
260
					if (isset($web_rechte["admin"]["toolbox"]["logbuch"]))
261
					{
262
						$GLOBALS["Log"]["best"]->log("Logistiker der Bestellung geändert", $Bestellung);
263
					}
264
				}
265
				else
266
				{
267
					$sql_bl = "
268
						DELETE FROM
269
							bestellung_logistiker
270
						WHERE
271
							bestellung=".$Bestellung."
272
					";
273
					$GLOBALS["order_db"]->query($sql_bl);
274
					if (isset($web_rechte["admin"]["toolbox"]["logbuch"]))
275
					{
276
						$GLOBALS["Log"]["best"]->log("Logistiker der Bestellung geändert", $Bestellung);
277
					}
278
				}
279
			}
280
			if (isset($update["current"]))
281
			{
282
				header("Location: /backend/order/edit/".$Bestellung);
283
			}
284
			elseif (isset($update["list"]))
285
			{
286
				header("Location: /backend/order/index#".$Bestellung);
287
			}
288
		}
1131 lars 289
	}
1172 lars 290
 
1131 lars 291
	public function del($id = null)
292
	{
293
	}
294
 
295
}