<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/enrgise-html.tld" prefix="enrgise" %>
<%@ page import="wenrgise.common.utility.ReportReader" %>
<%@ page import="wenrgise.common.utility.ParamUtil" %>

<html:html>
<html:base />
<head>
  <TITLE><bean:message  key="hrm.title" /></TITLE>
  <jsp:include page="GenIncludes.jsp" flush="true" />
</head>

<BODY  onkeydown="hotKeys(event);" scroll=auto>
<html:form name="HrmMisReportForm" action="HrmMisReportJasperAction" type="wenrgise.hrms.webtier.form.HrmMisReportForm">
<bean:define id="ParentForm" name="HrmMisReportForm" toScope="request" />
<jsp:include page="GenMenu.jsp" flush="true" />
<bean:define id="left" name="ParentForm" property="positionRequested"/>
<bean:define id="right" name="ParentForm" property="totalCount"/>
<table cellSpacing=0 bgColor=#bdd0ef>
<tr height=27>
  <td colSpan=11></td>
</tr>
  <TR > 
    <TD ><enrgise:img name="ParentForm" property="butQuery" onmouseover='this.src="../includes/images/query_act.jpg"' onmouseout='this.src="../includes/images/query.jpg"' alt="Query (Ctrl+Q)" src="../includes/images/query.jpg" onclick="doBaseQueryMode()" /><enrgise:img name="ParentForm" property="butInsert" onmouseover='this.src="../includes/images/insert_act.jpg"' onmouseout='this.src="../includes/images/insert.jpg"' alt="Insert (Alt+N)" src="../includes/images/insert.jpg"  onclick="doBaseInsertMode()"/></TD>
    <TD width="2%"></TD>
    <TD ><enrgise:img name="ParentForm" property="butExecute" onmouseover='this.src="../includes/images/execute_act.jpg"' onmouseout='this.src="../includes/images/execute.jpg"' alt="Execute (Ctrl+U)" src="../includes/images/execute.jpg" onclick="doBaseExecute()" /><enrgise:img name="ParentForm" property="butSave" onmouseover='this.src="../includes/images/save_act.jpg"' onmouseout='this.src="../includes/images/save.jpg"' alt="Save (Ctrl+S)" src="../includes/images/save.jpg" onclick="doBaseSave()" />
    <img name="ParentForm" property="butDelete" src="../includes/images/delete_dis.jpg" /><enrgise:img name="ParentForm" property="butRefresh" onmouseover='this.src="../includes/images/refresh_act.jpg"' onmouseout='this.src="../includes/images/refresh.jpg"' alt="Refresh (Ctrl+R)"  src="../includes/images/refresh.jpg" onclick="doBaseRefresh()" />
    <enrgise:img name="ParentForm" property="butPrint" onmouseover='this.src="../includes/images/print_act.jpg"' onmouseout='this.src="../includes/images/print.jpg"' alt="Print (Ctrl+P)"  src="../includes/images/print.jpg" /></TD>
    <TD width="2%" bgColor=#bdd0ef></TD>
 <TD><enrgise:img name="ParentForm" property="butExit" onmouseover='this.src="../includes/images/exit_act.jpg"' onmouseout='this.src="../includes/images/exit.jpg"' alt="Exit (Alt+X)"  src="../includes/images/exit.jpg"   onclick="doBaseExit()" />
    <enrgise:img name="ParentForm" property="butHelp" onmouseover='this.src="../includes/images/help_act.jpg"' onmouseout='this.src="../includes/images/help.jpg"' alt="Help (Ctrl+?)" src="../includes/images/help.jpg" onclick="doBaseHelp()" /></TD>    <TD width="50%"></TD>
    <TD ><enrgise:img name="ParentForm" property="butPrevHeader" src='../includes/images/butn_prev.jpg' onmouseover='this.src="../includes/images/butn_prev_act.jpg"' onmouseout='this.src="../includes/images/butn_prev.jpg"' alt="Butn_prev (Ctrl+<)" onclick="doBasePrevHeader()" /></td>
    <td class=dtlNavText><bean:write  name="left" /> of 
    <bean:write name="right" /></td>
    <td align=right><enrgise:img name="ParentForm" property="butNextHeader" src="../includes/images/butn_next.jpg" onmouseover='this.src="../includes/images/butn_next_act.jpg"' onmouseout='this.src="../includes/images/butn_next.jpg"' alt="Butn_next (Ctrl+>)" onclick="doBaseNextHeader()" /></td>
    <td align=right><enrgise:text property="newPositionRequested" size="1" onkeydown="isInteger(event)" title="wenrgise.common.jumpDetail" alt="N" disabledClass="locked" styleClass="optional" /></td>
    <td ><enrgise:img name="ParentForm" property="butJumpHeader" alt="Go (Ctrl+G)" src="../includes/images/go.jpg" onmouseover='this.src="../includes/images/go_act.jpg"' onmouseout='this.src="../includes/images/go.jpg"' onclick="doBaseJumpHeader()" /></td>
    <td > </td>
