added nicer overview and delete function

This commit is contained in:
2023-10-26 17:50:54 +02:00
parent 0f13bdea27
commit ddf13b2413
8 changed files with 81 additions and 23 deletions

View File

@ -15,7 +15,7 @@ class Dogs extends Page {
$this->addSubmenuItem('Hund hinzufügen','/dogs/add','fas fa-plus-circle');
if($_SESSION['user']->data['dogs'] && count($_SESSION['user']->data['dogs']) > 0)
{
$this->addSubmenuItem('divider','');
$this->addSubmenuItem('divider');
foreach($_SESSION['user']->data['dogs'] as $dogid)
{
$dog = new Dog();
@ -23,7 +23,6 @@ class Dogs extends Page {
$this->addSubmenuItem($dog->data['name'],'/dogs/overview/'.$dogid,'fas fa-dog');
}
}
}
function index() {
@ -67,6 +66,20 @@ class Dogs extends Page {
$this->set('template', 'edit.html');
}
function delete(){
$dogid = $this->params[0];
$d = new Dog();
if(!$d->isMyDog($dogid))
return 'Not your dog :(';
$d->load($dogid);
$d->delete();
$_SESSION['user']->removeDog($dogid);
$this->redirect('/dogs');
}
function edit() {
if($_REQUEST['submit'])
{
@ -74,10 +87,11 @@ class Dogs extends Page {
$name = $_REQUEST['name'];
$kennel_name = $_REQUEST['kennel_name'];
$dog_breed = $_REQUEST['dog_breed'];
$dog_size = $_REQUEST['dog_size'];
$dog_size = intval($_REQUEST['dog_size']);
$dog_birthday = $_REQUEST['dog_birthday'];
$agi_height_category = $_REQUEST['agi_height_category'];
$newphoto = false;
$active = intval($_REQUEST['agi_active']);
if($_FILES['photo'])
{
@ -142,6 +156,7 @@ class Dogs extends Page {
$dog->size = $dog_size;
$dog->birthday = $dog_birthday;
$dog->agility_size = $agi_height_category;
$dog->active = $active;
if($newphoto)
$dog->photo = $newphoto;