Added CAMOS form and 'Patient Photograph' document category to pre-installed.
[openemr.git] / library / spreadsheet.inc.php
blob3024c8fff094424f29132f0350e513b2fc7f574a
1 <?php
2 // Copyright (C) 2006-2007 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) {
24 $fldval = trim($fldval);
25 if (!get_magic_quotes_gpc()) $fldval = addslashes($fldval);
26 return $fldval;
29 // encode a plain string for database writing.
30 function real2db($fldval) {
31 return addslashes($fldval);
34 // Get the actual string from a form field.
35 function form2real($fldval) {
36 $fldval = trim($fldval);
37 if (get_magic_quotes_gpc()) $fldval = stripslashes($fldval);
38 return $fldval;
41 // encode a plain string for html display.
42 function real2form($fldval) {
43 return htmlspecialchars($fldval, ENT_QUOTES);
46 // Putting an error message in here will result in a javascript alert.
47 $alertmsg = '';
49 // If we are invoked as a popup (not in an encounter):
50 $popup = $_GET['popup'];
52 // The form ID is passed to us when an existing encounter form is loaded.
53 $formid = $_GET['id'];
55 // $tempid is the currently selected template, if any.
56 $tempid = $_POST['form_template'] + 0;
58 // This is the start date to be saved with the spreadsheet.
59 $start_date = '';
61 $form_completed = '0';
63 if (!$popup && !$encounter) { // $encounter comes from globals.php
64 die("Internal error: we do not seem to be in an encounter!");
67 // Get the name of the template selected by the dropdown, if any;
68 // or if we are loading a form then it comes from that.
69 $template_name = '';
70 if ($tempid) {
71 $trow = sqlQuery("SELECT value FROM form_$spreadsheet_form_name WHERE " .
72 "id = $tempid AND rownbr = -1 AND colnbr = -1");
73 $template_name = $trow['value'];
75 else if ($formid) {
76 $trow = sqlQuery("SELECT value FROM form_$spreadsheet_form_name WHERE " .
77 "id = $formid AND rownbr = -1 AND colnbr = -1");
78 list($form_completed, $start_date, $template_name) = explode('|', $trow['value'], 3);
81 if (!$start_date) $start_date = form2real($_POST['form_start_date']);
83 // Used rows and columns are those beyond which there are only unused cells.
84 $num_used_rows = 0;
85 $num_used_cols = 0;
87 // If we are saving...
89 if ($_POST['bn_save_form'] || $_POST['bn_save_template']) {
91 // The form data determines how many rows and columns are now used.
92 $cells = $_POST['cell'];
93 for ($i = 0; $i < count($cells); ++$i) {
94 $row = $cells[$i];
95 for ($j = 0; $j < count($row); ++$j) {
96 if (substr($row[$j], 0, 1)) {
97 if ($i >= $num_used_rows) $num_used_rows = $i + 1;
98 if ($j >= $num_used_cols) $num_used_cols = $j + 1;
103 if ($_POST['bn_save_form']) {
104 $form_completed = $_POST['form_completed'] ? '1' : '0';
106 // If updating an existing form...
107 if ($formid) {
108 sqlStatement("UPDATE form_$spreadsheet_form_name SET " .
109 "value = '$form_completed|$start_date|$template_name' " .
110 "WHERE id = '$formid' AND rownbr = -1 AND colnbr = -1");
111 sqlStatement("DELETE FROM form_$spreadsheet_form_name WHERE " .
112 "id = '$formid' AND rownbr >= 0 AND colnbr >= 0");
114 // If adding a new form...
115 else {
116 sqlStatement("LOCK TABLES form_$spreadsheet_form_name WRITE");
117 $tmprow = sqlQuery("SELECT MAX(id) AS maxid FROM form_$spreadsheet_form_name");
118 $formid = $tmprow['maxid'] + 1;
119 if ($formid <= 0) $formid = 1;
120 sqlInsert("INSERT INTO form_$spreadsheet_form_name ( " .
121 "id, rownbr, colnbr, datatype, value " .
122 ") VALUES ( " .
123 "$formid, -1, -1, 0, " .
124 "'$form_completed|$start_date|$template_name' " .
125 ")");
126 sqlStatement("UNLOCK TABLES");
127 addForm($encounter, "Injury Log", $formid, "$spreadsheet_form_name",
128 $pid, $userauthorized);
130 $saveid = $formid;
132 else { // saving a template
133 // The rule is, we can update the original name, or insert a new name
134 // which must not match any existing template name.
135 $new_template_name = form2real($_POST['form_new_template_name']);
136 if ($new_template_name != $template_name) {
137 $trow = sqlQuery("SELECT id FROM form_$spreadsheet_form_name WHERE " .
138 "id < 0 AND rownbr = -1 AND colnbr = -1 AND value = '" .
139 real2db($new_template_name) . "'");
140 if ($trow['id']) {
141 $alertmsg = "Template \"" . real2form($new_template_name) .
142 "\" already exists!";
144 else {
145 $tempid = 0; // to force insert of new template
146 $template_name = $new_template_name;
149 if (!$alertmsg) {
150 // If updating an existing template...
151 if ($tempid) {
152 sqlStatement("DELETE FROM form_$spreadsheet_form_name WHERE " .
153 "id = '$tempid' AND rownbr >= 0 AND colnbr >= 0");
155 // If adding a new template...
156 else {
157 sqlStatement("LOCK TABLES form_$spreadsheet_form_name WRITE");
158 $tmprow = sqlQuery("SELECT MIN(id) AS minid FROM form_$spreadsheet_form_name");
159 $tempid = $tmprow['minid'] - 1;
160 if ($tempid >= 0) $tempid = -1;
161 sqlInsert("INSERT INTO form_$spreadsheet_form_name ( " .
162 "id, rownbr, colnbr, datatype, value " .
163 ") VALUES ( " .
164 "$tempid, -1, -1, 0, " .
165 "'" . real2db($template_name) . "' " .
166 ")");
167 sqlStatement("UNLOCK TABLES");
169 $saveid = $tempid;
173 if (!$alertmsg) {
174 // Finally, save the table cells.
175 for ($i = 0; $i < $num_used_rows; ++$i) {
176 for ($j = 0; $j < $num_used_cols; ++$j) {
177 $tmp = $cells[$i][$j];
178 $celltype = substr($tmp, 0, 1) + 0;
179 $cellvalue = form2db(substr($tmp, 1));
180 if ($celltype) {
181 sqlInsert("INSERT INTO form_$spreadsheet_form_name ( " .
182 "id, rownbr, colnbr, datatype, value " .
183 ") VALUES ( " .
184 "$saveid, $i, $j, $celltype, '$cellvalue' )");
190 else if ($_POST['bn_delete_template'] && $tempid) {
191 sqlStatement("DELETE FROM form_$spreadsheet_form_name WHERE " .
192 "id = '$tempid'");
193 $tempid = 0;
194 $template_name = '';
197 if ($_POST['bn_save_form'] && !$alertmsg && !$popup) {
198 formHeader("Redirecting....");
199 formJump();
200 formFooter();
201 exit;
204 // If we get here then we are displaying a spreadsheet, either a template or
205 // an encounter form.
207 // Get the array of template names.
208 $tres = sqlStatement("SELECT id, value FROM form_$spreadsheet_form_name WHERE " .
209 "id < 0 AND rownbr = -1 AND colnbr = -1 ORDER BY value");
211 $dres = false;
213 # If we are reloading a form, get it.
214 if ($formid) {
215 $dres = sqlStatement("SELECT * FROM form_$spreadsheet_form_name WHERE " .
216 "id = '$formid' ORDER BY rownbr, colnbr");
217 $tmprow = sqlQuery("SELECT MAX(rownbr) AS rowmax, MAX(colnbr) AS colmax " .
218 "FROM form_$spreadsheet_form_name WHERE id = '$formid'");
219 $num_used_rows = $tmprow['rowmax'] + 1;
220 $num_used_cols = $tmprow['colmax'] + 1;
222 # Otherwise if we are editing a template, get it.
223 else if ($tempid) {
224 $dres = sqlStatement("SELECT * FROM form_$spreadsheet_form_name WHERE " .
225 "id = '$tempid' ORDER BY rownbr, colnbr");
226 $tmprow = sqlQuery("SELECT MAX(rownbr) AS rowmax, MAX(colnbr) AS colmax " .
227 "FROM form_$spreadsheet_form_name WHERE id = '$tempid'");
228 $num_used_rows = $tmprow['rowmax'] + 1;
229 $num_used_cols = $tmprow['colmax'] + 1;
232 // Virtual rows and columns are those available when in Edit Structure mode,
233 // and include some additional ones beyond those used. This allows quite a
234 // lot of stuff to be entered before having to save the template.
235 $num_virtual_rows = $num_used_rows ? $num_used_rows + 5 : 10;
236 $num_virtual_cols = $num_used_cols ? $num_used_cols + 5 : 10;
238 <html>
239 <head>
240 <link rel=stylesheet href="<?echo $css_header;?>" type="text/css">
241 <style type="text/css">@import url(../../../library/dynarch_calendar.css);</style>
242 <style>
243 .sstable td {
244 font-family: sans-serif;
245 font-weight: bold;
246 font-size: 9pt;
248 .seltype {
249 font-family: sans-serif;
250 font-weight: normal;
251 font-size: 8pt;
252 background-color: transparent;
254 .selgen {
255 font-family: sans-serif;
256 font-weight: normal;
257 font-size: 8pt;
258 background-color: transparent;
260 .intext {
261 font-family: sans-serif;
262 font-weight: normal;
263 font-size: 9pt;
264 background-color: transparent;
265 width: 100%;
267 .seldiv {
268 margin: 0 0 0 0;
269 padding: 0 0 0 0;
271 </style>
272 <script type="text/javascript" src="../../../library/textformat.js"></script>
273 <script type="text/javascript" src="../../../library/dynarch_calendar.js"></script>
274 <script type="text/javascript" src="../../../library/dynarch_calendar_en.js"></script>
275 <script type="text/javascript" src="../../../library/dynarch_calendar_setup.js"></script>
277 <script language="JavaScript">
278 var mypcc = '<?php echo $GLOBALS['phone_country_code']; ?>';
279 var ssChanged = false; // if they have changed anything in the spreadsheet
280 var startDate = '<?php echo $start_date ? $start_date : date('Y-m-d'); ?>';
282 // Helper function to set the contents of a block.
283 function setBlockContent(id, content) {
284 if (document.getElementById) {
285 var x = document.getElementById(id);
286 x.innerHTML = '';
287 x.innerHTML = content;
289 else if (document.all) {
290 var x = document.all[id];
291 x.innerHTML = content;
293 // alert("ID = \"" + id + "\", string = \"" + content + "\"");
296 // Called when a different template name is selected.
297 function newTemplate(sel) {
298 if (ssChanged && !confirm('You have made changes that will be discarded ' +
299 'if you select a new template. Do you really want to do this?'))
301 // Restore the original template selection.
302 for (var i = 0; i < sel.options.length; ++i) {
303 if (sel.options[i].value == '<?php echo $tempid ?>') {
304 sel.options[i].selected = true;
307 return;
309 top.restoreSession();
310 document.forms[0].submit();
313 // Called when the Cancel button is clicked.
314 function doCancel() {
315 if (!ssChanged || confirm('You have made changes that will be discarded ' +
316 'if you close now. Click OK if you really want to exit this form.'))
318 <?php if ($popup) { ?>
319 window.close();
320 <?php } else { ?>
321 top.restoreSession();
322 location='<?php echo $GLOBALS['form_exit_url'] ?>';
323 <?php } ?>
327 // Called when the Edit Structure checkbox is clicked.
328 function editChanged() {
329 var f = document.forms[0];
330 var newdisplay = f.form_edit_template.checked ? '' : 'none';
331 var usedrows = 0;
332 var usedcols = 0;
333 for (var i = 0; i < <?php echo $num_virtual_rows; ?>; ++i) {
334 for (var j = 0; j < <?php echo $num_virtual_cols; ?>; ++j) {
335 if (f['cell['+i+']['+j+']'].value.charAt(0) != '0') {
336 if (i >= usedrows) usedrows = i + 1;
337 if (j >= usedcols) usedcols = j + 1;
341 for (var i = 0; i < <?php echo $num_virtual_rows; ?>; ++i) {
342 for (var j = 0; j < <?php echo $num_virtual_cols; ?>; ++j) {
343 // document.getElementById('div_'+i+'_'+j).style.display = newdisplay;
344 document.getElementById('sel_'+i+'_'+j).style.display = newdisplay;
345 if (i >= usedrows || j >= usedcols) {
346 document.getElementById('td_'+i+'_'+j).style.display = newdisplay;
352 // Prepare a string for use as an HTML value attribute in single quotes.
353 function escQuotes(s) {
354 return s.replace(/'/g, "&#39;");
357 // Parse static text to evaluate possible functions.
358 function genStatic(s) {
359 var i = 0;
361 // Parse "%day(n)".
362 while ((i = s.indexOf('%day(')) >= 0) {
363 var s1 = s.substring(0, i);
364 i += 5;
365 var j = s.indexOf(')', i);
366 if (j < 0) break;
367 var dayinc = parseInt(s.substring(i,j));
368 var mydate = new Date(parseInt(startDate.substring(0,4)),
369 parseInt(startDate.substring(5,7))-1, parseInt(startDate.substring(8)));
370 mydate.setTime(1000 * 60 * 60 * 24 * dayinc + mydate.getTime());
371 var year = mydate.getYear(); if (year < 1900) year += 1900;
372 s = s1 + year + '-' +
373 ('' + (mydate.getMonth() + 101)).substring(1) + '-' +
374 ('' + (mydate.getDate() + 100)).substring(1) +
375 s.substring(j + 1);
378 // Parse "%sel(first,second,third,...,default)".
379 while ((i = s.indexOf('%sel(')) >= 0) {
380 var s1 = s.substring(0, i);
381 i += 5;
382 var j = s.indexOf(')', i);
383 if (j < 0) break;
384 var x = s.substring(0,j);
385 var k = x.lastIndexOf(',');
386 if (k < i) break;
387 var dflt = s.substring(k+1, j);
388 x = "<select class='selgen' onchange='newsel(this)'>";
389 while ((k = s.indexOf(',', i)) > i) {
390 if (k > j) break;
391 var elem = s.substring(i,k);
392 x += "<option value='" + elem + "'";
393 if (elem == dflt) x += " selected";
394 x += ">" + elem + "</option>";
395 i = k + 1;
397 x += "</select>";
398 s = s1 + x + s.substring(j + 1);
399 break; // only one %sel allowed
402 // Parse "%ptp(default)".
403 while ((i = s.indexOf('%ptp(')) >= 0) {
404 var s1 = s.substring(0, i);
405 i += 5;
406 var j = s.indexOf(')', i);
407 if (j < 0) break;
408 var dflt = s.substring(i, j);
409 x = "<select class='selgen' onchange='newptp(this)'>";
410 x += "<option value=''>-- Select --</option>";
411 <?php
412 foreach ($bcodes['PTCJ']['Physiotherapy Procedures'] as $key => $value) {
413 echo " x += \"<option value='$key'\";\n";
414 echo " if (dflt == '$key') x += ' selected';\n";
415 echo " x += '>$value</option>';\n";
418 x += "</select>";
419 s = s1 + x + s.substring(j + 1);
420 break; // only one %ptp allowed
423 return s;
426 // Called when a cell type selector in the spreadsheet is clicked.
427 function newType(i,j) {
428 ssChanged = true;
429 var f = document.forms[0];
430 var typeval = f['cell['+i+']['+j+']'].value;
431 var thevalue = typeval.substring(1);
432 var thetype = document.getElementById('sel_'+i+'_'+j).value;
433 var s = "<input type='hidden' name='cell[" + i + "][" + j + "]' " +
434 "value='" + thetype + escQuotes(thevalue) + "' />";
436 if (thetype == '1') {
437 s += genStatic(thevalue);
439 else if (thetype == '2') {
440 s += "<input type='checkbox' value='1' onclick='cbClick(this," + i + "," + j + ")'";
441 if (thevalue) s += " checked";
442 s += " />";
444 else if (thetype == '3') {
445 s += "<input type='text' onchange='textChange(this," + i + "," + j + ")'" +
446 " class='intext' value='" + escQuotes(thevalue) + "' size='12' />";
448 else if (thetype == '4') {
449 s += "<textarea rows='3' cols='25' wrap='virtual' class='intext' " +
450 "onchange='longChange(this," + i + "," + j + ")'>" +
451 escQuotes(thevalue) + "</textarea>";
453 setBlockContent('vis_' + i + '_' + j, s);
456 // Called when a checkbox in the spreadsheet is clicked.
457 function cbClick(elem,i,j) {
458 ssChanged = true;
459 var f = document.forms[0];
460 var cell = f['cell['+i+']['+j+']'];
461 cell.value = '2' + (elem.checked ? '1' : '');
464 // Called when a text value in the spreadsheet is changed.
465 function textChange(elem,i,j) {
466 ssChanged = true;
467 var f = document.forms[0];
468 var cell = f['cell['+i+']['+j+']'];
469 cell.value = '3' + elem.value;
472 // Called when a textarea value in the spreadsheet is changed.
473 function longChange(elem,i,j) {
474 ssChanged = true;
475 var f = document.forms[0];
476 var cell = f['cell['+i+']['+j+']'];
477 cell.value = '4' + elem.value;
480 // Helper function to get the value element of a table cell given any
481 // other element within that cell.
482 function getHidden(sel) {
483 var p = sel.parentNode;
484 while (p.tagName != 'TD') {
485 if (!p.parentNode || p.parentNode == p) {
486 alert("JavaScript error, cannot find TD element");
487 return '';
489 p = p.parentNode;
491 // Get the <input type=hidden> element within this table cell.
492 var f = document.forms[0];
493 var s = p.id.substring(3);
494 var uix = s.indexOf('_');
495 var i = s.substring(0, uix);
496 var j = s.substring(uix+1);
497 return f['cell[' + i + '][' + j + ']'];
500 // Called when a user-defined select list has a new selection.
501 // This rewrites the function definition for the select list.
502 function newsel(sel) {
503 var inelem = getHidden(sel);
504 var s = inelem.value;
505 var i = s.indexOf('%sel(');
506 var j = s.indexOf(')', i);
507 var x = s.substring(0, j);
508 var k = x.lastIndexOf(',');
509 inelem.value = s.substring(0, k+1) + sel.value + s.substring(j);
512 // Called when a physiotherapy select list has a new selection.
513 // This rewrites the function definition for the select list.
514 function newptp(sel) {
515 var inelem = getHidden(sel);
516 var s = inelem.value;
517 var i = s.indexOf('%ptp(') + 5;
518 var j = s.indexOf(')', i);
519 inelem.value = s.substring(0, i) + sel.value + s.substring(j);
522 </script>
524 </head>
526 <body <?echo $top_bg_line;?> topmargin="0" rightmargin="0" leftmargin="0"
527 bottommargin="0" marginwidth="0" marginheight="0">
528 <form method="post" action="<?php echo "$rootdir/forms/$spreadsheet_form_name/new.php?id=$formid"; if ($popup) echo '&popup=1'; ?>"
529 onsubmit="return top.restoreSession()">
530 <center>
532 <table border='0' cellpadding='5' cellspacing='0' style='margin:8pt'>
533 <tr bgcolor='#ddddff'>
534 <td>
535 <?php xl('Start Date','e'); ?>:
536 <input type='text' name='form_start_date' id='form_start_date'
537 size='10' value='<?php echo $start_date; ?>'
538 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' title='yyyy-mm-dd'
539 <?php if ($formid && $start_date) echo 'disabled '; ?>/>
540 <?php if (!$formid || !$start_date) { ?>
541 <img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22'
542 id='img_start_date' border='0' alt='[?]' style='cursor:pointer'
543 title='Click here to choose a date'>
544 <?php } ?>
545 &nbsp;
546 <?php xl('Template:','e') ?>
547 <select name='form_template' onchange='newTemplate(this)'<?php if ($formid) echo ' disabled'; ?>>
548 <option value='0'>-- Select --</option>
549 <?php
550 while ($trow = sqlFetchArray($tres)) {
551 echo " <option value='" . $trow['id'] . "'";
552 if ($tempid && $tempid == $trow['id'] ||
553 $formid && $template_name == $trow['value'])
555 echo " selected";
557 echo ">" . $trow['value'] . "</option>\n";
560 </select>
561 &nbsp;
562 <input type='checkbox' name='form_edit_template'
563 onclick='editChanged()'
564 title='<?php xl("If you want to change data types, or add rows or columns","e") ?>' />
565 <?php xl('Edit Structure','e') ?>
566 <?php if ($formid) { ?>
567 &nbsp;
568 <input type='checkbox' name='form_completed'
569 title='<?php xl("If all data for all columns are complete for this form","e") ?>'
570 <?php if ($form_completed) echo 'checked '; ?>/>
571 <?php xl('Completed','e') ?>
572 <?php } ?>
573 </td>
574 </tr>
575 </table>
577 <table border='1' cellpadding='2' cellspacing='0' class='sstable'>
578 <?php
579 if ($dres) $drow = sqlFetchArray($dres);
580 $typeprompts = array('unused','static','checkbox','text');
582 for ($i = 0; $i < $num_virtual_rows; ++$i) {
583 echo " <tr>\n";
584 for ($j = 0; $j < $num_virtual_cols; ++$j) {
586 // Match up with the database for cell type and value.
587 $celltype = '0';
588 $cellvalue = '';
589 if ($dres) {
590 while ($drow && $drow['rownbr'] < $i)
591 $drow = sqlFetchArray($dres);
592 while ($drow && $drow['rownbr'] == $i && $drow['colnbr'] < $j)
593 $drow = sqlFetchArray($dres);
594 if ($drow && $drow['rownbr'] == $i && $drow['colnbr'] == $j) {
595 $celltype = $drow['datatype'];
596 $cellvalue = real2form($drow['value']);
597 $cellstatic = addslashes($drow['value']);
601 echo " <td id='td_${i}_${j}' valign='top'";
602 if ($i >= $num_used_rows || $j >= $num_used_cols)
603 echo " style='display:none'";
604 echo ">";
606 /*****************************************************************
607 echo "<span id='div_${i}_${j}' ";
608 echo "style='float:right;cursor:pointer;display:none' ";
609 echo "onclick='newType($i,$j)'>[";
610 echo $typeprompts[$celltype];
611 echo "]</span>";
612 *****************************************************************/
613 echo "<div class='seldiv'>";
614 echo "<select id='sel_${i}_${j}' class='seltype' style='display:none' " .
615 "onchange='newType($i,$j)'>";
616 foreach ($celltypes as $key => $value) {
617 echo "<option value='$key'";
618 if ($key == $celltype) echo " selected";
619 echo ">$value</option>";
621 echo "</select>";
622 echo "</div>";
623 /****************************************************************/
625 echo "<span id='vis_${i}_${j}'>"; // new //
627 echo "<input type='hidden' name='cell[$i][$j]' value='$celltype$cellvalue' />";
628 if ($celltype == '1') {
629 // So we don't have to write a PHP version of genStatic():
630 echo "<script language='JavaScript'>document.write(genStatic('$cellstatic'));</script>";
632 else if ($celltype == '2') {
633 echo "<input type='checkbox' value='1' onclick='cbClick(this,$i,$j)'";
634 if ($cellvalue) echo " checked";
635 echo " />";
637 else if ($celltype == '3') {
638 echo "<input type='text' class='intext' onchange='textChange(this,$i,$j)'";
639 echo " value='$cellvalue'";
640 echo " size='12' />";
642 else if ($celltype == '4') {
643 echo "<textarea rows='3' cols='25' wrap='virtual' class='intext' " .
644 "onchange='longChange(this,$i,$j)'>";
645 echo $cellvalue;
646 echo "</textarea>";
649 echo "</span>"; // new //
651 echo "</td>\n";
653 echo " </tr>\n";
656 </table>
659 <input type='submit' name='bn_save_form' value='Save Form' />
660 <?php if (!$formid) { ?>
661 &nbsp;
662 <input type='submit' name='bn_save_template' value='Save as Template:' />
663 &nbsp;
664 <input type='text' name='form_new_template_name' value='<?php echo $template_name ?>' />
665 &nbsp;
666 <input type='submit' name='bn_delete_template' value='Delete Template' />
667 <?php } ?>
668 &nbsp;
669 <input type='button' value='Cancel' onclick="doCancel()" />
670 </p>
672 </center>
673 </form>
674 <script language='JavaScript'>
675 Calendar.setup({inputField:"form_start_date", ifFormat:"%Y-%m-%d", button:"img_start_date"});
676 <?php
677 if ($alertmsg) echo " alert('$alertmsg');\n";
679 </script>
680 </body>
681 </html>