2 // Copyright (C) 2005-2006 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 // The event editor looks something like this:
11 //------------------------------------------------------------//
12 // Category __________________V O All day event //
13 // Date _____________ [?] O Time ___:___ __V //
14 // Title ___________________ duration ____ minutes //
15 // Patient _(Click_to_select)_ //
16 // Provider __________________V X Repeats ______V ______V //
17 // Status __________________V until __________ [?] //
18 // Comments ________________________________________________ //
20 // [Save] [Find Available] [Delete] [Cancel] //
21 //------------------------------------------------------------//
23 include_once("../../globals.php");
24 include_once("$srcdir/patient.inc");
25 include_once("$srcdir/forms.inc");
27 // Things that might be passed by our opener.
29 $eid = $_GET['eid']; // only for existing events
30 $date = $_GET['date']; // this and below only for new events
31 $userid = $_GET['userid'];
32 $default_catid = $_GET['catid'] ?
$_GET['catid'] : '5';
35 $date = substr($date, 0, 4) . '-' . substr($date, 4, 2) . '-' . substr($date, 6);
37 $date = date("Y-m-d");
40 if (isset($_GET['starttimem']))
41 $starttimem = substr('00' . $_GET['starttimem'], -2);
43 if (isset($_GET['starttimeh'])) {
44 $starttimeh = $_GET['starttimeh'];
45 if (isset($_GET['startampm'])) {
46 if ($_GET['startampm'] == '2' && $starttimeh < 12)
50 $starttimeh = date("G");
56 // ===========================
57 // EVENTS TO FACILITIES (lemonsoftware)
58 // edit event case - if there is no association made, then insert one with the first facility
61 $facility = sqlQuery("SELECT pc_facility, pc_multiple FROM openemr_postcalendar_events WHERE pc_eid = $eid");
62 if ( !$facility['pc_facility'] ) {
63 $qmin = sqlQuery("SELECT MIN(id) as minId FROM facility");
64 $min = $qmin['minId'];
66 // multiple providers case
67 if ( $GLOBALS['select_multi_providers'] ) {
68 $mul = $facility['pc_multiple'];
69 sqlStatement("UPDATE openemr_postcalendar_events SET pc_facility = $min WHERE pc_multiple = $mul");
73 sqlStatement("UPDATE openemr_postcalendar_events SET pc_facility = $min WHERE pc_eid = $eid");
76 $e2f = $facility['pc_facility'];
80 // ===========================
83 // If we are saving, then save and close the window.
85 if ($_POST['form_save']) {
87 $event_date = fixDate($_POST['form_date']);
89 // Compute start and end time strings to be saved.
90 if ($_POST['form_allday']) {
95 $tmph = $_POST['form_hour'] +
0;
96 $tmpm = $_POST['form_minute'] +
0;
97 if ($_POST['form_ampm'] == '2' && $tmph < 12) $tmph +
= 12;
98 $duration = $_POST['form_duration'];
100 $starttime = "$tmph:$tmpm:00";
103 while ($tmpm >= 60) {
107 $endtime = "$tmph:$tmpm:00";
109 // Useless garbage that we must save.
110 $locationspec = 'a:6:{s:14:"event_location";N;s:13:"event_street1";N;' .
111 's:13:"event_street2";N;s:10:"event_city";N;s:11:"event_state";N;s:12:"event_postal";N;}';
113 // More garbage, but this time 1 character of it is used to save the
115 if ($_POST['form_repeat']) {
116 $recurrspec = 'a:5:{' .
117 's:17:"event_repeat_freq";s:1:"' . $_POST['form_repeat_freq'] . '";' .
118 's:22:"event_repeat_freq_type";s:1:"' . $_POST['form_repeat_type'] . '";' .
119 's:19:"event_repeat_on_num";s:1:"1";' .
120 's:19:"event_repeat_on_day";s:1:"0";' .
121 's:20:"event_repeat_on_freq";s:1:"0";}';
123 $recurrspec = 'a:5:{' .
124 's:17:"event_repeat_freq";N;' .
125 's:22:"event_repeat_freq_type";s:1:"0";' .
126 's:19:"event_repeat_on_num";s:1:"1";' .
127 's:19:"event_repeat_on_day";s:1:"0";' .
128 's:20:"event_repeat_on_freq";s:1:"1";}';
131 /* =======================================================
133 ========================================================*/
136 // what is multiple key around this $eid?
137 $row = sqlQuery("SELECT pc_multiple FROM openemr_postcalendar_events WHERE pc_eid = $eid");
139 if ($GLOBALS['select_multi_providers'] && $row['pc_multiple']) {
140 /* ==========================================
141 // multi providers BOS
142 ==========================================*/
144 // obtain current list of providers regarding the multiple key
145 $up = sqlStatement("SELECT pc_aid FROM openemr_postcalendar_events WHERE pc_multiple={$row['pc_multiple']}");
146 while ($current = sqlFetchArray($up)) {
147 $providers_current[] = $current['pc_aid'];
150 $providers_new = $_POST['form_provider'];
152 // this difference means that some providers from current was UNCHECKED
153 // so we must delete this event for them
154 $r1 = array_diff ($providers_current, $providers_new);
156 foreach ($r1 as $to_be_removed) {
157 sqlQuery("DELETE FROM openemr_postcalendar_events WHERE pc_aid='$to_be_removed' AND pc_multiple={$row['pc_multiple']}");
161 // this difference means that some providers was added
162 // so we must insert this event for them
163 $r2 = array_diff ($providers_new, $providers_current);
165 foreach ($r2 as $to_be_inserted) {
166 sqlInsert("INSERT INTO openemr_postcalendar_events ( pc_catid, pc_multiple, pc_aid, pc_pid, pc_title, pc_time, pc_hometext, pc_informant, pc_eventDate, pc_endDate, pc_duration, pc_recurrtype, pc_recurrspec, pc_startTime, pc_endTime, pc_alldayevent, pc_apptstatus, pc_prefcatid, pc_location, pc_eventstatus, pc_sharing, pc_facility)
168 "'" . $_POST['form_category'] . "', " .
169 "'" . $row['pc_multiple'] . "', " .
170 "'" . $to_be_inserted . "', " .
171 "'" . $_POST['form_pid'] . "', " .
172 "'" . $_POST['form_title'] . "', " .
174 "'" . $_POST['form_comments'] . "', " .
175 "'" . $_SESSION['authUserID'] . "', " .
176 "'" . $event_date . "', " .
177 "'" . fixDate($_POST['form_enddate']) . "', " .
178 "'" . ($duration * 60) . "', " .
179 "'" . ($_POST['form_repeat'] ?
'1' : '0') . "', " .
183 "'" . $_POST['form_allday'] . "', " .
184 "'" . $_POST['form_apptstatus'] . "', " .
185 "'" . $_POST['form_prefcat'] . "', " .
186 "'$locationspec', " .
188 "1, " .(int)$_POST['facility']. " )"); // FF stuff
193 // after the two diffs above, we must update for remaining providers
194 // those who are intersected in $providers_current and $providers_new
195 foreach ($_POST['form_provider'] as $provider) {
196 sqlStatement("UPDATE openemr_postcalendar_events SET " .
197 "pc_catid = '" . $_POST['form_category'] . "', " .
198 "pc_pid = '" . $_POST['form_pid'] . "', " .
199 "pc_title = '" . $_POST['form_title'] . "', " .
200 "pc_time = NOW(), " .
201 "pc_hometext = '" . $_POST['form_comments'] . "', " .
202 "pc_informant = '" . $_SESSION['authUserID'] . "', " .
203 "pc_eventDate = '" . $event_date . "', " .
204 "pc_endDate = '" . fixDate($_POST['form_enddate']) . "', " .
205 "pc_duration = '" . ($duration * 60) . "', " .
206 "pc_recurrtype = '" . ($_POST['form_repeat'] ?
'1' : '0') . "', " .
207 "pc_recurrspec = '$recurrspec', " .
208 "pc_startTime = '$starttime', " .
209 "pc_endTime = '$endtime', " .
210 "pc_alldayevent = '" . $_POST['form_allday'] . "', " .
211 "pc_apptstatus = '" . $_POST['form_apptstatus'] . "', " .
212 "pc_prefcatid = '" . $_POST['form_prefcat'] . "' " .
213 "pc_facility = '" .(int)$_POST['facility'] ."' " . // FF stuff
214 "WHERE pc_aid = '$provider' AND pc_multiple={$row['pc_multiple']}");
217 /* ==========================================
218 // multi providers EOS
219 ==========================================*/
221 } elseif ( !$row['pc_multiple'] ) {
222 if ( $GLOBALS['select_multi_providers'] ) {
223 $prov = $_POST['form_provider'][0];
225 $prov = $_POST['form_provider'];
228 // simple provider case
229 sqlStatement("UPDATE openemr_postcalendar_events SET " .
230 "pc_catid = '" . $_POST['form_category'] . "', " .
231 "pc_aid = '" . $prov . "', " .
232 "pc_pid = '" . $_POST['form_pid'] . "', " .
233 "pc_title = '" . $_POST['form_title'] . "', " .
234 "pc_time = NOW(), " .
235 "pc_hometext = '" . $_POST['form_comments'] . "', " .
236 "pc_informant = '" . $_SESSION['authUserID'] . "', " .
237 "pc_eventDate = '" . $event_date . "', " .
238 "pc_endDate = '" . fixDate($_POST['form_enddate']) . "', " .
239 "pc_duration = '" . ($duration * 60) . "', " .
240 "pc_recurrtype = '" . ($_POST['form_repeat'] ?
'1' : '0') . "', " .
241 "pc_recurrspec = '$recurrspec', " .
242 "pc_startTime = '$starttime', " .
243 "pc_endTime = '$endtime', " .
244 "pc_alldayevent = '" . $_POST['form_allday'] . "', " .
245 "pc_apptstatus = '" . $_POST['form_apptstatus'] . "', " .
246 "pc_prefcatid = '" . $_POST['form_prefcat'] . "' " .
247 "WHERE pc_eid = '$eid'");
251 // =======================================
252 // EOS multi providers case
253 // =======================================
255 // EVENTS TO FACILITIES
258 /* =======================================================
260 ========================================================*/
263 // =======================================
264 // multi providers case
265 // =======================================
267 if (is_array($_POST['form_provider'])) {
269 // obtain the next available unique key to group multiple providers around some event
270 $q = sqlStatement ("SELECT MAX(pc_multiple) as max FROM openemr_postcalendar_events");
271 $max = sqlFetchArray($q);
272 $new_multiple_value = $max['max'] +
1;
274 foreach ($_POST['form_provider'] as $provider) {
275 sqlInsert("INSERT INTO openemr_postcalendar_events ( " .
276 "pc_catid, pc_multiple, pc_aid, pc_pid, pc_title, pc_time, pc_hometext, " .
277 "pc_informant, pc_eventDate, pc_endDate, pc_duration, pc_recurrtype, " .
278 "pc_recurrspec, pc_startTime, pc_endTime, pc_alldayevent, " .
279 "pc_apptstatus, pc_prefcatid, pc_location, pc_eventstatus, pc_sharing, pc_facility " .
281 "'" . $_POST['form_category'] . "', " .
282 "'" . $new_multiple_value . "', " .
283 "'" . $provider . "', " .
284 "'" . $_POST['form_pid'] . "', " .
285 "'" . $_POST['form_title'] . "', " .
287 "'" . $_POST['form_comments'] . "', " .
288 "'" . $_SESSION['authUserID'] . "', " .
289 "'" . $event_date . "', " .
290 "'" . fixDate($_POST['form_enddate']) . "', " .
291 "'" . ($duration * 60) . "', " .
292 "'" . ($_POST['form_repeat'] ?
'1' : '0') . "', " .
296 "'" . $_POST['form_allday'] . "', " .
297 "'" . $_POST['form_apptstatus'] . "', " .
298 "'" . $_POST['form_prefcat'] . "', " .
299 "'$locationspec', " .
301 "1, " .(int)$_POST['facility']. " )"); // FF stuff
306 sqlInsert("INSERT INTO openemr_postcalendar_events ( " .
307 "pc_catid, pc_aid, pc_pid, pc_title, pc_time, pc_hometext, " .
308 "pc_informant, pc_eventDate, pc_endDate, pc_duration, pc_recurrtype, " .
309 "pc_recurrspec, pc_startTime, pc_endTime, pc_alldayevent, " .
310 "pc_apptstatus, pc_prefcatid, pc_location, pc_eventstatus, pc_sharing " .
312 "'" . $_POST['form_category'] . "', " .
313 "'" . $_POST['form_provider'] . "', " .
314 "'" . $_POST['form_pid'] . "', " .
315 "'" . $_POST['form_title'] . "', " .
317 "'" . $_POST['form_comments'] . "', " .
318 "'" . $_SESSION['authUserID'] . "', " .
319 "'" . $event_date . "', " .
320 "'" . fixDate($_POST['form_enddate']) . "', " .
321 "'" . ($duration * 60) . "', " .
322 "'" . ($_POST['form_repeat'] ?
'1' : '0') . "', " .
326 "'" . $_POST['form_allday'] . "', " .
327 "'" . $_POST['form_apptstatus'] . "', " .
328 "'" . $_POST['form_prefcat'] . "', " .
329 "'$locationspec', " .
331 "1," .(int)$_POST['facility']. ")"); // FF stuff
335 // Save new DOB if it's there.
336 $patient_dob = trim($_POST['form_dob']);
337 if ($patient_dob && $_POST['form_pid']) {
338 sqlStatement("UPDATE patient_data SET DOB = '$patient_dob' WHERE " .
339 "pid = '" . $_POST['form_pid'] . "'");
342 // Auto-create a new encounter if appropriate.
344 if ($GLOBALS['auto_create_new_encounters'] &&
345 $_POST['form_apptstatus'] == '@' && $event_date == date('Y-m-d'))
347 $tmprow = sqlQuery("SELECT count(*) AS count FROM form_encounter WHERE " .
348 "pid = '" . $_POST['form_pid'] . "' AND date = '$event_date 00:00:00'");
349 if ($tmprow['count'] == 0) {
350 $tmprow = sqlQuery("SELECT username, facility, facility_id FROM users WHERE id = '" .
351 $_POST['form_provider'] . "'");
352 $username = $tmprow['username'];
353 $facility = $tmprow['facility'];
354 $facility_id = $tmprow['facility_id'];
355 $conn = $GLOBALS['adodb']['db'];
356 $encounter = $conn->GenID("sequences");
357 addForm($encounter, "New Patient Encounter",
358 sqlInsert("INSERT INTO form_encounter SET " .
359 "date = '$event_date', " .
360 "onset_date = '$event_date', " .
361 "reason = '" . $_POST['form_comments'] . "', " .
362 "facility = '$facility', " .
363 "facility_id = '$facility_id', " .
364 "pid = '" . $_POST['form_pid'] . "', " .
365 "encounter = '$encounter'"
367 "newpatient", $_POST['form_pid'], "1", "NOW()", $username
369 $info_msg .= "New encounter $encounter was created. ";
374 else if ($_POST['form_delete']) {
375 // =======================================
376 // multi providers case
377 // =======================================
378 if ($GLOBALS['select_multi_providers']) {
379 // what is multiple key around this $eid?
380 $row = sqlQuery("SELECT pc_multiple FROM openemr_postcalendar_events WHERE pc_eid = $eid");
381 if ( $row['pc_multiple'] ) {
382 sqlStatement("DELETE FROM openemr_postcalendar_events WHERE pc_multiple = {$row['pc_multiple']}");
384 sqlStatement("DELETE FROM openemr_postcalendar_events WHERE pc_eid = $eid");
386 // =======================================
387 // EOS multi providers case
388 // =======================================
390 sqlStatement("DELETE FROM openemr_postcalendar_events WHERE pc_eid = '$eid'");
394 if ($_POST['form_save'] ||
$_POST['form_delete']) {
395 // Close this window and refresh the calendar display.
396 echo "<html>\n<body>\n<script language='JavaScript'>\n";
397 if ($info_msg) echo " alert('$info_msg');\n";
398 echo " if (!opener.closed && opener.refreshme) opener.refreshme();\n";
399 echo " window.close();\n";
400 echo "</script>\n</body>\n</html>\n";
404 // If we get this far then we are displaying the form.
408 '*' => xl('* Reminder done'),
409 '+' => xl('+ Chart pulled'),
410 '?' => xl('? No show'),
411 '@' => xl('@ Arrived'),
412 '~' => xl('~ Arrived late'),
413 '!' => xl('! Left w/o visit'),
414 '#' => xl('# Ins/fin issue'),
415 '<' => xl('< In exam room'),
416 '>' => xl('> Checked out'),
417 '$' => xl('$ Coding done'),
420 $repeats = 0; // if the event repeats
424 if ($_REQUEST['patientid']) $patientid = $_REQUEST['patientid'];
425 $patientname = xl('Click to select');
430 // If we are editing an existing event, then get its data.
432 $row = sqlQuery("SELECT * FROM openemr_postcalendar_events WHERE pc_eid = $eid");
433 $date = $row['pc_eventDate'];
434 $userid = $row['pc_aid'];
435 $patientid = $row['pc_pid'];
436 $starttimeh = substr($row['pc_startTime'], 0, 2) +
0;
437 $starttimem = substr($row['pc_startTime'], 3, 2);
438 $repeats = $row['pc_recurrtype'];
439 $multiple_value = $row['pc_multiple'];
441 if (preg_match('/"event_repeat_freq_type";s:1:"(\d)"/', $row['pc_recurrspec'], $matches)) {
442 $repeattype = $matches[1];
444 if (preg_match('/"event_repeat_freq";s:1:"(\d)"/', $row['pc_recurrspec'], $matches)) {
445 $repeatfreq = $matches[1];
447 $hometext = $row['pc_hometext'];
448 if (substr($hometext, 0, 6) == ':text:') $hometext = substr($hometext, 6);
451 // If we have a patient ID, get the name and phone numbers to display.
453 $prow = sqlQuery("SELECT lname, fname, phone_home, phone_biz, DOB " .
454 "FROM patient_data WHERE pid = '" . $patientid . "'");
455 $patientname = $prow['lname'] . ", " . $prow['fname'];
456 if ($prow['phone_home']) $patienttitle .= " H=" . $prow['phone_home'];
457 if ($prow['phone_biz']) $patienttitle .= " W=" . $prow['phone_biz'];
460 // Get the providers list.
461 $ures = sqlStatement("SELECT id, username, fname, lname FROM users WHERE " .
462 "authorized != 0 AND active = 1 ORDER BY lname, fname");
464 // Get event categories.
465 $cres = sqlStatement("SELECT pc_catid, pc_catname, pc_recurrtype, pc_duration, pc_end_all_day " .
466 "FROM openemr_postcalendar_categories ORDER BY pc_catname");
468 // Fix up the time format for AM/PM.
470 if ($starttimeh >= 12) { // p.m. starts at noon and not 12:01
472 if ($starttimeh > 12) $starttimeh -= 12;
477 <title
><?
echo $eid ?
"Edit" : "Add New" ?
> <?php
xl('Event','e');?
></title
>
478 <link rel
=stylesheet href
='<? echo $css_header ?>' type
='text/css'>
481 td
{ font
-size
:10pt
; }
484 <style type
="text/css">@import
url(../../../library
/dynarch_calendar
.css
);</style
>
485 <script type
="text/javascript" src
="../../../library/topdialog.js"></script
>
486 <script type
="text/javascript" src
="../../../library/dialog.js"></script
>
487 <script type
="text/javascript" src
="../../../library/textformat.js"></script
>
488 <script type
="text/javascript" src
="../../../library/dynarch_calendar.js"></script
>
489 <script type
="text/javascript" src
="../../../library/dynarch_calendar_en.js"></script
>
490 <script type
="text/javascript" src
="../../../library/dynarch_calendar_setup.js"></script
>
492 <script language
="JavaScript">
494 var mypcc
= '<? echo $GLOBALS['phone_country_code
'] ?>';
496 var durations
= new Array();
497 // var rectypes = new Array();
499 // Read the event categories, generate their options list, and get
500 // the default event duration from them if this is a new event.
502 $prefcat_options = " <option value='0'>-- None --</option>\n";
505 $thisduration = $row['pc_alldayevent'] ?
1440 : round($row['pc_duration'] / 60);
507 while ($crow = sqlFetchArray($cres)) {
508 $duration = round($crow['pc_duration'] / 60);
509 if ($crow['pc_end_all_day']) $duration = 1440;
510 echo " durations[" . $crow['pc_catid'] . "] = $duration\n";
511 // echo " rectypes[" . $crow['pc_catid'] . "] = " . $crow['pc_recurrtype'] . "\n";
512 $catoptions .= " <option value='" . $crow['pc_catid'] . "'";
514 if ($crow['pc_catid'] == $row['pc_catid']) $catoptions .= " selected";
516 if ($crow['pc_catid'] == $default_catid) {
517 $catoptions .= " selected";
518 $thisduration = $duration;
521 $catoptions .= ">" . $crow['pc_catname'] . "</option>\n";
523 // This section is to build the list of preferred categories:
525 $prefcat_options .= " <option value='" . $crow['pc_catid'] . "'";
527 if ($crow['pc_catid'] == $row['pc_prefcatid']) $prefcat_options .= " selected";
529 $prefcat_options .= ">" . $crow['pc_catname'] . "</option>\n";
535 <?php
require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
537 // This is for callback by the find-patient popup.
538 function setpatient(pid
, lname
, fname
, dob
) {
539 var f
= document
.forms
[0];
540 f
.form_patient
.value
= lname +
', ' + fname
;
541 f
.form_pid
.value
= pid
;
542 dobstyle
= (dob
== '' || dob
.substr(5, 10) == '00-00') ?
'' : 'none';
543 document
.getElementById('dob_row').style
.display
= dobstyle
;
546 // This invokes the find-patient popup.
547 function sel_patient() {
548 dlgopen('find_patient_popup.php', '_blank', 500, 400);
551 // Do whatever is needed when a new event category is selected.
552 // For now this means changing the event title and duration.
553 function set_display() {
554 var f
= document
.forms
[0];
555 var s
= f
.form_category
;
556 if (s
.selectedIndex
>= 0) {
557 var catid
= s
.options
[s
.selectedIndex
].value
;
558 var style_apptstatus
= document
.getElementById('title_apptstatus').style
;
559 var style_prefcat
= document
.getElementById('title_prefcat').style
;
560 if (catid
== '2') { // In Office
561 style_apptstatus
.display
= 'none';
562 style_prefcat
.display
= '';
563 f
.form_apptstatus
.style
.display
= 'none';
564 f
.form_prefcat
.style
.display
= '';
566 style_prefcat
.display
= 'none';
567 style_apptstatus
.display
= '';
568 f
.form_prefcat
.style
.display
= 'none';
569 f
.form_apptstatus
.style
.display
= '';
574 // Do whatever is needed when a new event category is selected.
575 // For now this means changing the event title and duration.
576 function set_category() {
577 var f
= document
.forms
[0];
578 var s
= f
.form_category
;
579 if (s
.selectedIndex
>= 0) {
580 var catid
= s
.options
[s
.selectedIndex
].value
;
581 f
.form_title
.value
= s
.options
[s
.selectedIndex
].text
;
582 f
.form_duration
.value
= durations
[catid
];
587 // Modify some visual attributes when the all-day or timed-event
588 // radio buttons are clicked.
589 function set_allday() {
590 var f
= document
.forms
[0];
591 var color1
= '#777777';
592 var color2
= '#777777';
593 var disabled2
= true;
594 if (document
.getElementById('rballday1').checked
) {
597 if (document
.getElementById('rballday2').checked
) {
601 document
.getElementById('tdallday1').style
.color
= color1
;
602 document
.getElementById('tdallday2').style
.color
= color2
;
603 document
.getElementById('tdallday3').style
.color
= color2
;
604 document
.getElementById('tdallday4').style
.color
= color2
;
605 document
.getElementById('tdallday5').style
.color
= color2
;
606 f
.form_hour
.disabled
= disabled2
;
607 f
.form_minute
.disabled
= disabled2
;
608 f
.form_ampm
.disabled
= disabled2
;
609 f
.form_duration
.disabled
= disabled2
;
612 // Modify some visual attributes when the Repeat checkbox is clicked.
613 function set_repeat() {
614 var f
= document
.forms
[0];
615 var isdisabled
= true;
616 var mycolor
= '#777777';
617 var myvisibility
= 'hidden';
618 if (f
.form_repeat
.checked
) {
621 myvisibility
= 'visible';
623 f
.form_repeat_type
.disabled
= isdisabled
;
624 f
.form_repeat_freq
.disabled
= isdisabled
;
625 f
.form_enddate
.disabled
= isdisabled
;
626 document
.getElementById('tdrepeat1').style
.color
= mycolor
;
627 document
.getElementById('tdrepeat2').style
.color
= mycolor
;
628 document
.getElementById('img_enddate').style
.visibility
= myvisibility
;
631 // This is for callback by the find-available popup.
632 function setappt(year
,mon
,mday
,hours
,minutes
) {
633 var f
= document
.forms
[0];
634 f
.form_date
.value
= '' + year +
'-' +
635 ('' +
(mon +
100)).substring(1) +
'-' +
636 ('' +
(mday +
100)).substring(1);
637 f
.form_ampm
.selectedIndex
= (hours
>= 12) ?
1 : 0;
638 f
.form_hour
.value
= (hours
> 12) ? hours
- 12 : hours
;
639 f
.form_minute
.value
= ('' +
(minutes +
100)).substring(1);
642 // Invoke the find-available popup.
643 function find_available() {
644 top
.restoreSession();
645 var s
= document
.forms
[0].form_provider
;
646 var c
= document
.forms
[0].form_category
;
647 dlgopen('find_appt_popup.php?providerid=' + s
.options
[s
.selectedIndex
].value +
648 '&catid=' + c
.options
[c
.selectedIndex
].value
, '_blank', 500, 400);
651 // Check for errors when the form is submitted.
652 function validate() {
653 var f
= document
.forms
[0];
654 if (f
.form_repeat
.checked
&&
655 (! f
.form_enddate
.value || f
.form_enddate
.value
< f
.form_date
.value
)) {
656 alert('An end date later than the start date is required for repeated events!');
659 top
.restoreSession();
667 <body
<?
echo $top_bg_line;?
> onunload
='imclosing()'>
669 <form method
='post' name
='theform' action
='add_edit_event.php?eid=<? echo $eid ?>'
670 onsubmit
='return validate()'>
673 <table border
='0' width
='100%'>
676 <td width
='1%' nowrap
>
677 <b
><?
xl('Category','e'); ?
>:</b
>
680 <select name
='form_category' onchange
='set_category()' style
='width:100%'>
681 <?
echo $catoptions ?
>
684 <td width
='1%' nowrap
>
686 <input type
='radio' name
='form_allday' onclick
='set_allday()' value
='1' id
='rballday1'
687 <?
if ($thisduration == 1440) echo "checked " ?
>/>
689 <td colspan
='2' nowrap id
='tdallday1'>
690 <?
xl('All day event','e'); ?
>
696 <b
><?
xl('Date','e'); ?
>:</b
>
699 <input type
='text' size
='10' name
='form_date' id
='form_date'
700 value
='<? echo $eid ? $row['pc_eventDate
'] : $date ?>'
701 title
='<?php xl('yyyy
-mm
-dd event date
or starting date
','e
'); ?>'
702 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' />
703 <img src
='../../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
704 id
='img_date' border
='0' alt
='[?]' style
='cursor:pointer'
705 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
709 <input type
='radio' name
='form_allday' onclick
='set_allday()' value
='0' id
='rballday2'
710 <?
if ($thisduration != 1440) echo "checked " ?
>/>
712 <td width
='1%' nowrap id
='tdallday2'>
713 <?
xl('Time','e'); ?
>
715 <td width
='1%' nowrap id
='tdallday3'>
716 <input type
='text' size
='2' name
='form_hour'
717 value
='<? echo $starttimeh ?>'
718 title
='<?php xl('Event start time
','e
'); ?>' /> :
719 <input type
='text' size
='2' name
='form_minute'
720 value
='<? echo $starttimem ?>'
721 title
='<?php xl('Event start time
','e
'); ?>' /> 
;
722 <select name
='form_ampm' title
='Note: 12:00 noon is PM, not AM'>
723 <option value
='1'><?php
xl('AM','e'); ?
></option
>
724 <option value
='2'<?
if ($startampm == '2') echo " selected" ?
>><?php
xl('PM','e'); ?
></option
>
730 <b
><?
xl('Title','e'); ?
>:</b
>
733 <input type
='text' size
='10' name
='form_title'
734 value
='<? echo addslashes($row['pc_title
']) ?>'
736 title
='<?php xl('Event title
','e
'); ?>' />
741 <td nowrap id
='tdallday4'><?
xl('duration','e'); ?
>
743 <td nowrap id
='tdallday5'>
744 <input type
='text' size
='4' name
='form_duration' value
='<? echo $thisduration ?>'
745 title
='<?php xl('Event duration in minutes
','e
'); ?>' /> <?
xl('minutes','e'); ?
>
750 <td nowrap
><b
><?php
xl('Facility','e'); ?
>:</b
></td
>
752 <select name
="facility" id
="facility">
754 // ===========================
755 // EVENTS TO FACILITIES
756 // get the facilities
757 $qsql = sqlStatement("SELECT * FROM facility");
758 while ($row = sqlFetchArray($qsql)) {
759 $selected = ( $row['id'] == $e2f ) ?
'selected="selected"' : '' ;
760 echo "<option value={$row['id']} $selected>{$row['name']}</option>";
763 // ===========================
772 <b
><?
xl('Patient','e'); ?
>:</b
>
775 <input type
='text' size
='10' name
='form_patient' style
='width:100%'
776 value
='<? echo $patientname ?>' onclick
='sel_patient()'
777 title
='<?php xl('Click to select patient
','e
'); ?>' readonly
/>
778 <input type
='hidden' name
='form_pid' value
='<? echo $patientid ?>' />
780 <td colspan
='3' nowrap style
='font-size:8pt'>
781  
;<?
echo $patienttitle ?
>
787 <b
><?
xl('Provider','e'); ?
>:</b
>
793 // =======================================
794 // multi providers case
795 // =======================================
796 if ($GLOBALS['select_multi_providers']) {
798 // there are two posible situations: edit and new record
800 // this is executed only on edit ($eid)
802 if ( $multiple_value ) {
803 // find all the providers around multiple key
804 $qall = sqlStatement ("SELECT pc_aid AS providers FROM openemr_postcalendar_events WHERE pc_multiple = $multiple_value");
805 while ($r = sqlFetchArray($qall)) {
806 $providers_array[] = $r['providers'];
809 $qall = sqlStatement ("SELECT pc_aid AS providers FROM openemr_postcalendar_events WHERE pc_eid = $eid");
810 $providers_array = sqlFetchArray($qall);
814 // build the selection tool
815 echo "<select name='form_provider[]' style='width:100%' multiple='multiple' size='5'>";
817 while ($urow = sqlFetchArray($ures)) {
818 echo " <option value='" . $urow['id'] . "'";
821 if ( in_array($urow['id'], $providers_array) ||
($urow['id'] == $userid) ) echo " selected";
824 echo ">" . $urow['lname'];
825 if ($urow['fname']) echo ", " . $urow['fname'];
831 // =======================================
832 // EOS multi providers case
833 // =======================================
836 <select name
='form_provider' style
='width:100%'>
838 while ($urow = sqlFetchArray($ures)) {
839 echo " <option value='" . $urow['id'] . "'";
841 if ($urow['id'] == $userid) echo " selected";
843 if ($urow['id'] == $_SESSION['authUserID']) echo " selected";
845 echo ">" . $urow['lname'];
846 if ($urow['fname']) echo ", " . $urow['fname'];
857 <input type
='checkbox' name
='form_repeat' onclick
='set_repeat(this)'
858 value
='1'<?
if ($repeats) echo " checked" ?
>/>
860 <td nowrap id
='tdrepeat1'><?
xl('Repeats','e'); ?
>
864 <select name
='form_repeat_freq' title
='Every, every other, every 3rd, etc.'>
866 foreach (array(1 => 'every', 2 => '2nd', 3 => '3rd', 4 => '4th', 5 => '5th', 6 => '6th')
869 echo " <option value='$key'";
870 if ($key == $repeatfreq) echo " selected";
871 echo ">$value</option>\n";
876 <select name
='form_repeat_type'>
878 // See common.api.php for these:
879 foreach (array(0 => 'day' , 4 => 'workday', 1 => 'week', 2 => 'month', 3 => 'year')
882 echo " <option value='$key'";
883 if ($key == $repeattype) echo " selected";
884 echo ">$value</option>\n";
894 <span id
='title_apptstatus'><b
><?
xl('Status','e'); ?
>:</b
></span
>
895 <span id
='title_prefcat' style
='display:none'><b
><?
xl('Pref Cat','e'); ?
>:</b
></span
>
899 <select name
='form_apptstatus' style
='width:100%' title
='<?php xl('Appointment status
','e
'); ?>'>
901 foreach ($statuses as $key => $value) {
902 echo " <option value='$key'";
903 if ($key == $row['pc_apptstatus']) echo " selected";
904 echo ">" . htmlspecialchars($value) . "</option>\n";
909 The following
list will be invisible unless this is an In Office
910 event
, in which
case form_apptstatus (above
) is to be invisible
.
912 <select name
='form_prefcat' style
='width:100%;display:none' title
='<?php xl('Preferred Event Category
','e
');?>'>
913 <?
echo $prefcat_options ?
>
920 <td nowrap id
='tdrepeat2'><?
xl('until','e'); ?
>
923 <input type
='text' size
='10' name
='form_enddate' id
='form_enddate'
924 value
='<? echo $row['pc_endDate
'] ?>'
925 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)'
926 title
='<?php xl('yyyy
-mm
-dd last date of this event
','e
');?>' />
927 <img src
='../../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
928 id
='img_enddate' border
='0' alt
='[?]' style
='cursor:pointer'
929 title
='<?php xl('Click here to choose a date
','e
');?>'>
935 <b
><?
xl('Comments','e'); ?
>:</b
>
937 <td colspan
='4' nowrap
>
938 <input type
='text' size
='40' name
='form_comments' style
='width:100%'
939 value
='<? echo $hometext ?>'
940 title
='<?php xl('Optional information about this event
','e
');?>' />
945 // DOB is important for the clinic, so if it's missing give them a chance
946 // to enter it right here. We must display or hide this row dynamically
947 // in case the patient-select popup is used.
948 $patient_dob = trim($prow['DOB']);
949 $dobstyle = ($prow && (!$patient_dob ||
substr($patient_dob, 5) == '00-00')) ?
952 <tr id
='dob_row' style
='display:<?php echo $dobstyle ?>'>
953 <td colspan
='4' nowrap
>
954 <b
><font color
='red'><?
xl('DOB is missing, please enter if possible','e'); ?
>:</font
></b
>
957 <input type
='text' size
='10' name
='form_dob' id
='form_dob'
958 title
='<?php xl('yyyy
-mm
-dd date of birth
','e
');?>'
959 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' />
960 <img src
='../../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
961 id
='img_dob' border
='0' alt
='[?]' style
='cursor:pointer'
962 title
='<?php xl('Click here to choose a date
','e
');?>'>
969 <input type
='submit' name
='form_save' value
='<?php xl('Save
','e
');?>' />
971 <input type
='button' value
='<?php xl('Find Available
','e
');?>' onclick
='find_available()' />
973 <input type
='submit' name
='form_delete' value
='<?php xl('Delete
','e
');?>'<?
if (!$eid) echo " disabled" ?
> />
975 <input type
='button' value
='<?php xl('Cancel
','e
');?>' onclick
='window.close()' />
980 <script language
='JavaScript'>
989 Calendar
.setup({inputField
:"form_date", ifFormat
:"%Y-%m-%d", button
:"img_date"});
990 Calendar
.setup({inputField
:"form_enddate", ifFormat
:"%Y-%m-%d", button
:"img_enddate"});
991 Calendar
.setup({inputField
:"form_dob", ifFormat
:"%Y-%m-%d", button
:"img_dob"});