Subversion Repositories artstore

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 p.duerhamm 1
<?php
2
/***************************************************************************
3
 *   Copyright (C) 2014 by Computerhaus GmbH                               *
4
 *   m@kom.at                                                              *
5
 *                                                                         *
6
 *   COPYRIGHT (C) 2014      by COMPUTERHAUS EDV-HANDELS GMBH. ALL RIGHTS  *
7
 *   RESERVED. NO PART OF THIS PRGORAM OR PUBLICATION MAY BE REPRODUCED,   *
8
 *   TRANSLATED, TRANSCRIBED, STORED IN A RETRIEVAL SYSTEM, OR TRANSLATED  *
9
 *   INTO ANY LANGUAGE OR COMPUTER LANGUAGE IN ANY FORM OR BY ANY MEANS,   *
10
 *   ELECTRONIC, MECHANICAL, MAGNETIC, OPTICAL, CHEMICAL, MANUAL, OR       *
11
 *   OTHERWISE, WITHOUT THE PRIOR WRITTEN PERMISSION OF:                   *
12
 *                                                                         *
13
 *                 COMPUTERHAUS EDV-HANDELS GES.M.B.H                      *
14
 *                                                                         *
15
 *               WIENERSTRASSE 26 - 8605 KAPFENBERG - AUSTRIA              *
16
 *                                                                         *
17
 ***************************************************************************/
18
 
19
spl_autoload_register(null, false );
20
spl_autoload_extensions( '.php, .class.php' );
21
 
22
require_once 'includes/configuration.php';
23
 
24
function classesLoader($class) {
25
	$filename = strtolower($class) . '.php';
26
	$file = DIR_WS_INCLUDES . $filename;
27
	if( !file_exists($file) )
28
		return false;
29
	include $file;
30
}
31
 
32
spl_autoload_register('classesLoader');
33
 
34
$db = new Database;
35
 
36
 
37
$return_data = array();
38
// $return_data['error_text'] = "";
39
 
40
if ( isset($_GET) ) {
41
	error_log( 'backend GET DATA: ' . print_r( $_GET, true ) );
42
}
43
if ( isset($_POST) ) {
44
	error_log( 'backend POST DATA: ' . print_r( $_POST, true ) );
45
}
46
 
