Search in sources :

Example 1 with PFDateTime

use of org.projectforge.framework.time.PFDateTime in project projectforge by micromata.

the class AttrInputCellItemListenerPropertyColumn method populateItem.

/**
 * Call CellItemListener. If a property model object is of type I18nEnum then the translation is automatically used.
 *
 * @see org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn#populateItem(org.apache.wicket.markup.repeater.Item,
 *      java.lang.String, org.apache.wicket.model.IModel)
 * @see CellItemListener#populateItem(Item, String, IModel)
 */
@Override
public void populateItem(final Item<ICellPopulator<T>> item, final String componentId, final IModel<T> rowModel) {
    final EmployeeDO employee = (EmployeeDO) rowModel.getObject();
    PFDateTime dt = PFDateTime.withDate(selectedYear, selectedMonth, 1);
    EmployeeTimedDO row = timeableService.getAttrRowForSameMonth(employee, getPropertyExpression(), dt.getUtilDate());
    if (row == null) {
        row = employeeService.addNewTimeAttributeRow(employee, getPropertyExpression());
        row.setStartTime(dt.getUtilDate());
    }
    final AttrGroup attrGroup = guiAttrSchemaService.getAttrGroup(employee, getPropertyExpression());
    final AttrDescription attrDescription = guiAttrSchemaService.getAttrDescription(attrGroup, groupAttribute);
    item.add((Component) guiAttrSchemaService.createWicketComponent(componentId, attrGroup, attrDescription, row));
    if (cellItemListener != null) {
        cellItemListener.populateItem(item, componentId, rowModel);
    }
}
Also used : EmployeeTimedDO(org.projectforge.business.fibu.EmployeeTimedDO) AttrDescription(de.micromata.genome.db.jpa.tabattr.api.AttrDescription) EmployeeDO(org.projectforge.business.fibu.EmployeeDO) PFDateTime(org.projectforge.framework.time.PFDateTime) AttrGroup(de.micromata.genome.db.jpa.tabattr.api.AttrGroup)

Example 2 with PFDateTime

use of org.projectforge.framework.time.PFDateTime in project projectforge by micromata.

the class ExportDataPage method exportData.

public void exportData() {
    checkAccess();
    log.info("Export data for LB");
    List<EmployeeDO> employeeList = employeeDao.internalLoadAllNotDeleted();
    final String filename = "Liste-PF-" + form.selectedMonth + "-" + form.selectedYear + ".xls";
    PFDateTime dt = PFDateTime.from(new GregorianCalendar(form.selectedYear, form.selectedMonth - 1, 1).getTime());
    byte[] xls = exporterService.getExcel(employeeList, dt);
    if (xls == null || xls.length == 0) {
        log.error("Oups, xls has zero size. Filename: " + filename);
        return;
    }
    DownloadUtils.setDownloadTarget(xls, filename);
}
Also used : GregorianCalendar(java.util.GregorianCalendar) EmployeeDO(org.projectforge.business.fibu.EmployeeDO) PFDateTime(org.projectforge.framework.time.PFDateTime)

Example 3 with PFDateTime

use of org.projectforge.framework.time.PFDateTime in project projectforge by micromata.

the class IHKExporter method setFirstRow.

private void setFirstRow(final List<TimesheetDO> timesheets, ExcelSheet excelSheet) {
    PFDateTime mondayDate = PFDateTime.from(Objects.requireNonNull(timesheets.get(0).getStartTime())).getBeginOfWeek().getEndOfDay();
    PFDateTime sundayDate = mondayDate.getEndOfWeek().getEndOfDay();
    sdf.setTimeZone(timeZone);
    // run exception
    if (excelSheet == null) {
        return;
    }
    String contentOfCell = excelSheet.getRow(0).getCell(0).getStringCellValue();
    if (contentOfCell == null) {
        log.error("in setFirstRow(...) contentOfCell is null");
        return;
    }
    contentOfCell = contentOfCell.replace("#idName", getCurrentAzubiName());
    // KR: contentOfCell = contentOfCell.replace("#idYear", getCurrentAzubiYear(sundayDate));
    contentOfCell = contentOfCell.replace("#idYear", getCurrentAzubiYear(sundayDate.getUtilDate()));
    contentOfCell = contentOfCell.replace("#idNr", getDocNrByDate(sundayDate));
    contentOfCell = contentOfCell.replace("#idFirstDate", mondayDate.getLocalDate().format(DateTimeFormatter.ofPattern("dd.MM.yyyy")));
    contentOfCell = contentOfCell.replace("#idLastDate", sundayDate.getLocalDate().format(DateTimeFormatter.ofPattern("dd.MM.yyyy")));
    contentOfCell = contentOfCell.replace("#idDepartment", getDepartment());
    excelSheet.getRow(0).getCell(0).setCellValue(contentOfCell);
}
Also used : PFDateTime(org.projectforge.framework.time.PFDateTime)

Example 4 with PFDateTime

use of org.projectforge.framework.time.PFDateTime in project projectforge by micromata.

the class ProjectForgeRootElement method setCreated.

/**
 * Set the current time stamp as created value (millis=0).
 */
public ProjectForgeRootElement setCreated() {
    final PFDateTime dateTime = PFDateTime.now().withPrecision(DatePrecision.SECOND);
    created = dateTime.getUtilDate();
    return this;
}
Also used : PFDateTime(org.projectforge.framework.time.PFDateTime)

Example 5 with PFDateTime

use of org.projectforge.framework.time.PFDateTime in project projectforge by micromata.

the class MonthlyEmployeeReportForm method init.

