<%
/**
 * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library 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 Lesser General Public License for more
 * details.
 */
%>

<%
boolean allInstances = false;

List<WorkflowInstance> resultsInstances = null;

int totalInstances = 0;

if (portletName.equals(PortletKeys.WORKFLOW_DEFINITIONS) || portletName.equals(PortletKeys.WORKFLOW_INSTANCES)) {
	if (completedInstances) {
		searchContainer.setEmptyResultsMessage("there-are-no-completed-instances");
	}
	else {
		searchContainer.setEmptyResultsMessage("there-are-no-pending-instances");
	}

	allInstances = true;

	resultsInstances = WorkflowInstanceManagerUtil.getWorkflowInstances(company.getCompanyId(), null, null, null, completedInstances, searchContainer.getStart(), searchContainer.getEnd(), null);
	totalInstances =  WorkflowInstanceManagerUtil.getWorkflowInstanceCount(company.getCompanyId(), null, null, null, completedInstances);
}
else {
	if (completedInstances) {
		searchContainer.setEmptyResultsMessage("there-are-no-completed-instances-started-by-me");
	}
	else {
		searchContainer.setEmptyResultsMessage("there-are-no-pending-instances-started-by-me");
	}

	resultsInstances = WorkflowInstanceManagerUtil.getWorkflowInstances(company.getCompanyId(), user.getUserId(), null, null, completedInstances, searchContainer.getStart(), searchContainer.getEnd(), null);
	totalInstances =  WorkflowInstanceManagerUtil.getWorkflowInstanceCount(company.getCompanyId(), user.getUserId(), null, null, completedInstances);
}
%>