-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset_schedule.php
396 lines (293 loc) · 14.2 KB
/
set_schedule.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
<?php
include("db.php");
include("sessionclient.php");
include("saatini.php");
include("function_botlelang.php");
include("fonnte/function_fonnte_lelang.php");
include("fonnte/settings.php");
//echo "<h1>SET SChedule</h1>";
cek_aktive_not_active($saatini,$link,$mySQLserver,$mySQLdefaultdb,$mySQLuser,$mySQLpassword);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$catatan="";
$mode = isset($_GET['mode']) ? $_GET['mode'] : '';
if ($mode=="") {
$mode = isset($_POST['mode']) ? $_POST['mode'] : '';
}
//echo "<br>mode = ".$mode;
$jambuka = isset($_POST['jambuka']) ? $_POST['jambuka'] : '';
$jamtutup = isset($_POST['jamtutup']) ? $_POST['jamtutup'] : '';
//echo "<h2>check jambuka = ".$jambuka."</h2>";
//echo "<h2>check jamtutup = ".$jamtutup."</h2>";
//2021-10-24 05:15:00 am
$check_am_pm_jambuka = substr($jambuka,20,2);
$check_am_pm_jamtutup = substr($jamtutup,20,2);
//echo "<br>check_am_pm_jambuka = ".$check_am_pm_jambuka;
//echo "<br>check_am_pm_jamtutup = ".$check_am_pm_jamtutup;
if ($check_am_pm_jambuka=="pm") {
$check_jam_buka = substr($jambuka,11,2);
if ($check_jam_buka==12) {
$check_jam_buka=0;
echo "<br>cbila jam buka = 12 maka check_jam_buka = ".$check_jam_buka;
}
$check_tahun_bulan_tanggal_jam_buka = substr($jambuka,0,10);
$check_menit_detik_jambuka = substr($jambuka,14,5);
//echo "<br>check_jam_buka = ".$check_jam_buka;
//echo "<br>check_tahun_bulan_tanggal_jam_buka = ".$check_tahun_bulan_tanggal_jam_buka;
$check_menit_detik_jambuka = substr($jambuka,14,5);
//echo "<br>check_menit_detik_jambuka = ".$check_menit_detik_jambuka;
$koreksi_jam_buka = intval($check_jam_buka) + 12;
//echo "<br>koreksi_jam_buka = ".$koreksi_jam_buka;
$jambuka_baru = $check_tahun_bulan_tanggal_jam_buka. " ".$koreksi_jam_buka.":". $check_menit_detik_jambuka;
//echo "<br>jambuka_baru = ".$jambuka_baru;
$jambuka = $jambuka_baru;
}
if ($check_am_pm_jamtutup=="pm") {
$check_jam_tutup = substr($jamtutup,11,2);
// echo "<br>check_jam_tutup = ".$check_jam_tutup;
if ($check_jam_tutup==12) {
$check_jam_tutup=0;
// echo "<br>cbila jam tutup = 12 maka check_jam_tutup = ".$check_jam_tutup;
}
$check_tahun_bulan_tanggal_jam_tutup = substr($jamtutup,0,10);
//echo "<br>check_tahun_bulan_tanggal_jam_tutup = ".$check_tahun_bulan_tanggal_jam_tutup;
$check_menit_detik_jamtutup = substr($jamtutup,14,5);
//echo "<br>check_menit_detik_jamtutup = ".$check_menit_detik_jamtutup;
$koreksi_jam_tutup = intval($check_jam_tutup) + 12;
//echo "<br>koreksi_jam_tutup = ".$koreksi_jam_tutup;
$jamututup_baru = $check_tahun_bulan_tanggal_jam_tutup. " ".$koreksi_jam_tutup.":". $check_menit_detik_jamtutup;
// echo "<br>jamututup_baru = ".$jamututup_baru;
$jamtutup = $jamututup_baru;
// echo "<br>jamtutup = ".$jamtutup;
}
$timestamp_jambuka = strtotime($jambuka);
$timestamp_jamtutup = strtotime($jamtutup);
$timestamp_sekarang = strtotime($saatini);
//echo "<br>timestamp_jambuka = ".$timestamp_jambuka. " Jam Buka:".$jambuka;
//echo "<br>timestamp_jamtutup = ".$timestamp_jamtutup. " Jam Tutup:".$jamtutup;;
//echo "<br>timestamp_sekarang = ".$timestamp_sekarang. " saatini:".$saatini;;
$kelipatan = isset($_POST['kelipatan']) ? $_POST['kelipatan'] : '';
$startvalue = isset($_POST['startvalue']) ? $_POST['startvalue'] : '';
if ($mode=="set_schedule") {
$bolehproses=1;
$isactive = 0;
if ($timestamp_sekarang > $timestamp_jambuka
&&
$timestamp_sekarang < $timestamp_jamtutup) {
$isactive = 1;
}
if ($timestamp_jambuka>$timestamp_jamtutup) {
$bolehproses=0;
$catatan .= "Jam Buka lelang harus sebelum jam tutup lelang";
}
if ($bolehproses==1) {
$sql_update = "
update `msbot`
set `jambuka`='$jambuka' ,
`jamtutup`='$jamtutup' ,
`startvalue`='$startvalue' ,
`kelipatan`='$kelipatan' ,
`isactive`='$isactive'
where `botid`='$botid'
";
//echo "<Br>sql_update = ".$sql_update;
$query = mysqli_query($link,$sql_update)or die ('gagal update data'.mysqli_error($link));
}
if ($bolehproses==0) {
$catatan .= "<h1>Update Gagal !</h1> ";
$catatan .="<h2>".$catatan."</h2>";
// echo "<Br>catatan = ".$catatan;
}
}
?>
<html lang="en">
<?php include("head_register.php") ?>
<body class="bg-dark">
<div class="container">
<div class="card card-register mx-auto mt-5">
<div class="card-header">Entry Group</div>
<div class="card-body">
<?php include("menu.php"); ?>
<?php
$sql = "SELECT DATE_ADD('".$saatini."', INTERVAL 7 DAY) as `tujuhari`; ";
//echo "<br>sqltujuhhari =".$sqltujuhhari;
$options = array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
);
$conn = new PDO("mysql:host=$mySQLserver;dbname=$mySQLdefaultdb", $mySQLuser, $mySQLpassword);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
foreach($conn->query($sql) as $row) {
$tujuhari=$row['tujuhari'];
}
$conn=null;
$sql = "SELECT DATE_ADD('".$saatini."', INTERVAL 8 DAY) as `delapanhari` ;";
//echo "<br>sqltujuhhari =".$sqldelapanhari;
$options = array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
);
$conn = new PDO("mysql:host=$mySQLserver;dbname=$mySQLdefaultdb", $mySQLuser, $mySQLpassword);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
foreach($conn->query($sql) as $row) {
$delapanhari=$row['delapanhari'];
}
$conn=null;
$html = "<font color='red' size='1'><h1>".$catatan."</h1></font>";
$html .="<br>";
$sql = "select * from `msbot`
where `botid` ='$botid' ";
//echo "<br>sql = ".$sql;
$options = array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
);
$conn = new PDO("mysql:host=$mySQLserver;dbname=$mySQLdefaultdb", $mySQLuser, $mySQLpassword);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$rt=0;
foreach($conn->query($sql) as $row) {
$rt=$rt+1;
$jambuka=$row['jambuka'];
$jamtutup = $row['jamtutup'];
$kelipatan = $row['kelipatan'];
$startvalue = $row['startvalue'];
$isactive = $row['isactive'];
$kelipatan=$row['kelipatan'];
$kelipatan_f = number_format($kelipatan);
$startvalue=$row['startvalue'];
$startvalue_f = number_format($startvalue);
$timestamp_jambuka = strtotime($jambuka);
$timestamp_jamtutup = strtotime($jamtutup);
$timestamp_sekarang = strtotime($saatini);
if ($isactive==1) {
$ket_active="<font color='green'><b>Lelang dalam keadaan AKTIF</b></font>";
}
if ($isactive==0) {
$ket_active="<font color='red'><b>Lelang dalam keadaan TIDAK AKTIF</b></font>";
}
if ($timestamp_sekarang<=$timestamp_jambuka) {
$ket_jam_buka = "Lelang akan dibuka pada ".get_time_forward($timestamp_jambuka);
}
if ($timestamp_sekarang>=$timestamp_jambuka) {
$ket_jam_buka = "Lelang telah dibuka sejak ".get_time_ago($timestamp_jambuka);
}
if ($timestamp_sekarang<=$timestamp_jamtutup) {
$ket_jam_tutup = "Lelang akan ditutup pada ".get_time_forward($timestamp_jamtutup);
}
if ($timestamp_sekarang>=$timestamp_jamtutup) {
$ket_jam_tutup = "Lelang telah ditutup sejak ".get_time_ago($timestamp_jamtutup);
}
if ($jambuka=="0000-00-00 00:00:00") {
$jambuka=$tujuhari;
}
if ($jamtutup=="0000-00-00 00:00:00") {
$jamtutup=$delapanhari;
}
$jambuka_tampil = ambil_format_hari_3($jambuka);
$jamtutup_tampil = ambil_format_hari_3($jamtutup);
$ket_active="";
if ($isactive==1) {
$ket_active="<font color='green'><b>Lelang dalam keadaan AKTIF</b></font>";
}
if ($isactive==0) {
$ket_active="<font color='red'><b>Lelang dalam keadaan TIDAK AKTIF</b></font>";
}
$html ="<br>";
$html ="<br>Status Active : ".$ket_active;
$html .="<form method='POST' action='' >";
$html .="<br><br>";
$html .="Jam Buka (GMT +7) : $jambuka_tampil
<div class='input-group date form_datetime' data-date='".$tanggalhariini."T".$jamhariini."Z"."' data-date-format='yyyy-mm-dd HH:ii:ss p' data-link-field='jambuka'>
<input class='form-control' size='16' type='text' name='jambuka' value='$jambuka'>
<span class='input-group-addon'><span class='glyphicon glyphicon-remove'></span></span>
<span class='input-group-addon'><span class='glyphicon glyphicon-th'></span></span>
</div>
<input type='hidden' id='jambuka' value='$jambuka' />";
$html .="".$ket_jam_buka."<br><br>";
$html .="Jam Tutup (GMT +7) : $jamtutup_tampil
<div class='input-group date form_datetime' data-date='".$tanggalhariini."T".$jamhariini."Z"."' data-date-format='yyyy-mm-dd HH:ii:ss p' data-link-field='jamtutup'>
<input class='form-control' size='16' type='text' name='jamtutup' value='$jamtutup'>
<span class='input-group-addon'><span class='glyphicon glyphicon-remove'></span></span>
<span class='input-group-addon'><span class='glyphicon glyphicon-th'></span></span>
</div>
<input type='hidden' id='jamtutup' value='$jamtutup' />";
$html .="".$ket_jam_tutup."<br>";
$html .="<br>Nilai Awal Nominal Lelang : Rp ".$startvalue_f. "";
$html .="<br>";
if ($startvalue<=0) {
$html .="<b><font color='red'>Nilai awal nominal Lelang Tidak boleh 0</b></font>";
$html .="<br>";
}
$boleh_update_nilai_awal_nominal=1;
$status_enabled_disabled_awal_nominal="";
$html .="<textarea ".$status_enabled_disabled_awal_nominal." name='startvalue' rows='3' cols='40'>".$startvalue."</textarea>";
$html .="<br><br>Kelipatan Nominal Lelang Rp ".$kelipatan_f. "";
$html .="<br>";
if ($kelipatan<=0) {
$html .="<b><font color='red'>Nilai Kelipatan nominal Lelang Tidak boleh 0</b></font>";
$html .="<br>";
}
$html .="<br>";
$html .="<textarea name='kelipatan' rows='3' cols='40'>".$kelipatan."</textarea>";
$html .="<input type='hidden' name='mode' value='edit_kelipatan'>";
$html .="<br><input type='checkbox' name='warn1' required> ";
$html .="Saya mengerti , bahwa dengan melakukan edit jadwal buka lelang dan jadwal tutup lelang, data transaksi lelang sebelumnya akan terhapus, data produk lelang sebelumnya akan terhapus";
$html .="<br><input type='checkbox' name='warn2' required> ";
$html .="Saya mengerti , bahwa saya sudah menyimpan data transaksi lelang sebelumnya, yang ada di menu rekap lelang dan detail lelang";
$html .="<br><input type='checkbox' name='warn3' required> ";
$html .="Saya mengerti , bahwa setelah melakukan setting jam buka lelang, jam tutup lelang, nilai open bid dan kelipatan bid, selanjutnya saya akan mengisi data produk yang akan dilelang, yaitu pada menu ENTRY DATA";
$html .="<input type='hidden' name='mode' value='set_schedule'>";
$html .="<br><br><input type='submit' class='btn btn-space btn-primary' name='' value='Update Schedule'>";
$html .= "<br></form>";
}
$html .= "<h3>Perhatian, Ketika lelang akan berjalan atau sedang berjalan, melakukan update ini, akan berpengaruh kepada data produk , Ketika melakukan entry data ini, harap, melakukan isian kembali data produk di menu entry data</h3>";
echo $html;
?>
</div>
</div>
</div>
<!-- Bootstrap core JavaScript-->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Core plugin JavaScript-->
<script src="vendor/jquery-easing/jquery.easing.min.js"></script>
<script type="text/javascript" src="jquery/jquery-1.8.3.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/bootstrap-datetimepicker.js" charset="UTF-8"></script>
<script type="text/javascript" src="js/locales/bootstrap-datetimepicker.fr.js" charset="UTF-8"></script>
<script type="text/javascript">
$('.form_datetime').datetimepicker({
language: 'en',
weekStart: 1,
todayBtn: 1,
autoclose: 1,
todayHighlight: 1,
startView: 2,
forceParse: 0,
showMeridian: 1
});
$('.form_date').datetimepicker({
language: 'fr',
weekStart: 1,
todayBtn: 1,
autoclose: 1,
todayHighlight: 1,
startView: 2,
minView: 2,
forceParse: 0
});
$('.form_time').datetimepicker({
language: 'fr',
weekStart: 1,
todayBtn: 1,
autoclose: 1,
todayHighlight: 1,
startView: 1,
minView: 0,
maxView: 1,
forceParse: 0
});
</script>
</body>
</html>