/** * Insert one baptismRegistry in the database * * @author Jonathan Sandoval <*****@*****.**> * @param BaptismRegistry $baptismRegistry The baptismRegistry to insert * @return boolean If was possible to insert */ static function addBaptismRegistry($baptismRegistry = null) { if ($baptismRegistry === null) { return false; } $number = $baptismRegistry->getNumber(); $book = $baptismRegistry->getBook(); $page = $baptismRegistry->getPage(); $reverse = $baptismRegistry->getReverse(); $singleBaptismRegistry = self::getSingleBaptismRegistry('number', $number, 'book', $book, 'page', $page, 'reverse', $reverse); if ($singleBaptismRegistry === null) { $tableBaptismRegistry = DatabaseManager::getNameTable('TABLE_BAPTISM_REGISTRY'); $query = "INSERT INTO {$tableBaptismRegistry}\r\n (number, book, page, reverse)\r\n VALUES \r\n ('{$number}', '{$book}', '{$page}', '{$reverse}')"; return DatabaseManager::singleAffectedRow($query); } else { return false; } }
$baptismReg->setBook($_POST["bookBookRegistryB"]); $baptismReg->setPage($_POST["pageBookRegistryB"]); $baptismReg->setNumber($_POST["numBookRegistryB"]); BaptismManager::updateBaptismRegistry($baptismReg); } } } else { echo "KO"; } } else { if ($_POST["status"] === 'update') { ConfirmationManager::updateConfirmation($confirmation); echo "OK"; 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());