Project 4, Report (MVC Framework)

Admin System

MVC framework

Multi Media 2014/15 Project 4

Istvan Franko

CET202

Tasks

URL

CSS (design)

Log-in

login_view.php (View)

login.php (Controller)

user.php (Model)

verifylogin.php (Controller)

Validation

Vans

home_view.php (View)

home.php (Controller)

vans_view.php (View)

vans.php (Controller)

datatables_help.php (Helper)

Add van

vAddVan_view.php (View)

addvan.php (Controller)

maddvan.php (Model)

Edit van

vEditVan_view.php (View)

editvan.php (Controller)

meditvan.php (Model)

Drivers

drivers_view.php (View)

drivers.php (Controller)

Add driver

vAddDriver_view.php (View)

adddriver.php (Controller)

madddriver.php (Model)

Edit driver

vEditDriver_view.php (View)

editdriver.php (Controller)

meditdriver.php (Model)

Logs

logs_view.php (View)

logs.php (Controller)

Add log

vAddLog_view.php (View)

addlog.php (Controller)

maddlog.php (Model)

Edit Log

vEditLog_view.php (View)

editlog.php (Controller)

meditlog.php (Model)

Monthly mileage report

vMileageForm_view.php (view)

vMileage_view.php (view)

mileage.php (Controller)

mmileage.php (Model)

Service history

services_view.php (View)

services.php (Controller)

Add service

vAddService_view.php (View)

addservice.php (Controller)

maddservice.php (Model)

Edit service

vEditService_view.php (View)

editservice.php (Controller)

meditservice.php (Model)

Database

mvc_users

mvc_vans

mvc_drivers

mvc_logs

mvc_services

Tasks

Project 4 - Admin System

 

Beanco have distribution centres in Sunderland, Liverpool and Portsmouth. The company has a fleet of 60 vans that deliver products from each centre to retailers daily. The company wants to track vehicle mileages, service records, vehicle damage and repairs more effectively using a browser based system. The current tracking system uses spreadsheets and paper documents.

Using an appropriate MVC framework (as directed by the tutor) and suitable data storage engine (e.g. MySQL) you are required to build a vehicle management system for the company, which will make it easier to track mileages and service records.

All vehicles are fitted with a transmitter which broadcasts the vehicle ID and current location. Drivers start work at 8.30am and return the vehicle at the end of the day, usually around 6.30pm, signing in and returning the keys to the admin office. Staff log the van, employee ID, mileage and any additional notes.

· As a minimum, the vehicle management system functionality should include:

· Ability to view all vehicles (appropriate filtering, sorting and presentation)

· View specific vehicle location (using broadcast data)

