$godFather->setLastname1($_POST["lastname1GodFather"]); $godFather->setLastname2($_POST["lastname2GodFather"]); $godFather->setGender('M'); PersonManager::addPerson($godFather, 'true'); $godFather = PersonManager::getSinglePerson('id', PersonManager::getLastID()); } $communion->setIdGodFather($godFather->getId()); } //Get The Book Registry Data $reverse = substr($_POST["reverseBookRegistry"], 0, 1); if ($reverse === 'Y' || $reverse === 'S') { $reverse = 'Y'; } $bookRegistry = CommunionManager::getSingleCommunionRegistry('book', $_POST["bookBookRegistry"], 'page', $_POST["pageBookRegistry"], 'number', $_POST["numBookRegistry"], 'reverse', $reverse); if ($bookRegistry === NULL) { $bookRegistry = new CommunionRegistry(); $bookRegistry->setBook($_POST["bookBookRegistry"]); $bookRegistry->setPage($_POST["pageBookRegistry"]); $bookRegistry->setNumber($_POST["numBookRegistry"]); $bookRegistry->setReverse($reverse); CommunionManager::addCommunionRegistry($bookRegistry); $bookRegistry = CommunionManager::getSingleCommunionRegistry('book', $_POST["bookBookRegistry"], 'page', $_POST["pageBookRegistry"], 'number', $_POST["numBookRegistry"], 'reverse', substr($reverse, 0, 1)); } $communion->setIdBookRegistry(1); if ($bookRegistry !== NULL) { $communion->setIdBookRegistry($bookRegistry->getId()); } //Add the registry if ($_SESSION["user_type"] != 'A') { if ($_SESSION["user_church"] == $church->getId()) { if ($_POST["status"] === 'insert') {
/** * insert one communionRegistry in the database * * @author Jonathan Sandoval <*****@*****.**> * @param CommunionRegistry $communionRegistry The communionRegistry to insert * @return boolean If was possible to insert */ static function addCommunionRegistry($communionRegistry = null) { if ($communionRegistry === null) { return false; } $number = $communionRegistry->getNumber(); $book = $communionRegistry->getBook(); $page = $communionRegistry->getPage(); $reverse = $communionRegistry->getReverse(); $singleCommunionRegistry = self::getSingleCommunionRegistry('number', $number, 'book', $book, 'page', $page, 'reverse', $reverse); if ($singleCommunionRegistry === null) { $tableCommunionRegistry = DatabaseManager::getNameTable('TABLE_COMMUNION_REGISTRY'); $query = "INSERT INTO {$tableCommunionRegistry}\r\n (number, book, page, reverse)\r\n VALUES \r\n ('{$number}', '{$book}', '{$page}', '{$reverse}')"; return DatabaseManager::singleAffectedRow($query); } else { return false; } }