Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update updates to use propel orm #6867

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions propel/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@
<column name="usr_defaultFY" phpName="DefaultFY" type="SMALLINT" size="9" required="true" defaultValue="10"/>
<column name="usr_currentDeposit" phpName="CurrentDeposit" type="SMALLINT" size="9" required="true" defaultValue="0"/>
<column name="usr_UserName" phpName="UserName" type="VARCHAR" size="32" required="true"/>
<column name="usr_Style" phpName="UserStyle" type="VARCHAR" size="50" />
<column name="usr_ApiKey" phpName="ApiKey" type="VARCHAR" size="255" />
<column name="usr_TwoFactorAuthSecret" phpName="TwoFactorAuthSecret" type="VARCHAR" size="255" />
<column name="usr_TwoFactorAuthLastKeyTimestamp" phpName="TwoFactorAuthLastKeyTimestamp" type="SMALLINT" size="9" />
Expand Down
8 changes: 6 additions & 2 deletions src/BatchWinnerEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
require 'Include/Config.php';
require 'Include/Functions.php';

use ChurchCRM\model\ChurchCRM\DonatedItemQuery;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;

Expand Down Expand Up @@ -42,8 +43,11 @@
$di = $_POST["Item$row"];
$price = $_POST["SellPrice$row"];
if ($buyer > 0 && $di > 0 && $price > 0) {
$sSQL = "UPDATE donateditem_di SET di_buyer_id=$buyer, di_sellprice=$price WHERE di_ID=$di";
RunQuery($sSQL);
$donatedItem = DonatedItemQuery::create()->findOneById($di);
$donatedItem
->setBuyerId($buyer)
->setSellprice($price);
$donatedItem->save();
}
}
RedirectUtils::redirect($linkBack);
Expand Down
29 changes: 15 additions & 14 deletions src/CSVImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
use ChurchCRM\dto\SystemConfig;
use ChurchCRM\dto\SystemURLs;
use ChurchCRM\model\ChurchCRM\FamilyCustom;
use ChurchCRM\model\ChurchCRM\FamilyQuery;
use ChurchCRM\model\ChurchCRM\Note;
use ChurchCRM\model\ChurchCRM\PersonCustom;
use ChurchCRM\model\ChurchCRM\PersonQuery;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;

Expand Down Expand Up @@ -656,8 +658,10 @@ public function assignRoles()
);
$Families[$famid] = $fFamily;
}
$sSQL = 'UPDATE person_per SET per_fam_ID = ' . $famid . ' WHERE per_ID = ' . $per_ID;
RunQuery($sSQL);

$person = PersonQuery::create()->findOneById($per_ID);
$person->setFamId($famid);
$person->save();

if ($bHasFamCustom) {
// Check if family_custom record exists
Expand Down Expand Up @@ -789,26 +793,23 @@ public function assignRoles()
default:
$iRole = 0;
}
$sSQL = 'UPDATE person_per SET per_fmr_ID = ' . $iRole . ' WHERE per_ID = ' . $member['personid'];
RunQuery($sSQL);

$person = PersonQuery::create()->findOneById($member['personid']);
$person->setFmrId($iRole);
$person->save();
}

$valuesToUpdate = [];
$familyModel = FamilyQuery::create()->findOneById($fid);
if ($family->WeddingDate !== '') {
$valuesToUpdate[] = "fam_WeddingDate='$family->WeddingDate'";
$familyModel->setWeddingdate($family->WeddingDate);
}
if ($family->Phone !== '') {
$valuesToUpdate[] = "fam_HomePhone='$family->Phone'";
$familyModel->setHomePhone($family->Phone);
}
if ($family->Envelope !== 0) {
$valuesToUpdate[] = "fam_Envelope='$family->Envelope'";
}
if (!empty($valuesToUpdate)) {
$sSQL = 'UPDATE family_fam SET ' .
implode(',', $valuesToUpdate) .
" WHERE fam_ID = $fid";
RunQuery($sSQL);
$familyModel->setEnvelope($family->Envelope);
}
$familyModel->save();
}

