| 1 |
09481cf6 |
Josh |
<?php
|
| 2 |
09481cf6 |
Josh |
|
| 3 |
09481cf6 |
Josh |
/*
|
| 4 |
09481cf6 |
Josh |
|
| 5 |
6ebba44e |
Cameron |
Copyright (C) 2010, All Rights Reserved.
|
| 6 |
09481cf6 |
Josh |
|
| 7 |
09481cf6 |
Josh |
This file is part of RPInventory.
|
| 8 |
09481cf6 |
Josh |
|
| 9 |
09481cf6 |
Josh |
RPInventory is free software: you can redistribute it and/or modify
|
| 10 |
09481cf6 |
Josh |
it under the terms of the GNU General Public License as published by
|
| 11 |
09481cf6 |
Josh |
the Free Software Foundation, either version 3 of the License, or
|
| 12 |
09481cf6 |
Josh |
(at your option) any later version.
|
| 13 |
09481cf6 |
Josh |
|
| 14 |
09481cf6 |
Josh |
RPInventory is distributed in the hope that it will be useful,
|
| 15 |
09481cf6 |
Josh |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 |
09481cf6 |
Josh |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 17 |
09481cf6 |
Josh |
GNU General Public License for more details.
|
| 18 |
09481cf6 |
Josh |
|
| 19 |
09481cf6 |
Josh |
You should have received a copy of the GNU General Public License
|
| 20 |
09481cf6 |
Josh |
along with RPInventory. If not, see <http://www.gnu.org/licenses/>.
|
| 21 |
09481cf6 |
Josh |
|
| 22 |
edcaaf40 |
Josh |
*/
|
| 23 |
09481cf6 |
Josh |
require_once("lib/auth.lib.php"); //Session
|
| 24 |
edcaaf40 |
Josh |
require_once('lib/borrowers.lib.php');
|
| 25 |
edcaaf40 |
Josh |
require_once('lib/addresses.lib.php');
|
| 26 |
edcaaf40 |
Josh |
require_once('lib/loans.lib.php');
|
| 27 |
edcaaf40 |
Josh |
require_once('lib/checkouts.lib.php');
|
| 28 |
7fe4f7a5 |
Josh |
require_once('class/database.class.php');
|
| 29 |
7fe4f7a5 |
Josh |
|
| 30 |
7fe4f7a5 |
Josh |
// Connect
|
| 31 |
7fe4f7a5 |
Josh |
$db = new database();
|
| 32 |
09481cf6 |
Josh |
|
| 33 |
09481cf6 |
Josh |
//Authenticate
|
| 34 |
09481cf6 |
Josh |
$auth = GetAuthority();
|
| 35 |
96dbfe0a |
Josh |
if($auth < 1)
|
| 36 |
edcaaf40 |
Josh |
die("You dont have permission to access this page");
|
| 37 |
09481cf6 |
Josh |
|
| 38 |
09481cf6 |
Josh |
//id
|
| 39 |
09481cf6 |
Josh |
$id = (int)$_GET["id"];
|
| 40 |
09481cf6 |
Josh |
if($id == 0)
|
| 41 |
edcaaf40 |
Josh |
die("Invalid ID");
|
| 42 |
d866d7e9 |
Josh |
|
| 43 |
96dbfe0a |
Josh |
// Don't delete active borrowers
|
| 44 |
7fe4f7a5 |
Josh |
$records = getBorrowerActiveLoans($id, $db);
|
| 45 |
edcaaf40 |
Josh |
if (count($records) > 0) {
|
| 46 |
96dbfe0a |
Josh |
die('Cannot delete an active borrower');
|
| 47 |
96dbfe0a |
Josh |
}
|
| 48 |
96dbfe0a |
Josh |
|
| 49 |
7fe4f7a5 |
Josh |
$records = getBorrowerActiveCheckouts($id, $db);
|
| 50 |
edcaaf40 |
Josh |
if (count($records) > 0) {
|
| 51 |
96dbfe0a |
Josh |
die('Cannot delete an active borrower');
|
| 52 |
96dbfe0a |
Josh |
}
|
| 53 |
96dbfe0a |
Josh |
|
| 54 |
d866d7e9 |
Josh |
// Get the address_id of the borrower
|
| 55 |
7fe4f7a5 |
Josh |
$address = getAddressFromBorrower($id, $db);
|
| 56 |
edcaaf40 |
Josh |
$address_id = $address->address_id;
|
| 57 |
edcaaf40 |
Josh |
|
| 58 |
09481cf6 |
Josh |
//Remove login
|
| 59 |
7fe4f7a5 |
Josh |
deleteBorrower($id, $db);
|
| 60 |
edcaaf40 |
Josh |
|
| 61 |
d866d7e9 |
Josh |
// Remove the address
|
| 62 |
7fe4f7a5 |
Josh |
deleteAddress($address_id, $db);
|
| 63 |
7fe4f7a5 |
Josh |
|
| 64 |
7fe4f7a5 |
Josh |
$db->close();
|
| 65 |
09481cf6 |
Josh |
|
| 66 |
09481cf6 |
Josh |
header('Location: manageBorrowers.php');
|
| 67 |
edcaaf40 |
Josh |
|
| 68 |
09481cf6 |
Josh |
?> |