diff --git a/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/lib/portos-bo-portlet-service.jar b/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/lib/portos-bo-portlet-service.jar index bf17ad8a..a7ad6bcd 100644 Binary files a/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/lib/portos-bo-portlet-service.jar and b/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/lib/portos-bo-portlet-service.jar differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/lib/portos-bo-shared.jar b/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/lib/portos-bo-shared.jar index f8e54d4a..94db0c76 100644 Binary files a/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/lib/portos-bo-shared.jar and b/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/lib/portos-bo-shared.jar differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/lib/portos-report-shared.jar b/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/lib/portos-report-shared.jar index 3e51861b..5302f897 100644 Binary files a/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/lib/portos-report-shared.jar and b/liferay-plugins-sdk-6.2/portlets/portos-advanced-operation-portlet/docroot/WEB-INF/lib/portos-report-shared.jar differ 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 7f38ad90..462b610a 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 @@ -11,6 +11,7 @@ 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.theme.ThemeDisplay; import com.liferay.portal.util.PortalUtil; import com.liferay.util.bridges.mvc.MVCPortlet; @@ -24,8 +25,8 @@ 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.Arrays; import java.util.Date; import java.util.List; @@ -170,6 +171,27 @@ 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); + _log.info("== cambiaIstruttore == dentro"); + 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")) { + _log.info("== cambiaIstruttore == lastTask è esito"); + List controlloPraticas = ControlloPraticaLocalServiceUtil.findByIntPratica(intPratica.getIntPraticaId()); + if(!controlloPraticas.isEmpty() && Validator.isNotNull(controlloPraticas.get(0))){ + _log.info("== cambiaIstruttore == controlloPratica trovato"); + _log.info("== cambiaIstruttore == istruttoreId: "+istruttoreId); + ControlloPratica controlloPratica = controlloPraticas.get(0); + WorkflowUtil.assegnaUltimoTask(intPratica.getCompanyId(), intPratica.getGroupId(), + istruttoreId, themeDisplay.getUserId(), controlloPratica); + } + } + actionResponse.setRenderParameter("intPraticaId", String.valueOf(intPraticaId)); + } public void ripristinaPraticaConforme(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception{ 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 0a2bc33b..61699711 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 @@ -11,6 +11,7 @@ import com.liferay.portal.kernel.util.Validator; import com.liferay.portal.kernel.workflow.WorkflowConstants; import com.liferay.portal.kernel.workflow.WorkflowTask; import com.liferay.portal.kernel.workflow.WorkflowTaskManagerUtil; +import com.liferay.portal.model.User; import com.liferay.portal.model.WorkflowInstanceLink; import com.liferay.portal.service.WorkflowInstanceLinkLocalServiceUtil; @@ -23,6 +24,7 @@ import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil; 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; import java.util.ArrayList; import java.util.Date; @@ -43,7 +45,7 @@ public class AdvancedOperationUtil { return false; } } - + public static boolean hasControlloPratica_ProceduraC(IntPratica intPratica){ if(Constants.PROCEDURA_C.equalsIgnoreCase(intPratica.getTipoProcedura())){ try{ @@ -156,6 +158,41 @@ public class AdvancedOperationUtil { } return false; } + + public static long getCurrentAssignee(IntPratica intPratica){ + long currentAssignee = 0; + WorkflowTask lastTask = getLastTask(intPratica); + if(Validator.isNotNull(lastTask)){ + if(it.tref.liferay.portos.bo.util.WorkflowConstants.WORKFLOW_TASKNAME_ESITO.equalsIgnoreCase(lastTask.getName())){ + currentAssignee = lastTask.getAssigneeUserId(); + } + } + return currentAssignee; + } + + public static WorkflowTask getLastTask(IntPratica intPratica){ + if(Validator.isNotNull(intPratica)){ + try { + List controlloPraticas = ControlloPraticaLocalServiceUtil.findByIntPratica(intPratica.getIntPraticaId()); + if(!controlloPraticas.isEmpty() && Validator.isNotNull(controlloPraticas.get(0))){ + ControlloPratica controlloPratica = controlloPraticas.get(0); + return WorkflowUtil.getLastTask(controlloPratica.getCompanyId(), + controlloPratica.getGroupId(), null, controlloPratica); + } + }catch (SystemException | PortalException e){ + _log.error(e,e); + } + } + return null; + } + + public static boolean evalCurrentAssignee(IntPratica intPratica, User tecnico){ + WorkflowTask lastTask = getLastTask(intPratica); + if(Validator.isNotNull(lastTask) && lastTask.getName().equalsIgnoreCase("Esito")){ + return tecnico.getUserId() != lastTask.getAssigneeUserId() || lastTask.getAssigneeUserId() == 0; + } + return false; + } public static List fetchDettPraticaListWithInizioLavori(IntPratica intPratica){ if(Validator.isNotNull(intPratica)){ 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 579a1c9f..92d411cf 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 @@ -127,7 +127,11 @@ -

Status: <%= intPratica.getStatus() %>

+

+ Status: + + (<%= intPratica.getStatus() %>) +

<% @@ -420,6 +424,7 @@ <% List listaTask = AdvancedOperationUtil.getListaTask(intPratica); if(Validator.isNotNull(listaTask) && !listaTask.isEmpty()){ + long currentAssigneeId = AdvancedOperationUtil.getCurrentAssignee(intPratica); %> @@ -447,6 +452,25 @@ + + +
+ + +
+

Impersona Assegnatario Workflow:

+
+ + +
+
+
<% if(intPratica.getStatusByUserId() != 0L ){ User tecnico = UserLocalServiceUtil.fetchUser(intPratica.getStatusByUserId()); @@ -469,6 +493,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 " + tecnico.getFullName() + " ?')"; + %> + + + + + (<%= cambiaIstruttoreMsg %>) + + +
+
<% } @@ -565,11 +624,8 @@
-
- - <% if(Validator.isNotNull(intPratica)){ %> @@ -649,7 +705,5 @@ modal.show(); } ); - -