diff --git a/src/CSVImport.php b/src/CSVImport.php
index 8e76eae39e..a10dfd1b77 100644
--- a/src/CSVImport.php
+++ b/src/CSVImport.php
@@ -20,7 +20,9 @@
use ChurchCRM\Authentication\AuthenticationManager;
use ChurchCRM\dto\SystemConfig;
use ChurchCRM\dto\SystemURLs;
+use ChurchCRM\model\ChurchCRM\FamilyCustom;
use ChurchCRM\model\ChurchCRM\Note;
+use ChurchCRM\model\ChurchCRM\PersonCustom;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;
@@ -619,48 +621,37 @@ public function assignRoles()
);
}
} else {
- $sSQL = 'INSERT INTO family_fam (fam_ID,
- fam_Name,
- fam_Address1,
- fam_Address2,
- fam_City,
- fam_State,
- fam_Zip,
- fam_Country,
- fam_HomePhone,
- fam_WorkPhone,
- fam_CellPhone,
- fam_Email,
- fam_DateEntered,
- fam_EnteredBy)
- VALUES (NULL, ' .
- '"' . $per_LastName . '", ' .
- '"' . $sAddress1 . '", ' .
- '"' . $sAddress2 . '", ' .
- '"' . $sCity . '", ' .
- '"' . $sState . '", ' .
- '"' . $sZip . '", ' .
- '"' . $per_Country . '", ' .
- '"' . $per_HomePhone . '", ' .
- '"' . $per_WorkPhone . '", ' .
- '"' . $per_CellPhone . '", ' .
- '"' . $per_Email . '",' .
- '"' . date('YmdHis') . '",' .
- '"' . AuthenticationManager::getCurrentUser()->getId() . '");';
- RunQuery($sSQL);
+ $family = new \ChurchCRM\model\ChurchCRM\Family();
+ $family
+ ->setName($per_LastName)
+ ->setAddress1($sAddress1)
+ ->setAddress2($sAddress2)
+ ->setCity($sCity)
+ ->setState($sState)
+ ->setZip($sZip)
+ ->setHomePhone($per_HomePhone)
+ ->setWorkPhone($per_WorkPhone)
+ ->setCellPhone($per_CellPhone)
+ ->setEmail($per_Email)
+ ->setDateEntered(date('YmdHis'))
+ ->setEnteredBy(AuthenticationManager::getCurrentUser()->getId());
+ $family->save();
$sSQL = 'SELECT LAST_INSERT_ID()';
$rsFid = RunQuery($sSQL);
$aFid = mysqli_fetch_array($rsFid);
$famid = $aFid[0];
+
$note = new Note();
$note->setFamId($famid);
$note->setText(gettext('Imported'));
$note->setType('create');
$note->setEntered(AuthenticationManager::getCurrentUser()->getId());
$note->save();
- $sSQL = "INSERT INTO `family_custom` (`fam_ID`) VALUES ('" . $famid . "')";
- RunQuery($sSQL);
+
+ $familyCustom = new FamilyCustom();
+ $familyCustom->setFamId($famid);
+ $familyCustom->save();
$fFamily = new Family(InputUtils::legacyFilterInput($_POST['FamilyMode'], 'int'));
$fFamily->addMember(
@@ -681,8 +672,9 @@ public function assignRoles()
$sSQL = "SELECT fam_id FROM family_custom WHERE fam_id = $famid";
$rsFamCustomID = RunQuery($sSQL);
if (mysqli_num_rows($rsFamCustomID) === 0) {
- $sSQL = "INSERT INTO `family_custom` (`fam_ID`) VALUES ('" . $famid . "')";
- RunQuery($sSQL);
+ $familyCustom = new FamilyCustom();
+ $familyCustom->setFamId($famid);
+ $familyCustom->save();
}
// Build the family_custom SQL
@@ -728,6 +720,7 @@ public function assignRoles()
$rsPersonID = RunQuery($sSQL);
$aRow = mysqli_fetch_array($rsPersonID);
$iPersonID = $aRow['iPersonID'];
+
$note = new Note();
$note->setPerId($iPersonID);
$note->setText(gettext('Imported'));
@@ -735,8 +728,9 @@ public function assignRoles()
$note->setEntered(AuthenticationManager::getCurrentUser()->getId());
$note->save();
if ($bHasCustom) {
- $sSQL = "INSERT INTO `person_custom` (`per_ID`) VALUES ('" . $iPersonID . "')";
- RunQuery($sSQL);
+ $personCustom = new PersonCustom();
+ $personCustom->setPerId($iPersonID);
+ $personCustom->save();
// Build the person_custom SQL
for ($col = 0; $col < $numCol; $col++) {
diff --git a/src/CanvassEditor.php b/src/CanvassEditor.php
index 90c505fc50..ebf0b3f35b 100644
--- a/src/CanvassEditor.php
+++ b/src/CanvassEditor.php
@@ -14,6 +14,7 @@
require 'Include/Functions.php';
use ChurchCRM\Authentication\AuthenticationManager;
+use ChurchCRM\model\ChurchCRM\CanvassData;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;
@@ -66,22 +67,21 @@
// New canvas input (add)
if ($iCanvassID < 1) {
- $sSQL = 'INSERT INTO canvassdata_can (can_famID, can_Canvasser, can_FYID, can_date, can_Positive,
- can_Critical, can_Insightful, can_Financial, can_Suggestion,
- can_NotInterested, can_WhyNotInterested)
- VALUES (' . $iFamily . ',' .
- $iCanvasser . ',' .
- $iFYID . ',' .
- '"' . $dDate . '",' .
- '"' . $tPositive . '",' .
- '"' . $tCritical . '",' .
- '"' . $tInsightful . '",' .
- '"' . $tFinancial . '",' .
- '"' . $tSuggestion . '",' .
- '"' . $bNotInterested . '",' .
- '"' . $tWhyNotInterested . '")';
- //Execute the SQL
- RunQuery($sSQL);
+ $canvassData = new CanvassData();
+ $canvassData
+ ->setFamilyId($iFamily)
+ ->setCanvasser($iCanvasser)
+ ->setFyid($iFYID)
+ ->setDate($dDate)
+ ->setPositive($tPositive)
+ ->setCritical($tCritical)
+ ->setInsightful($tInsightful)
+ ->setFinancial($tFinancial)
+ ->setSuggestion($tSuggestion)
+ ->setNotInterested($bNotInterested)
+ ->setWhyNotInterested($tWhyNotInterested);
+ $canvassData->save();
+
$sSQL = 'SELECT MAX(can_ID) AS iCanvassID FROM canvassdata_can';
$rsLastEntry = RunQuery($sSQL);
$newRec = mysqli_fetch_array($rsLastEntry);
diff --git a/src/CartToEvent.php b/src/CartToEvent.php
index 1c77ab709f..2d0cbeb2db 100644
--- a/src/CartToEvent.php
+++ b/src/CartToEvent.php
@@ -19,7 +19,9 @@
use ChurchCRM\Authentication\AuthenticationManager;
use ChurchCRM\dto\Cart;
+use ChurchCRM\model\ChurchCRM\EventAttend;
use ChurchCRM\Utils\InputUtils;
+use ChurchCRM\Utils\LoggerUtils;
use ChurchCRM\Utils\RedirectUtils;
// Security: User must have Manage Groups & Roles permission
@@ -30,17 +32,21 @@
// Was the form submitted?
if (isset($_POST['Submit']) && count($_SESSION['aPeopleCart']) > 0 && isset($_POST['EventID'])) {
- // Get the PersonID
$iEventID = InputUtils::legacyFilterInput($_POST['EventID'], 'int');
- // Loop through the session array
$iCount = 0;
foreach ($_SESSION['aPeopleCart'] as $element) {
- // Enter ID into event
- $sSQL = 'INSERT IGNORE INTO event_attend (event_id, person_id)';
- $sSQL .= " VALUES ('" . $iEventID . "','" . $element . "')";
- RunQuery($sSQL);
- $iCount++;
+ try {
+ $eventAttend = new EventAttend();
+ $eventAttend
+ ->setEventId($iEventID)
+ ->setPersonId($element);
+ $eventAttend->save();
+ $iCount++;
+ } catch (\Throwable $ex) {
+ $logger = LoggerUtils::getAppLogger();
+ $logger->error('An error occurred when saving event attendance', ['exception' => $ex]);
+ }
}
Cart::emptyAll();
@@ -54,7 +60,7 @@
require 'Include/Header.php';
if (count($_SESSION['aPeopleCart']) > 0) {
- $sSQL = 'SELECT * FROM events_event';
+ $sSQL = 'SELECT event_id, event_title FROM events_event';
$rsEvents = RunQuery($sSQL); ?>
= gettext('Select the event to which you would like to add your cart') ?>:
@@ -74,8 +80,7 @@
// Create the group select drop-down
echo '
'; ?>
diff --git a/src/ChurchCRM/Service/FinancialService.php b/src/ChurchCRM/Service/FinancialService.php
index 59abf85f26..225ecea263 100644
--- a/src/ChurchCRM/Service/FinancialService.php
+++ b/src/ChurchCRM/Service/FinancialService.php
@@ -9,7 +9,9 @@
use ChurchCRM\dto\SystemConfig;
use ChurchCRM\dto\SystemURLs;
use ChurchCRM\MICRFunctions;
+use ChurchCRM\model\ChurchCRM\Deposit;
use ChurchCRM\model\ChurchCRM\FamilyQuery;
+use ChurchCRM\model\ChurchCRM\Pledge;
use ChurchCRM\model\ChurchCRM\PledgeQuery;
class FinancialService
@@ -59,9 +61,14 @@ public function setDeposit(string $depositType, string $depositComment, string $
}
RunQuery($sSQL);
} else {
- $sSQL = "INSERT INTO deposit_dep (dep_Date, dep_Comment, dep_EnteredBy, dep_Type)
- VALUES ('" . $depositDate . "','" . $depositComment . "'," . AuthenticationManager::getCurrentUser()->getId() . ",'" . $depositType . "')";
- RunQuery($sSQL);
+ $deposit = new Deposit();
+ $deposit
+ ->setDate($depositDate)
+ ->setComment($depositComment)
+ ->setEnteredby(AuthenticationManager::getCurrentUser()->getId())
+ ->setType($depositType);
+ $deposit->save();
+
$sSQL = 'SELECT MAX(dep_ID) AS iDepositSlipID FROM deposit_dep';
$rsDepositSlipID = RunQuery($sSQL);
$iDepositSlipID = mysqli_fetch_array($rsDepositSlipID)[0];
@@ -255,49 +262,38 @@ public function insertPledgeorPayment($payment)
$sGroupKey = genGroupKey('cash', $payment->FamilyID, $Fund->FundID, $payment->Date);
}
}
- $sSQL = "INSERT INTO pledge_plg
- (plg_famID,
- plg_FYID,
- plg_date,
- plg_amount,
- plg_schedule,
- plg_method,
- plg_comment,
- plg_DateLastEdited,
- plg_EditedBy,
- plg_PledgeOrPayment,
- plg_fundID,
- plg_depID,
- plg_CheckNo,
- plg_scanString,
- plg_aut_ID,
- plg_NonDeductible,
- plg_GroupKey)
- VALUES ('" .
- $payment->FamilyID . "','" .
- $payment->FYID . "','" .
- $payment->Date . "','" .
- $Fund->Amount . "','" .
- ($payment->schedule ?? 'NULL') . "','" .
- $payment->iMethod . "','" .
- $Fund->Comment . "','" .
- date('YmdHis') . "'," .
- AuthenticationManager::getCurrentUser()->getId() . ",'" .
- $payment->type . "'," .
- $Fund->FundID . ',' .
- $payment->DepositID . ',' .
- ($payment->iCheckNo ?? 'NULL') . ",'" .
- ($payment->tScanString ?? 'NULL') . "','" .
- ($payment->iAutID ?? 'NULL') . "','" .
- ($Fund->NonDeductible ?? 'NULL') . "','" .
- $sGroupKey . "')";
-
- if (isset($sSQL)) {
- RunQuery($sSQL);
- unset($sSQL);
-
- return $sGroupKey;
+
+ $pledge = new Pledge();
+ $pledge
+ ->setFamId($payment->FamilyID)
+ ->setFyId($payment->FYID)
+ ->setDate($payment->Date)
+ ->setAmount($Fund->Amount)
+ ->setMethod($payment->iMethod)
+ ->setComment($Fund->Comment)
+ ->setDateLastEdited(date('YmdHis'))
+ ->setEditedBy(AuthenticationManager::getCurrentUser()->getId())
+ ->setPledgeOrPayment($payment->type)
+ ->setFundId($Fund->FundID)
+ ->setDepId($payment->DepositID)
+ ->setGroupKey($sGroupKey);
+ if ($payment->schedule) {
+ $pledge->setSchedule($payment->schedule);
+ }
+ if ($payment->iCheckNo) {
+ $pledge->setCheckNo($payment->iCheckNo);
+ }
+ if ($payment->tScanString) {
+ $pledge->setScanString($payment->tScanString);
+ }
+ if ($payment->iAutID) {
+ $pledge->setAutId($payment->iAutID);
+ }
+ if ($Fund->NonDeductible) {
+ $pledge->setNondeductible($Fund->NonDeductible);
}
+ $pledge->save();
+ return $sGroupKey;
}
}
}
diff --git a/src/ChurchCRM/Service/GroupService.php b/src/ChurchCRM/Service/GroupService.php
index 6eac4ff95c..a7dc85b922 100644
--- a/src/ChurchCRM/Service/GroupService.php
+++ b/src/ChurchCRM/Service/GroupService.php
@@ -2,6 +2,7 @@
namespace ChurchCRM\Service;
+use ChurchCRM\model\ChurchCRM\ListOption;
use ChurchCRM\model\ChurchCRM\PersonQuery;
class GroupService
@@ -242,10 +243,14 @@ public function addGroupRole(string $groupID, string $groupRoleName): string
$newOptionID = $aTemp[0] + 1;
// Insert into the appropriate options table
- $sSQL = 'INSERT INTO list_lst (lst_ID, lst_OptionID, lst_OptionName, lst_OptionSequence)
- VALUES (' . $listID . ',' . $newOptionID . ",'" . $groupRoleName . "'," . $newOptionSequence . ')';
+ $listOption = new ListOption();
+ $listOption
+ ->setId($listID)
+ ->setOptionId($newOptionID)
+ ->setOptionName($groupRoleName)
+ ->setOptionSequence($newOptionSequence);
+ $listOption->save();
- RunQuery($sSQL);
$iNewNameError = 0;
}
}
diff --git a/src/ChurchCRM/Service/TaskService.php b/src/ChurchCRM/Service/TaskService.php
index 1e5fdf0c64..f7b4e19ba3 100644
--- a/src/ChurchCRM/Service/TaskService.php
+++ b/src/ChurchCRM/Service/TaskService.php
@@ -26,9 +26,9 @@
class TaskService
{
/**
- * @var ObjectCollection|TaskInterface[]
+ * @var TaskInterface[]
*/
- private $taskClasses;
+ private array $taskClasses;
private array $notificationClasses = [
// new LatestReleaseTask()
];
@@ -60,10 +60,12 @@ public function getCurrentUserTasks(): array
$tasks = [];
foreach ($this->taskClasses as $taskClass) {
if ($taskClass->isActive() && (!$taskClass->isAdmin() || ($taskClass->isAdmin() && AuthenticationManager::getCurrentUser()->isAdmin()))) {
- $tasks[] = ['title' => $taskClass->getTitle(),
+ $tasks[] = [
+ 'title' => $taskClass->getTitle(),
'link' => $taskClass->getLink(),
'admin' => $taskClass->isAdmin(),
- 'desc' => $taskClass->getDesc()];
+ 'desc' => $taskClass->getDesc()
+ ];
}
}
@@ -75,7 +77,7 @@ public function getTaskNotifications(): array
$tasks = [];
foreach ($this->notificationClasses as $taskClass) {
if ($taskClass->isActive()) {
- $tasks[] = new UiNotification($taskClass->getTitle(), 'wrench', $taskClass->getLink(), $taskClass->getDesc(), $taskClass->isAdmin() ? 'warning' : 'info', '12000', 'bottom', 'left');
+ $tasks[] = new UiNotification($taskClass->getTitle(), 'wrench', $taskClass->getLink(), $taskClass->getDesc(), $taskClass->isAdmin() ? 'warning' : 'info', 12000, 'bottom', 'left');
}
}
diff --git a/src/ChurchCRM/dto/Cart.php b/src/ChurchCRM/dto/Cart.php
index 1fc0cf6524..b197dc9518 100644
--- a/src/ChurchCRM/dto/Cart.php
+++ b/src/ChurchCRM/dto/Cart.php
@@ -22,7 +22,7 @@ public static function addPerson($PersonID): void
if (!is_numeric($PersonID)) {
throw new \Exception(gettext('PersonID for Cart must be numeric'), 400);
}
- if ($PersonID !== null && !in_array($PersonID, $_SESSION['aPeopleCart'], false)) {
+ if (!in_array($PersonID, $_SESSION['aPeopleCart'], false)) {
$_SESSION['aPeopleCart'][] = (int)$PersonID;
}
}
diff --git a/src/ChurchCRM/dto/ChurchCRMRelease.php b/src/ChurchCRM/dto/ChurchCRMRelease.php
index c073b0a23e..f1607e04f0 100644
--- a/src/ChurchCRM/dto/ChurchCRMRelease.php
+++ b/src/ChurchCRM/dto/ChurchCRMRelease.php
@@ -4,18 +4,9 @@
class ChurchCRMRelease
{
- /**
- * @var string
- */
- public $MAJOR;
- /**
- * @var string
- */
- public $MINOR;
- /**
- * @var string
- */
- public $PATCH;
+ public string $MAJOR;
+ public string $MINOR;
+ public string $PATCH;
private array $rawRelease;
@@ -30,10 +21,10 @@ public function __construct(array $releaseArray)
public function equals(ChurchCRMRelease $b): bool
{
- return $this->MAJOR == $b->MAJOR && $this->MINOR == $b->MINOR && $this->PATCH == $b->PATCH;
+ return $this->MAJOR === $b->MAJOR && $this->MINOR === $b->MINOR && $this->PATCH === $b->PATCH;
}
- public function compareTo(ChurchCRMRelease $b)
+ public function compareTo(ChurchCRMRelease $b): int
{
if ($this->MAJOR < $b->MAJOR) {
return -1;
@@ -59,21 +50,21 @@ public function compareTo(ChurchCRMRelease $b)
public function __toString(): string
{
try {
- return (string) $this->MAJOR . '.' . $this->MINOR . '.' . $this->PATCH;
+ return $this->MAJOR . '.' . $this->MINOR . '.' . $this->PATCH;
} catch (\Exception $exception) {
return '';
}
}
- public function getDownloadURL()
+ public function getDownloadURL(): string
{
foreach ($this->rawRelease['assets'] as $asset) {
if ($asset['name'] == 'ChurchCRM-' . $this->rawRelease['name'] . '.zip') {
- $url = $asset['browser_download_url'];
+ return $asset['browser_download_url'];
}
}
- return $url;
+ throw new \Exception('download url not found!');
}
public function getReleaseNotes(): string
@@ -85,6 +76,6 @@ public function isPreRelease(): bool
{
// yeah, it's a boolean in the JSON, but
// let's check it to be sure this function returns a boolean.
- return $this->rawRelease['prerelease'] == true;
+ return (bool) $this->rawRelease['prerelease'] === true;
}
}
diff --git a/src/ChurchCRM/dto/Notification/UiNotification.php b/src/ChurchCRM/dto/Notification/UiNotification.php
index d99e555ee8..b55e91bf1e 100644
--- a/src/ChurchCRM/dto/Notification/UiNotification.php
+++ b/src/ChurchCRM/dto/Notification/UiNotification.php
@@ -6,29 +6,25 @@
class UiNotification implements JsonSerializable
{
- private $title;
- private $message;
- private $url;
- private $type;
- private $icon;
- private $delay;
- private $placement;
- private $align;
+ private string $title;
+ private string $message;
+ private string $url;
+ private string $type;
+ private string $icon;
+ private int $delay;
+ private string $placement;
+ private string $align;
- /**
- * UiNotification constructor.
- *
- * @param $title
- * @param $message
- * @param $url
- * @param $type
- * @param $icon
- * @param $delay
- * @param $placement
- * @param $align
- */
- public function __construct($title, $icon, $url = '', $message = '', $type = 'info', $delay = 4000, $placement = 'top', $align = 'right')
- {
+ public function __construct(
+ string $title,
+ string $icon,
+ string $url = '',
+ string $message = '',
+ string $type = 'info',
+ int $delay = 4000,
+ string $placement = 'top',
+ string $align = 'right'
+ ) {
$this->title = $title;
$this->message = $message;
$this->url = $url;
@@ -39,66 +35,42 @@ public function __construct($title, $icon, $url = '', $message = '', $type = 'in
$this->align = $align;
}
- /**
- * @return mixed
- */
- public function getTitle()
+ public function getTitle(): string
{
return $this->title;
}
- /**
- * @return string
- */
- public function getMessage()
+ public function getMessage(): string
{
return $this->message;
}
- /**
- * @return string
- */
- public function getUrl()
+ public function getUrl(): string
{
return $this->url;
}
- /**
- * @return string
- */
- public function getType()
+ public function getType(): string
{
return $this->type;
}
- /**
- * @return mixed
- */
- public function getIcon()
+ public function getIcon(): string
{
return $this->icon;
}
- /**
- * @return int
- */
- public function getDelay()
+ public function getDelay(): int
{
return $this->delay;
}
- /**
- * @return string
- */
- public function getPlacement()
+ public function getPlacement(): string
{
return $this->placement;
}
- /**
- * @return string
- */
- public function getAlign()
+ public function getAlign(): string
{
return $this->align;
}
diff --git a/src/ChurchCRM/dto/SystemConfig.php b/src/ChurchCRM/dto/SystemConfig.php
index 177a7841f4..b22fd43af8 100644
--- a/src/ChurchCRM/dto/SystemConfig.php
+++ b/src/ChurchCRM/dto/SystemConfig.php
@@ -11,7 +11,7 @@
class SystemConfig
{
/**
- * @var Config[]
+ * @var Config[]|null
*/
private static ?array $configs = null;
diff --git a/src/ChurchCRM/model/ChurchCRM/Person.php b/src/ChurchCRM/model/ChurchCRM/Person.php
index a54824035a..2419b3a4e7 100644
--- a/src/ChurchCRM/model/ChurchCRM/Person.php
+++ b/src/ChurchCRM/model/ChurchCRM/Person.php
@@ -628,7 +628,7 @@ public function getNumericCellPhone(): string
return '1' . preg_replace('/[^\.0-9]/', '', $this->getCellPhone());
}
- public function postSave(ConnectionInterface $con = null)
+ public function postSave(ConnectionInterface $con = null): void
{
$this->getPhoto()->refresh();
diff --git a/src/ConvertIndividualToFamily.php b/src/ConvertIndividualToFamily.php
index ebf6799ec8..93d20ab7ac 100644
--- a/src/ConvertIndividualToFamily.php
+++ b/src/ConvertIndividualToFamily.php
@@ -25,6 +25,7 @@
require 'Include/Functions.php';
use ChurchCRM\Authentication\AuthenticationManager;
+use ChurchCRM\model\ChurchCRM\Family;
use ChurchCRM\Utils\RedirectUtils;
// Security
@@ -67,28 +68,19 @@
$per_Country = mysqli_real_escape_string($cnInfoCentral, $per_Country);
$per_HomePhone = mysqli_real_escape_string($cnInfoCentral, $per_HomePhone);
- $sSQL = "INSERT INTO family_fam (
- fam_Name,
- fam_Address1,
- fam_Address2,
- fam_City,
- fam_State,
- fam_Zip,
- fam_Country,
- fam_HomePhone,
- fam_DateEntered,
- fam_EnteredBy)
- VALUES ('" .
- $per_LastName . "','" .
- $per_Address1 . "','" .
- $per_Address2 . "','" .
- $per_City . "','" .
- $per_State . "','" .
- $per_Zip . "','" .
- $per_Country . "','" .
- $per_HomePhone . "'," .
- 'NOW()' . ",'" .
- $curUserId . "')";
+ $family = new Family();
+ $family
+ ->setName($per_LastName)
+ ->setAddress1($per_Address1)
+ ->setAddress2($per_Address2)
+ ->setCity($per_City)
+ ->setState($per_State)
+ ->setZip($per_Zip)
+ ->setCountry($per_Country)
+ ->setHomePhone($per_HomePhone)
+ ->setDateEntered(new DateTimeImmutable())
+ ->setEnteredBy($curUserId);
+ $family->save();
echo '
' . $sSQL;
// RunQuery to add family record
diff --git a/src/DonatedItemEditor.php b/src/DonatedItemEditor.php
index e6c71fc56c..6635b08d22 100644
--- a/src/DonatedItemEditor.php
+++ b/src/DonatedItemEditor.php
@@ -15,6 +15,7 @@
use ChurchCRM\Authentication\AuthenticationManager;
use ChurchCRM\dto\SystemURLs;
+use ChurchCRM\model\ChurchCRM\DonatedItem;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;
@@ -68,9 +69,24 @@
}
// New DonatedItem or deposit
if (strlen($iDonatedItemID) < 1) {
- $sSQL = 'INSERT INTO donateditem_di (di_FR_ID, di_Item, di_multibuy, di_donor_ID, di_buyer_ID, di_title, di_description, di_sellprice, di_estprice, di_materialvalue, di_minimum, di_picture, di_EnteredBy, di_EnteredDate)
- VALUES (' . $iCurrentFundraiser . ",'" . $sItem . "','" . $bMultibuy . "','" . $iDonor . "','" . $iBuyer . "','" . html_entity_decode($sTitle) . "','" . html_entity_decode($sDescription) . "','" . $nSellPrice . "','" . $nEstPrice . "','" . $nMaterialValue . "','" . $nMinimumPrice . "','" . mysqli_real_escape_string($cnInfoCentral, $sPictureURL) . "'";
- $sSQL .= ',' . AuthenticationManager::getCurrentUser()->getId() . ",'" . date('YmdHis') . "')";
+ $donatedItem = new DonatedItem();
+ $donatedItem
+ ->setFrId($iCurrentFundraiser)
+ ->setItem($sItem)
+ ->setMultibuy($bMultibuy)
+ ->setDonorId($iDonor)
+ ->setBuyerId($iBuyer)
+ ->setTitle(html_entity_decode($sTitle))
+ ->setDescription(html_entity_decode($sDescription))
+ ->setSellprice($nSellPrice)
+ ->setEstprice($nEstPrice)
+ ->setMaterialValue($nMaterialValue)
+ ->setMinimum($nMinimumPrice)
+ ->setPicture($sPictureURL)
+ ->setEnteredby(AuthenticationManager::getCurrentUser()->getId())
+ ->setEntereddate(date('YmdHis'));
+ $donatedItem->save();
+
$bGetKeyBack = true;
// Existing record (update)
} else {
diff --git a/src/FamilyCustomFieldsEditor.php b/src/FamilyCustomFieldsEditor.php
index 156cd895ff..383f5c8c0a 100644
--- a/src/FamilyCustomFieldsEditor.php
+++ b/src/FamilyCustomFieldsEditor.php
@@ -20,6 +20,7 @@
use ChurchCRM\Authentication\AuthenticationManager;
use ChurchCRM\dto\SystemURLs;
+use ChurchCRM\model\ChurchCRM\ListOption;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;
@@ -151,8 +152,13 @@
}
// Insert into the lists table with an example option.
- $sSQL = "INSERT INTO list_lst VALUES ($newListID, 1, 1,'" . gettext('Default Option') . "')";
- RunQuery($sSQL);
+ $listOption = new ListOption();
+ $listOption
+ ->setId($newListID)
+ ->setOptionId(1)
+ ->setOptionSequence(1)
+ ->setOptionName(gettext('Default Option'));
+ $listOption->save();
$newSpecial = "'$newListID'";
} else {
diff --git a/src/FamilyEditor.php b/src/FamilyEditor.php
index 2705edd309..07026cbaee 100644
--- a/src/FamilyEditor.php
+++ b/src/FamilyEditor.php
@@ -124,16 +124,12 @@
}
- if (is_numeric($nLatitude)) {
- $nLatitude = "'" . $nLatitude . "'";
- } else {
- $nLatitude = 'NULL';
+ if (!is_numeric($nLatitude)) {
+ $nLatitude = null;
}
- if (is_numeric($nLongitude)) {
- $nLongitude = "'" . $nLongitude . "'";
- } else {
- $nLongitude = 'NULL';
+ if (!is_numeric($nLongitude)) {
+ $nLongitude = null;
}
$nEnvelope = 0;
@@ -226,6 +222,7 @@
}
// Validate Wedding Date if one was entered
+ $dWeddingDate = null;
if ((strlen($dWeddingDate) > 0) && ($dWeddingDate != '')) {
$dateString = parseAndValidateDate($dWeddingDate, Bootstrapper::getCurrentLocale()->getCountryCode(), $pasfut = 'past');
if ($dateString === false) {
@@ -233,10 +230,8 @@
. gettext('Not a valid Wedding Date') . '';
$bErrorFlag = true;
} else {
- $dWeddingDate = "'$dateString'";
+ $dWeddingDate = $dateString;
}
- } else {
- $dWeddingDate = 'NULL';
}
// Validate Email
@@ -245,8 +240,7 @@
$sEmailError = '
'
. gettext('Email is Not Valid') . '';
$bErrorFlag = true;
- } else {
- $sEmail = $sEmail;
+ $sEmail = null;
}
}
@@ -277,59 +271,40 @@
}
//Write the base SQL depending on the Action
- if ($bSendNewsLetter) {
- $bSendNewsLetterString = "'TRUE'";
- } else {
- $bSendNewsLetterString = "'FALSE'";
- }
- if ($bOkToCanvass) {
- $bOkToCanvassString = "'TRUE'";
- } else {
- $bOkToCanvassString = "'FALSE'";
- }
+ $bSendNewsLetterString = $bSendNewsLetter ? 'TRUE' : 'FALSE';
+ $bOkToCanvassString = $bOkToCanvass ? 'TRUE' : 'FALSE';
+
if ($iFamilyID < 1) {
- $sSQL = "INSERT INTO family_fam (
- fam_Name,
- fam_Address1,
- fam_Address2,
- fam_City,
- fam_State,
- fam_Zip,
- fam_Country,
- fam_HomePhone,
- fam_WorkPhone,
- fam_CellPhone,
- fam_Email,
- fam_WeddingDate,
- fam_DateEntered,
- fam_EnteredBy,
- fam_SendNewsLetter,
- fam_OkToCanvass,
- fam_Canvasser,
- fam_Latitude,
- fam_Longitude,
- fam_Envelope)
- VALUES ('" .
- $sName . "','" .
- $sAddress1 . "','" .
- $sAddress2 . "','" .
- $sCity . "','" .
- $sState . "','" .
- $sZip . "','" .
- $sCountry . "','" .
- $sHomePhone . "','" .
- $sWorkPhone . "','" .
- $sCellPhone . "','" .
- $sEmail . "'," .
- $dWeddingDate . ",'" .
- date('YmdHis') . "'," .
- AuthenticationManager::getCurrentUser()->getId() . ',' .
- $bSendNewsLetterString . ',' .
- $bOkToCanvassString . ",'" .
- $iCanvasser . "'," .
- $nLatitude . ',' .
- $nLongitude . ',' .
- $nEnvelope . ')';
+ $family = new \ChurchCRM\model\ChurchCRM\Family();
+ $family
+ ->setName($sName)
+ ->setAddress1($sAddress1)
+ ->setAddress2($sAddress2)
+ ->setCity($sCity)
+ ->setState($sState)
+ ->setZip($sZip)
+ ->setHomePhone($sHomePhone)
+ ->setWorkPhone($sWorkPhone)
+ ->setCellPhone($sCellPhone)
+ ->setDateEntered(date('YmdHis'))
+ ->setEnteredBy(AuthenticationManager::getCurrentUser()->getId())
+ ->setSendNewsletter($bSendNewsLetterString)
+ ->setOkToCanvass($bOkToCanvassString)
+ ->setCanvasser($iCanvasser)
+ ->setEnvelope($nEnvelope);
+ if ($dWeddingDate) {
+ $family->setWeddingdate($dWeddingDate);
+ }
+ if ($sEmail) {
+ $family->setEmail($sEmail);
+ }
+ if ($nLatitude) {
+ $family->setLatitude($nLatitude);
+ }
+ if ($nLatitude) {
+ $family->setLongitude($nLongitude);
+ }
+ $family->save();
$bGetKeyBack = true;
} else {
$sSQL = "UPDATE family_fam SET fam_Name='" . $sName . "'," .
@@ -338,20 +313,20 @@
"fam_City='" . $sCity . "'," .
"fam_State='" . $sState . "'," .
"fam_Zip='" . $sZip . "'," .
- 'fam_Latitude=' . $nLatitude . ',' .
- 'fam_Longitude=' . $nLongitude . ',' .
+ 'fam_Latitude=' . ($nLatitude ? "\"$nLatitude\"" : '"NULL"') . ',' .
+ 'fam_Longitude=' . ($nLongitude ? "\"$nLongitude\"" : '"NULL"') . ',' .
"fam_Country='" . $sCountry . "'," .
"fam_HomePhone='" . $sHomePhone . "'," .
"fam_WorkPhone='" . $sWorkPhone . "'," .
"fam_CellPhone='" . $sCellPhone . "'," .
- "fam_Email='" . $sEmail . "'," .
- 'fam_WeddingDate=' . $dWeddingDate . ',' .
+ "fam_Email='" . ($sEmail ?? '') . "'," .
+ 'fam_WeddingDate=' . ($dWeddingDate ? "\"$dWeddingDate\"" : '"NULL"') . ',' .
'fam_Envelope=' . $nEnvelope . ',' .
"fam_DateLastEdited='" . date('YmdHis') . "'," .
'fam_EditedBy = ' . AuthenticationManager::getCurrentUser()->getId() . ',' .
- 'fam_SendNewsLetter = ' . $bSendNewsLetterString;
+ 'fam_SendNewsLetter = "' . $bSendNewsLetterString . '"';
if (AuthenticationManager::getCurrentUser()->isCanvasserEnabled()) {
- $sSQL .= ', fam_OkToCanvass = ' . $bOkToCanvassString .
+ $sSQL .= ', fam_OkToCanvass = "' . $bOkToCanvassString . '"' .
", fam_Canvasser = '" . $iCanvasser . "'";
}
$sSQL .= ' WHERE fam_ID = ' . $iFamilyID;
@@ -797,7 +772,7 @@
diff --git a/src/FundRaiserEditor.php b/src/FundRaiserEditor.php
index 1b8d2e6bdd..c40bbc5016 100644
--- a/src/FundRaiserEditor.php
+++ b/src/FundRaiserEditor.php
@@ -14,6 +14,7 @@
require 'Include/Functions.php';
use ChurchCRM\Authentication\AuthenticationManager;
+use ChurchCRM\model\ChurchCRM\FundRaiser;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;
@@ -60,8 +61,15 @@
if (!$bErrorFlag) {
// New deposit slip
if ($iFundRaiserID <= 0) {
- $sSQL = 'INSERT INTO fundraiser_fr (fr_date, fr_title, fr_description, fr_EnteredBy, fr_EnteredDate) VALUES (' .
- "'" . $dDate . "','" . $sTitle . "','" . $sDescription . "'," . AuthenticationManager::getCurrentUser()->getId() . ",'" . date('YmdHis') . "')";
+ $fundraiser = new FundRaiser();
+ $fundraiser
+ ->setDate($dDate)
+ ->setTitle($sTitle)
+ ->setDescription($sDescription)
+ ->setEnteredBy(AuthenticationManager::getCurrentUser()->getId())
+ ->setEnteredDate(date('YmdHis'));
+ $fundraiser->save();
+
$bGetKeyBack = true;
// Existing record (update)
} else {
diff --git a/src/GroupPropsFormEditor.php b/src/GroupPropsFormEditor.php
index a490172548..06490fc7d8 100644
--- a/src/GroupPropsFormEditor.php
+++ b/src/GroupPropsFormEditor.php
@@ -169,8 +169,13 @@
}
// Insert into the lists table with an example option.
- $sSQL = "INSERT INTO list_lst VALUES ($newListID, 1, 1," . gettext("'Default Option'") . ')';
- RunQuery($sSQL);
+ $listOption = new ListOption();
+ $listOption
+ ->setId($newListID)
+ ->setOptionId(1)
+ ->setOptionSequence(1)
+ ->setOptionName(gettext('Default Option'));
+ $listOption->save();
$newSpecial = "'$newListID'";
} else {
diff --git a/src/OptionManager.php b/src/OptionManager.php
index 93aadc2bb3..417d49d57a 100644
--- a/src/OptionManager.php
+++ b/src/OptionManager.php
@@ -17,6 +17,7 @@
require 'Include/Functions.php';
use ChurchCRM\Authentication\AuthenticationManager;
+use ChurchCRM\model\ChurchCRM\ListOption;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;
@@ -199,10 +200,14 @@
$newOptionID = $aTemp[0] + 1;
// Insert into the appropriate options table
- $sSQL = 'INSERT INTO list_lst (lst_ID, lst_OptionID, lst_OptionName, lst_OptionSequence)
- VALUES (' . $listID . ',' . $newOptionID . ",'" . $newFieldName . "'," . $newOptionSequence . ')';
+ $listOption = new ListOption();
+ $listOption
+ ->setId($listID)
+ ->setOptionId($newOptionID)
+ ->setOptionName($newFieldName)
+ ->setOptionSequence($newOptionSequence);
+ $listOption->save();
- RunQuery($sSQL);
$iNewNameError = 0;
}
}
diff --git a/src/PersonCustomFieldsEditor.php b/src/PersonCustomFieldsEditor.php
index 837e355e85..79a55c9ac9 100644
--- a/src/PersonCustomFieldsEditor.php
+++ b/src/PersonCustomFieldsEditor.php
@@ -15,6 +15,7 @@
use ChurchCRM\Authentication\AuthenticationManager;
use ChurchCRM\dto\SystemURLs;
+use ChurchCRM\model\ChurchCRM\ListOption;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;
@@ -140,8 +141,13 @@
}
// Insert into the lists table with an example option.
- $sSQL = "INSERT INTO list_lst VALUES ($newListID, 1, 1,'" . gettext('Default Option') . "')";
- RunQuery($sSQL);
+ $listOption = new ListOption();
+ $listOption
+ ->setId($newListID)
+ ->setOptionId(1)
+ ->setOptionSequence(1)
+ ->setOptionName(gettext('Default Option'));
+ $listOption->save();
$newSpecial = "'$newListID'";
} else {
diff --git a/src/PersonEditor.php b/src/PersonEditor.php
index 709f2dd923..456767e402 100644
--- a/src/PersonEditor.php
+++ b/src/PersonEditor.php
@@ -19,6 +19,7 @@
use ChurchCRM\dto\SystemURLs;
use ChurchCRM\Emails\NewPersonOrFamilyEmail;
use ChurchCRM\model\ChurchCRM\Note;
+use ChurchCRM\model\ChurchCRM\PersonCustom;
use ChurchCRM\model\ChurchCRM\PersonQuery;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\LoggerUtils;
@@ -404,8 +405,11 @@
$rsPersonID = RunQuery($sSQL);
$aRow = mysqli_fetch_array($rsPersonID);
$iPersonID = $aRow['iPersonID'];
- $sSQL = "INSERT INTO person_custom (per_ID) VALUES ('" . $iPersonID . "')";
- RunQuery($sSQL);
+
+ $personCustom = new PersonCustom();
+ $personCustom->setPerId($iPersonID);
+ $personCustom->save();
+
$note->setPerId($iPersonID);
$note->setText(gettext('Created'));
$note->setType('create');
diff --git a/src/PledgeEditor.php b/src/PledgeEditor.php
index c4e0627e48..c3312f0440 100644
--- a/src/PledgeEditor.php
+++ b/src/PledgeEditor.php
@@ -18,6 +18,7 @@
use ChurchCRM\dto\SystemConfig;
use ChurchCRM\dto\SystemURLs;
use ChurchCRM\MICRFunctions;
+use ChurchCRM\model\ChurchCRM\Pledge;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;
@@ -357,9 +358,26 @@
$sGroupKey = genGroupKey('cash', $iFamily, $fun_id, $dDate);
}
}
- $sSQL = "INSERT INTO pledge_plg (plg_famID, plg_FYID, plg_date, plg_amount, plg_schedule, plg_method, plg_comment, plg_DateLastEdited, plg_EditedBy, plg_PledgeOrPayment, plg_fundID, plg_depID, plg_CheckNo, plg_scanString, plg_aut_ID, plg_NonDeductible, plg_GroupKey)
- VALUES ('" . $iFamily . "','" . $iFYID . "','" . $dDate . "','" . $nAmount[$fun_id] . "','" . $iSchedule . "','" . $iMethod . "','" . $sComment[$fun_id] . "'";
- $sSQL .= ",'" . date('YmdHis') . "'," . AuthenticationManager::getCurrentUser()->getId() . ",'" . $PledgeOrPayment . "'," . $fun_id . ',' . $iCurrentDeposit . ',' . $iCheckNo . ",'" . $tScanString . "','" . $iAutID . "','" . $nNonDeductible[$fun_id] . "','" . $sGroupKey . "')";
+ $pledge = new Pledge();
+ $pledge
+ ->setFamId($iFamily)
+ ->setFyId($iFYID)
+ ->setDate($dDate)
+ ->setAmount($nAmount[$fun_id])
+ ->setSchedule($iSchedule)
+ ->setMethod($iMethod)
+ ->setComment($sComment[$fun_id])
+ ->setDateLastEdited(date('YmdHis'))
+ ->setEditedBy(AuthenticationManager::getCurrentUser()->getId())
+ ->setPledgeOrPayment($PledgeOrPayment)
+ ->setFundId($fun_id)
+ ->setDepId($iCurrentDeposit)
+ ->setCheckNo($iCheckNo)
+ ->setScanString($tScanString)
+ ->setAutId($iAutID)
+ ->setNondeductible($nNonDeductible[$fun_id])
+ ->setGroupKey($sGroupKey);
+ $pledge->save();
}
if (isset($sSQL)) {
RunQuery($sSQL);
diff --git a/src/PropertyEditor.php b/src/PropertyEditor.php
index eb46d6fc53..421ebc192e 100644
--- a/src/PropertyEditor.php
+++ b/src/PropertyEditor.php
@@ -14,6 +14,7 @@
require 'Include/Functions.php';
use ChurchCRM\Authentication\AuthenticationManager;
+use ChurchCRM\model\ChurchCRM\Property;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;
@@ -84,7 +85,14 @@
if (!$bError) {
//Vary the SQL depending on if we're adding or editing
if ($iPropertyID == 0) {
- $sSQL = "INSERT INTO property_pro (pro_Class,pro_prt_ID,pro_Name,pro_Description,pro_Prompt) VALUES ('" . $sType . "'," . $iClass . ",'" . $sName . "','" . $sDescription . "','" . $sPrompt . "')";
+ $property = new Property();
+ $property
+ ->setProClass($sType)
+ ->setProPrtId($iClass)
+ ->setProName($sName)
+ ->setProDescription($sDescription)
+ ->setProPrompt($sPrompt);
+ $property->save();
} else {
$sSQL = 'UPDATE property_pro SET pro_prt_ID = ' . $iClass . ", pro_Name = '" . $sName . "', pro_Description = '" . $sDescription . "', pro_Prompt = '" . $sPrompt . "' WHERE pro_ID = " . $iPropertyID;
}
diff --git a/src/SettingsIndividual.php b/src/SettingsIndividual.php
index afed949bfa..bd5d35b6d6 100644
--- a/src/SettingsIndividual.php
+++ b/src/SettingsIndividual.php
@@ -17,6 +17,7 @@
require 'Include/Functions.php';
use ChurchCRM\Authentication\AuthenticationManager;
+use ChurchCRM\model\ChurchCRM\UserConfig;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;
@@ -63,10 +64,16 @@
list($ucfg_per_id, $ucfg_id, $ucfg_name, $ucfg_value, $ucfg_type,
$ucfg_tooltip, $ucfg_permission) = $aDefaultRow;
- $sSQL = "INSERT INTO userconfig_ucfg VALUES ($iPersonID, $id, "
- . "'$ucfg_name', '$ucfg_value', '$ucfg_type', '$ucfg_tooltip', "
- . "$ucfg_permission, ' ')";
- $rsResult = RunQuery($sSQL);
+ $userConfig = new UserConfig();
+ $userConfig
+ ->setPeronId($iPersonID)
+ ->setId($id)
+ ->setName($ucfg_name)
+ ->setValue($ucfg_value)
+ ->setType($ucfg_type)
+ ->setTooltip($ucfg_tooltip)
+ ->setPermission($ucfg_permission);
+ $userConfig->save();
} else {
echo '
Error: Software BUG 3216';
exit;
diff --git a/src/UserEditor.php b/src/UserEditor.php
index ff540a1e72..3d85576080 100644
--- a/src/UserEditor.php
+++ b/src/UserEditor.php
@@ -27,13 +27,12 @@
use ChurchCRM\Emails\NewAccountEmail;
use ChurchCRM\model\ChurchCRM\PersonQuery;
use ChurchCRM\model\ChurchCRM\User;
+use ChurchCRM\model\ChurchCRM\UserConfig;
use ChurchCRM\model\ChurchCRM\UserQuery;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;
use Propel\Runtime\ActiveQuery\Criteria;
-;
-
// Security: User must be an Admin to access this page.
// Otherwise re-direct to the main menu.
if (!AuthenticationManager::getCurrentUser()->isAdmin()) {
@@ -299,10 +298,17 @@ function StyleSheetOptions($currentStyle)
list($ucfg_per_id, $ucfg_id, $ucfg_name, $ucfg_value, $ucfg_type,
$ucfg_tooltip, $ucfg_permission, $ucfg_cat) = $aDefaultRow;
- $sSQL = "INSERT INTO userconfig_ucfg VALUES ($iPersonID, $id, "
- . "'$ucfg_name', '$ucfg_value', '$ucfg_type', '" . htmlentities(addslashes($ucfg_tooltip), ENT_NOQUOTES, 'UTF-8') . "', "
- . "'$ucfg_permission', '$ucfg_cat')";
- $rsResult = RunQuery($sSQL);
+ $userConfig = new UserConfig();
+ $userConfig
+ ->setPeronId($iPersonID)
+ ->setId($id)
+ ->setName($ucfg_name)
+ ->setValue($ucfg_value)
+ ->setType($ucfg_type)
+ ->setTooltip($ucfg_tooltip)
+ ->setPermission($ucfg_permission)
+ ->setCat($ucfg_cat);
+ $userConfig->save();
} else {
echo '
Error on line ' . __LINE__ . ' of file ' . __FILE__;
exit;
diff --git a/src/VolunteerOpportunityEditor.php b/src/VolunteerOpportunityEditor.php
index 38ff41795b..078e49047a 100644
--- a/src/VolunteerOpportunityEditor.php
+++ b/src/VolunteerOpportunityEditor.php
@@ -12,6 +12,7 @@
require 'Include/Functions.php';
use ChurchCRM\Authentication\AuthenticationManager;
+use ChurchCRM\model\ChurchCRM\VolunteerOpportunity;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;
@@ -246,10 +247,14 @@
$rsOpps = RunQuery($sSQL);
$numRows = mysqli_num_rows($rsOpps);
$newOrder = $numRows + 1;
- $sSQL = "INSERT INTO `volunteeropportunity_vol`
- ( `vol_Order` , `vol_Name` , `vol_Description`)
- VALUES ( '" . $newOrder . "', '" . $newFieldName . "', '" . $newFieldDesc . "');";
- RunQuery($sSQL);
+
+ $volunteerOpp = new VolunteerOpportunity();
+ $volunteerOpp
+ ->setOrder($newOrder)
+ ->setName($newFieldName)
+ ->setDescription($newFieldDesc);
+ $volunteerOpp->save();
+
$bNewNameError = false;
}
}
diff --git a/src/WhyCameEditor.php b/src/WhyCameEditor.php
index 1462dbbdff..5381c5b409 100644
--- a/src/WhyCameEditor.php
+++ b/src/WhyCameEditor.php
@@ -18,6 +18,7 @@
require 'Include/Config.php';
require 'Include/Functions.php';
+use ChurchCRM\model\ChurchCRM\WhyCame;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;
@@ -41,17 +42,21 @@
// New input (add)
if (strlen($iWhyCameID) < 1) {
- $sSQL = 'INSERT INTO whycame_why (why_per_ID, why_join, why_come, why_suggest, why_hearOfUs)
- VALUES (' . $iPerson . ', "' . $tJoin . '", "' . $tCome . '", "' . $tSuggest . '", "' . $tHearOfUs . '")';
-
+ $whyCame = new WhyCame();
+ $whyCame
+ ->setPerId($iPerson)
+ ->setJoin($tJoin)
+ ->setCome($tCome)
+ ->setSuggest($tSuggest)
+ ->setHearOfUs($tHearOfUs);
+ $whyCame->save();
// Existing record (update)
} else {
$sSQL = 'UPDATE whycame_why SET why_join = "' . $tJoin . '", why_come = "' . $tCome . '", why_suggest = "' . $tSuggest . '", why_hearOfUs = "' . $tHearOfUs . '" WHERE why_per_ID = ' . $iPerson;
+ //Execute the SQL
+ RunQuery($sSQL);
}
- //Execute the SQL
- RunQuery($sSQL);
-
if (isset($_POST['Submit'])) {
// Check for redirection to another page after saving information: (ie. PledgeEditor.php?previousPage=prev.php?a=1;b=2;c=3)
if ($linkBack != '') {
diff --git a/src/api/routes/system/system.php b/src/api/routes/system/system.php
index 947d0c660f..56b4fe1ef5 100644
--- a/src/api/routes/system/system.php
+++ b/src/api/routes/system/system.php
@@ -30,7 +30,7 @@ function getUiNotificationAPI(Request $request, Response $response, array $args)
}
$notifications = [];
foreach (NotificationService::getNotifications() as $notification) {
- $uiNotification = new UiNotification($notification->title, 'bell', $notification->link, '', 'danger', '8000', 'bottom', 'left');
+ $uiNotification = new UiNotification($notification->getTitle(), 'bell', $notification->link, '', 'danger', 8000, 'bottom', 'left');
$notifications[] = $uiNotification;
}