<?php

$lib = new Legenda();
$MSG = '';
if (!empty($_POST['dodaj_legenda'])) {
    if ($lib->addLegenda($_POST['opis_legenda'], $_POST['symbol_legenda'])) {
        $message = 'Legenda została pomyślnie dodana';
        $MSG = Msg($message, 1);
    } else {
        $message = 'Błąd dodawania legendy';
        $MSG = Msg($message, 0);
    }
}
if (!empty($_POST['zapisz_legenda'])) {
    if ($lib->updateLegenda($_POST['id_legenda'], $_POST['opis_legenda'], $_POST['symbol_legenda'])) {
        $message = 'Legenda została pomyślnie zaktualizowana';
        $MSG = Msg($message, 1);
    } else {
        $message = 'Błąd aktualizacji legendy';
        $MSG = Msg($message, 0);
    }
}
if (!empty($_POST['usun_legenda'])) {
    if ($lib->deleteLegenda($_POST['id_legenda'])) {
        $message = 'Legenda została pomyślnie usunięta';
        $MSG = Msg($message, 1);
    } else {
        $message = 'Błąd usuwania legendy';
        $MSG = Msg($message, 0);
    }
}