diff --git a/navalplanner-business/src/main/java/org/navalplanner/business/reports/dtos/HoursWorkedPerWorkerInAMonthDTO.java b/navalplanner-business/src/main/java/org/navalplanner/business/reports/dtos/HoursWorkedPerWorkerInAMonthDTO.java
new file mode 100644
index 000000000..c65378136
--- /dev/null
+++ b/navalplanner-business/src/main/java/org/navalplanner/business/reports/dtos/HoursWorkedPerWorkerInAMonthDTO.java
@@ -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 .
+ */
+
+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();
+ }
+
+}
\ No newline at end of file
diff --git a/navalplanner-business/src/main/java/org/navalplanner/business/resources/daos/IResourceDAO.java b/navalplanner-business/src/main/java/org/navalplanner/business/resources/daos/IResourceDAO.java
index 5e17c8e07..e22530c3b 100644
--- a/navalplanner-business/src/main/java/org/navalplanner/business/resources/daos/IResourceDAO.java
+++ b/navalplanner-business/src/main/java/org/navalplanner/business/resources/daos/IResourceDAO.java
@@ -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 {
* the specified dates.
* @return
*/
- public List getWorkingHoursPerWorker(
+ List getWorkingHoursPerWorker(
List resources, List labels,
List criterions, Date startingDate,
Date endingDate);
+ /**
+ * Returns all {@link HoursWorkedPerWorkerInAMonthDTO} in year and month
+ *
+ * @param year
+ * @param month
+ * @return
+ */
+ List getWorkingHoursPerWorker(Integer year, Integer month);
+
}
diff --git a/navalplanner-business/src/main/java/org/navalplanner/business/resources/daos/ResourceDAO.java b/navalplanner-business/src/main/java/org/navalplanner/business/resources/daos/ResourceDAO.java
index 379b3b7b4..933335cc5 100644
--- a/navalplanner-business/src/main/java/org/navalplanner/business/resources/daos/ResourceDAO.java
+++ b/navalplanner-business/src/main/java/org/navalplanner/business/resources/daos/ResourceDAO.java
@@ -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 implements
return query.list();
}
+ @Override
+ public List 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 result = toDTO(query.list());
+ return result;
+ }
+
+ private List toDTO(List rows) {
+ List result = new ArrayList();
+
+ 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;
+ }
+
}
\ No newline at end of file
diff --git a/navalplanner-webapp/src/main/jasper/hoursWorkedPerWorkerInAMonthReport.jrxml b/navalplanner-webapp/src/main/jasper/hoursWorkedPerWorkerInAMonthReport.jrxml
new file mode 100644
index 000000000..85ab903e2
--- /dev/null
+++ b/navalplanner-webapp/src/main/jasper/hoursWorkedPerWorkerInAMonthReport.jrxml
@@ -0,0 +1,189 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/navalplanner-webapp/src/main/jasper/hoursWorkedPerWorkerInAMonth_Bundle/hoursWorkedPerWorkerInAMonth.properties b/navalplanner-webapp/src/main/jasper/hoursWorkedPerWorkerInAMonth_Bundle/hoursWorkedPerWorkerInAMonth.properties
new file mode 100644
index 000000000..5eebd7722
--- /dev/null
+++ b/navalplanner-webapp/src/main/jasper/hoursWorkedPerWorkerInAMonth_Bundle/hoursWorkedPerWorkerInAMonth.properties
@@ -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
diff --git a/navalplanner-webapp/src/main/jasper/hoursWorkedPerWorkerInAMonth_Bundle/hoursWorkedPerWorkerInAMonth_en_US.properties b/navalplanner-webapp/src/main/jasper/hoursWorkedPerWorkerInAMonth_Bundle/hoursWorkedPerWorkerInAMonth_en_US.properties
new file mode 100644
index 000000000..228059eba
--- /dev/null
+++ b/navalplanner-webapp/src/main/jasper/hoursWorkedPerWorkerInAMonth_Bundle/hoursWorkedPerWorkerInAMonth_en_US.properties
@@ -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
diff --git a/navalplanner-webapp/src/main/jasper/hoursWorkedPerWorkerInAMonth_Bundle/hoursWorkedPerWorkerInAMonth_es_ES.properties b/navalplanner-webapp/src/main/jasper/hoursWorkedPerWorkerInAMonth_Bundle/hoursWorkedPerWorkerInAMonth_es_ES.properties
new file mode 100644
index 000000000..45b804c7f
--- /dev/null
+++ b/navalplanner-webapp/src/main/jasper/hoursWorkedPerWorkerInAMonth_Bundle/hoursWorkedPerWorkerInAMonth_es_ES.properties
@@ -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
diff --git a/navalplanner-webapp/src/main/jasper/hoursWorkedPerWorkerInAMonth_Bundle/hoursWorkedPerWorkerInAMonth_gl_ES.properties b/navalplanner-webapp/src/main/jasper/hoursWorkedPerWorkerInAMonth_Bundle/hoursWorkedPerWorkerInAMonth_gl_ES.properties
new file mode 100644
index 000000000..bca0d6084
--- /dev/null
+++ b/navalplanner-webapp/src/main/jasper/hoursWorkedPerWorkerInAMonth_Bundle/hoursWorkedPerWorkerInAMonth_gl_ES.properties
@@ -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
diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/common/CustomMenuController.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/common/CustomMenuController.java
index 83a52a081..60dd81e4e 100644
--- a/navalplanner-webapp/src/main/java/org/navalplanner/web/common/CustomMenuController.java
+++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/common/CustomMenuController.java
@@ -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"),
diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/reports/HoursWorkedPerWorkerInAMonthController.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/reports/HoursWorkedPerWorkerInAMonthController.java
new file mode 100644
index 000000000..e675cd92b
--- /dev/null
+++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/reports/HoursWorkedPerWorkerInAMonthController.java
@@ -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 .
+ */
+
+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
+ */
+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 getParameters() {
+ Map result = new HashMap();
+
+ 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];
+ }
+
+}
\ No newline at end of file
diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/reports/HoursWorkedPerWorkerInAMonthModel.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/reports/HoursWorkedPerWorkerInAMonthModel.java
new file mode 100644
index 000000000..cdbf74443
--- /dev/null
+++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/reports/HoursWorkedPerWorkerInAMonthModel.java
@@ -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 .
+ */
+
+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
+ */
+@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 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;
+ }
+
+}
diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/reports/IHoursWorkedPerWorkerInAMonthModel.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/reports/IHoursWorkedPerWorkerInAMonthModel.java
new file mode 100644
index 000000000..391c354e3
--- /dev/null
+++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/reports/IHoursWorkedPerWorkerInAMonthModel.java
@@ -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 .
+ */
+
+package org.navalplanner.web.reports;
+
+import net.sf.jasperreports.engine.JRDataSource;
+
+/**
+ *
+ * @author Diego Pino Garcia
+ *
+ */
+public interface IHoursWorkedPerWorkerInAMonthModel {
+
+ JRDataSource getHoursWorkedPerWorkerReport(Integer year, Integer month);
+
+ void init();
+
+ boolean isShowReportMessage();
+
+}
diff --git a/navalplanner-webapp/src/main/webapp/reports/hoursWorkedPerWorkerInAMonthReport.zul b/navalplanner-webapp/src/main/webapp/reports/hoursWorkedPerWorkerInAMonthReport.zul
new file mode 100644
index 000000000..787f6bb42
--- /dev/null
+++ b/navalplanner-webapp/src/main/webapp/reports/hoursWorkedPerWorkerInAMonthReport.zul
@@ -0,0 +1,128 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pom.xml b/pom.xml
index 4cd722879..a670fb29d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -617,6 +617,9 @@
../navalplanner-webapp/src/main/jasper/hoursWorkedPerWorker_Bundle/
+
+ ../navalplanner-webapp/src/main/jasper/hoursWorkedPerWorkerInAMonth_Bundle/
+
../navalplanner-webapp/src/main/jasper/orderCostsPerResource_Bundle/