Subversion-Projekte lars-tiefland.ci

Revision

Revision 2285 | Revision 2287 | Zur aktuellen Revision | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 2285 Revision 2286
Zeile 3... Zeile 3...
3
/**
3
/**
4
 *
4
 *
5
 * @package WebanOS CI
5
 * @package WebanOS CI
6
 * @author Lars Tiefland <ltiefland@gmail.com> 
6
 * @author Lars Tiefland <ltiefland@gmail.com> 
7
 * @copyright 2016
7
 * @copyright 2016
8
 * @version $Rev: 2285 $
8
 * @version $Rev: 2286 $
9
 */
9
 */
Zeile 10... Zeile 10...
10
 
10
 
11
class Logistiker_model extends CI_Model
11
class Logistiker_model extends CI_Model
12
{
12
{
Zeile 47... Zeile 47...
47
	{
47
	{
48
	}
48
	}
Zeile 49... Zeile 49...
49
 
49
 
50
	public function export($id)
50
	public function export($id)
-
 
51
	{
-
 
52
		$sQuery = "SELECT DISTINCT
-
 
53
                    exported
-
 
54
                FROM
-
 
55
                    artikel_to_Bestellung ab
-
 
56
                JOIN
-
 
57
                    bestellung_logistiker bl
-
 
58
                ON
-
 
59
                    bl.logistiker=$id
-
 
60
                AND
-
 
61
                    bl.bestellung = ab.Bestellung
-
 
62
                WHERE
-
 
63
                    exported
-
 
64
 
-
 
65
                $sWhere
-
 
66
                $sOrder
-
 
67
                $sLimit
-
 
68
            ";
-
 
69
 
-
 
70
		$rResult = $this->order_db->query($sQuery);
-
 
71
 
-
 
72
		/* Data set length after filtering */
-
 
73
		$sQuery = "
-
 
74
                        SELECT FOUND_ROWS() AS total
-
 
75
                ";
-
 
76
		$rResultFilterTotal = $this->order_db->query($sQuery);
-
 
77
		$aResultFilterTotal = $aResultFilterTotal->unbuffered_row('array');
-
 
78
		$iFilteredTotal = $aResultFilterTotal["total"];
-
 
79
 
-
 
80
		/* Total data set length */
-
 
81
		$sQuery = "
-
 
82
                        SELECT
-
 
83
                    COUNT(" . $sIndexColumn . ") AS total
-
 
84
                FROM
-
 
85
                    artikel_to_Bestellung ab
-
 
86
                JOIN
-
 
87
                    bestellung_logistiker bl
-
 
88
                ON
-
 
89
                    bl.logistiker=$id
-
 
90
                AND
-
 
91
                    bl.bestellung = ab.Bestellung
-
 
92
                WHERE
-
 
93
                    exported
-
 
94
                ";
-
 
95
		$rResultTotal = $this->order_db->query($sQuery);
-
 
96
		$aResultTotal = $aResultTotal->unbuffert_row('array');
Zeile -... Zeile 97...
-
 
97
		$iTotal = $aResultTotal["total"];
-
 
98
 
-
 
99
 
-
 
100
		/*
-
 
101
		* Output
-
 
102
		*/
-
 
103
		$output = array(
-
 
104
			"sEcho" => intval($echo['sEcho']),
-
 
105
			"iTotalRecords" => $iTotal,
-
 
106
			"iTotalDisplayRecords" => $iTotal,
-
 
107
			"aaData" => array());
-
 
108
 
-
 
109
		$sql = "SELECT
-
 
110
                    export_script
-
 
111
                FROM
-
 
112
                    logistiker
-
 
113
                WHERE
-
 
114
                    id = " . $id . "
-
 
115
            ";
-
 
116
		$res = $this->order_db->query($sql);
-
 
117
		$nrow = $res->unbuffered_row('array');
-
 
118
		if (strstr($nrow["export_script"], "=")) {
-
 
119
			$qs = explode(";", $nrow["export_script"]);
-
 
120
			foreach ($qs as $val) {
-
 
121
				list($key, $wert) = explode("=", $val);
-
 
122
				if ($key == "mode") {
-
 
123
					$qsArr[] = "mode=" . $wert;
-
 
124
				} elseif (is_null($wert)) {
-
 
125
					$script = $key;
-
 
126
				} elseif (!stristr($key, "status") && $wert) {
-
 
127
					$qsArr[] = "$key=" . $wert;
-
 
128
				}
-
 
129
			}
-
 
130
			$qs = implode("&", $qsArr);
-
 
131
		} else {
-
 
132
			list($script, $mode) = explode(";", $nrow["export_script"]);
-
 
133
			$qs = "mode=" . $mode;
-
 
134
		}
-
 
135
		while ($aRow = $rResult->unbuffered_row('array')) {
-
 
136
			$aRow['exported'] = '<a href="/Warenwirtschaft/' . $script . '?time=' . $aRow['exported'] .
-
 
137
				'&id=' . $id . '&' . $qs . '" target="_blank">' . date('d.m.Y H:i:s', strtotime
-
 
138
				($aRow['exported'])) . '</a>';
-
 
139
			$row = array();
-
 
140
			for ($i = 0; $i < count($aColumns); $i++) {
-
 
141
				if ($aColumns[$i] == "version") {
-
 
142
					/* Special output formatting for 'version' column */
-
 
143
					$row[] = ($aRow[$aColumns[$i]] == "0") ? '-' : $aRow[$aColumns[$i]];
-
 
144
				} else
-
 
145
					if ($aColumns[$i] != ' ') {
-
 
146
						/* General output */
-
 
147
						$row[] = $aRow[$aColumns[$i]];
-
 
148
					}
-
 
149
			}
-
 
150
			$output['aaData'][] = $row;
-
 
151
		}
51
	{
152
 
Zeile 52... Zeile 153...
52
 
153
		return json_encode($output);
53
	}
154
	}
54
 
155
 
Zeile 143... Zeile 244...
143
 
244
 
144
		/*
245
		/*
145
		* Output
246
		* Output
146
		*/
247
		*/
147
		$output = array(
248
		$output = array(
148
			"sEcho" => intval($_GET['sEcho']),
249
			"sEcho" => intval($this->input->get('sEcho')),
149
			"iTotalRecords" => $iTotal,
250
			"iTotalRecords" => $iTotal,
150
			"iTotalDisplayRecords" => $iFilteredTotal,
251
			"iTotalDisplayRecords" => $iFilteredTotal,
Zeile 151... Zeile 252...
151
			"aaData" => array());
252
			"aaData" => array());
Zeile 187... Zeile 288...
187
		$output['aaData'][] = $row;
288
		$output['aaData'][] = $row;
Zeile 188... Zeile 289...
188
 
289
 
189
		return json_encode($output);
290
		return json_encode($output);
Zeile 190... Zeile -...
190
	}
-
 
191
 
-
 
192
	public function getexportjson($sLimit, $sOrder, $sWhere, $id, $aColumns, $sIndexColumn,
-
 
193
		$echo)
-
 
194
	{
-
 
195
 
-
 
196
		$sQuery = "SELECT DISTINCT
-
 
197
                    exported
-
 
198
                FROM
-
 
199
                    artikel_to_Bestellung ab
-
 
200
                JOIN
-
 
201
                    bestellung_logistiker bl
-
 
202
                ON
-
 
203
                    bl.logistiker=$id
-
 
204
                AND
-
 
205
                    bl.bestellung = ab.Bestellung
-
 
206
                WHERE
-
 
207
                    exported
-
 
208
 
-
 
209
                $sWhere
-
 
210
                $sOrder
-
 
211
                $sLimit
-
 
212
            ";
-
 
213
 
-
 
214
		$rResult = $this->order_db->query($sQuery);
-
 
215
 
-
 
216
		/* Data set length after filtering */
-
 
217
		$sQuery = "
-
 
218
                        SELECT FOUND_ROWS() AS total
-
 
219
                ";
-
 
220
		$rResultFilterTotal = $this->order_db->query($sQuery);
-
 
221
		$aResultFilterTotal = $aResultFilterTotal->unbuffered_row('array');
-
 
222
		$iFilteredTotal = $aResultFilterTotal["total"];
-
 
223
 
-
 
224
		/* Total data set length */
-
 
225
		$sQuery = "
-
 
226
                        SELECT
-
 
227
                    COUNT(" . $sIndexColumn . ") AS total
-
 
228
                FROM
-
 
229
                    artikel_to_Bestellung ab
-
 
230
                JOIN
-
 
231
                    bestellung_logistiker bl
-
 
232
                ON
-
 
233
                    bl.logistiker=$id
-
 
234
                AND
-
 
235
                    bl.bestellung = ab.Bestellung
-
 
236
                WHERE
-
 
237
                    exported
-
 
238
                ";
-
 
239
		$rResultTotal = $this->order_db->query($sQuery);
-
 
240
		$aResultTotal = $aResultTotal->unbuffert_row('array');
-
 
241
		$iTotal = $aResultTotal["total"];
-
 
242
 
-
 
243
 
-
 
244
		/*
-
 
245
		* Output
-
 
246
		*/
-
 
247
		$output = array(
-
 
248
			"sEcho" => intval($echo['sEcho']),
-
 
249
			"iTotalRecords" => $iTotal,
-
 
250
			"iTotalDisplayRecords" => $iTotal,
-
 
251
			"aaData" => array());
-
 
252
 
-
 
253
		$sql = "SELECT
-
 
254
                    export_script
-
 
255
                FROM
-
 
256
                    logistiker
-
 
257
                WHERE
-
 
258
                    id = " . $id . "
-
 
259
            ";
-
 
260
		$res = $this->order_db->query($sql);
-
 
261
		$nrow = $res->unbuffered_row('array');
-
 
262
		if (strstr($nrow["export_script"], "=")) {
-
 
263
			$qs = explode(";", $nrow["export_script"]);
-
 
264
			foreach ($qs as $val) {
-
 
265
				list($key, $wert) = explode("=", $val);
-
 
266
				if ($key == "mode") {
-
 
267
					$qsArr[] = "mode=" . $wert;
-
 
268
				} elseif (is_null($wert)) {
-
 
269
					$script = $key;
-
 
270
				} elseif (!stristr($key, "status") && $wert) {
-
 
271
					$qsArr[] = "$key=" . $wert;
-
 
272
				}
-
 
273
			}
-
 
274
			$qs = implode("&", $qsArr);
-
 
275
		} else {
-
 
276
			list($script, $mode) = explode(";", $nrow["export_script"]);
-
 
277
			$qs = "mode=" . $mode;
-
 
278
		}
-
 
279
		while ($aRow = $rResult->unbuffered_row('array')) {
-
 
280
			$aRow['exported'] = '<a href="/Warenwirtschaft/' . $script . '?time=' . $aRow['exported'] .
-
 
281
				'&id=' . $id . '&' . $qs . '" target="_blank">' . date('d.m.Y H:i:s', strtotime
-
 
282
				($aRow['exported'])) . '</a>';
-
 
283
			$row = array();
-
 
284
			for ($i = 0; $i < count($aColumns); $i++) {
-
 
285
				if ($aColumns[$i] == "version") {
-
 
286
					/* Special output formatting for 'version' column */
-
 
287
					$row[] = ($aRow[$aColumns[$i]] == "0") ? '-' : $aRow[$aColumns[$i]];
-
 
288
				} else
-
 
289
					if ($aColumns[$i] != ' ') {
-
 
290
						/* General output */
-
 
291
						$row[] = $aRow[$aColumns[$i]];
-
 
292
					}
-
 
293
			}
-
 
294
			$output['aaData'][] = $row;
-
 
295
		}
-
 
296
 
-
 
297
		return json_encode($output);
291
	}
Zeile 298... Zeile 292...
298
	}
292