1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
| <*----------------------------------------打印离职证明----------------------------------------*>
Function Print2 Local string &DESCR, &year, &month, &day; Local number &i; Local XmlDoc &xmlDoc; Local XmlNode &root_node, &sub_node, &text_node; Local number &check1; Local PSXP_RPTDEFNMANAGER:ReportDefn &oRptDefn; rem Local File &dataFile; rem Local string &last_name, &descr, &descr2, &SNDKP; rem Local number &index; Local C_PACKAGE:HtmlToExcle &htmlToExlcle = create C_PACKAGE:HtmlToExcle(); Local Rowset &RS = GetLevel0()(1).GetRowset(Scroll.C_PRINT_DATA_VW); rem 由于员工ID是唯一主键,所以查询出来只能有一条数据;
If (&RS.GetRow(1).C_PRINT_SR_WK.C_PRINT_CH.Value = 1) Then rem Local string &filepath = &htmlToExlcle.createFolder("xml"); &sDirSep = "/"; REM 创建路径指定的目录和在路径中指定的任何不存在的目录; CreateDirectory("XMLP", %FilePath_Relative); REM 字符串/files/XMLP/唯一标识符(字符串); &RptOutputDir = GetEnv("PS_SERVDIR") | &sDirSep | "files" | &sDirSep | "XMLP" | &sDirSep | UuidGen(); REM MessageBox(0, "", 0, 0, "" | &RptOutputDir); CreateDirectory(&RptOutputDir, %FilePath_Absolute); Local string &filepath = &RptOutputDir | "/" | %OperatorId | %Date | ".xml"; Local File &xmlFile = GetFile(&filepath, "W", "U", %FilePath_Absolute); rem MessageBox(0, "", 0, 0, &filepath); If Not &xmlFile.IsOpen Then Error ("Can't open the file " | &xmlFile); End-If; &xmlFile.WriteLine("<?xml version='1.0' encoding='utf-8'?>"); &xmlFile.WriteLine("<ROOT>"); REM 获取员工性别; Local string &CC; SQLExec("SELECT CASE WHEN SEX='M' THEN '男' ELSE '女' END FROM PS_PERSON WHERE EMPLID=:1", &RS.GetRow(1).C_PRINT_DATA_VW.C_PRINT_ID.Value, &CC); rem &xmlFile.WriteLine("<SEX>" | &CC | "</SEX>") ; REM MessageBox(0, "", 0, 0, "性别:" | &CC); If &CC = "男" Then &xmlFile.WriteLine("<NAME>" | &RS.GetRow(1).C_PRINT_DATA_VW.C_PRINT_NAME.Value | "先生</NAME>") ; Else &xmlFile.WriteLine("<NAME>" | &RS.GetRow(1).C_PRINT_DATA_VW.C_PRINT_NAME.Value | "女士</NAME>") ; End-If; rem &xmlFile.WriteLine("<EMPLID>" | &RS.GetRow(1).C_PRINT_DATA_VW.C_PRINT_ID.Value | "</EMPLID>") ; &xmlFile.WriteLine("<CARDID>" | &RS.GetRow(1).C_PRINT_DATA_VW.NATIONAL_ID.Value | "</CARDID>"); rem 获取当前部门+职务(岗位)的开始时间; Local string &bgndate; &bgndate = String(&RS.GetRow(1).C_PRINT_DATA_VW.DATE_CHAR1.Value); &bgnyear = Substring(&bgndate, 1, 4); &bgnmon = Substring(&bgndate, 6, 2); &bgnday = Substring(&bgndate, 9, 2); &xmlFile.WriteLine("<BGNYEAR>" | &bgnyear | "</BGNYEAR>"); &xmlFile.WriteLine("<BGNMON>" | &bgnmon | "</BGNMON>"); &xmlFile.WriteLine("<BGNDAY>" | &bgnday | "</BGNDAY>"); rem 获取当前部门+职务(岗位)的结束时间; Local string &enddate; &enddate = String(&RS.GetRow(1).C_PRINT_DATA_VW.DATE_CHAR.Value); &endyear = Substring(&enddate, 1, 4); &endmon = Substring(&enddate, 6, 2); &endday = Substring(&enddate, 9, 2); &xmlFile.WriteLine("<ENDYEAR>" | &endyear | "</ENDYEAR>"); &xmlFile.WriteLine("<ENDMON>" | &endmon | "</ENDMON>"); &xmlFile.WriteLine("<ENDDAY>" | &endday | "</ENDDAY>"); &xmlFile.WriteLine("<DEPT>" | &RS.GetRow(1).C_PRINT_DATA_VW.C_PRINT_DT_DSCR.Value | "</DEPT>"); &xmlFile.WriteLine("<POSITION>" | &RS.GetRow(1).C_PRINT_DATA_VW.C_PRINT_POST.Value | "</POSITION>"); rem 获取离职原因; Local string &reason; SQLExec("select r.descr from ps_job j,ps_ACTN_REASON_TBL r where j.action_reason = r.ACTION_REASON and j.effdt = (select max(pj.effdt) from ps_job pj where pj.emplid = j.emplid and pj.effdt < sysdate and pj.empl_rcd = '0') and j.effseq = (select max(pj1.effseq) from ps_job pj1 where pj1.emplid = j.emplid) and j.emplid = :1;", &RS.GetRow(1).C_PRINT_DATA_VW.C_PRINT_ID.Value, &reason); &xmlFile.WriteLine("<REASON>" | &reason | "</REASON>"); &xmlFile.WriteLine("<JYXY>未签订竞业限制协议。</JYXY>"); rem 获取竞业协议; REM if *** = ture then &xmlFile.WriteLine("<JYXY>"|"未签订竞业限制协议"|"</JYXY>"); REM else &xmlFile.WriteLine("<JYXY>"|"签订竞业限制协议(协议期限为劳动合同解除或终止之日起满XXX个月)"|"</JYXY>"); REM end-if; &xmlFile.WriteLine("<COM>" | &RS.GetRow(1).C_PRINT_DATA_VW.COMPANYID.Value | "</COM>"); rem 获取系统年月日; Local string &sysdate; SQLExec("SELECT TO_CHAR(SYSDATE , 'YYYY-MM-DD') FROM DUAL", &sysdate); REM &sysdate = String(%DATE); REM MessageBox(0, "", 0, 0, "系统时间:" | &sysdate); &sysyear = Substring(&sysdate, 1, 4); &sysmon = Substring(&sysdate, 6, 2); &sysday = Substring(&sysdate, 9, 2); &xmlFile.WriteLine("<SYSYEAR>" | &sysyear | "</SYSYEAR>"); &xmlFile.WriteLine("<SYSMON>" | &sysmon | "</SYSMON>"); &xmlFile.WriteLine("<SYSDAY>" | &sysday | "</SYSDAY>"); &xmlFile.WriteLine("</ROOT>"); rem C_PERS_TEMP_VW; &xmlFile.Close(); &oRptDefn = create PSXP_RPTDEFNMANAGER:ReportDefn("C_EMP_I_TEMP"); &oRptDefn.Get(); rem &oRptDefn.OutDestination = %FilePath; &oRptDefn.SetRuntimeDataXMLFile(&filepath); rem &oRptDefn.ProcessInstance = &ProcessInstance; &oRptDefn.ProcessReport("C_EMP_I_TEMP_1", "ZHS", %Date, ""); CommitWork(); &oRptDefn.DisplayOutput(); REM &oRptDefn.Publish("", "", "", &ProcessInstance); try catch Exception &Err If Not &oRptDefn = Null Then &oRptDefn.Close(); End-If; WriteToLog(%ApplicationLogFence_Error, &Err.ToString()); &Err.Output(); end-try; SQLExec("select 1 from ps_c_print_log where c_print_id=:1", &RS.GetRow(1).C_PRINT_DATA_VW.C_PRINT_ID.Value, &check1); If &check1 = 0 Then Local Record &REC = CreateRecord(Record.C_PRINT_LOG); &REC.C_PRINT_ID.Value = &RS.GetRow(1).C_PRINT_DATA_VW.C_PRINT_ID.Value; &REC.C_PRINT_FLAG.Value = "1"; &REC.Insert(); CommitWork(); End-If; Else Error "请勾选需要打印证明的员工"; End-If; End-Function;
|