Repository navigation
Expand file tree
/
Copy pathget.php
More file actions
37 lines (34 loc) · 1.37 KB
/
Copy pathget.php
File metadata and controls
37 lines (34 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
include 'common/common.php';
include 'api/getHelper.php';
$transactions = array();
$selectTransactionsQuery = 'SELECT DISTINCT ' . AppSync::$COLUMN_TIMESTAMP . ',' . AppSync::$COLUMN_OP_CODE . ' FROM ' . AppSync::$TABLE_NAME . ' ORDER BY ' . AppSync::$ID . ' ASC';
$selectTransactionsQueryResult = mysqli_query( $conn, $selectTransactionsQuery );
if ( mysqli_num_rows( $selectTransactionsQueryResult ) > 0 ) {
$response['success'] = true;
while ( $row = mysqli_fetch_assoc( $selectTransactionsQueryResult ) ) {
$timeStamp = $row[AppSync::$COLUMN_TIMESTAMP];
$opCode = $row[AppSync::$COLUMN_OP_CODE];
switch ( $opCode ) {
case 'ADD_CUST':
array_push( $transactions, addCustomer( $conn, $timeStamp ) );
break;
case 'SALE':
array_push( $transactions, addSales( $conn, $timeStamp ) );
break;
case 'PAY':
array_push( $transactions, addPayment( $conn, $timeStamp ) );
break;
case 'SALE_RETURN':
array_push( $transactions, addSalesReturn( $conn, $timeStamp ) );
break;
case 'REQUEST_ITEM':
array_push($transactions, requestItem( $conn));
break;
}
}
} else {
$response['status'] = 'EMPTY';
}
$response['transactions'] = $transactions;
echo json_encode( $response );