2 // Copyright (C) 2007-2011 Rod Roark <rod@sunsetsystems.com>
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 // Undo magic quotes and do not allow fake register globals.
10 $sanitize_all_escapes = true;
11 $fake_register_globals = false;
13 include_once("../globals.php");
14 include_once($GLOBALS['srcdir'] . "/patient.inc");
16 $template_dir = $GLOBALS['OE_SITE_DIR'] . "/letter_templates";
18 // array of field name tags to allow internationalization
22 'FROM_TITLE' => xl('FROM_TITLE'),
23 'FROM_FNAME' => xl('FROM_FNAME'),
24 'FROM_LNAME' => xl('FROM_LNAME'),
25 'FROM_MNAME' => xl('FROM_MNAME'),
26 'FROM_STREET' => xl('FROM_STREET'),
27 'FROM_CITY' => xl('FROM_CITY'),
28 'FROM_STATE' => xl('FROM_STATE'),
29 'FROM_POSTAL' => xl('FROM_POSTAL'),
30 'FROM_VALEDICTORY' => xl('FROM_VALEDICTORY'),
31 'FROM_PHONE' => xl('FROM_PHONE'),
32 'FROM_PHONECELL' => xl('FROM_PHONECELL'),
33 'FROM_EMAIL' => xl('FROM_EMAIL'),
34 'TO_TITLE' => xl('TO_TITLE'),
35 'TO_FNAME' => xl('TO_FNAME'),
36 'TO_LNAME' => xl('TO_LNAME'),
37 'TO_MNAME' => xl('TO_MNAME'),
38 'TO_STREET' => xl('TO_STREET'),
39 'TO_CITY' => xl('TO_CITY'),
40 'TO_STATE' => xl('TO_STATE'),
41 'TO_POSTAL' => xl('TO_POSTAL'),
42 'TO_VALEDICTORY' => xl('TO_VALEDICTORY'),
43 'TO_PHONE' => xl('TO_PHONE'),
44 'TO_PHONECELL' => xl('TO_PHONECELL'),
45 'TO_FAX' => xl('TO_FAX'),
46 'TO_ORGANIZATION' => xl('TO_ORGANIZATION'),
47 'PT_FNAME' => xl('PT_FNAME'),
48 'PT_LNAME' => xl('PT_LNAME'),
49 'PT_MNAME' => xl('PT_MNAME'),
50 'PT_STREET' => xl('PT_STREET'),
51 'PT_CITY' => xl('PT_CITY'),
52 'PT_STATE' => xl('PT_STATE'),
53 'PT_POSTAL' => xl('PT_POSTAL'),
54 'PT_PHONE_HOME' => xl('PT_PHONE_HOME'),
55 'PT_PHONE_CELL' => xl('PT_PHONE_CELL'),
56 'PT_SSN' => xl('PT_SSN'),
57 'PT_EMAIL' => xl('PT_EMAIL'),
58 'PT_DOB' => xl('PT_DOB')
62 $patdata = sqlQuery("SELECT " .
63 "p.fname, p.mname, p.lname, p.pubpid, p.DOB, " .
64 "p.street, p.city, p.state, p.phone_home, p.phone_cell, p.ss, p.email, p.postal_code " .
65 "FROM patient_data AS p " .
66 "WHERE p.pid = '$pid' LIMIT 1");
68 $alertmsg = ''; // anything here pops up in an alert box
70 // If the Generate button was clicked...
71 if ($_POST['formaction']=="generate") {
73 $form_pid = $_POST['form_pid'];
74 $form_from = $_POST['form_from'];
75 $form_to = $_POST['form_to'];
76 $form_date = $_POST['form_date'];
77 $form_template = $_POST['form_template'];
78 $form_format = $_POST['form_format'];
79 $form_body = $_POST['form_body'];
81 $frow = sqlQuery("SELECT * FROM users WHERE id = '$form_from'");
82 $trow = sqlQuery("SELECT * FROM users WHERE id = '$form_to'");
84 $datestr = date('j F Y', strtotime($form_date));
85 $from_title = $frow['title'] ?
$frow['title'] . ' ' : '';
86 $to_title = $trow['title'] ?
$trow['title'] . ' ' : '';
88 $cpstring = $_POST['form_body'];
90 // attempt to save to the autosaved template
91 $fh = fopen("$template_dir/autosaved", 'w');
92 // translate from definition to the constant
93 $temp_bodytext = $cpstring;
94 foreach ($FIELD_TAG as $key => $value) {
95 $temp_bodytext = str_replace("{".$value."}", "{".$key."}", $temp_bodytext);
97 if (! fwrite($fh, $temp_bodytext)) {
98 echo xl('Error while saving to the file','','',' ') . $template_dir."/autosaved" .
99 xl('Ensure OpenEMR has write privileges to directory','',' . ',' ') . $template_dir . "/ ." ;
104 $cpstring = str_replace('{'.$FIELD_TAG['DATE'].'}' , $datestr, $cpstring);
105 $cpstring = str_replace('{'.$FIELD_TAG['FROM_TITLE'].'}' , $from_title, $cpstring);
106 $cpstring = str_replace('{'.$FIELD_TAG['FROM_FNAME'].'}' , $frow['fname'], $cpstring);
107 $cpstring = str_replace('{'.$FIELD_TAG['FROM_LNAME'].'}' , $frow['lname'], $cpstring);
108 $cpstring = str_replace('{'.$FIELD_TAG['FROM_MNAME'].'}' , $frow['mname'], $cpstring);
109 $cpstring = str_replace('{'.$FIELD_TAG['FROM_STREET'].'}' , $frow['street'], $cpstring);
110 $cpstring = str_replace('{'.$FIELD_TAG['FROM_CITY'].'}' , $frow['city'], $cpstring);
111 $cpstring = str_replace('{'.$FIELD_TAG['FROM_STATE'].'}' , $frow['state'], $cpstring);
112 $cpstring = str_replace('{'.$FIELD_TAG['FROM_POSTAL'].'}' , $frow['zip'], $cpstring);
113 $cpstring = str_replace('{'.$FIELD_TAG['FROM_VALEDICTORY'].'}', $frow['valedictory'], $cpstring);
114 $cpstring = str_replace('{'.$FIELD_TAG['FROM_PHONECELL'].'}' , $frow['phonecell'], $cpstring);
115 $cpstring = str_replace('{'.$FIELD_TAG['FROM_PHONE'].'}' , $frow['phone'], $cpstring);
116 $cpstring = str_replace('{'.$FIELD_TAG['FROM_EMAIL'].'}' , $frow['email'], $cpstring);
117 $cpstring = str_replace('{'.$FIELD_TAG['TO_TITLE'].'}' , $to_title, $cpstring);
118 $cpstring = str_replace('{'.$FIELD_TAG['TO_FNAME'].'}' , $trow['fname'], $cpstring);
119 $cpstring = str_replace('{'.$FIELD_TAG['TO_LNAME'].'}' , $trow['lname'], $cpstring);
120 $cpstring = str_replace('{'.$FIELD_TAG['TO_MNAME'].'}' , $trow['mname'], $cpstring);
121 $cpstring = str_replace('{'.$FIELD_TAG['TO_STREET'].'}' , $trow['street'], $cpstring);
122 $cpstring = str_replace('{'.$FIELD_TAG['TO_CITY'].'}' , $trow['city'], $cpstring);
123 $cpstring = str_replace('{'.$FIELD_TAG['TO_STATE'].'}' , $trow['state'], $cpstring);
124 $cpstring = str_replace('{'.$FIELD_TAG['TO_POSTAL'].'}' , $trow['zip'], $cpstring);
125 $cpstring = str_replace('{'.$FIELD_TAG['TO_VALEDICTORY'].'}' , $trow['valedictory'], $cpstring);
126 $cpstring = str_replace('{'.$FIELD_TAG['TO_FAX'].'}' , $trow['fax'], $cpstring);
127 $cpstring = str_replace('{'.$FIELD_TAG['TO_PHONE'].'}' , $trow['phone'], $cpstring);
128 $cpstring = str_replace('{'.$FIELD_TAG['TO_PHONECELL'].'}' , $trow['phonecell'], $cpstring);
129 $cpstring = str_replace('{'.$FIELD_TAG['TO_ORGANIZATION'].'}' , $trow['organization'], $cpstring);
130 $cpstring = str_replace('{'.$FIELD_TAG['PT_FNAME'].'}' , $patdata['fname'], $cpstring);
131 $cpstring = str_replace('{'.$FIELD_TAG['PT_LNAME'].'}' , $patdata['lname'], $cpstring);
132 $cpstring = str_replace('{'.$FIELD_TAG['PT_MNAME'].'}' , $patdata['mname'], $cpstring);
133 $cpstring = str_replace('{'.$FIELD_TAG['PT_STREET'].'}' , $patdata['street'], $cpstring);
134 $cpstring = str_replace('{'.$FIELD_TAG['PT_CITY'].'}' , $patdata['city'], $cpstring);
135 $cpstring = str_replace('{'.$FIELD_TAG['PT_STATE'].'}' , $patdata['state'], $cpstring);
136 $cpstring = str_replace('{'.$FIELD_TAG['PT_POSTAL'].'}' , $patdata['postal_code'], $cpstring);
137 $cpstring = str_replace('{'.$FIELD_TAG['PT_PHONE_HOME'].'}' , $patdata['phone_home'], $cpstring);
138 $cpstring = str_replace('{'.$FIELD_TAG['PT_PHONE_CELL'].'}' , $patdata['phone_cell'], $cpstring);
139 $cpstring = str_replace('{'.$FIELD_TAG['PT_SSN'].'}' , $patdata['ss'], $cpstring);
140 $cpstring = str_replace('{'.$FIELD_TAG['PT_EMAIL'].'}' , $patdata['email'], $cpstring);
141 $cpstring = str_replace('{'.$FIELD_TAG['PT_DOB'].'}' , $patdata['DOB'], $cpstring);
143 if ($form_format == "pdf") {
144 $pdf = new Cezpdf($GLOBALS['rx_paper_size']);
145 $pdf->ezSetMargins($GLOBALS['rx_top_margin']
146 ,$GLOBALS['rx_bottom_margin']
147 ,$GLOBALS['rx_left_margin']
148 ,$GLOBALS['rx_right_margin']
150 if (file_exists("$template_dir/custom_pdf.php")) {
151 include("$template_dir/custom_pdf.php");
154 $pdf->selectFont('Helvetica');
155 $pdf->ezText($cpstring, 12);
160 else { // $form_format = html
161 $cpstring = text($cpstring); //escape to prevent stored cross script attack
162 $cpstring = str_replace("\n", "<br>", $cpstring);
163 $cpstring = str_replace("\t", " ", $cpstring);
169 font
-family
: sans
-serif
;
189 <title
><?php
xl('Letter','e'); ?
></title
>
192 <div
class='paddingdiv'>
193 <?php
echo $cpstring; ?
>
194 <div
class="navigate">
195 <a href
="<?php echo $GLOBALS['rootdir'] . '/patient_file/letter.php?template=autosaved'; ?>">(<?php
xl('Back','e'); ?
>)</a
>
197 <script language
='JavaScript'>
206 else if (isset($_GET['template']) && $_GET['template'] != "") {
207 // utilized to go back to autosaved template
209 $fh = fopen("$template_dir/".$_GET['template'], 'r');
210 while (!feof($fh)) $bodytext.= fread($fh, 8192);
212 // translate from constant to the definition
213 foreach ($FIELD_TAG as $key => $value) {
214 $bodytext = str_replace("{".$key."}", "{".$value."}", $bodytext);
217 else if ($_POST['formaction'] == "loadtemplate" && $_POST['form_template'] != "") {
219 $fh = fopen("$template_dir/".$_POST['form_template'], 'r');
220 while (!feof($fh)) $bodytext.= fread($fh, 8192);
222 // translate from constant to the definition
223 foreach ($FIELD_TAG as $key => $value) {
224 $bodytext = str_replace("{".$key."}", "{".$value."}", $bodytext);
227 else if ($_POST['formaction'] == "newtemplate" && $_POST['newtemplatename'] != "") {
228 // attempt to save the template
229 $fh = fopen("$template_dir/".$_POST['newtemplatename'], 'w');
230 // translate from definition to the constant
231 $temp_bodytext = $_POST['form_body'];
232 foreach ($FIELD_TAG as $key => $value) {
233 $temp_bodytext = str_replace("{".$value."}", "{".$key."}", $temp_bodytext);
235 if (! fwrite($fh, $temp_bodytext)) {
236 echo xl('Error while writing to file','','',' ') . $template_dir."/".$_POST['newtemplatename'];
241 // read the saved file back
242 $_POST['form_template'] = $_POST['newtemplatename'];
243 $fh = fopen("$template_dir/".$_POST['form_template'], 'r');
244 while (!feof($fh)) $bodytext.= fread($fh, 8192);
246 // translate from constant to the definition
247 foreach ($FIELD_TAG as $key => $value) {
248 $bodytext = str_replace("{".$key."}", "{".$value."}" , $bodytext);
251 else if ($_POST['formaction'] == "savetemplate" && $_POST['form_template'] != "") {
252 // attempt to save the template
253 $fh = fopen("$template_dir/".$_POST['form_template'], 'w');
254 // translate from definition to the constant
255 $temp_bodytext = $_POST['form_body'];
256 foreach ($FIELD_TAG as $key => $value) {
257 $temp_bodytext = str_replace("{".$value."}", "{".$key."}", $temp_bodytext);
259 if (! fwrite($fh, $temp_bodytext)) {
260 echo xl('Error while writing to file','','',' ') . $template_dir."/".$_POST['form_template'];
265 // read the saved file back
266 $fh = fopen("$template_dir/".$_POST['form_template'], 'r');
267 while (!feof($fh)) $bodytext.= fread($fh, 8192);
269 // translate from constant to the definition
270 foreach ($FIELD_TAG as $key => $value) {
271 $bodytext = str_replace("{".$key."}", "{".$value."}", $bodytext);
275 // This is the case where we display the form for data entry.
276 // Get the users list.
277 $ures = sqlStatement("SELECT id, fname, lname, specialty FROM users " .
278 "WHERE active = 1 AND ( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
279 "ORDER BY lname, fname");
283 $ulist = "var ulist = new Array();\n";
284 while ($urow = sqlFetchArray($ures)) {
285 $uname = $urow['lname'];
286 if ($urow['fname']) $uname .= ", " . $urow['fname'];
287 $tmp1 = " <option value='" . $urow['id'] . "'";
288 $tmp2 = ">$uname</option>\n";
289 $optto .= $tmp1 . $tmp2;
290 if ($urow['id'] == $_SESSION['authUserID']) $tmp1 .= " selected";
291 $optfrom .= $tmp1 . $tmp2;
292 $ulist .= "ulist[$i] = '" . addslashes($uname) . "|" .
293 $urow['id'] . "|" . addslashes($urow['specialty']) . "';\n";
297 // Get the unique specialties.
298 $sres = sqlStatement("SELECT DISTINCT specialty FROM users " .
299 "WHERE active = 1 AND ( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
300 "ORDER BY specialty");
301 $optspec = "<option value='All'>" . xl('All') . "</option>\n";
302 while ($srow = sqlFetchArray($sres)) {
303 $optspec .= " <option value='" . $srow['specialty'] . "'>" .
304 $srow['specialty'] . "</option>\n";
310 <?php
html_header_show();?
>
311 <title
><?php
xl('Letter Generator','e'); ?
></title
>
313 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
314 <link rel
='stylesheet' href
='<?php echo $css_header ?>' type
='text/css'>
316 <!-- supporting javascript code
-->
317 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-1/index.js"></script
>
319 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/topdialog.js"></script
>
320 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
321 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/textformat.js"></script
>
322 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.js"></script
>
323 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
324 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar_setup.js"></script
>
326 <script language
="JavaScript">
327 <?php
echo $ulist; ?
>
329 // React to selection of a specialty. This rebuilds the "to" users list
330 // with users having that specialty, or all users if "All" is selected.
331 function newspecialty() {
332 var f
= document
.forms
[0];
333 var s
= f
.form_specialty
.value
;
334 var theopts
= f
.form_to
.options
;
337 for (var i
= 0; i
< ulist
.length
; ++i
) {
338 tmp
= ulist
[i
].split("|");
339 if (s
!= 'All' && s
!= tmp
[2]) continue;
340 theopts
[j++
] = new Option(tmp
[0], tmp
[1], false, false);
345 // insert text into a textarea where the cursor is
346 function insertAtCaret(areaId
,text
) {
347 var txtarea
= document
.getElementById(areaId
);
348 var scrollPos
= txtarea
.scrollTop
;
350 var br
= ((txtarea
.selectionStart || txtarea
.selectionStart
== '0') ?
351 "ff" : (document
.selection ?
"ie" : false ) );
354 var range
= document
.selection
.createRange();
355 range
.moveStart ('character', -txtarea
.value
.length
);
356 strPos
= range
.text
.length
;
358 else if (br
== "ff") strPos
= txtarea
.selectionStart
;
360 var front
= (txtarea
.value
).substring(0,strPos
);
361 var back
= (txtarea
.value
).substring(strPos
,txtarea
.value
.length
);
362 txtarea
.value
=front+text+back
;
363 strPos
= strPos + text
.length
;
366 var range
= document
.selection
.createRange();
367 range
.moveStart ('character', -txtarea
.value
.length
);
368 range
.moveStart ('character', strPos
);
369 range
.moveEnd ('character', 0);
372 else if (br
== "ff") {
373 txtarea
.selectionStart
= strPos
;
374 txtarea
.selectionEnd
= strPos
;
377 txtarea
.scrollTop
= scrollPos
;
380 function insertAtCursor(myField
, myValue
) {
382 if (document
.selection
) {
384 sel
= document
.selection
.createRange();
387 //MOZILLA/NETSCAPE support
388 else if (myField
.selectionStart || myField
.selectionStart
== '0') {
389 var startPos
= myField
.selectionStart
;
390 var endPos
= myField
.selectionEnd
;
391 myField
.value
= myField
.value
.substring(0, startPos
)
393 + myField
.value
.substring(endPos
, myField
.value
.length
);
395 myField
.value +
= myValue
;
404 <body
class="body_top" onunload
='imclosing()'>
406 <!-- <form method
='post' action
='letter.php' onsubmit
='return top.restoreSession()'> -->
407 <form method
='post' action
='letter.php' id
="theform" name
="theform">
408 <input type
="hidden" name
="formaction" id
="formaction" value
="">
409 <input type
='hidden' name
='form_pid' value
='<?php echo $pid ?>' />
413 <table border
='0' cellspacing
='8' width
='98%'>
416 <td colspan
='4' align
='center'>
418 <b
><?php
xl('Generate Letter regarding ','e','',' '); echo $patdata['fname'] . " " .
419 $patdata['lname'] . " (" . $patdata['pubpid'] . ")" ?
></b
>
427 <?php
xl('From','e'); ?
>:
431 <select name
='form_from'>
432 <?php
echo $optfrom; ?
>
437 <?php
xl('Date','e'); ?
>:
441 <input type
='text' size
='10' name
='form_date' id
='form_date'
442 value
='<?php echo date('Y
-m
-d
'); ?>'
443 title
='<?php xl('yyyy
-mm
-dd date of this letter
','e
'); ?>'
444 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' />
445 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
446 id
='img_date' border
='0' alt
='[?]' style
='cursor:pointer'
447 title
='<?php xl('Click here to choose a date
','e
'); ?>' />
455 <?php
xl('Specialty','e'); ?
>:
459 <select name
='form_specialty' onchange
='newspecialty()'>
460 <?php
echo $optspec; ?
>
465 <?php
xl('Template','e'); ?
>:
469 <select name
="form_template" id
="form_template">
470 <option value
="">(<?php
xl('none','e'); ?
>)</option
>
472 $tpldir = $GLOBALS['OE_SITE_DIR'] . "/letter_templates";
473 $dh = opendir($tpldir);
474 if (! $dh) die(xl('Cannot read','','',' ') . $tpldir);
475 while (false !== ($tfname = readdir($dh))) {
476 // skip dot-files, scripts and images
477 if (preg_match("/^\./" , $tfname)) { continue; }
478 if (preg_match("/\.php$/", $tfname)) { continue; }
479 if (preg_match("/\.jpg$/", $tfname)) { continue; }
480 if (preg_match("/\.png$/", $tfname)) { continue; }
481 echo "<option value=".$tfname;
482 if (($tfname == $_POST['form_template']) ||
($tfname == $_GET['template'])) echo " SELECTED";
484 if ($tfname == 'autosaved') {
504 <?php
xl('To','e'); ?
>:
508 <select name
='form_to'>
509 <?php
echo $optto; ?
>
514 <?php
xl('Print Format','e'); ?
>:
518 <select name
='form_format'>
519 <option value
='html'><?php
xl('HTML','e'); ?
></option
>
520 <option value
='pdf'><?php
xl('PDF','e'); ?
></option
>
528 <div id
="letter_toolbar" class='text' style
="width: 100%; background-color: #ddd; padding: 5px; margin: 0px;">
529 <?php
echo xlt('Insert special field'); ?
>:
530 <select id
="letter_field">
531 <option value
="">- <?php
xl('Choose','e'); ?
> -</option
>
532 <option value
="<?php echo '{'.$FIELD_TAG['DATE'].'}'; ?>"><?php
xl('Today\'s Date','e'); ?
></option
>
533 <option value
="<?php echo '{'.$FIELD_TAG['FROM_TITLE'].'}'; ?>"><?php
xl('FROM','e'); ?
> - <?php
xl('Title','e'); ?
></option
>
534 <option value
="<?php echo '{'.$FIELD_TAG['FROM_FNAME'].'}'; ?>"><?php
xl('FROM','e'); ?
> - <?php
xl('First name','e'); ?
></option
>
535 <option value
="<?php echo '{'.$FIELD_TAG['FROM_MNAME'].'}'; ?>"><?php
xl('FROM','e'); ?
> - <?php
xl('Middle name','e'); ?
></option
>
536 <option value
="<?php echo '{'.$FIELD_TAG['FROM_LNAME'].'}'; ?>"><?php
xl('FROM','e'); ?
> - <?php
xl('Last name','e'); ?
></option
>
537 <option value
="<?php echo '{'.$FIELD_TAG['FROM_STREET'].'}'; ?>"><?php
xl('FROM','e'); ?
> - <?php
xl('Street','e'); ?
></option
>
538 <option value
="<?php echo '{'.$FIELD_TAG['FROM_CITY'].'}'; ?>"><?php
xl('FROM','e'); ?
> - <?php
xl('City','e'); ?
></option
>
539 <option value
="<?php echo '{'.$FIELD_TAG['FROM_STATE'].'}'; ?>"><?php
xl('FROM','e'); ?
> - <?php
xl('State','e'); ?
></option
>
540 <option value
="<?php echo '{'.$FIELD_TAG['FROM_POSTAL'].'}'; ?>"><?php
xl('FROM','e'); ?
> - <?php
xl('Postal Code','e'); ?
></option
>
541 <option value
="<?php echo '{'.$FIELD_TAG['FROM_VALEDICTORY'].'}'; ?>"><?php
xl('FROM','e'); ?
> - <?php
xl('Valedictory','e'); ?
></option
>
542 <option value
="<?php echo '{'.$FIELD_TAG['FROM_PHONECELL'].'}'; ?>"><?php
xl('FROM','e'); ?
> - <?php
xl('Cell Phone','e'); ?
></option
>
543 <option value
="<?php echo '{'.$FIELD_TAG['FROM_PHONE'].'}'; ?>"><?php
xl('FROM','e'); ?
> - <?php
xl('Phone','e'); ?
></option
>
544 <option value
="<?php echo '{'.$FIELD_TAG['FROM_EMAIL'].'}'; ?>"><?php
xl('FROM','e'); ?
> - <?php
xl('email','e'); ?
></option
>
545 <option value
="<?php echo '{'.$FIELD_TAG['TO_TITLE'].'}'; ?>"><?php
xl('TO','e'); ?
> - <?php
xl('Title','e'); ?
></option
>
546 <option value
="<?php echo '{'.$FIELD_TAG['TO_FNAME'].'}'; ?>"><?php
xl('TO','e'); ?
> - <?php
xl('First name','e'); ?
></option
>
547 <option value
="<?php echo '{'.$FIELD_TAG['TO_MNAME'].'}'; ?>"><?php
xl('TO','e'); ?
> - <?php
xl('Middle name','e'); ?
></option
>
548 <option value
="<?php echo '{'.$FIELD_TAG['TO_LNAME'].'}'; ?>"><?php
xl('TO','e'); ?
> - <?php
xl('Last name','e'); ?
></option
>
549 <option value
="<?php echo '{'.$FIELD_TAG['TO_STREET'].'}'; ?>"><?php
xl('TO','e'); ?
> - <?php
xl('Street','e'); ?
></option
>
550 <option value
="<?php echo '{'.$FIELD_TAG['TO_CITY'].'}'; ?>"><?php
xl('TO','e'); ?
> - <?php
xl('City','e'); ?
></option
>
551 <option value
="<?php echo '{'.$FIELD_TAG['TO_STATE'].'}'; ?>"><?php
xl('TO','e'); ?
> - <?php
xl('State','e'); ?
></option
>
552 <option value
="<?php echo '{'.$FIELD_TAG['TO_POSTAL'].'}'; ?>"><?php
xl('TO','e'); ?
> - <?php
xl('Postal Code','e'); ?
></option
>
553 <option value
="<?php echo '{'.$FIELD_TAG['TO_VALEDICTORY'].'}'; ?>"><?php
xl('TO','e'); ?
> - <?php
xl('Valedictory','e'); ?
></option
>
554 <option value
="<?php echo '{'.$FIELD_TAG['TO_ORGANIZATION'].'}'; ?>"><?php
xl('TO','e'); ?
> - <?php
xl('Organization','e'); ?
></option
>
555 <option value
="<?php echo '{'.$FIELD_TAG['TO_FAX'].'}'; ?>"><?php
xl('TO','e'); ?
> - <?php
xl('Fax number','e'); ?
></option
>
556 <option value
="<?php echo '{'.$FIELD_TAG['TO_PHONE'].'}'; ?>"><?php
xl('TO','e'); ?
> - <?php
xl('Phone number','e'); ?
></option
>
557 <option value
="<?php echo '{'.$FIELD_TAG['TO_PHONECELL'].'}'; ?>"><?php
xl('TO','e'); ?
> - <?php
xl('Cell phone number','e'); ?
></option
>
558 <option value
="<?php echo '{'.$FIELD_TAG['PT_FNAME'].'}'; ?>"><?php
xl('PATIENT','e'); ?
> - <?php
xl('First name','e'); ?
></option
>
559 <option value
="<?php echo '{'.$FIELD_TAG['PT_MNAME'].'}'; ?>"><?php
xl('PATIENT','e'); ?
> - <?php
xl('Middle name','e'); ?
></option
>
560 <option value
="<?php echo '{'.$FIELD_TAG['PT_LNAME'].'}'; ?>"><?php
xl('PATIENT','e'); ?
> - <?php
xl('Last name','e'); ?
></option
>
561 <option value
="<?php echo '{'.$FIELD_TAG['PT_STREET'].'}'; ?>"><?php
xl('PATIENT','e'); ?
> - <?php
xl('Street','e'); ?
></option
>
562 <option value
="<?php echo '{'.$FIELD_TAG['PT_CITY'].'}'; ?>"><?php
xl('PATIENT','e'); ?
> - <?php
xl('City','e'); ?
></option
>
563 <option value
="<?php echo '{'.$FIELD_TAG['PT_STATE'].'}'; ?>"><?php
xl('PATIENT','e'); ?
> - <?php
xl('State','e'); ?
></option
>
564 <option value
="<?php echo '{'.$FIELD_TAG['PT_POSTAL'].'}'; ?>"><?php
xl('PATIENT','e'); ?
> - <?php
xl('Postal Code','e'); ?
></option
>
565 <option value
="<?php echo '{'.$FIELD_TAG['PT_PHONE_HOME'].'}'; ?>"><?php
xl('PATIENT','e'); ?
> - <?php
xl('Phone Home','e'); ?
></option
>
566 <option value
="<?php echo '{'.$FIELD_TAG['PT_PHONE_CELL'].'}'; ?>"><?php
xl('PATIENT','e'); ?
> - <?php
xl('Phone Cell','e'); ?
></option
>
567 <option value
="<?php echo '{'.$FIELD_TAG['PT_SSN'].'}'; ?>"><?php
xl('PATIENT','e'); ?
> - <?php
xl('SSN','e'); ?
></option
>
568 <option value
="<?php echo '{'.$FIELD_TAG['PT_DOB'].'}'; ?>"><?php
xl('PATIENT','e'); ?
> - <?php
xl('Date of birth','e'); ?
></option
>
571 <textarea name
='form_body' id
="form_body" rows
='20' cols
='30' style
='width:100%'
572 title
=<?php
xl('Enter body of letter here','e','\'','\''); ?
> /><?php
echo $bodytext; ?
></textarea
>
578 <input type
='button' class="addtemplate" value
=<?php
xl('Save as New','e','\'','\''); ?
>>
579 <input type
='button' name
='savetemplate' id
="savetemplate" value
=<?php
xl('Save Changes','e','\'','\''); ?
>>
580 <input type
='button' name
='form_generate' id
="form_generate" value
=<?php
xl('Generate Letter','e','\'','\''); ?
>>
584 <!-- template DIV that appears when user chooses to add a
new letter template
-->
585 <div id
="newtemplatedetail" style
="border: 1px solid black; padding: 3px; display: none; visibility: hidden; background-color: lightgrey;">
586 <?php
xl('Template Name','e'); ?
>: <input type
="textbox" size
="20" maxlength
="30" name
="newtemplatename" id
="newtemplatename">
588 <input type
="button" class="savenewtemplate" value
=<?php
xl('Save new template','e','\'','\''); ?
>>
589 <input type
="button" class="cancelnewtemplate" value
=<?php
xl('Cancel','e','\'','\''); ?
>>
595 <script language
='JavaScript'>
596 Calendar
.setup({inputField
:"form_date", ifFormat
:"%Y-%m-%d", button
:"img_date"});
598 // jQuery stuff to make the page a little easier to use
600 $
(document
).ready(function(){
601 $
("#form_generate").click(function() { $
("#formaction").val("generate"); $
("#theform").submit(); });
602 $
("#form_template").change(function() { $
("#formaction").val("loadtemplate"); $
("#theform").submit(); });
604 $
("#savetemplate").click(function() { SaveTemplate(this
); });
606 $
("#letter_field").change(function() { insertAtCursor(document
.getElementById("form_body"), $
(this
).val()); $
(this
).attr("selectedIndex", "0"); });
608 $
(".addtemplate").click(function() { AddTemplate(this
); });
609 $
(".savenewtemplate").click(function() { SaveNewTemplate(this
); });
610 $
(".deletetemplate").click(function() { DeleteTemplate(this
); });
611 $
(".cancelnewtemplate").click(function() { CancelNewTemplate(this
); });
613 // display the 'new group' DIV
614 var AddTemplate
= function(btnObj
) {
615 // show the field details DIV
616 $
('#newtemplatedetail').css('visibility', 'visible');
617 $
('#newtemplatedetail').css('display', 'block');
618 $
(btnObj
).parent().append($
("#newtemplatedetail"));
619 $
('#newtemplatedetail > #newtemplatename').focus();
622 // save the new template
623 var SaveNewTemplate
= function(btnObj
) {
624 // the template name can only have letters, numbers, spaces and underscores
625 // AND it cannot start with a number
626 if ($
("#newtemplatename").val().match(/^\d+
/)) {
627 alert("<?php xl('Template names cannot start with numbers.','e'); ?>");
630 var validname
= $
("#newtemplatename").val().replace(/[^A
-za
-z0
-9]/g
, "_"); // match any non-word characters and replace them
631 $
("#newtemplatename").val(validname
);
633 // submit the form to add a new field to a specific group
634 $
("#formaction").val("newtemplate");
635 $
("#theform").submit();
638 // actually delete a template file
640 var DeleteTemplate = function(btnObj) {
641 var parts = $(btnObj).attr("id");
642 var groupname = parts.replace(/^\d+/, "");
643 if (confirm("WARNING - This action cannot be undone.\n Are you sure you wish to delete the entire group named '"+groupname+"'?")) {
644 // submit the form to add a new field to a specific group
645 $("#formaction").val("deletegroup");
646 $("#deletegroupname").val(parts);
647 $("#theform").submit();
652 // just hide the new template DIV
653 var CancelNewTemplate
= function(btnObj
) {
654 // hide the field details DIV
655 $
('#newtemplatedetail').css('visibility', 'hidden');
656 $
('#newtemplatedetail').css('display', 'none');
657 // reset the new group values to a default
658 $
('#newtemplatedetail > #newtemplatename').val("");
662 // save the template, overwriting the older version
663 var SaveTemplate
= function(btnObj
) {
664 if (! confirm("<?php xl('You are about to permanently replace the existing template. Are you sure you wish to continue?','e'); ?>")) {
667 $
("#formaction").val("savetemplate");
668 $
("#theform").submit();