<%@page contentType="text/html; charset=UTF-8"%>
<%@page import="com.csc.library.entry.HelpEntry,com.csc.library.system.*,com.csc.library.utilities.*"%>
<%@ page import="com.csc.library.entry.*,com.csc.library.database.*,com.csc.library.session.*"  %>
<jsp:useBean id="APS_DEL360" class="com.csc.library.system.Task" scope="page"/>
<%
	APS_DEL360.setChannel(request ,response);
   	ProcessEntry screen=(ProcessEntry)APS_DEL360.process("ProcessEntry","Process");
   	screen.process();

	CscCalendar today = new CscCalendar();
%>
<html ng-app="myHR">
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="../CSS/TISCO.css" rel="stylesheet" type="text/css">
        <script type='text/javascript' src='../JS/SCREEN.js'></script>
        <script language="javascript" src='../APPRAISAL/JS/PROCESS.js'></script>
        <script src="../JS/angular-1.3.15/angular.js" type="text/javascript"></script>
        <script src="../JS/ANGULAR/SCREEN_ANGULAR.js" type="text/javascript"></script>
        <script src="../JS/jquery-2.1.3.min.js" type="text/javascript"></script>
        <script language="javascript">setLang('<%=screen.getUProfile().get("lang")%>');</script>
        <script language="JavaScript">

            function process() {
                with(document.cscform){
                    if(chkapsid()){
                       alert('กรุณาเลือก เลขที่เอกสาร')
                    }else{
                        bCon=confirm("Start Delete Appraisal Data Process?");
                        if (bCon==true)	{
                            setDataProcess();
                            if($("select[name='__astype']").val() == "AP40"){
                                $("input[name='__prclass']").val("Delete360DegreeApprisalData") ;
                            }else if($("select[name='__astype']").val() == "AP10"){
                                $("input[name='__prclass']").val("DeleteApprisalData") ;
                            }
                             __cmd .value = "process";
                             submit();
                        }
                    }
                }
            }

            function chkapsid(){
                let result = true
                let i = 0
                $("select[name='apsidList']").find("option").each(function(){
                    i++
                })
                if(i > 0 ){
                    result = false
                }
                return result
            }

            function setDataProcess(){
                var jsObjJSON = {};
                var jsonObj = {};
                var jsonStr = "";
                var bu1 = "";
                var bu2 = "";
                var bu3 = "";
                var bu4 = "";
                var branch = "";
                var workarea = "";
                var emplist = "";
                var position = "";
                var empbet = "";
                var aps = "";
                var pl = "";

                //BU1
                $("select[name='bu1List']").find("option").each(function(){
                    bu1 = chkComma(bu1) + "'"+$(this).val()+"'";
                });
                //BU2
                $("select[name='bu2List']").find("option").each(function(){
                    bu2 = chkComma(bu2) + "'"+$(this).val()+"'";
                });
                //BU3
                $("select[name='bu3List']").find("option").each(function(){
                    bu3 = chkComma(bu3) + "'"+$(this).val()+"'";
                });
                //BU4
                $("select[name='bu4List']").find("option").each(function(){
                    bu4 = chkComma(bu4) + "'"+$(this).val()+"'";
                });
                //branch
                $("select[name='branchList']").find("option").each(function(){
                    branch = chkComma(branch) + "'"+$(this).val()+"'";
                });
                //workarea
                $("select[name='workareaList']").find("option").each(function(){
                    workarea = chkComma(workarea) + "'"+$(this).val()+"'";
                });
                //emplist
                $("select[name='employeeList']").find("option").each(function(){
                    emplist = chkComma(emplist) + "'"+$(this).val()+"'";
                });
                //position
                $("select[name='positionList']").find("option").each(function(){
                    position = chkComma(position) + "'"+$(this).val()+"'";
                });
                //apsid
                $("select[name='apsidList']").find("option").each(function(){
                    aps = chkComma(aps) + "'"+$(this).val()+"'";
                });
                //pl
                $("select[name='plList']").find("option").each(function(){
                    pl = chkComma(pl) + "'"+$(this).val()+"'";
                });
                //empbet
                empbet ="(employeeid between '"+$("input[name='empStart']").val()+"' and '"+$("input[name='empEnd']").val()+"')";

                jsonObj = ({
                    "BU1":bu1,
                    "BU2":bu2,
                    "BU3":bu3,
                    "BU4":bu4,
                    "BRANCH":branch,
                    "WORKAREA":workarea,
                    "EMPLIST":emplist,
                    "POSITION":position,
                    "aps":aps,
                    "pl":pl,
                    "EMPBET":empbet

                });

                jsObjJSON = { json : jsonObj};
                jsonStr = JSON.stringify( jsObjJSON );
                $('input[name="__condition$empfilter"]').val(jsonStr);
                console.log("jsonStr == "+ jsonStr);
            }

            function chkComma(str){
                if(str !== ""){
                    str += ",";
                }
                return str;
            }
        </script>
    </head>
    <body  leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif')" >
        <form name="cscform" method="post" action="">
            <!----------BEGIN CSC INITIAL ZONE ------------------------>
            <%=screen.InitialVariable()%>
            <!----------END CSC INITIAL ZONE -------------------------->

            <input type="hidden" name="__screen"  value="APS_DEL360">
            <input type="hidden" name="__fixCon"  value="">
            <input type="hidden" name="__cmd"  value="">
            <input type="hidden" name="__help"  value="">
            <input type="hidden" name="__user" value="<%=screen.getUProfile().getUserId()%>">
            <input type="hidden" name="__companyid" value='<%=screen.getUProfile().get("companyid")%>'>
            <input type="hidden" name="__tname" value="ลบข้อมูลการประเมินผลหน่วยงาน">
            <input type="hidden" name="__ename" value="Delete APS360">
            <input type="hidden" name="__ptype" value="">
            <input type="hidden" name="__prclass" value="">
            <input type="hidden" name="__calendar" value="">
            <script language="javascript">getInputFormatDate();</script>
            <input type="hidden" name="__language" value ="<%=screen.getUProfile().get("lang")%>">
            <div id="toolTipLayer" style="position:absolute; visibility: hidden"></div>
            <script language="javascript">initToolTips();</script>
            <input type="hidden" name="__condition$empfilter" value="">
            <br>
            <div align="center">
                <table  cellpadding="0"  cellspacing="0">
                    <tr >
                        <td  class="header" colspan="4"> APS_DEL360,&nbsp;<span>Delete Apprisal Data</span>&nbsp;</td>
                    </tr>
                    <tr>
                        <td colspan="4" class="blankspace"  ></td>
                    </tr>
                    <tr>
                        <td colspan="4" class="blankspace"  ></td>
                    </tr>

                    <tr>
                        <td colspan="4">&nbsp;</td>
                    </tr>

                     <tr>
                        <td>
                            <div style="margin-left: 20%;">
                                <span swlang code="SW001152">Appraisal Type </span> *&nbsp;&nbsp;
                                <select name="__astype" >
                                    <%
                                        DbInquiry mastype = new InitialInquiry(screen.getUProfile()).getDbInquiry("mastype");
                                        mastype.setColumn("*");
                                        mastype.setFilter("astid in ('AP10','AP40')");
                                        mastype.refresh();
                                        while(mastype.next()){
                                    %>
                                    <option value="<%=mastype.getString("astid")%>"><%=mastype.getString("tdesc")%></option>
                                    <%
                                        }
                                    %>
                                </select>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4">&nbsp;</td>
                    </tr>
                    <tr>
                        <td>
                            <div style="margin-left: 20%;"><span swlang code="SW000274">Employee ID </span>&nbsp;&nbsp;
                                <input type="text" name="empStart" size="15">
                                <a href="javascript:goHelp('MEMPLOYEEHELP','empStart','')" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image3','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)"><img src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" alt="Help" name="Image3" width="20" height="20" border="0" align="absmiddle"></a>&nbsp;&nbsp;-&nbsp;&nbsp;
                                <input type="text" name="empEnd" size="15">
                                <a href="javascript:goHelp('MEMPLOYEEHELP','empEnd','')" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image4','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)">
                                    <img src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" alt="Help" name="Image4" width="20" height="20" border="0" align="absmiddle">
                                </a>
                            </div>
                        </td>
                    </tr>
                    <tr >
                        <td colspan="4">
                            <table width="100%" border="0">
                                <tr>
                                    <td colspan="2" class="blankspace"  ></td>
                                </tr>

                                 <tr>
                                    <td width="50%" align="center">
                                        <span swlang code="SW012812">Documents No</span>&nbsp;
                                        <input type="button" name="__apsid" value="click" onClick="javascript:goHelp('TAPSTRAN0HELP','aps','apsidList')"/>
                                    </td>
                                    <td width="50%" align="center">
                                        <span swlang code="SW012005">Personal Level</span>&nbsp;
                                        <input type="button" name="__plid" value="click" onClick="javascript:goHelp('MPERSONALLEVELHELP','pl','plList')"/>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="center">
                                        <select name="apsidList" size="20" multiple class="large" style="width:250; height:100" onDblClick="listDblClick(this.form.apsidList);"></select>
                                    </td>
                                    <td align="center">
                                        <select name="plList" size="20" multiple class="large" style="width:250; height:100" onDblClick="listDblClick(this.form.plList);"></select>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2" class="blankspace"></td>
                                </tr>

                                <tr>
                                    <td width="50%" align="center">
                                        <script language="javascript">swapLang("Employee");</script>&nbsp;
                                        <input type="button" name="__employeeid" value="click" onClick="javascript:goHelp('MEMPLOYEEHELP','employee','employeeList')"/>
                                    </td>
                                    <td width="50%" align="center">
                                        <script language="javascript">swapLang("Position");</script>&nbsp;
                                        <input type="button" name="__positionid" value="click" onClick="javascript:goHelp('MPOSITIONHELP','position','positionList')"/>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="center">
                                        <select name="employeeList" size="20" multiple class="large" style="width:250; height:100" onDblClick="listDblClick(this.form.employeeList);"></select>
                                    </td>
                                    <td align="center">
                                        <select name="positionList" size="20" multiple class="large" style="width:250; height:100" onDblClick="listDblClick(this.form.positionList);"></select>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2" class="blankspace"></td>
                                </tr>
                                <%
                                    DbInquiry memployee = new InitialInquiry(screen.getUProfile()).getDbInquiry("memployee");
                                    memployee.setColumn("employeeid,companyid,bu1,bu2,bu3,bu4,bu5");
                                    memployee.refresh();

                                    DbRecord mbu = memployee.getCurrentDbRecord();
                                %>
                                <tr>
                                    <td width="50%" align="center"><%=mbu.getField("bu1").getDescription()%>&nbsp;<input type="button" name="__bu1id" value="click" onClick="javascript:goHelp('MBU1HELP','bu1','bu1List')"/></td>
                                    <td width="50%" align="center"><%=mbu.getField("bu2").getDescription()%>&nbsp;<input type="button" name="__bu2id" value="click" onClick="javascript:goHelp('MBU2HELP','bu2','bu2List')"/></td>
                                </tr>
                                <tr>
                                    <td align="center">
                                        <select name="bu1List" size="20" multiple class="large" style="width:250; height:100" onDblClick="listDblClick(this.form.bu1List);"></select>
                                    </td>
                                    <td align="center">
                                        <select name="bu2List" size="20" multiple class="large" style="width:250; height:100" onDblClick="listDblClick(this.form.bu2List);"></select>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2" class="blankspace"  ></td>
                                </tr>
                                <tr>
                                    <td width="50%" align="center"><%=mbu.getField("bu3").getDescription()%>&nbsp;
                                        <input type="button" name="__bu3id" value="click" onClick="javascript:goHelp('MBU3HELP','bu3','bu3List')"/>
                                    </td>
                                    <td width="50%" align="center"><%=mbu.getField("bu4").getDescription()%>&nbsp;
                                        <input type="button" name="__bu4id" value="click" onClick="javascript:goHelp('MBU4HELP','bu4','bu4List')"/>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="center">
                                        <select name="bu3List" size="20" multiple class="large" style="width:250; height:100" onDblClick="listDblClick(this.form.bu3List);"></select>
                                    </td>
                                    <td align="center">
                                        <select name="bu4List" size="20" multiple class="large" style="width:250; height:100" onDblClick="listDblClick(this.form.bu4List);"></select>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2" class="blankspace"  ></td>
                                </tr>
                                <tr>
                                    <td width="50%" align="center">
                                        <script language="javascript">swapLang("Branch");</script>&nbsp;
                                        <input type="button" name="__branchid" value="click" onClick="javascript:goHelp('MBRANCHHELP','branch','branchList')"/>
                                    </td>
                                    <td width="50%" align="center">
                                        <script language="javascript">swapLang("Workarea");</script>&nbsp;<input type="button" name="__workareaid" value="click" onClick="javascript:goHelp('MWORKAREAHELP','workarea','workareaList')"/>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="center">
                                        <select name="branchList" size="20" multiple class="large" style="width:250; height:100"onDblClick="listDblClick(this.form.branchList);"></select>
                                    </td>
                                    <td align="center">
                                        <select name="workareaList" size="20" multiple class="large" style="width:250; height:100" onDblClick="listDblClick(this.form.workareaList);"></select>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2" class="blankspace">
                                        <div align="center">
                                            <a href="javascript:process();"><img src="../IMAGES/BUTTON/PROCESS.gif" border="0"></a>&nbsp;&nbsp;
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2" class="blankspace"  ></td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td  class="bottom" colspan="2"></td>
                    </tr>
                </table>
            </div>
        </form>
    </body>
</html>
