edit.jsp 26 KB

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