diff --git a/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/src/it/nextmind/liferay/portos/advanced/operation/portlet/AdvancedOperationPortlet.java b/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/src/it/nextmind/liferay/portos/advanced/operation/portlet/AdvancedOperationPortlet.java index 01bc9989..bb71a95b 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/src/it/nextmind/liferay/portos/advanced/operation/portlet/AdvancedOperationPortlet.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/src/it/nextmind/liferay/portos/advanced/operation/portlet/AdvancedOperationPortlet.java @@ -21,10 +21,13 @@ import it.nextmind.liferay.portos.advanced.operation.util.AdvancedOperationUtil; import it.tref.liferay.portos.bo.model.ControlloPratica; import it.tref.liferay.portos.bo.model.DettPratica; import it.tref.liferay.portos.bo.model.DocPratica; +import it.tref.liferay.portos.bo.model.FineLavori; import it.tref.liferay.portos.bo.model.IntPratica; import it.tref.liferay.portos.bo.service.ControlloPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil; +import it.tref.liferay.portos.bo.service.FineLavoriLocalServiceUtil; +import it.tref.liferay.portos.bo.service.FineLavoriServiceUtil; import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.util.WorkflowUtil; @@ -117,6 +120,29 @@ public class AdvancedOperationPortlet extends MVCPortlet { DettPraticaLocalServiceUtil.updateDettPratica(dettPratica); } } + + public void cambiaDataFineLavori(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception{ + + _checkIfUserIsCompanyAdmin(actionRequest); + + long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", -1L); + + Date dataFineLavori = ParamUtil.getDate(actionRequest, "dataFineLavoriInput", + DateFormatFactoryUtil.getSimpleDateFormat("yyyy-MM-dd"), null); + + _log.info("AdvancedOperationPortlet --- Changing DataFineLavori on DettPraticas of IntPraticaId" + intPraticaId); + _setDataFineLavori(intPraticaId, dataFineLavori); + + actionResponse.setRenderParameter("intPraticaId", String.valueOf(intPraticaId)); + } + + private void _setDataFineLavori(long intPraticaId, Date dataFineLavori) + throws SystemException { + FineLavori fineLavori = FineLavoriServiceUtil.getLastEditable(intPraticaId); + fineLavori.setDataFineLavori(dataFineLavori); + FineLavoriServiceUtil.updateFineLavori(fineLavori); + } + public void fixNormLavoriInProprio(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception{ @@ -188,6 +214,7 @@ public class AdvancedOperationPortlet extends MVCPortlet { _log.info("AdvancedOperationPortlet --- Recovering Pratica Vidimata (INCOMPLETE ==> DRAFT) " + "with IntPraticaId " + intPraticaId); _ripristinaPratica(intPratica, WorkflowConstants.STATUS_DRAFT); + // FIXME: Verificare se va settato lo status dell'ultimo DETTPRATICA a 0 } else { SessionErrors.add(actionRequest, "operazione-impossibile"); throw new Exception("This Pratica is not in status=5, action RIPRISTINA is not available"); diff --git a/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/src/it/nextmind/liferay/portos/advanced/operation/util/AdvancedOperationUtil.java b/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/src/it/nextmind/liferay/portos/advanced/operation/util/AdvancedOperationUtil.java index e20005c5..7fce98a4 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/src/it/nextmind/liferay/portos/advanced/operation/util/AdvancedOperationUtil.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/src/it/nextmind/liferay/portos/advanced/operation/util/AdvancedOperationUtil.java @@ -24,6 +24,7 @@ import it.tref.liferay.portos.bo.service.ControlloPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.FineLavoriLocalServiceUtil; +import it.tref.liferay.portos.bo.service.FineLavoriServiceUtil; import it.tref.liferay.portos.bo.shared.util.Constants; import it.tref.liferay.portos.bo.shared.util.StatoPraticaConstants; import it.tref.liferay.portos.bo.util.WorkflowUtil; @@ -282,6 +283,30 @@ public class AdvancedOperationUtil { return intPratica.getUserId(); } + public static boolean hasEditableFineLavori(IntPratica intPratica){ + if(Validator.isNotNull(intPratica)){ + try { + return Validator.isNotNull( + FineLavoriServiceUtil.getLastEditable(intPratica.getIntPraticaId())); + } catch (SystemException e) { + return false; + } + } + return false; + } + + public static Date getEditableFineLavoriDate(IntPratica intPratica){ + if(Validator.isNotNull(intPratica)){ + try { + return FineLavoriServiceUtil. + getLastEditable(intPratica.getIntPraticaId()).getDataFineLavori(); + } catch (SystemException e) { + return null; + } + } + return null; + } + public static boolean hasNoFineLavori(IntPratica intPratica){ if(Validator.isNotNull(intPratica)){ try { diff --git a/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/html/view.jsp b/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/html/view.jsp index 480c694f..33adf598 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/html/view.jsp +++ b/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/html/view.jsp @@ -1,3 +1,4 @@ +<%@page import="it.tref.liferay.portos.bo.service.FineLavoriServiceUtil"%> <%@page import="com.liferay.portal.model.Layout"%> <%@page import="it.tref.liferay.portos.bo.shared.util.PortletKeys"%> <%@page import="com.liferay.portal.kernel.util.HtmlUtil"%> @@ -415,6 +416,43 @@ + <% if(AdvancedOperationUtil.hasEditableFineLavori(intPratica)){ %> +
+ + + + + + + <% + String functionCambiaDataFineLavori = "javascript:"+renderResponse.getNamespace()+"openConfirmationDialog('"+renderResponse.getNamespace()+"cambiaDataFineLavori','Sei sicuro di voler MODIFICARE la DATA di FINE LAVORI?')"; + %> + +
+

Data Fine Lavori:

+ + + + +
+
+
+
+
+ <% } %>