} else { $OFFSET = 0; $PAGE = 1; } $where_sql = ''; $params = array(); if ($from_date != 0) { $where_sql = 'paid_date > \'' . FormatTimeStamp($from_date) . '\''; $params[] = array(':from_date', FormatTimeStamp($from_date), 'str'); } if ($to_date != 0) { if (!empty($where_sql)) { $where_sql .= ' AND '; } $where_sql .= 'paid_date < \'' . FormatTimeStamp($to_date) . '\''; $params[] = array(':to_date', FormatTimeStamp($to_date), 'str'); } if ($list_type == 'm' || $list_type == 'w' || $list_type == 'd') { $OFFSET = 0; $PAGE = 1; $PAGES = 1; $show_pagnation = false; if ($list_type == 'm') { $query = "SELECT *, SUM(amount) As total FROM " . $DBPrefix . "accounts\n\t\t\t\t" . (!empty($where_sql) ? ' WHERE ' . $where_sql : '') . "\n\t\t\t\tGROUP BY month, year ORDER BY year, month"; } elseif ($list_type == 'w') { $query = "SELECT *, SUM(amount) As total FROM " . $DBPrefix . "accounts\n\t\t\t\t" . (!empty($where_sql) ? ' WHERE ' . $where_sql : '') . "\n\t\t\t\tGROUP BY week, year ORDER BY year, week"; } else { $query = "SELECT *, SUM(amount) As total FROM " . $DBPrefix . "accounts\n\t\t\t\t" . (!empty($where_sql) ? ' WHERE ' . $where_sql : '') . "\n\t\t\t\tGROUP BY day, year ORDER BY year, day"; } $db->query($query, $params); $bg = '';
} elseif (isset($_SESSION['RETURN_LIST_OFFSET']) && $_SESSION['RETURN_LIST'] == 'accounts.php') { $PAGE = intval($_SESSION['RETURN_LIST_OFFSET']); $OFFSET = ($PAGE - 1) * $system->SETTINGS['perpage']; } else { $OFFSET = 0; $PAGE = 1; } $where_sql = ''; if ($from_date != 0) { $where_sql = 'paid_date > \'' . FormatTimeStamp($from_date, '-') . '\''; } if ($to_date != 0) { if (!empty($where_sql)) { $where_sql .= ' AND '; } $where_sql .= 'paid_date < \'' . FormatTimeStamp($to_date, '-') . '\''; } if ($list_type == 'm' || $list_type == 'w' || $list_type == 'd') { $OFFSET = 0; $PAGE = 1; $PAGES = 1; $show_pagnation = false; if ($list_type == 'm') { $query = "SELECT *, SUM(amount) As total FROM " . $DBPrefix . "accounts\n\t\t\t\t" . (!empty($where_sql) ? ' WHERE ' . $where_sql : '') . "\n\t\t\t\tGROUP BY month, year ORDER BY year, month"; } elseif ($list_type == 'w') { $query = "SELECT *, SUM(amount) As total FROM " . $DBPrefix . "accounts\n\t\t\t\t" . (!empty($where_sql) ? ' WHERE ' . $where_sql : '') . "\n\t\t\t\tGROUP BY week, year ORDER BY year, week"; } else { $query = "SELECT *, SUM(amount) As total FROM " . $DBPrefix . "accounts\n\t\t\t\t" . (!empty($where_sql) ? ' WHERE ' . $where_sql : '') . "\n\t\t\t\tGROUP BY day, year ORDER BY year, day"; } $res = mysql_query($query); $system->check_mysql($res, $query, __LINE__, __FILE__);