fix: ccda zip import and php warnings and deprecations (#7416)
[openemr.git] / interface / billing / edih_view.php
blob8133f2a7ebc1b479988330580b0b6b0b1db6237a
1 <?php
3 /**
4 * edih_view.php
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Kevin McCormick Longview, Texas
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2012 Kevin McCormick Longview, Texas
11 * @copyright Copyright (c) 2018-2020 Brady Miller <brady.g.miller@gmail.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once(dirname(__FILE__) . '/../globals.php');
17 use OpenEMR\Common\Acl\AclMain;
18 use OpenEMR\Common\Csrf\CsrfUtils;
19 use OpenEMR\Common\Twig\TwigContainer;
20 use OpenEMR\Core\Header;
23 if (!AclMain::aclCheckCore('acct', 'eob')) {
24 echo (new TwigContainer(null, $GLOBALS['kernel']))->getTwig()->render('core/unauthorized.html.twig', ['pageTitle' => xl("EDI History")]);
25 exit;
29 <!DOCTYPE html>
30 <html>
32 <head>
33 <title><?php echo xlt("EDI History"); ?></title>
34 <?php Header::setupHeader(['datetime-picker', 'datatables', 'datatables-dt', 'datatables-bs', 'datatables-scroller']); ?>
35 <?php if ($_SESSION['language_direction'] == "rtl") { ?>
36 <link rel="stylesheet" href="<?php echo $GLOBALS['themes_static_relative']; ?>/misc/rtl_edi_history_v2.css?v=<?php echo $GLOBALS['v_js_includes']; ?>" />
37 <?php } else { ?>
38 <link rel="stylesheet" href="<?php echo $GLOBALS['themes_static_relative']; ?>/misc/edi_history_v2.css?v=<?php echo $GLOBALS['v_js_includes']; ?>" />
39 <?php } ?>
40 </head>
41 <!-- style for OpenEMR color -->
42 <body>
43 <div class="container mt-3">
44 <div class="row">
45 <div class="col-sm-12">
46 <div class="clearfix">
47 <h2><?php echo xlt('EDI History'); ?></h2>
48 </div>
49 </div>
50 </div>
51 <div class="container-fluid mb-3">
52 <ul class="nav nav-tabs">
53 <li class="nav-item">
54 <a class="nav-item nav-link font-weight-bold active" id="nav-newfiles-tab" data-toggle="tab" href="#nav-newfiles" role="tab" aria-controls="nav-newfiles" aria-selected="true">
55 <?php echo xlt("New Files"); ?>
56 </a>
57 </li>
58 <li class="nav-item">
59 <a class="nav-item nav-link font-weight-bold" id="nav-csvtables-tab" data-toggle="tab" href="#nav-csvtables" role="tab" aria-controls="nav-csvtables" aria-selected="false">
60 <?php echo xlt("CSV Tables"); ?>
61 </a>
62 </li>
63 <li class="nav-item">
64 <a class="nav-item nav-link font-weight-bold" id="nav-edifile-tab" data-toggle="tab" href="#nav-edifile" role="tab" aria-controls="nav-edifile" aria-selected="false">
65 <?php echo xlt("EDI File"); ?>
66 </a>
67 </li>
68 <li class="nav-item">
69 <a class="nav-item nav-link font-weight-bold" id="nav-notes-tab" data-toggle="tab" href="#nav-notes" role="tab" aria-controls="nav-notes" aria-selected="false">
70 <?php echo xlt("Notes"); ?>
71 </a>
72 </li>
73 <li class="nav-item">
74 <a class="nav-item nav-link font-weight-bold" id="nav-archive-tab" data-toggle="tab" href="#nav-archive" role="tab" aria-controls="nav-archive" aria-selected="false">
75 <?php echo xlt("Archive"); ?>
76 </a>
77 </li>
78 </ul>
80 <div class="tab-content jumbotron py-4" id="nav-tabContent">
81 <!-- New Files Section -->
82 <div class="tab-pane fade show active" id="nav-newfiles" role="tabpanel" aria-labelledby="nav-newfiles-tab">
83 <div class="container">
84 <div class="row">
85 <div class="col-sm-12 col-md-6">
86 <form id="formupl" name="form_upl" action="edih_main.php" method="POST" enctype="multipart/form-data">
87 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
88 <h4><?php echo xlt("Select one or more files to upload"); ?></h4>
89 <div class="custom-file">
90 <label class="custom-file-label"><?php echo xlt("Choose file"); ?></label>
91 <input type="file" class="custom-file-input" id="uplmulti" name="fileUplMulti[]" multiple />
92 <input type="hidden" name="NewFiles" form="formupl" value="ProcessNew" />
93 <div class="btn-group mt-3">
94 <button type="submit" class="btn btn-primary btn-add" id="uplsubmit" name="upl_submit" form="formupl" value="<?php echo xla("Submit"); ?>">
95 <?php echo xlt("Submit"); ?>
96 </button>
97 <input type="reset" class="btn btn-secondary" id="uplreset" name="upl_reset" form="formupl" value="<?php echo xla("Reset"); ?>" />
98 </div>
99 </div>
100 </form>
101 </div>
102 <div class="col-sm-12 col-md-6">
103 <form id="processnew" name="process_new" action="edih_main.php" method="GET">
104 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
105 <h4><?php echo xlt("Process new files for CSV records"); ?>:</h4>
106 <input type="checkbox" id="processhtml" name="process_html" form="processnew" value="htm" checked /> <?php echo xlt("HTML Output?"); ?>
107 <input type="checkbox" id="processerr" name="process_err" form="processnew" value="err" checked /> <?php echo xlt("Show Errors Only?"); ?> &nbsp;&nbsp;<br />
108 <input type="hidden" name="ProcessFiles" form="processnew" value="ProcessNew" />
109 <label for="process"><?php echo xlt("Process New Files"); ?></label>
110 <input type="submit" class="btn btn-primary btn-sm" id="fuplprocess" name="process" form="processnew" value="<?php echo xla("Process"); ?>" />
111 </form>
112 </div>
113 <div class="col-sm-md-6 d-none" id="fileupl1">
115 </div>
116 <div class="col-sm-md-6 d-none" id="fileupl2">
118 </div>
119 <div class="col-12">
120 <div class="alert alert-primary mt-3 d-none" id="processed">
121 </div>
122 <div id="rsp" title="<?php echo xla("Response"); ?>"></div>
123 <div id="sub" title="<?php echo xla("Submitted"); ?>"></div>
124 <div id="seg" title="<?php echo xla("x12 Segments"); ?>"></div>
125 </div>
126 </div>
127 </div>
128 </div>
129 <!-- CSV Tables Section -->
130 <div class="tab-pane fade" id="nav-csvtables" role="tabpanel" aria-labelledby="nav-csvtables-tab">
131 <div class="container">
132 <div class="row">
133 <div class="col-sm-12 col-md-8">
134 <form id="formcsvtables" name="form_csvtables" action="edih_main.php" method="GET">
135 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
136 <h4><?php echo xlt("View CSV tables"); ?>:</h4>
137 <table>
138 <tr>
139 <td colspan='4'><?php echo xlt("Choose a period or dates (YYYY-MM-DD)"); ?></td>
140 </tr>
141 <tr>
142 <td class='text-center'><?php echo xlt("Choose CSV table"); ?>:</td>
143 <td class='text-center'><?php echo xlt("From Period"); ?></td>
144 <td class='text-center'><?php echo xlt("Start Date"); ?>: &nbsp;&nbsp; <?php echo xlt("End Date"); ?>:</td>
145 <td class='text-center'><?php echo xlt("Submit"); ?></td>
146 </tr>
147 <tr height='1.5em'>
148 <td class='text-center'>
149 <select class="custom-select" id="csvselect" name="csvtables"></select>
150 </td>
151 <td class='text-center'>
152 <select class="custom-select" id="csvperiod" name="csv_period">
153 <option value='2w' selected='selected'>2 <?php echo xlt('weeks'); ?></option>
154 <option value='1m'>1 <?php echo xlt('month'); ?></option>
155 <option value='2m'>2 <?php echo xlt('months'); ?></option>
156 <option value='3m'>3 <?php echo xlt('months'); ?></option>
157 <option value='6m'>6 <?php echo xlt('months'); ?></option>
158 <option value='9m'>9 <?php echo xlt('months'); ?></option>
159 <option value='1y'>1 <?php echo xlt('year'); ?></option>
160 <option value='ALL'><?php echo xlt('All Dates'); ?></option>
161 </select>
162 </td>
163 <!-- datekeyup(e, defcc, withtime) dateblur(e, defcc, withtime) -->
164 <td class='text-left'>
165 <input type='text' size='10' class='datepicker' name="csv_date_start" id="caldte1" value="" title="<?php echo xla('yyyy-mm-dd Start Date'); ?>" />
166 <input type="text" size="10" class="datepicker" name="csv_date_end" id="caldte2" value="" title="<?php echo xla('yyyy-mm-dd End Date'); ?>" />
167 </td>
168 <td class='text-left'>
169 <input type="hidden" name="csvShowTable" form="formcsvtables" value="gettable" />
170 <button type="submit" class="btn btn-primary btn-add" id="csvshow" name="csv_show" form="formcsvtables" value="<?php echo xla("Submit"); ?>">
171 <?php echo xlt("Submit"); ?>
172 </button>
173 </td>
174 </tr>
175 </table>
176 </form>
177 </div>
178 <div class="col-sm-12 col-md-4">
179 <form id="formcsvhist" name="hist_csv" action="edih_main.php" method="get">
180 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
181 <h4><?php echo xlt("Per Encounter"); ?></h4>
182 <table>
183 <tr>
184 <td colspan='2'><?php echo xlt("Enter Encounter Number"); ?></td>
185 </tr>
186 <tr>
187 <td><?php echo xlt("Encounter"); ?></td>
188 <td><?php echo xlt("Submit"); ?></td>
189 </tr>
190 <tr>
191 <td><input id="histenctr" type="text" class="form-control" size=10 name="hist_enctr" value="" /></td>
192 <td>
193 <button type="submit" class="btn btn-primary btn-add" id="histsbmt" name="hist_sbmt" form="formcsvhist" value="<?php echo xla("Submit"); ?>">
194 <?php echo xlt("Submit"); ?>
195 </button>
196 </td>
197 </tr>
198 </table>
199 </form>
200 </div>
201 <div class="col-12">
202 <div class='alert alert-primary mt-3 d-none' id='tblshow'>
203 </div>
204 <div id='tbcsvhist'></div>
205 <div id='tbrpt'></div>
206 <div id='tbrsp'></div>
207 <div id='tbsub'></div>
208 <div id='tbseg'></div>
209 </div>
210 </div>
211 </div>
212 </div>
213 <!-- EDI File Section -->
214 <div class="tab-pane fade" id="nav-edifile" role="tabpanel" aria-labelledby="nav-edifile-tab">
215 <div class="container">
216 <div class="row">
217 <div class="col-12">
218 <form id="x12view" name="x12_view" action="edih_main.php" enctype="multipart/form-data" method="post">
219 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
220 <h4><?php echo xlt("View EDI x12 file"); ?>:</h4>
221 <table>
222 <tr>
223 <td class='text-left'><label for="x12htm"><?php echo xlt("Report?"); ?></label></td>
224 <td class='text-center'><label for="x12file"><?php echo xlt("Choose File"); ?>:</label></td>
225 <td class='text-left'><label for="x12_filebtn"><?php echo xlt("Submit"); ?>:</label></td>
226 <td class='text-center'><label for="x12_filereset"><?php echo xlt("Reset"); ?>:</label></td>
227 </tr>
228 <tr>
229 <td class='text-left'>
230 <input type="hidden" name="viewx12Files" value="view_x12" />
231 <input type="checkbox" id="x12htm" name="x12_html" value="html" />
232 </td>
233 <td class='text-left'>
234 <div class="custom-file">
235 <label class="custom-file-label"><?php echo xlt("Choose file"); ?></label>
236 <input id="x12file" type="file" class="custom-file-input" size=30 name="fileUplx12" />
237 </div>
238 </td>
239 <td class='text-center'>
240 <button type="submit" class="btn btn-primary btn-add" id="x12filebtn" name="x12_filebtn" form="x12view" value="<?php echo xla("Submit"); ?>">
241 <?php echo xlt("Submit"); ?>
242 </button>
243 </td>
244 <td class='text-center'>
245 <button type="button" class="btn btn-secondary btn-cancel" id="x12filerst" name="x12_filereset" form="x12view" value="<?php echo xla("Reset"); ?>">
246 <?php echo xlt("Reset"); ?>
247 </button>
248 </td>
249 </tr>
250 </table>
251 </form>
252 <div id="x12rsp"></div>
253 </div>
254 </div>
255 </div>
256 </div>
257 <!-- Notes Section -->
258 <div class="tab-pane fade" id="nav-notes" role="tabpanel" aria-labelledby="nav-notes-tab">
259 <div class="container">
260 <div class="row">
261 <div class="col-12">
262 <a class="text-decoration-none" href="<?php echo $web_root; ?>/Documentation/Readme_edihistory.html" rel="noopener" target="_blank"><?php echo xlt("View the README file"); ?></a>
263 </div>
264 <div class="col-sm-12 col-md-6">
265 <form id="formlog" name="form_log" action="edih_main.php" enctype="multipart/form-data" method="post">
266 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
267 <h4><?php echo xlt("Inspect the log"); ?></h4>
268 <label for="logfile"><?php echo xlt("View Log"); ?></label>
269 <select class="custom-select" id="logselect" name="log_select"></select>
270 <input type="hidden" name="logshowfile" value="getlog">
271 <div class="btn-group mt-3">
272 <button type="submit" class="btn btn-primary btn-add" id="logshow" form="formlog" value="<?php echo xla("Submit"); ?>">
273 <?php echo xlt("Submit"); ?>
274 </button>
275 <button type="button" class="btn btn-primary" id="logarch" form="formlog" value="<?php echo xla("Archive"); ?>">
276 <?php echo xlt("Archive"); ?>
277 </button>
278 <button type="button" class="btn btn-secondary btn-cancel" id="logclose" form="formlog" value="<?php echo xla("Close"); ?>">
279 <?php echo xlt("Close"); ?>
280 </button>
281 </div>
282 </form>
283 </div>
284 <div class="col-sm-12 col-md-6">
285 <form id="formnotes" name="form_notes" action="edih_main.php" enctype="multipart/form-data" method="post">
286 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
287 <h4><?php echo xlt("Notes"); ?></h4>
288 <label for="notesget"><?php echo xlt("Notes"); ?></label>
289 <div class="btn-group ml-2">
290 <button type="button" class="btn btn-primary" id="notesget" name="notes_get" form="formnotes" value="<?php echo xla("Open"); ?>">
291 <?php echo xlt("Open"); ?>
292 </button>
293 <input id="noteshidden" type="hidden" name="notes_hidden" value="putnotes" />
294 <button type="submit" class="btn btn-primary btn-save" id="notessave" name="notes_save" form="formnotes" value="<?php echo xla("Save"); ?>">
295 <?php echo xlt("Save"); ?>
296 </button>
297 <button type="button" class="btn btn-secondary btn-cancel" id="notesclose" name="notes_close" form="formnotes" value="<?php echo xla("Close"); ?>">
298 <?php echo xlt("Close"); ?>
299 </button>
300 </div>
301 </form>
302 </div>
303 <div class="col-12">
304 <div id='logrsp'></div>
305 <div id='notesrsp'></div>
306 </div>
307 </div>
308 </div>
309 </div>
310 <!-- Archive Section -->
311 <div class="tab-pane fade" id="nav-archive" role="tabpanel" aria-labelledby="nav-archive-tab">
312 <div class="container">
313 <div class="row">
314 <div class="col-12">
315 <span><?php echo xlt("Selected files and data will be removed from folders and tables"); ?></span>
316 </div>
317 <div class="col-sm-12 col-md-6">
318 <form id="formarchive" name="form_archive" action="edih_main.php" enctype="multipart/form-data" method="POST">
319 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
320 <h4><?php echo xlt("Archive old files"); ?></h4>
321 <label for="archive_sel"><?php echo xlt("Older than"); ?>:</label>
322 <select class="custom-select" id="archiveselect" name="archive_sel">
323 <option value="" selected="selected"><?php echo xlt('Choose'); ?></option>
324 <option value="24m">24 <?php echo xlt('months'); ?></option>
325 <option value="18m">18 <?php echo xlt('months'); ?></option>
326 <option value="12m">12 <?php echo xlt('months'); ?></option>
327 <option value="9m">9 <?php echo xlt('months'); ?></option>
328 <option value="6m">6 <?php echo xlt('months'); ?></option>
329 <option value="3m">3 <?php echo xlt('months'); ?></option>
330 </select>
331 <label for="archivereport"><?php echo xlt("Report"); ?>:</label>
332 <input type="button" class="btn btn-sm btn-secondary" id="archiverpt" name="archivereport" form="formarchive" value="<?php echo xla("Report"); ?>" />
333 <input type="hidden" name="ArchiveRequest" form="formarchive" value="requested" />
334 <label for="archivesbmt"><?php echo xlt("Archive"); ?>:</label>
335 <input type="submit" class="btn btn-sm btn-secondary" id="archivesbmt" name="archive_sbmt" form="formarchive" value="<?php echo xla("Archive"); ?>" />
336 </form>
337 </div>
338 <div class="col-sm-12 col-md-6">
339 <form id="formarchrestore" name="form_archrestore" action="edih_main.php" enctype="multipart/form-data" method="POST">
340 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
341 <h4><?php echo xlt("Restore Archive"); ?></h4>
342 <label for="archrestore_sel"><?php echo xlt("Restore"); ?>:</label>
343 <select class="custom-select" id="archrestoresel" name="archrestore_sel"> </select>
344 <input type="hidden" name="ArchiveRestore" form="formarchrestore" value="restore" />
345 <label for="arch_restore"><?php echo xlt("Restore"); ?>:</label>
346 <input type="submit" class="btn btn-sm btn-secondary" id="archrestore" name="arch_restore" form="formarchrestore" value="<?php echo xla("Restore"); ?>" />
347 </form>
348 </div>
349 <div class="col-12">
350 <div id="archiversp"></div>
351 </div>
352 </div>
353 </div>
354 </div>
355 </div>
356 </div>
357 </div>
360 <!-- end DataTables js Begin local js -->
361 <script>
362 $(function () {
363 // set some button disabled
364 $('#processfiles').prop('disabled', true);
365 $('#archivesubmit').prop('disabled', true);
366 // update list of available csv tables
367 $(function () { csvlist() });
368 // update list of available log files
369 $(function () { loglist() });
370 // update list of archive files
371 $(function () { archlist() });
372 // hide these div elements until used
373 $("#fileupl1").toggle(false);
374 $("#fileupl2").toggle(false);
376 $('.datepicker').datetimepicker({
377 <?php $datetimepicker_timepicker = false; ?>
378 <?php $datetimepicker_showseconds = false; ?>
379 <?php $datetimepicker_formatInput = false; ?>
380 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
381 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
384 /* ************
385 * end of document ready() $
386 * ************
388 /* **** from http://scratch99.com/web-development/javascript/convert-bytes-to-mb-kb/ *** */
389 function bytesToSize(bytes) {
390 var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
391 if (bytes == 0) return 'n/a';
392 var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
393 if (i == 0) return bytes + ' ' + sizes[i];
394 return (bytes / Math.pow(1024, i)).toFixed(1) + ' ' + sizes[i];
396 /* *** variables for upload maximums *** */
397 /* *** phpserver: 'maxfsize''maxfuploads''postmaxsize''tmpdir' phpserver['postmaxsize'] *** */
398 var phpserver = [];
399 $(function () {
400 $.ajax({
401 url: 'edih_main.php',
402 data: {
403 srvinfo: 'yes',
404 csrf_token_form: <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>
406 dataType: 'json',
407 success: function(rsp){ phpserver = rsp }
412 * update the list of available csv tables
414 function csvlist() {
415 $.ajax({
416 type: 'GET',
417 url: 'edih_main.php',
418 data: {
419 csvtbllist: 'yes',
420 csrf_token_form: <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>
422 dataType: 'json',
423 success: function(data) {
424 var options = $('#csvselect').attr('options');
425 var optct = $.isPlainObject(data); // data.length
426 if (optct) {
427 var options = [];
428 options.push("<option value='' selected='selected'><?php echo xla("Choose from list"); ?></option>");
429 $.each(data.claims, function(idx, value) {
430 options.push("<option value=" + value.fname + ">" + value.desc + "</option>");
432 $.each(data.files, function(idx, value) {
433 options.push("<option value=" + value.fname + ">" + value.desc + "</option>");
435 $("#csvselect").html(options.join(''));
440 /* *** update the list of log files *** */
441 function loglist() {
442 $.ajax({
443 type: 'GET',
444 url: 'edih_main.php',
445 data: {
446 loglist: 'yes',
447 csrf_token_form: <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>
449 dataType: 'json',
450 success: function(data) {
451 var options = $('#logselect').attr('options');
452 var optct = data.length;
453 if (optct) {
454 var options = [];
455 options.push('<option selected="selected"><?php echo xla("Choose from list"); ?></option>');
456 for (var i=0; i<optct; i++) {
457 options.push('<option value=' + data[i] + '>' + data[i] + '</option>');
459 $("#logselect").html(options.join(''));
464 /* *** update the list of archive files *** id="archrestoresel name="archrestore_sel" */
465 function archlist() {
466 $.ajax({
467 type: 'GET',
468 url: 'edih_main.php',
469 data: {
470 archlist: 'yes',
471 csrf_token_form: <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>
473 dataType: 'json',
474 success: function(data) {
475 //var options = $('#archrestoresel').attr('options');
476 $('#archrestoresel').empty();
477 var optct = data.length;
478 var options = [];
479 if (optct) {
480 options.push("<option selected='selected'><?php echo xla("Choose from list"); ?></option>");
481 for (var i=0; i<optct; i++) {
482 options.push("<option value=" + data[i] + ">" + data[i] + "</option>");
484 } else {
485 options.push("<option selected='selected'><?php echo xla("No Archives"); ?></option>");
487 $('#archrestoresel').html(options.join(""));
492 $('#tbcsvhist').on('click', 'a', function(e) {
493 e.preventDefault();
494 e.stopPropagation();
495 $('<div/>', {'class':'edihDlg', 'id':'link-'+($(this).index()+1)})
496 .load($(this).attr('href')).appendTo('#tbcsvhist');
499 /* #csvTable **** */
500 $('#tblshow').on('click', 'a', function(e) {
501 e.preventDefault();
502 e.stopPropagation();
503 $('<div/>', {'class':'edihDlg', 'id':'link-'+($(this).index()+1)})
504 .load($(this).attr('href')).appendTo('#tblshow');
507 /* **** links in dialog in uploads - processed div **** */
508 $('#processed').on('click', 'a', function(e) {
509 e.preventDefault();
510 e.stopPropagation();
511 $('<div/>', {'class':'edihDlg', 'id':'link-'+($(this).index()+1)})
512 .load($(this).attr('href')).appendTo('#processed');
514 /* ****************************
516 * === upload multiple files
517 * buttons are enabled/disabled
518 * selected and uploaded files are listed
519 * the process files script html output displayed,
521 /* **** if files have been uploaded **** */
522 var upld_ct = 0;
523 /* ***** list files selected in the multifile upload input **** */
524 $('#uplmulti').on('change', function(){
525 // clear uploaded files list, since new selected files list is coming
526 $('#fileupl2').html('');
527 $('#fileupl2').addClass('d-none');
528 $('#fileupl2').removeClass('flist');
529 $('#processed').html('');
530 $('#processed').addClass('d-none');
531 var uplfiles = this.files; //event.target.files;
532 var fct = uplfiles.length;
533 var fsize = 0;
534 var fl1 = $('#fileupl1');
535 fl1.html('');
536 fl1.toggle(true);
537 fl1.addClass('flist1');
538 fl1.removeClass('d-none')
539 var fmaxupl = phpserver['maxfuploads']; // $("#srvvals").data('mf');
540 var pmaxsize = phpserver['postmaxsize']
541 var str = "<p><em><?php echo xla('Selected Files'); ?>:</em></p>";
542 str = str + "<ul id='uplsel' class='fupl'>";
543 for(var i = 0; i < fct; i++) {
544 if (i == fmaxupl) str = str + '</ul><p><?php echo xla('max file count reached'); ?><br /> - <?php echo xla('reload names below'); ?> </p><ul class=fupl>';
545 str = str + "<li>" + uplfiles[i].name + "</li>"; //' ' +
546 fsize += uplfiles[i].size;
548 str = str + '</ul><p><?php echo xla('Total size'); ?>: ' + bytesToSize(fsize) + ' (<?php echo xla('max'); ?> ' + pmaxsize + ')</p>';
549 $('#uplsubmit').prop('disabled', false);
550 if (upld_ct === 0 ) {
551 $('#processupl').prop('disabled', true);
553 fl1.html(str);
555 // uplreset button click the file input is reset and associated values cleared
556 $('#uplreset').on('click', function( event ) {
557 event.preventDefault();
558 event.stopPropagation();
559 $('#fileupl1').html('');
560 $('#fileupl2').html('');
561 $('#fileupl1').hide();
562 $('#fileupl2').hide();
563 $('#processed').html('');
564 $('#processed').addClass('d-none');
565 $('#uplsubmit').prop('disabled', true);
566 if (upld_ct == 0 ) {
567 $('#fuplprocess').prop('disabled', true);
568 } else {
569 $('#fuplprocess').prop('disabled', false);
571 // $('#fupl').reset();
572 document.getElementById('formupl').reset();
573 return false;
576 /* ***** uplsubmit button click --upload files are scanned and copied into folders *** */
577 /* ***** files are listed next to file selected list by css *** */
578 $('#formupl').on('submit', function( event ) {
579 event.stopPropagation();
580 event.preventDefault();
581 var uplForm = document.getElementById("formupl");
582 var upldata = new FormData( document.getElementById('formupl') );
583 var rspElem = $('#fileupl2');
584 rspElem.html('');
585 rspElem.addClass('d-none');
586 $.ajax({
587 url: $('#formupl').attr('action'),
588 type: 'POST',
589 cache: false,
590 data: upldata,
591 dataType: 'html',
592 processData: false,
593 contentType: false,
594 success: function(data) {
595 rspElem.html(data);
596 rspElem.toggle();
597 rspElem.removeClass('d-none');
598 $('#fuplprocess').prop('disabled', false );
599 $('#fuplupload').prop('disabled', true);
600 uplForm.reset();
601 upld_ct++;
603 error: function( xhr, status ) { alert( <?php echo xlj('Sorry, there was a problem!'); ?> ); },
605 return false;
607 /* **** process button, files parsed and csv rows displayed *** */
608 $('#processnew').on('submit', function(e) {
609 e.stopPropagation();
610 e.preventDefault();
611 $.ajax({
612 url: $('#processnew').attr('action'),
613 type: 'GET',
614 data: $('#processnew').serialize(), //prcForm.serialize(),
615 success: [
616 function(data) {
617 $('#fileupl1').html('');
618 $('#fileupl1').addClass('d-none');
619 $('#fileupl2').html('');
620 $('#fileupl2').addClass('d-none');
621 $('#processed').html(data);
622 $('#processed').removeClass('d-none');
625 error: function( xhr, status ) {
626 alert( <?php echo xlj('Sorry, there was a problem!'); ?> ),
627 $('#processed').html(status);
628 $('#processed').removeClass('d-none');
631 upld_ct = 0;
632 /* *** update list of csv tables *** */
633 csvlist();
634 $('#fuplprocess').prop('disabled', true );
635 return false;
638 /* *********************************************
640 * ==== file upload lists match uploaded to selected
641 * when mouse is over element in one list, matching element
642 * in other list is highlighted also
644 function outlineMatch(matchElem, matchText) {
645 if (matchText == 'none') {
646 matchElem.css('font-weight', 'normal');
647 return false;
648 } else {
649 matchElem.each(function( index ) {
650 if ( matchText == $(this).text() ) {
651 $(this).siblings().css('font-weight', 'normal');
652 $(this).css('font-weight', 'bolder');
653 return false;
657 return false;
660 /* *** do not use .hover event */
661 $('#fileupl2').on('mouseenter', 'li', function(event){
662 var fl1 = $('#fileupl1').find('li');
663 var fname = $(this).text();
664 $(this).css('font-weight', 'bolder');
665 $(this).siblings().css('font-weight', 'normal');
666 outlineMatch(fl1, fname);
668 $('#fileupl2').on('mouseleave', 'li', function(){
669 var fl1 = $('#fileupl1').find('li');
670 $(this).css('font-weight', 'normal');
671 outlineMatch(fl1, 'none');
673 $('#fileupl1').on('mouseenter', 'li', function(event){
674 $(this).css('font-weight', 'bolder');
675 if ( $('#fileupl2').length ) {
676 var fl2 = $('#fileupl2').find('li');
677 var fname = $(this).text();
678 outlineMatch(fl2, fname);
681 $('#fileupl1').on('mouseleave', 'li', function(){
682 $(this).css('font-weight', 'normal');
683 if ( $('#fileupl2').length ) {
684 var fl2 = $('#fileupl2').find('li');
685 var fname = $(this).text();
686 outlineMatch(fl2, 'none');
690 /* ***** ==== end file upload lists match uploaded to selected
691 /* ****************************
692 * === end upload multiple files section
695 /* ****************
696 * begin csv tables section
697 * the csv tables are displayed using jquery dataTables plugin
698 * here, the 'success' action is to execute an array of functions
699 * the helper function bindlinks() applies jquery .on method
700 * so most links will open a jquery-ui dialog
702 $('#formcsvtables').on('submit', function(e) {
703 e.preventDefault();
704 e.stopPropagation();
705 // verify a csv file is selected
706 if ($('#csvselect').val() == '') {
707 $("#tblshow").html('<?php echo xla("No table selected! Select a table."); ?>');
708 $('#tblshow').removeClass('d-none');
709 return false;
711 $.ajax({
712 type:'get',
713 url: "edih_main.php",
714 data: $('#formcsvtables').serialize(),
715 dataType: "html",
716 success: [
717 function(data){
718 $('#tblshow').html(data);
719 $('#tblshow').css('maxWidth', 'fit-contents');
720 $('#tblshow').removeClass('d-none');
721 $('#tblshow table#csvTable').DataTable({
722 'processing': true,
723 'scrollY': '300px',
724 'scrollCollapse': true,
725 'scrollX': true,
726 'paging': true,
727 <?php // Bring in the translations ?>
728 <?php require($GLOBALS['srcdir'] . '/js/xl/datatables-net.js.php'); ?>
735 // csv encounter history
736 $('#formcsvhist').on('submit', function(e) {
737 e.preventDefault();
738 $('#tbcsvhist').empty();
739 var chenctr = $('#histenctr').value;
740 $.ajax({
741 type: "GET",
742 url: $('#formcsvhist').attr('action'),
743 data: $('#formcsvhist').serialize(), //{ csvenctr: chenctr },
744 dataType: "html",
745 success: [ function(data){
746 $('<div/>', {'class':'edihDlg', 'id':'link-'+($(this).index()+1)})
747 .appendTo('#tbcsvhist').html($.trim(data));
753 $('#csvClear').on('click', function(e) {
754 e.preventDefault();
755 $("#tblshow").html('');
756 $('#tblshow').addClass('d-none');
758 /* **************
759 * === end of csv tables and claim history
761 /* ****************8
762 * === view x12 file form form"view_x12" file"x12file" submit"fx12" check"ifhtml" newWin"x12nwin"
764 $('#x12view').on('submit', function(e) {
765 e.preventDefault();
766 e.stopPropagation();
768 var rspElem = $('#x12rsp');
769 var frmData = new FormData( document.getElementById('x12view') );
770 $.ajax({
771 url: $('#x12view').attr('action'),
772 type: 'POST',
773 data: frmData,
774 processData: false,
775 contentType: false,
777 success: function(data) {
778 rspElem.html('');
779 rspElem.html(data);
780 $('#x12filesbmt').prop('disabled', true);
782 error: function( xhr, status ) { alert( <?php echo xlj('Sorry, there was a problem!'); ?> ); }
786 $('#x12file').on('change', function(){
787 // clear file display
788 $('#x12rsp').html('');
789 $('#x12filesbmt').prop('disabled', false);
792 $('#x12filerst').on('click', function(e){
793 e.preventDefault();
794 e.stopPropagation();
795 // clear file display
796 $('#x12rsp').html('');
797 $('#x12filesbmt').prop('disabled', true);
798 $('#x12view').trigger('reset');
802 * === functions for logs, notes, and archive "frm_archive" "archiveselect""archivesubmit"
804 $('#logarch').on('click', function(e) {
805 e.preventDefault();
806 e.stopPropagation();
808 $.ajax({
809 type: 'get',
810 url: $('#formlog').attr('action'),
811 data: {
812 archivelog: 'yes',
813 csrf_token_form: <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>
815 dataType: "json",
816 success: function(data) {
817 var str = "<p><?php echo xla('Archive Log Files'); ?></p><ul id='logarchlist'>";
818 var fct = data.length;
819 if (fct == 0) {
820 str = str + "<li><?php echo xla('No logs older than 7 days'); ?></li>";
821 } else {
822 for(var i = 0; i < fct; i++) {
823 str = str + "<li>" + data[i] + "</li>";
826 str = str + "</ul>";
827 $('#notesrsp').hide();
828 $('#logrsp').html('');
829 $('#logrsp').html(str);
830 $('#logrsp').show();
832 error: function( xhr, status ) { alert( <?php echo xlj('Sorry, there was a problem!'); ?> ); }
834 loglist();
838 $('#logclose').on('click', function(e) {
839 e.preventDefault();
840 $('#logrsp').html('');
841 $('#logrsp').hide();
842 $('#notesrsp').show();
845 $('#logselect').on('change', function(e) {
846 $('#logshow').prop('disabled', false );
849 $('#logshow').on('click', function(e) {
850 e.preventDefault();
851 e.stopPropagation();
852 var fn = $('#logselect').val();
853 $.ajax({
854 type: 'get',
855 url: $('#formlog').attr('action'),
856 //data: { archivelog: 'yes', logfile: fn },
857 data: $('#formlog').serialize(),
858 dataType: "html",
859 success: function(data){
860 $('#notesrsp').hide();
861 $('#logrsp').html(''),
862 $('#logrsp').html($.trim(data));
863 $('#logrsp').show();
868 $('#notesget').on('click', function(e) {
869 e.preventDefault();
870 e.stopPropagation();
871 $.ajax({
872 type:'GET',
873 url: $('#formnotes').attr('action'),
874 data: {
875 getnotes: "yes",
876 csrf_token_form: <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>
878 dataType: "text",
879 success: function(data){
880 $('#notesrsp').html('');
881 $('#notesrsp').html("<H4>Notes:</H4>");
882 $('#notesrsp').append("<textarea class='form-control' id='txtnotes', name='txtnotes',form='formnotes',rows='10',cols='600',wrap='hard' autofocus='autofocus'></textarea>");
883 // necessary to trim the data since php from script has leading newlines (UTF-8 issue) '|:|'
884 $('#logrsp').hide();
885 $('#notesrsp \\:textarea').val($.trim(data));
886 $('#notesrsp').show();
891 $('#notessave').on('click', function(e) {
892 e.preventDefault();
893 var notetxt = $('#txtnotes').val();
894 var noteURL = $('#formnotes').attr('action');
895 $.post(noteURL, { putnotes: 'yes', tnotes: notetxt, csrf_token_form: <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?> },
896 function(data){ $('#notesrsp').append(data); });
899 $('#notesclose').on('click', function(e) {
900 e.preventDefault();
901 $('#notesrsp').html('');
902 $('#notesrsp').toggle(false);
906 * ==== Archive form id="formarchive"
909 $('#formarchive').on('submit', function(e) {
910 //e.stopPropagation();
911 e.preventDefault();
912 var archForm = document.getElementById('formarchive');
913 var archdata = new FormData(archForm);
914 var rspElem = $('#archiversp');
915 rspElem.html('');
916 $.ajax({
917 url: $('#formarchive').attr('action'),
918 type: 'POST',
919 cache: false,
920 data: archdata,
921 dataType: 'html',
922 processData: false,
923 contentType: false,
924 success: function(data) {
925 rspElem.html(data);
926 $('#archivesubmit').prop('disabled', true );
927 archForm.reset();
930 error: function( xhr, status ) { alert( <?php echo xlj('Sorry, there was a problem!'); ?> ); },
931 // code to run regardless of success or failure
932 // complete: function( xhr, status ) { alert( "The request is complete!" ); }
934 archlist();
935 csvlist();
936 return false;
939 $('#archiverpt').on('click', function(event) {
940 event.preventDefault();
941 event.stopPropagation();
942 // id="#archiversp"
943 var rspElem = $('#archiversp');
944 rspElem.html('');
945 var sprd = $('#archiveselect').val();
946 var surl = $('#formarchive').attr('action');
948 //console.log(surl);
949 $.ajax({
950 url: 'edih_main.php',
951 type: 'GET',
952 //cache: false,
953 dataType: 'html',
954 data: { archivereport: 'yes', period: sprd, csrf_token_form: <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?> },
956 success: function(data) {
957 //rspElem.html(data);
958 //rspElem.show();
959 $('#archiversp').html(data);
961 error: function( xhr, status ) {
962 alert( <?php echo xlj('Sorry, there was a problem!'); ?> );
963 rspElem.html(status);
964 rspElem.show();
967 return false;
970 $('#archiveselect').on('change', function(e) {
971 $('#archivesubmit').prop('disabled', false );
975 $('#formarchrestore').on('submit', function(e) {
976 //e.stopPropagation();
977 e.preventDefault();
979 var sel = $( "#archrestoresel option:selected" ).text();
980 console.log( sel );
981 if (sel == "No Archives") {
982 alert(<?php echo xlj('No archive files present'); ?>);
983 return false;
985 var archrstForm = document.getElementById('formarchrestore');
986 var archrstdata = new FormData(archrstForm);
987 var rspElem = $('#archiversp');
988 //var archf = $('#archrestoresel').val();
989 //archrstdata = { archrestore: 'yes', archfile: archf };
990 $.ajax({
991 url: $('#formarchrestore').attr('action'),
992 type: 'POST',
993 data: archrstdata,
994 dataType: 'html',
995 processData: false,
996 contentType: false,
997 success: function(data) {
998 rspElem.html('');
999 rspElem.html(data);
1001 error: function( xhr, status ) { alert( <?php echo xlj('Sorry, there was a problem!'); ?> ); },
1003 archlist();
1004 csvlist();
1005 archrstForm.reset();
1006 return false;
1009 /* ************
1010 * end of javascript block
1012 </script>
1014 </body>
1016 </html>