53 lines
1.6 KiB
PHP
Executable File
53 lines
1.6 KiB
PHP
Executable File
<?php #lnk/anwesenheiten_personal/class.php
|
|
|
|
class Anwesenheiten_PersonalLink extends BaseLink
|
|
{
|
|
protected function insert($ids) {
|
|
if ($ids["Anwesenheiten"]==null || $ids["Personal"]==null) {
|
|
return 400;
|
|
}
|
|
if (!$this->man->user->HasRight($this->adminRight)) {
|
|
return 403; // You shall not pass!
|
|
}
|
|
|
|
$qry = "INSERT INTO Anwesenheiten_Personal (Anwesenheiten, Personal) VALUES (?, ?)";
|
|
if ($stmt = $this->db->prepare($qry)) {
|
|
$stmt->bind_param("ii", $ids["Anwesenheiten"], $ids["Personal"]);
|
|
$stmt->execute();
|
|
if (1==$stmt->affected_rows) {
|
|
$this->man->AddMessage("Personal zu Anwesenheitsliste hinzugefügt!");
|
|
return 201;
|
|
} else {
|
|
return 200;
|
|
}
|
|
} else {
|
|
//$this->man->AddMessage("Mysql error: ".$this->db->error);
|
|
}
|
|
return 500; // Should not reach this stage
|
|
}
|
|
|
|
protected function remove($ids) {
|
|
if ($ids["Anwesenheiten"]==null || $ids["Personal"]==null) {
|
|
return 400;
|
|
}
|
|
if (!$this->man->user->HasRight($this->adminRight)) {
|
|
return 403; // You shall not pass!
|
|
}
|
|
|
|
$qry = "DELETE FROM Anwesenheiten_Personal WHERE Anwesenheiten = ? AND Personal = ?";
|
|
if ($stmt = $this->db->prepare($qry)) {
|
|
$stmt->bind_param("ii", $ids["Anwesenheiten"], $ids["Personal"]);
|
|
$stmt->execute();
|
|
if (1==$stmt->affected_rows) {
|
|
$this->man->AddMessage("Personal aus Anwesenheitsliste entfernt!");
|
|
return 200;
|
|
} else {
|
|
return 404;
|
|
}
|
|
} else {
|
|
$this->man->AddMessage("Mysql error: ".$this->db->error);
|
|
return 500;
|
|
}
|
|
}
|
|
}
|