47
if ( ( isset ( $_GET ) ) && ( Core::array_has_content($_GET) ) && ( array_key_exists('action',$_GET) ) ) {
48
 
49
// 	$colli_uuid = ( ( ( array_key_exists('colli_uuid',$_GET) ) && ( is_numeric ( $_GET['colli_uuid'] ) ) ) ? $_GET['colli_uuid'] : false );
50
	$colli_uuids = array();
51
	if ( array_key_exists('colli_uuid',$_GET) ) {
52
		if ( strpos( $_GET['colli_uuid'], "\n" ) !== false ) {
53
			if ( Core::array_has_content( $colli_uuid_data = explode("\n",$_GET['colli_uuid']) ) ) {
54
				foreach( $colli_uuid_data AS $colli_uuid ) {
55
					$colli_uuids[] = $colli_uuid;
56
				}
57
			}
58
		} elseif ( is_numeric($_GET['colli_uuid']) ) {
59
			$colli_uuids[] = $_GET['colli_uuid'];
60
		}
61
	}
62
	$sector_uuid = ( ( ( array_key_exists('sector_uuid',$_GET) ) && ( is_numeric ( $_GET['sector_uuid'] ) ) ) ? $_GET['sector_uuid'] : false );
63
	$store_type = ( ( ( array_key_exists('store_type',$_GET) ) && ( !empty( $_GET['store_type'] ) ) ) ? $_GET['store_type'] : false );
64
	$additional_type = ( ( ( array_key_exists('additional_type',$_GET) ) && ( !empty( $_GET['additional_type'] ) ) ) ? $_GET['additional_type'] : false );
65
	$objinfo_uuid = ( ( ( array_key_exists('objinfo_uuid',$_GET) ) && ( !empty( $_GET['objinfo_uuid'] ) ) ) ? $_GET['objinfo_uuid'] : false );
66
 
67
	switch ( $_GET['action'] ) {
68
		case 'check_colli_uuid':
69
			$return_data['success'] = false;
70
// 			if ( strpos($colli_uuid,"\n") !== false && Core::array_has_content( $colli_uuids = implode("\n",$colli_uuid) ) ) {
71
			if ( Core::array_has_content($colli_uuids) ) {
72
				$count_ok = 0;
73
				$count_nok = 0;
74
				$row = 0;
75
				$infos = array();
76
				$errors = array();
77
				foreach( $colli_uuids AS $colli_uuid ) {
78
					$row++;
79
					if ( !empty($colli_uuid) ) {
80
						if ( ( $colli_id = Core::get_colli_id_by_colli_uuid($colli_uuid) ) > 0 ) {
81
							$allowed_moves = Core::get_allowed_store_type_for_colli_id($colli_id);
82
							$return_data['cid'][] = 'CUR: '.Core::get_last_store_type_for_colli_id( $colli_id ).', allowed: <'.implode(',',$allowed_moves).'>';
83
 
84
							if ( $store_type !== false ) {
85
								$store_type_id = str_replace( 'store_type_','', $store_type);
86
								if ( in_array($store_type_id,$allowed_moves) ) {
87
									$infos[] = "Zeile $row: OK";
88
									$count_ok++;
89
								} else {
90
									$errors[] = "Zeile $row: Falsche Buchung f&uuml;r Paket";
91
									$count_nok++;
92
								}
93
							}
94
						} else {
95
							$errors[] = "Zeile $row: Paket nicht gefunden";
96
							$count_nok++;
97
						}
98
					}
99
				}
100
				if ( $count_ok > 0 && $count_nok == 0 ) {
101
					$return_data['success'] = true;
102
					$return_data['info'] = implode('<br>',$infos);
103
					$return_data['error_text'] = implode('<br>',$errors);
104
				} else {
105
					$return_data['success'] = false;
106
					$return_data['info'] = implode('<br>',$infos);
107
					$return_data['error_text'] = implode('<br>',$errors);
108
				}
109
			}
110
// 			else {
111
// 				if ( ( $colli_id = Core::get_colli_id_by_colli_uuid($colli_uuid) ) > 0 ) {
112
// 					$allowed_moves = Core::get_allowed_store_type_for_colli_id($colli_id);
113
// 					$return_data['cid'] = Core::get_last_store_type_for_colli_id( $colli_id ).'----'.print_r($allowed_moves,1);
114
//
115
// 					if ( $store_type !== false ) {
116
// 						$store_type_id = str_replace( 'store_type_','', $store_type);
117
// 						if ( in_array($store_type_id,$allowed_moves) ) {
118
// 							$return_data['success'] = true;
119
// 						} else {
120
// 							$return_data['error_text'] = "Falsche Buchung f&uuml;r Paket";
121
// 							$return_data['success'] = false;
122
// 						}
123
// 					}
124
// 				}
125
// 			}
126
			break;
127
		case 'check_sector_uuid':
128
// 		echo Core::get_sector_id_by_sector_uuid($sector_uuid);
129
			if ( Core::get_sector_id_by_sector_uuid($sector_uuid) > 0 ) {
130
				$return_data['success'] = true;
131
			}
132
			break;
133
		case 'check_objinfo_uuid':
134
			if ( Core::get_object_id_by_object_uuid($objinfo_uuid) > 0 ) {
135
				$return_data['success'] = true;
136
			} else {
137
				$return_data['error_text'] = 'Objekt wurde nicht gefunden (' . $objinfo_uuid . ')';
138
				$return_data['success'] = false;
139
			}
140
			break;
141
		case 'summary':
142
		case 'summary_objinfo':
143
			$text = array();
144
 
145
			if ( $store_type !== false ) {
146
				$store_type_name = 'unbekannt';
147
				foreach ( Core::get_store_types() AS $cur_type ) {
148
					if ( $store_type == 'store_type_' . $cur_type['id'] ) {
149
						$store_type_name = $cur_type['name'];
150
						break;
151
					}
152
				}
153
				$text[] = 'ausgew&auml;hlter Vorgang: ' . $store_type_name;
154
			} elseif ( $additional_type !== false ) {
155
				$additional_type_name = 'unbekannt';
156
				foreach ( Core::get_additional_selection() AS $cur_type ) {
157
					if ( $additional_type == 'additional_type_' . $cur_type['id'] ) {
158
						$additional_type_name = $cur_type['name'];
159
						break;
160
					}
161
				}
162
				$text[] = 'ausgew&auml;hlter Vorgang: ' . $additional_type_name;
163
			}
164
 
165
// 			if ( $colli_uuid !== false ) {
166
// 				$text[] = 'Colli UUID: ' . $colli_uuid;
167
// 				$text[] = 'Colli ID: ' . Core::get_colli_id_by_colli_uuid($colli_uuid);
168
// 			}
169
 
170
			if ( Core::array_has_content($colli_uuids) ) {
171
				foreach( $colli_uuids AS $colli_uuid ) {
172
					$text[] = 'Colli UUID: ' . $colli_uuid;
173
					$text[] = 'Colli ID: ' . Core::get_colli_id_by_colli_uuid($colli_uuid);
174
				}
175
			}
176
 
177
			if ( $sector_uuid !== false ) {
178
				$text[] = 'Sector UUID: ' . $sector_uuid;
179
				$text[] = 'Sector ID: ' . Core::get_sector_id_by_sector_uuid($sector_uuid);
180
				if ( Core::array_has_content($colli_uuids) ) {
181
					foreach( $colli_uuids AS $colli_uuid ) {
182
						$text[] = 'Projekt: ' . Core::get_projekte_id_by_colli_uuid($colli_uuid);
183
					}
184
				}
185
			}
186
 
187
			if ( $objinfo_uuid !== false ) {
188
// 				$text[] = 'Objekt-Info zu UUID: ' . $objinfo_uuid;
189
				if ( ( $obj_data = $db->get_object_data_by_object_uuid( $objinfo_uuid ) ) !== false ) {
190
// 					$text[] = 'Object: ' . $obj_data['projekte_objektliste_id'];
191
					$text[] = 'Lender: ' . utf8_decode($obj_data['projekte_objektliste_lender']);
192
					$text[] = 'Artist: ' . utf8_decode($obj_data['projekte_objektliste_artist']);
193
					$text[] = 'Title: ' . utf8_decode($obj_data['projekte_objektliste_title']);
194
					$text[] = 'Inv.No.: ' . utf8_decode($obj_data['projekte_objektliste_inv_nr']);
195
					$text[] = 'Project No: ' . utf8_decode($obj_data['projekte_projektnummer']);
196
					$text[] = 'Project Name: ' . utf8_decode($obj_data['projekte_name']);
197
				}
198
			}
199
 
200
			$return_data['success'] = true;
201
			$return_data['text'] = ( ( Core::array_has_content($text) ) ?  implode ( '<br>' , $text ) : '' );
202
			break;
203
 
204
		case 'show_result':
205
			if ( ( $store_type !== false ) && ( Core::array_has_content($colli_uuids) ) && ( $sector_uuid !== false ) ) {
206
				$store_type_name = 'unbekannt';
207
				foreach ( Core::get_store_types() AS $cur_type ) {
208
					if ( $store_type == 'store_type_' . $cur_type['id'] ) {
209
						$store_type_name = $cur_type['name'];
210
						break;
211
					}
212
				}
213
				$text = 'Bitte Daten &uuml;berpr&uuml;fen und best&auml;tigen!';
214
 
215
				$return_data['success'] = true;
216
				$return_data['text'] = $text;
217
			}
218
			break;
219
 
220
		case 'submit':
221
			if ( ( $store_type !== false ) && ( Core::array_has_content($colli_uuids) ) && ( $sector_uuid !== false ) ) {
222
				$success = false;
223
				$store_type_id = false;
224
				$store_type_name = 'unbekannt';
225
				foreach ( Core::get_store_types() AS $cur_type ) {
226
					if ( $store_type == 'store_type_' . $cur_type['id'] ) {
227
						$store_type_id = $cur_type['id'];
228
						$store_type_name = $cur_type['name'];
229
						break;
230
					}
231
				}
232
				foreach( $colli_uuids AS $colli_uuid ) {
233
					$success = Core::save_store_action_prepare ( $store_type_id , $sector_uuid , $colli_uuid );
234
				}
235
 
236
				if ( $success ) {
237
					$text = 'Daten erfolgreich gespeichert!';
238
				} else {
239
					$text = 'FEHLER: Konnte Datensatz nicht speichern!';
240
				}
241
				$return_data['success'] = $success;
242
				$return_data['text'] = $text;
243
			}
244
			break;
245
 
246
	}
247
 
248
}
249
 
250
$return_data['collis'] = print_r($colli_uuids,1);
251
 
252
if ( !Core::array_has_content($return_data) ) {
253
	$return_data['success'] = false;
254
	$return_data['info'] = 'Fehler bei der &Uuml;bertragung';
255
	$return_data['error_text'] = 'Fehler bei der &Uuml;bertragung';
256
}
257
if ( !array_key_exists('error_text', $return_data) ) {
258
	$return_data['error_text'] = "";
259
}
260
 
261
// $return_data['GET'] = $_GET;
262
// $return_data['POST'] = $_POST;
263
 
264
echo json_encode($return_data);
265
 
266
?>