Merge josh features and sagar features #11
@ -95,9 +95,11 @@ void interface_admin(vector<Park_spot>& spots) {
|
||||
}
|
||||
case 5: {
|
||||
report_customer(0);
|
||||
break;
|
||||
}
|
||||
case 6: {
|
||||
report_customer(0, true);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
@ -307,9 +309,9 @@ void report_customer(int customerID, bool weekly) {
|
||||
}
|
||||
pair<int, int> period;
|
||||
if (weekly) {
|
||||
pair<int, int> period = create_week_period();
|
||||
period = create_week_period();
|
||||
} else {
|
||||
pair<int, int> period = create_month_period();
|
||||
period = create_month_period();
|
||||
}
|
||||
reports_from_customer(customerID, period);
|
||||
}
|
24
Query.cpp
24
Query.cpp
@ -147,35 +147,29 @@ void current_status_parkspots(vector<Park_spot>& spots) {
|
||||
|
||||
vector<Park_time> reports_from_customer(int cid, pair<int, int> period) {
|
||||
vector<Park_time> park_times;
|
||||
// debug
|
||||
int verhicle = int(query_customer_with_id(cid).vehicle);
|
||||
float sum = 0;
|
||||
cout << period.first; // debug
|
||||
SQLite::Statement query(
|
||||
data::db, "SELECT * FROM Park_time WHERE 'customer_id' = '?' AND start > '?' AND end < '?';");
|
||||
// query.bind(1, cid);
|
||||
data::db, "SELECT * FROM Park_time WHERE customer_id = ? AND start > ? AND end < ?;");
|
||||
query.bind(1, cid);
|
||||
query.bind(2, period.first);
|
||||
cout << "before\n";
|
||||
query.bind(3, period.second);
|
||||
cout << "after\n";
|
||||
while (query.executeStep()) {
|
||||
int id = query.getColumn(1);
|
||||
int id = query.getColumn(0);
|
||||
int spotid = query.getColumn(2);
|
||||
int start = query.getColumn(3);
|
||||
int duration = query.getColumn(6);
|
||||
int duration = query.getColumn(5);
|
||||
Park_time result{id, cid, spotid, start, duration};
|
||||
park_times.push_back(result);
|
||||
sum += duration;
|
||||
}
|
||||
query.reset();
|
||||
|
||||
SQLite::Statement vtype(data::db, "SELECT * FROM Customer WHERE 'id' = '?' ;");
|
||||
query.bind(1, cid);
|
||||
int verhicle = 0;
|
||||
while (vtype.executeStep()) {
|
||||
verhicle = query.getColumn(4);
|
||||
}
|
||||
float sum;
|
||||
for (auto i : park_times) {
|
||||
cout << i;
|
||||
sum += i.duration / 3600;
|
||||
}
|
||||
cout << "Your fees for this month: $" << sum << "/n";
|
||||
cout << "Your fees for this month: $" << sum * verhicle << "/n";
|
||||
return park_times;
|
||||
}
|
2
data.cpp
2
data.cpp
@ -20,7 +20,7 @@ SQLite::Database start_db() {
|
||||
}
|
||||
db.exec(
|
||||
"create table if not exists Customer (id integer primary key, name "
|
||||
"text, password text, vehicle int, telephone text, role int, address text)");
|
||||
"text, password text, vehicle int, telephone text, role int)");
|
||||
db.exec(
|
||||
"create table if not exists Park_spot (id integer primary key, taken "
|
||||
"int, customer_id int, vehicle_type int)");
|
||||
|
Loading…
Reference in New Issue
Block a user