-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbook.php
More file actions
58 lines (39 loc) · 1.3 KB
/
Copy pathbook.php
File metadata and controls
58 lines (39 loc) · 1.3 KB
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
<?php
// Controleur qui gère l'affichage du détail d'un livre
require "model/entity/user.php";
require "model/userManager.php";
require "model/entity/book.php";
require "model/bookManager.php";
require "model/dataBase.php";
//if id is on url
if(isset($_GET["id"])){
$id = htmlspecialchars($_GET["id"]);
}
//create variable manager
$bookManager = new bookManager();
$userManager = new userManager();
// get all users
$users = $userManager->getUsers();
//creat Book selected
$book = $bookManager->getBook($id);
$owner_id = $book->getOwner_id();
// get owner of the book
$userByBook = $userManager->getUserByBook($owner_id);
//UPDATE BOOK TO OWNER_ID = NULL
if(isset($_POST['updatenull']) && !empty($_POST['updatenull'])){
$bookManager->updateBookStatusNULL($book);
header("Location: index.php");
}
// UPDATE BOOK TO OWNER ID = ID IN $_POST
if(isset($_POST['lendbook']) && !empty($_POST['lendbook'])){
$lendUser = $userManager->getUserById($_POST['UserID']);
$bookManager->updateBookStatusUser($lendUser, $book);
header("Location: index.php");
}
// REMOVE DEFINITELY
if(isset($_POST['removebook']) && !empty($_POST['removebook'])){
$removedBook = $bookManager->getBook($id);
$bookManager->removeBook($removedBook);
header("Location: index.php");
}
require "view/bookView.php";