From 617300a4c3f016f50e2dcf68203ced8be6dcf6f5 Mon Sep 17 00:00:00 2001 From: marcoalderighi Date: Thu, 18 May 2023 13:03:46 +0200 Subject: [PATCH] =?UTF-8?q?aggiunta=20funzionalit=C3=A0=20per=20il=20cambi?= =?UTF-8?q?o=20istruttore=20su=20AOP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../portlet/AdvancedOperationPortlet.java | 25 ++++++++++-- .../docroot/html/view.jsp | 39 ++++++++++++++++++- 2 files changed, 59 insertions(+), 5 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 1f6c22af..16c2a326 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 @@ -4,14 +4,12 @@ import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.exception.SystemException; import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; -import com.liferay.portal.kernel.search.Indexer; -import com.liferay.portal.kernel.search.IndexerRegistryUtil; -import com.liferay.portal.kernel.search.SearchException; import com.liferay.portal.kernel.servlet.SessionErrors; import com.liferay.portal.kernel.util.ParamUtil; import com.liferay.portal.kernel.util.Validator; import com.liferay.portal.kernel.util.WebKeys; import com.liferay.portal.kernel.workflow.WorkflowConstants; +import com.liferay.portal.kernel.workflow.WorkflowTask; import com.liferay.portal.service.UserLocalServiceUtil; import com.liferay.portal.theme.ThemeDisplay; import com.liferay.portal.util.PortalUtil; @@ -26,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.IntPraticaLocalServiceUtil; +import it.tref.liferay.portos.bo.util.WorkflowUtil; import java.util.List; @@ -120,6 +119,26 @@ 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); + long istruttoreId = ParamUtil.getLong(actionRequest, "istruttoreId", -1L); + IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(intPraticaId); + WorkflowTask lastTask = AdvancedOperationUtil.getLastTask(intPratica); + if (lastTask != null && lastTask.getName().equalsIgnoreCase("Esito")) { + List controlloPraticas = ControlloPraticaLocalServiceUtil.findByIntPratica(intPratica.getIntPraticaId()); + if(!controlloPraticas.isEmpty()){ + for(ControlloPratica controlloPratica : controlloPraticas){ + if(controlloPratica.getStatus() == WorkflowConstants.STATUS_PENDING){ + WorkflowUtil.assegnaUltimoTask(intPratica.getCompanyId(), intPratica.getGroupId(), + istruttoreId, themeDisplay.getUserId(), controlloPratica); + } + } + } + } + actionResponse.setRenderParameter("intPraticaId", String.valueOf(intPraticaId)); + } + public void fixUO(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception{ Privati.checkIfUserIsCompanyAdmin(actionRequest); 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 0e1152f0..5f634205 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 @@ -420,6 +420,7 @@ <% List listaTask = AdvancedOperationUtil.getListaTask(intPratica); if(Validator.isNotNull(listaTask) && !listaTask.isEmpty()){ + long currentAssigneeId = AdvancedOperationUtil.getCurrentAssignee(intPratica); %> @@ -448,10 +449,9 @@ <% - if(intPratica.getStatusByUserId() != 0L ){ + if(intPratica.getStatusByUserId() >= 0L ){ User tecnico = UserLocalServiceUtil.fetchUser(intPratica.getStatusByUserId()); if (Validator.isNotNull(tecnico)) { - %>
@@ -469,6 +469,41 @@ url="<%= impersonateIstruttoreURL %>">
+ + <% + String currentAssigneeName = StringPool.BLANK; + if(currentAssigneeId > 0L){ + currentAssigneeName = UserLocalServiceUtil.getUser(currentAssigneeId).getFullName(); + } + String cambiaIstruttoreMsg = currentAssigneeId != 0 ? "Pratica attualmente assegnata a " + currentAssigneeName : "Pratica attualmente senza assegnatario"; + String cambiaIstruttoreBtnLabelPrefix = currentAssigneeId != 0 ? "Riassegna" : "Assegna"; + %> +
+ + + + + + <% + String functionCambiaIstruttore = "javascript:"+renderResponse.getNamespace()+"openConfirmationDialog('"+renderResponse.getNamespace()+"cambiaIstruttore','Sei sicuro di voler riassegnare la pratica all istruttore?')"; + %> + + + + + (<%= cambiaIstruttoreMsg %>) + + +
+
<% }