require_once __DIR__ . "/../../Backend/LanguageSupport.php"; SessionManager::validateUserInPage('addRelationChurchRector.php'); //Get File contest from template $string = file_get_contents("template/AddRelationChurchRector.html"); //Remplace the nav $string = str_replace("|NavBar|", SessionManager::getNavBar(), $string); //Create a String of Church Options $churchString = ""; $churchs = ChurchManager::getAllChurchs('name', -1); foreach ($churchs as $singleChurch) { $churchString = $churchString . "<option> " . $singleChurch->getName() . "</option>\n"; } $string = str_replace("|ChurchOption|", $churchString, $string); //Create a String of Rector Options $rectorString = ""; $rectors = RectorManager::getAllRectors('name'); foreach ($rectors as $singleRector) { $idRector = $singleRector->getId(); $person = PersonManager::getSinglePerson('id', $idRector); $fullname = $person->getFullName(); $rectorString = $rectorString . "<option lang='{$idRector}' id='{$fullname}'> " . $fullname . "</option>\n"; } $string = str_replace("|RectorOption|", $rectorString, $string); //Create Button contest $saveButton = '<button type="button" class="btn btn-success" onclick=\'validateData("addRelationChurchRector.php", "' . SessionManager::getLastPage() . '")\'> <img src="../icons/save.png" width="50px"><br> <strong>^Save^</strong> </button>'; $cancelButton = '<button type="button" class="btn btn-success" onclick=\'href("' . SessionManager::getLastPage() . '")\'> <img src="../icons/delete.png" width="50px"><br> <strong>^Cancel^</strong>
$kchurch = $_GET["kchurch"]; $ktype = $_GET["ktype"]; $kstatus = $_GET["kstatus"]; $kposition = $_GET["kposition"]; $rector = new Rector(); $rector->setId($kid); $rector->setType($ktype); $rector->setStatus($kstatus); $rector->setPosition($kposition); $posibleNames = PersonManager::searchPersonsByNames($kname, $klastname1, $klastname2, false); $rector->setIdPerson($posibleNames); $posibleChurch = ChurchManager::simpleSearchChurch($kchurch, 'id', -1); $rector->setIdActualChurch($posibleChurch); $rectorRegistries = RectorManager::advancedSearchRector($rector, 'AND', $sortType, $numberPage); } else { $rectorRegistries = RectorManager::getAllRectors($sortType, $numberPage); } } //Get the total of registries $totalRegistries = DatabaseManager::getAffectedRows(); $affectedRegistries = DatabaseManager::registriesAffectedLastQuery(); if ($totalRegistries === 0 && $numberPage !== 0) { echo "<script src='../JS/functions.js'></script><script>nextPage('set', '0')</script>"; } $lastPage = floor($affectedRegistries / 10); if ($affectedRegistries % 10 === 0) { $lastPage = floor($affectedRegistries / 10) - 1; } //Create contest for button next and prev $nextButtonString = '<button type="button" class="btn btn-warning"