<%@ page language="java" import="java.sql.*, java.io.*, java.util.*, users.databases.*" errorPage="error.jsp" %> <% /***** VARIABLE DECLARATION and INITIALIZATION *****/ String strMainDB = "product_pgpClientInfoDB"; String strSubTitle = "", strCompanyName = "", strPrevBtn = "", strNextBtn = ""; String [] arrCPFName, arrCPLName, arrCPPos, arrCPDept, arrCPTel, arrCPEMail; int batchModifier = 2; // IF EQUAL TO UNITS OF LAST BATCH, IT'LL BE COMBINED WITH SECOND TO LAST BATCH int batchMaxUnit = 5; // MAXIMUM NUMBER OF BRANDS/PRODUCTS THAT WOULD BE DISPLAY PER PAGE int ctr = 0, total = 0; // USE FOR COUNTING TOTAL NUMBER CONTACT PERSONS int intID = 0; // USE TO INDICATE IF TABLE IS EMPTY OF ANY CONTACT PERSON int intUserID = Integer.parseInt(request.getParameter("uid")); int intCompanyID = Integer.parseInt(request.getParameter("cid")); byte bytDeptID = Byte.parseByte(request.getParameter("did")); int intBegPoint = Integer.parseInt(request.getParameter("p1")); int intEndPoint = Integer.parseInt(request.getParameter("p2")); /***** END OF VARIABLE DECLARATION *****/ String SQLstmt = "SELECT LogOnStatus FROM tblLogOn WHERE Usr_ID=" + intUserID + ";"; users.connect(strMainDB); ResultSet rs = users.listQuery(SQLstmt); byte bytLogStatus = 0; while (rs.next()) { bytLogStatus = rs.getByte("LogOnStatus"); } SQLstmt = "SELECT * FROM tblOtherCPs WHERE Co_ID=" + intCompanyID + " ORDER BY CPx_ID;"; rs = users.listQuery(SQLstmt); while (rs.next()) { intID = rs.getInt("CPx_ID"); ctr++; // COUNTS TOTAL NUMBER OF CONTACT PERSONS } if (bytLogStatus != 1) { // LOG CHECK RESULT - LOG-OUT, DISPLAYS HOME PAGE %> <% } else if (intID==0) { %> <% } else { // LOG CHECK RESULT - LOG-ON, PROCEED DISPLAYING ACTUAL PAGE total = ctr; if (intEndPoint > ctr) { // TOTAL CONTACT PERSONS TO BE DISPLAYED IS LESS THAN MAXIMUM arrCPFName = new String[(ctr-intBegPoint)]; arrCPLName = new String[(ctr-intBegPoint)]; arrCPPos = new String[(ctr-intBegPoint)]; arrCPDept = new String[(ctr-intBegPoint)]; arrCPTel = new String[(ctr-intBegPoint)]; arrCPEMail = new String[(ctr-intBegPoint)]; } else { if ((ctr-intEndPoint) <= batchModifier) { arrCPFName = new String[ctr-intBegPoint]; arrCPLName = new String[ctr-intBegPoint]; arrCPPos = new String[ctr-intBegPoint]; arrCPDept = new String[ctr-intBegPoint]; arrCPTel = new String[ctr-intBegPoint]; arrCPEMail = new String[ctr-intBegPoint]; } else { arrCPFName = new String[(intEndPoint-intBegPoint)]; arrCPLName = new String[(intEndPoint-intBegPoint)]; arrCPPos = new String[(intEndPoint-intBegPoint)]; arrCPDept = new String[(intEndPoint-intBegPoint)]; arrCPTel = new String[(intEndPoint-intBegPoint)]; arrCPEMail = new String[(intEndPoint-intBegPoint)]; } } if (intBegPoint==0) { // NO PREVIOUS DATA TO DISPLAY strPrevBtn = ""; } else { // PREVIOUS BUTTON IS ACTIVATED strPrevBtn = ""; } if (intEndPoint >= (ctr-batchModifier)) { // NO REMAINING DATA CAN BE DISPLAYED strNextBtn = ""; } else { // NEXT BUTTON IS ACTIVATED strNextBtn = ""; } if (intBegPoint==0) { // SINCE RESULTSET METHOD ABSOLUTE DOES NOT WORK WITH VALUE EQUAL TO ZERO rs.beforeFirst(); } else { rs.absolute(intBegPoint); } ctr = 0; while (rs.next()) { arrCPFName[ctr] = rs.getString("CPx_FirstN"); arrCPLName[ctr] = rs.getString("CPx_LastN"); arrCPPos[ctr] = rs.getString("CPx_Position"); arrCPDept[ctr] = rs.getString("CPx_Dept"); String strCPTArea = rs.getString("CPx_TelArea"); String strCPTNum = rs.getString("CPx_TelNum"); String strCPTLoc = rs.getString("CPx_TelLocal"); arrCPEMail[ctr] = rs.getString("CPx_EMail"); if (strCPTLoc.equals("")) { // FORMATS TEXT OUTPUT OF CONTACT PERSON'S PHONE NUMBER DEPENDING ON DATA arrCPTel[ctr] = "(+63" + strCPTArea + ")" + " " + strCPTNum; } else { arrCPTel[ctr] = "(+63" + strCPTArea + ")" + " " + strCPTNum + " loc. " + strCPTLoc; } if (arrCPEMail[ctr].equals("")) { arrCPEMail[ctr] = "none"; } ctr++; if (ctr==(arrCPFName.length)) { break; } } SQLstmt = "SELECT Co_Name FROM tblCompanyInfo WHERE Co_ID=" + intCompanyID + ";"; rs = users.listQuery(SQLstmt); while (rs.next()) { // GET NAME OF COMPANY strCompanyName = rs.getString("Co_Name"); } users.disconnect(); if (arrCPFName.length>1) { // THERE ARE MORE THAN ONE CONTACT PERSON ENTRY strSubTitle = "LIST OF ADDITIONAL CONTACT PERSONS"; } else { // CONTACT PERSON COUNT IS ONE strSubTitle = "ADDITIONAL CONTACT PERSON"; } /***** MERGING WITH MAIN HTML CODES STARTS HERE *****/ %> ADDITIONAL CONTACT PERSON

COMPANY PROFILE
Company: <%= strCompanyName %>


<%= strSubTitle %> <% for (int i=0; i

Name: <%= arrCPFName[i] + " " + arrCPLName[i] %>
Position: <%= arrCPPos[i] %>
Department: <%= arrCPDept[i] %>
Telephone: <%= arrCPTel[i] %>
e-mail: <%= arrCPEMail[i] %> <% if ((i+1)==ctr && ctr != 1) { %>

showing <%= intBegPoint + 1 %>-<%= intBegPoint + ctr %> of <%= total %>

<% } %> <% } %>

<% if ((intBegPoint == 0) && (intEndPoint >= (total-batchModifier))) { %> <% } else { %> <%= strPrevBtn %> <%= strNextBtn %> <% } %>

<% } // END OF LOG CHECK %>