} else {
positionsPanel.setOpen();
}
positionsPanel.setHeading(getPositionHeading(position, positionsPanel));
final GridBuilder posGridBuilder = positionsPanel.createGridBuilder();
posGridBuilder.newGridPanel();
{
final FieldsetPanel fs = posGridBuilder.newFieldset(getString("fibu.auftrag.titel"));
fs.add(new MaxLengthTextField(InputPanel.WICKET_ID, new PropertyModel<String>(position, "titel")));
}
posGridBuilder.newSplitPanel(GridSize.COL33);
{
// DropDownChoice type
final FieldsetPanel fs = posGridBuilder.newFieldset(getString("fibu.auftrag.position.art"));
final LabelValueChoiceRenderer<AuftragsPositionsArt> artChoiceRenderer = new LabelValueChoiceRenderer<AuftragsPositionsArt>(fs,
AuftragsPositionsArt.values());
final DropDownChoice<AuftragsPositionsArt> artChoice = new DropDownChoice<AuftragsPositionsArt>(fs.getDropDownChoiceId(),
new PropertyModel<AuftragsPositionsArt>(position, "art"), artChoiceRenderer.getValues(), artChoiceRenderer);
artChoice.setNullValid(false);
artChoice.setRequired(true);
fs.add(artChoice);
}
posGridBuilder.newSplitPanel(GridSize.COL33);
{
// Person days
final FieldsetPanel fs = posGridBuilder.newFieldset(getString("projectmanagement.personDays"));
fs.add(new MinMaxNumberField<BigDecimal>(InputPanel.WICKET_ID, new PropertyModel<BigDecimal>(position, "personDays"),
BigDecimal.ZERO, MAX_PERSON_DAYS));
}
posGridBuilder.newSplitPanel(GridSize.COL33);
{
// Net sum
final FieldsetPanel fs = posGridBuilder.newFieldset(getString("fibu.auftrag.nettoSumme"));
fs.add(new TextField<String>(InputPanel.WICKET_ID, new PropertyModel<String>(position, "nettoSumme")) {
@SuppressWarnings({ "rawtypes", "unchecked"})
@Override
public IConverter getConverter(final Class type)
{
return new CurrencyConverter();
}
});
if (abgeschlossenUndNichtFakturiert == true) {
fs.setWarningBackground();
}
}
posGridBuilder.newSplitPanel(GridSize.COL33);
final Set<RechnungsPositionVO> invoicePositionsByOrderPositionId = rechnungCache
.getRechnungsPositionVOSetByAuftragsPositionId(position.getId());
final boolean showInvoices = CollectionUtils.isNotEmpty(invoicePositionsByOrderPositionId);
{
// Invoices
final FieldsetPanel fs = posGridBuilder.newFieldset(getString("fibu.rechnungen")).suppressLabelForWarning();
if (showInvoices == true) {
final InvoicePositionsPanel panel = new InvoicePositionsPanel(fs.newChildId());
fs.add(panel);
panel.init(invoicePositionsByOrderPositionId);
} else {
fs.add(AbstractUnsecureBasePage.createInvisibleDummyComponent(fs.newChildId()));
}
}
posGridBuilder.newSplitPanel(GridSize.COL33);
{
// invoiced
final FieldsetPanel fs = posGridBuilder.newFieldset(getString("fibu.fakturiert")).suppressLabelForWarning();
if (showInvoices == true) {
fs.add(new DivTextPanel(fs.newChildId(), CurrencyFormatter.format(RechnungDao.getNettoSumme(invoicePositionsByOrderPositionId))));
} else {
fs.add(AbstractUnsecureBasePage.createInvisibleDummyComponent(fs.newChildId()));
}
if (UserRights.getAccessChecker().hasRight(getUser(), RechnungDao.USER_RIGHT_ID, UserRightValue.READWRITE) == true) {
final DivPanel checkBoxDiv = fs.addNewCheckBoxButtonDiv();
checkBoxDiv.add(new CheckBoxButton(checkBoxDiv.newChildId(), new PropertyModel<Boolean>(position, "vollstaendigFakturiert"),
getString("fibu.auftrag.vollstaendigFakturiert")));
}
}
posGridBuilder.newSplitPanel(GridSize.COL33);
{
// DropDownChoice status
final FieldsetPanel fs = posGridBuilder.newFieldset(getString("status"));
final LabelValueChoiceRenderer<AuftragsPositionsStatus> statusChoiceRenderer = new LabelValueChoiceRenderer<AuftragsPositionsStatus>(
fs, AuftragsPositionsStatus.values());
final DropDownChoice<AuftragsPositionsStatus> statusChoice = new DropDownChoice<AuftragsPositionsStatus>(fs.getDropDownChoiceId(),
new PropertyModel<AuftragsPositionsStatus>(position, "status"), statusChoiceRenderer.getValues(), statusChoiceRenderer);
statusChoice.setNullValid(true);
statusChoice.setRequired(false);
fs.add(statusChoice);
if (abgeschlossenUndNichtFakturiert == true) {
fs.setWarningBackground();
}
}
posGridBuilder.newSplitPanel(GridSize.COL100);
{
// Task
final FieldsetPanel fs = posGridBuilder.newFieldset(getString("task"));
final TaskSelectPanel taskSelectPanel = new TaskSelectPanel(fs, new PropertyModel<TaskDO>(position, "task"), parentPage, "taskId:"
+ position.getNumber()) {
@Override
protected void selectTask(final TaskDO task)
{
super.selectTask(task);
parentPage.getBaseDao().setTask(position, task.getId());
}
};
fs.add(taskSelectPanel);
taskSelectPanel.init();
}
posGridBuilder.newSplitPanel(GridSize.COL100);
{
// Period of performance
final FieldsetPanel fs = posGridBuilder.newFieldset(getString("fibu.periodOfPerformance"));
final LabelValueChoiceRenderer<PeriodOfPerformanceType> performanceChoiceRenderer = new LabelValueChoiceRenderer<PeriodOfPerformanceType>(
fs, PeriodOfPerformanceType.values());
final DropDownChoice<PeriodOfPerformanceType> performanceChoice = new DropDownChoice<PeriodOfPerformanceType>(
fs.getDropDownChoiceId(), new PropertyModel<PeriodOfPerformanceType>(position, "periodOfPerformanceType"),
performanceChoiceRenderer.getValues(), performanceChoiceRenderer) {
/**
* @see org.apache.wicket.markup.html.form.AbstractSingleSelectChoice#getDefaultChoice(java.lang.String)
*/
@Override
protected CharSequence getDefaultChoice(final String selectedValue)
{
if (posHasOwnPeriodOfPerformance(position.getNumber()) == true) {
return super.getDefaultChoice(PeriodOfPerformanceType.OWN.toString());
} else {
return super.getDefaultChoice(PeriodOfPerformanceType.SEEABOVE.toString());
}
}
};
performanceChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {
@Override
protected void onUpdate(final AjaxRequestTarget target)
{
final short pos = position.getNumber();
final PeriodOfPerformanceType s = performanceChoice.getModelObject();
final boolean visible = s.equals(PeriodOfPerformanceType.OWN);
setPosPeriodOfPerformanceVisible(pos, visible);
if (ajaxPosTargets != null) {
for (final Component ajaxPosTarget : ajaxPosTargets)
target.add(ajaxPosTarget);
}
}
});
performanceChoice.setOutputMarkupPlaceholderTag(true);
fs.add(performanceChoice);
final DatePanel fromDatePanel = new DatePanel(fs.newChildId(), new PropertyModel<Date>(position, "periodOfPerformanceBegin"),
DatePanelSettings.get().withTargetType(java.sql.Date.class));
fromDatePanel.getDateField().setOutputMarkupPlaceholderTag(true);
fs.add(fromDatePanel);
ajaxPosTargets.add(fromDatePanel.getDateField());
dependentComponents.add(fromDatePanel);
final DivTextPanel divPanel = new DivTextPanel(fs.newChildId(), "-");
divPanel.getLabel4Ajax().setOutputMarkupPlaceholderTag(true);
fs.add(divPanel);
ajaxPosTargets.add(divPanel.getLabel4Ajax());
final DatePanel endDatePanel = new DatePanel(fs.newChildId(), new PropertyModel<Date>(position, "periodOfPerformanceEnd"),
DatePanelSettings.get().withTargetType(java.sql.Date.class));
endDatePanel.getDateField().setOutputMarkupPlaceholderTag(true);
fs.add(endDatePanel);
ajaxPosTargets.add(endDatePanel.getDateField());
dependentComponents.add(endDatePanel);
final LabelValueChoiceRenderer<ModeOfPaymentType> paymentChoiceRenderer = new LabelValueChoiceRenderer<ModeOfPaymentType>(fs,
ModeOfPaymentType.values());
final DropDownChoice<ModeOfPaymentType> paymentChoice = new DropDownChoice<ModeOfPaymentType>(fs.getDropDownChoiceId(),
new PropertyModel<ModeOfPaymentType>(position, "modeOfPaymentType"), paymentChoiceRenderer.getValues(), paymentChoiceRenderer);
paymentChoice.setOutputMarkupPlaceholderTag(true);
fs.add(paymentChoice);
ajaxPosTargets.add(paymentChoice);
}
posGridBuilder.newGridPanel();
{
// Comment
final FieldsetPanel fs = posGridBuilder.newFieldset(getString("comment"));
fs.add(new MaxLengthTextArea(TextAreaPanel.WICKET_ID, new PropertyModel<String>(position, "bemerkung")));
}
setPosPeriodOfPerformanceVisible(position.getNumber(), posHasOwnPeriodOfPerformance(position.getNumber()));
}
positionsDependentFormComponents = dependentComponents.toArray(new FormComponent[0]);