<?php /** * Created by IntelliJ IDEA. * User: rorypb * Date: 08/12/2015 * Time: 11:57 AM */ require_once 'Garage.php'; require_once 'Connection.php'; require_once 'garageTableGateway.php'; if (!isset($_GET['id'])) { die("Invalid ID"); } $id = $_GET['id']; $connection = Connection::getInstance(); $gateway = new garageTableGateway($connection); $gateway->removeGarage($id); header("Location: index.php");
start_session(); //if user is not logged in redirect them to the log in form if (!is_logged_in()) { header("Location: login_form.php"); } //validate the data entered using the validate function in the validateGarage.php file validate($formdata, $errors); //if the validation is passed (errors array empty) set each variable to the valuye of the coresponding variable in the formdata array if (empty($errors)) { $id = $_POST['id']; $name = $formdata['name']; $managername = $formdata['managername']; $address = $formdata['address']; $email = $formdata['email']; $phone = $formdata['phone']; $openinghours = $formdata['openinghours']; $openingdate = $formdata['openingdate']; //make a new garage object with the data above $garage = new Garage($id, $name, $address, $email, $phone, $openingdate, $openinghours, $managername); //initialize db connection $dbconnection = dbconnection::getConnection(); //connect to the bus table through garageTableGateway using the connection above $gateway = new garageTableGateway($dbconnection); //execute the update function in the garagetablegateway using the object created above $id = $gateway->update($garage); //when completed redirect user to viewall header('Location: viewallgarages.php'); } else { //if an error occurs redisplay the edit form require 'editGarageForm.php'; }
* Date: 26/11/2015 * Time: 3:29 PM */ // require_once 'garage.php'; require_once 'connection.php'; require_once 'garageTableGateway.php'; require_once 'gformprocess.php'; validate($formdata, $errors); if (empty($errors)) { $garage_address = $formdata["garageAdd"]; $phone_no = $formdata["phoneNo"]; $manager_name = $formdata["managerName"]; $garage_name = $formdata["garageName"]; $garage_id; $service_date = $formdata["serviceDate"]; $over_night = true; $garage_url = filter_input(INPUT_POST, 'garageURL', FILTER_SANITIZE_URL); $garage_url_valid = filter_var($garage_url, FILTER_VALIDATE_URL); $manager_email = filter_input(INPUT_POST, 'managerEmail', FILTER_SANITIZE_EMAIL); $manager_email_valid = filter_var($manager_email, FILTER_VALIDATE_EMAIL); $garage = new Garage($garage_address, $phone_no, $manager_name, $garage_name, $garage_id, $service_date, $manager_email, $garage_url, $over_night); $connection = Connection::getInstance(); $gateway = new garageTableGateway($connection); $id = $gateway->insertGarage($garage); //Redirects the user to the specific page header('Location: index.php'); exit; } else { require "addgarage.php"; }
<?php require_once 'garageTableGateway.php'; //require the garage table gateway require_once 'connection.php'; //require the connection to the database require_once 'busTableGateway.php'; //tequire the bus table gateway $connection = Connection::getInstance(); //Use the connection class getinstance of the connection $gateway = new garageTableGateway($connection); //use the connection to connect to the garage table $garages = $gateway->getGarages(); //$garages will use the gateway to get Garages for viewing the garage a bus is assigned too //Function to set the value of the formdata to the respective fieldname function setValue($formdata, $fieldname) { if (isset($formdata) && isset($formdata[$fieldname])) { echo $formdata[$fieldname]; } } //Function to set the check boxs to the value function setChecked($formdata, $fieldName, $fieldValue) { if (isset($formdata[$fieldName]) && isset($formdata[$fieldName])) { if (is_array($formdata[$fieldName]) && in_array($fieldValue, $formdata[$fieldName])) { echo 'checked = "checked"'; } else { if ($formdata[$fieldName] == $fieldValue) { echo 'checked = "checked"'; }
<?php /** * Created by IntelliJ IDEA. * User: rorypb * Date: 01/12/2015 * Time: 12:17 PM */ require_once 'garage.php'; require_once 'connection.php'; require_once 'garageTableGateway.php'; $connection = Connection::getInstance(); $gateway = new garageTableGateway($connection); $statement = $gateway->getGarages(); echo "Connected to the database"; ?> <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/pure-min.css"> <link rel="stylesheet" href="css/global.css"> <meta charset="UTF-8"> <title>Base View of Garages</title> <script src="javascript/delete.js"></script> </head> <body> <div class="container_12"> <table class="pure-table pure-table-bordered"> <thead> <tr>
<?php require_once 'garagestablegateway.php'; require_once 'dbconnection.php'; //If the page is accessed without an id in the get array, die if (!isset($_GET['id'])) { die("Illegal Request"); } $id = $_GET['id']; //establish db connection $dbconnection = dbconnection::getConnection(); //conect to database via gateway using the connection $gateway = new garageTableGateway($dbconnection); //execute the delete bus function passing in the id $gateway->deleteGarage($id); //redirect user to viewall garages on deletion header('Location: viewallgarages.php');
//function used to set values of the form elements function setValue($formdata, $fieldName) { if (isset($formdata) && isset($formdata[$fieldName])) { echo $formdata[$fieldName]; } } if (!isset($formdata)) { $formdata = array(); } if (!isset($errors)) { $errors = array(); } $dbconnection = dbconnection::getConnection(); //connect to the garage table through garageTableGateway using the connection above $garageGateway = new garageTableGateway($dbconnection); $garages = $garageGateway->getGarage(); ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Create Bus</title> <!--javascript script for form validation--> <script src="validateBus.js"></script> </head> <body> <!--Links to my google fonts bootstrap/my own style sheets & javascript scripts-->
require_once 'connection.php'; //for connection to db require_once 'garageTableGateway.php'; //connecting to garage tbal require_once 'busTableGateway.php'; //connection to bus tbale if (!isset($_GET['id'])) { //oif the id is not one from the db die("Halt"); //die } $id = $_GET['id']; //get the id from the databae $connection = Connection::getInstance(); //connect to the db $garageGateway = new garageTableGateway($connection); //connect to the garage table $busGateway = new busTableGateway($connection); //connect to the bus table $garages = $garageGateway->getGarageByGarageId($id); //garage table get garageby id $buses = $busGateway->getBusByID($id); //bus table get bus by id //used in conjunction to view the garage that hioues that bus //$row = $statement->fetch(PDO::FETCH_ASSOC); //if (!$row) { // die("Unable to get Bus By ID"); //} ?>
require_once 'loginhelper.php'; require_once 'dbconnection.php'; require_once 'garagesTableGateway.php'; require_once 'busTableGateway.php'; start_session(); //if user is not logged in, return to log in form if (!is_logged_in()) { header("Location: loginform.php"); } $user = $_SESSION['user']; if (!isset($_GET['id'])) { die("Illegal Request"); } $id = $_GET['id']; $dbconnection = dbconnection::getConnection(); $garageGateway = new garageTableGateway($dbconnection); $busGateway = new busTableGateway($dbconnection); //get garage by id based on garageID of bus object $garages = $garageGateway->getGarageByBusId($id); //get bus by id based on the id passed in through the url $buses = $busGateway->getBusById($id); if (!$buses) { die("Illegal Request"); } ?> <html> <head> <meta charset="UTF-8"> <title></title> <meta name="viewport" content="width=device-width, initial-scale=1">
<?php /** * Created by IntelliJ IDEA. * User: rorypb * Date: 01/12/2015 * Time: 12:17 PM */ require_once 'connection.php'; require_once 'garageTableGateway.php'; if (!isset($_GET['id'])) { die("Halt"); } $id = $_GET['id']; $connection = Connection::getInstance(); $gateway = new garageTableGateway($connection); $statement = $gateway->getGarageByID($id); $row = $statement->fetch(PDO::FETCH_ASSOC); if (!$row) { die("Unable to get Garage By ID"); } ?> <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/pure-min.css"> <meta charset="UTF-8"> <title></title> </head>