-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathseeder_monitoring.php
52 lines (52 loc) · 2.51 KB
/
seeder_monitoring.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
<?php
date_default_timezone_set('Asia/Jakarta');
include "connect.php";
function dateRange() {
$f = strtotime('2020-02-01');
$l = strtotime('2020-02-13');
$int= rand($f,$l);
$string = date("Y-m-d",$int);
return $string;
}
function seeder_mon($nopol, $tgl, $sort, $quan){
include "connect.php";
$cek = mysqli_query($conn, "select * from monitoring where nopol = '$nopol' and tgl_scan = '$tgl'");
if(mysqli_num_rows($cek) > 0){
//ada
$ambil = mysqli_fetch_assoc($cek);
$id = $ambil['id'];
$q = (int)$ambil['quantity'] + (int)$quan;
mysqli_query($conn, "update monitoring set quantity = '$q' where id = '$id'");
echo "SUCCESS UPDATE :".$sort.": <br/>";
}else{
//tidak ada
mysqli_query($conn, "insert into monitoring (nopol, quantity, tgl_scan) values ('$nopol', '$quan', '$tgl')");
echo "SUCCESS INSERT :".$sort.": <br/>";
}
}
$tgl = date("Y-m-d H:i:s");
mysqli_query($conn, "insert into nopol (nik, nama, nopol, nomor_stnk, key_secret, tgl_post) values ('122333444455555', 'SUPRIANTO', 'L 6125 QZ', '555554444333221', 'KEY_SECRET1', '$tgl')");
mysqli_query($conn, "insert into nopol (nik, nama, nopol, nomor_stnk, key_secret, tgl_post) values ('908070605040302', 'CHAYANTO', 'W 3266 DS', '555554444333221', 'KEY_SECRET2', '$tgl')");
mysqli_query($conn, "insert into nopol (nik, nama, nopol, nomor_stnk, key_secret, tgl_post) values ('593857462811574', 'BAGYO', 'B 145 AA', '214576896534231', 'KEY_SECRET3', '$tgl')");
mysqli_query($conn, "insert into nopol (nik, nama, nopol, nomor_stnk, key_secret, tgl_post) values ('236749586739058', 'SANTO', 'S 1974 WR', '234576984543675', 'KEY_SECRET4', '$tgl')");
for($i=0;$i<20;$i++){
$randDate = dateRange();
$randValue = rand(5,50);
seeder_mon("L 6125 QZ", $randDate, $i, $randValue);
// mysqli_query($conn, "insert into monitoring values ('', 'L 6125 QZ', '$randValue','$randDate')");
}
for($i=0;$i<20;$i++){
$randDate = dateRange();
$randValue = rand(5,50);
seeder_mon("W 3266 DS", $randDate, $i, $randValue);
}
for($i=0;$i<20;$i++){
$randDate = dateRange();
$randValue = rand(5,50);
seeder_mon("B 145 AA", $randDate, $i, $randValue);
}
for($i=0;$i<20;$i++){
$randDate = dateRange();
$randValue = rand(5,50);
seeder_mon("S 1974 WR", $randDate, $i, $randValue);
}