From c64b725639f79c64693b76905fd6e94358d79a54 Mon Sep 17 00:00:00 2001 From: marcoalderighi Date: Fri, 7 Jul 2023 15:16:39 +0200 Subject: [PATCH] - fix search container impersonamento - aggiunto pulsante reset data inizio lavori --- .../portlet/AdvancedOperationPortlet.java | 52 +++++++---- .../operation/util/AdvancedOperationUtil.java | 15 ++++ .../docroot/css/main.css | 4 + .../docroot/html/view.jsp | 90 ++++++++++++------- 4 files changed, 116 insertions(+), 45 deletions(-) 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 0f0d8ffb..a380e81f 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 @@ -37,11 +37,11 @@ import javax.portlet.ActionResponse; public class AdvancedOperationPortlet extends MVCPortlet { private static final Log _log = LogFactoryUtil.getLog(AdvancedOperationPortlet.class); - + public void deleteControlloPratica(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception{ _checkIfUserIsCompanyAdmin(actionRequest); - + long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0L); if (intPraticaId != 0L) { List controlloPraticaList = @@ -52,24 +52,24 @@ public class AdvancedOperationPortlet extends MVCPortlet { for(ControlloPratica cp : controlloPraticaList){ if(_log.isDebugEnabled()){ _log.debug("AdvancedOperationPortlet --- Cycling... ControlloPraticaID " + cp.getCompanyId() - + " Status " + cp.getStatus()); + + " Status " + cp.getStatus()); } if(ArrayUtil.contains(AdvancedOperationUtil.STATUS_ARRAY, cp.getStatus())){ _log.info("AdvancedOperationPortlet --- Deleting ControlloPratica " + cp.getControlloPraticaId() + - " with Status " + cp.getStatus() +" of IntPraticaId " + intPraticaId); + " with Status " + cp.getStatus() +" of IntPraticaId " + intPraticaId); ControlloPraticaLocalServiceUtil.deleteControlloPratica(cp); } } } actionResponse.setRenderParameter("intPraticaId", String.valueOf(intPraticaId)); } - + public void reindexPratica(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception{ _checkIfUserIsCompanyAdmin(actionRequest); - + ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); - + long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0L); if (intPraticaId != 0L) { _log.info("AdvancedOperationPortlet --- Reindexing fascicolo of IntPraticaId " + intPraticaId); @@ -77,23 +77,45 @@ public class AdvancedOperationPortlet extends MVCPortlet { } actionResponse.setRenderParameter("intPraticaId", String.valueOf(intPraticaId)); } - + public void cambiaDataInizioLavori(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception{ _checkIfUserIsCompanyAdmin(actionRequest); long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", -1L); + IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(intPraticaId); + Date dataInizioLavoriOpera = ParamUtil.getDate(actionRequest, "dataInizioLavoriOperaInput", DateFormatFactoryUtil.getSimpleDateFormat("yyyy-MM-dd"), null); - IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(intPraticaId); + _log.info("AdvancedOperationPortlet --- Changing DataInizioLavori on DettPraticas of IntPraticaId" + intPraticaId); + _setDataInizioLavori(intPratica, dataInizioLavoriOpera); + + actionResponse.setRenderParameter("intPraticaId", String.valueOf(intPraticaId)); + } + + public void resetDataInizioLavori(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception{ + + _checkIfUserIsCompanyAdmin(actionRequest); + + long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", -1L); + IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(intPraticaId); + + if(AdvancedOperationUtil.hasNoFineLavori(intPratica)){ + _log.info("AdvancedOperationPortlet --- Resetting DataInizioLavori on DettPraticas of IntPraticaId" + intPraticaId); + _setDataInizioLavori(intPratica, null); + } + actionResponse.setRenderParameter("intPraticaId", String.valueOf(intPraticaId)); + } + + private void _setDataInizioLavori(IntPratica intPratica, Date dataInizioLavoriOpera) + throws SystemException { List dettPraticaListWithInizioLavori = AdvancedOperationUtil.fetchDettPraticaListWithInizioLavori(intPratica); for(DettPratica dettPratica : dettPraticaListWithInizioLavori){ dettPratica.setDataInizioLavoriOpera(dataInizioLavoriOpera); dettPratica.setModifiedDate(new Date()); DettPraticaLocalServiceUtil.updateDettPratica(dettPratica); } - actionResponse.setRenderParameter("intPraticaId", String.valueOf(intPraticaId)); } public void fixNormLavoriInProprio(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception{ @@ -172,7 +194,7 @@ public class AdvancedOperationPortlet extends MVCPortlet { } actionResponse.setRenderParameter("intPraticaId", String.valueOf(intPraticaId)); } - + public void cambiaIstruttore(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception{ ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", -1L); @@ -192,14 +214,14 @@ public class AdvancedOperationPortlet extends MVCPortlet { } actionResponse.setRenderParameter("intPraticaId", String.valueOf(intPraticaId)); } - + public void fixUserID(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception{ _checkIfUserIsCompanyAdmin(actionRequest); - + long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", -1L); IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(intPraticaId); - + if(!AdvancedOperationUtil.evalInt_Dett_UserID(intPratica)){ DettPratica dettPratica = DettPraticaLocalServiceUtil.getLastEditableByIntPratica(intPratica.getIntPraticaId()); if(Validator.isNotNull(dettPratica)){ @@ -218,7 +240,7 @@ public class AdvancedOperationPortlet extends MVCPortlet { long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", -1L); IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(intPraticaId); - + if(WorkflowConstants.STATUS_INCOMPLETE == intPratica.getStatus()){ _log.info("AdvancedOperationPortlet --- Recovering Pratica Vidimata (INCOMPLETE ==> APPROVED) " + "with IntPraticaId " + intPraticaId); 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 f23544f9..e20005c5 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 @@ -18,10 +18,12 @@ import com.liferay.portal.service.WorkflowInstanceLinkLocalServiceUtil; 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.shared.util.Constants; import it.tref.liferay.portos.bo.shared.util.StatoPraticaConstants; import it.tref.liferay.portos.bo.util.WorkflowUtil; @@ -279,6 +281,19 @@ public class AdvancedOperationUtil { } return intPratica.getUserId(); } + + public static boolean hasNoFineLavori(IntPratica intPratica){ + if(Validator.isNotNull(intPratica)){ + try { + List fineLavoriList = + FineLavoriLocalServiceUtil.findByIntPraticaId(intPratica.getIntPraticaId(), QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); + return fineLavoriList.isEmpty(); + } catch (SystemException e) { + _log.error(e,e); + } + } + return false; + } private static List _getDettPraticaList(long intPraticaId) { List dettPraticaList = new ArrayList(); diff --git a/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/css/main.css b/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/css/main.css index fc1d01e6..e61e395a 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/css/main.css +++ b/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/css/main.css @@ -7,4 +7,8 @@ #impersonaSoggettiBtn{ cursor: pointer; +} + +.aop-ml-5{ + margin-left: 5px!important; } \ No newline at end of file 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 36a933c9..480c694f 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 @@ -39,6 +39,7 @@ <%@page import="com.liferay.portal.kernel.util.ParamUtil"%> <%@ include file="/html/init.jsp"%> + <% long intPraticaId = ParamUtil.getLong(request, "intPraticaId"); String numeroProgetto = ParamUtil.getString(request, "numeroProgetto", StringPool.BLANK); @@ -169,28 +170,51 @@ <% - String functionDataInizio = "javascript:"+renderResponse.getNamespace()+"openConfirmationDialog('"+renderResponse.getNamespace()+"cambiaDataInizioLavori','Sei sicuro di voler modificare la DATA di INIZIO LAVORI?')"; + String functionChangeDataInizio = "javascript:"+renderResponse.getNamespace()+"openConfirmationDialog('"+renderResponse.getNamespace()+"cambiaDataInizioLavori','Sei sicuro di voler MODIFICARE la DATA di INIZIO LAVORI?')"; %> - -
+
+ +

Data inizio Lavori Opera:

- - -
- + + +
+ +
-
-
+ + + + + + + <% + String functionResetDataInizio = "javascript:"+renderResponse.getNamespace()+"openConfirmationDialog('"+renderResponse.getNamespace()+"resetDataInizioLavori','Sei sicuro di voler RESETTARE la DATA di INIZIO LAVORI?')"; + %> + +
+ +
+
+
+
<% } %> @@ -433,10 +457,6 @@ total="<%= SoggettoLocalServiceUtil.countByIntPratica(intPraticaId) %>" /> - - <%= soggetto.getFullTipologiaSoggetto() %> @@ -451,14 +471,24 @@ } %> + <% + User soggettoUser = + UserLocalServiceUtil.fetchUserByScreenName(company.getCompanyId(), soggetto.getCodiceFiscale()); + %> - - + + + + + +