</TR>
</TABLE>

<table>
<tr>
  <td colspan="11" class="userText"></td>
</tr>
<enrgise:checkSession/>
</TABLE>

<!--Top Most Blue Bar-->
<TABLE cellSpacing=0 bgColor=#bdd0ef>
    <tr>
        <TD  colSpan=12 class=mainHeader height=10><bean:message  key="hrm.HrmMisReportMainHeader" /></TD>
    </TR>
</TABLE>
<!--//  Display Errors -->
<enrgise:errors/>
<logic:messagesPresent message="true">
<Table>
    <html:messages id="message" message="true">
    <TR><TD>
      <bean:write name="message"/>
    </TD></TR>
    </html:messages>      
</Table>
</logic:messagesPresent>
<!--//  Display Errors -->
<TABLE cellSpacing=0 cellPadding=0 border=0 >
    <TR>
        <TD>
        
        <TABLE cellSpacing=0 cellPadding=0 >
        <!--Inspection Header Starts -->
            <TR>
                  <TD class=subHeader colspan=6><bean:message  key="hrm.HrmMisReportSubHeader" /></TD>
            </TR>
            <TR>
                  <TD colspan=6 bgColor=#4682b4><IMG height=1 src="../includes/images/pixel.gif" width=1 border=0></TD>
            </TR>
            
            
            <tr>
              <!--<td width="33%">  </td>-->
              <td colspan=2 width="20%"></td>
              <logic:equal name="HrmMisReportForm" property="screenMode" value="Q" >
              <td width="6%" align="right"  class="radioText" ><html:radio  property="optSelect" value="BR"  onclick="doSetFlag('BR');" />Branch
              <td></td>
              <td width="12%" align="right" class="radioText" ><html:radio  property="optSelect" value="RO" onclick="doSetFlag('RO');" />Regional Office</td>
              <td></td>
              </logic:equal>
              <logic:notEqual name="HrmMisReportForm" property="screenMode" value="Q" >
              <td width="6%" align="right"  class="radioText" ><html:radio  property="optSelect" value="BR"  onclick="doSetFlag('BR');" disabled="true" />Branch
              <td></td>
              <td width="12%" align="right" class="radioText" ><html:radio  property="optSelect" value="RO" onclick="doSetFlag('RO');" disabled="true" />Regional Office</td>
              <td></td>
              </logic:notEqual>
            </tr> 
            
            <tr height="10">
                <td colspan="6"></td>
            </tr>
         </table>
        
                      
         <table cellspacing=0 cellpadding=0 border=0>
          <!-- Detail Information Row starts -->
          <TR>
            <TD colspan=6>
            <!-- Tab Table Starts -->
            <TABLE cellSpacing=0 cellPadding=0 >
            <tr>                                             
                          <td bgcolor="#4682B4"><img src="../includes/images/pixel.gif" width="10" height="1" border="0"></td>
                          <td bgcolor="#4682B4" nowrap class=actTabText ><bean:message  key="hrm.HrmMisReportTableHeader" /><img src="../includes/images/pixel.gif" width="10" height="1" border="0"></td>
                          <TD><IMG height=19  src="../includes/images/formtab_r.gif" width=10  border=0></TD>                              
                          <TD width="100%" background="../includes/images/line_t.gif">&nbsp;</TD>
                          <TD background="../includes/images/line_t.gif"><IMG height=1 src="../includes/images/pixel.gif" width=10 border=0></TD>
            </tr>
              <TR height=10>
              
            <!-- Detail table Container starts -->
              <TD colSpan=5>
              <TABLE cellSpacing=0 cellPadding=0 border=0>
                <TBODY>
                 <TR>
                   <TD>
                     <DIV id=divDtlTable style="height:250px;width:1020px">
                    <TABLE  border="0" cellSpacing=0 cellPadding=0>
                     <TBODY>
                          <tr>
                            <TD class=tableHeader width="1%"><input type="checkbox" name="selectAll"  onclick="toggleCheckBox('checked')"  /></TD>
                              
                            <TD class=tableHeader colspan=3 ><bean:message key="hrm.HrmMisReport.Position" /></td>
                            <TD class=tableHeader colspan=2 ><bean:message  key="hrm.HrmMisReport.DesiredStrength" /></td>
                           </tr>
                          
                          <logic:iterate id="HrmMisRep" name="HrmMisReportForm" property="arrMisReport" type="wenrgise.hrms.bean.HrmMisReportDtlBean" indexId="idx" >
                         
                            <logic:notEqual name="HrmMisRep" property="status" value="D"  >
                              
                              <tr class='<bean:write name="HrmMisReportForm" property="listRowClass"/>'  >
                                <td >
                                <html:hidden property="status"  name="HrmMisRep" />
                                <html:hidden property="detailId"  name="HrmMisRep"  />
                                <html:checkbox property="checked"  name="HrmMisReportForm" alt="<%=idx.toString()%>" onclick="boxClicked(this.alt);" />
                                <html:hidden property="itemChecked" name="HrmMisRep" />
                                <html:hidden property="txtPositionId" name="HrmMisRep" />
                                </td>
                                  <logic:equal name="HrmMisRep" property="status" value="N"  >
                                <TD class=tableText colspan=3 ><html:text property="txtPosition" name="HrmMisRep" style="width:95%" onkeypress="isInteger(event)" titleKey="hrm.HrmMisReport.Position" styleClass="required" readonly="true" onchange='<%="doChangeDetail("+idx.toString()+")"%>' /><img height="16"  class="icon" align="center"  alt="<%=idx.toString()%>"  src="../includes/images/lov.jpg" name="butPosition" onclick="return ShowPosition(this.alt);" /></td>
                                  </logic:equal>
                                  <logic:notEqual name="HrmMisRep" property="status" value="N"  >
                                <TD class=tableText colspan=3 ><html:text property="txtPosition" name="HrmMisRep" style="width:95%" onkeypress="isInteger(event)" titleKey="hrm.HrmMisReport.Position" styleClass="required" readonly="true" onchange='<%="doChangeDetail("+idx.toString()+")"%>' /><img height="16"  class="icon" align="center"  alt="<%=idx.toString()%>"  src="../includes/images/lov_dis.jpg" name="butPosition" /></td>
                                  </logic:notEqual>
                                <TD class=tableText colspan=2 ><html:text property="txtDesiredStrength" name="HrmMisRep" style="width:100%" alt="D" onchange='<%="doChangeDetail("+idx.toString()+")"%>' maxlength="10" onkeydown="isInteger(event)" styleClass="required" /></td>
                             </tr>
                            </logic:notEqual>
                            
                              <logic:equal name="HrmMisRep" property="status" value="D"  >
                               <tr class='<bean:write name="HrmMisReportForm" property="listRowClass"/>'  >
                                <td >
                                <html:hidden property="status"  name="HrmMisRep" />
                                <html:hidden property="detailId"  name="HrmMisRep"  />
                                <html:checkbox property="checked"  name="HrmMisReportForm" disabled="true" />
                                <html:hidden property="itemChecked" name="HrmMisRep" />
                                <html:hidden property="txtPositionId" name="HrmMisRep" />
                                </td>
                                <TD class=tableText colspan=3><html:text property="txtPosition" name="HrmMisRep" style="width:95%" styleClass="deletedRow" onchange='<%="doChangeDetail("+idx.toString()+")"%>' readonly="true" /><img height="16"  class="icon" align="center"  alt="<%=idx.toString()%>"  src="../includes/images/lov_dis.jpg" name="butPosition" /></td>
                                <TD class=tableText colspan=2><html:text property="txtDesiredStrength" name="HrmMisRep" style="width:100%" styleClass="deletedRow" onchange='<%="doChangeDetail("+idx.toString()+")"%>' readonly="true" /></td>
                                
                              
                             </tr>
                             </logic:equal>             
                           
                         </logic:iterate>
                         
                    </TBODY>
                </TABLE>
              </DIV>
            </TD>
          </TR>
          
              <tr>
                  <td colspan=5>	
                    <jsp:include page="GenDetailMenu.jsp" />
                  </td>
                  <td width="13%"></td>
                </tr>
                   </TBODY>
                </TABLE>
              </td>
            </tr>
        </TABLE>
     </td>
	 </tr>
              
              <!-- Tab Table Ends -->

      <!-- Bottom Blue Bar -->
          <TR>
            <td>
              <TABLE  cellspacing="0" cellpadding="0" border=0>
                     <tr>
                        <td width=10% align=center bgColor=#4682b4></td>
                        <td  bgColor=#4682b4><enrgise:button name="HrmMisReportForm"   onclick="doShowReport();" property="butGenReport" styleClass="bottomBarText">Generate Current &nbsp;Report</enrgise:button><td>                 
                        <td  bgColor=#4682b4><enrgise:button name="HrmMisReportForm" onclick="doGetReport();" property="butViewReport" styleClass="bottomBarText">View Previous &nbsp;Report</enrgise:button><td>                 
                        <td align=right bgColor=#4682b4><img src="../includes/images/man.jpg"></td>
                        
                   </TR>
              </table>
            </td>
          </tr>
 
