Пример #1
0
 public static function showIncomeDashboardbyDate($from = '', $to = '', $cat = '')
 {
     $resultInfo = array();
     $idUser = Zend_Registry::get('user')->getId();
     $expenses = new Default_Model_Expenses();
     $select = $expenses->getMapper()->getDbTable()->select()->from(array('p' => 'expenses'), array('price' => 'SUM(p.price)'));
     if ($cat != '') {
         $select->joinLeft(array('pg' => 'product_groups'), 'p.id=pg.idProduct', array())->where('pg.idGroup=?', $cat);
     }
     $select->where('NOT p.deleted')->where('p.idMember = ? ', $idUser)->where('p.type=?', 1);
     if ($from != '') {
         $select->where('p.date>=?', date('Y-m-d', strtotime($from)));
     }
     if ($to != '') {
         $select->where('p.date<=?', date('Y-m-d', strtotime($to)));
     }
     $result = $expenses->fetchRow($select);
     $amount = $result->getPrice();
     return $amount;
 }