Commit 967e72cc by Nilu

Assume user - providing user alias to handle billing - partially complete

parent 9ec2a80e
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">it_does_not_matter</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="xxxx" type="CLOB" nullable="true"/>
</NODE>
</NODE></OBJECTS>
\ No newline at end of file
-- DROP TABLE it_does_not_matter;
CREATE TABLE it_does_not_matter (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
xxxx text NULL
);
ALTER TABLE it_does_not_matter ADD
CONSTRAINT PK_it_does_not_matter PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- DROP TABLE it_does_not_matter;
CREATE TABLE it_does_not_matter (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
xxxx clob NULL
);
ALTER TABLE it_does_not_matter ADD
CONSTRAINT PK_it_does_not_matter PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- @AutoRun
-- drop table it_does_not_matter;
CREATE TABLE it_does_not_matter (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
xxxx text NULL
);
ALTER TABLE it_does_not_matter ADD
CONSTRAINT pk_it_does_not_matter PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
package performa.form;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import oneit.appservices.accesslog.AccessLog;
import oneit.logging.LogLevel;
import oneit.logging.LogMgr;
import oneit.objstore.ObjectTransaction;
import oneit.objstore.StorageException;
import oneit.security.AuthorisationToken;
import oneit.security.LoginProcessor;
import oneit.security.SecUser;
import oneit.security.jsp.MaintainUserFP;
import oneit.servlets.forms.SubmissionDetails;
import oneit.servlets.forms.SuccessfulResult;
import oneit.servlets.process.ORMProcessFormProcessor;
import oneit.servlets.process.ORMProcessState;
import oneit.servlets.security.SessionSecUserDecorator;
import oneit.servlets.utils.decorator.LoggingDecorator;
import oneit.servlets.utils.session.SessionManager;
import oneit.utils.BusinessException;
import performa.orm.HiringTeam;
public class AssumeHTAdminFP extends ORMProcessFormProcessor
{
public static final String UNASSUME_SEC_USER_ID = "oeit.unassumeSecUser";
private LoginProcessor loginFP;
@Override
public SuccessfulResult processForm(ORMProcessState process,
SubmissionDetails submission,
Map params) throws BusinessException, StorageException
{
HttpServletRequest request = submission.getRequest();
HiringTeam hiringTeam = (HiringTeam) request.getAttribute("HiringTeam");
SecUser editor = (SecUser) request.getAttribute(AuthorisationToken.AUTH_TOKEN_ID);
SecUser secUser = hiringTeam.getAddedByUser() != null ? hiringTeam.getAddedByUser().getUser() : null;
if (secUser == null)
{
return null;
}
process.getTransaction().assertPrivilege("securityAssumeUser");
LogMgr.log( MaintainUserFP.LOG, LogLevel.BUSINESS1, "Assuming: ", secUser.getUserName(), " emp#: ", secUser.getObjectID(), " by ", editor );
SecUser toAssume = (SecUser)secUser.getInTransaction(ObjectTransaction.getTransaction());
AccessLog.getAccessLog().recordAccess("LOGIN", "Assume.jsp", toAssume.getAuthToken(), LoggingDecorator.getSessionID(submission.getRequest()), AccessLog.ACCESS_RESULT_OK, submission.getRequest().getRemoteAddr());
SessionManager.clearSession(request.getSession());
request.getSession().setAttribute(UNASSUME_SEC_USER_ID, editor);
request.getSession().setAttribute(SecUser.SEC_USER_ID, toAssume);
request.getSession().setAttribute(SessionSecUserDecorator.REFRESH_SECURITY, Boolean.TRUE);
request.getSession().setAttribute("SelectedHiringTeam", hiringTeam);
return loginFP.processSuccessfulLogin(submission, new HashMap(), toAssume);
}
}
package performa.search;
import oneit.objstore.BaseBusinessClass;
import performa.orm.HiringTeam;
public class SearchHiringTeam extends BaseSearchHiringTeam
{
private static final long serialVersionUID = 0L;
// This constructor should not be called
public SearchHiringTeam ()
{
// Do not add any code to this, always put it in initialiseNewObject
}
@Override
public BaseBusinessClass[] doSearch()
{
return HiringTeam.searchAll(getTransaction());
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='http://www.oneit.com.au/schemas/5.2/BusinessObject.xsd'>
<BUSINESSCLASS name="SearchHiringTeam" package="performa.search" superclass="SearchExecutor" >
<IMPORT value="oneit.servlets.orm.*" />
<TABLE name="it_does_not_matter" tablePrefix="object" polymorphic="FALSE" >
<ATTRIB name="Details" type="String" dbcol="xxxx" />
</TABLE>
</BUSINESSCLASS>
</ROOT>
\ No newline at end of file
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
Debug.assertion(hiringTeam != null , "Invalid hiring team in admin portal my company"); Debug.assertion(hiringTeam != null , "Invalid hiring team in admin portal my company");
String hiringTeamList = WebUtils.getSamePageInRenderMode(request, "Page"); String hiringTeamList = WebUtils.getSamePageInRenderMode(request, "Page");
String nextPage = WebUtils.getSamePageInRenderMode(request, "Billing"); String nextPage = WebUtils.getSamePageInRenderMode(request, (hiringTeam.getIsPPJ() == null || (!hiringTeam.getIsPPJ() && hiringTeam.getPaymentPlan() == null)) ? "ManagePlan" : "Billing");
String replaceCardPage = WebUtils.getSamePageInRenderMode(request, "ReplaceCard"); String replaceCardPage = WebUtils.getSamePageInRenderMode(request, "ReplaceCard");
%> %>
<script type="text/javascript"> <script type="text/javascript">
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
boolean ownBilling = hiringTeam.getManageOwnBilling(); boolean ownBilling = hiringTeam.getManageOwnBilling();
String disabled = ownBilling ? "false" : "true"; String disabled = ownBilling ? "false" : "true";
String disabledClass = ownBilling ? "" : "billing-disabled"; String disabledClass = ownBilling ? "" : "billing-disabled";
boolean isAssumedUser = Utils.isAssumedUser(request);
%> %>
<oneit:dynIncluded> <oneit:dynIncluded>
...@@ -33,10 +35,9 @@ ...@@ -33,10 +35,9 @@
<% <%
RoleType userRole = companyUser.getRoleForHiringTeam(hiringTeam); RoleType userRole = companyUser.getRoleForHiringTeam(hiringTeam);
if(userRole != RoleType.STANDARD && hiringTeam.getManageOwnBilling()) if((hiringTeam.getIsPPJ() == null || (!hiringTeam.getIsPPJ() && hiringTeam.getPaymentPlan() == null) || isAssumedUser) && hiringTeam.getManageOwnBilling())
{ {
%> %>
<li class="<%= tabNumber == "2" ? "active" : ""%>"> <li class="<%= tabNumber == "2" ? "active" : ""%>">
<oneit:button value=" " name="gotoPage" skin="link" <oneit:button value=" " name="gotoPage" skin="link"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", secondPage) requestAttribs="<%= CollectionUtils.mapEntry("nextPage", secondPage)
...@@ -44,6 +45,12 @@ ...@@ -44,6 +45,12 @@
Manage Plan Manage Plan
</oneit:button> </oneit:button>
</li> </li>
<%
}
if((userRole != RoleType.STANDARD && hiringTeam.getCardID() == null || isAssumedUser) && hiringTeam.getManageOwnBilling())
{
%>
<li class="<%= tabNumber == "3" ? "active" : ""%>"> <li class="<%= tabNumber == "3" ? "active" : ""%>">
<oneit:button value=" " name="gotoPage" skin="link" <oneit:button value=" " name="gotoPage" skin="link"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", thirdPage) requestAttribs="<%= CollectionUtils.mapEntry("nextPage", thirdPage)
...@@ -51,6 +58,12 @@ ...@@ -51,6 +58,12 @@
Billing Billing
</oneit:button> </oneit:button>
</li> </li>
<%
}
if(userRole != RoleType.STANDARD && hiringTeam.getManageOwnBilling())
{
%>
<li class="<%= tabNumber == "4" ? "active" : ""%>"> <li class="<%= tabNumber == "4" ? "active" : ""%>">
<oneit:button value=" " name="gotoPage" skin="link" <oneit:button value=" " name="gotoPage" skin="link"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", forthPage) requestAttribs="<%= CollectionUtils.mapEntry("nextPage", forthPage)
......
...@@ -67,6 +67,7 @@ ...@@ -67,6 +67,7 @@
new Comparator[]{ CollectionUtils.reverse(CollectionUtils.DEFAULT_COMPARATOR), CollectionUtils.reverse(CollectionUtils.DEFAULT_COMPARATOR), CollectionUtils.reverse(CollectionUtils.DEFAULT_COMPARATOR) }); new Comparator[]{ CollectionUtils.reverse(CollectionUtils.DEFAULT_COMPARATOR), CollectionUtils.reverse(CollectionUtils.DEFAULT_COMPARATOR), CollectionUtils.reverse(CollectionUtils.DEFAULT_COMPARATOR) });
Article jobsArticle = WebUtils.getArticleByShortCut(transaction, WebUtils.JOBS); Article jobsArticle = WebUtils.getArticleByShortCut(transaction, WebUtils.JOBS);
Article companyArticle = WebUtils.getArticleByShortCut(transaction, WebUtils.MY_COMPANY);
String nextPage = jobsArticle.getLink(request, CollectionUtils.mapEntry("cms.rm", WebUtils.VIEW_APPLICANTS).toMap()); String nextPage = jobsArticle.getLink(request, CollectionUtils.mapEntry("cms.rm", WebUtils.VIEW_APPLICANTS).toMap());
String shortlistPage = jobsArticle.getLink(request, CollectionUtils.mapEntry("cms.rm", WebUtils.APPLICANTS_SHORTLIST).toMap()); String shortlistPage = jobsArticle.getLink(request, CollectionUtils.mapEntry("cms.rm", WebUtils.APPLICANTS_SHORTLIST).toMap());
String homePage = WebUtils.getSamePageInRenderMode(request, "Page"); String homePage = WebUtils.getSamePageInRenderMode(request, "Page");
...@@ -75,6 +76,27 @@ ...@@ -75,6 +76,27 @@
boolean canCreateJob = Utils.allowJobCreation(hiringTeam); boolean canCreateJob = Utils.allowJobCreation(hiringTeam);
%> %>
<style>
#overlay {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0,0,0,0.5);
z-index: 2;
cursor: pointer;
}
.welcome-pop-top {
margin-top: 20%;
}
.main-welcome-popup h2 {
padding: 0 20px 0;
}
</style>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() $(document).ready(function()
{ {
...@@ -92,7 +114,7 @@ ...@@ -92,7 +114,7 @@
<div class="welcome-box"> <div class="welcome-box">
<div class="dashboard-welcome"> <div class="dashboard-welcome">
<div class="welcome-text"> Welcome <br/> <%= firstTime ? "" : "back"%> <oneit:toString value="<%= secUser.getFirstName()!=null ? secUser.getFirstName() : secUser.getUserName()%>" mode="EscapeHTML"/>!</div> <div class="welcome-text"> Welcome <br/> <%= firstTime ? "" : "back"%> <oneit:toString value="<%= secUser.getFirstName()!=null ? secUser.getFirstName() : secUser.getUserName()%>" mode="EscapeHTML"/>!</div>
<a class="d-create-job-btn <%= canCreateJob ? "" : "disabled"%>" href="<%= canCreateJob ? jobsArticle.getLink(request, CollectionUtils.mapEntry("cms.rm", WebUtils.CREATE_JOB).toMap()) : "#" %>">Create a Job</a> <a class="d-create-job-btn <%= canCreateJob ? "" : "disabled"%>" href="<%= canCreateJob ? jobsArticle.getLink(request, CollectionUtils.mapEntry("cms.rm", WebUtils.START_JOB).toMap()) : "#" %>">Create a Job</a>
</div> </div>
<div class="col-sm-3 col-xs-12 d-three-box green-light"> <div class="col-sm-3 col-xs-12 d-three-box green-light">
<div class="d-fl-left eq-height"> <div class="d-fl-left eq-height">
...@@ -195,7 +217,56 @@ ...@@ -195,7 +217,56 @@
</div> </div>
</div> </div>
</oneit:form> </oneit:form>
<%
if(hiringTeam.getCardID() == null)
{
%>
<oneit:form name="setupBilling" method="post" enctype="multipart/form-data">
<div id="overlay">
<div class="modal-dialog welcome-pop-top">
<div class="modal-body main-welcome-popup">
<h2>You haven't set up billing yet!</h2>
<p>Please set up billing details before creating jobs.</p>
<div class="create-y-f-job">
<oneit:button value=" " name="gotoPage" skin="link"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", companyArticle.getLink(request, CollectionUtils.mapEntry("cms.rm", "Billing").toMap()))
.mapEntry("procParams", CollectionUtils.mapEntry("HiringTeam", hiringTeam).toMap())
.toMap() %>">
Setup Billing
</oneit:button>
</div>
</div>
</div>
</div>
</oneit:form>
<%
}
else if(hiringTeam.getIsPPJ() == null || (!hiringTeam.getIsPPJ() && hiringTeam.getPaymentPlan() == null))
{
%>
<oneit:form name="setupPlan" method="post" enctype="multipart/form-data">
<div id="overlay">
<div class="modal-dialog welcome-pop-top">
<div class="modal-body main-welcome-popup">
<h2>You haven't set up a payment plan yet!</h2>
<p>Please select a payment plan before creating jobs</p>
<div class="create-y-f-job">
<oneit:button value=" " name="gotoPage" skin="link"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", companyArticle.getLink(request, CollectionUtils.mapEntry("cms.rm", "ManagePlan").toMap()))
.mapEntry("procParams", CollectionUtils.mapEntry("HiringTeam", hiringTeam).toMap())
.toMap() %>">
Setup Payment Plan
</oneit:button>
</div>
</div>
</div>
</div>
</oneit:form>
<%
}
%>
<!-- not using --> <!-- not using -->
<div class="modal fade" id="welcomepopup" role="dialog"> <div class="modal fade" id="welcomepopup" role="dialog">
<div class="modal-dialog welcome-pop-top"> <div class="modal-dialog welcome-pop-top">
......
...@@ -7,4 +7,11 @@ ...@@ -7,4 +7,11 @@
<FORM name="*.testAnalysis" factory="Participant" class="performa.form.TestAnalysisFP"/> <FORM name="*.testAnalysis" factory="Participant" class="performa.form.TestAnalysisFP"/>
</NODE> </NODE>
<NODE name="customers_jsp" factory="Participant">
<INHERITS factory="Named" nodename="CoreORMAdmin"/>
<FORM name="*.assume" factory="Participant" class="performa.form.AssumeHTAdminFP">
<NODE name="loginFP" factory="Named" nodename="CMSLoginFP"/>
</FORM>
</NODE>
</OBJECTS> </OBJECTS>
\ No newline at end of file
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<!-- <TOPMENU name="MENU.TEST_ANALYSIS" desc="Test Analysis" sortOrder="100" factory="Participant" class="oneit.servlets.jsp.ui.DefaultUICustomiser$Element" <!-- <TOPMENU name="MENU.TEST_ANALYSIS" desc="Test Analysis" sortOrder="100" factory="Participant" class="oneit.servlets.jsp.ui.DefaultUICustomiser$Element"
link="/extensions/performa/testAnalysis.jsp"/> --> link="/extensions/performa/testAnalysis.jsp"/> -->
<CHILD name="Performa.Customers" desc="Customers" sortOrder="10" toplevel="ADMIN" priv="admin" link="/extensions/performa/customers.jsp" factory="Participant" class="oneit.servlets.jsp.ui.DefaultUICustomiser$Element" />
</NODE> </NODE>
......
<%@ page extends="oneit.servlets.jsp.FormJSP"%>
<%@ include file="/setuprequest.jsp"%>
<%@ include file="inc/stdimports.jsp"%>
<%@ include file="/editor/stdimports.jsp"%>
<%@ page import="oneit.security.jsp.*" %>
<%! protected String getName (ServletConfig config) { return "customers_jsp"; } %>
<%
ORMProcessState process = (ORMProcessState) ProcessDecorator.getDefaultProcess(request);
ObjectTransaction objTran = process.getTransaction ();
String currentPage = request.getContextPath() + "/extensions/performa/customers.jsp";
SecUser secUser = SecUser.getTXUser(objTran);
UserSortOption userSortOpt = (UserSortOption) process.getAttribute("UserSortOption");
SearchHiringTeam searchHT = (SearchHiringTeam) RunSearchExecutorFP.setupExecutor(request, SearchHiringTeam.REFERENCE_SearchHiringTeam, true);
HiringTeam[] hiringTeams = (HiringTeam[]) process.getAttribute("HiringTeams");
if(hiringTeams == null)
{
hiringTeams = (HiringTeam[]) searchHT.doSearch();
}
if (getData (request, GenericObjSearchDF.GENERIC_SEARCH_RESULTS) != null)
{
hiringTeams = (HiringTeam[])getData (request, GenericObjSearchDF.GENERIC_SEARCH_RESULTS);
}
process.setAttribute("HiringTeams", hiringTeams);
if( request.getParameter("UserSortOption") != null)
{
userSortOpt = UserSortOption.forName((String) request.getParameter("UserSortOption"));
}
if(userSortOpt == null)
{
userSortOpt = UserSortOption.ALPHA_A_Z;
}
process.setAttribute("UserSortOption", userSortOpt);
// process.setAttribute( SecProcessConstants.SEC_USER , secUser);
Collection<HiringTeam> sortedHiringTeams = Utils.getHiringTeamsSorted(Arrays.asList(hiringTeams), userSortOpt);
request.setAttribute("oneit.pageFormDetails", CollectionUtils.mapEntry("name", "Customers").mapEntry("enctype", "multipart/form-data").toMap());
request.setAttribute("oneit.pageHeaderTitle", "Customers");
%>
<%@include file="/editor/header.jsp"%>
<oneit:css>
<oneit:css href="/css/common.css" />
</oneit:css>
<style>
.dashboard-content-area {
margin-top: 0px ;
width: 100%;
}
</style>
<div class="dashboard-content-area second-part">
<div class="jobs-list-shorting">
<div class="d-job-title all-jobs-title">Customers</div>
<div class="shorting-dropdown">
<span class="order-label">order by</span>
<select class="form-control" onChange="location=this.value">
<%
for (UserSortOption sortOption : UserSortOption.getUserSortOptionArray())
{
String optionLink = currentPage + "?UserSortOption=" + sortOption.getName() ;
%>
<option <%= (userSortOpt != null && userSortOpt == sortOption ? "selected" : "" )%> value="<%= optionLink %>">
<oneit:toString value="<%= sortOption.getDescription() %>" mode="EscapeHTML"/>
</option>
<%
}
%>
</select>
</div>
</div>
<div class="main-client-list">
<%
for(HiringTeam hiringTeam : sortedHiringTeams)
{
Job[] filledJobs = Job.SearchByAll().andJobStatus(new EqualsFilter<>(JobStatus.FILLED))
.andHiringTeam(new EqualsFilter<>(hiringTeam))
.search(objTran);
int filledCount = filledJobs != null ? filledJobs.length : 0;
Job[] openJobs = Job.SearchByAll().andJobStatus(new EqualsFilter<>(JobStatus.OPEN))
.andHiringTeam(new EqualsFilter<>(hiringTeam))
.search(objTran);
int openCount = openJobs != null ? openJobs.length : 0;
int clientCount = hiringTeam.pipelineHiringTeam().toClients().uniqueVals().size();
%>
<div class="client-list" id="<%= hiringTeam.getID() %>">
<div class="client-row" >
<div class="client-name-cell jl-c" style="width:50%;">
<div class="client-name">
<a href="<%= "&ClientID="+hiringTeam.getObjectID() %>">
<oneit:toString value="<%= hiringTeam.getHiringTeamName() %>" mode="EscapeHTML" />
</a>
</div>
</div>
</div>
<div class="<%= "application-count jl-c " + (clientCount == 0 ? "opaque-jobcount" : "")%>">
<oneit:toString value="<%= clientCount %>" mode="EscapeHTML" nullValue="0"/>
<span class="grey-span">Clients</span>
</div>
<div class="<%= "application-count jl-c " + (openCount == 0 ? "opaque-jobcount" : "")%>">
<oneit:toString value="<%= openCount %>" mode="EscapeHTML" nullValue="0"/>
<span class="grey-span">Open Jobs</span>
</div>
<div class="<%= "application-count jl-c " + (filledCount == 0 ? "opaque-jobcount" : "")%>">
<oneit:toString value="<%= filledCount %>" mode="EscapeHTML" nullValue="0"/>
<span class="grey-span">Jobs Filled</span>
</div>
<div class="application-count jl-c" style="width:20%;">
<oneit:button value="Login as Admin" name="assume" cssClass="btn btn-primary loginAsAdmin"
requestAttribs="<%= CollectionUtils.mapEntry("HiringTeam", hiringTeam)
.toMap()%>"/>
</div>
</div>
<%
}
%>
</div>
</div>
<%@include file="/editor/footer.jsp"%>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment