Month generation in progress
This commit is contained in:
@@ -555,3 +555,53 @@ void Database::DeleteCategory(User* user, struct category category)
|
||||
|
||||
EXECUTE_SQL_UPDATE(req, );
|
||||
}
|
||||
|
||||
std::map<int, std::vector<int> > Database::GetAllOperations(User* user)
|
||||
{
|
||||
wxString req;
|
||||
wxSQLite3ResultSet set, set2;
|
||||
std::vector<Account>::iterator it;
|
||||
std::map<int, std::vector<int> > res;
|
||||
int year;
|
||||
|
||||
if (!user->_accounts.empty())
|
||||
{
|
||||
it = user->_accounts.begin();
|
||||
req = _("SELECT DISTINCT year FROM account_amount WHERE account IN('") + it->id;
|
||||
it++;
|
||||
for (;it != user->_accounts.end(); it++)
|
||||
{
|
||||
req += _("', '") + it->id ;
|
||||
}
|
||||
req += _("') ORDER BY year ASC");
|
||||
|
||||
EXECUTE_SQL_QUERY(req, set, res);
|
||||
|
||||
while (set.NextRow())
|
||||
{
|
||||
year = set.GetInt(_("year"));
|
||||
|
||||
it = user->_accounts.begin();
|
||||
req = _("SELECT DISTINCT month FROM account_amount WHERE account IN('") + it->id;
|
||||
it++;
|
||||
for (;it != user->_accounts.end(); it++)
|
||||
{
|
||||
req += _("', '") + it->id ;
|
||||
}
|
||||
req += _("')");
|
||||
req += _(" AND year='") + set.GetAsString(_("year")) + _("'");
|
||||
req += _(" ORDER BY month ASC");
|
||||
|
||||
EXECUTE_SQL_QUERY(req, set2, res);
|
||||
|
||||
while (set2.NextRow())
|
||||
{
|
||||
res[year].push_back(set2.GetInt(_("month")));
|
||||
}
|
||||
set2.Finalize();
|
||||
}
|
||||
set.Finalize();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,8 @@ class Database
|
||||
void UpdateCategory(User* user, wxString oldName, wxString name, wxString color);
|
||||
void DeleteCategory(User* user, struct category category);
|
||||
|
||||
std::map<int, std::vector<int> > GetAllOperations(User* user);
|
||||
|
||||
private:
|
||||
wxSQLite3Database _db;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user