Mage_Reports_Model_Mysql4_Invoiced_Collection Class Reference

Inheritance diagram for Mage_Reports_Model_Mysql4_Invoiced_Collection:

Mage_Sales_Model_Entity_Order_Collection Mage_Eav_Model_Entity_Collection_Abstract Varien_Data_Collection_Db Varien_Data_Collection

List of all members.

Public Member Functions

 setDateRange ($from, $to)
 setStoreIds ($storeIds)
 getSelectCountSql ()


Detailed Description

Definition at line 35 of file Collection.php.


Member Function Documentation

getSelectCountSql (  ) 

Get SQL for get record count

Returns:
Varien_Db_Select

Reimplemented from Varien_Data_Collection_Db.

Definition at line 90 of file Collection.php.

00091     {
00092         $countSelect = clone $this->getSelect();
00093         $countSelect->reset(Zend_Db_Select::ORDER);
00094         $countSelect->reset(Zend_Db_Select::LIMIT_COUNT);
00095         $countSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
00096         $countSelect->reset(Zend_Db_Select::COLUMNS);
00097         $countSelect->reset(Zend_Db_Select::GROUP);
00098         $countSelect->reset(Zend_Db_Select::HAVING);
00099         $countSelect->from("", "count(*)");
00100         $sql = $countSelect->__toString();
00101         return $sql;
00102     }

setDateRange ( from,
to 
)

Definition at line 38 of file Collection.php.

00039     {
00040         $this->_reset()
00041             ->addAttributeToSelect('*')
00042             ->addAttributeToFilter('created_at', array('from' => $from, 'to' => $to))
00043             ->addExpressionAttributeToSelect('orders',
00044                 'COUNT({{base_total_invoiced}})',
00045                  array('base_total_invoiced'))
00046             ->addExpressionAttributeToSelect('orders_invoiced',
00047                 'SUM(IF({{base_total_invoiced}} > 0, 1, 0))',
00048                  array('base_total_invoiced'))
00049             ->addAttributeToFilter('state', array('neq' => Mage_Sales_Model_Order::STATE_CANCELED))
00050             ->getSelect()->group('("*")')->having('orders > 0');
00051 
00052         return $this;
00053     }

setStoreIds ( storeIds  ) 

Definition at line 55 of file Collection.php.

00056     {
00057         $vals = array_values($storeIds);
00058         if (count($storeIds) >= 1 && $vals[0] != '') {
00059             $this->addAttributeToFilter('store_id', array('in' => (array)$storeIds))
00060                 ->addExpressionAttributeToSelect(
00061                     'invoiced',
00062                     'SUM({{base_total_invoiced}})',
00063                     array('base_total_invoiced'))
00064                 ->addExpressionAttributeToSelect(
00065                     'invoiced_captured',
00066                     'SUM({{base_total_paid}})',
00067                     array('base_total_paid'))
00068                 ->addExpressionAttributeToSelect(
00069                     'invoiced_not_captured',
00070                     'SUM({{base_total_invoiced}}-{{base_total_paid}})',
00071                     array('base_total_invoiced', 'base_total_paid'));
00072         } else {
00073             $this->addExpressionAttributeToSelect(
00074                     'invoiced',
00075                     'SUM({{base_total_invoiced}}*{{base_to_global_rate}})',
00076                     array('base_total_invoiced', 'base_to_global_rate'))
00077                 ->addExpressionAttributeToSelect(
00078                     'invoiced_captured',
00079                     'SUM({{base_total_paid}}*{{base_to_global_rate}})',
00080                     array('base_total_paid', 'base_to_global_rate'))
00081                 ->addExpressionAttributeToSelect(
00082                     'invoiced_not_captured',
00083                     'SUM(({{base_total_invoiced}}-{{base_total_paid}})*{{base_to_global_rate}})',
00084                     array('base_total_invoiced', 'base_to_global_rate', 'base_total_paid'));
00085         }
00086 
00087         return $this;
00088     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:36 2009 for Magento by  doxygen 1.5.8