if (!it.hasNext()) {
WeekIndex planWeekIndex = new WeekIndex(weekIndex.getIndex() % sil.getWeekCount());
it = sil.daySelector(planWeekIndex, dayOfWeek);
}
DirectoryCabinetItem cabinet = null;
Calendar itemBegin = new GregorianCalendar();
itemBegin.setTime(item.getBegin());
Calendar itemEnd = new GregorianCalendar();
itemEnd.setTime(item.getEnd());
Calendar workBegin = new GregorianCalendar();
Calendar workEnd = new GregorianCalendar();
int year = itemBegin.get(Calendar.YEAR);
int month = itemBegin.get(Calendar.MONTH);
int dayy = itemBegin.get(Calendar.DAY_OF_MONTH);
while (it.hasNext()) {
SheduleIndividualData work = it.next();
workBegin.setTime(work.getBegin());
workBegin.set(year, month, dayy);
workEnd.setTime(work.getBegin());
workEnd.add(Calendar.MINUTE, work.getWorkDuration());
workEnd.set(year, month, dayy);
if ((itemBegin.after(workBegin) || itemBegin.equals(workBegin)) &&
(itemEnd.before(workEnd) || itemEnd.equals(workEnd))) {
cabinet = work.getCabinet();
break;
}
}
Calendar tb = GregorianCalendar.getInstance();
Calendar te = GregorianCalendar.getInstance();
tb.setTime(item.getBegin());
te.setTime(item.getEnd());
String period = String.format("%02d:%02d-%02d:%02d", tb.get(Calendar.HOUR_OF_DAY),
tb.get(Calendar.MINUTE), te.get(Calendar.HOUR_OF_DAY), te.get(Calendar.MINUTE));
data.put("period", "Время: " + period);
String services = "";
List<Integer> srl = item.getLinkedServicesList();
List<SerRenLocal> clientServices = getServices(item.getClient(am));
if (srl.size() != 0) {
for (int i = 0; i < clientServices.size(); i++) {
SerRenLocal s = clientServices.get(i);
if (srl.contains(s.getID())) {
services += " - " + s.getService().getTitle() + "\n";
}
}
}
else {
services += " нет привязанных услуг";
}
data.put("services", "Привязанные услуги: \n" + services);
if (!item.getDescription().isEmpty()) {
data.put("description", "Примечание: \n" + item.getDescription());
}
if (cabinet != null) {
String cab = cabinet.getTitle();
cab += " (" + cabinet.getDescription() + ")";
data.put("cabinet", "Кабинет: " + cab);
}
TableReportOptions ops = new TableReportOptions();
ops.setPageA5();