/** * Insert one changes logs to the database * * @author Jonathan Sandoval <*****@*****.**> * @param String $typéChange The type of the change to efect (insert, update, delete) * @param String $descriptionC The description of the change * @return boolean If was posible to insert the data */ static function addChangesLogs($typeChange = "", $descriptionC = "") { if ($typeChange == "") { return false; } $date = time(); $user = SessionManager::getCurrentUser(); if ($user === NULL) { return false; } $idUser = $user->getId(); $tableChangesLogs = DatabaseManager::getNameTable('TABLE_CHANGES_LOGS'); $query = "INSERT INTO {$tableChangesLogs}\r\n (date, idUser, type, description) \r\n VALUES \r\n ({$date}, {$idUser}, '{$typeChange}', '{$descriptionC}')"; return DatabaseManager::singleAffectedRow($query); }
/** * update one confirmation in the database * * @author Jonathan Sandoval <*****@*****.**> * @param Confirmation $confirmation The confirmation to update * @return boolean if was possible to update */ static function updateConfirmation($confirmation = null) { if ($confirmation === null) { return false; } $tableConfirmation = DatabaseManager::getNameTable('TABLE_CONFIRMATION'); $id = $confirmation->getId(); $celebrationDate = $confirmation->getCelebrationDate(); $idGodFather = $confirmation->getIdGodFather(); $idBookRegistry = $confirmation->getIdBookRegistry(); $idChurch = $confirmation->getIdChurch(); $idRector = $confirmation->getIdRector(); $idOwner = $confirmation->getIdOwner(); $query = "UPDATE {$tableConfirmation}\r\n SET confirmationDate = '{$celebrationDate}', \r\n idOwner = '{$idOwner}', \r\n idGodFather = '{$idGodFather}', \r\n idConfirmationRegistry = '{$idBookRegistry}', \r\n idChurch = '{$idChurch}', \r\n idRector = '{$idRector}' \r\n WHERE {$tableConfirmation}.id = {$id}"; $person = PersonManager::getSinglePerson("id", $idOwner); ChangesLogsManager::addChangesLogs("C", "Confirmacion de " . $person->getFullNameBeginName()); return DatabaseManager::singleAffectedRow($query); }
/** * Update one baptism in the database * * @author Jonathan Sandoval <*****@*****.**> * @param Baptism $baptism The baptism to update * @return boolean if was possible to update */ static function updateBaptism($baptism = null) { if ($baptism === null) { return false; } $tableBaptism = DatabaseManager::getNameTable('TABLE_BAPTISM'); $id = $baptism->getId(); $celebrationDate = $baptism->getCelebrationDate(); $bornPlace = $baptism->getBornPlace(); $bornDate = $baptism->getBornDate(); $legitimate = $baptism->getLegitimate(); $idGodFather = $baptism->getIdGodFather(); $idGodMother = $baptism->getIdGodMother(); $idBookRegistry = $baptism->getIdBookRegistry(); $idCivilRegistry = $baptism->getIdCivilRegistry(); $idChurch = $baptism->getIdChurch(); $idRector = $baptism->getIdRector(); $idOwner = $baptism->getIdOwner(); $query = "UPDATE {$tableBaptism}\r\n SET baptismDate = '{$celebrationDate}', \r\n bornPlace = '{$bornPlace}', \r\n bornDate = '{$bornDate}', \r\n legitimate = '{$legitimate}', \r\n idOwner = '{$idOwner}', \r\n idGodFather = '{$idGodFather}', \r\n idGodMother = '{$idGodMother}', \r\n idCivilRegistry = '{$idCivilRegistry}', \r\n idBookRegistry = '{$idBookRegistry}', \r\n idChurch = '{$idChurch}', \r\n idRector = '{$idRector}' \r\n WHERE {$tableBaptism}.id = {$id}"; $person = PersonManager::getSinglePerson("id", $idOwner); ChangesLogsManager::addChangesLogs("C", "Bautismo de " . $person->getFullNameBeginName()); return DatabaseManager::singleAffectedRow($query); }
/** * update one defuntion in the database * * @author Jonathan Sandoval <*****@*****.**> * @param Defuntion $defuntion The defuntion to update * @return boolean if was possible to update */ static function updateDefuntion($defuntion = null) { if ($defuntion === null) { return false; } $tableDefuntion = DatabaseManager::getNameTable('TABLE_DEFUNTION'); $id = $defuntion->getId(); $deadDate = $defuntion->getDeadDate(); $idOwner = $defuntion->getIdOwner(); $idChurch = $defuntion->getIdChurch(); $idCrypt = $defuntion->getIdCrypt(); if ($idCrypt == "") { $idCrypt = "NULL"; } $query = "UPDATE {$tableDefuntion}\r\n SET deadDate = '{$deadDate}', idOwner = '{$idOwner}', idChurch = '{$idChurch}', \r\n idCrypt = {$idCrypt} \r\n WHERE {$tableDefuntion}.id = {$id}"; $person = PersonManager::getSinglePerson("id", $idOwner); ChangesLogsManager::addChangesLogs("C", "Defuncion de " . $person->getFullNameBeginName()); return DatabaseManager::singleAffectedRow($query); }
/** * Update one User in the database * * @author Jonathan Sandoval <*****@*****.**> * @param User $User The User to update * @return boolean If was possible to update */ static function updateUser($User = null) { if ($User === null) { return false; } $tableUser = DatabaseManager::getNameTable('TABLE_USER'); $id = $User->getId(); $username = $User->getUsername(); $type = $User->getType(); $password = $User->getPassword(); $User->getIdChurch() == 0 ? $idChurch = 'null' : ($idChurch = $User->getIdChurch()); $offline = $User->getOffline(); $lastAct = $User->getLastActivityTime(); $language = $User->getLanguage(); $idPaperConfig = $User->getIdPaperConfig(); $ip = $User->getAddressIP(); $query = "UPDATE {$tableUser}\r\n SET username = '******', type = '{$type}', password = '******', \r\n idChurch = {$idChurch}, offline = {$offline}, language = '{$language}',\r\n lastActivityTime = '{$lastAct}', idPaperConfig = {$idPaperConfig}, \r\n addressIP = '{$ip}'\r\n WHERE {$tableUser}.id = {$id}"; return DatabaseManager::singleAffectedRow($query); }
/** * Update one church in the database * * @author Jonathan Sandoval <*****@*****.**> * @param Church $church The church to update * @return boolean If was possible to update */ static function updateChurch($church = null) { if ($church === null) { return false; } $tableChurch = DatabaseManager::getNameTable('TABLE_CHURCH'); $id = $church->getId(); $name = $church->getName(); $type = $church->getType(); $code = $church->getCode(); $address = $church->getAddress(); $colony = $church->getColony(); $postalCode = $church->getPostalCode(); $phoneNumber = $church->getPhoneNumber(); $idVicar = $church->getIdVicar(); $idDean = $church->getIdDean(); $idCity = $church->getIdCity(); $idNiche = $church->getIdNiche(); $query = "UPDATE {$tableChurch}\r\n SET name = '{$name}', \r\n type = '{$type}', \r\n code = '{$code}', \r\n address = '{$address}', \r\n colony = '{$colony}', \r\n postalCode = '{$postalCode}', \r\n phoneNumber = '{$phoneNumber}', \r\n idVicar = '{$idVicar}', \r\n idDean = '{$idDean}', \r\n idCity = '{$idCity}', \r\n idNiche = {$idNiche} \r\n WHERE {$tableChurch}.id = {$id}"; ChangesLogsManager::addChangesLogs("C", "Iglesia de " . $church->getName()); return DatabaseManager::singleAffectedRow($query); }
/** * update one ProofTalks in the database * * @author Jonathan Sandoval <*****@*****.**> * @param ProofTalks $ProofTalks The ProofTalks to update * @return boolean If was posible to update */ static function updateProofTalks($ProofTalks = null) { if ($ProofTalks === null) { return false; } $tableProofTalks = DatabaseManager::getNameTable('TABLE_PROFF_TALKS'); $idOwner = $ProofTalks->getIdOwner(); $type = $ProofTalks->getType(); $id = $ProofTalks->getId(); $idGodFather = $ProofTalks->getIdGodFather(); $idGodMother = $ProofTalks->getIdGodMother(); $idChurch = $ProofTalks->getIdChurch(); if ($idGodFather === NULL) { $idGodFather = 'NULL'; } if ($idGodMother === NULL) { $idGodMother = 'NULL'; } $query = "UPDATE {$tableProofTalks}\r\n SET idOwner = '{$idOwner}', type = '{$type}', idGodMother = {$idGodMother}, \r\n idGodFather = {$idGodFather}, idChurch = '{$idChurch}'\r\n WHERE {$tableProofTalks}.id = {$id}"; $person = PersonManager::getSinglePerson("id", $idOwner); ChangesLogsManager::addChangesLogs("C", "Comprobante de " . $person->getFullNameBeginName()); return DatabaseManager::singleAffectedRow($query); }
/** * update one city in the database * * @author Jonathan Sandoval <*****@*****.**> * @param City $city The city to update * @return boolean if was possible to update */ static function updateCity($city = null) { if ($city === null) { return false; } $tableCity = DatabaseManager::getNameTable('TABLE_CITY'); $id = $city->getId(); $idState = $city->getIdState(); $name = $city->getName(); $query = "UPDATE {$tableCity}\n SET name = '{$name}', idState = {$idState}\n WHERE {$tableCity}.id = {$id}"; return DatabaseManager::singleAffectedRow($query); }
/** * Update one Person in the database * * @author Jonathan Sandoval <*****@*****.**> * @param Person $Person The Person to update * @return boolean If was possible to update */ static function updatePerson($Person = null) { if ($Person === null) { return false; } $tablePerson = DatabaseManager::getNameTable('TABLE_PERSON'); $id = $Person->getId(); $names = $Person->getNames(); $lastname1 = $Person->getLastname1(); $lastname2 = $Person->getLastname2(); $gender = $Person->getGender(); $address = $Person->getAddress(); $phoneNumber = $Person->getPhoneNumber(); $Person->getIdFather() == 0 ? $idFather = 'null' : ($idFather = $Person->getIdFather()); $Person->getIdMother() == 0 ? $idMother = 'null' : ($idMother = $Person->getIdMother()); $idCityAddress = $Person->getIdCityAddress(); if ($idCityAddress === NULL) { $idCityAddress = 'NULL'; } $query = "UPDATE {$tablePerson}\n SET names = '{$names}', \n lastname1 = '{$lastname1}', \n lastname2 = '{$lastname2}', \n gender = '{$gender}', \n address = '{$address}', \n phoneNumber = '{$phoneNumber}', \n idFather = {$idFather}, \n idMother = {$idMother}, \n idCityAddress = {$idCityAddress}\n WHERE {$tablePerson}.id = {$id}"; return DatabaseManager::singleAffectedRow($query); }
/** * Return if exist one 'formerRectorChurch' in the database * * @author Jonathan Sandoval <*****@*****.**> * @param string $idRector The id of one rector * @param string $idChurch The id of one church * @return boolean True if exist in the database, else false */ static function existFormerRectorChurch($idRector = '', $idChurch = '') { if ($idRector == '' || $idChurch == '') { return false; } else { $tableName = DatabaseManager::getNameTable('TABLE_FORMER_RECTOR_CHURCH'); $query = "SELECT {$tableName}.*\r\n FROM {$tableName} \r\n WHERE {$tableName}.idRector = {$idRector} AND\r\n {$tableName}.idChurch = {$idChurch}"; return DatabaseManager::singleAffectedRow($query); } }
/** * update one marriage in the database * * @author Jonathan Sandoval <*****@*****.**> * @param Marriage $marriage The marriage to update * @return boolean if was possible to update */ static function updateMarriage($marriage = null) { if ($marriage === null) { return false; } $tableMarriage = DatabaseManager::getNameTable('TABLE_MARRIAGE'); $idBoyfriend = $marriage->getIdBoyfriend(); $idGirlfriend = $marriage->getIdGirlfriend(); $id = $marriage->getId(); $marriageDate = $marriage->getCelebrationDate(); $idGodFather = $marriage->getIdGodFather(); $idGodMother = $marriage->getIdGodMother(); $idChurchMarriage = $marriage->getIdChurchMarriage(); $idRector = $marriage->getIdRector(); $idWitness1 = $marriage->getIdWitness1(); $idWitness2 = $marriage->getIdWitness2(); $idChurchProcess = $marriage->getIdChurchProcess(); $idMarriageRegistry = $marriage->getIdBookRegistry(); $query = "UPDATE {$tableMarriage}\r\n SET idBoyfriend = '{$idBoyfriend}', \r\n idGirlfriend = '{$idGirlfriend}', \r\n idGodFather = '{$idGodFather}', \r\n idGodMother = '{$idGodMother}', \r\n idWitness1 = '{$idWitness1}', \r\n idWitness2 = '{$idWitness2}',\r\n idMarriageRegistry = '{$idMarriageRegistry}', \r\n idChurchProcess = '{$idChurchProcess}', \r\n idRector = '{$idRector}', \r\n idChurchMarriage = '{$idChurchMarriage}', \r\n marriageDate = '{$marriageDate}'\r\n WHERE {$tableMarriage}.id = {$id}"; $personA = PersonManager::getSinglePerson("id", $idBoyfriend); $personB = PersonManager::getSinglePerson("id", $idGirlfriend); ChangesLogsManager::addChangesLogs("C", "Matrimonio de" . $personA->getFullNameBeginName() . " y " . $personB->getFullNameBeginName()); return DatabaseManager::singleAffectedRow($query); }