void Report::reportOverdue() { std::vector <Borrower *> borrowers; borrowers = Service::getAllBorrowers(); // Javascript column headers array QString columns = "var columns = [ " "{ 'sTitle': 'ID' }, " "{ 'sTitle': 'Name' }, " "{ 'sTitle': 'Mobile' }, " "{ 'sTitle': 'Type' }, " "{ 'sTitle': 'Department' }, " "{ 'sTitle': 'Overdue items' }, " "];"; // Start javascript data array QString data = "var data = [ "; // Get data for the js array for (int i = 0; i < borrowers.size(); ++i) { Borrower *borrower = borrowers.at(i); QString overdues = Service::getOverdueTitlesBy(borrower); // Skip if this borrower has no overdues if (overdues.isEmpty()) { continue; } // ID, name, mobile, borrower type, department name, overdue titles data.append(QString("[%1, '%2', '%3', '%4', '%5', '%6']") .arg(borrower->getId()) .arg(borrower->getName()) .arg(borrower->getPhone()) .arg(borrower->getBorrowerType()->getName()) .arg(borrower->getDepartment()->getName()) .arg(overdues) ); if (i != borrowers.size() - 1) { data.append(","); } } // Close js data array data.append(" ];"); // Specify report name data.append(" tableName = 'Overdue'; "); data.append(columns); generateReport(data); }
void Report::reportBorrowers() { std::vector <Borrower *> borrowers; borrowers = Service::getAllBorrowers(); // Javascript column headers array QString columns = "var columns = [ " "{ 'sTitle': 'ID' }, " "{ 'sTitle': 'Name' }, " "{ 'sTitle': 'Mobile' }, " "{ 'sTitle': 'Type' }, " "{ 'sTitle': 'Department' }, " "{ 'sTitle': 'Items Borrowed (Past)' }, " "{ 'sTitle': 'Items Borrowing' }, " "];"; // Start javascript data array QString data = "var data = [ "; // Get data for the js array for (int i = 0; i < borrowers.size(); ++i) { Borrower *borrower = borrowers.at(i); std::vector<int> nums = Service::getNumbersOfItemsBorrowedBy(borrower); // ID, name, mobile, borrower type, department name, items borrowed, items borrowing data.append(QString("[%1, '%2', '%3', '%4', '%5', '%6', '%7']") .arg(borrower->getId()) .arg(borrower->getName()) .arg(borrower->getPhone()) .arg(borrower->getBorrowerType()->getName()) .arg(borrower->getDepartment()->getName()) .arg(QString("Borrowed %1") .arg(nums[0])) .arg(QString("Borrowing %1") .arg(nums[1])) ); if (i != borrowers.size() - 1) { data.append(","); } } // Close js data array data.append(" ];"); // Specify report name data.append(" tableName = 'Borrower'; "); data.append(columns); generateReport(data); }