/
item_edit.php
83 lines (49 loc) · 1.67 KB
/
item_edit.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
73
74
75
76
77
78
79
80
81
82
83
<?php
require_once 'core/init.php';
$member_role=$_SESSION['roles'];
if(in_array("Laboratory Administrator", $member_role) || in_array("Related Lecturer", $member_role)){
}else{
header('location:restricted_page.php');
}
if(count($_POST) > 0) {
//print_r($_POST);
if (isset($_POST["reference"])){
$item_data = array(
"item_id" => $_POST["item_id"],
"item_name" => $_POST["item_name"],
"item_type" => $_POST["item_type"],
"item_technical_details" => $_POST["item_tec_desc"],
"item_description" => $_POST["item_desc"],
//"reference" => $_POST["reference"]
);}
else{
$item_data = array(
"item_id" => $_POST["item_id"],
"item_name" => $_POST["item_name"],
"item_type" => $_POST["item_type"],
"item_technical_details" => $_POST["item_tec_desc"],
"item_description" => $_POST["item_desc"],
//"reference" => null
);
}
//echo $_POST["itemTechDetEdit"];
$temp_path=$_FILES["item_picture"]["tmp_name"];
$img_type = pathinfo($_FILES["item_picture"]["name"],PATHINFO_EXTENSION);
move_uploaded_file($temp_path, "img/items/" . $_POST["item_name"]."."."png");
//$_SESSION['form_data'] = $item_data;
$_SESSION['form_data'] = $item_data;
//header("Location: item_add.php",true,303);
//die();
//print_r($item_data);
$item_to_edit = Item::search(array("item_id"=>$_POST["item_id"]));
if($item_to_edit->editItem($_SESSION['form_data'])){
$message = "You have successfully updated the item !!";
echo $message;
}
else{
$message = "The Item update was unsuccessful.";
echo $message;
}
unset($_SESSION["form_data"]);
}
?>