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);
}
}
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);
}
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);
}
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;
}
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);
}
}
Aggregations