<!-- Container Table Ending Columns Starts-->
    
</TBODY>
</TABLE>
<html:hidden name="HrmMisReportForm"  property="screenMode"  />
<html:hidden name="HrmMisReportForm"  property="screenName" value="HrmMisReport" />
<html:hidden name="HrmMisReportForm"  property="forwardedPage" />
<html:hidden property="positionRequested" name="HrmMisReportForm" />


<html:hidden property="detailDataChanged" name="HrmMisReportForm" />
<html:hidden property="headerDataChanged" name="HrmMisReportForm" />

<html:hidden property="userPageRequested" name="HrmMisReportForm" />
<html:hidden property="userPositionRequested" name="HrmMisReportForm" />
<html:hidden property="pageRequested" name="HrmMisReportForm" />

<html:hidden property="lovKey" name="HrmMisReportForm"  />
<html:hidden property="txtSearchFields" name="HrmMisReportForm"  />
<html:hidden property="txtDisplayFields" name="HrmMisReportForm"  />

<html:hidden property="headerPrimaryKey" name="HrmMisReportForm"  />
<html:hidden property="buttonName" name="HrmMisReportForm"  />
<html:hidden property="txtYearMonth" name="HrmMisReportForm"  />


<html:hidden property="txtIndex" name="HrmMisReportForm"  />
<html:hidden property="firstLoad" name="HrmMisReportForm"  />