@SuppressWarnings("serial")
@Override
protected void init() {
    super.init();
    gridBuilder.newSplitPanel(GridSize.COL50);
    {
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("timesheet.user"));
        if (accessChecker.hasLoggedInUserAccessToTimesheetsOfOtherUsers()) {
            final UserSelectPanel userSelectPanel = new UserSelectPanel(fs.newChildId(), new PropertyModel<PFUserDO>(filter, "user"), parentPage, "user");
            userSelectPanel.setRequired(true);
            fs.add(userSelectPanel);
            userSelectPanel.init();
        } else {
            filter.setUser(ThreadLocalUserContext.getUser());
            fs.add(new DivTextPanel(fs.newChildId(), filter.getUser().getFullname()));
        }
    }
    gridBuilder.newSplitPanel(GridSize.COL50);
    {
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("calendar.month"));
        yearChoice = new DropDownChoice<Integer>(fs.getDropDownChoiceId(), new PropertyModel<Integer>(filter, "year"), new ArrayList<Integer>()) {

            /**
             * @see org.apache.wicket.markup.html.form.DropDownChoice#wantOnSelectionChangedNotifications()
             */
            @Override
            protected boolean wantOnSelectionChangedNotifications() {
                return true;
            }
        };
        yearChoice.setNullValid(false).setRequired(true);
        fs.add(yearChoice);
        // DropDownChoice months
        final LabelValueChoiceRenderer<Integer> monthChoiceRenderer = new LabelValueChoiceRenderer<Integer>();
        for (int month = 1; month <= 12; month++) {
            monthChoiceRenderer.addValue(month, StringHelper.format2DigitNumber(month));
        }
        monthChoice = new DropDownChoice<Integer>(fs.getDropDownChoiceId(), new PropertyModel<Integer>(filter, "month"), monthChoiceRenderer.getValues(), monthChoiceRenderer) {

            /**
             * @see org.apache.wicket.markup.html.form.DropDownChoice#wantOnSelectionChangedNotifications()
             */
            @Override
            protected boolean wantOnSelectionChangedNotifications() {
                return true;
            }
        };
        monthChoice.setNullValid(false).setRequired(true);
        fs.add(monthChoice);
        final QuickSelectMonthPanel quickSelectPanel = new QuickSelectMonthPanel(fs.newChildId(), new Model<LocalDate>() {

            /**
             * @see org.apache.wicket.model.Model#getObject()
             */
            @Override
            public LocalDate getObject() {
                Integer year = filter.getYear();
                Integer month = filter.getMonth();
                PFDateTime date;
                if (year == null || month == null) {
                    date = PFDateTime.now().getBeginOfMonth();
                } else {
                    date = PFDateTime.withDate(filter.getYear(), PFDayUtils.validateMonthValue(filter.getMonth()), 1);
                }
                return date.getLocalDate();
            }

            /**
             * @see org.apache.wicket.model.Model#setObject(java.io.Serializable)
             */
            @Override
            public void setObject(final LocalDate object) {
                if (object != null) {
                    setDate(object);
                }
            }
        }, parentPage, "quickSelect");
        fs.add(quickSelectPanel);
        quickSelectPanel.init();
    }
    {
        final Button showButton = new Button(SingleButtonPanel.WICKET_ID, new Model<String>("show"));
        final SingleButtonPanel showButtonPanel = new SingleButtonPanel(actionButtons.newChildId(), showButton, getString("show"), SingleButtonPanel.DEFAULT_SUBMIT);
        actionButtons.add(showButtonPanel);
        setDefaultButton(showButton);
    }
}
Also used : PropertyModel(org.apache.wicket.model.PropertyModel) LocalDate(java.time.LocalDate) PFDateTime(org.projectforge.framework.time.PFDateTime) QuickSelectMonthPanel(org.projectforge.web.calendar.QuickSelectMonthPanel) UserSelectPanel(org.projectforge.web.user.UserSelectPanel) DivTextPanel(org.projectforge.web.wicket.flowlayout.DivTextPanel) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) Button(org.apache.wicket.markup.html.form.Button) LabelValueChoiceRenderer(org.projectforge.web.wicket.components.LabelValueChoiceRenderer) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) FieldsetPanel(org.projectforge.web.wicket.flowlayout.FieldsetPanel) SingleButtonPanel(org.projectforge.web.wicket.components.SingleButtonPanel)

Aggregations

PFDateTime (org.projectforge.framework.time.PFDateTime)62 Test (org.junit.jupiter.api.Test)13 Date (java.util.Date)7 LocalDate (java.time.LocalDate)5 BigDecimal (java.math.BigDecimal)4 TimesheetDO (org.projectforge.business.timesheet.TimesheetDO)4 EmployeeDO (org.projectforge.business.fibu.EmployeeDO)3 ProjektDO (org.projectforge.business.fibu.ProjektDO)3 TaskDO (org.projectforge.business.task.TaskDO)3 TimesheetFilter (org.projectforge.business.timesheet.TimesheetFilter)3 UserException (org.projectforge.common.i18n.UserException)3 Holidays (org.projectforge.framework.calendar.Holidays)3 DateFormat (java.text.DateFormat)2 SimpleDateFormat (java.text.SimpleDateFormat)2 ArrayList (java.util.ArrayList)2 XYDifferenceRenderer (org.jfree.chart.renderer.xy.XYDifferenceRenderer)2 Day (org.jfree.data.time.Day)2 TimeSeries (org.jfree.data.time.TimeSeries)2 TimeSeriesCollection (org.jfree.data.time.TimeSeriesCollection)2 ICalendarEvent (org.projectforge.business.calendar.event.model.ICalendarEvent)2