void SearchViewExportAttendance() { system("CLS"); Semester m; string Class, courseID; if (!InputSandC(Class, m)) { return; } cout << "Course ID: "; getline(cin, courseID, '\n'); if (!ExistCourse(courseID, Class, m)) { cout << "Course isn't existing" << endl; return; } // Open file Class-Course ID to read ifstream fin("CS162\\Schedule\\" + m.year + "-" + m.semester + "-Schedule-" + Class + "-" + courseID + ".txt"); // Temp Course Course l; // Assign values to variables l TempDay(l, Class, courseID, m); int count; // Read number of elements fin >> count; // Initialize dynamic array Student* s = nullptr; s = new Student[count]; Score p1; cout << endl << "\t\t\ATTENDANCE IN COURSE " << courseID << " CLASS " << Class << endl << endl; cout << setfill('-'); cout << setw(76) << "-" << endl; cout << setfill(' '); cout << setw(3) << left << "No"; cout << setw(10) << left << "ID"; cout << setw(20) << left << "Name"; cout << setw(15) << left << "Date"; cout << setw(9) << left << "Start"; cout << setw(10) << left << "End"; cout << "Status" << endl; cout << setfill('-'); cout << setw(76) << "-" << endl; cout << setfill(' '); for (int i = 0; i < count; i++) { //Read Student fin.ignore(); ReadStudent(fin, s[i]); //Print ID and Full Name student cout << setw(3) << left << i + 1; cout << setw(10) << left << s[i].Account; cout << setw(20) << left << s[i].FullName; // Read Active , Print Score fin >> s[i].Active; ReadScore(fin, p1); ViewAttendance(fin, l.Day, l.startDay, l.endDay, l.hourStart, l.hourEnd); fin >> s[i].StatusCourse; cout << endl << endl; } fin.close(); delete[]s; } void ViewAttendance(ifstream& fin, int d, Date d1, Date d2, Time t1, Time t2) { int distance; // See the distance to the date to be considered if (DayOfWeek(d1) <= d) distance = d - DayOfWeek(d1); else distance = 8 - DayOfWeek(d1) + d - 1; // Move to the date in considered NextDays(d1, distance); int count = 0; while (CompareDay(d1, d2) <= 0) //Use loop to compare 2 times { if (count == 0) { PrintFirstAttendance(fin, d1, t1, t2); } else { PrintaAttendance(fin, d1, t1, t2); } count++; NextDays(d1, 7); } } void PrintaAttendance(ifstream& fin, Date d1, Time t1, Time t2) { int attendance; fin >> d1.year >> d1.month >> d1.day >> t1.hour >> t1.minute >> t2.hour >> t2.minute >> attendance; cout << endl; cout << setw(37) << right << d1.year << "/" << (d1.month < 10 ? "0" : "") << d1.month << "/" << (d1.day < 10 ? "0" : "") << d1.day; cout << setw(6) << right << t1.hour << ":" << (t1.minute < 10 ? "0" : "") << t1.minute; cout << setw(7) << right << t2.hour << ":" << (t2.minute < 10 ? "0" : "") << t2.minute; if (attendance == -1) { cout << setw(11) << right << "Absent"; } else { cout << setw(14) << right << "Attendant"; } } void PrintFirstAttendance(ifstream& fin, Date d1, Time t1, Time t2) { int attendance; fin >> d1.year >> d1.month >> d1.day >> t1.hour >> t1.minute >> t2.hour >> t2.minute >> attendance; cout << d1.year << "/" << (d1.month < 10 ? "0" : "") << d1.month << "/" << (d1.day < 10 ? "0" : "") << d1.day; cout << setw(6) << right <