<input type="hidden" name="multipleFlag" >
<input type="hidden" name="queryParam" >
<html:hidden property="locationCode" name="HrmMisReportForm"  /> 
    
<!-- Container Table Ends -->
<input type="hidden" name="reportPath" value="/hrms/report/esistatement.jasper"/>
<input type="hidden" name="reportFormat" value="TEXT"/>
<input type="hidden" name="DOWNLOAD" value="Y"/>
</html:form>
</body>
</html:html>

 <% ReportReader oReportReader=new ReportReader(); %> 
    <% ParamUtil oParamUtil=new ParamUtil(); %> 

<script language="javascript">
function downloadReport(target,downloadOption) {
    var button = document.getElementsByName('button');
    button.value='Download';
	  var downloadField = document.getElementsByName("DOWNLOAD");
    downloadField.value = downloadOption;
    //alert('downloadOption : ' + downloadOption);
    document.forms[0].submit();
    window.open(target,'Abc');
}
function doChangeHeader()
{

 if(document.forms[0].screenMode.value=="U" || document.forms[0].screenMode.value=="N"){
   document.forms[0].headerDataChanged.value="true";
 }
}
function boxClicked(val)
{    
    if(document.getElementsByName("checked")[val].checked)
    {      
      document.getElementsByName("itemChecked")[val].value = "Y";      
    }
    else
    {     
      document.getElementsByName("itemChecked")[val].value = "N";     
    }      
}

function doQueryMode()
{

  return "HrmMisRepQueryModeAction.do";
}


function doInsertMode()
{

  return "HrmMisRepNewModeAction.do";
}


