@@ -242,6 +242,10 @@ public function updateSpaceApi( $_spaceAPI )
242
242
243
243
public function updateDatabase ( )
244
244
{
245
+ // Audit/correct using this:
246
+ // https://ackspace.nl/spaceAPI/?key=API_KEY&address=premiumcola&update=sensors&type=audit&value=1&location=1&user=xopr
247
+ // https://ackspace.nl/spaceAPI/?key=API_KEY&address=premiumcola&update=sensors&type=correct&value=1
248
+
245
249
global $ sensorAbstraction ;
246
250
247
251
//Gather the information to load into the database
@@ -253,6 +257,9 @@ public function updateDatabase( )
253
257
$ arrLon = getVar ( "lon " );
254
258
$ arrAccuracy = getVar ( "accuracy " );
255
259
260
+ $ arrUser = getVar ( "user " ); // string
261
+ $ arrLocation = getVar ( "location " ); // id
262
+
256
263
if ( !is_array ( $ arrAddress ) )
257
264
$ arrAddress = Array ( $ arrAddress );
258
265
if ( !is_array ( $ arrValue ) )
@@ -267,6 +274,11 @@ public function updateDatabase( )
267
274
if ( !is_array ( $ arrAccuracy ) )
268
275
$ arrAccuracy = Array ( $ arrAccuracy );
269
276
277
+ if ( !is_array ( $ arrLocation ) )
278
+ $ arrLocation = Array ( $ arrLocation );
279
+ if ( !is_array ( $ arrUser ) )
280
+ $ arrUser = Array ( $ arrUser );
281
+
270
282
$ success = true ;
271
283
272
284
foreach ( $ arrAddress as $ idx => $ address )
@@ -300,30 +312,36 @@ public function updateDatabase( )
300
312
$ success = false ;
301
313
break ;
302
314
303
- case "audit " :
315
+ case "audit " :
304
316
if ( getVar ( "debug " ) !== false )
305
- print_r ( "AUDIT \n" .$ arrAddress [ $ idx ]."## " .$ arrValue [ $ idx ]."## \n" );
317
+ print_r ( "AUDIT \n" .$ arrAddress [ $ idx ]."## " .$ arrValue [ $ idx ]."## " . $ arrLocation [ $ idx ]. " ## " . $ arrUser [ $ idx ]. " ## \n" );
306
318
319
+ // Barcode, amount, location id, user
307
320
if ( !isset ( $ arrAddress [ $ idx ] ) )
308
321
continue ;
309
322
if ( !isset ( $ arrValue [ $ idx ] ) )
310
323
continue ;
324
+ if ( !isset ( $ arrLocation [ $ idx ] ) )
325
+ continue ;
326
+ if ( !isset ( $ arrUser [ $ idx ] ) )
327
+ continue ;
311
328
312
- if ( !$ sensorAbstraction ->updateStock ( $ arrAddress [ $ idx ], $ arrValue [ $ idx ], true ) )
329
+ if ( !$ sensorAbstraction ->updateStock ( $ arrAddress [ $ idx ], $ arrValue [ $ idx ], true , $ arrLocation [ $ idx ], $ arrUser [ $ idx ] ) )
313
330
$ success = false ;
314
331
break ;
315
332
316
- case "correct " :
333
+ case "correct " :
317
334
if ( getVar ( "debug " ) !== false )
318
335
print_r ( "CORRECT \n" .$ arrAddress [ $ idx ]."## " .$ arrValue [ $ idx ]."## \n" );
319
336
337
+ // Barcode
320
338
if ( !isset ( $ arrAddress [ $ idx ] ) )
321
339
continue ;
322
340
if ( !isset ( $ arrValue [ $ idx ] ) )
323
341
continue ;
324
342
325
- // Correct (not audit)
326
- if ( !$ sensorAbstraction ->updateStock ( $ arrAddress [ $ idx ], $ arrValue [ $ idx ], false ) )
343
+ // Correct (not audit, note that location and user are not used )
344
+ if ( !$ sensorAbstraction ->updateStock ( $ arrAddress [ $ idx ], $ arrValue [ $ idx ], false , null , null ) )
327
345
$ success = false ;
328
346
break ;
329
347
}
0 commit comments