Oke kita lanjut postingan sebelumnya yaitu membuat aplikasi po bus dengan php dan bootstrap. Sekarang kita akan buat dashboard adminnya. Silahkan buat folder admin pada directory project PO Bus. Copycan juga folder db dan file session.php, currentdate.php serta clock_lcd.php kedalam folder admin agar memudahkan kita nantinya.
Kalau sudah buat file header.php dan copycan syntax berikut
<?php include ('db/dbcon.php'); ?>
<?php include ('session.php'); ?>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- start: Meta -->
<meta charset="utf-8">
<title>Bus Dispatch and Information System</title>
<!-- end: Meta -->
<!-- start: Mobile Specific -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- end: Mobile Specific -->
<!-- start: CSS -->
<link id="bootstrap-style" href="css/bootstrap.min.css" rel="stylesheet">
<link id="bootstrap-style" href="css/slide.css" rel="stylesheet">
<link href="css/bootstrap-responsive.min.css" rel="stylesheet">
<link id="base-style" href="css/style.css" rel="stylesheet">
<link id="base-style-responsive" href="css/style-responsive.css" rel="stylesheet">
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800&subset=latin,cyrillic-ext,latin-ext' rel='stylesheet' type='text/css'>
<!-- end: CSS -->
<!-- The HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<link id="ie-style" href="css/ie.css" rel="stylesheet">
<![endif]-->
<!--[if IE 9]>
<link id="ie9style" href="css/ie9.css" rel="stylesheet">
<![endif]-->
<!-- start: Favicon -->
<link rel="shortcut icon" href="img/favicon.ico">
<!-- end: Favicon -->
<?php
//$user_query = mysql_query("select * from admin where adminid = '$id_session'")or die(mysql_error());
//$user_row =mysql_fetch_array($user_query);
//$user_type = $user_row['user_type'];
?>
<?php //if ($user_type == 'Dispatcher'){
?>
<script>
<!--
/*
Auto Refresh Page with Time script
By JavaScript Kit (javascriptkit.com)
Over 200+ free scripts here!
*/
//enter refresh time in "minutes:seconds" Minutes should range from 0 to inifinity. Seconds should range from 0 to 59
var limit="0:25"
var doctitle = document.title
var parselimit=limit.split(":")
parselimit=parselimit[0]*60+parselimit[1]*1
function beginrefresh(){
if (parselimit==1)
window.location.reload()
else{
parselimit-=1
curmin=Math.floor(parselimit/60)
cursec=parselimit%60
if (curmin!=0)
curtime=curmin+" minutes and "+cursec+" seconds left until page refresh!"
else
curtime=cursec+" seconds left until page refresh!"
document.title = doctitle + ' (' + curtime +')'
setTimeout("beginrefresh()",1000)
}
}
if (window.addEventListener)
window.addEventListener("load", beginrefresh, false)
else if (window.attachEvent)
window.attachEvent("load", beginrefresh)
//-->
</script>
<?php //} ?>
</head>
<body>
<!-- start: Header -->
<div class="navbar">
<div class="navbar-inner">
<div class="container-fluid">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".top-nav.nav-collapse,.sidebar-nav.nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="dashboard.php"><span>Bus Dispatch and Information System</span></a>
<!-- start: Header Menu -->
<div class="nav-no-collapse header-nav">
<ul class="nav pull-right">
<!-- start: User Dropdown -->
<li class="dropdown">
<?php
include('db/dbcon.php');
$user_query=mysql_query("select * from admin where adminid='$id_session'")or die(mysql_error());
$row=mysql_fetch_array($user_query); {
?>
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
<i class="halflings-icon user white"></i> <?php echo $row['firstname']; ?>
<span class="caret"></span>
</a>
<?php } ?>
<ul class="dropdown-menu">
<li class="dropdown-menu-title">
<span>Account Settings</span>
</li>
<?php
$user_query = mysql_query("select * from admin where adminid = '$id_session'")or die(mysql_error());
$user_row =mysql_fetch_array($user_query);
$user_type = $user_row['user_type'];
?>
<?php if ($user_type == 'Admin'){
?>
<li><a href="profile.php"><i class="halflings-icon user"></i> User List</a></li>
<?php } ?>
<li><a href="logout.php"><i class="halflings-icon off"></i> Logout</a></li>
</ul>
</li>
<!-- end: User Dropdown -->
</ul>
</div>
<!-- end: Header Menu -->
</div>
</div>
</div>
<!-- start: Header -->
<div class="container-fluid-full">
<div class="row-fluid">
<!-- start: Main Menu -->
<div id="sidebar-left" class="span2">
<div class="nav-collapse sidebar-nav">
<ul class="nav nav-tabs nav-stacked main-menu">
<li><a href="dashboard.php"><i class="halflings-icon home white"></i><span class="hidden-tablet"> Home</span></a></li>
<?php if ($user_type == 'Admin'){
?>
<li><a href="dispatcher.php"><i class="halflings-icon user white"></i><span class="hidden-tablet"> Dispatcher Profile</span></a></li>
<?php } ?>
<li><a href="driver.php"><i class="halflings-icon user white"></i><span class="hidden-tablet"> Driver Profile</span></a></li>
<li><a href="schedule.php"><i class="halflings-icon list white"></i><span class="hidden-tablet"> Manage Schedule</span></a></li>
<li><a href="report.php"><i class="halflings-icon th white"></i><span class="hidden-tablet"> Reports</span></a></li>
<li><a href="bus.php"><i class="halflings-icon info-sign white"></i><span class="hidden-tablet"> Bus Information</span></a></li>
<li><a href="branch.php"><i class="halflings-icon info-sign white"></i><span class="hidden-tablet"> Branch Information</span></a></li>
</ul>
</div>
</div>
<!-- end: Main Menu -->
<!-- start: Content -->
<div id="content" class="span10">
<?php include ('session.php'); ?>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- start: Meta -->
<meta charset="utf-8">
<title>Bus Dispatch and Information System</title>
<!-- end: Meta -->
<!-- start: Mobile Specific -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- end: Mobile Specific -->
<!-- start: CSS -->
<link id="bootstrap-style" href="css/bootstrap.min.css" rel="stylesheet">
<link id="bootstrap-style" href="css/slide.css" rel="stylesheet">
<link href="css/bootstrap-responsive.min.css" rel="stylesheet">
<link id="base-style" href="css/style.css" rel="stylesheet">
<link id="base-style-responsive" href="css/style-responsive.css" rel="stylesheet">
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800&subset=latin,cyrillic-ext,latin-ext' rel='stylesheet' type='text/css'>
<!-- end: CSS -->
<!-- The HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<link id="ie-style" href="css/ie.css" rel="stylesheet">
<![endif]-->
<!--[if IE 9]>
<link id="ie9style" href="css/ie9.css" rel="stylesheet">
<![endif]-->
<!-- start: Favicon -->
<link rel="shortcut icon" href="img/favicon.ico">
<!-- end: Favicon -->
<?php
//$user_query = mysql_query("select * from admin where adminid = '$id_session'")or die(mysql_error());
//$user_row =mysql_fetch_array($user_query);
//$user_type = $user_row['user_type'];
?>
<?php //if ($user_type == 'Dispatcher'){
?>
<script>
<!--
/*
Auto Refresh Page with Time script
By JavaScript Kit (javascriptkit.com)
Over 200+ free scripts here!
*/
//enter refresh time in "minutes:seconds" Minutes should range from 0 to inifinity. Seconds should range from 0 to 59
var limit="0:25"
var doctitle = document.title
var parselimit=limit.split(":")
parselimit=parselimit[0]*60+parselimit[1]*1
function beginrefresh(){
if (parselimit==1)
window.location.reload()
else{
parselimit-=1
curmin=Math.floor(parselimit/60)
cursec=parselimit%60
if (curmin!=0)
curtime=curmin+" minutes and "+cursec+" seconds left until page refresh!"
else
curtime=cursec+" seconds left until page refresh!"
document.title = doctitle + ' (' + curtime +')'
setTimeout("beginrefresh()",1000)
}
}
if (window.addEventListener)
window.addEventListener("load", beginrefresh, false)
else if (window.attachEvent)
window.attachEvent("load", beginrefresh)
//-->
</script>
<?php //} ?>
</head>
<body>
<!-- start: Header -->
<div class="navbar">
<div class="navbar-inner">
<div class="container-fluid">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".top-nav.nav-collapse,.sidebar-nav.nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="dashboard.php"><span>Bus Dispatch and Information System</span></a>
<!-- start: Header Menu -->
<div class="nav-no-collapse header-nav">
<ul class="nav pull-right">
<!-- start: User Dropdown -->
<li class="dropdown">
<?php
include('db/dbcon.php');
$user_query=mysql_query("select * from admin where adminid='$id_session'")or die(mysql_error());
$row=mysql_fetch_array($user_query); {
?>
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
<i class="halflings-icon user white"></i> <?php echo $row['firstname']; ?>
<span class="caret"></span>
</a>
<?php } ?>
<ul class="dropdown-menu">
<li class="dropdown-menu-title">
<span>Account Settings</span>
</li>
<?php
$user_query = mysql_query("select * from admin where adminid = '$id_session'")or die(mysql_error());
$user_row =mysql_fetch_array($user_query);
$user_type = $user_row['user_type'];
?>
<?php if ($user_type == 'Admin'){
?>
<li><a href="profile.php"><i class="halflings-icon user"></i> User List</a></li>
<?php } ?>
<li><a href="logout.php"><i class="halflings-icon off"></i> Logout</a></li>
</ul>
</li>
<!-- end: User Dropdown -->
</ul>
</div>
<!-- end: Header Menu -->
</div>
</div>
</div>
<!-- start: Header -->
<div class="container-fluid-full">
<div class="row-fluid">
<!-- start: Main Menu -->
<div id="sidebar-left" class="span2">
<div class="nav-collapse sidebar-nav">
<ul class="nav nav-tabs nav-stacked main-menu">
<li><a href="dashboard.php"><i class="halflings-icon home white"></i><span class="hidden-tablet"> Home</span></a></li>
<?php if ($user_type == 'Admin'){
?>
<li><a href="dispatcher.php"><i class="halflings-icon user white"></i><span class="hidden-tablet"> Dispatcher Profile</span></a></li>
<?php } ?>
<li><a href="driver.php"><i class="halflings-icon user white"></i><span class="hidden-tablet"> Driver Profile</span></a></li>
<li><a href="schedule.php"><i class="halflings-icon list white"></i><span class="hidden-tablet"> Manage Schedule</span></a></li>
<li><a href="report.php"><i class="halflings-icon th white"></i><span class="hidden-tablet"> Reports</span></a></li>
<li><a href="bus.php"><i class="halflings-icon info-sign white"></i><span class="hidden-tablet"> Bus Information</span></a></li>
<li><a href="branch.php"><i class="halflings-icon info-sign white"></i><span class="hidden-tablet"> Branch Information</span></a></li>
</ul>
</div>
</div>
<!-- end: Main Menu -->
<!-- start: Content -->
<div id="content" class="span10">
Selanjutnya kita buat file footer.php dulu
</div>
</div>
</div>
<div class="clearfix"></div>
<footer>
<p>
<span style="text-align:left;float:left">© <?php echo date('Y'); ?> <a alt="Bus Dispatch and Information System">Bus Dispatch and Information System</a></span>
</p>
</footer>
<!-- start: JavaScript-->
<script src="js/jquery-1.9.1.min.js"></script>
<script src="js/jquery-migrate-1.0.0.min.js"></script>
<script src="js/jquery-ui-1.10.0.custom.min.js"></script>
<script src="js/jquery.ui.touch-punch.js"></script>
<script src="js/modernizr.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.cookie.js"></script>
<script src='js/fullcalendar.min.js'></script>
<script src='js/jquery.dataTables.min.js'></script>
<script src="js/excanvas.js"></script>
<script src="js/jquery.flot.js"></script>
<script src="js/jquery.flot.pie.js"></script>
<script src="js/jquery.flot.stack.js"></script>
<script src="js/jquery.flot.resize.min.js"></script>
<script src="js/jquery.chosen.min.js"></script>
<script src="js/jquery.uniform.min.js"></script>
<script src="js/jquery.cleditor.min.js"></script>
<script src="js/jquery.noty.js"></script>
<script src="js/jquery.elfinder.min.js"></script>
<script src="js/jquery.raty.min.js"></script>
<script src="js/jquery.iphone.toggle.js"></script>
<script src="js/jquery.uploadify-3.1.min.js"></script>
<script src="js/jquery.gritter.min.js"></script>
<script src="js/jquery.imagesloaded.js"></script>
<script src="js/jquery.masonry.min.js"></script>
<script src="js/jquery.knob.modified.js"></script>
<script src="js/jquery.sparkline.min.js"></script>
<script src="js/counter.js"></script>
<script src="js/retina.js"></script>
<script src="js/custom.js"></script>
<!-- end: JavaScript-->
</body>
</html>
</div>
</div>
<div class="clearfix"></div>
<footer>
<p>
<span style="text-align:left;float:left">© <?php echo date('Y'); ?> <a alt="Bus Dispatch and Information System">Bus Dispatch and Information System</a></span>
</p>
</footer>
<!-- start: JavaScript-->
<script src="js/jquery-1.9.1.min.js"></script>
<script src="js/jquery-migrate-1.0.0.min.js"></script>
<script src="js/jquery-ui-1.10.0.custom.min.js"></script>
<script src="js/jquery.ui.touch-punch.js"></script>
<script src="js/modernizr.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.cookie.js"></script>
<script src='js/fullcalendar.min.js'></script>
<script src='js/jquery.dataTables.min.js'></script>
<script src="js/excanvas.js"></script>
<script src="js/jquery.flot.js"></script>
<script src="js/jquery.flot.pie.js"></script>
<script src="js/jquery.flot.stack.js"></script>
<script src="js/jquery.flot.resize.min.js"></script>
<script src="js/jquery.chosen.min.js"></script>
<script src="js/jquery.uniform.min.js"></script>
<script src="js/jquery.cleditor.min.js"></script>
<script src="js/jquery.noty.js"></script>
<script src="js/jquery.elfinder.min.js"></script>
<script src="js/jquery.raty.min.js"></script>
<script src="js/jquery.iphone.toggle.js"></script>
<script src="js/jquery.uploadify-3.1.min.js"></script>
<script src="js/jquery.gritter.min.js"></script>
<script src="js/jquery.imagesloaded.js"></script>
<script src="js/jquery.masonry.min.js"></script>
<script src="js/jquery.knob.modified.js"></script>
<script src="js/jquery.sparkline.min.js"></script>
<script src="js/counter.js"></script>
<script src="js/retina.js"></script>
<script src="js/custom.js"></script>
<!-- end: JavaScript-->
</body>
</html>
Selanjutnya buat file index.php
<?php require('login.php'); ?>
Karena file index memerlukan file login.php, maka kita buat file login.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Bus Dispatch and Information System</title>
<!-- Bootstrap Core CSS -->
<link href="css/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/css/simple-sidebar.css" rel="stylesheet">
<!-- SignIn CSS -->
<link href="css/css/signin.css" rel="stylesheet" type="text/css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- navbar start -->
<nav class="navbar navbar-inverse" style="border-radius:0px;" >
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand">Bus Dispatch and Information System</a>
</div>
<ul class="nav navbar-nav navbar-right">
<li class="">
<a>
<?php include('currentdate.php'); ?> <?php include('clock_lcd.php'); ?>
</a>
</li>
</ul>
</div>
</nav>
<!-- navbar end -->
<div class="account-container">
<div class="content clearfix">
<form action="login_info.php" method="post">
<h1 class="text-center">Login Info</h1>
<div class="login-fields">
<p>Please provide your details</p>
<div class="field">
<label for="username">Username</label>
<input type="text" id="username" name="username" value="" placeholder="Username" class="login username-field" />
</div> <!-- /field -->
<div class="field">
<label for="password">Password:</label>
<input type="password" id="password" name="password" value="" placeholder="Password" class="login password-field"/>
</div> <!-- /password -->
</div> <!-- /login-fields -->
<div class="login-actions">
<button type="submit" name="login" class="button btn btn-success btn-large">Sign In</button>
</div> <!-- .actions -->
</form>
</div> <!-- /content -->
</div> <!-- /account-container -->
<script src="js/js/jquery-1.7.2.min.js"></script>
<script src="js/js/bootstrap.js"></script>
<script src="js/js/signin.js"></script>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Bus Dispatch and Information System</title>
<!-- Bootstrap Core CSS -->
<link href="css/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/css/simple-sidebar.css" rel="stylesheet">
<!-- SignIn CSS -->
<link href="css/css/signin.css" rel="stylesheet" type="text/css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- navbar start -->
<nav class="navbar navbar-inverse" style="border-radius:0px;" >
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand">Bus Dispatch and Information System</a>
</div>
<ul class="nav navbar-nav navbar-right">
<li class="">
<a>
<?php include('currentdate.php'); ?> <?php include('clock_lcd.php'); ?>
</a>
</li>
</ul>
</div>
</nav>
<!-- navbar end -->
<div class="account-container">
<div class="content clearfix">
<form action="login_info.php" method="post">
<h1 class="text-center">Login Info</h1>
<div class="login-fields">
<p>Please provide your details</p>
<div class="field">
<label for="username">Username</label>
<input type="text" id="username" name="username" value="" placeholder="Username" class="login username-field" />
</div> <!-- /field -->
<div class="field">
<label for="password">Password:</label>
<input type="password" id="password" name="password" value="" placeholder="Password" class="login password-field"/>
</div> <!-- /password -->
</div> <!-- /login-fields -->
<div class="login-actions">
<button type="submit" name="login" class="button btn btn-success btn-large">Sign In</button>
</div> <!-- .actions -->
</form>
</div> <!-- /content -->
</div> <!-- /account-container -->
<script src="js/js/jquery-1.7.2.min.js"></script>
<script src="js/js/bootstrap.js"></script>
<script src="js/js/signin.js"></script>
Buat file login_info.php agar kita bisa login dan masuk ke dashboard admin
<?php
include('db/dbcon.php');
if (isset($_POST['login'])){
$username=$_POST['username'];
$password=sha1($_POST['password']);
$login_query=mysql_query("select * from admin where username='$username' and password='$password'");
$count=mysql_num_rows($login_query);
$row=mysql_fetch_array($login_query);
$firstname=$row['firstname'];
$lastname=$row['lastname'];
if ($count > 0){
session_start();
$_SESSION['id']=$row['adminid'];
echo "<script>alert('Successfully Login!'); window.location='dashboard.php'</script>";
}else{
echo "<script>alert('Invalid Username and Password! Try again.'); window.location='index.php'</script>";
?>
<?php }
}
?>
include('db/dbcon.php');
if (isset($_POST['login'])){
$username=$_POST['username'];
$password=sha1($_POST['password']);
$login_query=mysql_query("select * from admin where username='$username' and password='$password'");
$count=mysql_num_rows($login_query);
$row=mysql_fetch_array($login_query);
$firstname=$row['firstname'];
$lastname=$row['lastname'];
if ($count > 0){
session_start();
$_SESSION['id']=$row['adminid'];
echo "<script>alert('Successfully Login!'); window.location='dashboard.php'</script>";
}else{
echo "<script>alert('Invalid Username and Password! Try again.'); window.location='index.php'</script>";
?>
<?php }
}
?>
Nah, sekarang kita buat file dashboard.php
<?php require('header.php'); ?>
<ul class="breadcrumb">
<li>
<i class="icon-home"></i>
<a href="dashboard.php">Home</a>
<i class="icon-angle-right"></i>
</li>
</ul>
<?php include('slide.php'); ?>
<?php require('footer.php'); ?>
<ul class="breadcrumb">
<li>
<i class="icon-home"></i>
<a href="dashboard.php">Home</a>
<i class="icon-angle-right"></i>
</li>
</ul>
<?php include('slide.php'); ?>
<?php require('footer.php'); ?>
Selanjutnya kita buat file slide.php, catatan untuk gambar kalian bisa cari sendiri jika ingin diganti lalu ganti sesuai yang dipanggil pada file slide.php
<!--slider-->
<div id="slidy-container">
<figure id="slidy">
<img class="img-responsive img-rounded" src="images/slider/10.jpg" alt="">
<img class="img-responsive img-rounded" src="images/slider/11.jpg" alt="">
<img class="img-responsive img-rounded" src="images/slider/12.jpg" alt="">
<img class="img-responsive img-rounded" src="images/slider/13.jpg" alt="">
<img class="img-responsive img-rounded" src="images/slider/14.jpg" alt="">
</figure>
</div>
<script>
var timeOnSlide = 3,
timeBetweenSlides = 1,
animationstring = 'animation',
animation = false,
keyframeprefix = '',
domPrefixes = 'Webkit Moz O Khtml'.split(' '),
pfx = '',
slidy = document.getElementById("slidy");
if (slidy.style.animationName !== undefined) { animation = true; }
if ( animation === false ) {
for ( var i = 0; i < domPrefixes.length; i++ ) {
if ( slidy.style[ domPrefixes[i] + 'AnimationName' ] !== undefined ) {
pfx = domPrefixes[ i ];
animationstring = pfx + 'Animation';
keyframeprefix = '-' + pfx.toLowerCase() + '-';
animation = true;
break;
} } }
if ( animation === false ) {
// animate using a JavaScript fallback, if you wish
} else {
var images = slidy.getElementsByTagName("img"),
firstImg = images[0],
imgWrap = firstImg.cloneNode(false);
slidy.appendChild(imgWrap);
var imgCount = images.length,
totalTime = (timeOnSlide + timeBetweenSlides) * (imgCount - 1),
slideRatio = (timeOnSlide / totalTime)*100,
moveRatio = (timeBetweenSlides / totalTime)*100,
basePercentage = 100/imgCount,
position = 0,
css = document.createElement("style");
css.type = "text/css";
css.innerHTML += "#slidy { text-align: left; margin: 0; font-size: 0; position: relative; width: " + (imgCount * 100) + "%; }";
css.innerHTML += "#slidy img { float: left; width: " + basePercentage + "%; }";
css.innerHTML += "@"+keyframeprefix+"keyframes slidy {";
for (i=0;i<(imgCount-1); i++) {
position+= slideRatio;
css.innerHTML += position+"% { left: -"+(i * 100)+"%; }";
position += moveRatio;
css.innerHTML += position+"% { left: -"+((i+1) * 100)+"%; }";
}
css.innerHTML += "}";
css.innerHTML += "#slidy { left: 0%; "+keyframeprefix+"transform: translate3d(0,0,0); "+keyframeprefix+"animation: "+totalTime+"s slidy infinite; }";
document.body.appendChild(css);
}
</script>
Buat file schedule.php untuk menambahkan jadwal bus
<?php include ('header.php'); ?>
<?php
$user_query = mysql_query("select * from admin where adminid = '$id_session'")or die(mysql_error());
$user_row =mysql_fetch_array($user_query);
$user_type = $user_row['user_type'];
?>
<ul class="breadcrumb">
<li>
<i class="icon-home"></i>
<a href="dashboard.php">Home</a>
<i class="icon-angle-right"></i>
</li>
<li><a href="branch.php">Schedule Information</a></li>
</ul>
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Welcome!</strong> Bus Dispatch and Information System
</div>
<div class="row-fluid sortable">
<div class="box span12">
<div class="box-header" data-original-title>
<h2>
<?php
$result = mysql_query("SELECT * FROM schedule order by scheduleid DESC");
$num_rows = mysql_num_rows($result);
?>
<i class="halflings-icon user"></i><span class="label label-success"><?php echo $num_rows; ?></span><span class="break"></span>
<?php if ($user_type == 'Admin' || 'Dispatcher'){
?>
<a href="add_schedule.php">
<button style="margin-top:-7px;" class="btn btn-small btn-primary"><i class="halflings-icon plus white"></i> Schedule</button>
</a>
<?php } ?>
</h2>
<div class="box-icon">
<a href="#" class="btn-minimize"><i class="halflings-icon chevron-up"></i></a>
<a href="#" class="btn-close"><i class="halflings-icon remove"></i></a>
</div>
</div>
<div class="box-content">
<table class="table table-striped table-bordered bootstrap-datatable datatable">
<thead>
<tr>
<th>Schedule ID</th>
<th>Bus ID</th>
<th>Driver ID</th>
<th>From Location</th>
<th>Destination</th>
<th>Passanger</th>
<th>Departure Time</th>
<th>Arrival Time</th>
<th>Status</th>
<th>Status Operation</th>
<th>Arrived At Destination</th>
<th>Date Added</th>
<th>Income</th>
<?php if ($user_type == 'Admin'){
?>
<th>Actions</th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php
include ('db/dbcon.php');
$result= mysql_query("select * from schedule order by scheduleid DESC") or die (mysql_error());
while ($row= mysql_fetch_array ($result) ){
$id=$row['scheduleid'];
?>
<tr>
<td><?php echo $row['scheduleid']; ?></td>
<td><?php echo $row['busid']; ?></td>
<td><?php echo $row['driverid']; ?></td>
<td><?php echo $row['from_location']; ?></td>
<td><?php echo $row['destination_location']; ?></td>
<td><?php echo $row['passanger']; ?></td>
<td><?php echo $row['departure_time']; ?></td>
<td><?php echo $row['arrival_time']; ?></td>
<td><?php echo $row['status']; ?></td>
<td><?php echo $row['status_operation']; ?></td>
<td><?php echo $row['arrived_at_destination']; ?></td>
<td class="center">
<span class="label label-success"><?php echo $row['date_added']; ?></span>
</td>
<td><?php echo $row['income'];?></td>
<?php if ($user_type == 'Admin'){
?>
<td class="center">
<a class="btn btn-success" href="view_schedule.php<?php echo '?scheduleid='.$id; ?>">
<i class="halflings-icon white zoom-in"></i>
</a>
<a class="btn btn-info" href="edit_schedule.php<?php echo '?scheduleid='.$id; ?>">
<i class="halflings-icon white edit"></i>
</a>
<a class="btn btn-danger btn-setting" href="myModal<?php echo $id; ?>">
<i class="halflings-icon white trash"></i>
</a>
</td>
<?php } ?>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div><!--/span-->
</div><!--/row-->
<!--- Delete Modal -->
<div class="modal hide fade" id="myModal">
<div class="modal-header">
<i class="halflings-icon info-sign"></i><span class="hidden-tablet"> Schedule Information</span>
</div>
<div class="modal-body">
<p>Are you sure you want to delete?</p>
</div>
<div class="modal-footer">
<a href="schedule.php" class="btn" data-dismiss="modal">Close</a>
<a href="delete_schedule.php<?php echo '?scheduleid='.$id; ?>" class="btn btn-primary"><i class=" halflings-icon remove white"></i> Delete</a>
</div>
</div>
<?php include ('footer.php'); ?>
<?php
$user_query = mysql_query("select * from admin where adminid = '$id_session'")or die(mysql_error());
$user_row =mysql_fetch_array($user_query);
$user_type = $user_row['user_type'];
?>
<ul class="breadcrumb">
<li>
<i class="icon-home"></i>
<a href="dashboard.php">Home</a>
<i class="icon-angle-right"></i>
</li>
<li><a href="branch.php">Schedule Information</a></li>
</ul>
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Welcome!</strong> Bus Dispatch and Information System
</div>
<div class="row-fluid sortable">
<div class="box span12">
<div class="box-header" data-original-title>
<h2>
<?php
$result = mysql_query("SELECT * FROM schedule order by scheduleid DESC");
$num_rows = mysql_num_rows($result);
?>
<i class="halflings-icon user"></i><span class="label label-success"><?php echo $num_rows; ?></span><span class="break"></span>
<?php if ($user_type == 'Admin' || 'Dispatcher'){
?>
<a href="add_schedule.php">
<button style="margin-top:-7px;" class="btn btn-small btn-primary"><i class="halflings-icon plus white"></i> Schedule</button>
</a>
<?php } ?>
</h2>
<div class="box-icon">
<a href="#" class="btn-minimize"><i class="halflings-icon chevron-up"></i></a>
<a href="#" class="btn-close"><i class="halflings-icon remove"></i></a>
</div>
</div>
<div class="box-content">
<table class="table table-striped table-bordered bootstrap-datatable datatable">
<thead>
<tr>
<th>Schedule ID</th>
<th>Bus ID</th>
<th>Driver ID</th>
<th>From Location</th>
<th>Destination</th>
<th>Passanger</th>
<th>Departure Time</th>
<th>Arrival Time</th>
<th>Status</th>
<th>Status Operation</th>
<th>Arrived At Destination</th>
<th>Date Added</th>
<th>Income</th>
<?php if ($user_type == 'Admin'){
?>
<th>Actions</th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php
include ('db/dbcon.php');
$result= mysql_query("select * from schedule order by scheduleid DESC") or die (mysql_error());
while ($row= mysql_fetch_array ($result) ){
$id=$row['scheduleid'];
?>
<tr>
<td><?php echo $row['scheduleid']; ?></td>
<td><?php echo $row['busid']; ?></td>
<td><?php echo $row['driverid']; ?></td>
<td><?php echo $row['from_location']; ?></td>
<td><?php echo $row['destination_location']; ?></td>
<td><?php echo $row['passanger']; ?></td>
<td><?php echo $row['departure_time']; ?></td>
<td><?php echo $row['arrival_time']; ?></td>
<td><?php echo $row['status']; ?></td>
<td><?php echo $row['status_operation']; ?></td>
<td><?php echo $row['arrived_at_destination']; ?></td>
<td class="center">
<span class="label label-success"><?php echo $row['date_added']; ?></span>
</td>
<td><?php echo $row['income'];?></td>
<?php if ($user_type == 'Admin'){
?>
<td class="center">
<a class="btn btn-success" href="view_schedule.php<?php echo '?scheduleid='.$id; ?>">
<i class="halflings-icon white zoom-in"></i>
</a>
<a class="btn btn-info" href="edit_schedule.php<?php echo '?scheduleid='.$id; ?>">
<i class="halflings-icon white edit"></i>
</a>
<a class="btn btn-danger btn-setting" href="myModal<?php echo $id; ?>">
<i class="halflings-icon white trash"></i>
</a>
</td>
<?php } ?>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div><!--/span-->
</div><!--/row-->
<!--- Delete Modal -->
<div class="modal hide fade" id="myModal">
<div class="modal-header">
<i class="halflings-icon info-sign"></i><span class="hidden-tablet"> Schedule Information</span>
</div>
<div class="modal-body">
<p>Are you sure you want to delete?</p>
</div>
<div class="modal-footer">
<a href="schedule.php" class="btn" data-dismiss="modal">Close</a>
<a href="delete_schedule.php<?php echo '?scheduleid='.$id; ?>" class="btn btn-primary"><i class=" halflings-icon remove white"></i> Delete</a>
</div>
</div>
<?php include ('footer.php'); ?>
Jika ingin menambahkan jadwal selanjutnya kita buat file add_schedule.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" name="viewport"/
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Bus Dispatch and Information System</title>
<!-- Bootstrap Core CSS -->
<link href="css/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/css/simple-sidebar.css" rel="stylesheet">
<!-- SignIn CSS -->
<link href="css/css/signin.css" rel="stylesheet" type="text/css">
<link href="css/bootstrap-datetimepicker.min.css" rel="stylesheet">
<link href="css/font-awesome.min.css" rel="stylesheet">
<script src="js/jquery-1.9.1.min.js"></script>
<script src="js/moment.js"></script>
<script src="js/bootstrap-datetimepicker.min.js"></script>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css" rel="stylesheet">
<style type="text/css">
.wrapper{
padding:50px;
}
</style>
<!--<link rel="stylesheet" type="text/javascript" href="js/bootstrap.js">
<link rel="stylesheet" type="text/javascript" href="js/bootstrap-datetimepicker.js">
<link rel="stylesheet" type="text/javascript" href="js/jquery-1.9.1.min.js">-->
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script type="text/javascript">
$(function () {
$('#datetimepicker2').datetimepicker({
format: 'YYYY-MM-DD hh:mm:ss A',
});
});
</script>
</head>
<body>
<!-- navbar start -->
<nav class="navbar navbar-inverse" style="border-radius:0px;" >
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand">Bus Dispatch and Information System</a>
</div>
<ul class="nav navbar-nav navbar-right">
<li class="">
<a>
<?php include('currentdate.php'); ?> <?php include('clock_lcd.php'); ?>
</a>
</li>
</ul>
</div>
</nav>
<!-- navbar end -->
<div class="wrapper">
<div class="row">
<div class="col-md-12">
<div class="col-md-3"></div>
<div class="col-md-6">
<form action="" method="post" role="form" class="form-horizontal">
<h1>Enter Details</h1>
<div class="login-form-groups">
<p>Add Schedule: </p>
<div class="form-group">
<label for="Brach Location">Bus Number</label>
<select name="busnum" class="login" style="font-family: 'Open Sans'; font-size: 13px; color: #8e8d8d; background-color: #fdfdfd; width: 100%; display: block; height: 40px; margin: 0; box-shadow: inset 2px 2px 4px #f1f1f1;">
<option value="" selected disabled>Choose Number Bus</option>
<?php
include('db/dbcon.php');
$result = mysql_query("select * from bus")or die(mysql_error());
while ($row=mysql_fetch_array($result)){ ?>
<option value="<?php echo $row[0]; ?>"><?php echo $row[1]; ?></option>
<?php } ?>
</select>
</div> <!-- /form-group -->
<div class="form-group">
<label for="username">Driver</label>
<select name="driver" class="login" style="font-family: 'Open Sans'; font-size: 13px; color: #8e8d8d; background-color: #fdfdfd; width: 100%; display: block; height: 40px; margin: 0; box-shadow: inset 2px 2px 4px #f1f1f1;">
<option value="" disabled selected>Choose Driver</option>
<?php
include('db/dbcon.php');
$result = mysql_query("select * from driver")or die(mysql_error());
while ($row=mysql_fetch_array($result)){ ?>
<option value="<?php echo $row[0]; ?>"><?php echo $row[1]. " ".$row[2]; ?></option>
<?php } ?>
</select>
</div> <!-- /form-group -->
<div class="form-group">
<label for="Branch Location">From Location</label>
<select name="departure" class="login" style="font-family: 'Open Sans'; font-size: 13px; color: #8e8d8d; background-color: #fdfdfd; width: 100%; display: block; height: 40px; margin: 0; box-shadow: inset 2px 2px 4px #f1f1f1;">
<option value disabled selected>Choose Departure</option>
<?php
include('db/dbcon.php');
$result = mysql_query("select * from route")or die(mysql_error());
while ($row=mysql_fetch_array($result)){ ?>
<option value="<?php echo $row[0]; ?>"><?php echo $row[0] ?></option>
<?php } ?>
</select>
</div> <!-- /form-group -->
<div class="form-group">
<label for="Branch Location">Destination</label>
<select name="destination" class="login" style="font-family: 'Open Sans'; font-size: 13px; color: #8e8d8d; background-color: #fdfdfd; width: 100%; display: block; height: 40px; margin: 0; box-shadow: inset 2px 2px 4px #f1f1f1;">
<option value="" selected disabled>Choose Destination</option>
<?php
include('db/dbcon.php');
$result = mysql_query("select * from route")or die(mysql_error());
while ($row=mysql_fetch_array($result)){ ?>
<option value="<?php echo $row[1]; ?>"><?php echo $row[1] ?></option>
<?php } ?>
</select>
</div> <!-- /form-group -->
<div class="form-group">
<label for="firstname">Passanger</label>
<input type="text" style="width: 100%;" id="username" name="passanger" value="" placeholder="Passanger" class="login" required />
</div> <!-- /form-group -->
<div class="form-group">
<label for="Branch Location">Branch Location</label>
<select name="branchid" class="login" style="font-family: 'Open Sans'; font-size: 13px; color: #8e8d8d; background-color: #fdfdfd; width: 100%; display: block; height: 40px; margin: 0; box-shadow: inset 2px 2px 4px #f1f1f1;">
<option value="" selected disabled>Choose Branch</option>
<?php
include('db/dbcon.php');
$result = mysql_query("select * from branch")or die(mysql_error());
while ($row=mysql_fetch_array($result)){ ?>
<option value="<?php echo $row['branch_location']; ?>"><?php echo $row['branch_location']; ?></option>
<?php } ?>
</select>
</div> <!-- /form-group -->
<div class="form-group">
<label for="datetimepicker">Departure On</label>
<div class='input-group date' id='datetimepicker2'>
<input type='text' name="date" class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
<div class="login-actions">
<button type="submit" name="save" class="button btn btn-primary btn-large">Add</button>
<a href="schedule.php"><button type="button" style="margin-right:20px;" class="button btn btn-primary btn-large">Cancel</button></a>
</div>
<!-- .actions -->
</div> <!-- /login-form-groups -->
</form>
<?php
include ('db/dbcon.php');
if (isset($_POST['save'])){
$busnum=$_POST['busnum'];
$driver=$_POST['driver'];
$from=$_POST['departure'];
$destination=$_POST['destination'];
$passanger=$_POST['passanger'];
$terminal=$_POST['branchid'];
$date = $_POST['date'];
$harga= mysql_query("SELECT harga FROM bus WHERE busid='$busnum'");
$roww = mysql_fetch_array($harga);
if($roww > 0 ){
$price = $roww['harga'];
}
$subtot = $price * $passanger;
$r=mysql_query("SELECT price FROM route WHERE from_location='$from' AND destination_location ='$destination'") or die(mysql_error());
$rr=mysql_fetch_array($r);
if($rr > 0){
$sub = $rr['price'];
}
$tot = $subtot * $sub;
$result=mysql_query("select * from schedule WHERE busid='$busnum' and status='Travel' or driverid='$driver'") or die (mySQL_error());
$row=mysql_num_rows($result);
if ($row > 0)
{
echo "<script>alert('Bus On travel or Driver not available!'); window.location='add_schedule.php'</script>";
}
else
mysql_query("INSERT INTO schedule VALUES(NULL,'$busnum','$driver','$from','$destination','$passanger','$date','0000-00-00 00:00:00','$terminal','Travel','On Travel','Not Yet',CURRENT_TIMESTAMP,'$tot')") or die(mysql_error());
echo"<script>alert('Data Disimpan'); window.location='schedule.php'</script>";
}
?>
</div>
</div>
</div> <!-- /content -->
</div> <!-- /account-container -->
<!--<script src="js/jquery-1.9.1.min.js"></script>-->
<script src="js/js/signin.js"></script>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" name="viewport"/
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Bus Dispatch and Information System</title>
<!-- Bootstrap Core CSS -->
<link href="css/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/css/simple-sidebar.css" rel="stylesheet">
<!-- SignIn CSS -->
<link href="css/css/signin.css" rel="stylesheet" type="text/css">
<link href="css/bootstrap-datetimepicker.min.css" rel="stylesheet">
<link href="css/font-awesome.min.css" rel="stylesheet">
<script src="js/jquery-1.9.1.min.js"></script>
<script src="js/moment.js"></script>
<script src="js/bootstrap-datetimepicker.min.js"></script>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css" rel="stylesheet">
<style type="text/css">
.wrapper{
padding:50px;
}
</style>
<!--<link rel="stylesheet" type="text/javascript" href="js/bootstrap.js">
<link rel="stylesheet" type="text/javascript" href="js/bootstrap-datetimepicker.js">
<link rel="stylesheet" type="text/javascript" href="js/jquery-1.9.1.min.js">-->
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script type="text/javascript">
$(function () {
$('#datetimepicker2').datetimepicker({
format: 'YYYY-MM-DD hh:mm:ss A',
});
});
</script>
</head>
<body>
<!-- navbar start -->
<nav class="navbar navbar-inverse" style="border-radius:0px;" >
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand">Bus Dispatch and Information System</a>
</div>
<ul class="nav navbar-nav navbar-right">
<li class="">
<a>
<?php include('currentdate.php'); ?> <?php include('clock_lcd.php'); ?>
</a>
</li>
</ul>
</div>
</nav>
<!-- navbar end -->
<div class="wrapper">
<div class="row">
<div class="col-md-12">
<div class="col-md-3"></div>
<div class="col-md-6">
<form action="" method="post" role="form" class="form-horizontal">
<h1>Enter Details</h1>
<div class="login-form-groups">
<p>Add Schedule: </p>
<div class="form-group">
<label for="Brach Location">Bus Number</label>
<select name="busnum" class="login" style="font-family: 'Open Sans'; font-size: 13px; color: #8e8d8d; background-color: #fdfdfd; width: 100%; display: block; height: 40px; margin: 0; box-shadow: inset 2px 2px 4px #f1f1f1;">
<option value="" selected disabled>Choose Number Bus</option>
<?php
include('db/dbcon.php');
$result = mysql_query("select * from bus")or die(mysql_error());
while ($row=mysql_fetch_array($result)){ ?>
<option value="<?php echo $row[0]; ?>"><?php echo $row[1]; ?></option>
<?php } ?>
</select>
</div> <!-- /form-group -->
<div class="form-group">
<label for="username">Driver</label>
<select name="driver" class="login" style="font-family: 'Open Sans'; font-size: 13px; color: #8e8d8d; background-color: #fdfdfd; width: 100%; display: block; height: 40px; margin: 0; box-shadow: inset 2px 2px 4px #f1f1f1;">
<option value="" disabled selected>Choose Driver</option>
<?php
include('db/dbcon.php');
$result = mysql_query("select * from driver")or die(mysql_error());
while ($row=mysql_fetch_array($result)){ ?>
<option value="<?php echo $row[0]; ?>"><?php echo $row[1]. " ".$row[2]; ?></option>
<?php } ?>
</select>
</div> <!-- /form-group -->
<div class="form-group">
<label for="Branch Location">From Location</label>
<select name="departure" class="login" style="font-family: 'Open Sans'; font-size: 13px; color: #8e8d8d; background-color: #fdfdfd; width: 100%; display: block; height: 40px; margin: 0; box-shadow: inset 2px 2px 4px #f1f1f1;">
<option value disabled selected>Choose Departure</option>
<?php
include('db/dbcon.php');
$result = mysql_query("select * from route")or die(mysql_error());
while ($row=mysql_fetch_array($result)){ ?>
<option value="<?php echo $row[0]; ?>"><?php echo $row[0] ?></option>
<?php } ?>
</select>
</div> <!-- /form-group -->
<div class="form-group">
<label for="Branch Location">Destination</label>
<select name="destination" class="login" style="font-family: 'Open Sans'; font-size: 13px; color: #8e8d8d; background-color: #fdfdfd; width: 100%; display: block; height: 40px; margin: 0; box-shadow: inset 2px 2px 4px #f1f1f1;">
<option value="" selected disabled>Choose Destination</option>
<?php
include('db/dbcon.php');
$result = mysql_query("select * from route")or die(mysql_error());
while ($row=mysql_fetch_array($result)){ ?>
<option value="<?php echo $row[1]; ?>"><?php echo $row[1] ?></option>
<?php } ?>
</select>
</div> <!-- /form-group -->
<div class="form-group">
<label for="firstname">Passanger</label>
<input type="text" style="width: 100%;" id="username" name="passanger" value="" placeholder="Passanger" class="login" required />
</div> <!-- /form-group -->
<div class="form-group">
<label for="Branch Location">Branch Location</label>
<select name="branchid" class="login" style="font-family: 'Open Sans'; font-size: 13px; color: #8e8d8d; background-color: #fdfdfd; width: 100%; display: block; height: 40px; margin: 0; box-shadow: inset 2px 2px 4px #f1f1f1;">
<option value="" selected disabled>Choose Branch</option>
<?php
include('db/dbcon.php');
$result = mysql_query("select * from branch")or die(mysql_error());
while ($row=mysql_fetch_array($result)){ ?>
<option value="<?php echo $row['branch_location']; ?>"><?php echo $row['branch_location']; ?></option>
<?php } ?>
</select>
</div> <!-- /form-group -->
<div class="form-group">
<label for="datetimepicker">Departure On</label>
<div class='input-group date' id='datetimepicker2'>
<input type='text' name="date" class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
<div class="login-actions">
<button type="submit" name="save" class="button btn btn-primary btn-large">Add</button>
<a href="schedule.php"><button type="button" style="margin-right:20px;" class="button btn btn-primary btn-large">Cancel</button></a>
</div>
<!-- .actions -->
</div> <!-- /login-form-groups -->
</form>
<?php
include ('db/dbcon.php');
if (isset($_POST['save'])){
$busnum=$_POST['busnum'];
$driver=$_POST['driver'];
$from=$_POST['departure'];
$destination=$_POST['destination'];
$passanger=$_POST['passanger'];
$terminal=$_POST['branchid'];
$date = $_POST['date'];
$harga= mysql_query("SELECT harga FROM bus WHERE busid='$busnum'");
$roww = mysql_fetch_array($harga);
if($roww > 0 ){
$price = $roww['harga'];
}
$subtot = $price * $passanger;
$r=mysql_query("SELECT price FROM route WHERE from_location='$from' AND destination_location ='$destination'") or die(mysql_error());
$rr=mysql_fetch_array($r);
if($rr > 0){
$sub = $rr['price'];
}
$tot = $subtot * $sub;
$result=mysql_query("select * from schedule WHERE busid='$busnum' and status='Travel' or driverid='$driver'") or die (mySQL_error());
$row=mysql_num_rows($result);
if ($row > 0)
{
echo "<script>alert('Bus On travel or Driver not available!'); window.location='add_schedule.php'</script>";
}
else
mysql_query("INSERT INTO schedule VALUES(NULL,'$busnum','$driver','$from','$destination','$passanger','$date','0000-00-00 00:00:00','$terminal','Travel','On Travel','Not Yet',CURRENT_TIMESTAMP,'$tot')") or die(mysql_error());
echo"<script>alert('Data Disimpan'); window.location='schedule.php'</script>";
}
?>
</div>
</div>
</div> <!-- /content -->
</div> <!-- /account-container -->
<!--<script src="js/jquery-1.9.1.min.js"></script>-->
<script src="js/js/signin.js"></script>
Kita buat file driver.php
<?php include ('header.php'); ?>
<?php
$user_query = mysql_query("select * from admin where adminid = '$id_session'")or die(mysql_error());
$user_row =mysql_fetch_array($user_query);
$user_type = $user_row['user_type'];
?>
<ul class="breadcrumb">
<li>
<i class="icon-home"></i>
<a href="dashboard.php">Home</a>
<i class="icon-angle-right"></i>
</li>
<li><a href="driver.php">Driver Profile</a></li>
</ul>
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Welcome!</strong> Driver
</div>
<div class="row-fluid sortable">
<div class="box span12">
<div class="box-header" data-original-title>
<h2>
<?php
$result = mysql_query("SELECT * FROM driver");
$num_rows = mysql_num_rows($result);
?>
<i class="halflings-icon user"></i><span class="label label-success"><?php echo $num_rows; ?></span><span class="break"></span>
<?php if ($user_type == 'Admin'){
?>
<a href="add_driver.php">
<button style="margin-top:-7px;" class="btn btn-small btn-primary"><i class="halflings-icon plus white"></i> Driver</button>
</a>
<?php } ?>
</h2>
<div class="box-icon">
<a href="#" class="btn-minimize"><i class="halflings-icon chevron-up"></i></a>
<a href="#" class="btn-close"><i class="halflings-icon remove"></i></a>
</div>
</div>
<div class="box-content">
<table class="table table-striped table-bordered bootstrap-datatable datatable">
<thead>
<tr>
<th>Profile Image</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Contact Number</th>
<th>Date Added</th>
<?php if ($user_type == 'Admin'){
?>
<th>Actions</th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php
include ('db/dbcon.php');
$result= mysql_query("select * from driver order by driverid DESC") or die (mysql_error());
while ($row= mysql_fetch_array ($result) ){
$id=$row['driverid'];
?>
<tr>
<td style="text-align:center; word-break:break-all; width:200px;"><a href="#image<?php echo $id;?>"><?php if($row['profile'] != ""): ?>
<img src="upload/<?php echo $row['profile']; ?>" width="100px" height="100px" style="border:4px groove #CCCCCC; border-radius:5px;">
<?php else: ?>
<img src="images/default.png" width="100px" height="100px" style="border:4px groove #CCCCCC; border-radius:5px;">
<?php endif; ?>
</a></td>
<td><?php echo $row['firstname']; ?></td>
<td class="center"><?php echo $row['lastname']; ?></td>
<td class="center"><?php echo $row['contact_number']; ?></td>
<td class="center">
<span class="label label-success"><?php echo $row['date_added']; ?></span>
</td>
<?php if ($user_type == 'Admin'){
?>
<td class="center">
<a class="btn btn-success" href="view_driver.php<?php echo '?driverid='.$id; ?>">
<i class="halflings-icon white zoom-in"></i>
</a>
<a class="btn btn-info" href="edit_driver.php<?php echo '?driverid='.$id; ?>">
<i class="halflings-icon white edit"></i>
</a>
<a class="btn btn-danger btn-setting" href="myModal<?php echo $id; ?>">
<i class="halflings-icon white trash"></i>
</a>
</td>
<?php } ?>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div><!--/span-->
</div><!--/row-->
<!--- Delete Modal -->
<div class="modal hide fade" id="myModal">
<div class="modal-header">
<i class="halflings-icon user"></i><span class="hidden-tablet"> Driver Profile</span>
</div>
<div class="modal-body">
<p>Are you sure you want to delete?</p>
</div>
<div class="modal-footer">
<a href="driver.php" class="btn" data-dismiss="modal">Close</a>
<a href="delete_driver.php<?php echo '?driverid='.$id; ?>" class="btn btn-primary"><i class=" halflings-icon remove white"></i> Delete</a>
</div>
</div>
<?php include ('footer.php'); ?>
<?php
$user_query = mysql_query("select * from admin where adminid = '$id_session'")or die(mysql_error());
$user_row =mysql_fetch_array($user_query);
$user_type = $user_row['user_type'];
?>
<ul class="breadcrumb">
<li>
<i class="icon-home"></i>
<a href="dashboard.php">Home</a>
<i class="icon-angle-right"></i>
</li>
<li><a href="driver.php">Driver Profile</a></li>
</ul>
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Welcome!</strong> Driver
</div>
<div class="row-fluid sortable">
<div class="box span12">
<div class="box-header" data-original-title>
<h2>
<?php
$result = mysql_query("SELECT * FROM driver");
$num_rows = mysql_num_rows($result);
?>
<i class="halflings-icon user"></i><span class="label label-success"><?php echo $num_rows; ?></span><span class="break"></span>
<?php if ($user_type == 'Admin'){
?>
<a href="add_driver.php">
<button style="margin-top:-7px;" class="btn btn-small btn-primary"><i class="halflings-icon plus white"></i> Driver</button>
</a>
<?php } ?>
</h2>
<div class="box-icon">
<a href="#" class="btn-minimize"><i class="halflings-icon chevron-up"></i></a>
<a href="#" class="btn-close"><i class="halflings-icon remove"></i></a>
</div>
</div>
<div class="box-content">
<table class="table table-striped table-bordered bootstrap-datatable datatable">
<thead>
<tr>
<th>Profile Image</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Contact Number</th>
<th>Date Added</th>
<?php if ($user_type == 'Admin'){
?>
<th>Actions</th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php
include ('db/dbcon.php');
$result= mysql_query("select * from driver order by driverid DESC") or die (mysql_error());
while ($row= mysql_fetch_array ($result) ){
$id=$row['driverid'];
?>
<tr>
<td style="text-align:center; word-break:break-all; width:200px;"><a href="#image<?php echo $id;?>"><?php if($row['profile'] != ""): ?>
<img src="upload/<?php echo $row['profile']; ?>" width="100px" height="100px" style="border:4px groove #CCCCCC; border-radius:5px;">
<?php else: ?>
<img src="images/default.png" width="100px" height="100px" style="border:4px groove #CCCCCC; border-radius:5px;">
<?php endif; ?>
</a></td>
<td><?php echo $row['firstname']; ?></td>
<td class="center"><?php echo $row['lastname']; ?></td>
<td class="center"><?php echo $row['contact_number']; ?></td>
<td class="center">
<span class="label label-success"><?php echo $row['date_added']; ?></span>
</td>
<?php if ($user_type == 'Admin'){
?>
<td class="center">
<a class="btn btn-success" href="view_driver.php<?php echo '?driverid='.$id; ?>">
<i class="halflings-icon white zoom-in"></i>
</a>
<a class="btn btn-info" href="edit_driver.php<?php echo '?driverid='.$id; ?>">
<i class="halflings-icon white edit"></i>
</a>
<a class="btn btn-danger btn-setting" href="myModal<?php echo $id; ?>">
<i class="halflings-icon white trash"></i>
</a>
</td>
<?php } ?>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div><!--/span-->
</div><!--/row-->
<!--- Delete Modal -->
<div class="modal hide fade" id="myModal">
<div class="modal-header">
<i class="halflings-icon user"></i><span class="hidden-tablet"> Driver Profile</span>
</div>
<div class="modal-body">
<p>Are you sure you want to delete?</p>
</div>
<div class="modal-footer">
<a href="driver.php" class="btn" data-dismiss="modal">Close</a>
<a href="delete_driver.php<?php echo '?driverid='.$id; ?>" class="btn btn-primary"><i class=" halflings-icon remove white"></i> Delete</a>
</div>
</div>
<?php include ('footer.php'); ?>
Lalu buat file bus.php untuk melihat daftar bus yang terdaftar dalam database
<?php include ('header.php'); ?>
<?php
$user_query = mysql_query("select * from admin where adminid = '$id_session'")or die(mysql_error());
$user_row =mysql_fetch_array($user_query);
$user_type = $user_row['user_type'];
?>
<ul class="breadcrumb">
<li>
<i class="icon-home"></i>
<a href="dashboard.php">Home</a>
<i class="icon-angle-right"></i>
</li>
<li><a href="bus.php">Bus Information</a></li>
</ul>
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Welcome!</strong> Bus Dispatch and Information System
</div>
<div class="row-fluid sortable">
<div class="box span12">
<div class="box-header" data-original-title>
<h2>
<?php
$result = mysql_query("SELECT * FROM bus");
$num_rows = mysql_num_rows($result);
?>
<i class="halflings-icon user"></i><span class="label label-success"><?php echo $num_rows; ?></span><span class="break"></span>
<?php if ($user_type == 'Admin'){
?>
<a href="add_bus.php">
<button style="margin-top:-7px;" class="btn btn-small btn-primary"><i class="halflings-icon plus white"></i> Bus</button>
</a>
<?php } ?>
</h2>
<div class="box-icon">
<a href="#" class="btn-minimize"><i class="halflings-icon chevron-up"></i></a>
<a href="#" class="btn-close"><i class="halflings-icon remove"></i></a>
</div>
</div>
<div class="box-content">
<table class="table table-striped table-bordered bootstrap-datatable datatable">
<thead>
<tr>
<th>Bus Number</th>
<th>Bus Type</th>
<th>Price</th>
<th>Date Added</th>
<?php if ($user_type == 'Admin'){
?>
<th>Actions</th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php
include ('db/dbcon.php');
$result= mysql_query("select * from bus order by busid DESC") or die (mysql_error());
while ($row= mysql_fetch_array ($result) ){
$id=$row['busid'];
?>
<tr>
<td><?php echo $row['bus_number']; ?></td>
<td class="center"><?php echo $row['bus_type']; ?></td>
<td><?php echo $row['harga']?></td>
<td class="center">
<span class="label label-success"><?php echo $row['date_added']; ?></span>
</td>
<?php if ($user_type == 'Admin'){
?>
<td class="center">
<a class="btn btn-success" href="view_bus.php<?php echo '?busid='.$id; ?>">
<i class="halflings-icon white zoom-in"></i>
</a>
<a class="btn btn-info" href="edit_bus.php<?php echo '?busid='.$id; ?>">
<i class="halflings-icon white edit"></i>
</a>
<a class="btn btn-danger btn-setting" href="myModal<?php echo $id; ?>">
<i class="halflings-icon white trash"></i>
</a>
</td>
<?php } ?>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div><!--/span-->
</div><!--/row-->
<!--- Delete Modal -->
<div class="modal hide fade" id="myModal">
<div class="modal-header">
<i class="halflings-icon info-sign"></i><span class="hidden-tablet"> Bus Information</span>
</div>
<div class="modal-body">
<p>Are you sure you want to delete?</p>
</div>
<div class="modal-footer">
<a href="bus.php" class="btn" data-dismiss="modal">Close</a>
<a href="delete_bus.php<?php echo '?busid='.$id; ?>" class="btn btn-primary"><i class=" halflings-icon remove white"></i> Delete</a>
</div>
</div>
<?php include ('footer.php'); ?>
<?php
$user_query = mysql_query("select * from admin where adminid = '$id_session'")or die(mysql_error());
$user_row =mysql_fetch_array($user_query);
$user_type = $user_row['user_type'];
?>
<ul class="breadcrumb">
<li>
<i class="icon-home"></i>
<a href="dashboard.php">Home</a>
<i class="icon-angle-right"></i>
</li>
<li><a href="bus.php">Bus Information</a></li>
</ul>
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Welcome!</strong> Bus Dispatch and Information System
</div>
<div class="row-fluid sortable">
<div class="box span12">
<div class="box-header" data-original-title>
<h2>
<?php
$result = mysql_query("SELECT * FROM bus");
$num_rows = mysql_num_rows($result);
?>
<i class="halflings-icon user"></i><span class="label label-success"><?php echo $num_rows; ?></span><span class="break"></span>
<?php if ($user_type == 'Admin'){
?>
<a href="add_bus.php">
<button style="margin-top:-7px;" class="btn btn-small btn-primary"><i class="halflings-icon plus white"></i> Bus</button>
</a>
<?php } ?>
</h2>
<div class="box-icon">
<a href="#" class="btn-minimize"><i class="halflings-icon chevron-up"></i></a>
<a href="#" class="btn-close"><i class="halflings-icon remove"></i></a>
</div>
</div>
<div class="box-content">
<table class="table table-striped table-bordered bootstrap-datatable datatable">
<thead>
<tr>
<th>Bus Number</th>
<th>Bus Type</th>
<th>Price</th>
<th>Date Added</th>
<?php if ($user_type == 'Admin'){
?>
<th>Actions</th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php
include ('db/dbcon.php');
$result= mysql_query("select * from bus order by busid DESC") or die (mysql_error());
while ($row= mysql_fetch_array ($result) ){
$id=$row['busid'];
?>
<tr>
<td><?php echo $row['bus_number']; ?></td>
<td class="center"><?php echo $row['bus_type']; ?></td>
<td><?php echo $row['harga']?></td>
<td class="center">
<span class="label label-success"><?php echo $row['date_added']; ?></span>
</td>
<?php if ($user_type == 'Admin'){
?>
<td class="center">
<a class="btn btn-success" href="view_bus.php<?php echo '?busid='.$id; ?>">
<i class="halflings-icon white zoom-in"></i>
</a>
<a class="btn btn-info" href="edit_bus.php<?php echo '?busid='.$id; ?>">
<i class="halflings-icon white edit"></i>
</a>
<a class="btn btn-danger btn-setting" href="myModal<?php echo $id; ?>">
<i class="halflings-icon white trash"></i>
</a>
</td>
<?php } ?>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div><!--/span-->
</div><!--/row-->
<!--- Delete Modal -->
<div class="modal hide fade" id="myModal">
<div class="modal-header">
<i class="halflings-icon info-sign"></i><span class="hidden-tablet"> Bus Information</span>
</div>
<div class="modal-body">
<p>Are you sure you want to delete?</p>
</div>
<div class="modal-footer">
<a href="bus.php" class="btn" data-dismiss="modal">Close</a>
<a href="delete_bus.php<?php echo '?busid='.$id; ?>" class="btn btn-primary"><i class=" halflings-icon remove white"></i> Delete</a>
</div>
</div>
<?php include ('footer.php'); ?>
Lalu kita buat file branch.php yang berfungsi melihat daftar lokasi terminal
<?php include ('header.php'); ?>
<?php
$user_query = mysql_query("select * from admin where adminid = '$id_session'")or die(mysql_error());
$user_row =mysql_fetch_array($user_query);
$user_type = $user_row['user_type'];
?>
<ul class="breadcrumb">
<li>
<i class="icon-home"></i>
<a href="dashboard.php">Home</a>
<i class="icon-angle-right"></i>
</li>
<li><a href="branch.php">Branch Information</a></li>
</ul>
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Welcome!</strong> Bus Dispatch and Information System
</div>
<div class="row-fluid sortable">
<div class="box span12">
<div class="box-header" data-original-title>
<h2>
<?php
$result = mysql_query("SELECT * FROM branch order by branchid DESC");
$num_rows = mysql_num_rows($result);
?>
<i class="halflings-icon user"></i><span class="label label-success"><?php echo $num_rows; ?></span><span class="break"></span>
<?php if ($user_type == 'Admin'){
?>
<a href="add_branch.php">
<button style="margin-top:-7px;" class="btn btn-small btn-primary"><i class="halflings-icon plus white"></i> Branch</button>
</a>
<?php } ?>
</h2>
<div class="box-icon">
<a href="#" class="btn-minimize"><i class="halflings-icon chevron-up"></i></a>
<a href="#" class="btn-close"><i class="halflings-icon remove"></i></a>
</div>
</div>
<div class="box-content">
<table class="table table-striped table-bordered bootstrap-datatable datatable">
<thead>
<tr>
<th>Branch Location</th>
<th>Date Added</th>
<?php if ($user_type == 'Admin'){
?>
<th>Actions</th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php
include ('db/dbcon.php');
$result= mysql_query("select * from branch order by branchid DESC") or die (mysql_error());
while ($row= mysql_fetch_array ($result) ){
$id=$row['branchid'];
?>
<tr>
<td><?php echo $row['branch_location']; ?></td>
<td class="center">
<span class="label label-success"><?php echo $row['date_added']; ?></span>
</td>
<?php if ($user_type == 'Admin'){
?>
<td class="center">
<a class="btn btn-success" href="view_branch.php<?php echo '?branchid='.$id; ?>">
<i class="halflings-icon white zoom-in"></i>
</a>
<a class="btn btn-info" href="edit_branch.php<?php echo '?branchid='.$id; ?>">
<i class="halflings-icon white edit"></i>
</a>
<a class="btn btn-danger btn-setting" href="myModal<?php echo $id; ?>">
<i class="halflings-icon white trash"></i>
</a>
</td>
<?php } ?>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div><!--/span-->
</div><!--/row-->
<!--- Delete Modal -->
<div class="modal hide fade" id="myModal">
<div class="modal-header">
<i class="halflings-icon info-sign"></i><span class="hidden-tablet"> Branch Information</span>
</div>
<div class="modal-body">
<p>Are you sure you want to delete?</p>
</div>
<div class="modal-footer">
<a href="branch.php" class="btn" data-dismiss="modal">Close</a>
<a href="delete_branch.php<?php echo '?branchid='.$id; ?>" class="btn btn-primary"><i class=" halflings-icon remove white"></i> Delete</a>
</div>
</div>
<?php include ('footer.php'); ?>
<?php
$user_query = mysql_query("select * from admin where adminid = '$id_session'")or die(mysql_error());
$user_row =mysql_fetch_array($user_query);
$user_type = $user_row['user_type'];
?>
<ul class="breadcrumb">
<li>
<i class="icon-home"></i>
<a href="dashboard.php">Home</a>
<i class="icon-angle-right"></i>
</li>
<li><a href="branch.php">Branch Information</a></li>
</ul>
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Welcome!</strong> Bus Dispatch and Information System
</div>
<div class="row-fluid sortable">
<div class="box span12">
<div class="box-header" data-original-title>
<h2>
<?php
$result = mysql_query("SELECT * FROM branch order by branchid DESC");
$num_rows = mysql_num_rows($result);
?>
<i class="halflings-icon user"></i><span class="label label-success"><?php echo $num_rows; ?></span><span class="break"></span>
<?php if ($user_type == 'Admin'){
?>
<a href="add_branch.php">
<button style="margin-top:-7px;" class="btn btn-small btn-primary"><i class="halflings-icon plus white"></i> Branch</button>
</a>
<?php } ?>
</h2>
<div class="box-icon">
<a href="#" class="btn-minimize"><i class="halflings-icon chevron-up"></i></a>
<a href="#" class="btn-close"><i class="halflings-icon remove"></i></a>
</div>
</div>
<div class="box-content">
<table class="table table-striped table-bordered bootstrap-datatable datatable">
<thead>
<tr>
<th>Branch Location</th>
<th>Date Added</th>
<?php if ($user_type == 'Admin'){
?>
<th>Actions</th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php
include ('db/dbcon.php');
$result= mysql_query("select * from branch order by branchid DESC") or die (mysql_error());
while ($row= mysql_fetch_array ($result) ){
$id=$row['branchid'];
?>
<tr>
<td><?php echo $row['branch_location']; ?></td>
<td class="center">
<span class="label label-success"><?php echo $row['date_added']; ?></span>
</td>
<?php if ($user_type == 'Admin'){
?>
<td class="center">
<a class="btn btn-success" href="view_branch.php<?php echo '?branchid='.$id; ?>">
<i class="halflings-icon white zoom-in"></i>
</a>
<a class="btn btn-info" href="edit_branch.php<?php echo '?branchid='.$id; ?>">
<i class="halflings-icon white edit"></i>
</a>
<a class="btn btn-danger btn-setting" href="myModal<?php echo $id; ?>">
<i class="halflings-icon white trash"></i>
</a>
</td>
<?php } ?>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div><!--/span-->
</div><!--/row-->
<!--- Delete Modal -->
<div class="modal hide fade" id="myModal">
<div class="modal-header">
<i class="halflings-icon info-sign"></i><span class="hidden-tablet"> Branch Information</span>
</div>
<div class="modal-body">
<p>Are you sure you want to delete?</p>
</div>
<div class="modal-footer">
<a href="branch.php" class="btn" data-dismiss="modal">Close</a>
<a href="delete_branch.php<?php echo '?branchid='.$id; ?>" class="btn btn-primary"><i class=" halflings-icon remove white"></i> Delete</a>
</div>
</div>
<?php include ('footer.php'); ?>
Oke sekarang kita buat file add_bus.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Bus Dispatch and Information System</title>
<!-- Bootstrap Core CSS -->
<link href="css/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/css/simple-sidebar.css" rel="stylesheet">
<!-- SignIn CSS -->
<link href="css/css/signin.css" rel="stylesheet" type="text/css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- navbar start -->
<nav class="navbar navbar-inverse" style="border-radius:0px;" >
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand">Bus Dispatch and Information System</a>
</div>
<ul class="nav navbar-nav navbar-right">
<li class="">
<a>
<?php include('currentdate.php'); ?> <?php include('clock_lcd.php'); ?>
</a>
</li>
</ul>
</div>
</nav>
<!-- navbar end -->
<div class="account-container register">
<div class="content clearfix">
<form action="add_bus_info.php" method="post">
<h1>Enter your Details</h1>
<div class="login-fields">
<p>Create bus information:</p>
<div class="field">
<label for="bus_number">Bus Number:</label>
<input type="text" id="bus_number" name="bus_number" value="" placeholder="Bus Number" class="login" required />
</div> <!-- /field -->
<div class="field">
<label for="Branch Location">Bus Type</label>
<select name="bus_type" class="login" style="font-family: 'Open Sans'; font-size: 13px; color: #8e8d8d; background-color: #fdfdfd; width: 297px; display: block; height: 40px; margin: 0; box-shadow: inset 2px 2px 4px #f1f1f1;">
<option value="" disabled selected>Choose Class</option>
<?php
include('db/dbcon.php');
$result = mysql_query("select * from type")or die(mysql_error());
while ($row=mysql_fetch_array($result)){ ?>
<option value="<?php echo $row['class']; ?>"><?php echo $row['class']; ?></option>
<?php } ?>
</select>
</div> <!-- /field -->
</div> <!-- /login-fields -->
<div class="login-actions">
<button type="submit" name="save" class="button btn btn-primary btn-large">Register</button>
<a href="bus.php"><button type="button" style="margin-right:20px;" class="button btn btn-primary btn-large">Cancel</button></a>
</div>
<!-- .actions -->
</form>
</div> <!-- /content -->
</div> <!-- /account-container -->
<script src="js/js/jquery-1.7.2.min.js"></script>
<script src="js/js/bootstrap.js"></script>
<script src="js/js/signin.js"></script>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Bus Dispatch and Information System</title>
<!-- Bootstrap Core CSS -->
<link href="css/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/css/simple-sidebar.css" rel="stylesheet">
<!-- SignIn CSS -->
<link href="css/css/signin.css" rel="stylesheet" type="text/css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- navbar start -->
<nav class="navbar navbar-inverse" style="border-radius:0px;" >
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand">Bus Dispatch and Information System</a>
</div>
<ul class="nav navbar-nav navbar-right">
<li class="">
<a>
<?php include('currentdate.php'); ?> <?php include('clock_lcd.php'); ?>
</a>
</li>
</ul>
</div>
</nav>
<!-- navbar end -->
<div class="account-container register">
<div class="content clearfix">
<form action="add_bus_info.php" method="post">
<h1>Enter your Details</h1>
<div class="login-fields">
<p>Create bus information:</p>
<div class="field">
<label for="bus_number">Bus Number:</label>
<input type="text" id="bus_number" name="bus_number" value="" placeholder="Bus Number" class="login" required />
</div> <!-- /field -->
<div class="field">
<label for="Branch Location">Bus Type</label>
<select name="bus_type" class="login" style="font-family: 'Open Sans'; font-size: 13px; color: #8e8d8d; background-color: #fdfdfd; width: 297px; display: block; height: 40px; margin: 0; box-shadow: inset 2px 2px 4px #f1f1f1;">
<option value="" disabled selected>Choose Class</option>
<?php
include('db/dbcon.php');
$result = mysql_query("select * from type")or die(mysql_error());
while ($row=mysql_fetch_array($result)){ ?>
<option value="<?php echo $row['class']; ?>"><?php echo $row['class']; ?></option>
<?php } ?>
</select>
</div> <!-- /field -->
</div> <!-- /login-fields -->
<div class="login-actions">
<button type="submit" name="save" class="button btn btn-primary btn-large">Register</button>
<a href="bus.php"><button type="button" style="margin-right:20px;" class="button btn btn-primary btn-large">Cancel</button></a>
</div>
<!-- .actions -->
</form>
</div> <!-- /content -->
</div> <!-- /account-container -->
<script src="js/js/jquery-1.7.2.min.js"></script>
<script src="js/js/bootstrap.js"></script>
<script src="js/js/signin.js"></script>
lalu add_bus_info.php
<?php
include ('db/dbcon.php');
if (isset($_POST['save'])){
$bus_number=$_POST['bus_number'];
$bus_type=$_POST['bus_type'];
$harga= mysql_query("SELECT price FROM type WHERE class='$bus_type'");
$row = mysql_fetch_array($harga);
if($row > 0 ){
$price = $row['price'];
}
mysql_query("insert into bus (bus_number,bus_type,harga,date_added)
values ('$bus_number','$bus_type','$price',DATE_FORMAT(NOW(),'%b %d %Y %h:%i %p'))") or die(mysql_error());
echo "<script>alert('Bus Added!'); window.location='bus.php'</script>";
}
?>
include ('db/dbcon.php');
if (isset($_POST['save'])){
$bus_number=$_POST['bus_number'];
$bus_type=$_POST['bus_type'];
$harga= mysql_query("SELECT price FROM type WHERE class='$bus_type'");
$row = mysql_fetch_array($harga);
if($row > 0 ){
$price = $row['price'];
}
mysql_query("insert into bus (bus_number,bus_type,harga,date_added)
values ('$bus_number','$bus_type','$price',DATE_FORMAT(NOW(),'%b %d %Y %h:%i %p'))") or die(mysql_error());
echo "<script>alert('Bus Added!'); window.location='bus.php'</script>";
}
?>
edit_bus.php
<?php include ('db/dbcon.php');
$ID=$_GET['busid'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Bus Dispatch and Information System</title>
<!-- Bootstrap Core CSS -->
<link href="css/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/css/simple-sidebar.css" rel="stylesheet">
<!-- SignIn CSS -->
<link href="css/css/signin.css" rel="stylesheet" type="text/css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- navbar start -->
<nav class="navbar navbar-inverse" style="border-radius:0px;" >
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand">Bus Dispatch and Information System</a>
</div>
<ul class="nav navbar-nav navbar-right">
<li class="">
<a>
<?php include('currentdate.php'); ?> <?php include('clock_lcd.php'); ?>
</a>
</li>
</ul>
</div>
</nav>
<!-- navbar end -->
<div class="account-container register">
<div class="content clearfix">
<form method="post">
<h1>Edit Details</h1>
<div class="login-fields">
<?php
$query=mysql_query("select * from bus where busid='$ID'")or die(mysql_error());
$row=mysql_fetch_array($query);
?>
<p>Edit bus information:</p>
<div class="field">
<label for="bus_number">Bus Number:</label>
<input type="text" id="bus_number" name="bus_number" value="<?php echo $row['bus_number']; ?>" placeholder="Bus Number" class="login" required />
</div> <!-- /field -->
<div class="field">
<label for="Branch Location">Bus Type</label>
<select name="bus_type" class="login" style="font-family: 'Open Sans'; font-size: 13px; color: #8e8d8d; background-color: #fdfdfd; width: 297px; display: block; height: 40px; margin: 0; box-shadow: inset 2px 2px 4px #f1f1f1;">
<option value="<?php echo $row['bus_type']; ?>"><?php echo $row['bus_type']; ?></option>
<option value="Super Executive">Super Executive</option>
<option value="Executive">Executive</option>
<option value="Bussiness">Bussiness</option>
<option value="Economy">Economy</option>
</select>
</div> <!-- /field -->
</div> <!-- /login-fields -->
<div class="login-actions">
<button type="submit" name="update" class="button btn btn-primary btn-large">Update</button>
<a href="bus.php"><button type="button" style="margin-right:20px;" class="button btn btn-primary btn-large">Cancel</button></a>
</div>
<!-- .actions -->
</form>
<?php
$id =$_GET['busid'];
if (isset($_POST['update'])) {
$bus_number=$_POST['bus_number'];
$bus_type=$_POST['bus_type'];
mysql_query(" UPDATE bus SET bus_number='$bus_number', bus_type='$bus_type' WHERE busid = '$id' ")or die(mysql_error());
echo "<script>alert('Successfully Update!'); window.location='bus.php'</script>";
}
?>
</div> <!-- /content -->
</div> <!-- /account-container -->
<script src="js/js/jquery-1.7.2.min.js"></script>
<script src="js/js/bootstrap.js"></script>
<script src="js/js/signin.js"></script>
$ID=$_GET['busid'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Bus Dispatch and Information System</title>
<!-- Bootstrap Core CSS -->
<link href="css/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/css/simple-sidebar.css" rel="stylesheet">
<!-- SignIn CSS -->
<link href="css/css/signin.css" rel="stylesheet" type="text/css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- navbar start -->
<nav class="navbar navbar-inverse" style="border-radius:0px;" >
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand">Bus Dispatch and Information System</a>
</div>
<ul class="nav navbar-nav navbar-right">
<li class="">
<a>
<?php include('currentdate.php'); ?> <?php include('clock_lcd.php'); ?>
</a>
</li>
</ul>
</div>
</nav>
<!-- navbar end -->
<div class="account-container register">
<div class="content clearfix">
<form method="post">
<h1>Edit Details</h1>
<div class="login-fields">
<?php
$query=mysql_query("select * from bus where busid='$ID'")or die(mysql_error());
$row=mysql_fetch_array($query);
?>
<p>Edit bus information:</p>
<div class="field">
<label for="bus_number">Bus Number:</label>
<input type="text" id="bus_number" name="bus_number" value="<?php echo $row['bus_number']; ?>" placeholder="Bus Number" class="login" required />
</div> <!-- /field -->
<div class="field">
<label for="Branch Location">Bus Type</label>
<select name="bus_type" class="login" style="font-family: 'Open Sans'; font-size: 13px; color: #8e8d8d; background-color: #fdfdfd; width: 297px; display: block; height: 40px; margin: 0; box-shadow: inset 2px 2px 4px #f1f1f1;">
<option value="<?php echo $row['bus_type']; ?>"><?php echo $row['bus_type']; ?></option>
<option value="Super Executive">Super Executive</option>
<option value="Executive">Executive</option>
<option value="Bussiness">Bussiness</option>
<option value="Economy">Economy</option>
</select>
</div> <!-- /field -->
</div> <!-- /login-fields -->
<div class="login-actions">
<button type="submit" name="update" class="button btn btn-primary btn-large">Update</button>
<a href="bus.php"><button type="button" style="margin-right:20px;" class="button btn btn-primary btn-large">Cancel</button></a>
</div>
<!-- .actions -->
</form>
<?php
$id =$_GET['busid'];
if (isset($_POST['update'])) {
$bus_number=$_POST['bus_number'];
$bus_type=$_POST['bus_type'];
mysql_query(" UPDATE bus SET bus_number='$bus_number', bus_type='$bus_type' WHERE busid = '$id' ")or die(mysql_error());
echo "<script>alert('Successfully Update!'); window.location='bus.php'</script>";
}
?>
</div> <!-- /content -->
</div> <!-- /account-container -->
<script src="js/js/jquery-1.7.2.min.js"></script>
<script src="js/js/bootstrap.js"></script>
<script src="js/js/signin.js"></script>
delete_bus.php
<?php
include('db/dbcon.php');
$get_id=$_GET['busid'];
mysql_query("delete from bus where busid = '$get_id' ")or die(mysql_error());
echo "<script>alert('Successfully Delete'); window.location='bus.php'</script>";
?>
include('db/dbcon.php');
$get_id=$_GET['busid'];
mysql_query("delete from bus where busid = '$get_id' ")or die(mysql_error());
echo "<script>alert('Successfully Delete'); window.location='bus.php'</script>";
?>
Oke itulah part 2 mengenai tutorial crud aplikasi PO Bus dengan PHP dan bootstrap. Sampai ketemu di artikel selanjutnya