Repository navigation
Expand file tree
/
Copy pathpush.php
More file actions
119 lines (100 loc) · 4.07 KB
/
Copy pathpush.php
File metadata and controls
119 lines (100 loc) · 4.07 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
include 'common/common.php';
include 'operation/serverPushHelper.php';
mysqli_autocommit($conn, false);
$commitTransaction = true;
$updateFlagSetupQuery = "UPDATE " . Staff::$TABLE_NAME . "
SET " . Staff::$COLUMN_FORCE . " = '1', " . Staff::$COLUMN_UPDATE . " = '0'";
if (mysqli_query($conn, $updateFlagSetupQuery)) {
$jsonArray = file_get_contents($_FILES['fabizjson']['tmp_name']);
for ($i = 0; i < count($jsonArray); $i++) {
$SUCCESS = false;
$currentTb = $jsonArray[$i];
switch ($currentTb['table_name']) {
case "tb_info":
$SUCCESS = addInfo($conn, $currentTb['value']);
break;
case "global_precision":
$SUCCESS = addPrecision($conn, $currentTb['value']);
break;
case "tb_staff":
$SUCCESS = addStaff($conn, $currentTb['rows']);
break;
case "tb_item":
$SUCCESS = addItem($conn, $currentTb['rows']);
break;
case "tb_item_unit":
$SUCCESS = addUnit($conn, $currentTb['rows']);
break;
case "tb_customer":
$SUCCESS = addCustomer($conn, $currentTb['rows']);
break;
case "tb_bill_detail":
$SUCCESS = addBillDetail($conn, $currentTb['rows']);
break;
case "tb_cart":
$SUCCESS = addCart($conn, $currentTb['rows']);
break;
case "tb_payment":
$SUCCESS = addPayment($conn, $currentTb['rows']);
break;
case "tb_sales_return":
$SUCCESS = addsSalesreturn($conn, $currentTb['rows']);
break;
}
if (!$SUCCESS) {
$commitTransaction = false;
break;
}
}
} else {
$commitTransaction = false;
}
if ($commitTransaction) {
mysqli_commit($conn);
$response["success"] = true;
} else {
mysqli_rollback($conn);
}
echo json_encode($response);
function deleteAllTableValues($conn)
{
$deleteTable = "DELETE FROM tb_app_sync";
if (mysqli_query($conn, $deleteTable)) {
$deleteTable = "DELETE FROM tb_bill_detail";
if (mysqli_query($conn, $deleteTable)) {
$deleteTable = "DELETE FROM tb_cart";
if (mysqli_query($conn, $deleteTable)) {
$deleteTable = "DELETE FROM tb_customer";
if (mysqli_query($conn, $deleteTable)) {
$deleteTable = "DELETE FROM tb_global_precision";
if (mysqli_query($conn, $deleteTable)) {
$deleteTable = "DELETE FROM tb_info";
if (mysqli_query($conn, $deleteTable)) {
$deleteTable = "DELETE FROM tb_item";
if (mysqli_query($conn, $deleteTable)) {
$deleteTable = "DELETE FROM tb_item_unit";
if (mysqli_query($conn, $deleteTable)) {
$deleteTable = "DELETE FROM tb_payment";
if (mysqli_query($conn, $deleteTable)) {
$deleteTable = "DELETE FROM tb_request_item";
if (mysqli_query($conn, $deleteTable)) {
$deleteTable = "DELETE FROM tb_sales_return";
if (mysqli_query($conn, $deleteTable)) {
$deleteTable = "DELETE FROM tb_staff";
if (mysqli_query($conn, $deleteTable)) {
return false;
}
}
}
}
}
}
}
}
}
}
}
}
return false;
}