/**
 * Created by PhpStorm.
 * User: Prashanth
 * Date: 11/21/2015
 * Time: 9:17 PM
 */
session_start();
if (!isset($_SESSION['user'])) {
    header("Location: index.php");
    exit;
}
require_once '../controller/SqliteRepository.php';
require_once '../model/Customer.php';
require_once '../model/Employee.php';
require_once '../model/Payment.php';
$repo = new \pnaika\finals\SqliteRepository();
$customerId = isset($_GET['id']) ? $_GET['id'] : '';
$customer = $repo->getCustomerById($customerId);
$parkingHours = isset($_POST['timeofParking']) ? input($_POST['timeofParking']) : '';
$formIsValid = true;
$hoursFieldErr = '';
$time = date("d M Y - h:i:s A");
if (empty($parkingHours)) {
    $formIsValid = false;
    $hoursFieldErr = '<span style="color: #f00;">REQUIRED FIELD!</span>';
}
function input($data)
{
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
 $passwordErr = '';
 $time = date("d M Y - h:i:s A");
 if (empty($employeeName)) {
     $formIsValid = false;
     $employeeNameErr = '<span style="color: #f00;">NAME IS A REQUIRED FIELD!</span>';
 }
 if (empty($password)) {
     $formIsValid = false;
     $passwordErr = '<span style="color: #f00;">PASSWORD IS MANDATORY!</span>';
 }
 ?>
     <?php 
 if ($formIsValid) {
     ?>
         <?php 
     $repo = new \pnaika\finals\SqliteRepository();
     $employeeDetails = new \pnaika\finals\Employee();
     $employeeDetails->setEmployeeName($employeeName);
     $hashPassword = password_hash($password, PASSWORD_DEFAULT);
     $employeeDetails->setPassword($hashPassword);
     $employeeDetails->setEmpAddress($address);
     $employeeDetails->setEmpEmail($email);
     $employeeDetails->setEmpPhoneNumber($phoneNumber);
     $employeeDetails->setEmpLastUpdate($time);
     $repo->saveEmployee($employeeDetails);
     ?>
         <header></header>
         <div class="alert alert-success" role="alert">
         <h2>EMPLOYEE PROFILE GOT CREATED!</h2>
         <h5>EMPLOYEE NEED TO ACCESS THEIR PROFILE WITH NEWLY CREATED USERNAME AND PASSWORD </h5>
         </div>
 * Created by PhpStorm.
 * User: Prashanth
 * Date: 11/22/2015
 * Time: 1:00 PM
 */
session_start();
if (!isset($_SESSION['user'])) {
    header("Location: index.php");
    exit;
}
require_once '../controller/SqliteRepository.php';
require_once '../model/Customer.php';
require_once '../model/Employee.php';
require_once '../model/Payment.php';
require_once '../model/Admin.php';
$repo = new \pnaika\finals\SqliteRepository();
$time = date("d M Y - h:i:s A");
if (isset($_GET['empId'])) {
    $employeeId = $_GET['empId'];
    $employee = $repo->getEmployeeById($employeeId);
    $role = 'EMPLOYEE';
} else {
    if (isset($_GET['adminId'])) {
        $adminId = $_GET['adminId'];
        $role = 'ADMIN';
    }
}
$allCustomers = $repo->getAllCustomers();
?>

<!DOCTYPE html>
<?php

/**
 * Created by PhpStorm.
 * User: Prashanth
 * Date: 11/21/2015
 * Time: 9:17 PM
 */
require_once '../controller/SqliteRepository.php';
require_once '../model/Customer.php';
require_once '../model/Employee.php';
$repo = new \pnaika\finals\SqliteRepository();
$employeeId = isset($_GET['empId']) ? $_GET['empId'] : '';
$employee = $repo->getEmployeeById($employeeId);
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>EMPLOYEE HOME</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <link rel="stylesheet" href="../style/style.css">
    <link href='http://fonts.googleapis.com/css?family=Lora:400,700' rel='stylesheet' type='text/css'/>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css"/>
    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"/>
</head>
<body>
<a href="#"><img class="logo" src="../images/logo/gpsLogo.jpg" alt="CCS" title="GLOBAL PARKING SYSTEM"></a>
<div id="wrapper">
Example #5
0
<?php

/**
 * Created by PhpStorm.
 * User: Prashanth
 * Date: 11/21/2015
 * Time: 8:05 PM
 */
session_start();
require_once '../controller/SqliteRepository.php';
require_once '../model/Customer.php';
require_once '../model/Employee.php';
$u = new \pnaika\finals\SqliteRepository();
if (isset($_GET['logout'])) {
    session_destroy();
    header("Location: index.php");
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $username = isset($_POST['userName']) ? trim($_POST['userName']) : '';
    $password = isset($_POST['password']) ? trim($_POST['password']) : '';
    $userType = isset($_POST['userType']) ? trim($_POST['userType']) : '';
    if ($userType == 'customer') {
        $res = $u->getCustomerDetails($username, $password);
        $id = $res->getId();
        $passwordValue = $res->getPassword();
        $isValid = password_verify($password, $passwordValue);
        if ($username == $res->getCustomerName() && $isValid) {
            $_SESSION['user'] = $username;
            header("Location: customerHome.php?id={$id}");
        } else {
            print '<div class="alert alert-danger" role="alert"><strong>INVALID LOGIN ! </strong>' . strtoupper($username) . ' & ' . 'PASSWORD ENTERED DOES NOT MATCH IN OUR SYSTEM. ' . '</div>';
<?php

/**
 * Created by PhpStorm.
 * User: Prashanth
 * Date: 10/15/2015
 * Time: 7:03 PM
 */
session_start();
if (!isset($_SESSION['user'])) {
    header("Location: index.php");
    exit;
}
require_once '../controller/SqliteRepository.php';
require_once '../model/Employee.php';
$repo = new \pnaika\finals\SqliteRepository();
$customerId = isset($_POST['custId']) ? $_POST['custId'] : '';
$adminId = $_POST['adminId'];
?>

<?php 
if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['custId'])) {
    $repo->deleteCustomer($customerId);
    ?>
    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>DELETE CUSTOMER</title>
        <link rel="stylesheet" href="../style/style.css">
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
/**
 * Created by PhpStorm.
 * User: Prashanth
 * Date: 11/22/2015
 * Time: 1:00 PM
 */
session_start();
if (!isset($_SESSION['user'])) {
    header("Location: index.php");
    exit;
}
require_once '../controller/SqliteRepository.php';
require_once '../model/Customer.php';
require_once '../model/Employee.php';
require_once '../model/Payment.php';
$repo = new \pnaika\finals\SqliteRepository();
$time = date("d M Y - h:i:s A");
$customerId = isset($_GET['id']) ? $_GET['id'] : '';
$employeeId = isset($_GET['empId']) ? $_GET['empId'] : '';
if ($customerId != '') {
    $customer = $repo->getCustomerById($customerId);
    $payments = $repo->getPaymentByCustId($customerId);
} elseif ($employeeId != '') {
    $employee = $repo->getEmployeeById($employeeId);
    $payments = $repo->getAllPayments();
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
<?php

/**
 * Created by PhpStorm.
 * User: Prashanth
 * Date: 11/21/2015
 * Time: 9:17 PM
 */
require_once '../controller/SqliteRepository.php';
require_once '../model/Customer.php';
require_once '../model/Employee.php';
require_once '../model/Admin.php';
$repo = new \pnaika\finals\SqliteRepository();
$adminId = isset($_GET['adminId']) ? $_GET['adminId'] : '';
$employee = $repo->getAllEmployees();
$customer = $repo->getAllCustomers();
$payment = $repo->getAllPayments();
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ADMIN HOME</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <link rel="stylesheet" href="../style/style.css">
    <link href='http://fonts.googleapis.com/css?family=Lora:400,700' rel='stylesheet' type='text/css'/>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css"/>
    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"/>
</head>
/**
 * Created by PhpStorm.
 * User: Prashanth
 * Date: 11/22/2015
 * Time: 1:00 PM
 */
session_start();
if (!isset($_SESSION['user'])) {
    header("Location: index.php");
    exit;
}
require_once '../controller/SqliteRepository.php';
require_once '../model/Customer.php';
require_once '../model/Employee.php';
require_once '../model/Payment.php';
$repo = new \pnaika\finals\SqliteRepository();
$time = date("d M Y - h:i:s A");
if (isset($_GET['empId'])) {
    $employeeId = $_GET['empId'];
    $role = 'EMPLOYEE';
    $employee = $repo->getEmployeeById($employeeId);
} else {
    if (isset($_GET['adminId'])) {
        $adminId = $_GET['adminId'];
        $role = 'ADMIN';
    }
}
$allEmployees = $repo->getAllEmployees();
?>

<!DOCTYPE html>
/**
 * Created by PhpStorm.
 * User: Prashanth
 * Date: 11/22/2015
 * Time: 1:00 PM
 */
session_start();
if (!isset($_SESSION['user'])) {
    header("Location: index.php");
    exit;
}
require_once '../controller/SqliteRepository.php';
require_once '../model/Customer.php';
require_once '../model/Employee.php';
require_once '../model/Payment.php';
$repo = new \pnaika\finals\SqliteRepository();
$time = date("d M Y - h:i:s A");
$customerId = isset($_GET['custId']) ? $_GET['custId'] : '';
$employeeId = isset($_GET['empId']) ? $_GET['empId'] : '';
$paymentId = isset($_GET['payId']) ? $_GET['payId'] : '';
if ($_GET['ROLE'] === 'Cust') {
    $customer = $repo->getCustomerById($customerId);
    $paymentDetails = $repo->getPaymentById($paymentId);
} elseif ($_GET['ROLE'] === 'Emp') {
    $employee = $repo->getEmployeeById($employeeId);
    $paymentDetails = $repo->getPaymentById($paymentId);
    $customer = $repo->getCustomerById($paymentDetails->getCustomerId());
}
?>

<!DOCTYPE html>
    $passwordErr = '';
    $time = date("d M Y - h:i:s A");
    if (empty($customerName)) {
        $formIsValid = false;
        $customerNameErr = '<span style="color: #f00;">NAME IS A REQUIRED FIELD!</span>';
    }
    if (empty($password)) {
        $formIsValid = false;
        $passwordErr = '<span style="color: #f00;">PASSWORD IS MANDATORY!</span>';
    }
    ?>
        <?php 
    if ($formIsValid) {
        ?>
            <?php 
        $repo = new \pnaika\finals\SqliteRepository();
        $customerDetails = new \pnaika\finals\Customer();
        $customerDetails->setCustomerName($customerName);
        $hashPassword = password_hash($password, PASSWORD_DEFAULT);
        $customerDetails->setPassword($hashPassword);
        $customerDetails->setAddress($address);
        $customerDetails->setEmail($email);
        $customerDetails->setPhoneNumber($phoneNumber);
        $customerDetails->setLastUpdate($time);
        $repo->saveCustomer($customerDetails);
        ?>
            <header></header>

            <div class="alert alert-success" role="alert">
                <h2>CUSTOMER PROFILE GOT CREATED!</h2>
                <h5>CUSTOMER SHOULD USE NEWLY CREATED USERNAME AND PASSWORD TO LOGIN :) </h5>
<?php

session_start();
if (!isset($_SESSION['user'])) {
    header("Location: index.php");
    exit;
}
require_once '../controller/SqliteRepository.php';
require_once '../model/Employee.php';
$repo = new \pnaika\finals\SqliteRepository();
function input($data)
{
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    return $data;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['empId'])) {
    ?>
    <?php 
    $employee = $repo->getEmployeeById($_POST['empId']);
    ?>
    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>EMPLOYEE PROFILE</title>
        <link rel="stylesheet" href="../style/style.css">
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <link href='http://fonts.googleapis.com/css?family=Lora:400,700' rel='stylesheet' type='text/css'/>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"/>
/**
 * Created by PhpStorm.
 * User: Prashanth
 * Date: 11/21/2015
 * Time: 9:17 PM
 */
session_start();
if (!isset($_SESSION['user'])) {
    header("Location: index.php");
    exit;
}
require_once '../controller/SqliteRepository.php';
require_once '../model/Customer.php';
require_once '../model/Employee.php';
$repo = new \pnaika\finals\SqliteRepository();
$customerId = isset($_GET['id']) ? $_GET['id'] : '';
$customer = $repo->getCustomerById($customerId);
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>CUSTOMER HOME</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <link rel="stylesheet" href="../style/style.css">
    <link href='http://fonts.googleapis.com/css?family=Lora:400,700' rel='stylesheet' type='text/css'/>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css"/>
    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"/>
<?php

session_start();
if (!isset($_SESSION['user'])) {
    header("Location: index.php");
    exit;
}
require_once '../controller/SqliteRepository.php';
require_once '../model/Customer.php';
$repo = new \pnaika\finals\SqliteRepository();
function input($data)
{
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    return $data;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['id'])) {
    ?>
    <?php 
    $customer = $repo->getCustomerById($_POST['id']);
    ?>
    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>CUSTOMER PROFILE</title>
        <link rel="stylesheet" href="../style/style.css">
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <link href='http://fonts.googleapis.com/css?family=Lora:400,700' rel='stylesheet' type='text/css'/>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"/>
<?php

/**
 * Created by PhpStorm.
 * User: Prashanth
 * Date: 10/15/2015
 * Time: 7:03 PM
 */
session_start();
if (!isset($_SESSION['user'])) {
    header("Location: index.php");
    exit;
}
require_once '../controller/SqliteRepository.php';
require_once '../model/Employee.php';
$repo = new \pnaika\finals\SqliteRepository();
$employeeId = isset($_POST['empId']) ? $_POST['empId'] : '';
$adminId = $_POST['adminId'];
?>

<?php 
if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['empId'])) {
    $repo->deleteEmployee($employeeId);
    ?>
    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>DELETE EMPLOYEE</title>
        <link rel="stylesheet" href="../style/style.css">
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
/**
 * Created by PhpStorm.
 * User: Prashanth
 * Date: 10/15/2015
 * Time: 7:03 PM
 */
session_start();
if (!isset($_SESSION['user'])) {
    header("Location: index.php");
    exit;
}
require_once '../controller/SqliteRepository.php';
require_once '../model/Employee.php';
require_once '../model/Payment.php';
$repo = new \pnaika\finals\SqliteRepository();
$employeeId = isset($_GET['empId']) ? $_GET['empId'] : '';
$paymentId = isset($_GET['payId']) ? $_GET['payId'] : '';
?>

<?php 
if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['payId'])) {
    $repo->deletePayment($paymentId);
    ?>
    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>DELETE PAYMENT</title>
        <link rel="stylesheet" href="../style/style.css">
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>