function doExecute()
{

  return "HrmMisRepGetHeaderAction.do";
}

function doSave()
{

  return "HrmMisRepSaveAction.do";
  
}



function doDelete()
{

  return "HrmMisRepDeleteAction.do";
  
}

function doRefresh()
{

  return "HrmMisRepRefreshAction.do";
  
}

function doPrevHeader()
{
  return "HrmMisRepGetNextHeaderAction.do"; 
}

function doNextHeader()
{
  return "HrmMisRepGetNextHeaderAction.do"; 
}

function doJumpHeader()
{
  return "HrmMisRepGetNextHeaderAction.do"; 
}


function doDelRow()
{
 return "HrmMisRepDeleteRowAction.do";  
}

function doGetDetailTableName()
{
  return "tableName";
}

function doPrevDetail()
{

  return "HrmMisRepGetDetailPageAction.do";  
}

function doNextDetail()
{

  return "HrmMisRepGetDetailPageAction.do";
}

function doJumpDetail()
{
  return  "HrmMisRepGetDetailPageAction.do"; 
}


function doGetDetail()
{
return "HrmMisRepGetDetailAction.do";  

}

function doAddRow()
{
    return "HrmMisRepAddRowAction.do";
}
function doExit()
{
    return "HrmMisRepExitAction.do";
}


function setCheckedValues(val)
{
document.forms[0].hidDetailId.value=document.getElementsByName("DetailId")[val].value;
}
function doValidate()
{
  return  "HrmMisRepValidateAction.do"; 
}

function doOnLoad()
{
  if(document.forms[0].firstLoad.value!="false")
  {
    return  "HrmMisRepOnLoadAction.do"; 
  }
}

function ShowPosition(i)
{
        
        document.forms[0].queryParam.value ="location="+ document.forms[0].locationCode.value ;
        document.forms[0].lovKey.value = "HrmMisRepPost" + document.forms[0].screenName.value + document.forms[0].screenMode.value;
        document.forms[0].txtSearchFields.value = "hrm.HrmMisReport.Position";
        document.forms[0].txtIndex.value = i;
        document.forms[0].txtDisplayFields.value = "txtPositionId,txtPosition"; 
        showLov('<html:rewrite page="/hrms/jsp/CommonSearchScreen.jsp" />','HrmMisReportForm');
        return true;
       
}

function doGetReport()
{
        
        document.forms[0].lovKey.value = "HrmMisRepYYYYMM" + document.forms[0].screenName.value + document.forms[0].screenMode.value;
        document.forms[0].txtSearchFields.value = "hrm.HrmMisReport.yearmonth";
        document.forms[0].multipleFlag.value = "false";
        document.forms[0].txtDisplayFields.value = "txtYearMonth"; 
        showLov('<html:rewrite page="/hrms/jsp/CommonSearchScreen.jsp" />','HrmMisReportForm');
        return true;
       
}

function doOnChangeLov(lovName)
{
   if(lovName=="HrmMisRepYYYYMMHrmMisReportQ" || lovName=="HrmMisRepYYYYMMHrmMisReportU") 
    {
      doShowReport();
    }
}

function doShowReport()
{
  document.forms[0].headerDataChanged.value="false"; 
  document.forms[0].detailDataChanged.value="false";
  var win_option="width=900,height=620,left=50,top=50,modal=yes,"+"toolbar=yes,location=no,directories=no,status=no,menubar=yes,"+"scrollbars=yes,resizable=yes";
  window.open("http://<%=oReportReader.getAppServerName()%>:<%=oReportReader.getAppServerPortNumber()%>/<%=oReportReader.getAppServerReportPathAlias()%>/rwservlet?<%=oParamUtil.getKeyinfo("Hrms","HrmMisReport","RepHrmMisReportKey").trim()%>&yearmonth="+document.forms[0].txtYearMonth.value,'',win_option);
  

}

function doSetFlag(val)
{ 
     
      HrmMisReportForm.locationCode.value=val;
      doBaseValidate();
     
}


function doAllInsertion()
{
  document.forms[0].headerDataChanged.value="false"; 
  document.forms[0].detailDataChanged.value="false";
  document.forms[0].buttonName.value="butGenRep";
  document.forms[0].action= contextRoot+"HrmMisRepGetButtonAction.do";
  document.forms[0].submit();
}

</script>