$iStage = 3;
Expand Down
35 changes: 16 additions & 19 deletions src/CanvassEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use ChurchCRM\Authentication\AuthenticationManager;
use ChurchCRM\model\ChurchCRM\CanvassData;
use ChurchCRM\model\ChurchCRM\CanvassDataQuery;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;

Expand Down Expand Up @@ -78,26 +79,22 @@
->setNotInterested($bNotInterested)
->setWhyNotInterested($tWhyNotInterested);
$canvassData->save();

$sSQL = 'SELECT MAX(can_ID) AS iCanvassID FROM canvassdata_can';
$rsLastEntry = RunQuery($sSQL);
$newRec = mysqli_fetch_array($rsLastEntry);
$iCanvassID = $newRec['iCanvassID'];
$canvassData->reload();
$iCanvassID = $canvassData->getId();
} else {
$sSQL = 'UPDATE canvassdata_can SET can_famID=' . $iFamily . ',' .
'can_Canvasser=' . $iCanvasser . ',' .
'can_FYID=' . $iFYID . ',' .
'can_date="' . $dDate . '",' .
'can_Positive="' . $tPositive . '",' .
'can_Critical="' . $tCritical . '",' .
'can_Insightful="' . $tInsightful . '",' .
'can_Financial="' . $tFinancial . '",' .
'can_Suggestion="' . $tSuggestion . '",' .
'can_NotInterested="' . $bNotInterested . '",' .
'can_WhyNotInterested="' . $tWhyNotInterested .
'" WHERE can_FamID = ' . $iFamily;
//Execute the SQL
RunQuery($sSQL);
$canvassData = CanvassDataQuery::create()->findOneByFamilyId($iFamily);
$canvassData
->setCanvasser($iCanvasser)
->setFyid($iFYID)
->setDate($dDate)
->setPositive($tPositive)
->setCritical($tCritical)
->setInsightful($tInsightful)
->setFinancial($tFinancial)
->setSuggestion($tSuggestion)
->setNotInterested($bNotInterested)
->setWhyNotInterested($tWhyNotInterested);
$canvassData->save();
}

if (isset($_POST['Submit'])) {
Expand Down
9 changes: 7 additions & 2 deletions src/CartToFamily.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

use ChurchCRM\Authentication\AuthenticationManager;
use ChurchCRM\dto\SystemURLs;
use ChurchCRM\model\ChurchCRM\PersonQuery;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;

Expand Down Expand Up @@ -129,8 +130,12 @@
throw new \Exception(sprintf('person (%d) does not have role in post body', $iPersonID));
}

$sSQL = 'UPDATE person_per SET per_fam_ID = ' . $iFamilyID . ', per_fmr_ID = ' . $iFamilyRoleID . ' WHERE per_ID = ' . $iPersonID;
RunQuery($sSQL);
$person = PersonQuery::create()->findOneById($iPersonID);
$person
->setFamId($iFamilyID)
->setFmrId($iFamilyRoleID);
$person->save();

$iCount++;
}

