Added popup date widget to From and To dates
[openemr.git] / interface / billing / billing_report.php
blob14b0d6d1abfa314d82747d3c61273c9f112e70b1
1 <?
2 include_once("../globals.php");
3 include_once("../../library/acl.inc");
4 include_once("../../custom/code_types.inc.php");
6 include_once("$srcdir/patient.inc");
7 include_once("$srcdir/billrep.inc");
8 include_once(dirname(__FILE__) . "/../../library/classes/OFX.class.php");
9 include_once(dirname(__FILE__) . "/../../library/classes/X12Partner.class.php");
11 $EXPORT_INC = "$webserver_root/custom/BillingExport.php";
13 $alertmsg = '';
15 if ($_POST['mode'] == 'export') {
16 $sdate = $_POST['from_date'];
17 $edate = $_POST['to_date'];
19 $sql = "SELECT billing.*, concat(pd.fname, ' ', pd.lname) as name from billing "
20 . "join patient_data as pd on pd.pid = billing.pid where billed = '1' and "
21 . "(process_date > '" . mysql_real_escape_string($sdate)
22 . "' or DATE_FORMAT( process_date, '%Y-%m-%d' ) = '" . mysql_real_escape_string($sdate) ."') "
23 . "and (process_date < '" . mysql_real_escape_string($edate)
24 . "'or DATE_FORMAT( process_date, '%Y-%m-%d' ) = '" . mysql_real_escape_string($edate) ."') "
25 . "order by pid,encounter";
26 $db = get_db();
27 $results = $db->Execute($sql);
28 $billings = array();
29 if ($results->RecordCount() == 0) {
30 echo xl("No Bills Found to Include in OFX Export<br>");
32 else {
33 while(!$results->EOF) {
34 $billings[] = $results->fields;
35 $results->MoveNext();
37 $ofx = new OFX($billings);
38 header("Pragma: public");
39 header("Expires: 0");
40 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
41 header("Content-Disposition: attachment; filename=openemr_ofx.ofx");
42 header("Content-Type: text/xml");
43 echo $ofx->get_OFX();
44 exit;
48 if ($_POST['mode'] == 'process') {
49 if (exec("ps x | grep 'process_bills[.]php'")) {
50 $alertmsg = xl('Request ignored - claims processing is already running!');
52 else {
53 exec("cd $webserver_root/library/freeb;" .
54 "php -q process_bills.php bill > process_bills.log 2>&1 &");
55 $alertmsg = xl('Batch processing initiated; this may take a while.');
59 //global variables:
60 if (!isset($_POST["mode"])) {
61 if (!isset($_POST["from_date"])) {
62 $from_date=date("Y-m-d");
63 } else {
64 $from_date = $_POST["from_date"];
66 if (!isset($_POST["to_date"])) {
67 $to_date = date("Y-m-d");
68 } else {
69 $to_date = $_POST["to_date"];
71 if (!isset($_POST["code_type"])) {
72 $code_type="all";
73 } else {
74 $code_type = $_POST["code_type"];
76 if (!isset($_POST["unbilled"])) {
77 $unbilled = "on";
78 } else {
79 $unbilled = $_POST["unbilled"];
81 if (!isset($_POST["authorized"])) {
82 $my_authorized = "on";
83 } else {
84 $my_authorized = $_POST["authorized"];
86 } else {
87 $from_date = $_POST["from_date"];
88 $to_date = $_POST["to_date"];
89 $code_type = $_POST["code_type"];
90 $unbilled = $_POST["unbilled"];
91 $my_authorized = $_POST["authorized"];
94 $ofrom_date = $from_date;
95 $oto_date = $to_date;
96 $ocode_type = $code_type;
97 $ounbilled = $unbilled;
98 $oauthorized = $my_authorized;
102 <html>
103 <head>
104 <link rel=stylesheet href="<?echo $css_header;?>" type="text/css">
105 <style>
106 .subbtn { margin-top:3px; margin-bottom:3px; margin-left:2px; margin-right:2px }
107 </style>
108 <script>
110 function select_all() {
111 for($i=0;$i < document.update_form.length;$i++) {
112 $name = document.update_form[$i].name;
113 if ($name.substring(0,7) == "claims[" && $name.substring($name.length -6) == "[bill]") {
114 document.update_form[$i].checked = true;
117 set_button_states();
120 function set_button_states() {
121 var f = document.update_form;
122 var count0 = 0;
123 var count1 = 0;
124 var count2 = 0;
125 for($i = 0; $i < f.length; ++$i) {
126 $name = f[$i].name;
127 if ($name.substring(0, 7) == "claims[" && $name.substring($name.length -6) == "[bill]" && f[$i].checked == true) {
128 if (f[$i].value == '0') ++count0;
129 else if (f[$i].value == '1' || f[$i].value == '5') ++count1;
130 else ++count2;
134 var can_generate = (count0 > 0 || count1 > 0 || count2 > 0);
135 var can_mark = (count1 == 0 && (count0 > 0 || count2 > 0));
136 var can_bill = (count0 == 0 && count1 == 0 && count2 > 0);
138 <? if (file_exists($EXPORT_INC)) { ?>
139 f.bn_external.disabled = !can_generate;
140 <? } else { ?>
141 f.bn_hcfa_print.disabled = !can_generate;
142 f.bn_hcfa.disabled = !can_generate;
143 f.bn_ub92_print.disabled = !can_generate;
144 f.bn_ub92.disabled = !can_generate;
145 f.bn_x12.disabled = !can_generate;
146 f.bn_electronic_file.disabled = !can_bill;
147 <? } ?>
148 f.bn_mark.disabled = !can_mark;
151 </script>
152 </head>
153 <body <?echo $top_bg_line;?> topmargin=0 rightmargin=0 leftmargin=2 bottommargin=0 marginwidth=2 marginheight=0>
155 <p style='margin-top:5px;margin-bottom:5px;margin-left:5px'>
157 if ($userauthorized) {
159 <a href="../main/main.php" target=Main><font class=title><?xl('Billing Report','e')?></font><font class=more> <?echo $tback;?></font></a>
160 <?} else {?>
161 <a href="../main/onotes/office_comments.php" target=Main><font class=title><?xl('Billing Report','e')?></font><font class=more><?echo $tback;?></font></a>
165 </p>
167 <form name=the_form method=post action=billing_report.php>
169 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
170 <script type="text/javascript" src="../../library/dialog.js"></script>
171 <script type="text/javascript" src="../../library/textformat.js"></script>
172 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
173 <script type="text/javascript" src="../../library/dynarch_calendar_en.js"></script>
174 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
175 <script language='JavaScript'>
176 var mypcc = '1';
177 </script>
179 <input type=hidden name=mode value="change">
180 <table width=100% border="1" cellspacing="0" cellpadding="0">
182 <tr>
184 <td nowrap>
185 &nbsp;<span class=text><?xl('From: ','e')?></span>
186 <input type='text' size='10' name='from_date' id='from_date'
187 value='<?echo $from_date;?>'
188 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
189 title='yyyy-mm-dd last date of this event' />
190 <img src='../../interface/pic/show_calendar.gif' align='absbottom' width='24' height='22'
191 id='img_fromdate' border='0' alt='[?]' style='cursor:pointer'
192 title='Click here to choose a date'>
193 <script>
194 Calendar.setup({inputField:"from_date", ifFormat:"%Y-%m-%d", button:"img_fromdate"});
195 </script>
196 </td>
198 <td nowrap>
199 &nbsp;<span class=text><?xl('To: ','e')?></span>
200 <input type='text' size='10' name='to_date' id='to_date'
201 value='<?echo $to_date;?>'
202 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
203 title='yyyy-mm-dd last date of this event' />
204 <img src='../../interface/pic/show_calendar.gif' align='absbottom' width='24' height='22'
205 id='img_todate' border='0' alt='[?]' style='cursor:pointer'
206 title='Click here to choose a date'>
207 <script>
208 Calendar.setup({inputField:"to_date", ifFormat:"%Y-%m-%d", button:"img_todate"});
209 </script>
210 </td>
212 <input type="hidden" name="code_type" value="%"></td>
213 <td nowrap><input type=checkbox name=unbilled <?if ($unbilled == "on") {echo "checked";};?>><span class=text><?xl('Show Unbilled Only','e')?></span></td>
214 <td nowrap><input type=checkbox name=authorized <?if ($my_authorized == "on") {echo "checked";};?>><span class=text><?xl('Show Authorized Only','e')?></span></td>
215 <td align='right' width='10%' nowrap>
216 &nbsp;<span class=text><a href="javascript:document.the_form.mode.value='change';document.the_form.submit()" class=link_submit><?xl('[Change View]','e')?></a>
218 <a href="javascript:document.the_form.mode.value='export';document.the_form.submit()" class=link_submit><?xl('[Export OFX]','e')?></a></span>&nbsp;
219 </td>
220 </tr>
221 <tr>
222 <td nowrap>&nbsp;<a href="print_billing_report.php?<?print "from_date=".urlencode($ofrom_date)."&to_date=".urlencode($oto_date)."&code_type=".urlencode($ocode_type)."&unbilled=".urlencode($ounbilled)."&authorized=".urlencode($oauthorized);?>" class=link_submit target=new><?xl('[View Printable Report]','e')?></a></td>
223 <td nowrap>
224 <?php
225 print '&nbsp;';
226 $acct_config = $GLOBALS['oer_config']['ws_accounting'];
227 if($acct_config['enabled'] == true) {
228 print '<span class=text><a href="javascript:void window.open(\'' . $acct_config['url_path'] . '\')">' . xl("[SQL-Ledger]") . '</a></span>';
229 if (acl_check('acct', 'rep')) {
230 print '<span class=text> &nbsp; <a href="javascript:void window.open(\'sl_receipts_report.php\')">' . xl('[Reports]') . '</a></span>';
232 if (acl_check('acct', 'eob')) {
233 print '<span class=text> &nbsp; <a href="javascript:void window.open(\'sl_eob_search.php\')">' . xl('[EOBs]') . '</a></span>';
237 </td>
238 <td colspan='2' nowrap>
239 &nbsp;
240 <? if (! file_exists($EXPORT_INC)) { ?>
241 <a href="javascript:document.the_form.mode.value='process';document.the_form.submit()" class="link_submit"
242 title="Process all queued bills to create electronic data (and print if requested)"><?xl('[Start Batch Processing]','e')?></a>
243 &nbsp; <a href='../../library/freeb/process_bills.log' target='_blank' class='link_submit'
244 title='See messages from the last batch processing run'><?xl('[view log]','e')?></a></span>
245 <? } ?>
246 </td>
247 <td align='right' nowrap>
248 <a href="javascript:select_all()" class="link_submit"><?xl('[Select All]','e')?></a>&nbsp;
249 </td>
250 </tr>
251 </table>
252 </form>
254 <form name=update_form method=post action=billing_process.php>
256 <center>
258 <? if (file_exists($EXPORT_INC)) { ?>
259 <input type="submit" class="subbtn" name="bn_external" value="Export Billing" title="<?xl('Export to external billing system','e')?>">
260 <input type="submit" class="subbtn" name="bn_mark" value="Mark as Cleared" title="<?xl('Mark as billed but skip billing','e')?>">
261 <? } else { ?>
262 <input type="submit" class="subbtn" name="bn_hcfa_print" value="Queue HCFA &amp; Print" title="<?xl('Queue for HCFA batch processing and printing','e')?>">
263 <input type="submit" class="subbtn" name="bn_hcfa" value="Queue HCFA" title="<?xl('Queue for HCFA batch processing','e')?>">
264 <input type="submit" class="subbtn" name="bn_ub92_print" value="Queue UB92 &amp; Print" title="<?xl('Queue for UB-92 batch processing and printing','e')?>">
265 <input type="submit" class="subbtn" name="bn_ub92" value="Queue UB92" title="<?xl('Queue for UB-92 batch processing','e')?>">
266 <input type="submit" class="subbtn" name="bn_x12" value="Queue X12" title="<?xl('Queue for X12 batch processing','e')?>">
267 <input type="submit" class="subbtn" name="bn_mark" value="Mark as Cleared" title="<?xl('Post to accounting and mark as billed','e')?>">
268 <input type="submit" class="subbtn" name="bn_electronic_file" value="Make Electronic Batch &amp; Clear" title="<?xl('Download billing file, post to accounting and mark as billed','e')?>">
269 <? } ?>
271 </center>
273 <input type=hidden name=mode value="bill">
274 <input type=hidden name=authorized value="<?echo $my_authorized;?>">
275 <input type=hidden name=unbilled value="<?echo $unbilled;?>">
276 <input type=hidden name=code_type value="%">
277 <input type=hidden name=to_date value="<?echo $to_date;?>">
278 <input type=hidden name=from_date value="<?echo $from_date;?>">
280 if ($my_authorized == "on" ) {
281 $my_authorized = "1";
282 } else {
283 $my_authorized = "%";
286 if ($unbilled == "on") {
287 $unbilled = "0";
288 } else {
289 $unbilled = "%";
292 <input type=hidden name=bill_list value="<?
293 $list = getBillsListBetween($from_date,$to_date,$my_authorized,$unbilled,"%");
294 print $list;
295 ?>">
296 <!-- new form for uploading -->
297 <?php
298 if (!isset($_POST["mode"])) {
299 if (!isset($_POST["from_date"])) {
300 $from_date=date("Y-m-d");
301 } else {
302 $from_date = $_POST["from_date"];
304 if (!isset($_POST["to_date"])) {
305 $to_date = date("Y-m-d");
306 } else {
307 $to_date = $_POST["to_date"];
309 if (!isset($_POST["code_type"])) {
310 $code_type="all";
311 } else {
312 $code_type = $_POST["code_type"];
314 if (!isset($_POST["unbilled"])) {
315 $unbilled = "on";
316 } else {
317 $unbilled = $_POST["unbilled"];
319 if (!isset($_POST["authorized"])) {
320 $my_authorized = "on";
321 } else {
322 $my_authorized = $_POST["authorized"];
324 } else {
325 $from_date = $_POST["from_date"];
326 $to_date = $_POST["to_date"];
327 $code_type = $_POST["code_type"];
328 $unbilled = $_POST["unbilled"];
329 $my_authorized = $_POST["authorized"];
331 if ($my_authorized == "on" ) {
332 $my_authorized = "1";
333 } else {
334 $my_authorized = "%";
337 if ($unbilled == "on") {
338 $unbilled = "0";
339 } else {
340 $unbilled = "%";
345 if (isset($_POST["mode"]) && $_POST["mode"] == "bill") {
346 billCodesList($list);
351 <table border="0" cellspacing="0" cellpadding="0" width="100%">
354 if ($ret = getBillsBetween($from_date,$to_date,$my_authorized,$unbilled,"%")) {
355 $loop = 0;
356 $oldcode = "";
357 $last_encounter_id = "";
358 $lhtml = "";
359 $rhtml = "";
360 $lcount = 0;
361 $rcount = 0;
362 $bgcolor = "";
363 $skipping = FALSE;
365 foreach ($ret as $iter) {
366 $this_encounter_id = $iter['pid'] . "-" . $iter['encounter'];
368 if ($last_encounter_id != $this_encounter_id) {
369 if ($lhtml) {
370 while ($rcount < $lcount) {
371 $rhtml .= "<tr bgcolor='$bgcolor'><td colspan='7'>&nbsp;</td></tr>";
372 ++$rcount;
374 echo "<tr bgcolor='$bgcolor'>\n<td rowspan='$rcount' valign='top'>\n$lhtml</td>$rhtml\n";
375 echo "<tr bgcolor='$bgcolor'><td colspan='8' height='5'></td></tr>\n\n";
378 $lhtml = "";
379 $rhtml = "";
381 // If there are ANY unauthorized items in this encounter and this is
382 // the normal case of viewing only authorized billing, then skip the
383 // entire encounter.
385 $skipping = FALSE;
386 if ($my_authorized == '1') {
387 $res = sqlQuery("select count(*) as count from billing where " .
388 "encounter = '" . $iter['encounter'] . "' and " .
389 "pid='" . $iter['pid'] . "' and " .
390 "activity = 1 and authorized = 0");
391 if ($res['count'] > 0) {
392 $skipping = TRUE;
393 $last_encounter_id = $this_encounter_id;
394 continue;
398 $name = getPatientData($iter['pid'], "fname, mname, lname");
400 # Check if patient has primary insurance and a subscriber exists for it.
401 # If not we will highlight their name in red.
402 # TBD: more checking here.
404 $res = sqlQuery("select count(*) as count from insurance_data where " .
405 "pid = " . $iter['pid'] . " and " .
406 "type='primary' and " .
407 "subscriber_lname is not null and " .
408 "subscriber_lname != '' limit 1");
409 $namecolor = ($res['count'] > 0) ? "black" : "#ff7777";
411 ++$encount;
412 $bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd");
413 echo "<tr bgcolor='$bgcolor'><td colspan='8' height='5'></td></tr>\n";
414 $lcount = 3;
415 $rcount = 0;
416 $oldcode = "";
418 $lhtml .= "&nbsp;<span class=bold><font color='$namecolor'>". $name['fname'] . "&nbsp;" . $name['lname'] . "</font></span><span class=small>&nbsp;(" . $iter['pid'] . "-" . $iter['encounter'] . ")</span>";
419 $lhtml .= "&nbsp;&nbsp;&nbsp;<a class=\"link_submit\" href=\"" . $GLOBALS['webroot'] ."/interface/patient_file/encounter/patient_encounter.php?set_encounter=" . $iter['encounter'] . "&pid=" . $iter['pid'] . "\">[To&nbsp;Encounter]</a>";
420 $lhtml .= "&nbsp;&nbsp;&nbsp;<a class=\"link_submit\" href=\"" . $GLOBALS['webroot'] ."/interface/patient_file/summary/demographics_full.php?&pid=" . $iter['pid'] . "\">[To&nbsp;Demographics]</a>";
421 $lhtml .= "<br />\n";
422 $lhtml .= "&nbsp;<span class=text>Bill: ";
423 $lhtml .= "<select name='claims[" . $this_encounter_id . "][payer]' style='background-color:$bgcolor'>";
424 $query = "SELECT id.provider as id, id.type, ic.x12_default_partner_id as ic_x12id, ic.name as provider FROM insurance_data as id, insurance_companies as ic WHERE ic.id = id.provider AND pid = '" . mysql_escape_string($iter['pid']) . "' order by type";
426 $result = sqlStatement($query);
427 $count = 0;
428 $default_x12_partner = $iter['ic_x12id'];
430 while ($row = mysql_fetch_array($result)) {
431 if (strlen($row['provider']) > 0) {
432 if ($count == 0) {
433 $lhtml .= "<option value=\"" .$row['id'] . "\" selected>" . $row['type'] . ": " . $row['provider']. "</option>";
434 if (!is_numeric($default_x12_partner)) $default_x12_partner = $row['ic_x12id'];
436 else {
437 $lhtml .= "<option value=\"" . $row['id'] . "\">" . $row['type'] . ": " . $row['provider']. "</option>";
440 $count++;
442 $lhtml .= "<option value='-1'>Unassigned</option>\n";
443 $lhtml .= "</select>&nbsp;&nbsp;\n";
444 $lhtml .= "<select name='claims[" . $this_encounter_id . "][partner]' style='background-color:$bgcolor'>";
445 $x = new X12Partner();
446 $partners = $x->_utility_array($x->x12_partner_factory());
447 foreach ($partners as $xid => $xname) {
448 $lhtml .= '<option label="' . $xname . '" value="' . $xid .'"';
449 if ($xid == $default_x12_partner) {
450 $lhtml .= "selected";
452 $lhtml .= '>' . $xname . '</option>';
454 $lhtml .= "</select>";
455 $lhtml .= "<br>\n&nbsp;".xl("Claim was initiated: ") . $iter['date'];
456 if ($iter['billed'] == 1) {
457 $lhtml .= "<br>\n&nbsp;".xl("Claim was billed: ") . $iter['bill_date'];
458 ++$lcount;
460 if ($iter['bill_process'] == 1) {
461 $lhtml .= "<br>\n&nbsp;".xl("Claim is queued for processing");
462 ++$lcount;
464 if ($iter['bill_process'] == 5) {
465 $lhtml .= "<br>\n&nbsp;".xl("Claim is queued for printing and processing");
466 ++$lcount;
468 if ($iter['bill_process'] == 2) {
469 $lhtml .= "<br>\n&nbsp;".xl("Claim was processed: ") . $iter['process_date'];
470 $lhtml .= '<br>' . "\n" . '&nbsp;'.xl("Claim is in file:").' <a href="get_claim_file.php?key=' . $iter['process_file'] .'">' . $iter['process_file'] . '</a> or ';
471 $lhtml .= '<a href="get_claim_file.php?action=print&key=' . $iter['process_file'] .'">Print It</a> or ';
472 $lhtml .= '<a target="_new" href="freebtest.php?format=' . $iter['target'] . '&billkey=' . $iter['pid'] . '-' . $iter['encounter'] . '">'.xl('Run Test').'</a>';
473 $lhtml .= '<input type="hidden" name="claims[' . $this_encounter_id . '][file]" value="' . $iter['process_file'] . '">';
474 $lcount += 2;
476 if ($iter['bill_process'] == 3) {
477 $lhtml .= "<br>\n&nbsp;".xl("Claim was processed: ") . $iter['process_date'] . xl(" but there was an error: "). $iter['process_file'];
478 ++$lcount;
482 if ($skipping) continue;
484 ++$rcount;
485 if ($rhtml) {
486 $rhtml .= "<tr bgcolor='$bgcolor'>\n";
488 $rhtml .= "<td width='50'>";
489 if ($oldcode != $iter['code_type']) {
490 $rhtml .= "<span class=text>" . $iter['code_type'] . ": </span>";
492 $oldcode = $iter['code_type'];
493 $rhtml .= "</td>\n";
494 $justify = "";
495 // if ($iter['code_type'] == "CPT4" || $iter['code_type'] == "HCPCS") {
496 if ($code_types[$iter['code_type']]['just']) {
497 $js = split(":",$iter['justify']);
498 $counter = 0;
499 foreach ($js as $j) {
500 if(!empty($j)) {
501 if ($counter == 0) {
502 $justify .= " (<b>$j</b>)";
504 else {
505 $justify .= " ($j)";
507 $counter++;
512 $rhtml .= "<td><span class=text>" . $iter{"code"}. "</span>" . '<span style="font-size:8pt;">' . $justify . "</span></td>\n";
513 $rhtml .= '<td align="right"><span style="font-size:8pt;">&nbsp;&nbsp;&nbsp;';
514 if ($iter['fee'] > 0) {
515 $rhtml .= '$' . $iter['fee'];
517 $rhtml .= "</span></td>\n";
518 $rhtml .= '<td><span style="font-size:8pt;">&nbsp;&nbsp;&nbsp;';
519 $rhtml .= getProviderName($iter['provider_id']);
520 $rhtml .= "</span></td>\n";
521 $rhtml .= '<td width=100>&nbsp;&nbsp;&nbsp;<span style="font-size:8pt;">' . date("Y-m-d",strtotime($iter{"date"})) . "</span></td>\n";
522 if ($iter['authorized'] != 1) {
523 $rhtml .= "<td><span class=alert>".xl("Note: This code was not entered by an authorized user. Only authorized codes may be uploaded to the Open Medical Billing Network for processing. If you wish to upload these codes, please select an authorized user here.")."</span></td>\n";
525 else {
526 $rhtml .= "<td></td>\n";
528 if ($last_encounter_id != $this_encounter_id) {
529 $rhtml .= "<td><input type='checkbox' value='" . $iter['bill_process'] . "$procstatus' name='claims[" . $this_encounter_id . "][bill]' onclick='set_button_states()'>&nbsp;</td>\n";
531 else {
532 $rhtml .= "<td></td>\n";
534 $rhtml .= "</tr>\n";
535 $last_encounter_id = $this_encounter_id;
538 if ($lhtml) {
539 while ($rcount < $lcount) {
540 $rhtml .= "<tr bgcolor='$bgcolor'><td colspan='7'>&nbsp;</td></tr>";
541 ++$rcount;
543 echo "<tr bgcolor='$bgcolor'>\n<td rowspan='$rcount' valign='top'>\n$lhtml</td>$rhtml\n";
544 echo "<tr bgcolor='$bgcolor'><td colspan='8' height='5'></td></tr>\n";
550 </table>
552 </form>
553 <script>
554 set_button_states();
557 if ($alertmsg) {
558 echo "alert('$alertmsg');\n";
562 </script>
563 </body>
564 </html>