Subversion-Projekte lars-tiefland.ci

Revision

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