$girlfriend = PersonManager::getSinglePerson('id', $_POST["idGirlfriend"]);
}
$boyfriend->setId($_POST["idBoyfriend"]);
$boyfriend->setNames($_POST["boyfriendName"]);
$boyfriend->setLastname1($_POST["lastname1Boyfriend"]);
$boyfriend->setLastname2($_POST["lastname2Boyfriend"]);
$girlfriend->setId($_POST["idGirlfriend"]);
$girlfriend->setNames($_POST["girlfriendName"]);
$girlfriend->setLastname1($_POST["lastname1Girlfriend"]);
$girlfriend->setLastname2($_POST["lastname2Girlfriend"]);
$marriage = new Marriage();
$marriage->setId($_POST["idMarriage"]);
$celb = DatabaseManager::singleDateToDatabaseDate($_POST["celebrationDate"]);
$marriage->setCelebrationDate($celb);
$marriage->setIdChurchProcess($churchProcess->getId());
$marriage->setIdChurchMarriage($churchMarriage->getId());
$marriage->setIdRector($_POST["rectorId"]);
if ($boyfriend->getId() === '0') {
    PersonManager::addPerson($boyfriend, 'true');
    $boyfriend = PersonManager::getSinglePerson('id', PersonManager::getLastID());
} else {
    PersonManager::updatePerson($boyfriend);
}
if ($girlfriend->getId() === '0') {
    PersonManager::addPerson($girlfriend, 'true');
    $girlfriend = PersonManager::getSinglePerson('id', PersonManager::getLastID());
} else {
    PersonManager::updatePerson($girlfriend);
}
$marriage->setIdBoyfriend($boyfriend->getId());
$marriage->setIdGirlfriend($girlfriend->getId());
        $klastname2b = $_GET["klastname2b"];
        $knameg = $_GET["knameg"];
        $klastname1g = $_GET["klastname1g"];
        $klastname2g = $_GET["klastname2g"];
        $kchurchc = $_GET["kchurch"];
        $kbook = $_GET["kbook"];
        $knumber = $_GET["knumber"];
        $kpape = $_GET["kpape"];
        $marriageSearch->setId($kid);
        $marriageSearch->setCelebrationDate($kcelebration);
        $posibleNames[0] = PersonManager::searchPersonsByNames($knameb, $klastname1b, $klastname2b, false);
        $posibleNames[1] = PersonManager::searchPersonsByNames($knameg, $klastname1g, $klastname2g, false);
        $marriageSearch->setIdBoyfriend($posibleNames[0]);
        $marriageSearch->setIdGirlfriend($posibleNames[1]);
        $posibleChurch = ChurchManager::simpleSearchChurch($kchurchc, 'id', -1);
        $marriageSearch->setIdChurchMarriage($posibleChurch);
        $marriageRegistry = MarriageManager::getSingleMarriageRegistry('book', $kbook, 'page', $kpape, 'number', $knumber);
        $marriageSearch->setIdBookRegistry($marriageRegistry);
        $marriageRegistries = MarriageManager::advancedSearchMarriage($marriageSearch, 'AND', $sortType, $numberPage);
    } else {
        $marriageRegistries = MarriageManager::getAllMarriages($sortType, $numberPage);
    }
}
//Get the total of registries
$totalRegistries = DatabaseManager::getAffectedRows();
$affectedRegistries = DatabaseManager::registriesAffectedLastQuery();
$lastPage = floor($affectedRegistries / 10);
if ($affectedRegistries % 10 === 0) {
    $lastPage = floor($affectedRegistries / 10) - 1;
}
if ($totalRegistries === 0 && $numberPage !== 0) {