· Ability to add new vehicles (all van details including photograph(s)

· Ability to amend vehicle information

· Ability to remove vehicle from system (mark as off-road, disposed etc.)

· Add service/repair information

· View audit/history of vehicle and record(s)

· Add appropriate notes to record

· View upcoming services – with estimated date

· Ability to search for vehicle using various search criteria

· Ability to run monthly mileage reports and vehicle inventory

· Uses the Bootstrap framework for the user interface

A ZIP file containing scanned paper documents (used by drivers and the admin team) has been made available for your perusal and should be consulted prior to the development of the computer system.

The following components should be submitted:

A user manual (including screenshots of each part of the system & URLs)

URL to your system

Full code listing with comments

Database diagram or equivalent

MVC diagrams for system

SQL export file or equivalent

ZIP file containing all of your code (including all MVC and Framework files)

URL

http://www.frankofamily.info/UniOfSunderland/Level2/Multimedia/Project4/MVC/index.php/login

Access: user: Andrew

pass: Andrew

CSS (design)

I used Bootstrap Framework for design my pages. Bootstrap.min.css file added to my all view.

<!--link the bootstrap css file-->

<link rel="stylesheet" href="/../assets/css/bootstrap.min.css">

and

<script type="text/javascript" src="/../assets/js/jquery-1.11.2.js"></script>

<script type="text/javascript" src="/../assets/js/bootstrap.js""></script>

To customize my datatables I added few lines to bootstrap.min.css file:

.wrapper { margin: 0 auto; width: 960px; }

footer { border-top: 1px solid #CCCCCC; float: right; font-size: 12px; margin: 40px 0 0; padding: 10px; width: 81%;}

/*Datatables style*/

#big_table_wrapper {background-color: #fff; }

#big_table_wrapper .dataTables_length {float:left;}

#big_table_wrapper .dataTables_filter {float:right;}

#big_Table_wrapper .ui-toolbar{padding:5px;}

#big_Table_wrapper .ui-toolbar{padding:5px;}

#big_table{width:960px; text-align: center;}

.dataTables_paginate .ui-button { margin-right: -0.1em !important;}

.paging_full_numbers .ui-button { color: #333333 !important; cursor: pointer; margin: 0; padding: 2px 6px;}

.dataTables_info { float: left; width: 50%;}

.dataTables_info { padding-top: 3px;}

.dataTables_paginate { float: right; text-align: right;}

.dataTables_paginate { width: auto;}

.paging_full_numbers { width: 350px !important;}

#big_table_processing > img {padding-left:20px;}

.actions{ display:block; padding:3px; }

.actions a { margin-left:10px; margin-right: 10px; }

.ui-widget-header {

border: 1px solid #000000;

background: #428bc2;

color: #000000;

font-weight: bold;

}

.required

{

color: #FF0000;

font-size: 10px;

}

.error

{

color: #FF0000;

font-size: 10px;

}

Log-in

To use this system user must log-in first.

Source: http://www.iluv2code.com/login-with-codeigniter-php.html

 

login_view.php (View)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Login Form</title>

<!--link the bootstrap css file-->

<link rel="stylesheet" href="/../assets/css/bootstrap.min.css">

<style type="text/css">

.colbox {

margin-left: 0px;

margin-right: 0px;

}

</style>

</head>

<body>

<div class="container">

<div class="row">

<div class="col-lg-6 col-sm-6">

<h1>BEANACO LOGIN</h1>

</div>

</div>

</div>

<hr/>

<div class="container">

<div class="row">

<div class="col-lg-4 col-sm-4 well">

<?php

$attributes = array("class" => "form-horizontal", "id" => "loginform", "name" => "loginform");

echo form_open("verifylogin", $attributes);?>

<?php echo validation_errors(); ?>

<fieldset>

<legend>Login</legend>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="username" class="control-label">Username:</label>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" type="text" size="20" id="username" name="username"/>

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="password" class="control-label">Password:</label>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" type="password" size="20" id="passowrd" name="password"/>

</div>

</div>

</div>

<div class="form-group">

<div class="col-lg-12 col-sm-12 text-center">

<input type="submit" class="btn btn-default" value="Login"/>

</div>

</div>

</fieldset>

</form>

<script type="text/javascript" src="/../MVC/assets/js/jquery-1.11.2.js"></script>

<script type="text/javascript" src="/../MVC/assets/js/bootstrap.js""></script>

</body>

</html>

login.php (Controller)

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Login extends CI_Controller {

function __construct()

{

parent::__construct();

}

function index()

{

$this->load->helper('form');

$this->load->view('login_view');

}

}

?>

user.php (Model)

<?php

Class User extends CI_Model

{

function login($username, $password)

{

$this -> db -> select('id, username, password');

$this -> db -> from('mvc_users');

$this -> db -> where('username = ' . "'" . $username . "'");

$this -> db -> where('password = ' . "'" . MD5($password) . "'");

$this -> db -> limit(1);

$query = $this -> db -> get();

if($query -> num_rows() == 1)

{

return $query->result();

}

else

{

return false;

}

}

}

?>

verifylogin.php (Controller)

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class VerifyLogin extends CI_Controller {

function __construct()

{

parent::__construct();

$this->load->model('user','',TRUE);

}

function index()

{

//This method will have the credentials validation

$this->load->library('form_validation');

$this->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean');

$this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean|callback_check_database');

if($this->form_validation->run() == FALSE)

{

//Field validation failed. User redirected to login page

$this->load->view('login_view');

}

else

{

//Go to private area

redirect('home', 'refresh');

}

}

function check_database($password)

{

//Field validation succeeded. Validate against database

$username = $this->input->post('username');

//query the database

$result = $this->user->login($username, $password);

if($result)

{

$sess_array = array();

foreach($result as $row)

{

$sess_array = array(

'id' => $row->id,

'username' => $row->username

);

$this->session->set_userdata('logged_in', $sess_array);

}

return TRUE;

}

else

{

$this->form_validation->set_message('check_database', 'Invalid username or password');

return false;

}

}

}

?>

Validation

All Controllers check the $session_data and in user not logged_in they will redirect to login page.

if($this->session->userdata('logged_in'))

{

$session_data = $this->session->userdata('logged_in');

$data['username'] = $session_data['username'];

………………………

}

else

{

//If no session, redirect to login page

redirect('login', 'refresh');

}

Vans

URL: http://www.frankofamily.info/UniOfSunderland/Level2/Multimedia/Project4/MVC/index.php/home

To display vans I have chosen Datatables frameworks. It is a java framework which is shows element in a table, with search, sorting and pagination functions.

User can add a new van to database or edit exist by pencil buttons.

When user click to van’s picture thumbnail a full size picture open. I have tried to add lightbox function to show large picture but the lightbox frameworks JavaScript was not compatible that JavaScript what I use for Datatable.

I also tried to use picture upload function on my project but it didn’t work on my university server account. It created the files in image folder but their size always was 0 and the owner was “120” not my user name. I spent a lot of hours to solve this problem but I couldn’t. Therefore user have to create a 600px wide jpg picture on van’s reg plate name end a 100px wide thumbnail picture on “thumb_” + reg plate name, and upload them to project assest/images folder.

Source:

http://www.ahmed-samy.com/php-codeigniter-full-featrued-jquery-datatables-part-1/

http://www.datatables.net/download/download

 

home_view.php (View)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Beanaco - Private Area</title>

<meta http-equiv="content-type" content="text/html;charset=UTF-8">

<!--link the bootstrap css file-->

<link rel="stylesheet" href="/../assets/css/bootstrap.min.css">

</head>

<body>

<div class="container">

<div class="row">

<div class="col-lg-4 col-sm-">

<h1>BEANACO ADMIN</h1>

</div>

<div class="col-lg-4 col-sm-4">

<ul class="nav nav-pills pull-right" style="margin-top:20px">

<li class="active"><a href="/home">Vans</a></li>

<li><a href="/drivers">Drivers</a></li>

<li><a href="/<?php echo base_url(); ?>/index.php/logs">Logs</a></li>

<li><a href="/<?php echo base_url(); ?>/index.php/services">Services</a></li>

</ul>

</div>

<div class="col-lg-4 col-sm-4">

<h2>Welcome <?php echo $username; ?>!</h2>

<a href="/home/logout">Logout</a>

</div>

</div>

</div>

<script type="text/javascript" src="/../assets/js/jquery-1.11.2.js"></script>

<script type="text/javascript" src="/../assets/js/bootstrap.js""></script>

</body>

</html>

 

home.php (Controller)

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

session_start(); //we need to call PHP's session object to access it through CI

class Home extends CI_Controller {

function __construct()

{

parent::__construct();

$this->load->library('Datatables');

$this->load->library('table');

$this->load->database();

}

function index()

{

if($this->session->userdata('logged_in'))

{

$session_data = $this->session->userdata('logged_in');

$data['username'] = $session_data['username'];

$this->load->view('home_view', $data);

//set table id in table open tag

$tmpl = array ( 'table_open' => '<table id="big_table" border="1" cellpadding="2" cellspacing="1" class="mytable">' );

$this->table->set_template($tmpl);

$this->table->set_heading('Reg plate','Type','Model', 'Fuel','State','Latitude loc','Longtitude loc','Picture','Actions');

$this->load->view('vans_view');

}

else

{

//If no session, redirect to login page

redirect('login', 'refresh');

}

}

function logout()

{

$this->session->unset_userdata('logged_in');

session_destroy();

redirect('home', 'refresh');

}

}

?>

vans_view.php (View)

<html>

<head>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<title>Vans list</title>

<meta http-equiv="content-type" content="text/html;charset=UTF-8">

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/ui-lightness/jquery-ui.css" type="text/css" media="screen"/>

<!--link the bootstrap css file-->

<link rel="stylesheet" href="/<?php echo base_url(); ?>assets/css/bootstrap.min.css">

<script type="text/javascript" src="/<?php echo base_url(); ?>assets/js/jquery.dataTables.min.js"></script>

</head>

<body>

<div class="wrapper">

<ul class="nav nav-pills pull-right" style="margin-top:20px">

<li class="active"><a href="/addvan">Add new van to list</a></li>

</ul>

<br/><br/>

</div>

<div class="wrapper">

<hr/>

<script type="text/javascript">

$(document).ready(function() {

var oTable = $('#big_table').dataTable( {

"bProcessing": true,

"bServerSide": true,

"sAjaxSource": '<?php echo base_url(); ?>index.php/vans/datatable',

"bJQueryUI": true,

"sPaginationType": "full_numbers",

"iDisplayStart ":20,

"bAutoWidth": false, // Disable the auto width calculation

"oLanguage": {

"sProcessing": "<img src='<?php echo base_url(); ?>assets/images/ajax-loader_dark.gif'>"

},

"fnInitComplete": function() {

//oTable.fnAdjustColumnSizing();

},

'fnServerData': function(sSource, aoData, fnCallback)

{

$.ajax

({

'dataType': 'json',

'type' : 'POST',

'url' : sSource,

'data' : aoData,

'success' : fnCallback

});

}

} );

} );

</script>

<h1>Vans list</h1>

<?php echo $this->table->generate(); ?>

</div>

</body>

<footer>

<label class="footer-label" >Created by <a href="http://www.frankotrade.info">Istvan Franko</a></label>

</footer>

</html>

vans.php (Controller)

<html>

<head>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<title>Vans list</title>

<meta http-equiv="content-type" content="text/html;charset=UTF-8">

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/ui-lightness/jquery-ui.css" type="text/css" media="screen"/>

<!--link the bootstrap css file-->

<link rel="stylesheet" href="/<?php echo base_url(); ?>assets/css/bootstrap.min.css">

<script type="text/javascript" src="/<?php echo base_url(); ?>assets/js/jquery.dataTables.min.js"></script>

</head>

<body>

<div class="wrapper">

<ul class="nav nav-pills pull-right" style="margin-top:20px">

<li class="active"><a href="/addvan">Add new van to list</a></li>

</ul>

<br/><br/>

</div>

<div class="wrapper">

<hr/>

<script type="text/javascript">

$(document).ready(function() {

var oTable = $('#big_table').dataTable( {

"bProcessing": true,

"bServerSide": true,

"sAjaxSource": '<?php echo base_url(); ?>index.php/vans/datatable',

"bJQueryUI": true,

"sPaginationType": "full_numbers",

"iDisplayStart ":20,

"bAutoWidth": false, // Disable the auto width calculation

"oLanguage": {

"sProcessing": "<img src='<?php echo base_url(); ?>assets/images/ajax-loader_dark.gif'>"

},

"fnInitComplete": function() {

//oTable.fnAdjustColumnSizing();

},

'fnServerData': function(sSource, aoData, fnCallback)

{

$.ajax

({

'dataType': 'json',

'type' : 'POST',

'url' : sSource,

'data' : aoData,

'success' : fnCallback

});

}

} );

} );

</script>

<h1>Vans list</h1>

<?php echo $this->table->generate(); ?>

</div>

</body>

<footer>

<label class="footer-label" >Created by <a href="http://www.frankotrade.info">Istvan Franko</a></label>

</footer>

</html>

datatables_help.php (Helper)

In this file have functions for buttons and get pictures.

<?php

//edit vans button function

function get_buttons($id)

{

$ci= & get_instance();

$html='<span class="actions">';

$html .='<a href="'. base_url().'index.php/editvan/updatevan/'.$id.'"><img src="'. base_url().'assets/images/edit.png"/></a>';

$html.='</span>';

return $html;

}

//get pictures function

function get_fullpic($id)

{

$ci= & get_instance();

$html='<span class="actions">';

$html .='<a href="'. base_url().'assets/images/' . $id . '.jpg"><img src="'. base_url().'assets/images/thumb_' . $id . '.jpg"/></a>';

$html.='</span>';

return $html;

}

//edit drivers button function

function get_driverbuttons($id)

{

$ci= & get_instance();

$html='<span class="actions">';

$html .='<a href="'. base_url().'index.php/editdriver/updatedriver/'.$id.'"><img src="'. base_url().'assets/images/edit.png"/></a>';

$html.='</span>';

return $html;

}

//edit logs button function

function get_logbuttons($id)

{

$ci= & get_instance();

$html='<span class="actions">';

$html .='<a href="'. base_url().'index.php/editlog/updatelog/'.$id.'"><img src="'. base_url().'assets/images/edit.png"/></a>';

$html.='</span>';

return $html;

}

//edit services button function

function get_servicebuttons($id)

{

$ci= & get_instance();

$html='<span class="actions">';

$html .='<a href="'. base_url().'index.php/editservice/updateservice/'.$id.'"><img src="'. base_url().'assets/images/edit.png"/></a>';

$html.='</span>';

return $html;

}

//callback function

function custom_notes($val)

{

$ci= & get_instance();

$str = substr($val, 0, 20);

//$str = gettype($val) . " " . strlen($val);

return $str;

}

Add van

 

vAddVan_view.php (View)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Beanaco - Private Area</title>

<meta http-equiv="content-type" content="text/html;charset=UTF-8">

<!--link the bootstrap css file-->

<link rel="stylesheet" href="/../assets/css/bootstrap.min.css">

</head>

<body>

<hr/>

<div class="container">

<div class="row">

<div class="col-lg-6 col-sm-6 well">

<?php // Change the css classes to suit your needs

$attributes = array("class" => "form-horizontal", "id" => "addvan", "name" => "Add van form");

echo form_open('addvan', $attributes); ?>

<fieldset>

<legend>Add new van</legend>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="reg_plate" class="control-label">Reg plate:<span class="required">*</span></label>

<?php echo form_error('reg_plate'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" size="20" id="reg_plate" type="text" name="reg_plate" maxlength="10" value="<?php echo set_value('reg_plate'); ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="type" class="control-label">Type:<span class="required">*</span></label>

<?php echo form_error('type'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" size="20" id="type" type="text" name="type" maxlength="100" value="<?php echo set_value('type'); ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="model" class="control-label">Model <span class="required">*</span></label>

<?php echo form_error('model'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" size="20" id="model" type="text" name="model" maxlength="100" value="<?php echo set_value('model'); ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="fuel" class="control-label">Fuel <span class="required">*</span></label>

<?php echo form_error('fuel'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" size="30" id="fuel" type="text" name="fuel" maxlength="10" value="<?php echo set_value('fuel'); ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="state" class="control-label">State <span class="required">*</span></label>

<?php echo form_error('state'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<?php // Change the values in this array to populate your dropdown as required ?>

<?php $options = array(

'On Road' => 'On Road',

'Off Road' => 'Off Road',

'Sold' => 'Sold'

); ?>

<?php echo form_dropdown('state', $options, set_value('state'))?>

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="location_lati" class="control-label">Location lati <span class="required">*</span></label>

<?php echo form_error('location_lati'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" id="location_lati" type="text" name="location_lati" maxlength="50" value="<?php echo set_value('location_lati'); ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="location_long" class="control-label">Location long <span class="required">*</span></label>

<?php echo form_error('location_long'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" id="location_long" type="text" name="location_long" maxlength="50" value="<?php echo set_value('location_long'); ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="col-lg-12 col-sm-12 text-center">

<input type="submit" class="btn btn-default" value="Submit"/>

<?php //echo form_submit( 'submit', 'Submit'); ?>

</div>

</div>

</fieldset>

</form>

<script type="text/javascript" src="/../assets/js/jquery-1.11.2.js"></script>

<script type="text/javascript" src="/../assets/js/bootstrap.js""></script>

</body>

</html>

addvan.php (Controller)

<?php

class Addvan extends CI_Controller {

function __construct()

{

parent::__construct();

$this->load->library('form_validation');

$this->load->database();

$this->load->helper('form');

$this->load->helper('url');

$this->load->model('maddvan');

}

function index()

{

if($this->session->userdata('logged_in'))

{

$session_data = $this->session->userdata('logged_in');

$data['username'] = $session_data['username'];

$this->load->view('home_view', $data);

$this->form_validation->set_rules('reg_plate', 'Reg plate', 'required|max_length[10]');

$this->form_validation->set_rules('type', 'Type', 'required|max_length[100]');

$this->form_validation->set_rules('model', 'Model', 'required|max_length[100]');

$this->form_validation->set_rules('fuel', 'Fuel', 'required|max_length[10]');

//$this->form_validation->set_rules('mileage', 'Mileage', 'required');

$this->form_validation->set_rules('state', 'State', 'required|max_length[50]');

$this->form_validation->set_rules('location_lati', 'Location lati', 'required|max_length[50]');

$this->form_validation->set_rules('location_long', 'Location long', 'required|max_length[50]');

$this->form_validation->set_error_delimiters('<br /><span class="error">', '</span>');

if ($this->form_validation->run() == FALSE) // validation hasn't been passed

{

$this->load->view('vAddVan_view');

}

else // passed validation proceed to post success logic

{

// build array for the model

$form_data = array(

'reg_plate' => set_value('reg_plate'),

'type' => set_value('type'),

'model' => set_value('model'),

'fuel' => set_value('fuel'),

//'mileage' => set_value('mileage'),

'state' => set_value('state'),

'location_lati' => set_value('location_lati'),

'location_long' => set_value('location_long'),

);

// run insert model to write data to db

if ($this->maddvan->SaveForm($form_data) == TRUE) // the information has therefore been successfully saved in the db

{

redirect('home'); // or whatever logic needs to occur

}

else

{

echo 'An error occurred saving your information. Please try again later';

// Or whatever error handling is necessary

}

}

}

else

{

//If no session, redirect to login page

redirect('login', 'refresh');

}

}

function success()

{

echo 'this form has been successfully submitted with all validation being passed. All messages or logic here. Please note

sessions have not been used and would need to be added in to suit your app';

}

}

?>

maddvan.php (Model)

<?php

class maddvan extends CI_Model {

function __construct()

{

parent::__construct();

}

// --------------------------------------------------------------------

/**

* function SaveForm()

*

* insert form data

* @param $form_data - array

* @return Bool - TRUE or FALSE

*/

function SaveForm($form_data)

{

$this->db->insert('mvc_vans', $form_data);

if ($this->db->affected_rows() == '1')

{

return TRUE;

}

return FALSE;

}

}

?>

Edit van

 

vEditVan_view.php (View)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Beanaco - Private Area</title>

<meta http-equiv="content-type" content="text/html;charset=UTF-8">

<!--link the bootstrap css file-->

<link rel="stylesheet" href="/<?php echo base_url(); ?>assets/css/bootstrap.min.css">

</head>

<body>

<div class="container">

<div class="row">

<div class="col-lg-4 col-sm-">

<h1>BEANACO ADMIN</h1>

</div>

<div class="col-lg-4 col-sm-4">

<ul class="nav nav-pills pull-right" style="margin-top:20px">

<li class="active"><a href="/<?php echo base_url(); ?>/index.php/home">Vans</a></li>

<li><a href="/<?php echo base_url(); ?>/index.php/drivers">Drivers</a></li>

<li><a href="/<?php echo base_url(); ?>/index.php/logs">Logs</a></li>

<li><a href="/<?php echo base_url(); ?>/index.php/services">Services</a></li>

</ul>

</div>

<div class="col-lg-4 col-sm-4">

<h2>Welcome <?php echo $username; ?>!</h2>

<a href="/home/logout">Logout</a>

</div>

</div>

</div>

<hr/>

<div class="container">

<div class="row">

<div class="col-lg-6 col-sm-6 well">

<?php foreach($results as $row) { ?>

<?php echo form_open_multipart('editvan'); ?>

<fieldset>

<legend>Edit a van</legend>

<input type="hidden" name="vanID" value="<?php echo $row->vanID; ?>">

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="reg_plate" class="control-label">Reg plate:<span class="required">*</span></label>

<?php echo form_error('reg_plate'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" size="20" id="reg_plate" type="text" name="reg_plate" maxlength="10" value="<?php echo $row->reg_plate; ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="type" class="control-label">Type:<span class="required">*</span></label>

<?php echo form_error('type'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" size="20" id="type" type="text" name="type" maxlength="100" value="<?php echo $row->type; ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="model" class="control-label">Model <span class="required">*</span></label>

<?php echo form_error('model'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" size="20" id="model" type="text" name="model" maxlength="100" value="<?php echo $row->model; ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="fuel" class="control-label">Fuel <span class="required">*</span></label>

<?php echo form_error('fuel'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" size="30" id="fuel" type="text" name="fuel" maxlength="10" value="<?php echo $row->fuel; ?>" />

</div>

</div>

</div>

<!--

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="mileage" class="control-label">Mileage <span class="required">*</span></label>

<?php echo form_error('mileage'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" id="mileage" type="text" name="mileage" value="<?php echo $row->mileage; ?>" />

</div>

</div>

</div>-->

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="state" class="control-label">State <span class="required">*</span></label>

<?php echo form_error('state'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<?php // Change the values in this array to populate your dropdown as required ?>

<?php $options = array(

'On Road' => 'On Road',

'Off Road' => 'Off Road',

'Sold' => 'Sold'

);

$selected = $row ->state;

?>

<?php echo form_dropdown('state', $options, $selected)?>

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="location_lati" class="control-label">Location lati <span class="required">*</span></label>

<?php echo form_error('location_lati'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" id="location_lati" type="text" name="location_lati" maxlength="50" value="<?php echo $row->location_lati; ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="location_long" class="control-label">Location long <span class="required">*</span></label>

<?php echo form_error('location_long'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" id="location_long" type="text" name="location_long" maxlength="50" value="<?php echo $row->location_long; ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="col-lg-12 col-sm-12 text-center">

<input type="submit" class="btn btn-default" value="Submit"/>

<?php //echo form_submit( 'submit', 'Submit'); ?>

</div>

</div>

</fieldset>

</form>

<?php } ?>

<script type="text/javascript" src="/<?php echo base_url(); ?>assets/js/jquery-1.11.2.js"></script>

<script type="text/javascript" src="/<?php echo base_url(); ?>assets/js/bootstrap.js""></script>

</body>

</html>

editvan.php (Controller)

<?php

class Editvan extends CI_Controller {

function __construct()

{

parent::__construct();

$this->load->library('form_validation');

$this->load->database();

$this->load->helper('form');

$this->load->helper('url');

$this->load->model('meditvan');

}

function index()

{

if($this->session->userdata('logged_in'))

{

$session_data = $this->session->userdata('logged_in');

$data['username'] = $session_data['username'];

$this->load->view('home_view', $data);

$this->form_validation->set_rules('reg_plate', 'Reg plate', 'required|max_length[10]');

$this->form_validation->set_rules('type', 'Type', 'required|max_length[100]');

$this->form_validation->set_rules('model', 'Model', 'required|max_length[100]');

$this->form_validation->set_rules('fuel', 'Fuel', 'required|max_length[10]');

//$this->form_validation->set_rules('mileage', 'Mileage', 'required');

$this->form_validation->set_rules('state', 'State', 'required|max_length[50]');

$this->form_validation->set_rules('location_lati', 'Location lati', 'required|max_length[50]');

$this->form_validation->set_rules('location_long', 'Location long', 'required|max_length[50]');

$this->form_validation->set_error_delimiters('<br /><span class="error">', '</span>');

if ($this->form_validation->run() == FALSE) // validation hasn't been passed

{

$this->load->view('vEditVan_view', $data);

}

else // passed validation proceed to post success logic

{

// build array for the model

$id = $this->input->post('vanID');

$form_data = array(

'reg_plate' => set_value('reg_plate'),

'type' => set_value('type'),

'model' => set_value('model'),

'fuel' => set_value('fuel'),

//'mileage' => set_value('mileage'),

'state' => set_value('state'),

'location_lati' => set_value('location_lati'),

'location_long' => set_value('location_long')

);

// run insert model to write data to db

if ($this->meditvan->SaveForm($id, $form_data) == TRUE) // the information has therefore been successfully saved in the db

{

redirect('home'); // or whatever logic needs to occur

}

else

{

echo 'An error occurred saving your information. Please try again later';

// Or whatever error handling is necessary

}

}

}

else

{

//If no session, redirect to login page

redirect('login', 'refresh');

}

}

function success()

{

echo 'this form has been successfully submitted with all validation being passed. All messages or logic here. Please note

sessions have not been used and would need to be added in to suit your app';

}

public function updatevan($id = null) {

if($this->session->userdata('logged_in'))

{

$session_data = $this->session->userdata('logged_in');

$data['username'] = $session_data['username'];

//$this->load->view('drivers_view', $data);

if ( is_numeric($id) ) {

//Echo "this is edit";

$this->load->helper(array('form', 'url'));

$query = $this->db->query("select * from mvc_vans where vanID =" . $id);

$data['results'] = $query->result();

$this->load->view('vEditVan_view.php', $data);

//Load up the appropriate view

} else {

//echo "No ID provided for record in the URL.";

$this->load->model("meditvan");

$this->load->view('home_view.php');

}

}

else

{

//If no session, redirect to login page

redirect('login', 'refresh');

}

}

}

?>

meditvan.php (Model)

<?php

class meditvan extends CI_Model {

function __construct()

{

parent::__construct();

}

function SaveForm($id, $form_data)

{

$this->db->where('vanID', $id);

$this->db->update('mvc_vans', $form_data);

return TRUE;

}

}

?>

Drivers

 

drivers_view.php (View)

<html>

<head>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

<title>Beanaco - Drivers</title>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<meta http-equiv="content-type" content="text/html;charset=UTF-8">

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/ui-lightness/jquery-ui.css" type="text/css" media="screen"/>

<!--link the bootstrap css file-->

<link rel="stylesheet" href="/<?php echo base_url(); ?>assets/css/bootstrap.min.css">

<script type="text/javascript" src="/<?php echo base_url(); ?>assets/js/jquery.dataTables.min.js"></script>

</head>

<body>

<div class="container">

<div class="row">

<div class="col-lg-4 col-sm-">

<h1>BEANACO ADMIN</h1>

</div>

<div class="col-lg-4 col-sm-4">

<ul class="nav nav-pills pull-right" style="margin-top:20px">

<li><a href="/<?php echo base_url(); ?>/index.php/home">Vans</a></li>

<li class="active"><a href="/<?php echo base_url(); ?>/index.php/drivers">Drivers</a></li>

<li><a href="/<?php echo base_url(); ?>/index.php/logs">Logs</a></li>

<li><a href="/<?php echo base_url(); ?>/index.php/services">Services</a></li>

</ul>

</div>

<div class="col-lg-4 col-sm-4">

<h2>Welcome <?php echo $username; ?>!</h2>

<a href="/home/logout">Logout</a>

</div>

</div>

</div>

<div class="wrapper">

<ul class="nav nav-pills pull-right" style="margin-top:20px">

<li class="active"><a href="/adddriver">Add new driver to list</a></li>

</ul>

<br/><br/>

</div>

<div class="wrapper">

<hr/>

<script type="text/javascript">

$(document).ready(function() {

var oTable = $('#big_table').dataTable( {

"bProcessing": true,

"bServerSide": true,

"sAjaxSource": '<?php echo base_url(); ?>index.php/drivers/datatable',

"bJQueryUI": true,

"sPaginationType": "full_numbers",

"iDisplayStart ":20,

"oLanguage": {

"sProcessing": "<img src='<?php echo base_url(); ?>assets/images/ajax-loader_dark.gif'>"

},

"fnInitComplete": function() {

//oTable.fnAdjustColumnSizing();

},

'fnServerData': function(sSource, aoData, fnCallback)

{

$.ajax

({

'dataType': 'json',

'type' : 'POST',

'url' : sSource,

'data' : aoData,

'success' : fnCallback

});

}

} );

} );

</script>

<h1>Drivers list</h1>

<?php echo $this->table->generate(); ?>

</div>

</body>

<footer>

<label class="footer-label" >Created by <a href="http://www.frankotrade.info">Istvan Franko</a></label>

</footer>

</html>

drivers.php (Controller)

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

session_start(); //we need to call PHP's session object to access it through CI

class Drivers extends CI_Controller {

public function __construct() {

parent::__construct();

$this->load->library('Datatables');

$this->load->library('table');

$this->load->database();

}

function index()

{

if($this->session->userdata('logged_in'))

{

$session_data = $this->session->userdata('logged_in');

$data['username'] = $session_data['username'];

//$this->load->view('home_view', $data);

//set table id in table open tag

$tmpl = array ( 'table_open' => '<table id="big_table" border="1" cellpadding="2" cellspacing="1" class="mytable">' );

$this->table->set_template($tmpl);

$this->table->set_heading('Driver ID','Driver name','Driver Phone', 'Driving Licence Num','Driving Licence Exp','Actions');

$this->load->view('drivers_view', $data);

}

else

{

//If no session, redirect to login page

redirect('login', 'refresh');

}

}

//function to handle callbacks

function datatable()

{

$this->datatables->select('DriverID,DriverName,DriverPhone,DriverLicenceNum,DriverLicenceExp')

->add_column('Actions', get_driverbuttons('$1'),'DriverID')

->from('mvc_drivers');

echo $this->datatables->generate();

}

function edit($id)

{

//load some edit form

redirect('vans');

}

function delete($id)

{

//add some delete code

redirect('vans');

}

}

Add driver

 

vAddDriver_view.php (View)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Beanaco - Add Driver</title>

<meta http-equiv="content-type" content="text/html;charset=UTF-8">

<!--link the bootstrap css file-->

<link rel="stylesheet" href="/../assets/css/bootstrap.min.css">

</head>

<body>

<div class="container">

<div class="row">

<div class="col-lg-4 col-sm-">

<h1>BEANACO ADMIN</h1>

</div>

<div class="col-lg-4 col-sm-4">

<ul class="nav nav-pills pull-right" style="margin-top:20px">

<li><a href="/home">Vans</a></li>

<li class="active"><a href="/drivers">Drivers</a></li>

<li><a href="/<?php echo base_url(); ?>/index.php/logs">Logs</a></li>

<li><a href="/<?php echo base_url(); ?>/index.php/services">Services</a></li>

</ul>

</div>

<div class="col-lg-4 col-sm-4">

<h2>Welcome <?php echo $username; ?>!</h2>

<a href="/home/logout">Logout</a>

</div>

</div>

</div>

<hr/>

<div class="container">

<div class="row">

<div class="col-lg-6 col-sm-6 well">

<?php // Change the css classes to suit your needs

$attributes = array("class" => "form-horizontal", "id" => "adddriver", "name" => "Add driver form");

echo form_open('adddriver', $attributes); ?>

<fieldset>

<legend>Add new driver</legend>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-6 col-sm-6">

<label for="DriverName" class="control-label">Driver Name:<span class="required">*</span></label>

<?php echo form_error('DriverName'); ?>

</div>

<div class="col-lg-6 col-sm-6">

<input class="form-control" size="20" id="DriverName" type="text" name="DriverName" maxlength="100" value="<?php echo set_value('DriverName'); ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-6 col-sm-6">

<label for="DriverPhone" class="control-label">Driver Phone:<span class="required">*</span></label>

<?php echo form_error('DriverPhone'); ?>

</div>

<div class="col-lg-6 col-sm-6">

<input class="form-control" size="20" id="DriverPhone" type="text" name="DriverPhone" maxlength="30" value="<?php echo set_value('DriverPhone'); ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-6 col-sm-6">

<label for="DriverLicenceNum" class="control-label">Driver Licence Num:<span class="required">*</span></label>

<?php echo form_error('DriverLicenceNum'); ?>

</div>

<div class="col-lg-6 col-sm-6">

<input class="form-control" size="20" id="DriverLicenceNum" type="text" name="DriverLicenceNum" maxlength="16" value="<?php echo set_value('DriverLicenceNum'); ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-6 col-sm-6">

<label for="DriverLicenceExp" class="control-label">Driver Licence Exp: (YYYY-MM-DD)<span class="required">*</span></label>

<?php echo form_error('DriverLicenceExp'); ?>

</div>

<div class="col-lg-6 col-sm-6">

<input class="form-control" size="30" id="DriverLicenceExp" type="text" name="DriverLicenceExp" maxlength="20" value="<?php echo set_value('DriverLicenceExp'); ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="col-lg-12 col-sm-12 text-center">

<input type="submit" class="btn btn-default" value="Submit"/>

<?php //echo form_submit( 'submit', 'Submit'); ?>

</div>

</div>

</fieldset>

</form>

<script type="text/javascript" src="/../assets/js/jquery-1.11.2.js"></script>

<script type="text/javascript" src="/../assets/js/bootstrap.js""></script>

</body>

</html>

adddriver.php (Controller)

<?php

class Adddriver extends CI_Controller {

function __construct()

{

parent::__construct();

$this->load->library('form_validation');

$this->load->database();

$this->load->helper('form');

$this->load->helper('url');

$this->load->model('madddriver');

}

function index()

{

if($this->session->userdata('logged_in'))

{

$session_data = $this->session->userdata('logged_in');

$data['username'] = $session_data['username'];

//$this->load->view('home_view', $data);

$this->form_validation->set_rules('DriverName', 'Driver Name', 'required|max_length[100]');

$this->form_validation->set_rules('DriverPhone', 'Driver Phone', 'required|max_length[30]');

$this->form_validation->set_rules('DriverLicenceNum', 'Driver Licence Num', 'required|max_length[16]');

$this->form_validation->set_rules('DriverLicenceExp', 'Driver Licence Exp', 'required|max_length[20]');

$this->form_validation->set_error_delimiters('<br /><span class="error">', '</span>');

if ($this->form_validation->run() == FALSE) // validation hasn't been passed

{

$this->load->view('vAddDriver_view', $data);

}

else // passed validation proceed to post success logic

{

// build array for the model

$form_data = array(

'DriverName' => set_value('DriverName'),

'DriverPhone' => set_value('DriverPhone'),

'DriverLicenceNum' => set_value('DriverLicenceNum'),

'DriverLicenceExp' => set_value('DriverLicenceExp'),

);

// run insert model to write data to db

if ($this->madddriver->SaveForm($form_data) == TRUE) // the information has therefore been successfully saved in the db

{

redirect('drivers'); // or whatever logic needs to occur

}

else

{

echo 'An error occurred saving your information. Please try again later';

// Or whatever error handling is necessary

}

}

}

else

{

//If no session, redirect to login page

redirect('login', 'refresh');

}

}

function success()

{

echo 'this form has been successfully submitted with all validation being passed. All messages or logic here. Please note

sessions have not been used and would need to be added in to suit your app';

}

}

?>

madddriver.php (Model)

<?php

class madddriver extends CI_Model {

function __construct()

{

parent::__construct();

}

// --------------------------------------------------------------------

function SaveForm($form_data)

{

$this->db->insert('mvc_drivers', $form_data);

if ($this->db->affected_rows() == '1')

{

return TRUE;

}

return FALSE;

}

}

?>

Edit driver

 

vEditDriver_view.php (View)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Beanaco - Edit Driver</title>

<meta http-equiv="content-type" content="text/html;charset=UTF-8">

<!--link the bootstrap css file-->

<link rel="stylesheet" href="/<?php echo base_url(); ?>assets/css/bootstrap.min.css">

</head>

<body>

<div class="container">

<div class="row">

<div class="col-lg-4 col-sm-">

<h1>BEANACO ADMIN</h1>

</div>

<div class="col-lg-4 col-sm-4">

<ul class="nav nav-pills pull-right" style="margin-top:20px">

<li><a href="/home">Vans</a></li>

<li class="active"><a href="/<?php echo base_url(); ?>/index.php/drivers">Drivers</a></li>

<li><a href="/<?php echo base_url(); ?>/index.php/logs">Logs</a></li>

<li><a href="/<?php echo base_url(); ?>/index.php/services">Services</a></li>

</ul>

</div>

<div class="col-lg-4 col-sm-4">

<h2>Welcome <?php echo $username; ?>!</h2>

<a href="/home/logout">Logout</a>

</div>

</div>

</div>

<hr/>

<div class="container">

<div class="row">

<div class="col-lg-6 col-sm-6 well">

<?php foreach($results as $row) { ?>

<?php echo form_open_multipart('editdriver'); ?>

<fieldset>

<legend>Edit driver</legend>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="DriverName" class="control-label">Driver Name:<span class="required">*</span></label>

<?php echo form_error('DriverName'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" size="20" type="text" name="DriverName" value="<?php echo $row->DriverName; ?>" size="50" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="DriverPhone" class="control-label">Driver Phone:<span class="required">*</span></label>

<?php echo form_error('DriverPhone'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" size="20" type="text" name="DriverPhone" value="<?php echo $row->DriverPhone; ?>" size="50" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="DriverLicenceNum" class="control-label">Driver Licence Num: <span class="required">*</span></label>

<?php echo form_error('DriverLicenceNum'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" size="20" type="text" name="DriverLicenceNum" value="<?php echo $row->DriverLicenceNum; ?>" size="50" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="DriverLicenceExp" class="control-label">Driver Licence Exp: (YYYY-MM-DD) <span class="required">*</span></label>

<?php echo form_error('DriverLicenceExp'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" size="20" type="text" name="DriverLicenceExp" value="<?php echo $row->DriverLicenceExp; ?>" size="50" />

</div>

</div>

</div>

<input type="hidden" name="DriverID" value="<?php echo $row->DriverID; ?>" size="0" />

<div class="form-group">

<div class="col-lg-12 col-sm-12 text-center">

<input type="submit" value="Submit" />

</div>

</div>

</fieldset>

</form>

<?php } ?>

<script type="text/javascript" src="/<?php echo base_url(); ?>assets/js/jquery-1.11.2.js"></script>

<script type="text/javascript" src="/<?php echo base_url(); ?>assets/js/bootstrap.js""></script>

</body>

</html>

editdriver.php (Controller)

<?php

class Editdriver extends CI_Controller {

function __construct()

{

parent::__construct();

$this->load->library('form_validation');

$this->load->database();

$this->load->helper('form');

$this->load->helper('url');

$this->load->model('meditdriver');

}

function index()

{

if($this->session->userdata('logged_in'))

{

$session_data = $this->session->userdata('logged_in');

$data['username'] = $session_data['username'];

//$this->load->view('drivers_view', $data);

$this->form_validation->set_rules('DriverName', 'Driver Name', 'required|max_length[100]');

$this->form_validation->set_rules('DriverPhone', 'Driver Phone', 'required|max_length[30]');

$this->form_validation->set_rules('DriverLicenceNum', 'Driver Licence Num', 'required|max_length[50]');

$this->form_validation->set_rules('DriverLicenceExp', 'Driver Licence Exp', 'required|max_length[20]');

$this->form_validation->set_error_delimiters('<br /><span class="error">', '</span>');

if ($this->form_validation->run() == FALSE) // validation hasn't been passed

{

$this->load->view('vEditDriver_view', $data);

}

else // passed validation proceed to post success logic

{

// build array for the model

$id = $this->input->post('DriverID');

$form_data = array(

'DriverName' => set_value('DriverName'),

'DriverPhone' => set_value('DriverPhone'),

'DriverLicenceNum' => set_value('DriverLicenceNum'),

'DriverLicenceExp' => set_value('DriverLicenceExp'),

);

// run insert model to write data to db

if ($this->meditdriver->SaveForm($id, $form_data) == TRUE) // the information has therefore been successfully saved in the db

{

redirect('drivers'); // or whatever logic needs to occur

}

else

{

echo 'An error occurred saving your information. Please try again later';

// Or whatever error handling is necessary

}

}

}

else

{

//If no session, redirect to login page

redirect('login', 'refresh');

}

}

function success()

{

echo 'this form has been successfully submitted with all validation being passed. All messages or logic here. Please note

sessions have not been used and would need to be added in to suit your app';

}

public function updatedriver($id = null) {

if($this->session->userdata('logged_in'))

{

$session_data = $this->session->userdata('logged_in');

$data['username'] = $session_data['username'];

//$this->load->view('drivers_view', $data);

if ( is_numeric($id) ) {

//Echo "this is edit";

$this->load->helper(array('form', 'url'));

$query = $this->db->query("select * from mvc_drivers where DriverID =" . $id);

$data['results'] = $query->result();

$this->load->view('vEditDriver_view.php', $data);

//Load up the appropriate view

} else {

//echo "No ID provided for record in the URL.";

$this->load->model("meditdriver");

$this->load->view('drivers_view.php');

}

}

else

{

//If no session, redirect to login page

redirect('login', 'refresh');

}

}

}

?>

meditdriver.php (Model)

<?php

class meditdriver extends CI_Model {

function __construct()

{

parent::__construct();

}

function SaveForm($id, $form_data)

{

$this->db->where('DriverID', $id);

$this->db->update('mvc_drivers', $form_data);

return TRUE;

}

}

?>

Logs

This page shows registered details of vans and drivers days. There are a from number, a van’s registration plate, driver’s ID number, Time Out (when leave site), Time In (when come back), Mileage Start and Mileage and information.

Admin can edit these details or add new record to database.

Also there is a “Monthly mileage report” button what allow user to collect monthly miles from selected van.

 

logs_view.php (View)

<html>

<head>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

<title>Beanaco - Logs</title>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<meta http-equiv="content-type" content="text/html;charset=UTF-8">

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/ui-lightness/jquery-ui.css" type="text/css" media="screen"/>

<!--link the bootstrap css file-->

<link rel="stylesheet" href="/<?php echo base_url(); ?>assets/css/bootstrap.min.css">

<script type="text/javascript" src="/<?php echo base_url(); ?>assets/js/jquery.dataTables.min.js"></script>

</head>

<body>

<div class="container">

<div class="row">

<div class="col-lg-4 col-sm-">

<h1>BEANACO ADMIN</h1>

</div>

<div class="col-lg-4 col-sm-4">

<ul class="nav nav-pills pull-right" style="margin-top:20px">

<li><a href="/<?php echo base_url(); ?>/index.php/home">Vans</a></li>

<li><a href="/<?php echo base_url(); ?>/index.php/drivers">Drivers</a></li>

<li class="active"><a href="/<?php echo base_url(); ?>/index.php/logs">Logs</a></li>

<li><a href="/<?php echo base_url(); ?>/index.php/services">Services</a></li>

</ul>

</div>

<div class="col-lg-4 col-sm-4">

<h2>Welcome <?php echo $username; ?>!</h2>

<a href="/home/logout">Logout</a>

</div>

</div>

</div>

<div class="wrapper">

<ul class="nav nav-pills pull-right" style="margin-top:20px">

<li class="active"><a href="/addlog">Add new log to list</a></li>

<li class="active"><a href="/mileage">Monthly mileage report</a></li>

</ul>

<br/><br/>

</div>

<div class="wrapper">

<hr/>

<script type="text/javascript">

$(document).ready(function() {

var oTable = $('#big_table').dataTable( {

"bProcessing": true,

"bServerSide": true,

"sAjaxSource": '<?php echo base_url(); ?>index.php/logs/datatable',

"bJQueryUI": true,

"sPaginationType": "full_numbers",

"iDisplayStart ":20,

"bAutoWidth": false, // Disable the auto width calculation

"oLanguage": {

"sProcessing": "<img src='<?php echo base_url(); ?>assets/images/ajax-loader_dark.gif'>"

},

"fnInitComplete": function() {

//oTable.fnAdjustColumnSizing();

},

'fnServerData': function(sSource, aoData, fnCallback)

{

$.ajax

({

'dataType': 'json',

'type' : 'POST',

'url' : sSource,

'data' : aoData,

'success' : fnCallback

});

}

} );

} );

</script>

<h1>Logs list</h1>

<?php echo $this->table->generate(); ?>

</div>

</body>

<footer>

<label class="footer-label" >Created by <a href="http://www.frankotrade.info">Istvan Franko</a></label>

</footer>

</html>

logs.php (Controller)

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

session_start(); //we need to call PHP's session object to access it through CI

class Logs extends CI_Controller {

public function __construct() {

parent::__construct();

$this->load->library('Datatables');

$this->load->library('table');

$this->load->database();

}

function index()

{

if($this->session->userdata('logged_in'))

{

$session_data = $this->session->userdata('logged_in');

$data['username'] = $session_data['username'];

//$this->load->view('home_view', $data);

//set table id in table open tag

$tmpl = array ( 'table_open' => '<table id="big_table" border="1" cellpadding="2" cellspacing="1" class="mytable">' );

$this->table->set_template($tmpl);

$this->table->set_heading('Form Number','Reg Plate','Driver ID', 'Time Out','Time In','Mileage Start','Mileage End','Actions');

$this->load->view('logs_view', $data);

}

else

{

//If no session, redirect to login page

redirect('login', 'refresh');

}

}

//function to handle callbacks

function datatable()

{

$this->datatables->select('logID,form_number,reg_plate,driver_id,time_out,time_in,mileage_start,mileage_end')

->unset_column('logID')

->add_column('Actions', get_logbuttons('$1'),'logID')

->from('mvc_logs');

echo $this->datatables->generate();

}

}

Add log

 

vAddLog_view.php (View)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Beanaco - Add Log</title>

<meta http-equiv="content-type" content="text/html;charset=UTF-8">

<!--link the bootstrap css file-->

<link rel="stylesheet" href="/<?php echo base_url(); ?>assets/css/bootstrap.min.css">

</head>

<body>

<div class="container">

<div class="row">

<div class="col-lg-4 col-sm-">

<h1>BEANACO ADMIN</h1>

</div>

<div class="col-lg-4 col-sm-4">

<ul class="nav nav-pills pull-right" style="margin-top:20px">

<li><a href="/home">Vans</a></li>

<li><a href="/drivers">Drivers</a></li>

<li class="active"><a href="/<?php echo base_url(); ?>/index.php/logs">Logs</a></li>

<li><a href="/<?php echo base_url(); ?>/index.php/services">Services</a></li>

</ul>

</div>

<div class="col-lg-4 col-sm-4">

<h2>Welcome <?php echo $username; ?>!</h2>

<a href="/home/logout">Logout</a>

</div>

</div>

</div>

<hr/>

<div class="container">

<div class="row">

<div class="col-lg-6 col-sm-6 well">

<?php // Change the css classes to suit your needs

$attributes = array("class" => "form-horizontal", "id" => "addlog", "name" => "Add log form");

echo form_open('addlog', $attributes); ?>

<fieldset>

<legend>Add new log</legend>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-6 col-sm-6">

<label for="form_number" class="control-label">Form Number:<span class="required">*</span></label>

<?php echo form_error('form_number'); ?>

</div>

<div class="col-lg-6 col-sm-6">

<input class="form-control" size="20" id="form_number" type="text" name="form_number" maxlength="100" value="<?php echo set_value('form_number'); ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-6 col-sm-6">

<label for="reg_plate" class="control-label">Reg Plate:<span class="required">*</span></label>

<?php echo form_error('reg_plate'); ?>

</div>

<div class="col-lg-6 col-sm-6">

<input class="form-control" size="20" id="reg_plate" type="text" name="reg_plate" maxlength="30" value="<?php echo set_value('reg_plate'); ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-6 col-sm-6">

<label for="driver_id" class="control-label">Driver ID:<span class="required">*</span></label>

<?php echo form_error('driver_id'); ?>

</div>

<div class="col-lg-6 col-sm-6">

<input class="form-control" size="20" id="driver_id" type="text" name="driver_id" maxlength="50" value="<?php echo set_value('driver_id'); ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-6 col-sm-6">

<label for="time_out" class="control-label">Time Out: (YYYY/MM/DD HH:MM)<span class="required">*</span></label>

<?php echo form_error('time_out'); ?>

</div>

<div class="col-lg-6 col-sm-6">

<input class="form-control" size="20" id="time_out" type="text" name="time_out" maxlength="50" value="<?php echo set_value('time_out'); ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-6 col-sm-6">

<label for="time_in" class="control-label">Time In: (YYYY/MM/DD HH:MM) <span class="required">*</span></label>

<?php echo form_error('time_in'); ?>

</div>

<div class="col-lg-6 col-sm-6">

<input class="form-control" size="20" id="time_in" type="text" name="time_in" maxlength="50" value="<?php echo set_value('time_in'); ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-6 col-sm-6">

<label for="mileage_start" class="control-label">Mileage Start:<span class="required">*</span></label>

<?php echo form_error('mileage_start'); ?>

</div>

<div class="col-lg-6 col-sm-6">

<input class="form-control" size="20" id="mileage_start" type="text" name="mileage_start" maxlength="50" value="<?php echo set_value('mileage_start'); ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-6 col-sm-6">

<label for="mileage_end" class="control-label">Mileage End:<span class="required">*</span></label>

<?php echo form_error('mileage_end'); ?>

</div>

<div class="col-lg-6 col-sm-6">

<input class="form-control" size="20" id="mileage_end" type="text" name="mileage_end" maxlength="50" value="<?php echo set_value('mileage_end'); ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="col-lg-12 col-sm-12 text-center">

<input type="submit" class="btn btn-default" value="Submit"/>

<?php //echo form_submit( 'submit', 'Submit'); ?>

</div>

</div>

</fieldset>

</form>

<script type="text/javascript" src="/../assets/js/jquery-1.11.2.js"></script>

<script type="text/javascript" src="/../assets/js/bootstrap.js""></script>

</body>

</html>

addlog.php (Controller)

<?php

class Addlog extends CI_Controller {

function __construct()

{

parent::__construct();

$this->load->library('form_validation');

$this->load->database();

$this->load->helper('form');

$this->load->helper('url');

$this->load->model('maddlog');

}

function index()

{

if($this->session->userdata('logged_in'))

{

$session_data = $this->session->userdata('logged_in');

$data['username'] = $session_data['username'];

//$this->load->view('home_view', $data);

$this->form_validation->set_rules('form_number', 'Log Number', 'required|max_length[11]');

$this->form_validation->set_rules('reg_plate', 'Reg Plate', 'required|max_length[11]');

$this->form_validation->set_rules('driver_id', 'Driver ID', 'required|max_length[20]');

$this->form_validation->set_rules('time_out', 'Time Out', 'required|max_length[30]');

$this->form_validation->set_rules('time_in', 'Time In', 'required|max_length[30]');

$this->form_validation->set_rules('mileage_start', 'Mileage Start', 'required|max_length[11]');

$this->form_validation->set_rules('mileage_end', 'Mileage End', 'required|max_length[11]');

$this->form_validation->set_error_delimiters('<br /><span class="error">', '</span>');

if ($this->form_validation->run() == FALSE) // validation hasn't been passed

{

$this->load->view('vAddLog_view', $data);

}

else // passed validation proceed to post success logic

{

// build array for the model

$form_data = array(

'form_number' => set_value('form_number'),

'reg_plate' => set_value('reg_plate'),

'driver_id' => set_value('driver_id'),

'time_out' => set_value('time_out'),

'time_in' => set_value('time_in'),

'mileage_start' => set_value('mileage_start'),

'mileage_end' => set_value('mileage_end'),

);

// run insert model to write data to db

if ($this->maddlog->SaveForm($form_data) == TRUE) // the information has therefore been successfully saved in the db

{

redirect('logs'); // or whatever logic needs to occur

}

else

{

echo 'An error occurred saving your information. Please try again later';

// Or whatever error handling is necessary

}

}

}

else

{

//If no session, redirect to login page

redirect('login', 'refresh');

}

}

function success()

{

echo 'this form has been successfully submitted with all validation being passed. All messages or logic here. Please note

sessions have not been used and would need to be added in to suit your app';

}

}

?>

maddlog.php (Model)

<?php

class maddlog extends CI_Model {

function __construct()

{

parent::__construct();

}

function SaveForm($form_data)

{

$this->db->insert('mvc_logs', $form_data);

if ($this->db->affected_rows() == '1')

{

return TRUE;

}

return FALSE;

}

}

?>

Edit Log

 

vEditLog_view.php (View)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Beanaco - Edit Log</title>

<meta http-equiv="content-type" content="text/html;charset=UTF-8">

<!--link the bootstrap css file-->

<link rel="stylesheet" href="/<?php echo base_url(); ?>assets/css/bootstrap.min.css">

</head>

<body>

<div class="container">

<div class="row">

<div class="col-lg-4 col-sm-">

<h1>BEANACO ADMIN</h1>

</div>

<div class="col-lg-4 col-sm-4">

<ul class="nav nav-pills pull-right" style="margin-top:20px">

<li><a href="/home">Vans</a></li>

<li><a href="/<?php echo base_url(); ?>/index.php/drivers">Drivers</a></li>

<li class="active"><a href="/<?php echo base_url(); ?>/index.php/logs">Logs</a></li>

<li><a href="/<?php echo base_url(); ?>/index.php/services">Services</a></li>

</ul>

</div>

<div class="col-lg-4 col-sm-4">

<h2>Welcome <?php echo $username; ?>!</h2>

<a href="/home/logout">Logout</a>

</div>

</div>

</div>

<hr/>

<div class="container">

<div class="row">

<div class="col-lg-6 col-sm-6 well">

<?php foreach($results as $row) { ?>

<?php echo form_open_multipart('editlog'); ?>

<fieldset>

<legend>Edit log</legend>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="form_number" class="control-label">Form Number:<span class="required">*</span></label>

<?php echo form_error('form_number'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" size="20" id="form_number" type="text" name="form_number" maxlength="11" value="<?php echo $row->form_number; ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="reg_plate" class="control-label">Reg Plate:<span class="required">*</span></label>

<?php echo form_error('reg_plate'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" size="20" id="reg_plate" type="text" name="reg_plate" maxlength="10" value="<?php echo $row->reg_plate; ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="driver_id" class="control-label">Driver ID:<span class="required">*</span></label>

<?php echo form_error('driver_id'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" size="20" id="driver_id" type="text" name="driver_id" maxlength="20" value="<?php echo $row->driver_id; ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="time_out" class="control-label">Time Out:<span class="required">*</span></label>

<?php echo form_error('time_out'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" size="20" id="time_out" type="text" name="time_out" maxlength="20" value="<?php echo $row->time_out; ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="time_in" class="control-label">Time In:<span class="required">*</span></label>

<?php echo form_error('time_in'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" size="20" id="time_in" type="text" name="time_in" maxlength="20" value="<?php echo $row->time_in; ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="mileage_start" class="control-label">Mileage Start:<span class="required">*</span></label>

<?php echo form_error('mileage_start'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" size="20" id="mileage_start" type="text" name="mileage_start" maxlength="11" value="<?php echo $row->mileage_start; ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="mileage_end" class="control-label">Mileage End:<span class="required">*</span></label>

<?php echo form_error('mileage_end'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" size="20" id="mileage_end" type="text" name="mileage_end" maxlength="11" value="<?php echo $row->mileage_end; ?>" />

</div>

</div>

</div>

<input type="hidden" name="logID" value="<?php echo $row->logID; ?>" size="0" />

<div class="form-group">

<div class="col-lg-12 col-sm-12 text-center">

<input type="submit" class="btn btn-default" value="Submit"/>

<?php //echo form_submit( 'submit', 'Submit'); ?>

</div>

</div>

</fieldset>

</form>

<?php } ?>

<script type="text/javascript" src="/<?php echo base_url(); ?>assets/js/jquery-1.11.2.js"></script>

<script type="text/javascript" src="/<?php echo base_url(); ?>assets/js/bootstrap.js""></script>

</body>

</html>

editlog.php (Controller)

<?php

class Editlog extends CI_Controller {

function __construct()

{

parent::__construct();

$this->load->library('form_validation');

$this->load->database();

$this->load->helper('form');

$this->load->helper('url');

$this->load->model('meditlog');

}

function index()

{

if($this->session->userdata('logged_in'))

{

$session_data = $this->session->userdata('logged_in');

$data['username'] = $session_data['username'];

//$this->load->view('drivers_view', $data);

$this->form_validation->set_rules('form_number', 'Log Number', 'required|max_length[11]');

$this->form_validation->set_rules('reg_plate', 'Reg Plate', 'required|max_length[11]');

$this->form_validation->set_rules('driver_id', 'Driver ID', 'required|max_length[20]');

$this->form_validation->set_rules('time_out', 'Time Out', 'required|max_length[30]');

$this->form_validation->set_rules('time_in', 'Time In', 'required|max_length[30]');

$this->form_validation->set_rules('mileage_start', 'Mileage Start', 'required|max_length[11]');

$this->form_validation->set_rules('mileage_end', 'Mileage End', 'required|max_length[11]');

$this->form_validation->set_error_delimiters('<br /><span class="error">', '</span>');

if ($this->form_validation->run() == FALSE) // validation hasn't been passed

{

$this->load->view('vEditLog_view', $data);

}

else // passed validation proceed to post success logic

{

// build array for the model

$id = $this->input->post('logID');

$form_data = array(

'form_number' => set_value('form_number'),

'reg_plate' => set_value('reg_plate'),

'driver_id' => set_value('driver_id'),

'time_out' => set_value('time_out'),

'time_in' => set_value('time_in'),

'mileage_start' => set_value('mileage_start'),

'mileage_end' => set_value('mileage_end'),

);

// run insert model to write data to db

if ($this->meditlog->SaveForm($id, $form_data) == TRUE) // the information has therefore been successfully saved in the db

{

redirect('logs'); // or whatever logic needs to occur

}

else

{

echo 'An error occurred saving your information. Please try again later';

// Or whatever error handling is necessary

}

}

}

else

{

//If no session, redirect to login page

redirect('login', 'refresh');

}

}

function success()

{

echo 'this form has been successfully submitted with all validation being passed. All messages or logic here. Please note

sessions have not been used and would need to be added in to suit your app';

}

public function updatelog($id = null) {

if($this->session->userdata('logged_in'))

{

$session_data = $this->session->userdata('logged_in');

$data['username'] = $session_data['username'];

//$this->load->view('drivers_view', $data);

if ( is_numeric($id) ) {

//Echo "this is edit";

$this->load->helper(array('form', 'url'));

$query = $this->db->query("select * from mvc_logs where logID =" . $id);

$data['results'] = $query->result();

$this->load->view('vEditLog_view.php', $data);

//Load up the appropriate view

} else {

//echo "No ID provided for record in the URL.";

$this->load->model("meditlog");

$this->load->view('logs_view.php');

}

}

else

{

//If no session, redirect to login page

redirect('login', 'refresh');

}

}

}

?>

meditlog.php (Model)

<?php

class meditlog extends CI_Model {

function __construct()

{

parent::__construct();

}

function SaveForm($id, $form_data)

{

$this->db->where('logID', $id);

$this->db->update('mvc_logs', $form_data);

return TRUE;

}

}

?>

Monthly mileage report

When admin want to check a van’s monthly mileage, first have to fill a form with Reg Plate and the selected month (YYYY-MM).

 

If admin submit form details on next page get a table with selected van’s monthly mileage.

 

vMileageForm_view.php (view)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Beanaco - Private Area</title>

<meta http-equiv="content-type" content="text/html;charset=UTF-8">

<!--link the bootstrap css file-->

<link rel="stylesheet" href="/<?php echo base_url(); ?>assets/css/bootstrap.min.css">

</head>

<body>

<div class="container">

<div class="row">

<div class="col-lg-4 col-sm-">

<h1>BEANACO ADMIN</h1>

</div>

<div class="col-lg-4 col-sm-4">

<ul class="nav nav-pills pull-right" style="margin-top:20px">

<li><a href="/<?php echo base_url(); ?>/index.php/home">Vans</a></li>

<li><a href="/<?php echo base_url(); ?>/index.php/drivers">Drivers</a></li>

<li class="active"><a href="/<?php echo base_url(); ?>/index.php/logs">Logs</a></li>

<li><a href="/<?php echo base_url(); ?>/index.php/services">Services</a></li>

</ul>

</div>

<div class="col-lg-4 col-sm-4">

<h2>Welcome <?php echo $username; ?>!</h2>

<a href="/home/logout">Logout</a>

</div>

</div>

</div>

<hr/>

<div class="container">

<div class="row">

<div class="col-lg-6 col-sm-6 well">

<?php // Change the css classes to suit your needs

$attributes = array("class" => "form-horizontal", "id" => "mileage", "name" => "Mileage");

echo form_open('mileage', $attributes); ?>

<fieldset>

<legend>Monthly mileage form</legend>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-3 col-sm-3">

<label for="reg_plate" class="control-label">Reg Plate:<span class="required">*</span></label>

<?php echo form_error('reg_plate'); ?>

</div>

<div class="col-lg-6 col-sm-6">

<input class="form-control" size="15" id="reg_plate" type="text" name="reg_plate" maxlength="20" value="<?php echo set_value('reg_plate'); ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-5 col-sm-5">

<label for="selecteddate" class="control-label">Selected month (YYYY-MM)<span class="required">*</span></label>

<?php echo form_error('selecteddate'); ?>

</div>

<div class="col-lg-6 col-sm-6">

<input class="form-control" size="15" id="selecteddate" type="text" name="selecteddate" maxlength="20" value="<?php echo set_value('selecteddate'); ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="col-lg-12 col-sm-12 text-center">

<input type="submit" class="btn btn-default" value="Submit"/>

<?php //echo form_submit( 'submit', 'Submit'); ?>

</div>

</div>

</fieldset>

</form>

<script type="text/javascript" src="/<?php echo base_url(); ?>assets/js/jquery-1.11.2.js"></script>

<script type="text/javascript" src="/<?php echo base_url(); ?>assets/js/bootstrap.js""></script>

</body>

</html>

vMileage_view.php (view)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Beanaco - Private Area</title>

<meta http-equiv="content-type" content="text/html;charset=UTF-8">

<!--link the bootstrap css file-->

<link rel="stylesheet" href="/<?php echo base_url(); ?>assets/css/bootstrap.min.css">

</head>

<body>

<div class="container">

<div class="row">

<div class="col-lg-4 col-sm-4">

<h1>BEANACO ADMIN</h1>

</div>

<div class="col-lg-4 col-sm-4">

<ul class="nav nav-pills pull-right" style="margin-top:20px">

<li><a href="/<?php echo base_url(); ?>/index.php/home">Vans</a></li>

<li><a href="/<?php echo base_url(); ?>/index.php/drivers">Drivers</a></li>

<li class="active"><a href="/<?php echo base_url(); ?>/index.php/logs">Logs</a></li>

<li><a href="/<?php echo base_url(); ?>/index.php/services">Services</a></li>

</ul>

</div>

<div class="col-lg-4 col-sm-4">

<h2>Welcome <?php echo $username; ?>!</h2>

<a href="/home/logout">Logout</a>

</div>

</div>

</div>

<hr/>

<div class="container">

<div class="row">

<div class="col-lg-10 col-sm-10 well">

<h3>Monthly mileage</h3>

<table class="table table-striped table-bordered">

<thead>

<tr><td>Reg plate</td>

<td>Date</td>

<td>Start</td>

<td>End</td>

<td>Miles</td>

</tr>

</thead>

<tbody>

<?php

$monthly_mileage = 0;

foreach($results as $row) {

$miles = $row->mileage_end - $row->mileage_start;

$monthly_mileage = $monthly_mileage + $miles;

echo "<tr><td>";

echo $row->reg_plate;

echo "</td>";

echo "<td>";

echo $row->time_out;

echo "</td>";

echo "<td>";

echo $row->mileage_start;

echo "</td>";

echo "<td>";

echo $row->mileage_end;

echo "</td>";

echo "<td>";

echo $miles;

echo "</td>";

echo "</tr>";

}

?>

<tr></tr>

<tr><td width="%40">Monthly mileage:</td><td width="%40"><?php echo $monthly_mileage ?></td></tr>

</tbody>

</table>

</div>

</div>

<script type="text/javascript" src="/<?php echo base_url(); ?>assets/js/jquery-1.11.2.js"></script>

<script type="text/javascript" src="/<?php echo base_url(); ?>assets/js/bootstrap.js"></script>

</body>

</html>

mileage.php (Controller)

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Mileage extends CI_Controller {

function __construct()

{

parent::__construct();

$this->load->library('form_validation');

$this->load->database();

$this->load->helper('form');

$this->load->helper('url');

$this->load->model('mmileage');

}

public function index()

{

if($this->session->userdata('logged_in'))

{

$session_data = $this->session->userdata('logged_in');

$data['username'] = $session_data['username'];

$this->form_validation->set_rules('reg_plate', 'Reg Plate', 'required|max_length[11]');

$this->form_validation->set_rules('selecteddate', 'Selected date', 'required|max_length[11]');

$this->form_validation->set_error_delimiters('<br /><span class="error">', '</span>');

if ($this->form_validation->run() == FALSE) // validation hasn't been passed

{

$this->load->view('vMileageForm_view', $data);

}

else // passed validation proceed to post success logic

{

// build array for the model

$form_data = array(

'reg_plate' => set_value('reg_plate'),

'time_out' => set_value('selecteddate')

);

//Call the function getAllSelectedVan() from the model

$data['results'] = $this->mmileage->getAllSelectedVan($form_data);

//Load the view and pass the $data array to it

$this->load->view("vMileage_view.php", $data);

}

}

else

{

//If no session, redirect to login page

redirect('login', 'refresh');

}

}

}

?>

mmileage.php (Model)

<?php

class mmileage extends CI_Model{

public function getAllSelectedVan($form_data) {

//use functions in the library class

$this->db->from('mvc_logs');

$this->db->like($form_data);

$query = $this->db->get();

return $query->result();

}

}

?>

Service history

On this page are displayed van’s services. Admin allow to add or edit details and add notes to records. On this page also displayed estimated “Revision” if van reached next mileage stage and MOT’s date when need to renew annual check.

 

services_view.php (View)

<html>

<head>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

<title>Beanaco - Logs</title>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<meta http-equiv="content-type" content="text/html;charset=UTF-8">

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/ui-lightness/jquery-ui.css" type="text/css" media="screen"/>

<!--link the bootstrap css file-->

<link rel="stylesheet" href="/<?php echo base_url(); ?>assets/css/bootstrap.min.css">

<script type="text/javascript" src="/<?php echo base_url(); ?>assets/js/jquery.dataTables.min.js"></script>

</head>

<body>

<div class="container">

<div class="row">

<div class="col-lg-4 col-sm-">

<h1>BEANACO ADMIN</h1>

</div>

<div class="col-lg-4 col-sm-4">

<ul class="nav nav-pills pull-right" style="margin-top:20px">

<li><a href="/<?php echo base_url(); ?>/index.php/home">Vans</a></li>

<li><a href="/<?php echo base_url(); ?>/index.php/drivers">Drivers</a></li>

<li><a href="/<?php echo base_url(); ?>/index.php/logs">Logs</a></li>

<li class="active"><a href="/<?php echo base_url(); ?>/index.php/services">Services</a></li>

</ul>

</div>

<div class="col-lg-4 col-sm-4">

<h2>Welcome <?php echo $username; ?>!</h2>

<a href="/home/logout">Logout</a>

</div>

</div>

</div>

<div class="wrapper">

<ul class="nav nav-pills pull-right" style="margin-top:20px">

<li class="active"><a href="/addservice">Add new service to list</a></li>

</ul>

<br/><br/>

</div>

<div class="wrapper">

<hr/>

<script type="text/javascript">

$(document).ready(function() {

var oTable = $('#big_table').dataTable( {

"bProcessing": true,

"bServerSide": true,

"sAjaxSource": '<?php echo base_url(); ?>index.php/services/datatable',

"bJQueryUI": true,

"sPaginationType": "full_numbers",

"iDisplayStart ":20,

"bAutoWidth": false, // Disable the auto width calculation

"oLanguage": {

"sProcessing": "<img src='<?php echo base_url(); ?>assets/images/ajax-loader_dark.gif'>"

},

"fnInitComplete": function() {

//oTable.fnAdjustColumnSizing();

},

'fnServerData': function(sSource, aoData, fnCallback)

{

$.ajax

({

'dataType': 'json',

'type' : 'POST',

'url' : sSource,

'data' : aoData,

'success' : fnCallback

});

}

} );

} );

</script>

<h1>Services list</h1>

<?php echo $this->table->generate(); ?>

</div>

</body>

<footer>

<label class="footer-label" >Created by <a href="http://www.frankotrade.info">Istvan Franko</a></label>

</footer>

</html>

services.php (Controller)

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

session_start(); //we need to call PHP's session object to access it through CI

class Services extends CI_Controller {

public function __construct() {

parent::__construct();

$this->load->library('Datatables2');

$this->load->library('table');

$this->load->database();

}

function index()

{

if($this->session->userdata('logged_in'))

{

$session_data = $this->session->userdata('logged_in');

$data['username'] = $session_data['username'];

//set table id in table open tag

$tmpl = array ( 'table_open' => '<table id="big_table" border="1" cellpadding="2" cellspacing="1" class="mytable">' );

$this->table->set_template($tmpl);

$this->table->set_heading('Worksheet Num','Reg Plate','Date','Miles','Event','Notes','Actions');

$this->load->view('services_view', $data);

}

else

{

//If no session, redirect to login page

redirect('login', 'refresh');

}

}

//function to handle callbacks

function datatable()

{

$this->load->library('Datatables');

$this->datatables->select('serviceID,worksheet_num,reg_plate,date,miles,event,notes')

->from('mvc_services')

->unset_column('serviceID')

->edit_column('notes', custom_notes('$1'), 'notes') // custom functions

->add_column('Actions', get_servicebuttons('$1'),'serviceID');

echo $this->datatables->generate();

}

}

Add service

 

vAddService_view.php (View)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Beanaco - Add Log</title>

<meta http-equiv="content-type" content="text/html;charset=UTF-8">

<!--link the bootstrap css file-->

<link rel="stylesheet" href="/<?php echo base_url(); ?>assets/css/bootstrap.min.css">

</head>

<body>

<div class="container">

<div class="row">

<div class="col-lg-4 col-sm-">

<h1>BEANACO ADMIN</h1>

</div>

<div class="col-lg-4 col-sm-4">

<ul class="nav nav-pills pull-right" style="margin-top:20px">

<li><a href="/home">Vans</a></li>

<li><a href="/drivers">Drivers</a></li>

<li><a href="/<?php echo base_url(); ?>/index.php/logs">Logs</a></li>

<li class="active"><a href="/<?php echo base_url(); ?>/index.php/services">Services</a></li>

</ul>

</div>

<div class="col-lg-4 col-sm-4">

<h2>Welcome <?php echo $username; ?>!</h2>

<a href="/home/logout">Logout</a>

</div>

</div>

</div>

<hr/>

<div class="container">

<div class="row">

<div class="col-lg-6 col-sm-6 well">

<?php // Change the css classes to suit your needs

$attributes = array("class" => "form-horizontal", "id" => "addservice", "name" => "Add service form");

echo form_open('addservice', $attributes); ?>

<fieldset>

<legend>Add new service</legend>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="worksheet_num" class="control-label">Worksheet Number:<span class="required">*</span></label>

<?php echo form_error('worksheet_num'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" size="20" id="worksheet_num" type="text" name="worksheet_num" maxlength="10" value="<?php echo set_value('worksheet_num'); ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="reg_plate" class="control-label">Reg Plate:<span class="required">*</span></label>

<?php echo form_error('reg_plate'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" size="20" id="reg_plate" type="text" name="reg_plate" maxlength="10" value="<?php echo set_value('reg_plate'); ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="date" class="control-label">Date: (YYYY/MM/DD)</label>

<?php echo form_error('date'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" size="20" id="date" type="text" name="date" maxlength="20" value="<?php echo set_value('date'); ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="miles" class="control-label">Miles:</label>

<?php echo form_error('miles'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" size="20" id="miles" type="text" name="miles" maxlength="30" value="<?php echo set_value('miles'); ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="event" class="control-label">Event <span class="required">*</span></label>

<?php echo form_error('event'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<?php // Change the values in this array to populate your dropdown as required ?>

<?php $options = array(

'Accident repair' => 'Accident repair',

'Causal service' => 'Causal service',

'MOT' => 'MOT',

'Revision' => 'Revision',

'Other' => 'Other'

); ?>

<?php echo form_dropdown('event', $options, set_value('event'))?>

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="notes" class="control-label">Notes:</label>

<?php echo form_error('notes'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<textarea class="form-control" cols="20" rows="6" id="notes" name="notes" maxlength="1000" ><?php echo set_value('notes'); ?></textarea>

</div>

</div>

</div>

<div class="form-group">

<div class="col-lg-12 col-sm-12 text-center">

<input type="submit" class="btn btn-default" value="Submit"/>

<?php //echo form_submit( 'submit', 'Submit'); ?>

</div>

</div>

</fieldset>

</form>

<script type="text/javascript" src="/../assets/js/jquery-1.11.2.js"></script>

<script type="text/javascript" src="/../assets/js/bootstrap.js""></script>

</body>

</html>

addservice.php (Controller)

<?php

class Addservice extends CI_Controller {

function __construct()

{

parent::__construct();

$this->load->library('form_validation');

$this->load->database();

$this->load->helper('form');

$this->load->helper('url');

$this->load->model('maddservice');

}

function index()

{

if($this->session->userdata('logged_in'))

{

$session_data = $this->session->userdata('logged_in');

$data['username'] = $session_data['username'];

//$this->load->view('home_view', $data);

$this->form_validation->set_rules('worksheet_num', 'Worksheet Num', 'required|max_length[11]');

$this->form_validation->set_rules('reg_plate', 'Reg Plate', 'required|max_length[10]');

$this->form_validation->set_rules('date', 'Date', 'max_length[20]');

$this->form_validation->set_rules('miles', 'Miles', 'max_length[10]');

$this->form_validation->set_rules('event', 'Event', 'required|max_length[30]');

$this->form_validation->set_rules('notes', 'Notes', 'max_length[1000]');

$this->form_validation->set_error_delimiters('<br /><span class="error">', '</span>');

if ($this->form_validation->run() == FALSE) // validation hasn't been passed

{

$this->load->view('vAddService_view', $data);

}

else // passed validation proceed to post success logic

{

// build array for the model

$form_data = array(

'worksheet_num' => set_value('worksheet_num'),

'reg_plate' => set_value('reg_plate'),

'date' => set_value('date'),

'miles' => set_value('miles'),

'event' => set_value('event'),

'notes' => set_value('notes')

);

// run insert model to write data to db

if ($this->maddservice->SaveForm($form_data) == TRUE) // the information has therefore been successfully saved in the db

{

redirect('services'); // or whatever logic needs to occur

}

else

{

echo 'An error occurred saving your information. Please try again later';

// Or whatever error handling is necessary

}

}

}

else

{

//If no session, redirect to login page

redirect('login', 'refresh');

}

}

function success()

{

echo 'this form has been successfully submitted with all validation being passed. All messages or logic here. Please note

sessions have not been used and would need to be added in to suit your app';

}

}

?>

maddservice.php (Model)

<?php

class maddservice extends CI_Model {

function __construct()

{

parent::__construct();

}

function SaveForm($form_data)

{

$this->db->insert('mvc_services', $form_data);

if ($this->db->affected_rows() == '1')

{

return TRUE;

}

return FALSE;

}

}

?>

Edit service

 

vEditService_view.php (View)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Beanaco - Edit Log</title>

<meta http-equiv="content-type" content="text/html;charset=UTF-8">

<!--link the bootstrap css file-->

<link rel="stylesheet" href="/<?php echo base_url(); ?>assets/css/bootstrap.min.css">

</head>

<body>

<div class="container">

<div class="row">

<div class="col-lg-4 col-sm-">

<h1>BEANACO ADMIN</h1>

</div>

<div class="col-lg-4 col-sm-4">

<ul class="nav nav-pills pull-right" style="margin-top:20px">

<li><a href="/home">Vans</a></li>

<li><a href="/<?php echo base_url(); ?>/index.php/drivers">Drivers</a></li>

<li><a href="/<?php echo base_url(); ?>/index.php/logs">Logs</a></li>

<li class="active"><a href="/<?php echo base_url(); ?>/index.php/services">Services</a></li>

</ul>

</div>

<div class="col-lg-4 col-sm-4">

<h2>Welcome <?php echo $username; ?>!</h2>

<a href="/home/logout">Logout</a>

</div>

</div>

</div>

<hr/>

<div class="container">

<div class="row">

<div class="col-lg-6 col-sm-6 well">

<?php foreach($results as $row) { ?>

<?php echo form_open_multipart('editservice'); ?>

<fieldset>

<legend>Edit service</legend>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="worksheet_num" class="control-label">Worksheet Number:<span class="required">*</span></label>

<?php echo form_error('worksheet_num'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" size="20" id="worksheet_num" type="text" name="worksheet_num" maxlength="10" value="<?php echo $row->worksheet_num; ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="reg_plate" class="control-label">Reg Plate:<span class="required">*</span></label>

<?php echo form_error('reg_plate'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" size="20" id="reg_plate" type="text" name="reg_plate" maxlength="10" value="<?php echo $row->reg_plate; ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="date" class="control-label">Date: (YYYY/MM/DD)<span class="required">*</span></label>

<?php echo form_error('date'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" size="20" id="date" type="text" name="date" maxlength="20" value="<?php echo $row->date; ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="miles" class="control-label">Miles:</label>

<?php echo form_error('miles'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<input class="form-control" size="20" id="miles" type="text" name="miles" maxlength="30" value="<?php echo $row->miles; ?>" />

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="event" class="control-label">Event <span class="required">*</span></label>

<?php echo form_error('event'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<?php // Change the values in this array to populate your dropdown as required ?>

<?php $options = array(

'Accident repair' => 'Accident repair',

'Causal service' => 'Causal service',

'MOT' => 'MOT',

'Revision' => 'Revision',

'Other' => 'Other'

);

$selected = $row->event;

?>

<?php echo form_dropdown('event', $options, $selected)?>

</div>

</div>

</div>

<div class="form-group">

<div class="row colbox">

<div class="col-lg-4 col-sm-4">

<label for="notes" class="control-label">Notes:<span class="required">*</span></label>

<?php echo form_error('notes'); ?>

</div>

<div class="col-lg-8 col-sm-8">

<textarea class="form-control" cols="20" rows="6" id="notes" name="notes" maxlength="1000" ><?php echo $row->notes; ?></textarea>

</div>

</div>

</div>

<input type="hidden" name="serviceID" value="<?php echo $row->serviceID; ?>" size="0" />

<div class="form-group">

<div class="col-lg-12 col-sm-12 text-center">

<input type="submit" class="btn btn-default" value="Submit"/>

</div>

</div>

</fieldset>

</form>

<?php } ?>

<script type="text/javascript" src="/<?php echo base_url(); ?>assets/js/jquery-1.11.2.js"></script>

<script type="text/javascript" src="/<?php echo base_url(); ?>assets/js/bootstrap.js""></script>

</body>

</html>

editservice.php (Controller)

<?php

class Editservice extends CI_Controller {

function __construct()

{

parent::__construct();

$this->load->library('form_validation');

$this->load->database();

$this->load->helper('form');

$this->load->helper('url');

$this->load->model('meditservice');

}

function index()

{

if($this->session->userdata('logged_in'))

{

$session_data = $this->session->userdata('logged_in');

$data['username'] = $session_data['username'];

//$this->load->view('drivers_view', $data);

$this->form_validation->set_rules('worksheet_num', 'Worksheet Num', 'required|max_length[11]');

$this->form_validation->set_rules('reg_plate', 'Reg Plate', 'required|max_length[10]');

$this->form_validation->set_rules('date', 'Date', 'max_length[20]');

$this->form_validation->set_rules('miles', 'Miles', 'max_length[10]');

$this->form_validation->set_rules('event', 'Event', 'required|max_length[30]');

$this->form_validation->set_rules('notes', 'Notes', 'max_length[1000]');

$this->form_validation->set_error_delimiters('<br /><span class="error">', '</span>');

if ($this->form_validation->run() == FALSE) // validation hasn't been passed

{

$this->load->view('vEditService_view', $data);

}

else // passed validation proceed to post success logic

{

// build array for the model

$id = $this->input->post('serviceID');

$form_data = array(

'worksheet_num' => set_value('worksheet_num'),

'reg_plate' => set_value('reg_plate'),

'date' => set_value('date'),

'miles' => set_value('miles'),

'event' => set_value('event'),

'notes' => set_value('notes')

);

// run insert model to write data to db

if ($this->meditservice->SaveForm($id, $form_data) == TRUE) // the information has therefore been successfully saved in the db

{

redirect('services'); // or whatever logic needs to occur

}

else

{

echo 'An error occurred saving your information. Please try again later';

// Or whatever error handling is necessary

}

}

}

else

{

//If no session, redirect to login page

redirect('login', 'refresh');

}

}

function success()

{

echo 'this form has been successfully submitted with all validation being passed. All messages or logic here. Please note

sessions have not been used and would need to be added in to suit your app';

}

public function updateservice($id = null) {

if($this->session->userdata('logged_in'))

{

$session_data = $this->session->userdata('logged_in');

$data['username'] = $session_data['username'];

//$this->load->view('drivers_view', $data);

if ( is_numeric($id) ) {

//Echo "this is edit";

$this->load->helper(array('form', 'url'));

$query = $this->db->query("select * from mvc_services where serviceID =" . $id);

$data['results'] = $query->result();

$this->load->view('vEditService_view.php', $data);

//Load up the appropriate view

} else {

//echo "No ID provided for record in the URL.";

$this->load->model("meditservice");

$this->load->view('services_view.php');

}

}

else

{

//If no session, redirect to login page

redirect('login', 'refresh');

}

}

}

?>

meditservice.php (Model)

<?php

class Editservice extends CI_Controller {

function __construct()

{

parent::__construct();

$this->load->library('form_validation');

$this->load->database();

$this->load->helper('form');

$this->load->helper('url');

$this->load->model('meditservice');

}

function index()

{

if($this->session->userdata('logged_in'))

{

$session_data = $this->session->userdata('logged_in');

$data['username'] = $session_data['username'];

//$this->load->view('drivers_view', $data);

$this->form_validation->set_rules('worksheet_num', 'Worksheet Num', 'required|max_length[11]');

$this->form_validation->set_rules('reg_plate', 'Reg Plate', 'required|max_length[10]');

$this->form_validation->set_rules('date', 'Date', 'max_length[20]');

$this->form_validation->set_rules('miles', 'Miles', 'max_length[10]');

$this->form_validation->set_rules('event', 'Event', 'required|max_length[30]');

$this->form_validation->set_rules('notes', 'Notes', 'max_length[1000]');

$this->form_validation->set_error_delimiters('<br /><span class="error">', '</span>');

if ($this->form_validation->run() == FALSE) // validation hasn't been passed

{

$this->load->view('vEditService_view', $data);

}

else // passed validation proceed to post success logic

{

// build array for the model

$id = $this->input->post('serviceID');

$form_data = array(

'worksheet_num' => set_value('worksheet_num'),

'reg_plate' => set_value('reg_plate'),

'date' => set_value('date'),

'miles' => set_value('miles'),

'event' => set_value('event'),

'notes' => set_value('notes')

);

// run insert model to write data to db

if ($this->meditservice->SaveForm($id, $form_data) == TRUE) // the information has therefore been successfully saved in the db

{

redirect('services'); // or whatever logic needs to occur

}

else

{

echo 'An error occurred saving your information. Please try again later';

// Or whatever error handling is necessary

}

}

}

else

{

//If no session, redirect to login page

redirect('login', 'refresh');

}

}

function success()

{

echo 'this form has been successfully submitted with all validation being passed. All messages or logic here. Please note

sessions have not been used and would need to be added in to suit your app';

}

public function updateservice($id = null) {

if($this->session->userdata('logged_in'))

{

$session_data = $this->session->userdata('logged_in');

$data['username'] = $session_data['username'];

//$this->load->view('drivers_view', $data);

if ( is_numeric($id) ) {

//Echo "this is edit";

$this->load->helper(array('form', 'url'));

$query = $this->db->query("select * from mvc_services where serviceID =" . $id);

$data['results'] = $query->result();

$this->load->view('vEditService_view.php', $data);

//Load up the appropriate view

} else {

//echo "No ID provided for record in the URL.";

$this->load->model("meditservice");

$this->load->view('services_view.php');

}

}

else

{

//If no session, redirect to login page

redirect('login', 'refresh');

}

}

}

?>

Database

mvc_users

Columns:

  • id
  • username
  • password

Sql command to insert a new user to database with encrypted password:

insert into mvc_users (username, password) values ('xxxxx', MD5('xxxxx'));

SQL

-- phpMyAdmin SQL Dump

-- version 4.1.12

-- http://www.phpmyadmin.net

--

-- Host: fas-dbms.sunderland.ac.uk

-- Generation Time: Mar 12, 2015 at 03:44 PM

-- Server version: 5.1.73

-- PHP Version: 5.3.3

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";

SET time_zone = "+00:00";

--

-- Database: `********`

--

-- --------------------------------------------------------

--

-- Table structure for table `mvc_users`

--

CREATE TABLE `mvc_users` (

`id` tinyint(4) NOT NULL AUTO_INCREMENT,

`username` varchar(10) NOT NULL,

`password` varchar(100) NOT NULL,

PRIMARY KEY (`id`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

--

-- Dumping data for table `mvc_users`

--

INSERT INTO `mvc_users` (`id`, `username`, `password`) VALUES

(1, 'fpisti35', '23d03063960753161e65ca6dad0265c7'),

(2, 'Andrew', '8aae3a73a9a43ee6b04dfd986fe9d136');

mvc_vans

Columns:

  • vanID
  • reg_plate
  • type
  • model
  • fuel
  • state
  • location_lati
  • location_long

SQL

-- phpMyAdmin SQL Dump

-- version 4.1.12

-- http://www.phpmyadmin.net

--

-- Host: fas-dbms.sunderland.ac.uk

-- Generation Time: Mar 12, 2015 at 03:47 PM

-- Server version: 5.1.73

-- PHP Version: 5.3.3

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";

SET time_zone = "+00:00";

--

-- Database: `********`

--

-- --------------------------------------------------------

--

-- Table structure for table `mvc_vans`

--

CREATE TABLE `mvc_vans` (

`vanID` int(11) NOT NULL AUTO_INCREMENT,

`reg_plate` char(10) NOT NULL,

`type` varchar(100) NOT NULL,

`model` varchar(100) NOT NULL,

`fuel` char(10) NOT NULL,

`state` char(50) NOT NULL,

`location_lati` char(50) NOT NULL,

`location_long` char(50) NOT NULL,

PRIMARY KEY (`vanID`),

UNIQUE KEY `reg_plate` (`reg_plate`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=64 ;

--

-- Dumping data for table `mvc_vans`

--

INSERT INTO `mvc_vans` (`vanID`, `reg_plate`, `type`, `model`, `fuel`, `state`, `location_lati`, `location_long`) VALUES

(1, 'HV02XJY', 'Fiat', 'Ducato 2.8', 'Diesel', 'On Road', '54.898816', '-1.415176'),

(2, 'BW04KUJ', 'Ford', 'Transit 85 T300', 'Diesel', 'On Road', '53.526357', '-1.415698'),

(3, 'GU56JAO', 'Ford', 'Transit MWD', 'Diesel', 'On Road', '53.526389', '-1.412578'),

(4, 'BT63UOH', 'Mercedes', 'Sprinter 313 cdi', 'Diesel', 'On Road', '54.894756', '-1.415325'),

(5, 'AX51MZT', 'Ford', 'Transit 2,4 RWD', 'Diesel', 'On Road', '54.893724', '-1.415642'),

(6, 'PY56CLZ', 'Ford', 'Transit T280', 'Diesel', 'On Road', '54.898816', '-1.415165'),

(7, 'KP15JTF', 'Citroen', 'Relay L3H2', 'Petrol', 'On Road', '54.895897', '-1.415890'),

(8, 'VO14XYE', 'Volkswagen ', 'Transporter 2.0 TDI', 'Diesel', 'On Road', '53.365816', '-1.387576'),

(9, 'BL14AAE', 'Mercedes', 'Sprinter 313 cdi', 'Diesel', 'On Road', '54.898564', '-1.415259'),

(10, 'FL63GHV', 'Vauxhall', 'Movano LWB', 'Diesel', 'On Road', '54.898816', '-1.415165'),

(11, 'WX63BTS', 'Mercedes', 'Sprinter 313 cdi', 'Diesel', 'On Road', '53.526331', '-1.412254'),

(12, 'WX63EET', 'Mercedes', 'Sprinter 313 cdi', 'Diesel', 'On Road', '54.893630', '-1.412595'),

(13, 'BU13LLN', 'Ford', 'Transit 350 EF', 'Diesel', 'On Road', '53.526363', '-1.415478'),

(14, 'DG64ODE', 'Nissan ', 'NV400', 'Diesel', 'On Road', '53.526965', '-1.415005'),

(15, 'WX63EFS', 'Mercedes', 'Sprinter 313 cdi', 'Diesel', 'On Road', '53.526308', '-1.412639'),

(16, 'WX65MHG', 'Vauxhall', 'Movano 2.3 CDTI', 'Diesel', 'On Road', '54.893796', '-1.412554'),

(17, 'WX63UTR', 'Ford', 'Transit 350 TDCI', 'Diesel', 'On Road', '53.526856', '-1.415669'),

(18, 'LB57EOY', 'Ford', 'Transit Luton', 'Diesel', 'On Road', '54.895858', '-1.412559'),

(19, 'OE64URM', 'Volkswagen', 'Movano 2.3 CDTI', 'Diesel', 'On Road', '54.893485', '-1.412624'),

(20, 'BL14AAK', 'Mercedes', 'Sprinter 313 cdi', 'Diesel', 'Off Road', '53.526338', '-1.415287'),

(21, 'BD14WEK', 'Ford', 'Transit 310 MWB', 'Diesel', 'On Road', '54.893715', '-1.426869'),

(22, 'GU13KOX', 'Volkswagen', 'Crafter CR35', 'Diesel', 'On Road', '54.898563', '-1.426715'),

(23, 'OE14XKY', 'Vauxhall', 'Movano 2.3 CDTI', 'Diesel', 'On Road', '54.893645', '-1.387526'),

(24, 'S890SDF', 'Iveco', 'Daily 35S13', 'Diesel', 'On Road', '53.526983', '-1.387525'),

(25, 'GF63HJE', 'Volkswagen', 'Crafter CR35', 'Diesel', 'On Road', '53.526351', '-1.387528'),

(26, 'LB14EGU', 'Volkswagen', 'Crafter CR35', 'Diesel', 'On Road', '53.526962', '-1.395276'),

(27, 'V695MPK', 'Mercedes', 'Sprinter 318 cdi', 'Diesel', 'On Road', '53.365887', '-1.395568'),

(28, 'LT14ELO', 'Mercedes', 'Sprinter 313 cdi', 'Diesel', 'On Road', '54.898845', '-1.395554'),

(29, 'GU13JXD', 'Volkswagen', 'Crafter CR35', 'Diesel', 'On Road', '53.526985', '-1.415087'),

(30, 'EO14XLB', 'Ford', 'Transit 350 L3 RWB', 'Diesel', 'On Road', '54.893675', '-1.412264'),

(31, 'CE64TKC', 'Citroen', 'Relay 35 L3', 'Diesel', 'On Road', '54.898802', '-1.387598'),

(32, 'D368HKT', 'Volkswagen', 'Crafter CR35', 'Diesel', 'On Road', '54.893768', '-1.395908'),

(33, 'BU13LKS', 'Volkswagen', 'Crafter CR35', 'Diesel', 'Off Road', '54.893897', '-1.387568'),

(34, 'RV63SYA', 'Mercedes', 'Sprinter 313 cdi', 'Diesel', 'On Road', '53.526375', '-1.387578'),

(35, 'VO14WPL', 'Volkswagen', 'Crafter 2.0 TDI', 'Diesel', 'On Road', '54.893348', '-1.395224'),

(36, 'NJ63VGL', 'Volkswagen', 'Crafter 2.0 TDI', 'Diesel', 'On Road', '53.526396', '-1.387568'),

(37, 'LM13UVA', 'Mercedes', 'Sprinter 313 cdi', 'Diesel', 'On Road', '53.526968', '-1.412687'),

(38, 'YJ13LXA', 'Mercedes', 'Sprinter 313 cdi', 'Diesel', 'On Road', '53.526331', '-1.395276'),

(39, 'LM13UHT', 'Mercedes', 'Sprinter 313 cdi', 'Diesel', 'On Road', '53.365816', '-1.415176'),

(40, 'LM13UTN', 'Mercedes', 'Sprinter 313 cdi', 'Diesel', 'On Road', '54.898816', '-1.415176'),

(41, 'KV63VYD', 'Mercedes', 'Sprinter 313 cdi', 'Petrol', 'On Road', '54.898816', '-1.415176'),

(42, 'WW13OSZ', 'Mercedes', 'Sprinter 313 cdi', 'Diesel', 'On Road', '54.898816', '-1.415176'),

(43, 'SH13NUY', 'Mercedes', 'Sprinter 316 cdi', 'Diesel', 'On Road', '54.898816', '-1.415176'),

(44, 'BV13CZB', 'Mercedes', 'Sprinter 313 cdi', 'Diesel', 'On Road', '54.898825', '-1.415187'),

(45, 'SL63JXL', 'Vauxhall', 'Movano 2.3 CDTI', 'Diesel', 'On Road', '53.365887', '-1.387576'),

(46, 'FL12CBG', 'Iveco', 'Daily 50C15', 'Diesel', 'On Road', '53.526962', '-1.387578'),

(47, 'CE14HKM', 'Citroen', 'Relay 35 L3', 'Petrol', 'On Road', '54.898816', '-1.415176'),

(48, 'MV61LYY', 'Ford', 'Transit 350 L3 RWB', 'Diesel', 'On Road', '53.526856', '-1.415325'),

(49, 'CU13KNO', 'Iveco', 'Daily 35S13', 'Diesel', 'On Road', '54.898816', '-1.415176'),

(50, 'WX63XME', 'Volkswagen', 'Crafter CR35', 'Diesel', 'On Road', '53.526968', '-1.395908'),

(51, 'BV13CKT', 'Mercedes', 'Sprinter 313 cdi', 'Diesel', 'On Road', '54.898816', '-1.415176'),

(52, 'BT62YBG', 'Mercedes', 'Sprinter 313 cdi', 'Diesel', 'On Road', '54.898816', '-1.415176'),

(53, 'BT62YBF', 'Mercedes', 'Sprinter 313 cdi', 'Diesel', 'On Road', '54.893675', '-1.412264'),

(54, 'BT62YBH', 'Mercedes', 'Sprinter 313 cdi', 'Diesel', 'On Road', '54.898816', '-1.415176'),

(55, 'BT62YBM', 'Mercedes', 'Sprinter 313 cdi', 'Diesel', 'On Road', '53.526968', '-1.415087'),

(56, 'LL14WRW', 'Mercedes', 'Vito 113 CDI', 'Diesel', 'On Road', '53.526375', '-1.415478'),

(57, 'FN13DOH', 'Vauxhall', 'Movano 2.3 CDTI', 'Diesel', 'On Road', '54.898816', '-1.395908'),

(58, 'KR63HZG', 'Mercedes', 'Sprinter 313 cdi', 'Diesel', 'On Road', '53.526357', '-1.395224'),

(59, 'KR63JDO', 'Mercedes', 'Sprinter 313 cdi', 'Diesel', 'On Road', '54.898816', '-1.395568'),

(60, 'YM14VTX', 'Vauxhall', 'Movano 2.3 CDTI', 'Diesel', 'On Road', '53.526363', '-1.415176'),

(61, 'KU09BTX', 'Mercedes', 'Sprinter 511', 'Diesel', 'On Road', '53.526351', '-1.387526'),

(62, 'FG62OSV', 'Ford', 'Transit T280', 'Diesel', 'On Road', '53.526389', '-1.412254'),

(63, 'FG62DSU', 'Ford', 'Transit 350 EF', 'Diesel', 'On Road', '53.526968', '-1.415176');

mvc_drivers

Columns:

  • DriverID
  • DriverName
  • DriverPhone
  • DriverLicenceNum
  • DriverLicenceExp

SQL

-- phpMyAdmin SQL Dump

-- version 4.1.12

-- http://www.phpmyadmin.net

--

-- Host: fas-dbms.sunderland.ac.uk

-- Generation Time: Mar 12, 2015 at 03:57 PM

-- Server version: 5.1.73

-- PHP Version: 5.3.3

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";

SET time_zone = "+00:00";

--

-- Database: `*******`

--

-- --------------------------------------------------------

--

-- Table structure for table `mvc_drivers`

--

CREATE TABLE `mvc_drivers` (

`DriverID` tinyint(4) NOT NULL AUTO_INCREMENT,

`DriverName` varchar(100) NOT NULL,

`DriverPhone` char(30) NOT NULL,

`DriverLicenceNum` varchar(50) NOT NULL,

`DriverLicenceExp` date NOT NULL,

PRIMARY KEY (`DriverID`),

UNIQUE KEY `id` (`DriverID`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=82 ;

--

-- Dumping data for table `mvc_drivers`

--

INSERT INTO `mvc_drivers` (`DriverID`, `DriverName`, `DriverPhone`, `DriverLicenceNum`, `DriverLicenceExp`) VALUES

(1, 'Reece Hudson', '077 5646 6358', 'HUDSO6910101k67GH', '2016-02-16'),

(2, 'John Garner', '079 8530 9912', 'GARNE8405171n54KL', '2017-03-15'),

(3, 'Patrick Bates', '079 8806 0113', 'BATE7803245j86TR', '2015-08-17'),

(4, 'Elliot Pratt', '079 2083 4535', 'PRATT6904304h78KJ', '2020-04-18'),

(5, 'Ryan Holland', '077 4379 5031', 'HOLLAN750412u87OJ', '2015-03-20'),

(6, 'Isaac Houghton', '079 1365 4592', 'HOUGHT100753g589', '2018-02-16'),

(7, 'Isaac Arnold', '079 1690 8072', 'ARNOLD250853j785', '2018-02-01'),

(8, 'Megan Forster', '078 7692 5676', 'FORSTE181076p547', '2016-06-03'),

(9, 'Holly Burke', '077 5997 6402', 'BURKEH230333g114', '2017-10-18'),

(10, 'Owen Mellor', '070 2761 6419', 'MELLOR050654d758', '2019-12-10'),

(11, 'Madison Bell', '079 1772 7793', 'BELLMA020444h746', '2019-06-22'),

(12, 'Erin Stevens', '077 1064 6645', 'STEVEN040581c795', '2017-11-06'),

(13, 'James Gardner', '077 0239 7262', 'GARDNE200569f482', '2020-05-18'),

(14, 'Harvey Rowe', '070 1444 9129', 'ROWEHA301072k169', '2020-07-01'),

(15, 'Mohammed Jenkins', '078 7111 5176', 'JENKIN030157a964', '2020-04-02'),

(16, 'Mollie Roberts', '078 1855 6171', 'ROBERT120877x621', '2018-12-03'),

(17, 'Jasmine Walker', '078 6207 8519', 'WALKER191273s666', '2019-10-04'),

(18, 'Alexandra Sanders', '078 1239 3154', 'SANDER290960r327', '2018-04-05'),

(19, 'Scott Peacock', '070 7468 8349', 'PEACOC190959n841', '2019-01-06'),

(20, 'Jack Webster', '079 0213 9502', 'WEBSTE011037q419', '2018-10-07'),

(21, 'Kayleigh North', '077 1491 9405', 'NORTH260645s637', '2016-01-08'),

(22, 'Francesca Hodgson', '078 8885 0555', 'HODGSO130745d344', '2016-01-09'),

(23, 'Edward Pratt', '078 1809 5126', 'PRATTE210942t371', '2016-02-28'),

(24, 'Alisha Bartlett', '070 8530 9017', 'BARTLE080144u446', '2020-03-17'),

(25, 'Isabella Kirby', '077 6562 3353', 'KIRBYI290362w394', '2018-12-25'),

(26, 'Bailey Talbot', '078 3323 7537', 'TALBOT031083k661', '2019-09-05'),

(27, 'Alfie Boyle', '078 4897 3873', 'BOYLEA080785k674', '2020-01-18'),

(28, 'Sophie Howard', '077 0647 0392', 'HOWARD230469b311', '2019-06-22'),

(29, 'Eva Rahman', '077 8699 3598', 'RAHMAN300443z119', '2018-07-06'),

(30, 'Olivia Rice', '077 2105 2166', 'RICEOL040429t743', '2019-03-31'),

(31, 'Georgia Oliver', '070 0751 2615', 'OLIVER180553f333', '2019-07-29'),

(32, 'Leah Hilton', '079 1099 5387', 'HILTON160488v611', '2018-08-17'),

(33, 'David Howells', '079 3223 7092', 'HOWELL090958l675', '2018-12-02'),

(34, 'Leo Walsh', '079 8690 8846', 'WALSHL300449d443', '2016-12-16'),

(35, 'Harrison O&#39;Donnell', '077 7222 1919', 'ODONNE210354y388', '2016-12-01'),

(36, 'Mia Cox', '079 7038 0486', 'COXMIA230459c284', '2016-09-18'),

(37, 'Amelie Reed', '078 3954 9312', 'REEDAM051089f336', '2017-09-25'),

(38, 'Elizabeth Palmer', '079 4323 7120', 'PALMER171075c492', '2016-11-06'),

(39, 'Riley Adams', '070 5189 9026', 'ADAMSR011288j638', '2019-08-11'),

(40, 'Taylor Morrison', '077 0087 9906', 'MORRIS160646e937', '2019-09-26'),

(41, 'Mohammed Holmes', '079 7393 7415', 'HOLMES240665a311', '2016-08-18'),

(42, 'Danielle Mellor', '079 2275 1728', 'MELLOR280558j299', '2019-08-24'),

(43, 'Mollie Hussain', '078 0100 9495', 'HUSSAI260787t687', '2020-07-03'),

(44, 'Riley Edwards', '077 6295 8569', 'EDWARD271240p699', '2016-07-15'),

(45, 'Chloe Patel', '077 0555 2399', 'PATELC040855s325', '2020-12-07'),

(46, 'Holly Watson', '070 2982 0492', 'WATSON070789o322', '2016-06-28'),

(47, 'Hannah Sharp', '079 4895 1820', 'SHARPH101275d300', '2020-09-20'),

(48, 'Ryan Webb', '078 4658 2258', 'WEBBRY101242u388', '2016-09-30'),

(49, 'Josh Iqbal', '070 6944 6953', 'IQBALJ160136x677', '2016-07-31'),

(50, 'Harvey Byrne', '079 7193 6403', 'BYRNEH260281g999', '2016-03-10'),

(51, 'Spencer Parry', '079 4642 2904', 'PARRYS070462k311', '2017-10-11'),

(52, 'Summer Potter', '079 2866 2111', 'POTTER121289d111', '2019-12-03'),

(53, 'Lydia Chan', '078 5781 1010', 'CHANLY110787m854', '2017-12-19'),

(54, 'Logan Lynch', '079 1003 9967', 'LYNCHL310844o330', '2016-09-15'),

(55, 'Charlotte Sharpe', '079 6408 4299', 'SHARPE260189t974', '2020-04-04'),

(56, 'Finlay Savage', '077 1589 3207', 'SAVAGE130349d355', '2020-06-23'),

(57, 'Eva Bruce', '070 6127 7086', 'BRUCEE221282h555', '2019-10-21'),

(58, 'Madeleine Rowley', '078 2033 0405', 'ROWLEY180867v937', '2017-06-13'),

(59, 'Freya Frost', '070 3330 5906', 'FROSTF031041j111', '2020-04-23'),

(60, 'Ewan Howell', '079 8414 4352', 'HOWELL130793x666', '2016-01-19'),

(61, 'Luca Fitzgerald', '079 5185 2459', 'FITZGE100382z347', '2018-05-09'),

(62, 'Rebecca Woodward', '078 5778 1547', 'WOODWA211250o488', '2020-09-03'),

(63, 'Jessica Leonard', '070 8838 1913', 'LEONAR300664y555', '2018-01-23'),

(64, 'Summer Peacock', '079 3343 5803', 'PEACOC191083e662', '2017-10-09'),

(65, 'Cameron Wright', '078 6044 2345', 'WRIGHT140981b118', '0000-00-00'),

(66, 'Benjamin Richardson', '070 6916 9558', 'RICHAR250884s008', '2019-09-11'),

(67, 'Zoe Price', '078 7671 0232', 'PRICEZ060293l087', '2020-10-22'),

(68, 'Sam Pritchard', '079 7250 7582', 'PRITCH210876x108', '2020-09-17'),

(69, 'Alice Bowen', '070 3144 1104', 'BOWENA170637u380', '2018-04-29'),

(70, 'Emma Page', '078 5067 6792', 'PAGEEM280944w331', '2019-08-08'),

(71, 'Morgan Hardy', '077 3354 6344', 'HARDYM180451t666', '2018-04-16'),

(72, 'Amelia May', '079 3338 5916', 'MAYAME160167u888', '2020-05-05'),

(73, 'Faith Rice', '077 0456 1509', 'RICEFA140169o628', '2016-07-03'),

(74, 'Ethan Long', '079 1957 6933', 'LONGET090272g841', '2019-12-26'),

(75, 'Abbie Herbert', '077 3099 1495', 'HERBER090435g088', '2018-05-11'),

(76, 'Michael Swift', '070 8425 2974', 'SWIFTM300551f303', '2020-12-12'),

(77, 'Elliot Thomson', '077 4528 5971', 'THOMSO261054l662', '2016-05-20'),

(78, 'Edward Pritchard', '079 5785 1914', 'PRITCH091186f622', '2019-01-26'),

(79, 'Maya Collier', '070 6802 4227', 'COLLIE071269v554', '2020-01-27'),

(80, 'Sarah Harding', '077 0013 3539', 'HARDIN250929y582', '2020-10-10'),

(81, 'Sean Mellor', '078 1360 5723', 'MELLOR080664k856', '2017-01-06');

mvc_logs

Columns:

  • logID
  • form_number
  • reg_plate
  • driver_id
  • time_out
  • time_in
  • mileage_start
  • mileage_end

SQL

-- phpMyAdmin SQL Dump

-- version 4.1.12

-- http://www.phpmyadmin.net

--

-- Host: fas-dbms.sunderland.ac.uk

-- Generation Time: Mar 12, 2015 at 04:00 PM

-- Server version: 5.1.73

-- PHP Version: 5.3.3

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";

SET time_zone = "+00:00";

--

-- Database: `********`

--

-- --------------------------------------------------------

--

-- Table structure for table `mvc_logs`

--

CREATE TABLE `mvc_logs` (

`logID` int(11) NOT NULL AUTO_INCREMENT,

`form_number` int(11) NOT NULL,

`reg_plate` char(10) NOT NULL,

`driver_id` int(20) NOT NULL,

`time_out` datetime NOT NULL,

`time_in` datetime DEFAULT NULL,

`mileage_start` int(11) NOT NULL,

`mileage_end` int(11) NOT NULL,

PRIMARY KEY (`logID`),

UNIQUE KEY `id` (`logID`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=93 ;

--

-- Dumping data for table `mvc_logs`

--

INSERT INTO `mvc_logs` (`logID`, `form_number`, `reg_plate`, `driver_id`, `time_out`, `time_in`, `mileage_start`, `mileage_end`) VALUES

(1, 1526, 'D368HKT', 4, '2015-03-05 08:32:00', '2015-03-11 16:40:00', 98567, 98842),

(2, 1630, 'S890SDF', 2, '2015-03-04 08:32:00', '2015-03-04 16:20:00', 49489, 49763),

(3, 1340, 'D368HKT', 4, '2015-03-01 08:25:00', '2015-03-01 15:50:00', 98456, 98567),

(4, 1342, 'V694MKT', 3, '2015-03-04 08:32:00', '2015-03-04 14:48:00', 56789, 56857),

(5, 1458, 'S890SDF', 3, '2015-02-06 08:00:00', '2015-02-06 14:00:00', 48953, 49156),

(6, 1467, 'S890SDF', 3, '2015-02-07 08:00:00', '2015-02-07 15:00:00', 49156, 49489),

(7, 1650, 'S890SDF', 1, '2015-02-20 08:10:00', '2015-02-20 16:50:00', 49763, 49960),

(8, 1657, 'S890SDF', 1, '2015-02-22 08:15:00', '2015-02-22 16:30:00', 49960, 50238),

(9, 1700, 'AX51MZT', 55, '2015-02-01 08:05:00', '2015-02-01 16:20:00', 52687, 52916),

(10, 1701, 'AX51MZT', 55, '2015-02-02 08:05:00', '2015-02-02 16:25:00', 52916, 53250),

(11, 1702, 'AX51MZT', 55, '2015-02-03 08:10:00', '2015-02-03 16:15:00', 53250, 53530),

(12, 1703, 'AX51MZT', 55, '2015-02-04 08:10:00', '2015-02-04 16:30:00', 53530, 53855),

(13, 1704, 'AX51MZT', 55, '2015-02-05 08:05:00', '2015-02-05 16:25:00', 53855, 54168),

(14, 1705, 'AX51MZT', 55, '2015-02-06 08:05:00', '2015-02-06 16:20:00', 54168, 54435),

(15, 1706, 'AX51MZT', 55, '2015-02-07 08:15:00', '2015-02-07 16:20:00', 54435, 54741),

(16, 1707, 'AX51MZT', 55, '2015-02-08 08:10:00', '2015-02-08 16:15:00', 54741, 55059),

(17, 1708, 'AX51MZT', 55, '2015-02-09 08:10:00', '2015-02-09 16:25:00', 55059, 55333),

(18, 1709, 'AX51MZT', 55, '2015-02-10 08:05:00', '2015-02-10 16:25:00', 55333, 55629),

(19, 1710, 'AX51MZT', 55, '2015-02-11 08:10:00', '2015-02-11 16:25:00', 55629, 55948),

(20, 1711, 'AX51MZT', 55, '2015-02-12 08:15:00', '2015-02-12 16:25:00', 55948, 56251),

(21, 1712, 'AX51MZT', 55, '2015-02-13 08:15:00', '2015-02-13 16:20:00', 56251, 56534),

(22, 1713, 'AX51MZT', 55, '2015-02-14 08:10:00', '2015-02-14 16:10:00', 56534, 56885),

(23, 1714, 'AX51MZT', 55, '2015-02-15 08:10:00', '2015-02-15 16:22:00', 56885, 57162),

(24, 1715, 'AX51MZT', 55, '2015-02-16 08:00:00', '2015-02-16 16:18:00', 57162, 57463),

(25, 1716, 'AX51MZT', 55, '2015-02-17 08:05:00', '2015-02-17 16:28:00', 57463, 57772),

(26, 1717, 'AX51MZT', 55, '2015-02-18 08:10:00', '2015-02-18 16:30:00', 57772, 58096),

(27, 1718, 'AX51MZT', 55, '2015-02-19 08:10:00', '2015-02-19 16:25:00', 58096, 58385),

(28, 1719, 'AX51MZT', 55, '2015-02-20 08:15:00', '2015-02-20 16:20:00', 58385, 58677),

(29, 1720, 'AX51MZT', 55, '2015-02-21 08:15:00', '2015-02-21 16:20:00', 58677, 58981),

(30, 1721, 'AX51MZT', 55, '2015-02-22 08:20:00', '2015-02-22 16:20:00', 58981, 59287),

(31, 1722, 'AX51MZT', 55, '2015-02-23 08:22:00', '2015-02-23 16:30:00', 59287, 59576),

(32, 1723, 'AX51MZT', 55, '2015-02-24 08:07:00', '2015-02-24 16:18:00', 59576, 59884),

(33, 1724, 'AX51MZT', 55, '2015-02-25 08:13:00', '2015-02-25 16:18:00', 59884, 60188),

(34, 1725, 'AX51MZT', 55, '2015-02-26 08:18:00', '2015-02-26 16:25:00', 60188, 60462),

(35, 1726, 'AX51MZT', 55, '2015-02-27 08:18:00', '2015-02-27 16:15:00', 60462, 60772),

(36, 1727, 'AX51MZT', 55, '2015-02-28 08:05:00', '2015-02-28 16:25:00', 60772, 61063),

(37, 1800, 'BD14WEK', 37, '2015-02-01 08:00:00', '2015-02-01 16:20:00', 52688, 52988),

(38, 1801, 'BD14WEK', 37, '2015-02-02 08:00:00', '2015-02-02 16:25:00', 52988, 53278),

(39, 1802, 'BD14WEK', 37, '2015-02-03 08:05:00', '2015-02-03 16:15:00', 53278, 53596),

(40, 1803, 'BD14WEK', 37, '2015-02-04 08:05:00', '2015-02-04 16:30:00', 53596, 53896),

(41, 1804, 'BD14WEK', 37, '2015-02-05 08:10:00', '2015-02-05 16:25:00', 53896, 54169),

(42, 1805, 'BD14WEK', 37, '2015-02-06 08:10:00', '2015-02-06 16:20:00', 54169, 54503),

(43, 1806, 'BD14WEK', 37, '2015-02-07 08:15:00', '2015-02-07 16:20:00', 54503, 54821),

(44, 1807, 'BD14WEK', 37, '2015-02-08 08:15:00', '2015-02-08 16:15:00', 54821, 55098),

(45, 1808, 'BD14WEK', 37, '2015-02-09 08:20:00', '2015-02-09 16:20:00', 55098, 55420),

(46, 1809, 'BD14WEK', 37, '2015-02-10 08:20:00', '2015-02-10 16:22:00', 55420, 55708),

(47, 1810, 'BD14WEK', 37, '2015-02-11 08:08:00', '2015-02-11 16:25:00', 55708, 56006),

(48, 1811, 'BD14WEK', 37, '2015-02-12 08:17:00', '2015-02-12 16:23:00', 56006, 56347),

(49, 1812, 'BD14WEK', 37, '2015-02-13 08:18:00', '2015-02-13 16:23:00', 56347, 56653),

(50, 1813, 'BD14WEK', 37, '2015-02-14 08:13:00', '2015-02-14 16:13:00', 56653, 56942),

(51, 1814, 'BD14WEK', 37, '2015-02-15 08:13:00', '2015-02-15 16:25:00', 56942, 57264),

(52, 1815, 'BD14WEK', 37, '2015-02-16 08:03:00', '2015-02-16 16:21:00', 57264, 57587),

(53, 1816, 'BD14WEK', 37, '2015-02-17 08:08:00', '2015-02-17 16:25:00', 57587, 57866),

(54, 1817, 'BD14WEK', 37, '2015-02-18 08:07:00', '2015-02-18 16:30:00', 57866, 58166),

(55, 1818, 'BD14WEK', 37, '2015-02-19 08:10:00', '2015-02-19 16:25:00', 58166, 58449),

(56, 1819, 'BD14WEK', 37, '2015-02-20 08:17:00', '2015-02-20 16:20:00', 58449, 58726),

(57, 1820, 'BD14WEK', 37, '2015-02-21 08:15:00', '2015-02-21 16:20:00', 58726, 59058),

(58, 1821, 'BD14WEK', 37, '2015-02-22 08:13:00', '2015-02-22 16:20:00', 59058, 59455),

(59, 1822, 'BD14WEK', 37, '2015-02-23 08:25:00', '2015-02-23 16:29:00', 59455, 59790),

(60, 1823, 'BD14WEK', 37, '2015-02-24 08:07:00', '2015-02-24 16:20:00', 59790, 60061),

(61, 1824, 'BD14WEK', 37, '2015-02-25 08:10:00', '2015-02-25 16:18:00', 60061, 60385),

(62, 1825, 'BD14WEK', 37, '2015-02-26 08:16:00', '2015-02-26 16:25:00', 60385, 60718),

(63, 1826, 'BD14WEK', 37, '2015-02-27 08:21:00', '2015-02-27 16:15:00', 60718, 61006),

(64, 1827, 'BD14WEK', 37, '2015-02-28 08:05:00', '2015-02-28 16:25:00', 61006, 61318),

(65, 1900, 'BL14AAE', 18, '2015-02-01 08:03:00', '2015-02-01 16:18:00', 54692, 54997),

(66, 1901, 'BL14AAE', 18, '2015-02-02 08:03:00', '2015-02-02 16:22:00', 54997, 55308),

(67, 1902, 'BL14AAE', 18, '2015-02-03 08:07:00', '2015-02-03 16:17:00', 55308, 55594),

(68, 1903, 'BL14AAE', 18, '2015-02-04 08:09:00', '2015-02-04 16:30:00', 55594, 55892),

(69, 1904, 'BL14AAE', 18, '2015-02-05 08:12:00', '2015-02-05 16:21:00', 55892, 56220),

(70, 1905, 'BL14AAE', 18, '2015-02-06 08:11:00', '2015-02-06 16:20:00', 56220, 56548),

(71, 1906, 'BL14AAE', 18, '2015-02-07 08:13:00', '2015-02-07 16:19:00', 56548, 56817),

(72, 1907, 'BL14AAE', 18, '2015-02-08 08:15:00', '2015-02-08 16:27:00', 56817, 57090),

(73, 1908, 'BL14AAE', 18, '2015-02-09 08:10:00', '2015-02-09 16:29:00', 57090, 57442),

(74, 1909, 'BL14AAE', 18, '2015-02-10 08:20:00', '2015-02-10 16:22:00', 57442, 57728),

(75, 1910, 'BL14AAE', 18, '2015-02-11 08:06:00', '2015-02-11 16:23:00', 57728, 58011),

(76, 1911, 'BL14AAE', 18, '2015-02-12 08:17:00', '2015-02-12 16:27:00', 58011, 58316),

(77, 1912, 'BL14AAE', 18, '2015-02-13 08:18:00', '2015-02-13 16:18:00', 58316, 58638),

(78, 1913, 'BL14AAE', 18, '2015-02-14 08:02:00', '2015-02-14 16:13:00', 58638, 58957),

(79, 1914, 'BL14AAE', 18, '2015-02-15 08:10:00', '2015-02-15 16:27:00', 58957, 59242),

(80, 1915, 'BL14AAE', 18, '2015-02-16 08:16:00', '2015-02-16 16:18:00', 59242, 59539),

(81, 1916, 'BL14AAE', 18, '2015-02-17 08:08:00', '2015-02-17 16:28:00', 59539, 59864),

(82, 1917, 'BL14AAE', 18, '2015-02-18 08:10:00', '2015-02-18 16:27:00', 59864, 60144),

(83, 1918, 'BL14AAE', 18, '2015-02-19 08:26:00', '2015-02-19 16:19:00', 60144, 60437),

(84, 1919, 'BL14AAE', 18, '2015-02-20 08:17:00', '2015-02-20 16:13:00', 60437, 60751),

(85, 1920, 'BL14AAE', 18, '2015-02-21 08:19:00', '2015-02-21 16:20:00', 60751, 61076),

(86, 1921, 'BL14AAE', 18, '2015-02-22 08:13:00', '2015-02-22 16:21:00', 61076, 61362),

(87, 1922, 'BL14AAE', 18, '2015-02-23 08:25:00', '2015-02-23 16:29:00', 61362, 61704),

(88, 1923, 'BL14AAE', 18, '2015-02-24 08:07:00', '2015-02-24 16:20:00', 61704, 61987),

(89, 1924, 'BL14AAE', 18, '2015-02-25 08:09:00', '2015-02-25 16:18:00', 61987, 62320),

(90, 1925, 'BL14AAE', 18, '2015-02-26 08:16:00', '2015-02-26 16:25:00', 62320, 62615),

(91, 1926, 'BL14AAE', 18, '2015-02-27 08:18:00', '2015-02-27 16:15:00', 62615, 62894),

(92, 1927, 'BL14AAE', 18, '2015-02-28 08:17:00', '2015-02-28 16:23:00', 62894, 63195);

mvc_services

Columns:

  • serviceID
  • worksheet_num
  • reg_plate
  • date
  • miles
  • event
  • notes

SQL

-- phpMyAdmin SQL Dump

-- version 4.1.12

-- http://www.phpmyadmin.net

--

-- Host: fas-dbms.sunderland.ac.uk

-- Generation Time: Mar 12, 2015 at 04:02 PM

-- Server version: 5.1.73

-- PHP Version: 5.3.3

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";

SET time_zone = "+00:00";

--

-- Database: `*********`

--

-- --------------------------------------------------------

--

-- Table structure for table `mvc_services`

--

CREATE TABLE `mvc_services` (

`serviceID` int(11) NOT NULL AUTO_INCREMENT,

`worksheet_num` int(10) NOT NULL,

`reg_plate` char(10) NOT NULL,

`date` date NOT NULL,

`miles` int(10) NOT NULL,

`event` char(30) NOT NULL,

`notes` varchar(1000) CHARACTER SET utf8 COLLATE utf8_hungarian_ci NOT NULL,

PRIMARY KEY (`serviceID`),

UNIQUE KEY `id` (`serviceID`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;

--

-- Dumping data for table `mvc_services`

--

INSERT INTO `mvc_services` (`serviceID`, `worksheet_num`, `reg_plate`, `date`, `miles`, `event`, `notes`) VALUES

(1, 357, 'V695MPK', '2015-02-10', 58976, 'Revision', 'Oils and filters changed. New front tires fitted. All test passed.'),

(2, 358, 'WX63XME', '0000-00-00', 60000, 'Revision', 'Periodic inspection'),

(3, 415, 'V695MPK', '2015-04-20', 0, 'MOT', 'MOT scheduled '),

(4, 414, 'BL14AAK', '2015-03-15', 75942, 'Accident repair', 'Front bumper damaged. Under part order.'),

(5, 416, 'BT62YBG', '2015-03-04', 69843, 'Causal service', 'Diesel pump exchange.\nRepaired.');