Merge josh features and sagar features #11

Closed
MassiveAtoms wants to merge 20 commits from billing4real into billing
3 changed files with 16 additions and 20 deletions
Showing only changes of commit 3bf5b26c2b - Show all commits

View File

@ -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);
}

View File

@ -137,7 +137,7 @@ void reports_from_allparkspots(pair<int, int> period) {
void current_status_parkspots(vector<Park_spot>& 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<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;
sum += i.duration / 3600;
}
cout << "Your fees for this month: $" << sum << "/n";
cout << "Your fees for this month: $" << sum * verhicle << "/n";
return park_times;
}

View File

@ -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)");