57 lines
1.6 KiB
PHP
57 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Blog\Controller;
|
|
|
|
use Blog\Model\GutscheinModel;
|
|
|
|
class GutscheinController {
|
|
|
|
private $model;
|
|
private $view;
|
|
|
|
public function __construct($view) {
|
|
$this->model = new GutscheinModel();
|
|
$this->view = $view;
|
|
}
|
|
|
|
public function showGutscheine() {
|
|
$gutscheine = $this->model->getGutscheine();
|
|
$this->view->setVars(['gutscheine' => $gutscheine]);
|
|
}
|
|
|
|
public function createGutschein() {
|
|
$data = [
|
|
'code' => $_POST['code'] ?? null,
|
|
'rabatt' => $_POST['rabatt'] ?? null,
|
|
'ausstellungid' => $_POST['ausstellungid'] ?? null,
|
|
'gueltigkeit' => $_POST['gueltigkeit'] ?? null
|
|
];
|
|
$erg = $this->model->createGutschein($data);
|
|
$this->view->setVars(['gutschein' => $erg]);
|
|
exit;
|
|
}
|
|
|
|
public function editGutscheinForm() {
|
|
$id = $_GET['gutscheinid'];
|
|
if ($id) {
|
|
$gutschein = $this->model->getGutschein($id);
|
|
$this->view->setVars(['gutschein' => $gutschein]);
|
|
}
|
|
}
|
|
|
|
public function updateGutschein() {
|
|
$id = $_POST['gutscheinid'];
|
|
$data = [
|
|
'code' => $_POST['code'] ?? null,
|
|
'rabatt' => $_POST['rabatt'] ?? null,
|
|
'ausstellungid' => $_POST['ausstellungid'] ?? null,
|
|
'gueltigkeit' => $_POST['gueltigkeit'] ?? null
|
|
];
|
|
$this->model->updateGutschein($id, $data);
|
|
}
|
|
|
|
public function deleteGutschein() {
|
|
$id = $_GET['gutscheinid'] ?? null;
|
|
$this->model->deleteGutschein($id);
|
|
}
|
|
} |