if (hrPlanningEntryDao.hasLoggedInUserSelectAccess(false) == false) {
filter.setUserId(getUser().getId());
}
{
gridBuilder.newSplitPanel(GridSize.COL66);
final FieldsetPanel fs = gridBuilder.newFieldset(getString("timePeriod"));
startDate = new DatePanel(fs.newChildId(), new PropertyModel<Date>(filter, "startTime"), DatePanelSettings.get()
.withSelectPeriodMode(true).withRequired(true));
fs.add(startDate);
fs.setLabelFor(startDate);
fs.add(new DivTextPanel(fs.newChildId(), " - ").setRenderBodyOnly(false));
stopDate = new DatePanel(fs.newChildId(), new PropertyModel<Date>(filter, "stopTime"), DatePanelSettings.get()
.withSelectPeriodMode(true).withRequired(true));
fs.add(stopDate);
{
fs.add(new IconLinkPanel(fs.newChildId(), IconType.REMOVE_SIGN, new ResourceModel("calendar.tooltip.unselectPeriod"), new SubmitLink(
IconLinkPanel.LINK_ID) {
@Override
public void onSubmit()
{
getSearchFilter().setStartTime(null);
getSearchFilter().setStopTime(null);
clearInput();
parentPage.refresh();
};
}).setColor(CSSColor.RED));
}
final QuickSelectPanel quickSelectPanel = new QuickSelectPanel(fs.newChildId(), parentPage, "quickSelect", startDate);
fs.add(quickSelectPanel);
quickSelectPanel.init();
fs.add(new DivTextPanel(fs.newChildId(), new Model<String>() {
@Override
public String getObject()
{
return WicketUtils.getCalendarWeeks(HRPlanningListForm.this, filter.getStartTime(), filter.getStopTime());
}
}));
fs.add(new HtmlCommentPanel(fs.newChildId(), new Model<String>() {
@Override
public String getObject()
{
return WicketUtils.getUTCDates(filter.getStartTime(), filter.getStopTime());
}
}));
}
{
// Total hours
gridBuilder.newSplitPanel(GridSize.COL33);
final FieldsetPanel fs = gridBuilder.newFieldset(getString("timesheet.totalDuration")).suppressLabelForWarning();
fs.add(new TextPanel(fs.newChildId(), new Model<String>() {
@Override
public String getObject()
{
BigDecimal duration = new BigDecimal(0);
if (parentPage.getList() != null) {
for (final HRPlanningEntryDO sheet : parentPage.getList()) {
final BigDecimal temp = sheet.getTotalHours();
duration = duration.add(temp);
}
}
return duration.toString();
}
}));
}
boolean showProjectSelectPanel = false;
final boolean hasFullAccess = parentPage.hasFullAccess();
if (projektDao.hasLoggedInUserSelectAccess(false) == true) {
// Project
showProjectSelectPanel = true;
if (hasFullAccess == true) {
gridBuilder.newSplitPanel(GridSize.COL66);
} else {
gridBuilder.newGridPanel();
}
final FieldsetPanel fs = gridBuilder.newFieldset(getString("fibu.projekt"));
projektSelectPanel = new NewProjektSelectPanel(fs.newChildId(), new Model<ProjektDO>() {
@Override
public ProjektDO getObject()
{
return projektDao.getById(filter.getProjektId());
}
}, parentPage, "projektId");
fs.add(projektSelectPanel);
projektSelectPanel.init();
}
if (hasFullAccess == true) {
// User
if (showProjectSelectPanel == true) {
gridBuilder.newSplitPanel(GridSize.COL33);
}
final FieldsetPanel fs = gridBuilder.newFieldset(getString("user"));
final UserSelectPanel userSelectPanel = new UserSelectPanel(fs.newChildId(), new Model<PFUserDO>() {
@Override
public PFUserDO getObject()
{
return userGroupCache.getUser(filter.getUserId());
}
@Override
public void setObject(final PFUserDO object)
{
if (object == null) {
filter.setUserId(null);
} else {
filter.setUserId(object.getId());
}
}
}, parentPage, "userId");
fs.add(userSelectPanel);
userSelectPanel.setDefaultFormProcessing(false);
userSelectPanel.init().withAutoSubmit(true);
}
}