} else { $tid = '0'; } if ($_SESSION['userlevel'] != 1 && $_SESSION['userlevel'] != "") { $admin = true; } else { $admin = false; } if (isset($_POST['action']) && $_POST['action'] == 'Delete' && $admin) { $staff = new staff(); $staff->db_open(); $delete = $staff->delete_ticket($_GET['tid']); if ($delete) { header('Location: index.php'); } else { $error = htmlspecialchars($staff->get_error(), ENT_QUOTES); } } if (isset($_POST['action']) && $_POST['action'] == 'Close' && $admin) { $close = $ticket->close_ticket($_GET['tid']); if (!$close) { $error = htmlspecialchars($staff->get_error(), ENT_QUOTES); } } if (isset($_POST['action']) && $_POST['action'] == 'Open' && $admin) { $open = $ticket->close_ticket($_GET['tid'], TRUE); if (!$open) { $error = htmlspecialchars($staff->get_error(), ENT_QUOTES); } } if (isset($_POST['message'])) {
if (isset($_POST['deldepartment']) || isset($_POST['adddepartment']) || isset($_POST['delproduct']) || isset($_POST['addproduct'])) { $staff = new staff(); $staff->db_open(); if (isset($_POST['deldepartment'])) { $edit = $staff->edit_departments($_POST['deldepartment'], 'del'); } elseif (isset($_POST['adddepartment'])) { $edit = $staff->edit_departments($_POST['adddepartment'], 'add'); } elseif (isset($_POST['delproduct'])) { $edit = $staff->edit_products($_POST['delproduct'], 'del'); } elseif (isset($_POST['addproduct'])) { $edit = $staff->edit_products($_POST['addproduct'], 'add'); } if ($edit) { $successmsg = "Operation successfull"; } else { $errormsg = $staff->get_error(); } } if (isset($_POST['name'])) { $user = new user(); $user->db_open(); $adduser = $user->add_user($_POST['name'], $_POST['regemail'], $_POST['confirmemail'], $_POST['regpassword'], $_POST['confirmpassword'], 2); if ($adduser) { $successmsg = "New staff user crated."; } else { $errormsg = $user->get_error; } } $departments = $ticket->get_departments(); $products = $ticket->get_products(); ?>