several constant fixes (removed trailing spaces from new constants)
[openemr.git] / interface / billing / edih_view.php
blob4913979614ca8a3abc125a7086ba20fadb7fcae8
1 <?php
2 /**
3 * edih_view.php
4 *
5 * Copyright 2012 Kevin McCormick Longview, Texas
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; version 3 or later. You should have
15 * received a copy of the GNU General Public License along with this program;
16 * if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * <http://opensource.org/licenses/gpl-license.php>
20 * @author Kevin McCormick
21 * @link: http://www.open-emr.org
22 * @package OpenEMR
23 * @subpackage ediHistory
26 $sanitize_all_escapes = true;
27 $fake_register_globals = false;
28 require_once(dirname(__FILE__) . '/../globals.php');
30 if (!acl_check('acct', 'eob')) die(xlt("Access Not Authorized"));
32 //include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php");
35 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
36 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
37 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
39 <head>
40 <title><?php echo xlt("edi history"); ?></title>
41 <meta http-equiv="content-type" content="text/html;charset=utf-8" />
42 <!-- jQuery-ui and datatables -->
43 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-ui-1-10-4/themes/sunny/jquery-ui.min.css" />
44 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/datatables.net-jqui-1-10-11/css/dataTables.jqueryui.min.css" />
45 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/datatables.net-scroller-jqui-1-4-1/css/scroller.jqueryui.min.css" />
47 <!-- edi_history css -->
48 <link rel="stylesheet" href="<?php echo $web_root?>/library/css/edi_history_v2.css" type="text/css" />
49 <link rel="stylesheet" href="<?php echo $web_root?>/library/dynarch_calendar.css" type="text/css" />
50 <!-- OpenEMR Calendar -->
51 <script type="text/javascript" src="<?php echo $web_root?>/library/dynarch_calendar.js"></script>
52 <script type="text/javascript" src="<?php echo $web_root?>/library/dynarch_calendar_setup.js"></script>
53 <script type="text/javascript" src="<?php echo $web_root?>/library/textformat.js"></script>
55 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
56 </head>
57 <!-- style for OpenEMR color -->
58 <body style='background-color:#fefdcf'>
60 <!-- Begin tabs section class="Clear"-->
61 <div id="tabs" style="visibility:hidden">
62 <ul>
63 <li><a href="#newfiles" id="btn-newfiles"><?php echo xlt("New Files"); ?></a></li>
64 <li><a href="#csvdatatables" id="btn-csvdatatables"><?php echo xlt("CSV Tables"); ?></a></li>
65 <li><a href="#x12text" id="btn-x12text"><?php echo xlt("EDI File"); ?></a></li>
66 <li><a href="#edinotes" id="btn-edinotes"><?php echo xlt("Notes"); ?></a></li>
67 <li><a href="#archive" id="btn-archive"><?php echo xlt("Archive"); ?></a></li>
68 </ul>
70 <div id="newfiles">
71 <table>
72 <tr vertical-align="middle">
73 <td align="center">
74 <form id="formupl" name="form_upl" action="edih_main.php" method="POST" enctype="multipart/form-data">
75 <fieldset>
76 <legend><?php echo xlt("Select one or more files to upload"); ?></legend>
77 <input type="file" id="uplmulti" name="fileUplMulti[]" multiple />
78 <input type="hidden" name="NewFiles" form="formupl" value="ProcessNew" />
79 <input type="submit" id="uplsubmit" name="upl_submit" form="formupl" value=<?php echo xla("Submit"); ?> />
80 <input type="reset" id="uplreset" name="upl_reset" form="formupl" value=<?php echo xla("Reset"); ?> />
81 </fieldset>
82 </form>
83 </td>
84 <td align="center">
85 <form id="processnew" name="process_new" action="edih_main.php" method="GET">
86 <fieldset>
87 <legend><?php echo xlt("Process new files for CSV records"); ?>:</legend>
88 <input type="checkbox" id="processhtml" name="process_html" form="processnew" value="htm" checked /> <?php echo xlt("HTML Output?"); ?>
89 <input type="checkbox" id="processerr" name="process_err" form="processnew" value="err" checked /> <?php echo xlt("Show Errors Only?"); ?> &nbsp;&nbsp;<br>
90 <input type="hidden" name="ProcessFiles" form="processnew" value="ProcessNew" />
91 <label for="process"><?php echo xlt("Process New Files"); ?></label>
92 <input type="submit" id="fuplprocess" name="process" form="processnew" value=<?php echo xla("Process"); ?> />
93 </fieldset>
94 </form>
95 </td>
96 </tr>
97 </table>
99 <div id="fileupl1"></div>
100 <div id="fileupl2"></div>
101 <div id="processed"></div>
102 <div id="rsp" title="<?php echo xla("Response"); ?>"></div>
103 <div id="sub" title="<?php echo xla("Submitted"); ?>"></div>
104 <div id="seg" title="<?php echo xla("x12 Segments"); ?>"></div>
105 </div>
107 <div id="csvdatatables">
108 <table>
109 <tr>
110 <td colspan=4>
112 <form id="formcsvtables" name="form_csvtables" action="edih_main.php" method="GET">
113 <fieldset>
114 <legend><?php echo xlt("View CSV tables"); ?>:</legend>
115 <table>
116 <tr>
117 <td colspan=4><?php echo xlt("Choose a period or dates (YYYY-MM-DD)"); ?></td>
118 </tr>
119 <tr>
120 <td align='center'><?php echo xlt("Choose CSV table"); ?>:</td>
121 <td align='center'><?php echo xlt("From Period"); ?></td>
122 <td align='center'><?php echo xlt("Start Date"); ?>: &nbsp;&nbsp <?php echo xlt("End Date"); ?>:</td>
123 <td align='center'><?php echo xlt("Submit"); ?></td>
124 </tr>
125 <tr height='1.5em'>
126 <td align='center'>
127 <select id="csvselect" name="csvtables"></select>
128 </td>
129 <td align='center'>
130 <select id="csvperiod" name="csv_period">
131 <option value='2w' selected='selected'>2 <?php echo xlt('weeks'); ?></option>
132 <option value='1m'>1 <?php echo xlt('month'); ?></option>
133 <option value='2m'>2 <?php echo xlt('months'); ?></option>
134 <option value='3m'>3 <?php echo xlt('months'); ?></option>
135 <option value='6m'>6 <?php echo xlt('months'); ?></option>
136 <option value='9m'>9 <?php echo xlt('months'); ?></option>
137 <option value='1y'>1 <?php echo xlt('year'); ?></option>
138 <option value='ALL'><?php echo xlt('All Dates'); ?></option>
139 </select>
140 </td>
141 <!-- datekeyup(e, defcc, withtime) dateblur(e, defcc, withtime) -->
142 <td align='left'>
143 <input type='text' size='10' name="csv_date_start" id="caldte1" value="" title="<?php echo xla('yyyy-mm-dd Start Date'); ?>" />
144 <img src="<?php echo $web_root?>/interface/pic/show_calendar.gif" align='absbottom' width='24' height='22'
145 id="csvdate1_cal" border="0" alt="[?]" style="cursor:pointer;cursor:hand" title="<?php echo xla('Start date'); ?>">
147 <input type="text" size="10" name="csv_date_end" id="caldte2" value="" title="<?php echo xla('yyyy-mm-dd End Date'); ?>" />
148 <img src="../pic/show_calendar.gif" align="absbottom" width="24" height="22"
149 id="csvdate2_cal" border="0" alt="[?]" style="cursor:pointer;cursor:hand" title="<?php echo xla('End date'); ?>">
150 </td>
151 <!-- OEMR calendar srcipt -->
152 <script type="text/javascript">
153 Calendar.setup({inputField:"caldte1", ifFormat:"%Y-%m-%d", button:"csvdate1_cal"});
154 Calendar.setup({inputField:"caldte2", ifFormat:"%Y-%m-%d", button:"csvdate2_cal"});
155 </script>
157 <td align='center'>
158 <input type="hidden" name="csvShowTable" form="formcsvtables" value="gettable">
159 <input id="csvshow" type="submit" name="csv_show" form="formcsvtables" value="<?php echo xla("Submit"); ?>" />
160 </td>
162 </tr>
163 </table>
164 </fieldset>
165 </form>
167 </td>
168 <td colspan=2>
169 <form id="formcsvhist" name="hist_csv" action="edih_main.php" method="get">
170 <fieldset>
171 <legend><?php echo xlt("Per Encounter"); ?></legend>
172 <table cols='2'>
173 <tr><td colspan='2'><?php echo xlt("Enter Encounter Number"); ?></td></tr>
174 <tr>
175 <td><?php echo xlt("Encounter"); ?></td>
176 <td><?php echo xlt("Submit"); ?></td>
177 </tr>
178 <tr>
179 <td><input id="histenctr" type="text" size=10 name="hist_enctr" value="" /></td>
180 <td><input id="histsbmt" type="submit" name="hist_sbmt" form="formcsvhist" value="<?php echo xla("Submit"); ?>" /></td>
181 </tr>
182 </table>
183 </fieldset>
184 </form>
185 </td>
186 </tr>
187 </table>
189 <div id='tblshow'></div>
190 <div id='tbcsvhist'></div>
191 <div id='tbrpt'></div>
192 <div id='tbrsp'></div>
193 <div id='tbsub'></div>
194 <div id='tbseg'></div>
196 </div>
197 <!-- erafiles to be replaced by functionality in x12text
198 <div id='erafiles'>
200 </div>
203 <div id="x12text" >
204 <form id="x12view" name="x12_view" action="edih_main.php" enctype="multipart/form-data" method="post">
205 <fieldset>
206 <legend><?php echo xlt("View EDI x12 file"); ?>:</legend>
207 <table>
208 <tr>
209 <td align='left'><label for="x12htm"><?php echo xlt("Report?"); ?></label></td>
210 <td align='center'><label for="x12file"><?php echo xlt("Choose File"); ?>:</label></td>
211 <td align='left'><label for="x12_filebtn"><?php echo xlt("Submit"); ?>:</label></td>
212 <td align='center'><label for="x12_filereset"><?php echo xlt("Reset"); ?>:</label></td>
213 </tr>
214 <tr>
215 <td align='left'>
216 <input type="hidden" name="viewx12Files" value="view_x12">
217 <input type="checkbox" id="x12htm" name="x12_html" value="html" />
218 </td>
219 <td align='left'><input id="x12file" type="file" size=30 name="fileUplx12" /></td>
220 <td align='center'>
221 <input type="submit" id="x12filebtn" name="x12_filebtn" form="x12view" value="<?php echo xla("Submit"); ?>" />
222 </td>
223 <td align='center'>
224 <input type="button" id="x12filerst" name="x12_filereset" form="x12view" value="<?php echo xla("Reset"); ?>" />
225 </td>
226 </tr>
227 </table>
228 </fieldset>
229 </form>
231 <div id="x12rsp"></div>
233 </div>
235 <div id="edinotes">
236 <table>
237 <tr>
238 <td colspan=2><a href="<?php echo $web_root?>/Documentation/Readme_edihistory.html" target="_blank"><?php echo xlt("View the README file"); ?></a></td>
239 </tr>
240 <tr>
241 <td>
242 <form id ="formlog" name="form_log" action="edih_main.php" enctype="multipart/form-data" method="post">
243 <fieldset><legend><?php echo xlt("Inspect the log"); ?></legend>
244 <label for="logfile"><?php echo xlt("View Log"); ?></label>
245 <select id="logselect" name="log_select"> </select>
246 <input type="hidden" name="logshowfile" value="getlog">
247 <input id="logshow" type="submit" form="formlog" value="<?php echo xla("Submit"); ?>" />
248 <input id="logclose" type="button" form="formlog" value="<?php echo xla("Close"); ?>" />
249 <input id="logarch" type="button" form="formlog" value="<?php echo xla("Archive"); ?>" />
250 </fieldset>
251 </form>
252 </td>
253 <td><form id ="formnotes" name="form_notes" action="edih_main.php" enctype="multipart/form-data" method="post">
254 <fieldset><legend><?php echo xlt("Notes"); ?></legend>
255 <label for="notesget"><?php echo xlt("Notes"); ?></label>
256 <input id="notesget" type="button" name="notes_get" form="formnotes" value="<?php echo xla("Open"); ?>" />
257 <input id="noteshidden" type="hidden" name="notes_hidden" value="putnotes" />
258 <input id="notessave" type="submit" name="notes_save" form="formnotes" value="<?php echo xla("Save"); ?>" />
259 <input id="notesclose" type="button" name="notes_close" form="formnotes" value="<?php echo xla("Close"); ?>" />
260 </fieldset>
261 </form>
262 </td>
263 </tr>
264 </table>
266 <div id='logrsp'></div>
267 <div id='notesrsp'></div>
269 </div>
271 <div id="archive">
272 <table>
273 <tr>
274 <td colspan=3><?php echo xlt("Selected files and data will be removed from folders and tables"); ?></td>
275 </tr>
276 <tr>
277 <td colspan=2>
278 <form id="formarchive" name="form_archive" action="edih_main.php" enctype="multipart/form-data" method="POST">
279 <fieldset><legend><?php echo xlt("Archive old files"); ?></legend>
280 <label for="archive_sel"><?php echo xlt("Older than"); ?>:</label>
281 <select id="archiveselect" name="archive_sel">
282 <option value="" selected="selected"><?php echo xlt('Choose'); ?></option>
283 <option value="24m">24 <?php echo xlt('months'); ?></option>
284 <option value="18m">18 <?php echo xlt('months'); ?></option>
285 <option value="12m">12 <?php echo xlt('months'); ?></option>
286 <option value="9m">9 <?php echo xlt('months'); ?></option>
287 <option value="6m">6 <?php echo xlt('months'); ?></option>
288 <option value="3m">3 <?php echo xlt('months'); ?></option>
289 </select>
290 <label for="archivereport"><?php echo xlt("Report"); ?>:</label>
291 <input type="button" id="archiverpt" name="archivereport" form="formarchive" value="<?php echo xla("Report"); ?>" />
292 <input type="hidden" name="ArchiveRequest" form="formarchive" value="requested" />
293 <label for="archivesbmt"><?php echo xlt("Archive"); ?>:</label>
294 <input type="submit" id="archivesbmt" name="archive_sbmt" form="formarchive" value="<?php echo xla("Archive"); ?>" />
295 </fieldset>
296 </form>
297 </td>
298 <td><form id="formarchrestore" name="form_archrestore" action="edih_main.php" enctype="multipart/form-data" method="POST">
299 <fieldset><legend><?php echo xlt("Restore Archive"); ?></legend>
300 <label for="archrestore_sel"><?php echo xlt("Restore"); ?>:</label>
301 <select id="archrestoresel" name="archrestore_sel"> </select>
302 <input type="hidden" name="ArchiveRestore" form="formarchrestore" value="restore" />
303 <label for="arch_restore"><?php echo xlt("Restore"); ?>:</label>
304 <input type="submit" id="archrestore" name="arch_restore" form="formarchrestore" value=<?php echo xla("Restore"); ?> />
305 </fieldset>
306 </form>
307 </td>
308 </tr>
309 </table>
311 <div id="archiversp"></div>
313 </div>
314 </div>
315 <!-- End tabs section -->
316 <!-- -->
317 <script src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-10-2/index.js" type="text/javascript"></script>
318 <script src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-ui-1-10-4/ui/minified/jquery-ui.custom.min.js" type="text/javascript"></script>
319 <script src="<?php echo $GLOBALS['assets_static_relative']; ?>/datatables.net-1-10-11/js/jquery.dataTables.min.js"></script>
320 <script src="<?php echo $GLOBALS['assets_static_relative']; ?>/datatables.net-jqui-1-10-11/js/dataTables.jqueryui.min.js"></script>
321 <script src="<?php echo $GLOBALS['assets_static_relative']; ?>/datatables.net-scroller-1-4-1/js/dataTables.scroller.min.js"></script>
322 <!-- end DataTables js Begin local js -->
323 <script type="text/javascript">
324 jQuery(document).ready(function() {
325 // activate tab interface
326 jQuery("#tabs").tabs();
327 jQuery("#tabs").tabs().css('visibility','visible');
328 // set some button disabled
329 jQuery('#processfiles').prop('disabled', true);
330 jQuery('#archivesubmit').prop('disabled', true);
331 // update list of available csv tables
332 jQuery(function() { csvlist() });
333 // update list of available log files
334 jQuery(function() { loglist() });
335 // update list of archive files
336 jQuery(function() { archlist() });
337 // hide these div elements until used
338 jQuery("#fileupl1").toggle(false);
339 jQuery("#fileupl2").toggle(false);
341 /* ************
342 * end of document ready() jquery
343 * ************
345 /* **** from http://scratch99.com/web-development/javascript/convert-bytes-to-mb-kb/ *** */
346 function bytesToSize(bytes) {
347 var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
348 if (bytes == 0) return 'n/a';
349 var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
350 if (i == 0) return bytes + ' ' + sizes[i];
351 return (bytes / Math.pow(1024, i)).toFixed(1) + ' ' + sizes[i];
353 /* *** variables for upload maximums *** */
354 /* *** phpserver: 'maxfsize''maxfuploads''postmaxsize''tmpdir' phpserver['postmaxsize'] *** */
355 var phpserver = [];
356 jQuery(function() {
357 jQuery.ajax({
358 url: 'edih_main.php',
359 data: { srvinfo: 'yes' },
360 dataType: 'json',
361 success: function(rsp){ phpserver = rsp }
363 });
364 /* *** update the list of available csv tables *** */
365 function csvlist() {
366 jQuery.ajax({
367 type: 'GET',
368 url: 'edih_main.php',
369 data: { csvtbllist: 'yes' },
370 dataType: 'json',
371 success: function(data) {
372 var options = jQuery('#csvselect').attr('options');
373 var optct = jQuery.isPlainObject(data); // data.length
374 if (optct) {
375 var options = [];
376 options.push("<option value='' selected='selected'><?php echo xla("Choose from list"); ?></option>");
377 jQuery.each(data.claims, function(idx, value) {
378 options.push("<option value=" + value.fname + ">" + value.desc + "</option>");
380 jQuery.each(data.files, function(idx, value) {
381 options.push("<option value=" + value.fname + ">" + value.desc + "</option>");
383 jQuery("#csvselect").html(options.join(''));
388 /* *** update the list of log files *** */
389 function loglist() {
390 jQuery.ajax({
391 type: 'GET',
392 url: 'edih_main.php',
393 data: { loglist: 'yes' },
394 dataType: 'json',
395 success: function(data) {
396 var options = jQuery('#logselect').attr('options');
397 var optct = data.length;
398 if (optct) {
399 var options = [];
400 options.push('<option selected="selected"><?php echo xla("Choose from list"); ?></option>');
401 for (var i=0; i<optct; i++) {
402 options.push('<option value=' + data[i] + '>' + data[i] + '</option>');
404 jQuery("#logselect").html(options.join(''));
409 /* *** update the list of archive files *** id="archrestoresel name="archrestore_sel" */
410 function archlist() {
411 jQuery.ajax({
412 type: 'GET',
413 url: 'edih_main.php',
414 data: { archlist: 'yes' },
415 dataType: 'json',
416 success: function(data) {
417 //var options = jQuery('#archrestoresel').attr('options');
418 jQuery('#archrestoresel').empty();
419 var optct = data.length;
420 var options = [];
421 if (optct) {
422 options.push("<option selected='selected'><?php echo xla("Choose from list"); ?></option>");
423 for (var i=0; i<optct; i++) {
424 options.push("<option value=" + data[i] + ">" + data[i] + "</option>");
426 } else {
427 options.push("<option selected='selected'><?php echo xla("No Archives"); ?></option>");
429 jQuery('#archrestoresel').html(options.join(""));
435 jQuery-UI dialog
436 control visibility by designating to which div the dialog is appended
438 function dialogOptions(appendElem) {
439 var tblDialogOpts = {
440 appendTo: appendElem,
441 draggable: true,
442 resizable: true,
443 height: 328,
444 width: 512,
445 maxWidth: 768,
446 title: 'Transaction Detail',
447 close: function(event, ui)
449 jQuery(this).dialog("close");
450 jQuery(this).remove();
453 return tblDialogOpts;
457 jQuery('#tbcsvhist').on('click', 'a', function(e) {
458 e.preventDefault();
459 e.stopPropagation();
460 var options = dialogOptions('#tbcsvhist');
461 jQuery('<div/>', {'class':'edihDlg', 'id':'link-'+(jQuery(this).index()+1)})
462 .load(jQuery(this).attr('href')).appendTo('#tbcsvhist').dialog(options);
464 /* #csvTable **** */
465 jQuery('#tblshow').on('click', 'a', function(e) {
466 e.preventDefault();
467 e.stopPropagation();
468 var ttl = jQuery(this).attr('title');
469 var options = dialogOptions('#tblshow');
470 jQuery('<div/>', {'class':'edihDlg', 'id':'link-'+(jQuery(this).index()+1)})
471 .load(jQuery(this).attr('href')).appendTo('#tblshow').dialog(options);
474 jQuery('#tbrpt').on('click', 'a', function(e) {
475 e.preventDefault();
476 e.stopPropagation();
477 var options = dialogOptions('#tblshow');
478 jQuery('<div/>', {'class':'edihDlg', 'id':'link-'+(jQuery(this).index()+1)})
479 .load(jQuery(this).attr('href')).appendTo('#tblshow').dialog(options);
482 /* **** links in dialog in uploads - processed div **** */
483 jQuery('#processed').on('click', 'a', function(e) {
484 e.preventDefault();
485 e.stopPropagation();
486 var options = dialogOptions('#processed');
487 jQuery('<div/>', {'class':'edihDlg', 'id':'link-'+(jQuery(this).index()+1)})
488 .load(jQuery(this).attr('href')).appendTo('#processed').dialog(options);
492 // **** script ****
493 /* ****
494 * jQuery-UI accordian -- for 27x file html (not used -- have not figured out how to invoke)
496 function apply_accordion(selector) {
497 var sel = selector + ' > #accordion';
498 jQuery( sel )
499 .accordion({
500 header: "h3",
501 collapsible: true,
502 heightStyle: "content"
505 /* ****************************
507 * === upload multiple files
508 * buttons are enabled/disabled
509 * selected and uploaded files are listed
510 * the process files script html output displayed,
512 /* **** if files have been uploaded **** */
513 var upld_ct = 0;
514 /* ***** list files selected in the multifile upload input **** */
515 jQuery('#uplmulti').change( function(){
516 // clear uploaded files list, since new selected files list is coming
517 jQuery('#fileupl2').html('');
518 jQuery('#fileupl2').removeClass('flist');
519 jQuery('#processed').html('');
520 var uplfiles = this.files; //event.target.files;
521 var fct = uplfiles.length;
522 var fsize = 0;
523 var fl1 = jQuery('#fileupl1');
524 fl1.html('');
525 fl1.toggle(true);
526 fl1.addClass('flist1');
527 var fmaxupl = phpserver['maxfuploads']; // jQuery("#srvvals").data('mf');
528 var pmaxsize = phpserver['postmaxsize']
529 var str = "<p><em><?php echo xla('Selected Files'); ?>:</em></p>";
530 str = str + "<ul id='uplsel' class='fupl'>";
531 for(var i = 0; i < fct; i++) {
532 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>';
533 str = str + "<li>" + uplfiles[i].name + "</li>"; //' ' +
534 fsize += uplfiles[i].size;
536 str = str + '</ul><p><?php echo xla('Total size'); ?>: ' + bytesToSize(fsize) + ' (<?php echo xla('max'); ?> ' + pmaxsize + ')</p>';
537 jQuery('#uplsubmit').prop('disabled', false);
538 if (upld_ct === 0 ) {
539 jQuery('#processupl').prop('disabled', true);
541 fl1.html(str);
543 // uplreset button click the file input is reset and associated values cleared
544 jQuery('#uplreset').on('click', function( event ) {
545 event.preventDefault();
546 event.stopPropagation();
547 jQuery('#fileupl1').html('');
548 jQuery('#fileupl2').html('');
549 jQuery('#fileupl1').hide();
550 jQuery('#fileupl2').hide();
551 jQuery('#processed').html('');
552 jQuery('#uplsubmit').prop('disabled', true);
553 if (upld_ct == 0 ) {
554 jQuery('#fuplprocess').prop('disabled', true);
555 } else {
556 jQuery('#fuplprocess').prop('disabled', false);
558 // jQuery('#fupl').reset();
559 document.getElementById('formupl').reset();
560 return false;
563 /* ***** uplsubmit button click --upload files are scanned and copied into folders *** */
564 /* ***** files are listed next to file selected list by css *** */
565 jQuery('#formupl').on('submit', function( event ) {
566 event.stopPropagation();
567 event.preventDefault();
568 var uplForm = document.getElementById("formupl");
569 var upldata = new FormData( document.getElementById('formupl') );
570 var rspElem = jQuery('#fileupl2');
571 rspElem.html('');
572 jQuery.ajax({
573 url: jQuery('#formupl').attr('action'),
574 type: 'POST',
575 cache: false,
576 data: upldata,
577 dataType: 'html',
578 processData: false,
579 contentType: false,
580 success: function(data) {
581 rspElem.html(data);
582 rspElem.show();
583 jQuery('#fuplprocess').prop('disabled', false );
584 jQuery('#fuplupload').prop('disabled', true);
585 uplForm.reset();
586 upld_ct++;
588 error: function( xhr, status ) { alert( "<?php echo xls('Sorry, there was a problem!'); ?>" ); },
590 return false;
592 /* **** process button, files parsed and csv rows displayed *** */
593 jQuery('#processnew').on('submit', function(e) {
594 e.stopPropagation();
595 e.preventDefault();
596 jQuery.ajax({
597 url: jQuery('#processnew').attr('action'),
598 type: 'GET',
599 data: jQuery('#processnew').serialize(), //prcForm.serialize(),
600 success: [
601 function(data) {
602 jQuery('#fileupl1').html('');
603 jQuery('#fileupl1').hide();
604 jQuery('#fileupl2').html('');
605 jQuery('#fileupl2').hide();
607 jQuery('#processed').html(data);
608 jQuery('#processed').show();
611 error: function( xhr, status ) {
612 alert( "<?php echo xls('Sorry, there was a problem!'); ?>" ),
613 jQuery('#processed').html(status)
616 upld_ct = 0;
617 /* *** update list of csv tables *** */
618 csvlist();
619 jQuery('#fuplprocess').prop('disabled', true );
620 return false;
623 /* *********************************************
625 * ==== file upload lists match uploaded to selected
626 * when mouse is over element in one list, matching element
627 * in other list is highlighted also
629 function outlineMatch(matchElem, matchText) {
630 if (matchText == 'none') {
631 matchElem.css('font-weight', 'normal');
632 return false;
633 } else {
634 matchElem.each(function( index ) {
635 if ( matchText == jQuery(this).text() ) {
636 jQuery(this).siblings().css('font-weight', 'normal');
637 jQuery(this).css('font-weight', 'bolder');
638 return false;
642 return false;
645 /* *** do not use .hover event */
646 jQuery('#fileupl2').on('mouseenter', 'li', function(event){
647 var fl1 = jQuery('#fileupl1').find('li');
648 var fname = jQuery(this).text();
649 jQuery(this).css('font-weight', 'bolder');
650 jQuery(this).siblings().css('font-weight', 'normal');
651 outlineMatch(fl1, fname);
653 jQuery('#fileupl2').on('mouseleave', 'li', function(){
654 var fl1 = jQuery('#fileupl1').find('li');
655 jQuery(this).css('font-weight', 'normal');
656 outlineMatch(fl1, 'none');
658 jQuery('#fileupl1').on('mouseenter', 'li', function(event){
659 jQuery(this).css('font-weight', 'bolder');
660 if ( jQuery('#fileupl2').length ) {
661 var fl2 = jQuery('#fileupl2').find('li');
662 var fname = jQuery(this).text();
663 outlineMatch(fl2, fname);
666 jQuery('#fileupl1').on('mouseleave', 'li', function(){
667 jQuery(this).css('font-weight', 'normal');
668 if ( jQuery('#fileupl2').length ) {
669 var fl2 = jQuery('#fileupl2').find('li');
670 var fname = jQuery(this).text();
671 outlineMatch(fl2, 'none');
675 /* ***** ==== end file upload lists match uploaded to selected
676 /* ****************************
677 * === end upload multiple files section
680 /* ****************
681 * begin csv tables section
682 * the csv tables are displayed using jquery dataTables plugin
683 * here, the 'success' action is to execute an array of functions
684 * the helper function bindlinks() applies jquery .on method
685 * so most links will open a jquery-ui dialog
687 jQuery('#formcsvtables').on('submit', function(e) {
688 e.preventDefault();
689 e.stopPropagation();
690 // verify a csv file is selected
691 if (jQuery('#csvselect').val() == '') {
692 jQuery("#tblshow").html('<?php echo xla("No table selected! Select a table."); ?>');
693 return false;
695 jQuery.ajax({
696 type:'get',
697 url: "edih_main.php",
698 data: jQuery('#formcsvtables').serialize(),
699 dataType: "html",
700 success: [
701 function(data){
702 jQuery('#tblshow').html(data);
703 jQuery('#tblshow').css('maxWidth', 'fit-contents');
704 jQuery('#tblshow table#csvTable').DataTable({
705 'processing': true,
706 'scrollY': '300px',
707 'scrollCollapse': true,
708 'scrollX': true,
709 'paging': true
714 });
716 // csv encounter history
717 jQuery('#formcsvhist').on('submit', function(e) {
718 e.preventDefault();
719 jQuery('#tbcsvhist').empty();
720 var chenctr = jQuery('#histenctr').value;
721 var histopts = { modal: false,
722 appendTo: '#tbcsvhist',
723 height: 'auto',
724 width: 568,
725 maxWidth: 616,
726 title: "<?php echo xla("Encounter EDI Record"); ?>",
727 close: function(event, ui) {
728 jQuery(this).empty();
729 jQuery(this).dialog('close');
732 jQuery.ajax({
733 type: "GET",
734 url: jQuery('#formcsvhist').attr('action'),
735 data: jQuery('#formcsvhist').serialize(), //{ csvenctr: chenctr },
736 dataType: "html",
737 success: [ function(data){
738 jQuery('<div/>', {'class':'edihDlg', 'id':'link-'+(jQuery(this).index()+1)})
739 .appendTo('#tbcsvhist').html(jQuery.trim(data)).dialog(histopts).dialog('open');
745 jQuery('#csvClear').on('click', function(e) {
746 e.preventDefault();
747 jQuery("#tblshow").html('');
749 /* **************
750 * === end of csv tables and claim history
752 /* ****************8
753 * === view x12 file form form"view_x12" file"x12file" submit"fx12" check"ifhtml" newWin"x12nwin"
755 jQuery('#x12view').on('submit', function(e) {
756 e.preventDefault();
757 e.stopPropagation();
759 var rspElem = jQuery('#x12rsp');
760 var frmData = new FormData( document.getElementById('x12view') );
761 jQuery.ajax({
762 url: jQuery('#x12view').attr('action'),
763 type: 'POST',
764 data: frmData,
765 processData: false,
766 contentType: false,
768 success: function(data) {
769 rspElem.html('');
770 rspElem.html(data);
771 jQuery('#x12filesbmt').prop('disabled', true);
773 error: function( xhr, status ) { alert( "<?php echo xls('Sorry, there was a problem!'); ?>" ); }
775 // jQuery accordion requires html to be present at document ready
776 // accordion does not work for added content, so no effect here
777 jQuery('#x12rsp > #accordion')
778 .accordion({
779 header: "h3",
780 collapsible: true,
781 heightStyle: "content",
782 active: false
784 return false;
787 jQuery('#x12file').change( function(){
788 // clear file display
789 jQuery('#x12rsp').html('');
790 jQuery('#x12filesbmt').prop('disabled', false);
793 jQuery('#x12filerst').on('click', function(e){
794 e.preventDefault();
795 e.stopPropagation();
796 // clear file display
797 jQuery('#x12rsp').html('');
798 jQuery('#x12filesbmt').prop('disabled', true);
799 jQuery('#x12view').trigger('reset');
803 * === functions for logs, notes, and archive "frm_archive" "archiveselect""archivesubmit"
805 jQuery('#logarch').on('click', function(e) {
806 e.preventDefault();
807 e.stopPropagation();
809 jQuery.ajax({
810 type: 'get',
811 url: jQuery('#formlog').attr('action'),
812 data: { archivelog: 'yes' },
813 dataType: "json",
814 success: function(data) {
815 var str = "<p><?php echo xla('Archive Log Files'); ?></p><ul id='logarchlist'>";
816 var fct = data.length;
817 if (fct == 0) {
818 str = str + "<li><?php echo xla('No logs older than 7 days'); ?></li>";
819 } else {
820 for(var i = 0; i < fct; i++) {
821 str = str + "<li>" + data[i] + "</li>";
824 str = str + "</ul>";
825 jQuery('#notesrsp').hide();
826 jQuery('#logrsp').html('');
827 jQuery('#logrsp').html(str);
828 jQuery('#logrsp').show();
830 error: function( xhr, status ) { alert( "<?php echo xls('Sorry, there was a problem!'); ?>" ); }
832 loglist();
836 jQuery('#logclose').on('click', function(e) {
837 e.preventDefault();
838 jQuery('#logrsp').html('');
839 jQuery('#logrsp').hide();
840 jQuery('#notesrsp').show();
843 jQuery('#logselect').on('change', function(e) {
844 jQuery('#logshow').prop('disabled', false );
847 jQuery('#logshow').on('click', function(e) {
848 e.preventDefault();
849 e.stopPropagation();
850 var fn = jQuery('#logselect').val();
851 jQuery.ajax({
852 type: 'get',
853 url: jQuery('#formlog').attr('action'),
854 //data: { archivelog: 'yes', logfile: fn },
855 data: jQuery('#formlog').serialize(),
856 dataType: "html",
857 success: function(data){
858 jQuery('#notesrsp').hide();
859 jQuery('#logrsp').html(''),
860 jQuery('#logrsp').html(jQuery.trim(data));
861 jQuery('#logrsp').show();
864 });
866 jQuery('#notesget').on('click', function(e) {
867 e.preventDefault();
868 e.stopPropagation();
869 jQuery.ajax({
870 type:'GET',
871 url: jQuery('#formnotes').attr('action'),
872 data: { getnotes: "yes"},
873 dataType: "text",
874 success: function(data){
875 jQuery('#notesrsp').html('');
876 jQuery('#notesrsp').html("<H4>Notes:</H4>");
877 jQuery('#notesrsp').append("<textarea id='txtnotes', name='txtnotes',form='formnotes',rows='10',cols='600',wrap='hard' autofocus='autofocus'></textarea>");
878 // necessary to trim the data since php from script has leading newlines (UTF-8 issue) '|:|'
879 jQuery('#logrsp').hide();
880 jQuery('#notesrsp \\:textarea').val(jQuery.trim(data));
881 jQuery('#notesrsp').show();
884 });
886 jQuery('#notessave').on('click', function(e) {
887 e.preventDefault();
888 var notetxt = jQuery('#notesrsp :textarea').val();
889 var noteURL = jQuery('#formnotes').attr('action');
890 jQuery.post(noteURL, { putnotes: 'yes', tnotes: notetxt },
891 function(data){ jQuery('#notesrsp').append(data); });
894 jQuery('#notesclose').on('click', function(e) {
895 e.preventDefault();
896 jQuery('#notesrsp').html('');
897 jQuery('#notesrsp').toggle(false);
901 * ==== Archive form id="formarchive"
904 jQuery('#formarchive').on('submit', function(e) {
905 //e.stopPropagation();
906 e.preventDefault();
907 var archForm = document.getElementById('formarchive');
908 var archdata = new FormData(archForm);
909 var rspElem = jQuery('#archiversp');
910 rspElem.html('');
911 jQuery.ajax({
912 url: jQuery('#formarchive').attr('action'),
913 type: 'POST',
914 cache: false,
915 data: archdata,
916 dataType: 'html',
917 processData: false,
918 contentType: false,
919 success: function(data) {
920 rspElem.html(data);
921 jQuery('#archivesubmit').prop('disabled', true );
922 archForm.reset();
925 error: function( xhr, status ) { alert( "<?php echo xls('Sorry, there was a problem!'); ?>" ); },
926 // code to run regardless of success or failure
927 // complete: function( xhr, status ) { alert( "The request is complete!" ); }
929 archlist();
930 csvlist();
931 return false;
934 jQuery('#archiverpt').on('click', function(event) {
935 event.preventDefault();
936 event.stopPropagation();
937 // id="#archiversp"
938 var rspElem = jQuery('#archiversp');
939 rspElem.html('');
940 var sprd = jQuery('#archiveselect').val();
941 var surl = jQuery('#formarchive').attr('action');
943 //console.log(surl);
944 jQuery.ajax({
945 url: 'edih_main.php',
946 type: 'GET',
947 //cache: false,
948 dataType: 'html',
949 data: { archivereport: 'yes', period: sprd },
951 success: function(data) {
952 //rspElem.html(data);
953 //rspElem.show();
954 jQuery('#archiversp').html(data);
956 error: function( xhr, status ) {
957 alert( "<?php echo xls('Sorry, there was a problem!'); ?>" );
958 rspElem.html(status);
959 rspElem.show();
962 return false;
965 jQuery('#archiveselect').on('change', function(e) {
966 jQuery('#archivesubmit').prop('disabled', false );
970 jQuery('#formarchrestore').on('submit', function(e) {
971 //e.stopPropagation();
972 e.preventDefault();
974 var sel = jQuery( "#archrestoresel option:selected" ).text();
975 console.log( sel );
976 if (sel == "No Archives") {
977 alert("<?php echo xls('No archive files present'); ?>");
978 return false;
980 var archrstForm = document.getElementById('formarchrestore');
981 var archrstdata = new FormData(archrstForm);
982 var rspElem = jQuery('#archiversp');
983 //var archf = jQuery('#archrestoresel').val();
984 //archrstdata = { archrestore: 'yes', archfile: archf };
985 jQuery.ajax({
986 url: jQuery('#formarchrestore').attr('action'),
987 type: 'POST',
988 data: archrstdata,
989 dataType: 'html',
990 processData: false,
991 contentType: false,
992 success: function(data) {
993 rspElem.html('');
994 rspElem.html(data);
996 error: function( xhr, status ) { alert( "<?php echo xls('Sorry, there was a problem!'); ?>" ); },
998 archlist();
999 csvlist();
1000 archrstForm.reset();
1001 return false;
1004 /* ************
1005 * end of javascript block
1007 </script>
1009 </body>
1011 </html>