Created
July 7, 2010 18:07
-
-
Save MisterPhoton/467033 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returns all payments or invoices made within a certain date range. | |
* | |
* @param Zend_Date $start | |
* @param Zend_Date $end | |
* @return System_Db_DataObject_Collection | |
*/ | |
public static function getPaymentsByDateRange(Zend_Date $start, Zend_Date $end) { | |
require_once 'System/Db/DataObject/Collection.php'; | |
$collection = new System_Db_DataObject_Collection(self::getDao(), 'Guide_Invoice_Payment'); | |
$startDate = $start->get('yyyy-MM-dd 00:00:00'); | |
$endDate = $end->get('yyyy-MM-dd 23:59:59'); | |
// Payments will have dateCreated set, but not date. Invoices will have a dateCreated date of the time the proposal was | |
// created and a date value of the time the proposal was converted to an invoice, which is what we want in this case. | |
$collection->getSelect()->where('void = 0') | |
->where('proposal = 0') | |
->where(sprintf("dateCreated >= '%s' AND dateCreated <= '%s'", $startDate, $endDate)) | |
->orWhere(sprintf("date >= '%s' AND date <= '%s'", $startDate, $endDate)); | |
return $collection; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment