require_once __DIR__ . "/../../Backend/ChurchManager.php"; require_once __DIR__ . "/../../Backend/DefuntionManager.php"; require_once __DIR__ . "/../../Backend/PersonManager.php"; require_once __DIR__ . "/../../Backend/LanguageSupport.php"; SessionManager::validateUserInPage('defuntionLook.php'); //Get File contest from template $string = file_get_contents("template/DefuntionInsertion.html"); if (!isset($_GET) || $_GET["id"] === NULL) { echo "<script src='../JS/functions.js'></script><script>href('main.php')</script>"; } //Remplace the nav $string = str_replace("|title|", 'Look Defuntion', $string); $string = str_replace("|NavBar|", SessionManager::getNavBar(), $string); //Get The Data of the Defuntion $idDefuntion = $_GET["id"]; $defuntion = DefuntionManager::getSingleDefuntion('id', $idDefuntion); $ownerId = $defuntion->getIdOwner(); $owner = PersonManager::getSinglePerson('id', $ownerId); $churchId = $defuntion->getIdChurch(); $defuntionDate = DatabaseManager::databaseDateToSingleDate($defuntion->getDeadDate()); //Create a String of options of Last Church $churchString = ""; $churchs = ChurchManager::getAllChurchs('name'); foreach ($churchs as $singleChurch) { if ($singleChurch->getId() === $churchId) { $churchString = $churchString . "<option selected> " . $singleChurch->getName() . "</option>\n"; } else { $churchString = $churchString . "<option> " . $singleChurch->getName() . "</option>\n"; } } $string = str_replace("|ChurchOption|", $churchString, $string);
<?php require_once __DIR__ . "/../../../Backend/SessionManager.php"; require_once __DIR__ . "/../../../Backend/DefuntionManager.php"; if (!isset($_GET) || $_GET["idDefuntion"] === NULL) { echo "KO"; } else { $defuntion = DefuntionManager::getSingleDefuntion("id", $_GET["idDefuntion"]); if ($defuntion === NULL) { echo "KO"; } else { if (!isset($_SESSION) || $_SESSION["user_church"] === NULL) { echo "KO"; } else { //Check for permision if ($_SESSION["user_type"] == 'A' || $_SESSION["user_church"] == $defuntion->getIdChurch()) { if (DefuntionManager::removeDefuntion($defuntion)) { echo "OK"; } else { echo "KO"; } } } } }