send.jsp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
  2. <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
  3. <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
  4. <%@ page language="java" contentType="text/html; charset=UTF-8"
  5. pageEncoding="UTF-8"%>
  6. <jsp:include page="${data._INCLUDE}/header.jsp"></jsp:include>
  7. <script src="/resources/js/common/jquery.tablesorter.min.js"></script>
  8. <script>
  9. $( function(){
  10. setEventInit();
  11. setTargetSelect();
  12. setSendSelect();
  13. $( "#sendForm" ).validate({
  14. rules: {
  15. sendDate : {
  16. date : true
  17. }
  18. },
  19. messages : {
  20. targetPreview : {
  21. required : "대상자를 1명 이상 선택해주세요"
  22. }
  23. },
  24. onfocusout: function (element) {
  25. $( element ).val( $.trim( $( element ).val() ) );
  26. $( element ).valid();
  27. },
  28. submitHandler: function(form) {
  29. console.log( $( form ).serialize() );
  30. alertBox({
  31. txt: "등록 하시겠습니까?",
  32. type : "confirm",
  33. callBack : function( result ){
  34. if( result ) {
  35. form.submit();
  36. }
  37. }
  38. })
  39. }
  40. });
  41. $( "input.date" ).daterangepicker({
  42. singleDatePicker : true,
  43. // timePicker: true,
  44. showDropdowns : true,
  45. locale : {
  46. format : "YYYY-MM-DD"
  47. },
  48. // maxDate : ,
  49. minDate : new Date()
  50. }).on('apply.daterangepicker', function(ev, picker) {
  51. // 예약발송 -> 오늘날짜면 minDate 재설정
  52. $( "input.date-time-r" ).daterangepicker({
  53. singleDatePicker : true,
  54. showDropdowns : true,
  55. timePicker: true,
  56. locale: {
  57. format: 'HH:mm'
  58. },
  59. minDate : new Date()
  60. }).on('show.daterangepicker', function(ev, picker) {
  61. picker.container.find(".calendar-table").hide();
  62. });
  63. if( new Date().format( "yyyy-MM-dd" ) < $( this ).val() ) {
  64. $( "input.date-time-r" ).data( 'daterangepicker' ).minDate = "";
  65. }
  66. });
  67. // 예약 발송
  68. $( "input.date-time-r" ).daterangepicker({
  69. singleDatePicker : true,
  70. showDropdowns : true,
  71. timePicker: true,
  72. locale: {
  73. format: 'HH:mm',
  74. applyLabel: "적용",
  75. cancelLabel: "닫기"
  76. },
  77. minDate : new Date()
  78. }).on('show.daterangepicker', function(ev, picker) {
  79. picker.container.find(".calendar-table").hide();
  80. });
  81. // 매일 반복 발송
  82. $( "input.date-time-e" ).daterangepicker({
  83. singleDatePicker : true,
  84. showDropdowns : true,
  85. timePicker: true,
  86. locale: {
  87. format: 'HH:mm',
  88. applyLabel: "적용",
  89. cancelLabel: "닫기"
  90. }
  91. }).on('show.daterangepicker', function(ev, picker) {
  92. picker.container.find(".calendar-table").hide();
  93. });
  94. // checkbox 전체선택, 해제 이벤트 처리
  95. $( "#allCheck" ).click( function(){
  96. $( "#patientList" ).find( "input[name='patientIdx']" ).prop( "checked", $( this ).prop( "checked" ) );
  97. });
  98. $( "#patientList" ).find( "input[name='patientIdx']" ).click( function(){
  99. if( $( "#patientList" ).find( "input[name='patientIdx']:not(:checked)" ).length > 0 ){
  100. $( "#allCheck" ).prop( "checked", false );
  101. } else {
  102. $( "#allCheck" ).prop( "checked", true );
  103. }
  104. });
  105. });
  106. function setEventInit(){
  107. // 그룹선택 or 환자개별선택
  108. $( "input.target-select" ).click( function(){
  109. setTargetSelect();
  110. });
  111. // 발송방식 선택
  112. $( "input.send-select" ).click( function(){
  113. setSendSelect();
  114. });
  115. // 그룹선택이나 환자개별선택시 초기화 해야할부분 처리
  116. $( "input[name='selectType']" ).on( "click", function(){
  117. var selectType = $( this ).val();
  118. if( selectType == "GROUP" ) {
  119. // 그룹 선택
  120. $('#radio-target-a').click();
  121. initPatientSelect();
  122. } else if( selectType == "PATIENT" ) {
  123. // 환자 개별 선택
  124. $('#radio-target-p').click();
  125. }
  126. });
  127. // 환자 개별 선택 팝업창 열때 현재 선택된 환자목록 기준으로 팝업창에서 선택한 환자 동기화
  128. $( "#selectPatientList" ).on( "show.bs.modal", function(){
  129. var $this = $( this );
  130. var listPushTargetTemp = $( "#pushTargetTemp" );
  131. var savedPushTargetTemp = listPushTargetTemp.find( "input[type='checkbox']:checked" ).serializeArray();
  132. $( "#patientList" ).find( "input[type='checkbox']:checked" ).prop( "checked", false );
  133. savedPushTargetTemp.forEach( function( item, index, arr2 ){
  134. // console.log(item,index,arr2[index+1]);
  135. $this.find( "input[type='checkbox']:input[value='"+ item.value +"']" ).prop( "checked", true );
  136. });
  137. });
  138. $( "#sortTable" ).tablesorter({
  139. headers:{
  140. 2:{sorter:"text"},
  141. 3:{sorter:"text"}
  142. }
  143. });
  144. }
  145. function setTargetSelect(){
  146. $( "tr.target-select" ).hide();
  147. $( "#" + $( "input.target-select:checked" ).prop( "accessKey" ) ).fadeIn( 100 );
  148. };
  149. function setSendSelect(){
  150. $( "tr.send-select" ).hide().find( "input" ).prop( "disabled", true );
  151. $( "#" + $( "input.send-select:checked" ).prop( "accessKey" ) ).fadeIn( 100 ).find( "input" ).prop( "disabled", false );
  152. }
  153. function initPatientSelect(){
  154. $( "#allCheck" ).prop( "checked", false );
  155. $( "#pushTargetTemp" ).empty();
  156. $( "#target-preview" ).val( "" );
  157. $( "#pushTargetTempTotal" ).text( "" ).hide();
  158. }
  159. function saveSelectedPatientList(){
  160. alertBox({
  161. txt : "선택된 환자를 발송 대상자로 적용할까요?",
  162. type : "confirm",
  163. callBack : function( result ){
  164. if( result ) {
  165. addPatientToTargetTemp()
  166. } else {
  167. console.log( "취소 -> no event" );
  168. };
  169. }
  170. });
  171. $( "#selectPatientList" ).find( ".modal-title h3" ).remove();
  172. }
  173. function addPatientToTargetTemp(){
  174. $( "#selectPatientList" ).modal( "hide" );
  175. $( "#pushTargetTemp" ).empty();
  176. var appendData = $( "#patientList" ).find( "input[type='checkbox']:checked" ).clone();
  177. var name = appendData.map( function(){
  178. return $( this ).attr( "title" );
  179. }).get().join( ", " );
  180. console.log( name );
  181. appendData.appendTo( "#pushTargetTemp" );
  182. if( appendData.length > 0 ){
  183. $( "#pushTargetTempTotal" ).text( appendData.length ).show();
  184. } else {
  185. $( "#pushTargetTempTotal" ).text( "" ).hide();
  186. }
  187. $( "#target-preview" ).val( name ).valid();
  188. }
  189. </script>
  190. </head>
  191. <body>
  192. <div class="modal fade" id="selectPatientList" tabindex="-1" role="dialog" aria-hidden="true">
  193. <div class="modal-dialog modal-xl modal-dialog-scrollable" role="document">
  194. <div class="modal-content">
  195. <div class="modal-header">
  196. <h5 class="modal-title">환자 선택</h5>
  197. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span> </button>
  198. </div>
  199. <div class="modal-body m-4">
  200. <table class="table mobile-table table-striped text-center" id="sortTable">
  201. <colgroup>
  202. <col style="width: 5%">
  203. <col style="width: 10%">
  204. <col style="width: 15%">
  205. <col style="width: 20%">
  206. <col style="width: 10%">
  207. <col style="width: 15%">
  208. <col style="width: 10%">
  209. <col style="width: 25%">
  210. </colgroup>
  211. <thead>
  212. <tr>
  213. <th>
  214. <input type="checkbox" id="allCheck" style="width:20px;height:20px;" >
  215. </th>
  216. <th>번호 <i class="fa fa-fw fa-sort"></i></th>
  217. <th>환자명 <i class="fa fa-fw fa-sort"></i></th>
  218. <th>호실 <i class="fa fa-fw fa-sort"></i></th>
  219. <th>성별 <i class="fa fa-fw fa-sort"></i></th>
  220. <th>생년월일 <i class="fa fa-fw fa-sort"></i></th>
  221. <th>나이 <i class="fa fa-fw fa-sort"></i></th>
  222. <th>입소일자 <i class="fa fa-fw fa-sort"></i></th>
  223. </tr>
  224. </thead>
  225. <tbody id="patientList">
  226. <c:choose>
  227. <c:when test="${total eq 0}">
  228. <tr>
  229. <td colspan="6">no data</td>
  230. </tr>
  231. </c:when>
  232. <c:otherwise>
  233. <c:forEach var="pl" items="${patientList}" varStatus="lStatus">
  234. <tr>
  235. <td class="no">
  236. <input type="checkbox" name="patientIdx" title="[<c:if test="${pl.wardNumber ne '' and pl.wardNumber ne null}">${pl.wardNumber}동</c:if> ${pl.roomNumber}호:${pl.patientName}]" value="${pl.patientIdx}" style="width:20px;height:20px;" >
  237. </td>
  238. <td class="no">
  239. <c:set var="pageNum" value="${total - lStatus.index}" />
  240. <fmt:formatNumber value="${pageNum}" pattern="#,###" />
  241. </td>
  242. <td class="name"><c:out value="${pl.patientName}" /></td>
  243. <td class="ward"><c:if test="${pl.wardNumber ne '' and pl.wardNumber ne null}">${pl.wardNumber}동</c:if> ${pl.roomNumber}호</td>
  244. <td class="gender"><c:out value="${pl.gender}" /></td>
  245. <td class="age"><c:out value="${pl.jumin}" /></td>
  246. <td class="age"><c:out value="${pl.age}" /></td>
  247. <td class="hospitalization-date"><c:out value="${pl.hospitalizationDate}" /></td>
  248. </tr>
  249. </c:forEach>
  250. </c:otherwise>
  251. </c:choose>
  252. </tbody>
  253. </table>
  254. </div>
  255. <div class="modal-footer">
  256. <button type="button" class="btn border" data-dismiss="modal">취소</button>
  257. <button type="button" class="btn btn-primary" onclick="saveSelectedPatientList();">선택 완료</button>
  258. </div>
  259. </div>
  260. </div>
  261. </div>
  262. <div class="wrapper">
  263. <jsp:include page="${data._INCLUDE}/sidebar.jsp"></jsp:include>
  264. <div class="main">
  265. <jsp:include page="${data._INCLUDE}/top.jsp"></jsp:include>
  266. <main class="content">
  267. <div class="container-fluid p-0">
  268. <div class="row">
  269. <div class="col-12 col-lg-6">
  270. <h1 class="h3 mb-3">푸시 발송</h1>
  271. </div>
  272. <div class="col-12 col-lg-6 text-right">
  273. <nav aria-label="breadcrumb">
  274. <ol class="breadcrumb">
  275. <li class="breadcrumb-item"><a href="javscript:;">Home</a></li>
  276. <li class="breadcrumb-item">푸시서비스 관리</li>
  277. <li class="breadcrumb-item active">푸시 발송</li>
  278. </ol>
  279. </nav>
  280. </div>
  281. </div>
  282. <div class="row">
  283. <div class="col-12">
  284. <div class="card">
  285. <div class="alert alert-light text-info border p-3">
  286. <span style="font-size:14px;">· 발송 전체 대상자중 입소자만 푸시 발송 가능<br/>· 그룹선택 발송일 경우 발송시간기준으로 환자 실시간 조회 및 발송되므로 대상자가 현재와 달라질 수 있음</span>
  287. </div>
  288. <form id="sendForm" action="./send/insert" method="post">
  289. <div class="card-body">
  290. <table class="table mobile-table">
  291. <colgroup>
  292. <col style="width:20%">
  293. <col style="width:80%">
  294. </colgroup>
  295. <tr>
  296. <th>생활치료센터명</th>
  297. <td><c:out value="${data._SES_CENTER_NAME}"/></td>
  298. </tr>
  299. <tr>
  300. <th>발송등록자</th>
  301. <td><c:out value="${data._SES_NAME}(${data._SES_ID})"/></td>
  302. </tr>
  303. <tr>
  304. <th rowspan="2"><span class="fix">*</span>발송 대상</th>
  305. <td>
  306. <label class="form-check form-check-inline">
  307. <input class="form-check-input target-select" accesskey="target-group" type="radio" name="selectType" value="GROUP" checked="checked">
  308. <span class="form-check-label">그룹 선택</span>
  309. </label>
  310. <label class="form-check form-check-inline">
  311. <input class="form-check-input target-select" accesskey="target-patient" type="radio" name="selectType" value="PATIENT">
  312. <span class="form-check-label">환자 개별 선택</span>
  313. </label>
  314. </td>
  315. </tr>
  316. <tr class="target-select" id="target-group" style="display:none;">
  317. <td>
  318. <label class="form-check form-check-inline">
  319. <input class="form-check-input" type="radio" id="radio-target-a" name="targetType" value="A" checked="checked" required>
  320. <span class="form-check-label">전체 환자</span>
  321. </label>
  322. <label class="form-check form-check-inline">
  323. <input class="form-check-input" type="radio" id="radio-target-n" name="targetType" value="N" required>
  324. <span class="form-check-label">건강정보 미입력 환자</span>
  325. </label>
  326. <label class="form-check form-check-inline">
  327. <input class="form-check-input" type="radio" id="radio-target-m" name="targetType" value="M" required>
  328. <span class="form-check-label">본인 관리 환자</span>
  329. </label>
  330. <label class="form-check form-check-inline">
  331. <input class="form-check-input" type="radio" id="radio-target-t" name="targetType" value="T" required>
  332. <span class="form-check-label">정신건강 자가진단 미입력 환자</span>
  333. </label>
  334. </td>
  335. </tr>
  336. <tr class="target-select" id="target-patient" style="display:none;">
  337. <td>
  338. <div class="form-row">
  339. <div class="col-7">
  340. <input class="form-check-input d-none" id="radio-target-p" type="radio" name="targetType" value="P">
  341. <input type="text" value="" class="form-control" name="targetPreview" id="target-preview" readonly required>
  342. <!-- 발송대상 checkboc동적 추가 hidden 영역 -->
  343. <div class="d-none" id="pushTargetTemp"></div>
  344. </div>
  345. <div class="col-4">
  346. <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#selectPatientList">환자 불러오기 <span id="pushTargetTempTotal" class="badge badge-danger" style="display:none;">2</span></button>
  347. </div>
  348. </div>
  349. </td>
  350. </tr>
  351. <tr>
  352. <th rowspan="2"><span class="fix">*</span>발송 방식</th>
  353. <td>
  354. <label class="form-check form-check-inline">
  355. <input class="form-check-input send-select" accesskey="send-d" type="radio" name="sendType" value="D" checked="checked" required>
  356. <span class="form-check-label">즉시 발송</span>
  357. </label>
  358. <label class="form-check form-check-inline">
  359. <input class="form-check-input send-select" accesskey="send-r" type="radio" name="sendType" value="R" required>
  360. <span class="form-check-label">예약 발송</span>
  361. </label>
  362. <label class="form-check form-check-inline">
  363. <input class="form-check-input send-select" accesskey="send-e" type="radio" name="sendType" value="E" required>
  364. <span class="form-check-label">매일 반복</span>
  365. </label>
  366. </td>
  367. </tr>
  368. <tr class="send-select" id="send-d">
  369. <td><span>즉시 발송되며 취소가 불가능 합니다</span></td>
  370. </tr>
  371. <tr class="send-select" id="send-r">
  372. <td>
  373. <span class="mr-2">예약</span>
  374. <div class="form-check-inline calendar-bar mb-xl-0" style="width:120px;">
  375. <input type="text" class="form-control date" value="" name="sendDate" autocomplete="off" placeholder="예약 일자" required>
  376. <i class="align-middle mr-2 fas fa-fw fa-calendar-alt"></i>
  377. </div>
  378. <div class="form-check-inline calendar-bar mb-xl-0" style="width:80px;">
  379. <input type="text" class="form-control date-time-r" value="" name="sendTime" autocomplete="off" placeholder="매일 반복 시간" required>
  380. <i class="align-middle mr-2 fas fa-fw fa-clock"></i>
  381. </div>
  382. <span>에 발송됩니다</span>
  383. </td>
  384. </tr>
  385. <tr class="send-select" id="send-e">
  386. <td>
  387. <span class="mr-2">매일</span>
  388. <div class="form-check-inline calendar-bar mb-xl-0" style="width:80px;">
  389. <input type="text" class="form-control date-time-e" value="" name="sendTime" autocomplete="off" placeholder="매일 반복 시간" required>
  390. <i class="align-middle mr-2 fas fa-fw fa-clock"></i>
  391. </div>
  392. <span>선택 시간에 반복 발송됩니다</span>
  393. </td>
  394. </tr>
  395. <tr>
  396. <th><span class="fix">*</span>푸시(알림) 제목</th>
  397. <td>
  398. <input type="text" name="pushTitle" class="form-control" placeholder="제목을 입력하세요" maxlength="80" required>
  399. </td>
  400. </tr>
  401. <tr>
  402. <th><span class="fix">*</span>푸시(알림) 내용</th>
  403. <td>
  404. <textarea class="form-control" rows="10" name="pushContent" placeholder="내용을 입력하세요" maxlength="1000" required></textarea>
  405. </td>
  406. </tr>
  407. </table>
  408. <div class="row mt-3">
  409. <div class="col-12">
  410. <div class="text-right">
  411. <button type="button" class="btn btn-outline-primary w100" onclick="history.back();">취소</button>
  412. <button type="submit" class="btn btn-primary w100">등록</button>
  413. </div>
  414. </div>
  415. </div>
  416. </div>
  417. </form>
  418. </div>
  419. </div>
  420. </div>
  421. </div>
  422. </main>
  423. <jsp:include page="${data._INCLUDE}/footer.jsp"></jsp:include>
  424. </div>
  425. </div>
  426. </body>
  427. </html>