Expand Down
16 changes: 10 additions & 6 deletions src/ChurchCRM/Service/FinancialService.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use ChurchCRM\dto\SystemURLs;
use ChurchCRM\MICRFunctions;
use ChurchCRM\model\ChurchCRM\Deposit;
use ChurchCRM\model\ChurchCRM\DepositQuery;
use ChurchCRM\model\ChurchCRM\FamilyQuery;
use ChurchCRM\model\ChurchCRM\Pledge;
use ChurchCRM\model\ChurchCRM\PledgeQuery;
Expand Down Expand Up @@ -52,14 +53,18 @@ public function getMemberByScanString($tScanString): array
public function setDeposit(string $depositType, string $depositComment, string $depositDate, $iDepositSlipID = null, $depositClosed = false): void
{
if ($iDepositSlipID) {
$sSQL = "UPDATE deposit_dep SET dep_Date = '" . $depositDate . "', dep_Comment = '" . $depositComment . "', dep_EnteredBy = " . AuthenticationManager::getCurrentUser()->getId() . ', dep_Closed = ' . intval($depositClosed) . ' WHERE dep_ID = ' . $iDepositSlipID . ';';
$bGetKeyBack = false;
$deposit = DepositQuery::create()->findOneById($iDepositSlipID);
$deposit
->setDate($depositDate)
->setComment($depositComment)
->setEnteredby(AuthenticationManager::getCurrentUser()->getId())
->setClosed(intval($depositClosed));
$deposit->save();
if ($depositClosed && ($depositType === 'CreditCard' || $depositType === 'BankDraft')) {
// Delete any failed transactions on this deposit slip now that it is closing
$q = 'DELETE FROM pledge_plg WHERE plg_depID = ' . $iDepositSlipID . ' AND plg_PledgeOrPayment="Payment" AND plg_aut_Cleared=0';
RunQuery($q);
}
RunQuery($sSQL);
} else {
$deposit = new Deposit();
$deposit
Expand All @@ -68,10 +73,9 @@ public function setDeposit(string $depositType, string $depositComment, string $
->setEnteredby(AuthenticationManager::getCurrentUser()->getId())
->setType($depositType);
$deposit->save();
$deposit->reload();

$sSQL = 'SELECT MAX(dep_ID) AS iDepositSlipID FROM deposit_dep';
$rsDepositSlipID = RunQuery($sSQL);
$iDepositSlipID = mysqli_fetch_array($rsDepositSlipID)[0];
$iDepositSlipID = $deposit->getId();
}
$_SESSION['iCurrentDeposit'] = $iDepositSlipID;
}
Expand Down
17 changes: 15 additions & 2 deletions src/ChurchCRM/Service/GroupService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace ChurchCRM\Service;

use ChurchCRM\model\ChurchCRM\ListOption;
use ChurchCRM\model\ChurchCRM\Person2group2roleP2g2r;
use ChurchCRM\model\ChurchCRM\PersonQuery;

class GroupService
Expand Down Expand Up @@ -72,10 +73,22 @@ public function addUserToGroup(int $iGroupID, int $iPersonID, int $iRoleID): arr
$iRoleID = $Row[0];
}

$sSQL = 'INSERT INTO person2group2role_p2g2r (p2g2r_per_ID, p2g2r_grp_ID, p2g2r_rle_ID) VALUES (' . $iPersonID . ', ' . $iGroupID . ', ' . $iRoleID . ')';
$result = RunQuery($sSQL, false);
$result = false;
try {
$person2group2role = new Person2group2roleP2g2r();
$person2group2role
->setPersonId($iPersonID)
->setGroupId($iGroupID)
->setRoleId($iRoleID);
$person2group2role->save();
$result = true;
} catch (\Throwable $t) {
// do nothing
}

