/** * Returns an array of 2-item arrays, where each item has the following index: * 0: stewardship_fund_id * 1; total amount YTD * for a given month * @param QDateTime $dttMonth * @return string[][] */ public static function GetReportYtdByFundForMonth(QDateTime $dttMonth) { $dttMonth->Day = 1; $dttMonth->SetTime(null, null, null); $dttNextMonth = new QDateTime($dttMonth); $dttNextMonth->Month++; $dttNextMonth->SetTime(null, null, null); $dttMonth->Month = 1; $objResult = StewardshipPostAmount::GetDatabase()->Query(sprintf("SELECT stewardship_fund_id, SUM(amount) AS sum_amount FROM stewardship_post_amount, stewardship_post, stewardship_batch WHERE\n\t\t\t\tstewardship_batch_id=stewardship_batch.id AND\n\t\t\t\tstewardship_post_id=stewardship_post.id AND date_credited >= '%s' AND date_credited < '%s' GROUP BY stewardship_fund_id ORDER BY SUM(amount) DESC;", $dttMonth->ToString('YYYY-MM-DD'), $dttNextMonth->ToString('YYYY-MM-DD'))); $strToReturn = array(); while ($objRow = $objResult->GetNextRow()) { $strToReturn[] = array($objRow->GetColumn('stewardship_fund_id'), $objRow->GetColumn('sum_amount')); } return $strToReturn; }
/** * Gets the historical journal for an object from the log database. * Objects will have VirtualAttributes available to lookup login, date, and action information from the journal object. * @param integer intId * @return StewardshipPostAmount[] */ public static function GetJournalForId($intId) { $objDatabase = StewardshipPostAmount::GetDatabase()->JournalingDatabase; $objResult = $objDatabase->Query('SELECT * FROM stewardship_post_amount WHERE id = ' . $objDatabase->SqlVariable($intId) . ' ORDER BY __sys_date'); return StewardshipPostAmount::InstantiateDbResult($objResult); }