Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmad luky ramdani committed May 19, 2016
2 parents 50f003f + 70f35c8 commit f2862e4
Show file tree
Hide file tree
Showing 6 changed files with 204 additions and 0 deletions.
5 changes: 5 additions & 0 deletions apps/daemon.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
<?php

$loket = $_POST['loket'];
<<<<<<< HEAD
$counter = $_POST['counter'];

$db = new SQLite3('../db/antrian.db');
if ($counter) {
// update status counter
$results = $db->query('UPDATE data_antrian SET status=1 WHERE id='.$counter.'');
}
=======

$db = new SQLite3('../db/antrian.db');
>>>>>>> 70f35c8a2fe26c4fea1c887f15f597731f08f4cb
$results = $db->query('INSERT INTO data_antrian (counter,waktu,status) VALUES ('.$loket.',"'.date("Y-m-d H:i:s").'",0)');
$next_counter = $db->lastInsertRowID();

Expand Down
4 changes: 4 additions & 0 deletions apps/last_stage.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
$db = new SQLite3('../db/antrian.db');
$results = $db->query('SELECT Max(id) as id FROM data_antrian WHERE counter='.$loket.'');
$row = $results->fetchArray();
<<<<<<< HEAD
if ($row['id'] == NULL) {
$data = array('next' => 0);
} else {
$data = array('next' => $row['id']);
}
=======
$data = array('next' => $row['id']);
>>>>>>> 70f35c8a2fe26c4fea1c887f15f597731f08f4cb
echo json_encode($data);
?>
5 changes: 5 additions & 0 deletions apps/monitoring-daemon-result.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
// set done
$id = $_POST['id'];
$db = new SQLite3('../db/antrian.db');
$db->query('UPDATE data_antrian SET status= 2 WHERE id='.$id.''); // wait
33 changes: 33 additions & 0 deletions apps/monitoring-daemon.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
<<<<<<< HEAD
$db = new SQLite3('../db/antrian.db');
$data = array();
for ($i=1; $i <=3 ; $i++) {
Expand All @@ -11,4 +12,36 @@
}
}
echo json_encode($data);
=======
session_start();

$db = new SQLite3('../db/antrian.db');
$data = array();

//2 done
//1 wait
//0 execution

$result_wait = $db->query('SELECT count(*) as c FROM data_antrian WHERE status=1'); // wait
$wait = $result_wait->fetchArray();
$c = $wait['c'];
if ($c)
{
// idel
}else{

$result = $db->query('SELECT Max(id) as id, counter FROM data_antrian WHERE status=0 LIMIT 1'); // execution
$rows = $result->fetchArray();
if($rows['id']!=NULL)
{
$data['next'] = $rows['id'];
$data['counter'] = $rows['counter'];
// set wait
$_SESSION["next"] = $rows['id'];
$_SESSION["counter"] = $rows['counter'];
$db->query('UPDATE data_antrian SET status= 1 WHERE id='. $rows['id'] .''); // wait
echo json_encode($data);
}
}
>>>>>>> 70f35c8a2fe26c4fea1c887f15f597731f08f4cb
?>
52 changes: 52 additions & 0 deletions client/index.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<<<<<<< HEAD
<?php
session_start();
if (!isset($_SESSION["loket"])) {
$_SESSION["loket"] = NULL;
}
?>
=======
>>>>>>> 70f35c8a2fe26c4fea1c887f15f597731f08f4cb
<!DOCTYPE html>
<html lang="en">
<head>
Expand All @@ -20,6 +23,7 @@

<body>
<div class="container">
<<<<<<< HEAD
<div class="header clearfix">
<nav>
<ul class="nav nav-pills pull-right">
Expand All @@ -30,10 +34,29 @@
</div>

<div class="jumbotron">
=======
<div class="header clearfix">
<nav>
<ul class="nav nav-pills pull-right">
<li role="presentation" class="active"><a href="#">
<form>
<label for="exampleInputEmail1">NOMOR LOKET</label>
<input type="text" class="form-control loket" placeholder="Nomor Loket">
</form>
</a></li>
<li role="presentation"><a href="#">ABOUT</a></li>
</ul>
</nav>
<h3 class="text-muted">Queue apps</h3>
</div>

<div class="jumbotron">
>>>>>>> 70f35c8a2fe26c4fea1c887f15f597731f08f4cb
<h1>
0
</h1>
<p>
<<<<<<< HEAD
<a class="btn btn-lg btn-primary try_queue" href="#" role="button">
Ulangi Panggilan &nbsp;<span class="glyphicon glyphicon-volume-up"></span>
</a>
Expand All @@ -56,11 +79,23 @@
<footer class="footer">
<p>&copy; ITERA <?php echo date("Y");?></p>
</footer>
=======
<a class="btn btn-lg btn-success next_queue" href="#" role="button">
Next <span class="glyphicon glyphicon-chevron-right"></span>
</a>
</p>
</div>

<footer class="footer">
<p>&copy; ITERA <?php echo date("Y");?></p>
</footer>
>>>>>>> 70f35c8a2fe26c4fea1c887f15f597731f08f4cb
</div>
</body>

<script type="text/javascript">
$("document").ready(function(){
<<<<<<< HEAD

// SET EXSIST session LOKET
<?php if ($_SESSION["loket"] != NULL) { ?>
Expand All @@ -72,6 +107,8 @@
<?php } ?>

// GET LAST COUNTER
=======
>>>>>>> 70f35c8a2fe26c4fea1c887f15f597731f08f4cb
var data = {"loket": $(".loket").val()};
$.ajax({
type: "POST",
Expand All @@ -83,6 +120,7 @@
}
});

<<<<<<< HEAD
// NUMBER LOKET
$('form input').data('val', $('form input').val() );
$('form input').change(function() {
Expand All @@ -102,6 +140,11 @@
$(".jumbotron h1").html(data["next"]);
}
});
=======
$('form input').data('val', $('form input').val() );
$('form input').change(function() {
//set seassion or save
>>>>>>> 70f35c8a2fe26c4fea1c887f15f597731f08f4cb
});
$('form input').keyup(function() {
if( $('form input').val() != $('form input').data('val') ){
Expand All @@ -110,11 +153,17 @@
}
});

<<<<<<< HEAD
// GET NEXT COUNTER
$(".next_queue").click(function(){
var loket = $(".loket").val();
var counter = $(".jumbotron h1").val();
var data = {"loket" : loket, "counter": counter};
=======
$(".next_queue").click(function(){
var loket = $(".loket").val();
var data = {"loket": loket};
>>>>>>> 70f35c8a2fe26c4fea1c887f15f597731f08f4cb
$.ajax({
type: "POST",
dataType: "json",
Expand All @@ -126,7 +175,10 @@
});
return false;
});
<<<<<<< HEAD

=======
>>>>>>> 70f35c8a2fe26c4fea1c887f15f597731f08f4cb
});
</script>
</html>
Expand Down
Loading

0 comments on commit f2862e4

Please sign in to comment.