%@ include file="../common/header.html" %>
<%@ page import="com.hypertechsolutions.ipm.utils.*,com.hypertechsolutions.ipm.custmgmt.*,java.util.*"%>
<%
// Creation Date: 09/12/2001
// Author : HyperTech Solutions
UserController userController = sessionInfo.getUserController();
String messageText = validator.getErrorText();
String error = null;
String cdate = "Sunday, 25-Dec-05 23:12:40 GMT";
String email = request.getParameter("cc_email");
if (email == null)
email = "";
String password = request.getParameter("cc_pwd");
if (password == null)
password = "";
boolean cookButton = request.getParameter("cookButton")!=null;
String process = request.getParameter("PROCESS");
User user = null;
String focus = null;
String companyId = JSPHelper.getCompanyID(request,application);
String partnerId = JSPHelper.getPartnerID(request);
String usrType = JSPHelper.getUserType(request);
String userCookie = companyId+partnerId+usrType+"USER";
String passCookie = companyId+partnerId+usrType+"PASSWORD";
if (process == null)
{
if (email.length() != 0 && password.length() != 0)
{
user = userController.validateUser(email, password);
if (user != null && user.getUserType() == UserType.CALL_CENTER) {
sessionInfo.setUser(user);
sessionInfo.setCustomer(null);
String isAdminValue = user.getIsAdministrator()? "YES":"NO";
response.addHeader("Set-Cookie", "isCCUserAdmin="+isAdminValue+";Path=/");
response.addHeader("Set-Cookie", "IpmUserType=CC;Path=/");
response.addHeader("Set-Cookie", "IpmCompanyID=" + companyId + ";Path=/");
response.addHeader("Set-Cookie", "IpmPartnerID=" + partnerId + ";Path=/");
%>
<%
}
}
}
if (process != null)
{
validator.reset();
if(!validator.isValidEmailAddress(email, "E-mail", "Please enter your E-mail address."))
{
messageText = validator.getErrorText();
error="Yes";
if(focus == null)
focus="E-Mail";
}
if(!validator.isNonBlank(password, "Password" ,"Please enter Password."))
{
messageText = validator.getErrorText();
error="Yes";
if(focus == null)
focus="Password";
}
if(error==null)
{
try
{
user = userController.validateUser(email, password);
if(user!=null)
{
if (user.getUserType() != UserType.CALL_CENTER)
{
validator.addError("Sorry! You are not a Call Center user.");
messageText = validator.getErrorText();
error="Yes";
focus="E-Mail";
}
}
else
{
validator.addError("Invalid E-mail address/Password combination");
messageText = validator.getErrorText();
error="Yes";
focus="Password";
}
if(error==null)
{
String redirectUrl = user.getDestination3();
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("EEE, d-MMM-yyyy hh:mm:ss ");
java.util.Date date = new java.util.Date() ;
date.setDate(date.getDate()+365);
String dt = sdf.format(date)+ "GMT ";
String exp ="";
if(cookButton) exp=";Expires="+dt;
response.addHeader("Set-Cookie", passCookie + "=" + password + exp + ";Path=/");
response.addHeader("Set-Cookie", userCookie + "=" + email + exp + ";Path=/");
String isAdminValue = user.getIsAdministrator()? "YES":"NO";
response.addHeader("Set-Cookie", "IpmUserType=CC;Path=/");
response.addHeader("Set-Cookie", "IpmCompanyID=" + companyId + ";Path=/");
response.addHeader("Set-Cookie", "IpmPartnerID=" + partnerId + ";Path=/");
response.addHeader("Set-Cookie", "isLoggedOn=YES;Path=/");
response.addHeader("Set-Cookie", "isCCUserAdmin="+ isAdminValue +";Path=/");
sessionInfo.setUser(user);
sessionInfo.setCustomer(null);
if ( redirectUrl != null && redirectUrl.length() != 0 ) {
if ( redirectUrl.endsWith("jsp") ) {
%>
<%
} else {
%>
<%
}
} else {
%>
<%
}
}
}
catch(Exception e)
{
validator.addError("Sorry! No Active Account for this id");
messageText = validator.getErrorText();
focus="E-Mail";
}
}
}
if (focus == null)
focus = "E-Mail";
%>
<%@ include file="../common/footer.html" %>