diff --git a/Interface.cpp b/Interface.cpp index ca17dda..04f1773 100644 --- a/Interface.cpp +++ b/Interface.cpp @@ -95,9 +95,11 @@ void interface_admin(vector& 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 period; if (weekly) { - pair period = create_week_period(); + period = create_week_period(); } else { - pair period = create_month_period(); + period = create_month_period(); } reports_from_customer(customerID, period); } \ No newline at end of file diff --git a/Query.cpp b/Query.cpp index 5789c39..27d4900 100644 --- a/Query.cpp +++ b/Query.cpp @@ -137,7 +137,7 @@ void reports_from_allparkspots(pair period) { void current_status_parkspots(vector& spots) { cout << "P.spot \t\tStatus\t\t Customer\n"; for (auto& i : spots) { - cout << "\n"<< i.id << "\t\t" << ((i.taken) ? "true" : "false"); + cout << "\n" << i.id << "\t\t" << ((i.taken) ? "true" : "false"); if (i.taken) { cout << "\t\t" << i.parked_customer; } @@ -147,35 +147,29 @@ void current_status_parkspots(vector& spots) { vector reports_from_customer(int cid, pair period) { vector 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; + sum += i.duration / 3600; } - cout << "Your fees for this month: $" << sum << "/n"; + cout << "Your fees for this month: $" << sum * verhicle << "/n"; return park_times; } \ No newline at end of file diff --git a/data.cpp b/data.cpp index 2f4e599..0df1f7c 100644 --- a/data.cpp +++ b/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)");