if ($result) {
// Check if this group has special properties

$sSQL = 'SELECT grp_hasSpecialProps FROM group_grp WHERE grp_ID = ' . $iGroupID;
$rsTemp = RunQuery($sSQL);
$rowTemp = mysqli_fetch_row($rsTemp);
Expand Down
29 changes: 14 additions & 15 deletions src/ConvertIndividualToFamily.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

use ChurchCRM\Authentication\AuthenticationManager;
use ChurchCRM\model\ChurchCRM\Family;
use ChurchCRM\model\ChurchCRM\PersonQuery;
use ChurchCRM\Utils\RedirectUtils;

// Security
Expand Down Expand Up @@ -98,21 +99,19 @@
echo '<br><br>';

// Now update person record
$sSQL = 'UPDATE person_per ' .
"SET per_fam_ID='$iFamilyID'," .
' per_Address1=NULL,' .
' per_Address2=NULL,' .
' per_City=NULL,' .
' per_State=NULL,' .
' per_Zip=NULL,' .
' per_Country=NULL,' .
' per_HomePhone=NULL,' .
' per_DateLastEdited=NOW(),' .
" per_EditedBy='$curUserId' " .
"WHERE per_ID='$per_ID'";

echo '<br>' . $sSQL;
RunQuery($sSQL);
$person = PersonQuery::create()->findOneById($per_ID);
$person
->setFamId($iFamilyID)
->setAddress1(null)
->setAddress2(null)
->setCity(null)
->setState(null)
->setZip(null)
->setCountry(null)
->setHomePhone(null)
->setDateLastEdited(new \DateTimeImmutable())
->setEditedBy($curUserId);
$person->save();

echo '<br><br><br>';
echo "$per_FirstName $per_LastName (per_ID = $per_ID) is now part of the ";
Expand Down
24 changes: 18 additions & 6 deletions src/DonatedItemEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use ChurchCRM\Authentication\AuthenticationManager;
use ChurchCRM\dto\SystemURLs;
use ChurchCRM\model\ChurchCRM\DonatedItem;
use ChurchCRM\model\ChurchCRM\DonatedItemQuery;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;

Expand Down Expand Up @@ -90,15 +91,26 @@
$bGetKeyBack = true;
// Existing record (update)
} else {
$sSQL = 'UPDATE donateditem_di SET di_FR_ID = ' . $iCurrentFundraiser . ", di_Item = '" . $sItem . "', di_multibuy = '" . $bMultibuy . "', di_donor_ID = " . $iDonor . ', di_buyer_ID = ' . $iBuyer . ", di_title = '" . html_entity_decode($sTitle) . "', di_description = '" . html_entity_decode($sDescription) . "', di_sellprice = '" . $nSellPrice . "', di_estprice = '" . $nEstPrice . "', di_materialvalue = '" . $nMaterialValue . "', di_minimum = '" . $nMinimumPrice . "', di_picture = '" . mysqli_real_escape_string($cnInfoCentral, $sPictureURL) . "', di_EnteredBy=" . AuthenticationManager::getCurrentUser()->getId() . ", di_EnteredDate = '" . date('YmdHis') . "'";
$sSQL .= ' WHERE di_ID = ' . $iDonatedItemID;
echo '<br><br><br><br><br><br>' . $sSQL;
$donatedItem = DonatedItemQuery::create()->findOneById($iDonatedItemID);
$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 = false;
}

//Execute the SQL
RunQuery($sSQL);

// If this is a new DonatedItem or deposit, get the key back
if ($bGetKeyBack) {
$sSQL = 'SELECT MAX(di_ID) AS iDonatedItemID FROM donateditem_di';
Expand Down
11 changes: 7 additions & 4 deletions src/EditEventTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
require 'Include/Functions.php';

use ChurchCRM\Authentication\AuthenticationManager;
use ChurchCRM\model\ChurchCRM\EventTypeQuery;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;

Expand Down Expand Up @@ -51,8 +52,9 @@
$editing = 'FALSE';
$eName = $_POST['newEvtName'];
$theID = $_POST['EN_tyid'];
$sSQL = "UPDATE event_types SET type_name='" . InputUtils::legacyFilterInput($eName) . "' WHERE type_id='" . InputUtils::legacyFilterInput($theID) . "'";
RunQuery($sSQL);
$eventType = EventTypeQuery::create()->findOneById(InputUtils::legacyFilterInput($theID));
$eventType->setName(InputUtils::legacyFilterInput($eName));
$eventType->save();
$theID = '';
$_POST['Action'] = '';
break;
Expand All @@ -61,8 +63,9 @@
$editing = 'FALSE';
$eTime = $_POST['newEvtStartTime'];
$theID = $_POST['EN_tyid'];
$sSQL = "UPDATE event_types SET type_defstarttime='" . InputUtils::legacyFilterInput($eTime) . "' WHERE type_id='" . InputUtils::legacyFilterInput($theID) . "'";
RunQuery($sSQL);
$eventType = EventTypeQuery::create()->findOneById(InputUtils::legacyFilterInput($theID));
$eventType->setDefStartTime(InputUtils::legacyFilterInput($eTime));
$eventType->save();
$theID = '';
$_POST['Action'] = '';
break;
Expand Down
Loading
Loading