Added report 'hours worked per worker in a month'
FEA: ItEr61S06ExceptionTypeEntity
This commit is contained in:
parent
341145a597
commit
d3ce1413ef
14 changed files with 708 additions and 1 deletions
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* This file is part of NavalPlan
|
||||
*
|
||||
* Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.navalplanner.business.reports.dtos;
|
||||
|
||||
import org.navalplanner.business.resources.entities.Worker;
|
||||
|
||||
|
||||
public class HoursWorkedPerWorkerInAMonthDTO {
|
||||
|
||||
private String workerName;
|
||||
|
||||
private Long numHours;
|
||||
|
||||
public HoursWorkedPerWorkerInAMonthDTO(Worker worker, Long numHours) {
|
||||
this.workerName = worker.getName();
|
||||
this.numHours = numHours;
|
||||
}
|
||||
|
||||
public Long getNumHours() {
|
||||
return numHours;
|
||||
}
|
||||
|
||||
public void setNumHours(Long numHours) {
|
||||
this.numHours = numHours;
|
||||
}
|
||||
|
||||
public String getWorkerName() {
|
||||
return workerName;
|
||||
}
|
||||
|
||||
public void setWorkerName(String workerName) {
|
||||
this.workerName = workerName;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getWorkerName() + "; " + getNumHours();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -28,6 +28,7 @@ import org.navalplanner.business.common.daos.IIntegrationEntityDAO;
|
|||
import org.navalplanner.business.labels.entities.Label;
|
||||
import org.navalplanner.business.planner.entities.Task;
|
||||
import org.navalplanner.business.reports.dtos.HoursWorkedPerResourceDTO;
|
||||
import org.navalplanner.business.reports.dtos.HoursWorkedPerWorkerInAMonthDTO;
|
||||
import org.navalplanner.business.resources.entities.Criterion;
|
||||
import org.navalplanner.business.resources.entities.Machine;
|
||||
import org.navalplanner.business.resources.entities.Resource;
|
||||
|
|
@ -120,9 +121,18 @@ public interface IResourceDAO extends IIntegrationEntityDAO<Resource> {
|
|||
* the specified dates.
|
||||
* @return
|
||||
*/
|
||||
public List<HoursWorkedPerResourceDTO> getWorkingHoursPerWorker(
|
||||
List<HoursWorkedPerResourceDTO> getWorkingHoursPerWorker(
|
||||
List<Resource> resources, List<Label> labels,
|
||||
List<Criterion> criterions, Date startingDate,
|
||||
Date endingDate);
|
||||
|
||||
/**
|
||||
* Returns all {@link HoursWorkedPerWorkerInAMonthDTO} in year and month
|
||||
*
|
||||
* @param year
|
||||
* @param month
|
||||
* @return
|
||||
*/
|
||||
List<HoursWorkedPerWorkerInAMonthDTO> getWorkingHoursPerWorker(Integer year, Integer month);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import org.navalplanner.business.common.daos.IntegrationEntityDAO;
|
|||
import org.navalplanner.business.labels.entities.Label;
|
||||
import org.navalplanner.business.planner.entities.Task;
|
||||
import org.navalplanner.business.reports.dtos.HoursWorkedPerResourceDTO;
|
||||
import org.navalplanner.business.reports.dtos.HoursWorkedPerWorkerInAMonthDTO;
|
||||
import org.navalplanner.business.resources.entities.Criterion;
|
||||
import org.navalplanner.business.resources.entities.LimitingResourceQueue;
|
||||
import org.navalplanner.business.resources.entities.Machine;
|
||||
|
|
@ -275,4 +276,49 @@ public class ResourceDAO extends IntegrationEntityDAO<Resource> implements
|
|||
return query.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HoursWorkedPerWorkerInAMonthDTO> getWorkingHoursPerWorker(
|
||||
Integer year, Integer month) {
|
||||
|
||||
String strQuery =
|
||||
"SELECT wrlresource.id, SUM(wrl.numHours) "
|
||||
+ "FROM WorkReportLine wrl "
|
||||
+ "LEFT OUTER JOIN wrl.resource wrlresource ";
|
||||
|
||||
if (year != null) {
|
||||
strQuery += "WHERE YEAR(wrl.date) = :year ";
|
||||
}
|
||||
if (month != null) {
|
||||
strQuery += "AND MONTH(wrl.date) = :month ";
|
||||
}
|
||||
|
||||
strQuery += "GROUP BY wrlresource.id, MONTH(wrl.date) ";
|
||||
|
||||
Query query = getSession().createQuery(strQuery);
|
||||
if (year != null) {
|
||||
query.setParameter("year", year);
|
||||
}
|
||||
if (month != null) {
|
||||
query.setParameter("month", month);
|
||||
}
|
||||
|
||||
List<HoursWorkedPerWorkerInAMonthDTO> result = toDTO(query.list());
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<HoursWorkedPerWorkerInAMonthDTO> toDTO(List<Object> rows) {
|
||||
List<HoursWorkedPerWorkerInAMonthDTO> result = new ArrayList<HoursWorkedPerWorkerInAMonthDTO>();
|
||||
|
||||
for (Object row: rows) {
|
||||
Object[] columns = (Object[]) row;
|
||||
Worker worker = (Worker) findExistingEntity((Long) columns[0]);
|
||||
Long numHours = (Long) columns[1];
|
||||
|
||||
HoursWorkedPerWorkerInAMonthDTO dto = new HoursWorkedPerWorkerInAMonthDTO(
|
||||
worker, numHours);
|
||||
result.add(dto);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,189 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="hoursWorkedPerWorkerInAMonth" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" resourceBundle="hoursWorkedPerWorkerInAMonth">
|
||||
<style name="Title" isDefault="false" fontName="Arial" fontSize="26" isBold="true" pdfFontName="Helvetica-Bold"/>
|
||||
<style name="SubTitle" isDefault="false" forecolor="#666666" fontName="Arial" fontSize="18"/>
|
||||
<style name="Column header" isDefault="false" forecolor="#666666" fontName="Arial" fontSize="12" isBold="true"/>
|
||||
<style name="Detail" isDefault="false" fontName="Arial" fontSize="12"/>
|
||||
<parameter name="showNote" class="java.lang.Boolean"/>
|
||||
<parameter name="year" class="java.lang.String"/>
|
||||
<parameter name="month" class="java.lang.String"/>
|
||||
<field name="workerName" class="java.lang.String"/>
|
||||
<field name="numHours" class="java.lang.Long"/>
|
||||
<variable name="sumNumHours" class="java.lang.Long" calculation="Sum">
|
||||
<variableExpression><![CDATA[$F{numHours}]]></variableExpression>
|
||||
<initialValueExpression><![CDATA[new java.lang.Long(0)]]></initialValueExpression>
|
||||
</variable>
|
||||
<background>
|
||||
<band splitType="Stretch"/>
|
||||
</background>
|
||||
<title>
|
||||
<band height="146" splitType="Stretch">
|
||||
<textField>
|
||||
<reportElement style="Title" x="0" y="13" width="263" height="33"/>
|
||||
<textElement verticalAlignment="Middle" markup="none"/>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA[$R{title}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField>
|
||||
<reportElement style="SubTitle" x="23" y="46" width="295" height="22"/>
|
||||
<textElement markup="none"/>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA[$R{subtitle}]]></textFieldExpression>
|
||||
</textField>
|
||||
<image scaleImage="RetainShape">
|
||||
<reportElement x="318" y="0" width="180" height="53"/>
|
||||
<imageExpression class="java.lang.String"><![CDATA["logos/logo.png"]]></imageExpression>
|
||||
</image>
|
||||
<textField>
|
||||
<reportElement x="0" y="80" width="48" height="15">
|
||||
<printWhenExpression><![CDATA[new java.lang.Boolean($P{year} != null)]]></printWhenExpression>
|
||||
</reportElement>
|
||||
<textElement markup="none">
|
||||
<font isBold="true"/>
|
||||
</textElement>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA[$R{parameters.year}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField>
|
||||
<reportElement x="96" y="80" width="48" height="15">
|
||||
<printWhenExpression><![CDATA[new java.lang.Boolean($P{month} != null)]]></printWhenExpression>
|
||||
</reportElement>
|
||||
<textElement markup="none">
|
||||
<font isBold="true"/>
|
||||
</textElement>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA[$R{parameters.month}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField>
|
||||
<reportElement x="13" y="102" width="540" height="15">
|
||||
<printWhenExpression><![CDATA[$P{showNote}.equals( java.lang.Boolean.TRUE )]]></printWhenExpression>
|
||||
</reportElement>
|
||||
<textElement markup="none">
|
||||
<font isBold="true"/>
|
||||
</textElement>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA[$R{note1}]]></textFieldExpression>
|
||||
</textField>
|
||||
<staticText>
|
||||
<reportElement x="5" y="102" width="8" height="15">
|
||||
<printWhenExpression><![CDATA[$P{showNote}.equals( java.lang.Boolean.TRUE )]]></printWhenExpression>
|
||||
</reportElement>
|
||||
<textElement/>
|
||||
<text><![CDATA[*]]></text>
|
||||
</staticText>
|
||||
<textField>
|
||||
<reportElement x="48" y="80" width="48" height="15"/>
|
||||
<textElement/>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA[$P{year}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField>
|
||||
<reportElement x="144" y="80" width="100" height="15"/>
|
||||
<textElement/>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA[$P{month}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField>
|
||||
<reportElement style="Column header" mode="Opaque" x="13" y="126" width="200" height="20" backcolor="#E0E4FB"/>
|
||||
<box>
|
||||
<pen lineWidth="1.0"/>
|
||||
<topPen lineWidth="1.0"/>
|
||||
<leftPen lineWidth="1.0"/>
|
||||
<bottomPen lineWidth="1.0"/>
|
||||
<rightPen lineWidth="1.0"/>
|
||||
</box>
|
||||
<textElement textAlignment="Center" verticalAlignment="Middle" markup="none">
|
||||
<font size="10" isBold="true"/>
|
||||
</textElement>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA[$R{headers.column1}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField>
|
||||
<reportElement style="Column header" mode="Opaque" x="213" y="126" width="100" height="20" backcolor="#E0E4FB"/>
|
||||
<box>
|
||||
<pen lineWidth="1.0"/>
|
||||
<topPen lineWidth="1.0"/>
|
||||
<leftPen lineWidth="1.0"/>
|
||||
<bottomPen lineWidth="1.0"/>
|
||||
<rightPen lineWidth="1.0"/>
|
||||
</box>
|
||||
<textElement textAlignment="Center" verticalAlignment="Middle" markup="none">
|
||||
<font size="10" isBold="true"/>
|
||||
</textElement>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA[$R{headers.column2}]]></textFieldExpression>
|
||||
</textField>
|
||||
</band>
|
||||
</title>
|
||||
<pageHeader>
|
||||
<band splitType="Stretch"/>
|
||||
</pageHeader>
|
||||
<columnHeader>
|
||||
<band splitType="Stretch"/>
|
||||
</columnHeader>
|
||||
<detail>
|
||||
<band height="15" splitType="Stretch">
|
||||
<textField isBlankWhenNull="true">
|
||||
<reportElement x="213" y="0" width="100" height="15"/>
|
||||
<textElement textAlignment="Center"/>
|
||||
<textFieldExpression class="java.lang.Long"><![CDATA[$F{numHours}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField isBlankWhenNull="true">
|
||||
<reportElement x="13" y="0" width="200" height="15"/>
|
||||
<textElement textAlignment="Center"/>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA[$F{workerName}]]></textFieldExpression>
|
||||
</textField>
|
||||
</band>
|
||||
</detail>
|
||||
<columnFooter>
|
||||
<band height="34" splitType="Stretch">
|
||||
<printWhenExpression><![CDATA[$P{showNote}.equals( java.lang.Boolean.FALSE )]]></printWhenExpression>
|
||||
<textField evaluationTime="Report" isBlankWhenNull="true">
|
||||
<reportElement x="213" y="10" width="100" height="15"/>
|
||||
<textElement textAlignment="Center"/>
|
||||
<textFieldExpression class="java.lang.Long"><![CDATA[$V{sumNumHours}]]></textFieldExpression>
|
||||
</textField>
|
||||
<line>
|
||||
<reportElement x="224" y="4" width="80" height="1"/>
|
||||
</line>
|
||||
<textField>
|
||||
<reportElement x="121" y="10" width="92" height="15">
|
||||
<printWhenExpression><![CDATA[new java.lang.Boolean($P{year} != null)]]></printWhenExpression>
|
||||
</reportElement>
|
||||
<textElement markup="none">
|
||||
<font isBold="true"/>
|
||||
</textElement>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA[$R{total.hours}]]></textFieldExpression>
|
||||
</textField>
|
||||
</band>
|
||||
</columnFooter>
|
||||
<pageFooter>
|
||||
<band height="27" splitType="Stretch">
|
||||
<textField pattern="EEEEE dd MMMMM yyyy">
|
||||
<reportElement style="Column header" x="0" y="0" width="197" height="20"/>
|
||||
<textElement>
|
||||
<font size="10" isBold="false"/>
|
||||
</textElement>
|
||||
<textFieldExpression class="java.util.Date"><![CDATA[new java.util.Date()]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField>
|
||||
<reportElement x="435" y="2" width="43" height="20"/>
|
||||
<textElement/>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA[$R{page}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField>
|
||||
<reportElement x="498" y="2" width="15" height="20"/>
|
||||
<textElement/>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA[$R{of}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField evaluationTime="Report">
|
||||
<reportElement style="Column header" x="515" y="2" width="38" height="20"/>
|
||||
<textElement>
|
||||
<font size="10" isBold="false"/>
|
||||
</textElement>
|
||||
<textFieldExpression class="java.lang.Integer"><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField>
|
||||
<reportElement style="Column header" x="478" y="2" width="15" height="20"/>
|
||||
<textElement textAlignment="Right">
|
||||
<font size="10" isBold="false"/>
|
||||
</textElement>
|
||||
<textFieldExpression class="java.lang.Integer"><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
|
||||
</textField>
|
||||
</band>
|
||||
</pageFooter>
|
||||
<summary>
|
||||
<band splitType="Stretch"/>
|
||||
</summary>
|
||||
</jasperReport>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
# Locale for hoursWorkedPerWorkerReport.jrxml
|
||||
title = Work report
|
||||
subtitle = Worked hours per worker in a month
|
||||
parameters.year = Year:
|
||||
parameters.month = Month:
|
||||
headers.column1 = Code
|
||||
headers.column2 = Name
|
||||
headers.column3 = Hours
|
||||
total.hours = Total hours:
|
||||
note1 = There are not work reports for selected resources in the search range.
|
||||
page = page
|
||||
of = of
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# Locale for hoursWorkedPerWorkerReportInAMonth.jrxml
|
||||
title = Work report
|
||||
subtitle = Worked hours per worker in a month
|
||||
parameters.year = Year:
|
||||
parameters.month = Month:
|
||||
headers.column1 = Name
|
||||
headers.column2 = Hours
|
||||
total.hours = Total hours:
|
||||
note1 = There are not work reports for selected resources in the search range.
|
||||
page = page
|
||||
of = of
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# Locale for hoursWorkedPerWorkerInAMonthReport.jrxml
|
||||
title = Informe de trabajo
|
||||
subtitle = Horas trabajadas por trabajador en un mes
|
||||
parameters.year = Año:
|
||||
parameters.month = Mes:
|
||||
headers.column1 = Nombre
|
||||
headers.column2 = Horas
|
||||
total.hours = Horas totales:
|
||||
note1 = No hay informes de trabajo para los recursos seleccionados en este intervalo
|
||||
page = página
|
||||
of = of
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# Locale for hoursWorkedPerWorkerInAMonthReport.jrxml
|
||||
title = Informe de traballo
|
||||
subtitle = Horas traballadas por traballador nun mes
|
||||
parameters.year = Ano:
|
||||
parameters.month = Mes:
|
||||
headers.column1 = Nome
|
||||
headers.column2 = Horas
|
||||
total.hours = Horas totais:
|
||||
note1 = Non hai informes de traballo para os recursos seleccionados neste intervalo
|
||||
page = páxina
|
||||
of = of
|
||||
|
|
@ -273,6 +273,7 @@ public class CustomMenuController extends Div implements IMenuItemsRegister {
|
|||
topItem(_("Reports"), "/reports/hoursWorkedPerWorkerReport.zul", "",
|
||||
subItem(_("Work Report Lines"), "/workreports/workReportQuery.zul", "09-partes.html#id4"),
|
||||
subItem(_("Hours Worked Per Resource"),"/reports/hoursWorkedPerWorkerReport.zul","15-informes.html"),
|
||||
subItem(_("Hours Worked Per Resource In A Month"),"/reports/hoursWorkedPerWorkerInAMonthReport.zul","15-informes.html"),
|
||||
subItem(_("Work And Progress Per Project"),"/reports/schedulingProgressPerOrderReport.zul", "15-informes.html"),
|
||||
subItem(_("Work And Progress Per Task"),"/reports/workingProgressPerTaskReport.zul", "15-informes.html"),
|
||||
subItem(_("Estimated/Planned Hours Per Task"),"/reports/completedEstimatedHoursPerTask.zul", "15-informes.html"),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* This file is part of NavalPlan
|
||||
*
|
||||
* Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.navalplanner.web.reports;
|
||||
|
||||
import static org.navalplanner.web.I18nHelper._;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.sf.jasperreports.engine.JRDataSource;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zul.Listbox;
|
||||
import org.zkoss.zul.Listitem;
|
||||
|
||||
/**
|
||||
* @author Diego Pino Garcia <dpino@igalia.com>
|
||||
*/
|
||||
public class HoursWorkedPerWorkerInAMonthController extends NavalplannerReportController {
|
||||
|
||||
private static final String REPORT_NAME = "hoursWorkedPerWorkerInAMonthReport";
|
||||
|
||||
private static final String months[] = { _("January"), _("February"),
|
||||
_("March"), _("April"), _("May"), _("June"), _("July"),
|
||||
_("August"), _("September"), _("October"), _("November"),
|
||||
_("December") };
|
||||
|
||||
@Autowired
|
||||
private IHoursWorkedPerWorkerInAMonthModel hoursWorkedPerWorkerInAMonthModel;
|
||||
|
||||
private Listbox lbYears;
|
||||
|
||||
private Listbox lbMonths;
|
||||
|
||||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
comp.setVariable("controller", this, true);
|
||||
hoursWorkedPerWorkerInAMonthModel.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getReportName() {
|
||||
return REPORT_NAME;
|
||||
}
|
||||
|
||||
private String getSelectedMonth() {
|
||||
return getSelectedValue(lbMonths);
|
||||
}
|
||||
|
||||
private String getSelectedValue(Listbox listbox) {
|
||||
Listitem item = listbox.getSelectedItem();
|
||||
return (item != null) ? (String) item.getValue() : getFirst(listbox);
|
||||
}
|
||||
|
||||
private String getFirst(Listbox listbox) {
|
||||
final Listitem item = (Listitem) listbox.getItems().iterator().next();
|
||||
return (String) item.getValue();
|
||||
}
|
||||
|
||||
private String getSelectedYear() {
|
||||
return getSelectedValue(lbYears);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JRDataSource getDataSource() {
|
||||
return hoursWorkedPerWorkerInAMonthModel.getHoursWorkedPerWorkerReport(
|
||||
asInt(getSelectedYear()), asInt(getSelectedMonth()));
|
||||
}
|
||||
|
||||
private Integer asInt(String str) {
|
||||
return Integer.parseInt(str);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> getParameters() {
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
|
||||
result.put("year", getSelectedYear());
|
||||
result.put("month", monthAsLiteral(getSelectedMonth()));
|
||||
result.put("showNote", hoursWorkedPerWorkerInAMonthModel.isShowReportMessage());
|
||||
return result;
|
||||
}
|
||||
|
||||
private String monthAsLiteral(String monthNumber) {
|
||||
Integer number = Integer.parseInt(monthNumber);
|
||||
return months[number-1];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* This file is part of NavalPlan
|
||||
*
|
||||
* Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.navalplanner.web.reports;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.sf.jasperreports.engine.JRDataSource;
|
||||
import net.sf.jasperreports.engine.JREmptyDataSource;
|
||||
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
|
||||
|
||||
import org.navalplanner.business.reports.dtos.HoursWorkedPerWorkerInAMonthDTO;
|
||||
import org.navalplanner.business.resources.daos.IResourceDAO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* @author Diego Pino Garcia <dpino@igalia.com>
|
||||
*/
|
||||
@Service
|
||||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
||||
public class HoursWorkedPerWorkerInAMonthModel implements IHoursWorkedPerWorkerInAMonthModel {
|
||||
|
||||
@Autowired
|
||||
private IResourceDAO resourceDAO;
|
||||
|
||||
private boolean showReportMessage = false;
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public JRDataSource getHoursWorkedPerWorkerReport(Integer year, Integer month) {
|
||||
|
||||
final List<HoursWorkedPerWorkerInAMonthDTO> workingHoursPerWorkerList = resourceDAO
|
||||
.getWorkingHoursPerWorker(year, month);
|
||||
|
||||
if (workingHoursPerWorkerList != null
|
||||
&& !workingHoursPerWorkerList.isEmpty()) {
|
||||
setShowReportMessage(false);
|
||||
return new JRBeanCollectionDataSource(workingHoursPerWorkerList);
|
||||
} else {
|
||||
setShowReportMessage(true);
|
||||
return new JREmptyDataSource();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public void init() {
|
||||
|
||||
}
|
||||
|
||||
public void setShowReportMessage(boolean showReportMessage) {
|
||||
this.showReportMessage = showReportMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShowReportMessage() {
|
||||
return showReportMessage;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* This file is part of NavalPlan
|
||||
*
|
||||
* Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.navalplanner.web.reports;
|
||||
|
||||
import net.sf.jasperreports.engine.JRDataSource;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Diego Pino Garcia <dpino@igalia.com>
|
||||
*
|
||||
*/
|
||||
public interface IHoursWorkedPerWorkerInAMonthModel {
|
||||
|
||||
JRDataSource getHoursWorkedPerWorkerReport(Integer year, Integer month);
|
||||
|
||||
void init();
|
||||
|
||||
boolean isShowReportMessage();
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
<!--
|
||||
This file is part of NavalPlan
|
||||
|
||||
Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
|
||||
Desenvolvemento Tecnolóxico de Galicia
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<?page title="${i18n:_('NavalPlan: Hours Worked Per Worker In A Month')}" id="reports"?>
|
||||
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>
|
||||
<?init class="org.zkoss.zk.ui.util.Composition" arg0="/common/layout/template.zul"?>
|
||||
|
||||
<?link rel="stylesheet" type="text/css" href="/common/css/navalplan.css"?>
|
||||
<?link rel="stylesheet" type="text/css" href="/common/css/navalplan_zk.css"?>
|
||||
|
||||
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
|
||||
|
||||
<?component name="combobox_output_format" macroURI="combobox_output_format.zul"
|
||||
class="org.navalplanner.web.reports.ComboboxOutputFormat" ?>
|
||||
|
||||
<?component name="extendedjasperreport"
|
||||
class="org.navalplanner.web.common.components.ExtendedJasperreport"
|
||||
extends="jasperreport" ?>
|
||||
|
||||
<zk id="hoursWorkedPerWorker" xmlns:n="http://www.zkoss.org/2005/zk/native">
|
||||
|
||||
<!--
|
||||
<n:script>
|
||||
var label = document.getElementById("z_sq_83");
|
||||
if(label.value != ""){
|
||||
alert('holaaaaa');
|
||||
new Label("Hi, JavaScript!").setParent(win);
|
||||
}
|
||||
</n:script>
|
||||
-->
|
||||
|
||||
<window self="@{define(content)}"
|
||||
apply="org.navalplanner.web.reports.HoursWorkedPerWorkerInAMonthController"
|
||||
title="${i18n:_('Hours Worked Per Resource In A Month')}"
|
||||
border="normal" >
|
||||
|
||||
<!-- Select workers -->
|
||||
<panel title="${i18n:_('Filter by month')}"
|
||||
border="normal"
|
||||
style="overflow:auto">
|
||||
|
||||
<panelchildren>
|
||||
<hbox>
|
||||
<vbox>
|
||||
<label value="${i18n:_('Year')}" />
|
||||
<listbox id="lbYears" rows="1" mold="select">
|
||||
<listitem label="${i18n:_('2010')}" value="2010" />
|
||||
<listitem label="${i18n:_('2011')}" value="2011" />
|
||||
</listbox>
|
||||
</vbox>
|
||||
<vbox>
|
||||
<label value="${i18n:_('Month')}" />
|
||||
<listbox id="lbMonths" rows="1" mold="select">
|
||||
<listitem label="${i18n:_('January')}" value="1" />
|
||||
<listitem label="${i18n:_('February')}" value="2" />
|
||||
<listitem label="${i18n:_('March')}" value="3" />
|
||||
<listitem label="${i18n:_('April')}" value="4" />
|
||||
<listitem label="${i18n:_('May')}" value="5" />
|
||||
<listitem label="${i18n:_('June')}" value="6" />
|
||||
<listitem label="${i18n:_('July')}" value="7" />
|
||||
<listitem label="${i18n:_('August')}" value="8" />
|
||||
<listitem label="${i18n:_('September')}" value="9" />
|
||||
<listitem label="${i18n:_('October')}" value="10" />
|
||||
<listitem label="${i18n:_('November')}" value="11" />
|
||||
<listitem label="${i18n:_('December')}" value="12" />
|
||||
</listbox>
|
||||
</vbox>
|
||||
</hbox>
|
||||
</panelchildren>
|
||||
</panel>
|
||||
|
||||
<separator spacing="10px" orient="horizontal" />
|
||||
|
||||
<!-- Select output format -->
|
||||
<panel title="${i18n:_('Format')}" border="normal"
|
||||
style="overflow:auto">
|
||||
<panelchildren>
|
||||
<grid width="700px">
|
||||
<columns>
|
||||
<column width="200px" />
|
||||
<column />
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<label value="${i18n:_('Output format:')}" />
|
||||
<combobox_output_format id="outputFormat" />
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
|
||||
</panelchildren>
|
||||
</panel>
|
||||
|
||||
<separator spacing="10px" orient="horizontal" />
|
||||
|
||||
<hbox style="display: none" id="URItext">
|
||||
<label value="${i18n:_('Click on ')}" />
|
||||
<toolbarbutton id="URIlink" class="z-label" zclass="z-label"
|
||||
label="${i18n:_('direct link')}" />
|
||||
<label value="${i18n:_(' to go to output directly')}" />
|
||||
</hbox>
|
||||
|
||||
<separator spacing="10px" orient="horizontal" />
|
||||
|
||||
<button label="Show" onClick="controller.showReport(report)" />
|
||||
|
||||
<extendedjasperreport style="display: none" id="report" />
|
||||
|
||||
</window>
|
||||
|
||||
</zk>
|
||||
3
pom.xml
3
pom.xml
|
|
@ -617,6 +617,9 @@
|
|||
<resource>
|
||||
<directory>../navalplanner-webapp/src/main/jasper/hoursWorkedPerWorker_Bundle/</directory>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>../navalplanner-webapp/src/main/jasper/hoursWorkedPerWorkerInAMonth_Bundle/</directory>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>../navalplanner-webapp/src/main/jasper/orderCostsPerResource_Bundle/</directory>
|
||||
</resource>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue