-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage_routes.php
74 lines (65 loc) · 2.09 KB
/
manage_routes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
require_once 'filehead.php'; //include filehead file
if(isset($_SESSION['userid']))
{
if(($_SESSION['type']==0) || (($_SESSION['type']==1) && ($_SESSION['staffid']==2))) //only admin and manging staff allowedstaff allowed
{
require_once 'helper/Validation.php'; //email validation
$smarty->assign('CSS_URL', CSS_URL);
$smarty->display('header.tpl');
$smarty->assign('username',$_SESSION['username']);
$smarty->display('userheader.tpl');
if(isset($_POST['add'])) //adding route
{
if( ($_POST['city1']!=NULL) && ($_POST['city2']!=NULL) && ($_POST['expense']!=NULL) && ($_POST[ 'income']!=NULL) )
{
$route= new routes();
$route->add( $_POST['city1'] , $_POST['city2'] , $_POST['expense'] , $_POST[ 'income'] );
echo "ADDED";
} else
{
echo "MESSAGE...enter complete info";
}
}
if(isset($_POST['addRoute']))
{
$add=1;
$smarty->assign('add',$add);
}
if((isset($_POST['remove'])) && isset($_POST['id']) ) //removing route
{
$route= new routes();
$routeId=$_POST['id'];
$allRoutes = $route->getAll();
$route->remove($allRoutes[$routeId]['id']);
echo "MESSAGE: route removed";
}
if((isset($_POST['edit'])) && isset($_POST['id']) ) //selected to edit whole
{
$edit=1;
$route= new routes();
$routeId=$_POST['id'];
$allRoutes = $route->getAll();
$selectedRoute = $route->get('*',$allRoutes[$routeId]['id']);
$smarty->assign('edit',$edit);
$smarty->assign('selectedRoute', $selectedRoute);
}
if(isset($_POST['done_edit'])) //editing whole record
{
$route= new routes();
$routeId=$_POST['id'];
$allRoutes = $route->getAll();
$route->update($allRoutes[$routeId]['id'],$_POST['city1'],$_POST['city2'],$_POST['expense'],$_POST['income']);
echo "MESSAGE: route edited";
}
$route= new routes();
$allRoutes=$route->getAll();
$smarty->assign('allRoutes',$allRoutes);
$smarty->display('manage_routes.tpl');
$smarty->display('footer.tpl'); //include footer file
}
else
header('Location:' . URL . 'notauthorised.php');
} else
header('Location:' . URL . 'noaccess.php');
?>