if ($_POST["baptismId"] === '0') { if ($_POST["baptismChurch"] != "XXXXXXXXXX") { $bookRegistry = new BaptismRegistry(); $bookRegistry->setBook($_POST["bookBookRegistryB"]); $bookRegistry->setPage($_POST["pageBookRegistryB"]); $bookRegistry->setNumber($_POST["numBookRegistryB"]); BaptismManager::addBaptismRegistry($bookRegistry); $bookRegistry = BaptismManager::getSingleBaptismRegistry('book', $_POST["bookBookRegistryB"], 'page', $_POST["pageBookRegistryB"], 'number', $_POST["numBookRegistryB"]); $baptism = new Baptism('0', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL'); $baptism->setIdCivilRegistry('1'); $celb = DatabaseManager::singleDateToDatabaseDate($_POST["baptismDate"]); $baptism->setCelebrationDate($celb); $church = ChurchManager::getSingleChurch('name', $_POST["baptismChurch"]); if ($church !== NULL) { $baptism->setIdChurch($church->getId()); $baptism->setIdRector(RectorManager::getSingleRector('idActualChurch', $church->getId())->getId()); } $baptism->setIdOwner($child->getId()); $baptism->setIdBookRegistry($bookRegistry->getId()); BaptismManager::addBaptism($baptism); } } else { $baptism = BaptismManager::getSingleBaptism('id', $_POST["baptismId"]); if ($baptism !== NULL) { $celb = DatabaseManager::singleDateToDatabaseDate($_POST["baptismDate"]); $baptism->setCelebrationDate($celb); $church = ChurchManager::getSingleChurch('name', $_POST["baptismChurch"]); if ($church !== NULL) { $baptism->setIdChurch($church->getId()); } BaptismManager::updateBaptism($baptism);
if ($_POST["idChild"] !== '0') { $child = PersonManager::getSinglePerson('id', $_POST["idChild"]); } $child->setId($_POST["idChild"]); $child->setNames($_POST["nameChild"]); $child->setLastname1($_POST["lastname1Child"]); $child->setLastname2($_POST["lastname2Child"]); $child->setGender(substr($_POST["genderChild"], 0, 1)); $baptism = new Baptism(); $baptism->setId($_POST["idBaptism"]); $celb = DatabaseManager::singleDateToDatabaseDate($_POST["celebrationDate"]); $baptism->setCelebrationDate($celb); $baptism->setBornDate(DatabaseManager::singleDateToDatabaseDate($_POST["bornDateChild"])); $baptism->setBornPlace($_POST["bornPlaceChild"]); $baptism->setIdChurch($church->getId()); $baptism->setIdRector($_POST["rectorId"]); $legitimate = substr($_POST["legitimateChild"], 0, 1); if ($legitimate === 'S' || $legitimate === 'Y') { $baptism->setLegitimate('Y'); } else { $baptism->setLegitimate('N'); } //Data Process for the Father $father = new Person(); if ($_POST["idFather"] !== '0') { $father = PersonManager::getSinglePerson('id', $_POST["idFather"]); $father->setId($_POST["idFather"]); $father->setNames($_POST["nameFather"]); $father->setLastname1($_POST["lastname1Father"]); $father->setLastname2($_POST["lastname2Father"]); $father->setGender('M');