-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapi.php
168 lines (128 loc) · 5.34 KB
/
api.php
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<?php
$type = $_POST['type'];
if($type == 'get_data_do'){
$dbhost = '200.10.10.3:34123';
$dbuser = 'german';
$dbpass = '71KJ1171r74';
$dbname = 'dev_ilms_db';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname);
if(!$conn) {
die('Could not connect: ' . mysql_error());
}
//$get_days_ago = date('Y-m-d', strtotime('-14 days', strtotime(date('Y-m-d'))));
$date = date('Y-m-d', strtotime($_POST['do_date']));
$sql = "SELECT a.driver_name, b.truck_name as police_no, c.vessel_name, a.sj_ref as do_no, a.reg_no_sj as barcode_no, concat(a.sj_date,' ',a.sj_time) as do_date, a.qty_bulk_delivery_netto as qty_deliver, a.qty_bulk_receipt_netto as qty_receipt,
a.receipt_datetime as receipt_date
FROM (fx_trx_sj as a LEFT JOIN fx_mst_trucks as b ON a.truck_id = b.truck_id)
LEFT JOIN fx_mst_vessels as c ON a.vessel_id = c.vessel_id
WHERE a.deleted = 0 AND a.sj_date = '".$date."' ORDER BY a.sj_ref ASC";
$retval = mysql_query( $sql, $conn );
if(! $retval ) {
die('Could not get data: ' . mysql_error());
}
$data = array();
$get_data = array();
if(mysql_num_rows($retval) > 0){
$no = 1;
while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) {
$data = array(
'do_no' => substr($row['do_no'],2),
'barcode_no' => strtoupper($row['barcode_no']),
'driver_name' => $row['driver_name'],
'police_no' => $row['police_no'],
'vessel_name' => $row['vessel_name'],
'do_date' => $row['do_date'],
'qty_deliver' => (int) $row['qty_deliver'],
'receipt_date' => $row['receipt_date'],
'qty_receipt' => (int) $row['qty_receipt'],
'str_do_date' => date('d-m-Y',strtotime($row['do_date'])),
'str_receipt_date' => date('d-m-Y',strtotime($row['receipt_date'])),
);
array_push($get_data,$data);
}
}
echo json_encode($get_data);
mysql_close($conn);
}
else if($type == 'get_data_reimburse'){
$dbhost = '200.10.10.3:34123';
$dbuser = 'german';
$dbpass = '71KJ1171r74';
$dbname = 'tas_prod';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname);
if(!$conn ) {
die('Could not connect: ' . mysql_error());
}
$start_date = date('Y-m-d', strtotime($_POST['start_date']));
$end_date = date('Y-m-d', strtotime($_POST['end_date']));
$sql = "SELECT Kd_Perusahaan,Kd_Cab_Perusahaan, No_Reimburst,Tgl_Reimburst,Type_Adv,Grand_Total_ADVANCE,Grand_Total_REIMBURST
FROM reimburse_h
WHERE Tgl_Reimburst BETWEEN '".$start_date."' AND '".$end_date."'
ORDER BY Tgl_Reimburst, No_Reimburst";
$retval = mysql_query( $sql, $conn );
if(! $retval ) {
die('Could not get data: ' . mysql_error());
}
$data = array();
$get_data = array();
if(mysql_num_rows($retval) > 0){
$no = 1;
while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) {
$data = array(
'company_code' => $row['Kd_Perusahaan'],
'branch_company_code' => $row['Kd_Cab_Perusahaan'],
'reimburse_no' => $row['No_Reimburst'],
'reimburse_date' => date('d F Y',strtotime($row['Tgl_Reimburst'])),
'advance_type' => $row['Type_Adv'],
'grand_total_advance' => $row['Grand_Total_ADVANCE'],
'grand_total_reimburse' => $row['Grand_Total_REIMBURST']
);
array_push($get_data,$data);
}
}
echo json_encode($get_data);
mysql_close($conn);
}
else if($type == 'get_data_detail_reimburse'){
$dbhost = '200.10.10.3:34123';
$dbuser = 'german';
$dbpass = '71KJ1171r74';
$dbname = 'tas_prod';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname);
if(!$conn ) {
die('Could not connect: ' . mysql_error());
}
$reimburse_no = $_POST['reimburse_no'];
$sql = "SELECT Kd_Perusahaan,Kd_Cab_Perusahaan,No_Reimburst,Type_Adv,No_Adv,Tgl_Adv,Nilai_Adv,Nilai_Reimburst
FROM reimburse_d
WHERE No_Reimburst = '".$reimburse_no."'
ORDER BY Tgl_Adv,No_Adv";
$retval = mysql_query( $sql, $conn );
if(! $retval ) {
die('Could not get data: ' . mysql_error());
}
$data = array();
$get_data = array();
if(mysql_num_rows($retval) > 0){
$no = 1;
while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) {
$data = array(
'company_code' => $row['Kd_Perusahaan'],
'branch_company_code' => $row['Kd_Cab_Perusahaan'],
'reimburse_no' => $row['No_Reimburst'],
'advance_no' => $row['No_Adv'],
'advance_date' => date('d F Y',strtotime($row['Tgl_Adv'])),
'advance_type' => $row['Type_Adv'],
'total_advance' => $row['Nilai_Adv'],
'total_reimburse' => $row['Nilai_Reimburst']
);
array_push($get_data,$data);
}
}
echo json_encode($get_data);
mysql_close($conn);
}
?>