Merge josh features and sagar features #11

Closed
MassiveAtoms wants to merge 20 commits from billing4real into billing
5 changed files with 30 additions and 10 deletions
Showing only changes of commit 03c40541a5 - Show all commits

View File

@ -70,6 +70,8 @@ void interface_admin(vector<Park_spot>& spots) {
cout << "[2] See weekly report of ALL parking spots\n";
cout << "[3] See monthly report of a specific parking spot\n";
cout << "[4] See weekly report of a specific parking spot\n";
cout << "[5] See monthly report of a specific customer\n";
cout << "[6] See weekly report of a specific customer\n";
cout << "Enter option number: ";
int option_1;
cin >> option_1;
@ -91,6 +93,12 @@ void interface_admin(vector<Park_spot>& spots) {
report_single_spot(true);
break;
}
case 5: {
report_customer(0);
}
case 6: {
report_customer(0, true);
}
default:
break;
}

View File

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

View File

@ -135,35 +135,46 @@ 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";
cout << "PS #" << i.id << "\n";
cout << "Taken: " << ((i.taken) ? "true" : "false") << "\n";
cout << "\n"<< i.id << "\t\t" << ((i.taken) ? "true" : "false");
if (i.taken) {
cout << "Customer#" << i.parked_customer << " parked there\n";
cout << "\t\t" << i.parked_customer;
}
}
cout << "\n";
}
vector<Park_time> reports_from_customer(int cid, pair<int, int> period) {
vector<Park_time> park_times;
// debug
cout << "it called";
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(2, period.first);
query.bind(3, period.second);
while (query.executeStep()) {
int id = query.getColumn(0);
int id = query.getColumn(1);
int spotid = query.getColumn(2);
int start = query.getColumn(3);
int duration = query.getColumn(5);
int duration = query.getColumn(6);
Park_time result{id, cid, spotid, start, duration};
park_times.push_back(result);
}
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";
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)");
"text, password text, vehicle int, telephone text, role int, address text)");
db.exec(
"create table if not exists Park_spot (id integer primary key, taken "
"int, customer_id int, vehicle_type int)");

View File

@ -17,3 +17,4 @@ pair<int, int> create_week_period();
// report stuff
void report_single_spot(bool weekly = false);
void report_all_spots(bool weekly = false);
void report_customer(int customerID, bool weekly = false);