Merge josh features and sagar features #11
@ -95,9 +95,11 @@ void interface_admin(vector<Park_spot>& spots) {
|
|||||||
}
|
}
|
||||||
case 5: {
|
case 5: {
|
||||||
report_customer(0);
|
report_customer(0);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case 6: {
|
case 6: {
|
||||||
report_customer(0, true);
|
report_customer(0, true);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -307,9 +309,9 @@ void report_customer(int customerID, bool weekly) {
|
|||||||
}
|
}
|
||||||
pair<int, int> period;
|
pair<int, int> period;
|
||||||
if (weekly) {
|
if (weekly) {
|
||||||
pair<int, int> period = create_week_period();
|
period = create_week_period();
|
||||||
} else {
|
} else {
|
||||||
pair<int, int> period = create_month_period();
|
period = create_month_period();
|
||||||
}
|
}
|
||||||
reports_from_customer(customerID, period);
|
reports_from_customer(customerID, period);
|
||||||
}
|
}
|
28
Query.cpp
28
Query.cpp
@ -137,7 +137,7 @@ void reports_from_allparkspots(pair<int, int> period) {
|
|||||||
void current_status_parkspots(vector<Park_spot>& spots) {
|
void current_status_parkspots(vector<Park_spot>& spots) {
|
||||||
cout << "P.spot \t\tStatus\t\t Customer\n";
|
cout << "P.spot \t\tStatus\t\t Customer\n";
|
||||||
for (auto& i : spots) {
|
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) {
|
if (i.taken) {
|
||||||
cout << "\t\t" << i.parked_customer;
|
cout << "\t\t" << i.parked_customer;
|
||||||
}
|
}
|
||||||
@ -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> reports_from_customer(int cid, pair<int, int> period) {
|
||||||
vector<Park_time> park_times;
|
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(
|
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);
|
||||||
query.bind(2, period.first);
|
query.bind(2, period.first);
|
||||||
cout << "before\n";
|
|
||||||
query.bind(3, period.second);
|
query.bind(3, period.second);
|
||||||
cout << "after\n";
|
|
||||||
while (query.executeStep()) {
|
while (query.executeStep()) {
|
||||||
int id = query.getColumn(1);
|
int id = query.getColumn(0);
|
||||||
int spotid = query.getColumn(2);
|
int spotid = query.getColumn(2);
|
||||||
int start = query.getColumn(3);
|
int start = query.getColumn(3);
|
||||||
int duration = query.getColumn(6);
|
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;
|
||||||
}
|
}
|
||||||
query.reset();
|
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) {
|
for (auto i : park_times) {
|
||||||
cout << i;
|
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;
|
return park_times;
|
||||||
}
|
}
|
2
data.cpp
2
data.cpp
@ -20,7 +20,7 @@ SQLite::Database start_db() {
|
|||||||
}
|
}
|
||||||
db.exec(
|
db.exec(
|
||||||
"create table if not exists Customer (id integer primary key, name "
|
"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(
|
db.exec(
|
||||||
"create table if not exists Park_spot (id integer primary key, taken "
|
"create table if not exists Park_spot (id integer primary key, taken "
|
||||||
"int, customer_id int, vehicle_type int)");
|
"int, customer_id int, vehicle_type int)");
|
||||||
|
Loading…
Reference in New Issue
Block a user