5 class BorrowerReportDetail : Detail
8 font = { "Arial", 10 };
12 Label movieName { this, anchor = { left = 44, top = 2, right = 0.30, bottom = 2 } };
13 Label dateBorrowed { this, anchor = { left = 0.5, top = 2, right = 0.20, bottom = 2 } };
18 BorrowerReport report = (BorrowerReport)((ReportDestination)master).GetReport();
19 RowMovies row = (RowMovies)report.groupings[1].row;
21 s = row.name; movieName.text = s; delete s;
22 s = PrintString((ShortDate)row.dateBorrowed); dateBorrowed.text = s; delete s;
27 class BorrowerReportPageHeader : Detail
30 font = { "Arial", 10, bold = true };
32 Label name { this, anchor = { left = 44, top = 9, right = 0.65, bottom = 2 }, text = "Movie Name" };
33 Label dateBorrowed { this, anchor = { left = 0.5, top = 9, right = 4, bottom = 2 }, text = "Date Borrowed" };
35 void OnRedraw(Surface surface)
37 int x = clientSize.w - 1, y = clientSize.h - 1;
38 surface.Rectangle(0, 5, x, y);
42 class BorrowerGroupHeader : Detail
45 font = { "Arial", 10, bold = true };
49 Label name { this, anchor = { left = 4, top = 7, right = 0.65, bottom = 2 } };
50 Label phone { this, anchor = { left = 0.4, top = 7, right = 4, bottom = 2 } };
55 BorrowerReport report = (BorrowerReport)((ReportDestination)master).GetReport();
56 RowBorrowers row = (RowBorrowers)report.groupings[0].row;
57 s = row.name; name.text = s; delete s;
58 s = row.phoneNumber; phone.text = s; delete s;
62 void OnRedraw(Surface surface)
64 int x = clientSize.w - 1, y = clientSize.h - 1;
65 surface.Rectangle(0, 4, x, y - 2);
69 class BorrowerGroupContinuation : Detail
72 font = { "Arial", 10, bold = true };
76 Label name { this, anchor = { left = 4, top = 7, right = 0.65, bottom = 2 } };
81 BorrowerReport report = (BorrowerReport)((ReportDestination)master).GetReport();
82 RowBorrowers row = (RowBorrowers)report.groupings[0].row;
84 s = PrintString(row.name, " (Continued)"); name.text = s; delete s;
88 void OnRedraw(Surface surface)
90 int x = clientSize.w - 1, y = clientSize.h - 1;
91 surface.Rectangle(0, 4, x, y - 2);
97 class BorrowerGroupFooter : Detail
100 font = { "Arial", 10, bold = true };
104 Label title { this, anchor = { left = 0.85, top = 9, right = 0.03, bottom = 2 }, text = "Total count:" };
105 Label total { this, anchor = { left = 0.97, top = 9, right = 9, bottom = 2 } };
109 String s = PrintString(numMovies);
115 void OnRedraw(Surface surface)
117 int x = clientSize.w - 1, y = clientSize.h - 1;
118 surface.HLine(0, x, 5);
122 class BorrowerGrouping : Grouping
124 RowMovies rowMovies { };
127 RowBorrowers r = (RowBorrowers)row;
129 return !rowMovies.Find(dbfield("Movies", borrower), middle, nil, id);
135 class BorrowerReport : CommonReport
137 pageHeader = class(BorrowerReportPageHeader);
138 rowDetail = class(BorrowerReportDetail);
144 groupings[1] = groupings[0];
146 groupings[0] = BorrowerGrouping { };
147 groupings[0].field = dbfield("Borrowers", id);
148 groupings[0].header = class(BorrowerGroupHeader);
149 groupings[0].continuation = class(BorrowerGroupContinuation);
150 groupings[0].footer = class(BorrowerGroupFooter);
153 bool ExecuteData(Database db)
159 t -= 60 * 60 * 24 * daysAgo; // Go back 90 days
164 static char reportTitle[256];
165 sprintf(reportTitle, "Movies borrowed for more than %d days", daysAgo);
169 title = "Borrowed movies";
171 groupings[0].row = RowBorrowers { };
172 groupings[0].row.query = "SELECT ROWID, * FROM `Borrowers` ORDER BY `Name`;";
173 groupings[0].row.Select(nil);
175 groupings[1].row = RowMovies { };
176 groupings[1].row.query = "SELECT ROWID, * FROM `Movies` WHERE `Date Borrowed` < ? AND `Borrower` = ? ORDER BY `Date Borrowed`;";
177 groupings[1].row.SetQueryParamObject(1, Date { d.year, d.month, d.day }, class(Date));
181 void ExecuteRowData(int group)
185 groupings[1].row.SetQueryParam(2, (int)groupings[0].row.sysID);