Merge pull request #956 to fix therapy groups permissions
[openemr.git] / library / spreadsheet.inc.php
blob287b0b96290c310f562b24f8fb95f6e968d518f9
1 <?php
2 // Copyright (C) 2006-2011 Rod Roark <rod@sunsetsystems.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 include_once(dirname(__FILE__) . '/api.inc');
10 include_once(dirname(__FILE__) . '/forms.inc');
11 include_once(dirname(__FILE__) . '/../interface/forms/fee_sheet/codes.php');
13 $celltypes = array(
14 '0' => 'Unused',
15 '1' => 'Static',
16 '2' => 'Checkbox',
17 '3' => 'Text',
18 '4' => 'Longtext',
19 // '5' => 'Function',
22 // encode a string from a form field for database writing.
23 function form2db($fldval)
25 $fldval = trim($fldval);
26 $fldval = strip_escape_custom($fldval);
27 return $fldval;
30 // encode a plain string for database writing.
31 function real2db($fldval)
33 return addslashes($fldval);
36 // Get the actual string from a form field.
37 function form2real($fldval)
39 $fldval = trim($fldval);
40 $fldval = strip_escape_custom($fldval);
41 return $fldval;
44 // encode a plain string for html display.
45 function real2form($fldval)
47 return htmlspecialchars($fldval, ENT_QUOTES);
50 if (empty($spreadsheet_title)) {
51 $spreadsheet_title = 'Injury Log';
54 // Putting an error message in here will result in a javascript alert.
55 $alertmsg = '';
57 // Determine the encounter that we are working with.
58 $thisenc = empty($_GET['thisenc']) ? $encounter : $_GET['thisenc'] + 0;
60 // If we are invoked as a popup (not in an encounter):
61 $popup = $_GET['popup'];
63 // The form ID is passed to us when an existing encounter form is loaded.
64 $formid = $_GET['id'];
66 // $tempid is the currently selected template, if any.
67 $tempid = $_POST['form_template'] + 0;
69 // This is the start date to be saved with the spreadsheet.
70 $start_date = '';
72 $form_completed = '0';
74 if (!$popup && !$encounter) { // $encounter comes from globals.php
75 die("Internal error: we do not seem to be in an encounter!");
78 // Get the name of the template selected by the dropdown, if any;
79 // or if we are loading a form then it comes from that.
80 $template_name = '';
81 if ($tempid) {
82 $trow = sqlQuery("SELECT value FROM form_$spreadsheet_form_name WHERE " .
83 "id = $tempid AND rownbr = -1 AND colnbr = -1");
84 $template_name = $trow['value'];
85 } else if ($formid) {
86 $trow = sqlQuery("SELECT value FROM form_$spreadsheet_form_name WHERE " .
87 "id = $formid AND rownbr = -1 AND colnbr = -1");
88 list($form_completed, $start_date, $template_name) = explode('|', $trow['value'], 3);
91 if (!$start_date) {
92 $start_date = form2real($_POST['form_start_date']);
95 // Used rows and columns are those beyond which there are only unused cells.
96 $num_used_rows = 0;
97 $num_used_cols = 0;
99 // If we are saving...
101 if ($_POST['bn_save_form'] || $_POST['bn_save_template']) {
102 // The form data determines how many rows and columns are now used.
103 $cells = $_POST['cell'];
104 for ($i = 0; $i < count($cells); ++$i) {
105 $row = $cells[$i];
106 for ($j = 0; $j < count($row); ++$j) {
107 if (substr($row[$j], 0, 1)) {
108 if ($i >= $num_used_rows) {
109 $num_used_rows = $i + 1;
112 if ($j >= $num_used_cols) {
113 $num_used_cols = $j + 1;
119 if ($_POST['bn_save_form']) {
120 $form_completed = $_POST['form_completed'] ? '1' : '0';
122 // If updating an existing form...
123 if ($formid) {
124 sqlStatement("UPDATE form_$spreadsheet_form_name SET " .
125 "value = '$form_completed|$start_date|$template_name' " .
126 "WHERE id = '$formid' AND rownbr = -1 AND colnbr = -1");
127 sqlStatement("DELETE FROM form_$spreadsheet_form_name WHERE " .
128 "id = '$formid' AND rownbr >= 0 AND colnbr >= 0");
129 } // If adding a new form...
130 else {
131 $tmprow = sqlQuery(
132 "SELECT pid FROM form_encounter WHERE encounter = ? ORDER BY id DESC LIMIT 1",
133 array($thisenc)
135 $thispid = $tmprow['pid'];
136 sqlStatement("LOCK TABLES form_$spreadsheet_form_name WRITE, log WRITE");
137 $tmprow = sqlQuery("SELECT MAX(id) AS maxid FROM form_$spreadsheet_form_name");
138 $formid = $tmprow['maxid'] + 1;
139 if ($formid <= 0) {
140 $formid = 1;
143 sqlInsert("INSERT INTO form_$spreadsheet_form_name ( " .
144 "id, rownbr, colnbr, datatype, value " .
145 ") VALUES ( " .
146 "$formid, -1, -1, 0, " .
147 "'$form_completed|$start_date|$template_name' " .
148 ")");
149 sqlStatement("UNLOCK TABLES");
150 addForm(
151 $thisenc,
152 $spreadsheet_title,
153 $formid,
154 "$spreadsheet_form_name",
155 $thispid,
156 $userauthorized
160 $saveid = $formid;
161 } else { // saving a template
162 // The rule is, we can update the original name, or insert a new name
163 // which must not match any existing template name.
164 $new_template_name = form2real($_POST['form_new_template_name']);
165 if ($new_template_name != $template_name) {
166 $trow = sqlQuery("SELECT id FROM form_$spreadsheet_form_name WHERE " .
167 "id < 0 AND rownbr = -1 AND colnbr = -1 AND value = '" .
168 real2db($new_template_name) . "'");
169 if ($trow['id']) {
170 $alertmsg = "Template \"" . real2form($new_template_name) .
171 "\" already exists!";
172 } else {
173 $tempid = 0; // to force insert of new template
174 $template_name = $new_template_name;
178 if (!$alertmsg) {
179 // If updating an existing template...
180 if ($tempid) {
181 sqlStatement("DELETE FROM form_$spreadsheet_form_name WHERE " .
182 "id = '$tempid' AND rownbr >= 0 AND colnbr >= 0");
183 } // If adding a new template...
184 else {
185 sqlStatement("LOCK TABLES form_$spreadsheet_form_name WRITE, log WRITE");
186 $tmprow = sqlQuery("SELECT MIN(id) AS minid FROM form_$spreadsheet_form_name");
187 $tempid = $tmprow['minid'] - 1;
188 if ($tempid >= 0) {
189 $tempid = -1;
192 sqlInsert("INSERT INTO form_$spreadsheet_form_name ( " .
193 "id, rownbr, colnbr, datatype, value " .
194 ") VALUES ( " .
195 "$tempid, -1, -1, 0, " .
196 "'" . real2db($template_name) . "' " .
197 ")");
198 sqlStatement("UNLOCK TABLES");
201 $saveid = $tempid;
205 if (!$alertmsg) {
206 // Finally, save the table cells.
207 for ($i = 0; $i < $num_used_rows; ++$i) {
208 for ($j = 0; $j < $num_used_cols; ++$j) {
209 $tmp = $cells[$i][$j];
210 $celltype = substr($tmp, 0, 1) + 0;
211 $cellvalue = form2db(substr($tmp, 1));
212 if ($celltype) {
213 sqlInsert("INSERT INTO form_$spreadsheet_form_name ( " .
214 "id, rownbr, colnbr, datatype, value " .
215 ") VALUES ( " .
216 "$saveid, $i, $j, $celltype, '$cellvalue' )");
221 } else if ($_POST['bn_delete_template'] && $tempid) {
222 sqlStatement("DELETE FROM form_$spreadsheet_form_name WHERE " .
223 "id = '$tempid'");
224 $tempid = 0;
225 $template_name = '';
228 if ($_POST['bn_save_form'] && !$alertmsg && !$popup) {
229 formHeader("Redirecting....");
230 formJump();
231 formFooter();
232 exit;
235 // If we get here then we are displaying a spreadsheet, either a template or
236 // an encounter form.
238 // Get the array of template names.
239 $tres = sqlStatement("SELECT id, value FROM form_$spreadsheet_form_name WHERE " .
240 "id < 0 AND rownbr = -1 AND colnbr = -1 ORDER BY value");
242 $dres = false;
244 # If we are reloading a form, get it.
245 if ($formid) {
246 $dres = sqlStatement("SELECT * FROM form_$spreadsheet_form_name WHERE " .
247 "id = '$formid' ORDER BY rownbr, colnbr");
248 $tmprow = sqlQuery("SELECT MAX(rownbr) AS rowmax, MAX(colnbr) AS colmax " .
249 "FROM form_$spreadsheet_form_name WHERE id = '$formid'");
250 $num_used_rows = $tmprow['rowmax'] + 1;
251 $num_used_cols = $tmprow['colmax'] + 1;
252 } # Otherwise if we are editing a template, get it.
253 else if ($tempid) {
254 $dres = sqlStatement("SELECT * FROM form_$spreadsheet_form_name WHERE " .
255 "id = '$tempid' ORDER BY rownbr, colnbr");
256 $tmprow = sqlQuery("SELECT MAX(rownbr) AS rowmax, MAX(colnbr) AS colmax " .
257 "FROM form_$spreadsheet_form_name WHERE id = '$tempid'");
258 $num_used_rows = $tmprow['rowmax'] + 1;
259 $num_used_cols = $tmprow['colmax'] + 1;
262 // Virtual rows and columns are those available when in Edit Structure mode,
263 // and include some additional ones beyond those used. This allows quite a
264 // lot of stuff to be entered before having to save the template.
265 $num_virtual_rows = $num_used_rows ? $num_used_rows + 5 : 10;
266 $num_virtual_cols = $num_used_cols ? $num_used_cols + 5 : 10;
268 <html>
269 <head>
270 <?php html_header_show();?>
271 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
272 <style type="text/css">@import url(../../../library/dynarch_calendar.css);</style>
273 <style>
274 .sstable td {
275 font-family: sans-serif;
276 font-weight: bold;
277 font-size: 9pt;
279 .seltype {
280 font-family: sans-serif;
281 font-weight: normal;
282 font-size: 8pt;
283 background-color: transparent;
285 .selgen {
286 font-family: sans-serif;
287 font-weight: normal;
288 font-size: 8pt;
289 background-color: transparent;
291 .intext {
292 font-family: sans-serif;
293 font-weight: normal;
294 font-size: 9pt;
295 background-color: transparent;
296 width: 100%;
298 .seldiv {
299 margin: 0 0 0 0;
300 padding: 0 0 0 0;
302 </style>
303 <script type="text/javascript" src="../../../library/textformat.js"></script>
304 <script type="text/javascript" src="../../../library/dynarch_calendar.js"></script>
305 <script type="text/javascript" src="../../../library/dynarch_calendar_en.js"></script>
306 <script type="text/javascript" src="../../../library/dynarch_calendar_setup.js"></script>
308 <script language="JavaScript">
309 var mypcc = '<?php echo $GLOBALS['phone_country_code']; ?>';
310 var ssChanged = false; // if they have changed anything in the spreadsheet
311 var startDate = '<?php echo $start_date ? $start_date : date('Y-m-d'); ?>';
313 // In case we are a popup (top level) window, handle top.restoreSession() calls.
314 function restoreSession() {
315 return opener.top.restoreSession();
318 // Helper function to set the contents of a block.
319 function setBlockContent(id, content) {
320 if (document.getElementById) {
321 var x = document.getElementById(id);
322 x.innerHTML = '';
323 x.innerHTML = content;
325 else if (document.all) {
326 var x = document.all[id];
327 x.innerHTML = content;
329 // alert("ID = \"" + id + "\", string = \"" + content + "\"");
332 // Called when a different template name is selected.
333 function newTemplate(sel) {
334 if (ssChanged && !confirm('You have made changes that will be discarded ' +
335 'if you select a new template. Do you really want to do this?'))
337 // Restore the original template selection.
338 for (var i = 0; i < sel.options.length; ++i) {
339 if (sel.options[i].value == '<?php echo $tempid ?>') {
340 sel.options[i].selected = true;
343 return;
345 top.restoreSession();
346 document.forms[0].submit();
349 // Called when the Cancel button is clicked.
350 function doCancel() {
351 if (!ssChanged || confirm('You have made changes that will be discarded ' +
352 'if you close now. Click OK if you really want to exit this form.'))
354 <?php if ($popup) { ?>
355 window.close();
356 <?php } else { ?>
357 top.restoreSession();
358 location='<?php echo $GLOBALS['form_exit_url'] ?>';
359 <?php } ?>
363 // Called when the Edit Structure checkbox is clicked.
364 function editChanged() {
365 var f = document.forms[0];
366 var newdisplay = f.form_edit_template.checked ? '' : 'none';
367 var usedrows = 0;
368 var usedcols = 0;
369 for (var i = 0; i < <?php echo $num_virtual_rows; ?>; ++i) {
370 for (var j = 0; j < <?php echo $num_virtual_cols; ?>; ++j) {
371 if (f['cell['+i+']['+j+']'].value.charAt(0) != '0') {
372 if (i >= usedrows) usedrows = i + 1;
373 if (j >= usedcols) usedcols = j + 1;
377 for (var i = 0; i < <?php echo $num_virtual_rows; ?>; ++i) {
378 for (var j = 0; j < <?php echo $num_virtual_cols; ?>; ++j) {
379 // document.getElementById('div_'+i+'_'+j).style.display = newdisplay;
380 document.getElementById('sel_'+i+'_'+j).style.display = newdisplay;
381 if (i >= usedrows || j >= usedcols) {
382 document.getElementById('td_'+i+'_'+j).style.display = newdisplay;
388 // Prepare a string for use as an HTML value attribute in single quotes.
389 function escQuotes(s) {
390 return s.replace(/'/g, "&#39;");
393 // Parse static text to evaluate possible functions.
394 function genStatic(s) {
395 var i = 0;
397 // Parse "%day(n)".
398 while ((i = s.indexOf('%day(')) >= 0) {
399 var s1 = s.substring(0, i);
400 i += 5;
401 var j = s.indexOf(')', i);
402 if (j < 0) break;
403 var dayinc = parseInt(s.substring(i,j));
404 var mydate = new Date(parseInt(startDate.substring(0,4)),
405 parseInt(startDate.substring(5,7))-1, parseInt(startDate.substring(8)));
406 mydate.setTime(1000 * 60 * 60 * 24 * dayinc + mydate.getTime());
407 var year = mydate.getYear(); if (year < 1900) year += 1900;
408 s = s1 + year + '-' +
409 ('' + (mydate.getMonth() + 101)).substring(1) + '-' +
410 ('' + (mydate.getDate() + 100)).substring(1) +
411 s.substring(j + 1);
414 // Parse "%sel(first,second,third,...,default)".
415 while ((i = s.indexOf('%sel(')) >= 0) {
416 var s1 = s.substring(0, i);
417 i += 5;
418 var j = s.indexOf(')', i);
419 if (j < 0) break;
420 var x = s.substring(0,j);
421 var k = x.lastIndexOf(',');
422 if (k < i) break;
423 var dflt = s.substring(k+1, j);
424 x = "<select class='selgen' onchange='newsel(this)'>";
425 while ((k = s.indexOf(',', i)) > i) {
426 if (k > j) break;
427 var elem = s.substring(i,k);
428 x += "<option value='" + elem + "'";
429 if (elem == dflt) x += " selected";
430 x += ">" + elem + "</option>";
431 i = k + 1;
433 x += "</select>";
434 s = s1 + x + s.substring(j + 1);
435 break; // only one %sel allowed
438 // Parse "%ptp(default)".
439 while ((i = s.indexOf('%ptp(')) >= 0) {
440 var s1 = s.substring(0, i);
441 i += 5;
442 var j = s.indexOf(')', i);
443 if (j < 0) break;
444 var dflt = s.substring(i, j);
445 x = "<select class='selgen' onchange='newptp(this)'>";
446 x += "<option value=''>-- Select --</option>";
447 <?php
448 foreach ($bcodes['Phys']['Physiotherapy Procedures'] as $key => $value) {
449 echo " x += \"<option value='$key'\";\n";
450 echo " if (dflt == '$key') x += ' selected';\n";
451 echo " x += '>$value</option>';\n";
454 x += "</select>";
455 s = s1 + x + s.substring(j + 1);
456 break; // only one %ptp allowed
459 return s;
462 // Called when a cell type selector in the spreadsheet is clicked.
463 function newType(i,j) {
464 ssChanged = true;
465 var f = document.forms[0];
466 var typeval = f['cell['+i+']['+j+']'].value;
467 var thevalue = typeval.substring(1);
468 var thetype = document.getElementById('sel_'+i+'_'+j).value;
469 var s = "<input type='hidden' name='cell[" + i + "][" + j + "]' " +
470 "value='" + thetype + escQuotes(thevalue) + "' />";
472 if (thetype == '1') {
473 s += genStatic(thevalue);
475 else if (thetype == '2') {
476 s += "<input type='checkbox' value='1' onclick='cbClick(this," + i + "," + j + ")'";
477 if (thevalue) s += " checked";
478 s += " />";
480 else if (thetype == '3') {
481 s += "<input type='text' onchange='textChange(this," + i + "," + j + ")'" +
482 " class='intext' value='" + escQuotes(thevalue) + "' size='12' />";
484 else if (thetype == '4') {
485 s += "<textarea rows='3' cols='25' wrap='virtual' class='intext' " +
486 "onchange='longChange(this," + i + "," + j + ")'>" +
487 escQuotes(thevalue) + "</textarea>";
489 setBlockContent('vis_' + i + '_' + j, s);
492 // Called when a checkbox in the spreadsheet is clicked.
493 function cbClick(elem,i,j) {
494 ssChanged = true;
495 var f = document.forms[0];
496 var cell = f['cell['+i+']['+j+']'];
497 cell.value = '2' + (elem.checked ? '1' : '');
500 // Called when a text value in the spreadsheet is changed.
501 function textChange(elem,i,j) {
502 ssChanged = true;
503 var f = document.forms[0];
504 var cell = f['cell['+i+']['+j+']'];
505 cell.value = '3' + elem.value;
508 // Called when a textarea value in the spreadsheet is changed.
509 function longChange(elem,i,j) {
510 ssChanged = true;
511 var f = document.forms[0];
512 var cell = f['cell['+i+']['+j+']'];
513 cell.value = '4' + elem.value;
516 // Helper function to get the value element of a table cell given any
517 // other element within that cell.
518 function getHidden(sel) {
519 var p = sel.parentNode;
520 while (p.tagName != 'TD') {
521 if (!p.parentNode || p.parentNode == p) {
522 alert("JavaScript error, cannot find TD element");
523 return '';
525 p = p.parentNode;
527 // Get the <input type=hidden> element within this table cell.
528 var f = document.forms[0];
529 var s = p.id.substring(3);
530 var uix = s.indexOf('_');
531 var i = s.substring(0, uix);
532 var j = s.substring(uix+1);
533 return f['cell[' + i + '][' + j + ']'];
536 // Called when a user-defined select list has a new selection.
537 // This rewrites the function definition for the select list.
538 function newsel(sel) {
539 var inelem = getHidden(sel);
540 var s = inelem.value;
541 var i = s.indexOf('%sel(');
542 var j = s.indexOf(')', i);
543 var x = s.substring(0, j);
544 var k = x.lastIndexOf(',');
545 inelem.value = s.substring(0, k+1) + sel.value + s.substring(j);
548 // Called when a physiotherapy select list has a new selection.
549 // This rewrites the function definition for the select list.
550 function newptp(sel) {
551 var inelem = getHidden(sel);
552 var s = inelem.value;
553 var i = s.indexOf('%ptp(') + 5;
554 var j = s.indexOf(')', i);
555 inelem.value = s.substring(0, i) + sel.value + s.substring(j);
558 </script>
560 </head>
562 <body class="body_top">
563 <form method="post" action="<?php echo "$rootdir/forms/$spreadsheet_form_name/new.php?id=$formid&thisenc=$thisenc";
564 if ($popup) {
565 echo '&popup=1';
566 } ?>"
567 onsubmit="return top.restoreSession()">
568 <center>
570 <table border='0' cellpadding='5' cellspacing='0' style='margin:8pt'>
571 <tr bgcolor='#ddddff'>
572 <td>
573 <?php xl('Start Date', 'e'); ?>:
574 <input type='text' name='form_start_date' id='form_start_date'
575 size='10' value='<?php echo $start_date; ?>'
576 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' title='yyyy-mm-dd'
577 <?php if ($formid && $start_date) {
578 echo 'disabled ';
579 } ?>/>
580 <?php if (!$formid || !$start_date) { ?>
581 <img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22'
582 id='img_start_date' border='0' alt='[?]' style='cursor:pointer'
583 title='Click here to choose a date'>
584 <?php } ?>
585 &nbsp;
586 <?php xl('Template:', 'e') ?>
587 <select name='form_template' onchange='newTemplate(this)'<?php if ($formid) {
588 echo ' disabled';
589 } ?>>
590 <option value='0'>-- Select --</option>
591 <?php
592 while ($trow = sqlFetchArray($tres)) {
593 echo " <option value='" . $trow['id'] . "'";
594 if ($tempid && $tempid == $trow['id'] ||
595 $formid && $template_name == $trow['value']) {
596 echo " selected";
599 echo ">" . $trow['value'] . "</option>\n";
602 </select>
603 &nbsp;
604 <input type='checkbox' name='form_edit_template'
605 onclick='editChanged()'
606 title='<?php xl("If you want to change data types, or add rows or columns", "e") ?>' />
607 <?php xl('Edit Structure', 'e') ?>
608 <?php if ($formid) { ?>
609 &nbsp;
610 <input type='checkbox' name='form_completed'
611 title='<?php xl("If all data for all columns are complete for this form", "e") ?>'
612 <?php if ($form_completed) {
613 echo 'checked ';
614 } ?>/>
615 <?php xl('Completed', 'e') ?>
616 <?php } ?>
617 </td>
618 </tr>
619 </table>
621 <table border='1' cellpadding='2' cellspacing='0' class='sstable'>
622 <?php
623 if ($dres) {
624 $drow = sqlFetchArray($dres);
627 $typeprompts = array('unused','static','checkbox','text');
629 for ($i = 0; $i < $num_virtual_rows; ++$i) {
630 echo " <tr>\n";
631 for ($j = 0; $j < $num_virtual_cols; ++$j) {
632 // Match up with the database for cell type and value.
633 $celltype = '0';
634 $cellvalue = '';
635 if ($dres) {
636 while ($drow && $drow['rownbr'] < $i) {
637 $drow = sqlFetchArray($dres);
640 while ($drow && $drow['rownbr'] == $i && $drow['colnbr'] < $j) {
641 $drow = sqlFetchArray($dres);
644 if ($drow && $drow['rownbr'] == $i && $drow['colnbr'] == $j) {
645 $celltype = $drow['datatype'];
646 $cellvalue = real2form($drow['value']);
647 $cellstatic = addslashes($drow['value']);
651 echo " <td id='td_${i}_${j}' valign='top'";
652 if ($i >= $num_used_rows || $j >= $num_used_cols) {
653 echo " style='display:none'";
656 echo ">";
658 /*****************************************************************
659 echo "<span id='div_${i}_${j}' ";
660 echo "style='float:right;cursor:pointer;display:none' ";
661 echo "onclick='newType($i,$j)'>[";
662 echo $typeprompts[$celltype];
663 echo "]</span>";
664 *****************************************************************/
665 echo "<div class='seldiv'>";
666 echo "<select id='sel_${i}_${j}' class='seltype' style='display:none' " .
667 "onchange='newType($i,$j)'>";
668 foreach ($celltypes as $key => $value) {
669 echo "<option value='$key'";
670 if ($key == $celltype) {
671 echo " selected";
674 echo ">$value</option>";
677 echo "</select>";
678 echo "</div>";
679 /****************************************************************/
681 echo "<span id='vis_${i}_${j}'>"; // new //
683 echo "<input type='hidden' name='cell[$i][$j]' value='$celltype$cellvalue' />";
684 if ($celltype == '1') {
685 // So we don't have to write a PHP version of genStatic():
686 echo "<script language='JavaScript'>document.write(genStatic('$cellstatic'));</script>";
687 } else if ($celltype == '2') {
688 echo "<input type='checkbox' value='1' onclick='cbClick(this,$i,$j)'";
689 if ($cellvalue) {
690 echo " checked";
693 echo " />";
694 } else if ($celltype == '3') {
695 echo "<input type='text' class='intext' onchange='textChange(this,$i,$j)'";
696 echo " value='$cellvalue'";
697 echo " size='12' />";
698 } else if ($celltype == '4') {
699 echo "<textarea rows='3' cols='25' wrap='virtual' class='intext' " .
700 "onchange='longChange(this,$i,$j)'>";
701 echo $cellvalue;
702 echo "</textarea>";
705 echo "</span>"; // new //
707 echo "</td>\n";
710 echo " </tr>\n";
713 </table>
716 <input type='submit' name='bn_save_form' value='Save Form' />
717 <?php if (!$formid) { ?>
718 &nbsp;
719 <input type='submit' name='bn_save_template' value='Save as Template:' />
720 &nbsp;
721 <input type='text' name='form_new_template_name' value='<?php echo $template_name ?>' />
722 &nbsp;
723 <input type='submit' name='bn_delete_template' value='Delete Template' />
724 <?php } ?>
725 &nbsp;
726 <input type='button' value='Cancel' onclick="doCancel()" />
727 </p>
729 </center>
730 </form>
731 <script language='JavaScript'>
732 Calendar.setup({inputField:"form_start_date", ifFormat:"%Y-%m-%d", button:"img_start_date"});
733 <?php
734 if ($alertmsg) {
735 echo " alert('$alertmsg');\n";
738 </script>
739 </body>
740 </html>