OI_ECMAIL.jsp 6.25 KB
Newer Older
Thitichaipun Wutthisak committed
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 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%@ page import="org.apache.commons.lang.StringUtils"%>
<%@ page import="com.csc.library.session.DbRecord"  %>
<%@ page import="com.csc.library.session.InitialRecord"  %>
<%@ page import="com.csc.library.session.InitialEnvironment"  %>
<%@ page import="com.csc.library.mail.SendMail"  %>
<%@ page import="com.csc.library.utilities.SendPm"  %>
<%@ page import="com.csc.library.utilities.MyLog"  %>
<%@ page import="com.csc.library.utilities.UProfile"  %>
<%@ include file="../CHECKPROFILE.jsp"%>
<% request.setCharacterEncoding("UTF-8"); %>
<%
	String receiver = StringUtils.trimToEmpty(request.getParameter("__receiver"));
	String subject = StringUtils.trimToEmpty(request.getParameter("__subject")) ;
	String sender = uprofile.get("employeeid");
	String message = StringUtils.trimToEmpty(request.getParameter("__message")) ;
	
	if( StringUtils.equalsIgnoreCase("send", request.getParameter("__cmd"))  ) {
		
		if( request.getParameter("__send_pm") != null ) {
			try {
				final SendPm  pm = new SendPm( uprofile );
				
				pm.setSender( uprofile.getUserId()  );
				pm.setReceiver( receiver );
				pm.setSubject( subject );
				pm.setContent( message );
				pm.send();
				
			} catch (Exception e) {
				MyLog.error(this, uprofile, e);
			}
		}
		if( request.getParameter("__send_mail") != null ) {
			try {
				final String from = new InitialEnvironment("GLOBAL").getValue("MAILAUTH-username");
				final DbRecord dbRec = new InitialRecord( uprofile ).getDbRecord("memployee", false);
				dbRec.setColumn("employeeid,email,companyid,emp_prefix,fname,lname,efname,elname");
				dbRec.set("companyid", String.valueOf(uprofile.get("companyid")) );
				dbRec.set("employeeid", receiver);	
						
				if(dbRec.search() ==1 ) {
					String email = dbRec.getString("email");
					if( StringUtils.isNotEmpty( dbRec.getString("email") ) ) {
					
						final SendMail sm = new SendMail("", from, email, "", subject, message);
						sm.setUProfile( uprofile );
						sm.send();
					}
				}
			} catch (Exception e) {
				MyLog.error(this, uprofile, e);
			}
		}
	}
	
	
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>Employee View</title>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<!-- Begin CSS Links -->
<link rel="stylesheet" type="text/css" href="../CSS/EMV_DEFAULT.css" />
<link rel="stylesheet" type="text/css" href="../CSS/EMV_LAYOUT_POPUP.css" />
<link rel="stylesheet" type="text/css" href="../CSS/EMV_TEXT.css" />
<style type="text/css">
#send_type label { display: block;  }
#send_type label input { margin-right: 5px;}

</style>
<!-- End CSS Links -->
<!-- Begin Scripts -->
<script language="JavaScript"  type="text/javascript"src="../JS/EVENTS.js"></script>
<script language="JavaScript"  type="text/javascript"src="../JS/SCREEN.js"></script>
<script language="JavaScript" type="text/javascript">
	setLang("<%=uprofile.get("lang")%>");
	var title = swap2String("Send Mail");
	document.title = title;
	
	var i18n = {
		err_select_send_type: { tha: "กรุณาเลือกประเภทการส่งข้อความ", eng: "Please select send type"},
		err_subject: { tha: "กรุณาระบุหัวข้อ", eng: "Please input topic."},
		err_message: { tha: "กรุณาระบุรายละเอียด", eng: "Please input message body."}
	};
	
	function send() {
		with(document.cscform) {
			if( !send_mail.checked && !send_pm.checked) {
				alert(i18n.err_select_send_type[getLang()]);
				return false;
			} else if( !__subject.value) {
				alert(i18n.err_subject[getLang()]);
				return false;
			} else if( !__message.value) {
				alert(i18n.err_message[getLang()]);
				return false;
			}
			else {
				__cmd.value = "send";
				submit();
			}
		}
	}
</script>
<!-- End Scripts -->

</head>
<body onload="">
<form name="cscform" method="post"  action="?">

  <input type="hidden"name="__screen"  value="OI_ECMAIL">
  <input type="hidden" name="__fixCon" value="">
  <input type="hidden" name="__help" value="">
  <input type="hidden" name="__cmd"  value="">
  <input type="hidden" name="__calendar">
  <input type="hidden" name="__language" value ="<%=uprofile.get("lang")%>">
  <input type="hidden" name="__companyid" value="<%=uprofile.get("companyid")%>">
  <input type="hidden" name="__receiver" value="<%=receiver %>">
  
<div id="wrapper">
  <div id="header">
    <div class="content-header">
      
        <h2 class="right">
          <script language="javascript">document.write(title)</script>
        </h2>
    </div>
  </div>
  <div id="content">
  	
      <div>
        <div class="content-title"></div>
        <table width="100%" border="0" cellpadding="0" cellspacing="1" class="table-content" >
          <tr>
            <td width="150" class="column-label" ><script language="javascript">swapLang('Type');</script></td>
            <td class="column-text" ><div id="send_type">
            <label><input type="checkbox" name="__send_pm" id="send_pm" /> Private Message</label>
            <label><input type="checkbox" name="__send_mail" id="send_mail" /> Mail</label></div></td>
          </tr>
          <tr>
            <td class="column-label" ><script language="javascript">swapLang('Receiver');</script></td>
            <td class="column-input" ><input name="reciver" type="text" size="60" maxlength="15" value="<%=receiver %>" /></td>
          </tr>
          <tr>
            <td class="column-label" ><script language="javascript">swapLang('Subject');</script></td>
            <td class="column-input" ><input name="__subject" type="text" size="60" maxlength="50" value="<%=subject %>" /></td>
          </tr>
          <tr>
            <td class="column-label" ><script language="javascript">swapLang('Message');</script></td>
            <td class="column-input" ><textarea name="__message" cols="60" rows="5"><%=message %></textarea></td>
          </tr>
          
        </table>
        <div class="button-line"><a href="javascript:send();"><img src="../IMAGES/EMPVIEW/BUTTON/SEND.gif" alt="Send" /></a><a href="javascript:close();"><img src="../IMAGES/EMPVIEW/BUTTON/CLOSE.gif" alt="Close" /></a></div>
      </div>
  </div>
</div>
</form>
</body>
</html>