Esempio n. 1
0
 /**
  * This returns a 2d array, where the first index is the TransactionTypeId and second is the count of transactions
  * in the current batch that goes to that transaction type
  * @return integer[][]
  */
 public function GetContributionTypeCountArray()
 {
     $intArrayToReturn = array();
     $objResult = StewardshipContribution::GetDatabase()->Query('SELECT stewardship_contribution_type_id, count(id) AS row_count ' . 'FROM stewardship_contribution WHERE stewardship_batch_id=' . $this->intId . ' GROUP BY stewardship_contribution_type_id;');
     while ($objRow = $objResult->GetNextRow()) {
         $intArrayToReturn[] = array($objRow->GetColumn('stewardship_contribution_type_id'), $objRow->GetColumn('row_count'));
     }
     return $intArrayToReturn;
 }
Esempio n. 2
0
 /**
  * This will move all the transactions for a given year to be credited to another person
  * @param integer $intYear
  * @param Person $objPerson
  */
 public function MoveStewardshipTransactions($intYear, Person $objPerson)
 {
     StewardshipContribution::GetDatabase()->TransactionBegin();
     $objArray = StewardshipContribution::QueryArray(QQ::AndCondition(QQ::Equal(QQN::StewardshipContribution()->PersonId, $this->intId), QQ::GreaterOrEqual(QQN::StewardshipContribution()->DateCredited, new QDateTime($intYear . '-01-01')), QQ::LessThan(QQN::StewardshipContribution()->DateCredited, new QDateTime($intYear + 1 . '-01-01'))));
     foreach ($objArray as $objContribution) {
         $objContribution->Person = $objPerson;
         $objContribution->Save();
         foreach ($objContribution->GetStewardshipPostLineItemArray() as $objLineItem) {
             $objLineItem->Person = $objPerson;
             $objLineItem->Save();
         }
     }
     StewardshipContribution::GetDatabase()->TransactionCommit();
 }
    /**
     * Deletes all associated StewardshipPostLineItems
     * @return void
     */
    public function DeleteAllStewardshipPostLineItems()
    {
        if (is_null($this->intId)) {
            throw new QUndefinedPrimaryKeyException('Unable to call UnassociateStewardshipPostLineItem on this unsaved StewardshipContribution.');
        }
        // Get the Database Object for this Class
        $objDatabase = StewardshipContribution::GetDatabase();
        // Journaling
        if ($objDatabase->JournalingDatabase) {
            foreach (StewardshipPostLineItem::LoadArrayByStewardshipContributionId($this->intId) as $objStewardshipPostLineItem) {
                $objStewardshipPostLineItem->Journal('DELETE');
            }
        }
        // Perform the SQL Query
        $objDatabase->NonQuery('
				DELETE FROM
					`stewardship_post_line_item`
				WHERE
					`stewardship_contribution_id` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
    }