works, fixed another db problem

This commit is contained in:
MassiveAtoms 2019-07-22 00:34:26 -03:00
parent 3bf5b26c2b
commit 9a471428a6
5 changed files with 5 additions and 5 deletions

View File

@ -60,7 +60,8 @@ std::ostream& operator<<(std::ostream& os, const Park_time& pt) {
os << "Customer # " << pt.customer_id << "at parking spot " << pt.spot_id << "\n"; os << "Customer # " << pt.customer_id << "at parking spot " << pt.spot_id << "\n";
os << "Clocked in :" << std::ctime(&start_); os << "Clocked in :" << std::ctime(&start_);
os << "clocked out : " << std::ctime(&end_); os << "clocked out : " << std::ctime(&end_);
os << "duration : " << pt.duration/3600 << "\n"; float dur_h = pt.duration / 3600.0;
os << "duration : " << dur_h << " h\n";
os << "- - - - - - - - - - - - - - - - - - - -\n"; os << "- - - - - - - - - - - - - - - - - - - -\n";
return os; return os;
} }

View File

@ -149,7 +149,6 @@ vector<Park_time> reports_from_customer(int cid, pair<int, int> period) {
vector<Park_time> park_times; vector<Park_time> park_times;
int verhicle = int(query_customer_with_id(cid).vehicle); int verhicle = int(query_customer_with_id(cid).vehicle);
float sum = 0; float sum = 0;
cout << period.first; // debug
SQLite::Statement query( SQLite::Statement query(
data::db, "SELECT * FROM Park_time WHERE customer_id = ? AND start > ? AND end < ?;"); data::db, "SELECT * FROM Park_time WHERE customer_id = ? AND start > ? AND end < ?;");
query.bind(1, cid); query.bind(1, cid);
@ -162,14 +161,14 @@ vector<Park_time> reports_from_customer(int cid, pair<int, int> period) {
int duration = query.getColumn(5); int duration = query.getColumn(5);
Park_time result{id, cid, spotid, start, duration}; Park_time result{id, cid, spotid, start, duration};
park_times.push_back(result); park_times.push_back(result);
sum += duration; sum += duration/3600;
} }
query.reset(); query.reset();
for (auto i : park_times) { for (auto i : park_times) {
cout << i; cout << i;
sum += i.duration / 3600; sum += i.duration / 3600.0;
} }
cout << "Your fees for this month: $" << sum * verhicle << "/n"; cout << "Your fees for this month: $" << sum * verhicle << "\n";
return park_times; return park_times;
} }

BIN
__test.db3 Normal file

Binary file not shown.

Binary file not shown.

BIN
test.db3

Binary file not shown.