added cache clearing support for dialog.js (#411)
[openemr.git] / interface / patient_file / encounter / superbill_custom_full.php
blobffbd2254ef8e66f14398515e80c7c311d195c2a5
1 <?php
2 // This program is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU General Public License
4 // as published by the Free Software Foundation; either version 2
5 // of the License, or (at your option) any later version.
7 $fake_register_globals=false;
8 $sanitize_all_escapes=true;
10 require_once("../../globals.php");
11 require_once("../../../custom/code_types.inc.php");
12 require_once("$srcdir/sql.inc");
13 require_once("$srcdir/options.inc.php");
14 require_once("$srcdir/formatting.inc.php");
15 require_once("$srcdir/formdata.inc.php");
16 require_once("$srcdir/formatting.inc.php");
18 // Translation for form fields.
19 function ffescape($field) {
20 $field = add_escape_custom($field);
21 return trim($field);
24 // Format dollars for display.
26 function bucks($amount) {
27 if ($amount) {
28 $amount = oeFormatMoney($amount);
29 return $amount;
31 return '';
34 $alertmsg = '';
35 $pagesize = 100;
36 $mode = $_POST['mode'];
37 $code_id = 0;
38 $related_code = '';
39 $active = 1;
40 $reportable = 0;
41 $financial_reporting = 0;
43 if (isset($mode)) {
44 $code_id = empty($_POST['code_id']) ? '' : $_POST['code_id'] + 0;
45 $code = $_POST['code'];
46 $code_type = $_POST['code_type'];
47 $code_text = $_POST['code_text'];
48 $modifier = $_POST['modifier'];
49 $superbill = $_POST['form_superbill'];
50 $related_code = $_POST['related_code'];
51 $cyp_factor = $_POST['cyp_factor'] + 0;
52 $active = empty($_POST['active']) ? 0 : 1;
53 $reportable = empty($_POST['reportable']) ? 0 : 1; // dx reporting
54 $financial_reporting = empty($_POST['financial_reporting']) ? 0 : 1; // financial service reporting
56 $taxrates = "";
57 if (!empty($_POST['taxrate'])) {
58 foreach ($_POST['taxrate'] as $key => $value) {
59 $taxrates .= "$key:";
63 if ($mode == "delete") {
64 sqlStatement("DELETE FROM codes WHERE id = ?", array($code_id) );
65 $code_id = 0;
67 else if ($mode == "add" || $mode == "modify_complete") { // this covers both adding and modifying
68 $crow = sqlQuery("SELECT COUNT(*) AS count FROM codes WHERE " .
69 "code_type = '" . ffescape($code_type) . "' AND " .
70 "code = '" . ffescape($code) . "' AND " .
71 "modifier = '" . ffescape($modifier) . "' AND " .
72 "id != '" . add_escape_custom($code_id) . "'");
73 if ($crow['count']) {
74 $alertmsg = xl('Cannot add/update this entry because a duplicate already exists!');
76 else {
77 $sql =
78 "code = '" . ffescape($code) . "', " .
79 "code_type = '" . ffescape($code_type) . "', " .
80 "code_text = '" . ffescape($code_text) . "', " .
81 "modifier = '" . ffescape($modifier) . "', " .
82 "superbill = '" . ffescape($superbill) . "', " .
83 "related_code = '" . ffescape($related_code) . "', " .
84 "cyp_factor = '" . ffescape($cyp_factor) . "', " .
85 "taxrates = '" . ffescape($taxrates) . "', " .
86 "active = " . add_escape_custom($active) . ", " .
87 "financial_reporting = " . add_escape_custom($financial_reporting) . ", " .
88 "reportable = " . add_escape_custom($reportable);
89 if ($code_id) {
90 $query = "UPDATE codes SET $sql WHERE id = ?";
91 sqlStatement($query, array($code_id) );
92 sqlStatement("DELETE FROM prices WHERE pr_id = ? AND " .
93 "pr_selector = ''", array($code_id) );
95 else {
96 $code_id = sqlInsert("INSERT INTO codes SET $sql");
98 if (!$alertmsg) {
99 foreach ($_POST['fee'] as $key => $value) {
100 $value = $value + 0;
101 if ($value) {
102 sqlStatement("INSERT INTO prices ( " .
103 "pr_id, pr_selector, pr_level, pr_price ) VALUES ( " .
104 "?, '', ?, ?)", array($code_id,$key,$value) );
107 $code = $code_type = $code_text = $modifier = $superbill = "";
108 $code_id = 0;
109 $related_code = '';
110 $cyp_factor = 0;
111 $taxrates = '';
112 $active = 1;
113 $reportable = 0;
117 else if ($mode == "edit") { // someone clicked [Edit]
118 $sql = "SELECT * FROM codes WHERE id = ?";
119 $results = sqlStatement($sql, array($code_id) );
120 while ($row = sqlFetchArray($results)) {
121 $code = $row['code'];
122 $code_text = $row['code_text'];
123 $code_type = $row['code_type'];
124 $modifier = $row['modifier'];
125 // $units = $row['units'];
126 $superbill = $row['superbill'];
127 $related_code = $row['related_code'];
128 $cyp_factor = $row['cyp_factor'];
129 $taxrates = $row['taxrates'];
130 $active = 0 + $row['active'];
131 $reportable = 0 + $row['reportable'];
132 $financial_reporting = 0 + $row['financial_reporting'];
135 else if ($mode == "modify") { // someone clicked [Modify]
136 // this is to modify external code types, of which the modifications
137 // are stored in the codes table
138 $code_type_name_external = $_POST['code_type_name_external'];
139 $code_external = $_POST['code_external'];
140 $code_id = $_POST['code_id'];
141 $results = return_code_information($code_type_name_external,$code_external,false); // only will return one item
142 while ($row = sqlFetchArray($results)) {
143 $code = $row['code'];
144 $code_text = $row['code_text'];
145 $code_type = $code_types[$code_type_name_external]['id'];
146 $modifier = $row['modifier'];
147 // $units = $row['units'];
148 $superbill = $row['superbill'];
149 $related_code = $row['related_code'];
150 $cyp_factor = $row['cyp_factor'];
151 $taxrates = $row['taxrates'];
152 $active = $row['active'];
153 $reportable = $row['reportable'];
154 $financial_reporting = $row['financial_reporting'];
157 // If codes history is enabled in the billing globals save data to codes history table
158 if ($GLOBALS['save_codes_history'] && $alertmsg=='' &&
159 ( $mode == "modify" || $mode == "add" || $mode == "modify_complete" || $mode == "delete" ) ){
161 $action_type= empty($_POST['code_id']) ? 'new' : $mode;
162 $action_type= ($action_type=='add') ? 'update' : $action_type ;
163 $code = $_POST['code'];
164 $code_type = $_POST['code_type'];
165 $code_text = $_POST['code_text'];
166 $modifier = $_POST['modifier'];
167 $superbill = $_POST['form_superbill'];
168 $related_code = $_POST['related_code'];
169 $cyp_factor = $_POST['cyp_factor'] + 0;
170 $active = empty($_POST['active']) ? 0 : 1;
171 $reportable = empty($_POST['reportable']) ? 0 : 1; // dx reporting
172 $financial_reporting = empty($_POST['financial_reporting']) ? 0 : 1; // financial service reporting
173 $fee=json_encode($_POST['fee']);
174 $code_sql= sqlFetchArray(sqlStatement("SELECT (ct_label) FROM code_types WHERE ct_id=?",array($code_type)));
175 $code_name='';
177 if ($code_sql){
178 $code_name=$code_sql['ct_label'];
181 $categorey_id= $_POST['form_superbill'];
182 $categorey_sql=sqlFetchArray(sqlStatement("SELECT (title ) FROM list_options WHERE list_id='superbill'".
183 " AND option_id=?",array($categorey_id)));
185 $categorey_name='';
187 if ($categorey_sql){
188 $categorey_name=$categorey_sql['title'];
191 $date=date('Y-m-d H:i:s');
192 $date=oeFormatShortDate($date);
193 $results = sqlStatement("INSERT INTO codes_history ( " .
194 "date, code, modifier, active,diagnosis_reporting,financial_reporting,category,code_type_name,".
195 "code_text,code_text_short,prices,action_type, update_by ) VALUES ( " .
196 "?, ?,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,?)",
197 array($date,$code,$modifier,$active,$reportable,$financial_reporting,$categorey_name,$code_name,$code_text,'',$fee,$action_type,$_SESSION['authUser']) );
201 $related_desc = '';
202 if (!empty($related_code)) {
203 $related_desc = $related_code;
206 $fstart = $_REQUEST['fstart'] + 0;
207 if (isset($_REQUEST['filter'])) {
208 $filter = array();
209 $filter_key = array();
210 foreach ($_REQUEST['filter'] as $var) {
211 $var = $var+0;
212 array_push($filter,$var);
213 $var_key = convert_type_id_to_key($var);
214 array_push($filter_key,$var_key);
217 $search = $_REQUEST['search'];
218 $search_reportable = $_REQUEST['search_reportable'];
219 $search_financial_reporting = $_REQUEST['search_financial_reporting'];
221 //Build the filter_elements array
222 $filter_elements = array();
223 if (!empty($search_reportable)) {
224 $filter_elements['reportable'] = $search_reportable;
226 if (!empty($search_financial_reporting)) {
227 $filter_elements['financial_reporting'] = $search_financial_reporting;
230 if (isset($_REQUEST['filter'])) {
231 $count = main_code_set_search($filter_key,$search,NULL,NULL,false,NULL,true,NULL,NULL,$filter_elements);
234 if ($fstart >= $count) $fstart -= $pagesize;
235 if ($fstart < 0) $fstart = 0;
236 $fend = $fstart + $pagesize;
237 if ($fend > $count) $fend = $count;
240 <html>
241 <head>
242 <title><?php echo xlt("Codes"); ?></title>
243 <?php html_header_show(); ?>
244 <link rel="stylesheet" href="<?php echo attr($css_header);?>" type="text/css">
245 <script type="text/javascript" src="../../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
246 <script type="text/javascript" src="../../../library/textformat.js"></script>
248 <script language="JavaScript">
250 // This is for callback by the find-code popup.
251 // Appends to or erases the current list of related codes.
252 function set_related(codetype, code, selector, codedesc) {
253 var f = document.forms[0];
254 var s = f.related_code.value;
255 if (code) {
256 if (s.length > 0) s += ';';
257 s += codetype + ':' + code;
258 } else {
259 s = '';
261 f.related_code.value = s;
262 f.related_desc.value = s;
265 // This invokes the find-code popup.
266 function sel_related() {
267 var f = document.forms[0];
268 var i = f.code_type.selectedIndex;
269 var codetype = '';
270 if (i >= 0) {
271 var myid = f.code_type.options[i].value;
272 <?php
273 foreach ($code_types as $key => $value) {
274 $codeid = $value['id'];
275 $coderel = $value['rel'];
276 if (!$coderel) continue;
277 echo " if (myid == $codeid) codetype = '$coderel';";
281 if (!codetype) {
282 alert('<?php echo addslashes( xl('This code type does not accept relations.') ); ?>');
283 return;
285 dlgopen('find_code_popup.php', '_blank', 500, 400);
288 // Some validation for saving a new code entry.
289 function validEntry(f) {
290 if (!f.code.value) {
291 alert('<?php echo addslashes( xl('No code was specified!') ); ?>');
292 return false;
294 <?php if ($GLOBALS['ippf_specific']) { ?>
295 if (f.code_type.value == 12 && !f.related_code.value) {
296 alert('<?php echo addslashes( xl('A related IPPF code is required!') ); ?>');
297 return false;
299 <?php } ?>
300 return true;
303 function submitAdd() {
304 var f = document.forms[0];
305 if (!validEntry(f)) return;
306 f.mode.value = 'add';
307 f.code_id.value = '';
308 f.submit();
311 function submitUpdate() {
312 var f = document.forms[0];
313 if (! parseInt(f.code_id.value)) {
314 alert('<?php echo addslashes( xl('Cannot update because you are not editing an existing entry!') ); ?>');
315 return;
317 if (!validEntry(f)) return;
318 f.mode.value = 'add';
319 f.submit();
322 function submitModifyComplete() {
323 var f = document.forms[0];
324 f.mode.value = 'modify_complete';
325 f.submit();
328 function submitList(offset) {
329 var f = document.forms[0];
330 var i = parseInt(f.fstart.value) + offset;
331 if (i < 0) i = 0;
332 f.fstart.value = i;
333 f.submit();
336 function submitEdit(id) {
337 var f = document.forms[0];
338 f.mode.value = 'edit';
339 f.code_id.value = id;
340 f.submit();
343 function submitModify(code_type_name,code,id) {
344 var f = document.forms[0];
345 f.mode.value = 'modify';
346 f.code_external.value = code;
347 f.code_id.value = id;
348 f.code_type_name_external.value = code_type_name;
349 f.submit();
354 function submitDelete(id) {
355 var f = document.forms[0];
356 f.mode.value = 'delete';
357 f.code_id.value = id;
358 f.submit();
361 function getCTMask() {
362 var ctid = document.forms[0].code_type.value;
363 <?php
364 foreach ($code_types as $key => $value) {
365 $ctid = attr($value['id']);
366 $ctmask = attr($value['mask']);
367 echo " if (ctid == '$ctid') return '$ctmask';\n";
370 return '';
373 </script>
375 </head>
376 <body class="body_top" >
378 <form method='post' action='superbill_custom_full.php' name='theform'>
380 <input type='hidden' name='mode' value=''>
382 <br>
384 <center>
385 <table border='0' cellpadding='0' cellspacing='0'>
387 <tr>
388 <td colspan="3"> <?php echo xlt('Not all fields are required for all codes or code types.'); ?><br><br></td>
389 </tr>
391 <tr>
392 <td><?php echo xlt('Type'); ?>:</td>
393 <td width="5">
394 </td>
395 <td>
397 <?php if ($mode != "modify") { ?>
398 <select name="code_type">
399 <?php } ?>
401 <?php $external_sets = array(); ?>
402 <?php foreach ($code_types as $key => $value) { ?>
403 <?php if ( !($value['external']) ) { ?>
404 <?php if ($mode != "modify") { ?>
405 <option value="<?php echo attr($value['id']) ?>"<?php if ($code_type == $value['id']) echo " selected" ?>><?php echo xlt($value['label']) ?></option>
406 <?php } ?>
407 <?php } ?>
408 <?php if ($value['external']) {
409 array_push($external_sets,$key);
410 } ?>
411 <?php } // end foreach ?>
413 <?php if ($mode != "modify") { ?>
414 </select>
415 <?php } ?>
417 <?php if ($mode == "modify") { ?>
418 <input type='text' size='4' name='code_type' readonly='readonly' style='display:none' value='<?php echo attr($code_type) ?>' />
419 <?php echo attr($code_type_name_external) ?>
420 <?php } ?>
422 &nbsp;&nbsp;
423 <?php echo xlt('Code'); ?>:
425 <?php if ($mode == "modify") { ?>
426 <input type='text' size='6' name='code' readonly='readonly' value='<?php echo attr($code) ?>' />
427 <?php } else { ?>
428 <input type='text' size='6' name='code' value='<?php echo attr($code) ?>'
429 onkeyup='maskkeyup(this,getCTMask())'
430 onblur='maskblur(this,getCTMask())'
432 <?php } ?>
434 <?php if (modifiers_are_used()) { ?>
435 &nbsp;&nbsp;<?php echo xlt('Modifier'); ?>:
436 <?php if ($mode == "modify") { ?>
437 <input type='text' size='6' name='modifier' readonly='readonly' value='<?php echo attr($modifier) ?>'>
438 <?php } else { ?>
439 <input type='text' size='6' name='modifier' value='<?php echo attr($modifier) ?>'>
440 <?php } ?>
441 <?php } else { ?>
442 <input type='hidden' name='modifier' value=''>
443 <?php } ?>
445 &nbsp;&nbsp;
446 <input type='checkbox' name='active' value='1'<?php if (!empty($active) || ($mode == 'modify' && $active == NULL) ) echo ' checked'; ?> />
447 <?php echo xlt('Active'); ?>
448 </td>
449 </tr>
451 <tr>
452 <td><?php echo xlt('Description'); ?>:</td>
453 <td></td>
454 <td>
456 <?php if ($mode == "modify") { ?>
457 <input type='text' size='50' name="code_text" readonly="readonly" value='<?php echo attr($code_text) ?>'>
458 <?php } else { ?>
459 <input type='text' size='50' name="code_text" value='<?php echo attr($code_text) ?>'>
460 <?php } ?>
462 </td>
463 </tr>
465 <tr>
466 <td><?php echo xlt('Category'); ?>:</td>
467 <td></td>
468 <td>
469 <?php
470 generate_form_field(array('data_type'=>1,'field_id'=>'superbill','list_id'=>'superbill'), $superbill);
472 &nbsp;&nbsp;
473 <input type='checkbox' title='<?php echo xlt("Syndromic Surveillance Report") ?>' name='reportable' value='1'<?php if (!empty($reportable)) echo ' checked'; ?> />
474 <?php echo xlt('Diagnosis Reporting'); ?>
475 &nbsp;&nbsp;&nbsp;&nbsp;
476 <input type='checkbox' title='<?php echo xlt("Service Code Finance Reporting") ?>' name='financial_reporting' value='1'<?php if (!empty($financial_reporting)) echo ' checked'; ?> />
477 <?php echo xlt('Service Reporting'); ?>
478 </td>
479 </tr>
481 <tr<?php if (empty($GLOBALS['ippf_specific'])) echo " style='display:none'"; ?>>
482 <td><?php echo xlt('CYP Factor'); ?>:</td>
483 <td></td>
484 <td>
485 <input type='text' size='10' maxlength='20' name="cyp_factor" value='<?php echo attr($cyp_factor) ?>'>
486 </td>
487 </tr>
489 <tr<?php if (!related_codes_are_used()) echo " style='display:none'"; ?>>
490 <td><?php echo xlt('Relate To'); ?>:</td>
491 <td></td>
492 <td>
493 <input type='text' size='50' name='related_desc'
494 value='<?php echo attr($related_desc) ?>' onclick="sel_related()"
495 title='<?php echo xla('Click to select related code'); ?>' readonly />
496 <input type='hidden' name='related_code' value='<?php echo attr($related_code) ?>' />
497 </td>
498 </tr>
500 <tr>
501 <td><?php echo xlt('Fees'); ?>:</td>
502 <td></td>
503 <td>
504 <?php
505 $pres = sqlStatement("SELECT lo.option_id, lo.title, p.pr_price " .
506 "FROM list_options AS lo LEFT OUTER JOIN prices AS p ON " .
507 "p.pr_id = ? AND p.pr_selector = '' AND p.pr_level = lo.option_id " .
508 "WHERE lo.list_id = 'pricelevel' AND lo.activity = 1 ORDER BY lo.seq, lo.title", array($code_id) );
509 for ($i = 0; $prow = sqlFetchArray($pres); ++$i) {
510 if ($i) echo "&nbsp;&nbsp;";
511 echo text(xl_list_label($prow['title'])) . " ";
512 echo "<input type='text' size='6' name='fee[" . attr($prow['option_id']) . "]' " .
513 "value='" . attr($prow['pr_price']) . "' >\n";
516 </td>
517 </tr>
519 <?php
520 $taxline = '';
521 $pres = sqlStatement("SELECT option_id, title FROM list_options " .
522 "WHERE list_id = 'taxrate' AND activity = 1 ORDER BY seq");
523 while ($prow = sqlFetchArray($pres)) {
524 if ($taxline) $taxline .= "&nbsp;&nbsp;";
525 $taxline .= "<input type='checkbox' name='taxrate[" . attr($prow['option_id']) . "]' value='1'";
526 if (strpos(":$taxrates", $prow['option_id']) !== false) $taxline .= " checked";
527 $taxline .= " />\n";
528 $taxline .= text(xl_list_label($prow['title'])) . "\n";
530 if ($taxline) {
532 <tr>
533 <td><?php echo xlt('Taxes'); ?>:</td>
534 <td></td>
535 <td>
536 <?php echo $taxline ?>
537 </td>
538 </tr>
539 <?php } ?>
541 <tr>
542 <td colspan="3" align="center">
543 <input type="hidden" name="code_id" value="<?php echo attr($code_id) ?>"><br>
544 <input type="hidden" name="code_type_name_external" value="<?php echo attr($code_type_name_external) ?>">
545 <input type="hidden" name="code_external" value="<?php echo attr($code_external) ?>">
546 <?php if ($mode == "modify") { ?>
547 <a href='javascript:submitModifyComplete();' class='link'>[<?php echo xlt('Update'); ?>]</a>
548 <?php } else { ?>
549 <a href='javascript:submitUpdate();' class='link'>[<?php echo xlt('Update'); ?>]</a>
550 &nbsp;&nbsp;
551 <a href='javascript:submitAdd();' class='link'>[<?php echo xlt('Add as New'); ?>]</a>
552 <?php } ?>
553 </td>
554 </tr>
556 </table>
557 <br>
558 <table border='0' cellpadding='5' cellspacing='0' width='96%'>
559 <tr>
561 <td class='text'>
562 <select name='filter[]' multiple='multiple'>
563 <?php
564 foreach ($code_types as $key => $value) {
565 echo "<option value='" . attr($value['id']) . "'";
566 if (isset($filter) && in_array($value['id'],$filter)) echo " selected";
567 echo ">" . xlt($value['label']) . "</option>\n";
570 </select>
571 &nbsp;&nbsp;&nbsp;&nbsp;
573 <input type="text" name="search" size="5" value="<?php echo attr($search) ?>">&nbsp;
574 <input type="submit" name="go" value='<?php echo xla('Search'); ?>'>&nbsp;&nbsp;
575 <input type='checkbox' title='<?php echo xlt("Only Show Diagnosis Reporting Codes") ?>' name='search_reportable' value='1'<?php if (!empty($search_reportable)) echo ' checked'; ?> />
576 <?php echo xlt('Diagnosis Reporting Only'); ?>
577 &nbsp;&nbsp;&nbsp;&nbsp;
578 <input type='checkbox' title='<?php echo xlt("Only Show Service Code Finance Reporting Codes") ?>' name='search_financial_reporting' value='1'<?php if (!empty($search_financial_reporting)) echo ' checked'; ?> />
579 <?php echo xlt('Service Reporting Only'); ?>
580 <input type='hidden' name='fstart' value='<?php echo attr($fstart) ?>'>
581 </td>
583 <td class='text' align='right'>
584 <?php if ($fstart) { ?>
585 <a href="javascript:submitList(-<?php echo attr($pagesize) ?>)">
586 &lt;&lt;
587 </a>
588 &nbsp;&nbsp;
589 <?php } ?>
590 <?php echo ($fstart + 1) . " - $fend of $count" ?>
591 &nbsp;&nbsp;
592 <a href="javascript:submitList(<?php echo attr($pagesize) ?>)">
593 &gt;&gt;
594 </a>
595 </td>
597 </tr>
598 </table>
600 </form>
602 <table border='0' cellpadding='5' cellspacing='0' width='96%'>
603 <tr>
604 <td><span class='bold'><?php echo xlt('Code'); ?></span></td>
605 <td><span class='bold'><?php echo xlt('Mod'); ?></span></td>
606 <td><span class='bold'><?php echo xlt('Act'); ?></span></td>
607 <td><span class='bold'><?php echo xlt('Dx Rep'); ?></span></td>
608 <td><span class='bold'><?php echo xlt('Serv Rep'); ?></span></td>
609 <td><span class='bold'><?php echo xlt('Type'); ?></span></td>
610 <td><span class='bold'><?php echo xlt('Description'); ?></span></td>
611 <td><span class='bold'><?php echo xlt('Short Description'); ?></span></td>
612 <?php if (related_codes_are_used()) { ?>
613 <td><span class='bold'><?php echo xlt('Related'); ?></span></td>
614 <?php } ?>
615 <?php
616 $pres = sqlStatement("SELECT title FROM list_options " .
617 "WHERE list_id = 'pricelevel' AND activity = 1 ORDER BY seq, title");
618 while ($prow = sqlFetchArray($pres)) {
619 echo " <td class='bold' align='right' nowrap>" . text(xl_list_label($prow['title'])) . "</td>\n";
622 <td></td>
623 <td></td>
624 </tr>
625 <?php
627 if (isset($_REQUEST['filter'])) {
628 $res = main_code_set_search($filter_key,$search,NULL,NULL,false,NULL,false,$fstart,($fend - $fstart),$filter_elements);
631 for ($i = 0; $row = sqlFetchArray($res); $i++) $all[$i] = $row;
633 if (!empty($all)) {
634 $count = 0;
635 foreach($all as $iter) {
636 $count++;
638 $has_fees = false;
639 foreach ($code_types as $key => $value) {
640 if ($value['id'] == $iter['code_type']) {
641 $has_fees = $value['fee'];
642 break;
646 echo " <tr>\n";
647 echo " <td class='text'>" . text($iter["code"]) . "</td>\n";
648 echo " <td class='text'>" . text($iter["modifier"]) . "</td>\n";
649 if ($iter["code_external"] > 0) {
650 // If there is no entry in codes sql table, then default to active
651 // (this is reason for including NULL below)
652 echo " <td class='text'>" . ( ($iter["active"] || $iter["active"]==NULL) ? xlt('Yes') : xlt('No')) . "</td>\n";
654 else {
655 echo " <td class='text'>" . ( ($iter["active"]) ? xlt('Yes') : xlt('No')) . "</td>\n";
657 echo " <td class='text'>" . ($iter["reportable"] ? xlt('Yes') : xlt('No')) . "</td>\n";
658 echo " <td class='text'>" . ($iter["financial_reporting"] ? xlt('Yes') : xlt('No')) . "</td>\n";
659 echo " <td class='text'>" . text($iter['code_type_name']) . "</td>\n";
660 echo " <td class='text'>" . text($iter['code_text']) . "</td>\n";
661 echo " <td class='text'>" . text($iter['code_text_short']) . "</td>\n";
663 if (related_codes_are_used()) {
664 // Show related codes.
665 echo " <td class='text'>";
666 $arel = explode(';', $iter['related_code']);
667 foreach ($arel as $tmp) {
668 list($reltype, $relcode) = explode(':', $tmp);
669 $code_description = lookup_code_descriptions($reltype.":".$relcode);
670 echo text($relcode) . ' ' . text(trim($code_description)) . '<br />';
672 echo "</td>\n";
675 $pres = sqlStatement("SELECT p.pr_price " .
676 "FROM list_options AS lo LEFT OUTER JOIN prices AS p ON " .
677 "p.pr_id = ? AND p.pr_selector = '' AND p.pr_level = lo.option_id " .
678 "WHERE lo.list_id = 'pricelevel' AND lo.activity = 1 ORDER BY lo.seq", array($iter['id']));
679 while ($prow = sqlFetchArray($pres)) {
680 echo "<td class='text' align='right'>" . text(bucks($prow['pr_price'])) . "</td>\n";
683 if ($iter["code_external"] > 0) {
684 echo " <td align='right'><a class='link' href='javascript:submitModify(\"" . attr($iter['code_type_name']) . "\",\"" . attr($iter['code']) . "\",\"" . attr($iter['id']) . "\")'>[" . xlt('Modify') . "]</a></td>\n";
686 else {
687 echo " <td align='right'><a class='link' href='javascript:submitDelete(" . attr($iter['id']) . ")'>[" . xlt('Delete') . "]</a></td>\n";
688 echo " <td align='right'><a class='link' href='javascript:submitEdit(" . attr($iter['id']) . ")'>[" . xlt('Edit') . "]</a></td>\n";
691 echo " </tr>\n";
698 </table>
700 </center>
702 <script language="JavaScript">
703 <?php
704 if ($alertmsg) {
705 echo "alert('" . addslashes($alertmsg) . "');\n";
708 </script>
710 </body>
711 </html>