2 // Copyright (C) 2005-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 // 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 $fake_register_globals=false;
24 $sanitize_all_escapes=true;
26 require_once("../../globals.php");
27 require_once("$srcdir/patient.inc");
28 require_once("$srcdir/forms.inc");
29 require_once("$srcdir/calendar.inc");
30 require_once("$srcdir/formdata.inc.php");
31 require_once("$srcdir/options.inc.php");
32 require_once("$srcdir/encounter_events.inc.php");
33 require_once("$srcdir/acl.inc");
35 $my_permission = acl_check('patients', 'appt');
36 if ($my_permission !== 'write' && $my_permission !== 'wsome')
37 die(xl('Access not allowed'));
39 // Things that might be passed by our opener.
41 $eid = $_GET['eid']; // only for existing events
42 $date = $_GET['date']; // this and below only for new events
43 $userid = $_GET['userid'];
44 $default_catid = $_GET['catid'] ?
$_GET['catid'] : '5';
47 $date = substr($date, 0, 4) . '-' . substr($date, 4, 2) . '-' . substr($date, 6);
49 $date = date("Y-m-d");
52 if (isset($_GET['starttimem']))
53 $starttimem = substr('00' . $_GET['starttimem'], -2);
55 if (isset($_GET['starttimeh'])) {
56 $starttimeh = $_GET['starttimeh'];
57 if (isset($_GET['startampm'])) {
58 if ($_GET['startampm'] == '2' && $starttimeh < 12)
62 $starttimeh = date("G");
70 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script
>
74 function InsertEventFull()
76 global $new_multiple_value,$provider,$event_date,$duration,$recurrspec,$starttime,$endtime,$locationspec;
77 // =======================================
78 // multi providers case
79 // =======================================
80 if (is_array($_POST['form_provider'])) {
82 // obtain the next available unique key to group multiple providers around some event
83 $q = sqlStatement ("SELECT MAX(pc_multiple) as max FROM openemr_postcalendar_events");
84 $max = sqlFetchArray($q);
85 $new_multiple_value = $max['max'] +
1;
87 foreach ($_POST['form_provider'] as $provider) {
89 // specify some special variables needed for the INSERT
90 $args['new_multiple_value'] = $new_multiple_value;
91 $args['form_provider'] = $provider;
92 $args['event_date'] = $event_date;
93 $args['duration'] = $duration * 60;
94 $args['recurrspec'] = $recurrspec;
95 $args['starttime'] = $starttime;
96 $args['endtime'] = $endtime;
97 $args['locationspec'] = $locationspec;
101 // ====================================
103 // ====================================
106 // specify some special variables needed for the INSERT
107 $args['new_multiple_value'] = "";
108 $args['event_date'] = $event_date;
109 $args['duration'] = $duration * 60;
110 $args['recurrspec'] = $recurrspec;
111 $args['starttime'] = $starttime;
112 $args['endtime'] = $endtime;
113 $args['locationspec'] = $locationspec;
117 function DOBandEncounter()
119 global $event_date,$info_msg;
120 // Save new DOB if it's there.
121 $patient_dob = trim($_POST['form_dob']);
122 if ($patient_dob && $_POST['form_pid']) {
123 sqlStatement("UPDATE patient_data SET DOB = ? WHERE " .
124 "pid = ?", array($patient_dob,$_POST['form_pid']) );
127 // Auto-create a new encounter if appropriate.
129 if ($GLOBALS['auto_create_new_encounters'] && $_POST['form_apptstatus'] == '@' && $event_date == date('Y-m-d'))
131 $encounter = todaysEncounterCheck($_POST['form_pid'], $event_date, $_POST['form_comments'], $_POST['facility'], $_POST['billing_facility'], $_POST['form_provider'], $_POST['form_category'], false);
133 $info_msg .= xl("New encounter created with id");
134 $info_msg .= " $encounter";
138 //================================================================================================================
140 // EVENTS TO FACILITIES (lemonsoftware)
141 //(CHEMED) get facility name
142 // edit event case - if there is no association made, then insert one with the first facility
145 $facility = sqlQuery("SELECT pc_facility, pc_multiple, pc_aid, facility.name
146 FROM openemr_postcalendar_events
147 LEFT JOIN facility ON (openemr_postcalendar_events.pc_facility = facility.id)
148 WHERE pc_eid = ?", array($eid) );
149 // if ( !$facility['pc_facility'] ) {
150 if ( is_array($facility) && !$facility['pc_facility'] ) {
151 $qmin = sqlQuery("SELECT facility_id as minId, facility FROM users WHERE id = ?", array($facility['pc_aid']) );
152 $min = $qmin['minId'];
153 $min_name = $qmin['facility'];
155 // multiple providers case
156 if ( $GLOBALS['select_multi_providers'] ) {
157 $mul = $facility['pc_multiple'];
158 sqlStatement("UPDATE openemr_postcalendar_events SET pc_facility = ? WHERE pc_multiple = ?", array($min,$mul) );
162 sqlStatement("UPDATE openemr_postcalendar_events SET pc_facility = ? WHERE pc_eid = ?", array($min,$eid) );
164 $e2f_name = $min_name;
167 if (!$facility['pc_facility'] && $_SESSION['pc_facility']) {
168 $e2f = $_SESSION['pc_facility'];
169 } elseif (!$facility['pc_facility'] && $_COOKIE['pc_facility'] && $GLOBALS['set_facility_cookie']) {
170 $e2f = $_COOKIE['pc_facility'];
172 $e2f = $facility['pc_facility'];
173 $e2f_name = $facility['name'];
178 // ===========================
179 //=============================================================================================================================
180 if ($_POST['form_action'] == "duplicate" ||
$_POST['form_action'] == "save")
182 // the starting date of the event, pay attention with this value
183 // when editing recurring events -- JRM Oct-08
184 $event_date = fixDate($_POST['form_date']);
186 // Compute start and end time strings to be saved.
187 if ($_POST['form_allday']) {
192 $tmph = $_POST['form_hour'] +
0;
193 $tmpm = $_POST['form_minute'] +
0;
194 if ($_POST['form_ampm'] == '2' && $tmph < 12) $tmph +
= 12;
195 $duration = $_POST['form_duration'];
197 $starttime = "$tmph:$tmpm:00";
200 while ($tmpm >= 60) {
204 $endtime = "$tmph:$tmpm:00";
206 // Useless garbage that we must save.
207 $locationspecs = array("event_location" => "",
208 "event_street1" => "",
209 "event_street2" => "",
214 $locationspec = serialize($locationspecs);
216 // capture the recurring specifications
217 $recurrspec = array("event_repeat_freq" => $_POST['form_repeat_freq'],
218 "event_repeat_freq_type" => $_POST['form_repeat_type'],
219 "event_repeat_on_num" => "1",
220 "event_repeat_on_day" => "0",
221 "event_repeat_on_freq" => "0",
222 "exdate" => $_POST['form_repeat_exdate']
225 // no recurr specs, this is used for adding a new non-recurring event
226 $noRecurrspec = array("event_repeat_freq" => "",
227 "event_repeat_freq_type" => "",
228 "event_repeat_on_num" => "1",
229 "event_repeat_on_day" => "0",
230 "event_repeat_on_freq" => "0",
234 }//if ($_POST['form_action'] == "duplicate" || $_POST['form_action'] == "save")
235 //=============================================================================================================================
236 if ($_POST['form_action'] == "duplicate") {
243 // If we are saving, then save and close the window.
245 if ($_POST['form_action'] == "save") {
246 /* =======================================================
248 * =====================================================*/
251 // what is multiple key around this $eid?
252 $row = sqlQuery("SELECT pc_multiple FROM openemr_postcalendar_events WHERE pc_eid = ?", array($eid) );
254 // ====================================
255 // multiple providers
256 // ====================================
257 if ($GLOBALS['select_multi_providers'] && $row['pc_multiple']) {
259 // obtain current list of providers regarding the multiple key
260 $up = sqlStatement("SELECT pc_aid FROM openemr_postcalendar_events WHERE pc_multiple=?", array($row['pc_multiple']) );
261 while ($current = sqlFetchArray($up)) { $providers_current[] = $current['pc_aid']; }
263 // get the new list of providers from the submitted form
264 $providers_new = $_POST['form_provider'];
266 // ===== Only current event of repeating series =====
267 if ($_POST['recurr_affect'] == 'current') {
269 // update all existing event records to exlude the current date
270 foreach ($providers_current as $provider) {
271 // update the provider's original event
272 // get the original event's repeat specs
273 $origEvent = sqlQuery("SELECT pc_recurrspec FROM openemr_postcalendar_events ".
274 " WHERE pc_aid = ? AND pc_multiple=?", array($provider,$row['pc_multiple']) );
275 $oldRecurrspec = unserialize($origEvent['pc_recurrspec']);
276 $selected_date = date("Ymd", strtotime($_POST['selected_date']));
277 if ($oldRecurrspec['exdate'] != "") { $oldRecurrspec['exdate'] .= ",".$selected_date; }
278 else { $oldRecurrspec['exdate'] .= $selected_date; }
280 // mod original event recur specs to exclude this date
281 sqlStatement("UPDATE openemr_postcalendar_events SET " .
282 " pc_recurrspec = ? ".
283 " WHERE pc_aid = ? AND pc_multiple=?", array(serialize($oldRecurrspec),$provider,$row['pc_multiple']) );
286 // obtain the next available unique key to group multiple providers around some event
287 $q = sqlStatement ("SELECT MAX(pc_multiple) as max FROM openemr_postcalendar_events");
288 $max = sqlFetchArray($q);
289 $new_multiple_value = $max['max'] +
1;
291 // insert a new event record for each provider selected on the form
292 foreach ($providers_new as $provider) {
293 // insert a new event on this date with POST form data
295 // specify some special variables needed for the INSERT
296 $args['new_multiple_value'] = $new_multiple_value;
297 $args['form_provider'] = $provider;
298 $args['event_date'] = $event_date;
299 $args['duration'] = $duration * 60;
300 // this event is forced to NOT REPEAT
301 $args['form_repeat'] = "0";
302 $args['recurrspec'] = $noRecurrspec;
303 $args['form_enddate'] = "0000-00-00";
304 $args['starttime'] = $starttime;
305 $args['endtime'] = $endtime;
306 $args['locationspec'] = $locationspec;
311 // ===== Future Recurring events of a repeating series =====
312 else if ($_POST['recurr_affect'] == 'future') {
313 // update all existing event records to
314 // stop recurring on this date-1
315 $selected_date = date("Ymd", (strtotime($_POST['selected_date'])-24*60*60));
316 foreach ($providers_current as $provider) {
317 // mod original event recur specs to end on this date
318 sqlStatement("UPDATE openemr_postcalendar_events SET " .
320 " WHERE pc_aid = ? AND pc_multiple=?", array($selected_date,$provider,$row['pc_multiple']) );
323 // obtain the next available unique key to group multiple providers around some event
324 $q = sqlStatement ("SELECT MAX(pc_multiple) as max FROM openemr_postcalendar_events");
325 $max = sqlFetchArray($q);
326 $new_multiple_value = $max['max'] +
1;
328 // insert a new event record for each provider selected on the form
329 foreach ($providers_new as $provider) {
330 // insert a new event on this date with POST form data
332 // specify some special variables needed for the INSERT
333 $args['new_multiple_value'] = $new_multiple_value;
334 $args['form_provider'] = $provider;
335 $args['event_date'] = $event_date;
336 $args['duration'] = $duration * 60;
337 $args['recurrspec'] = $recurrspec;
338 $args['starttime'] = $starttime;
339 $args['endtime'] = $endtime;
340 $args['locationspec'] = $locationspec;
346 /* =================================================================== */
347 // ===== a Single event or All events in a repeating series ==========
348 /* =================================================================== */
350 // this difference means that some providers from current was UNCHECKED
351 // so we must delete this event for them
352 $r1 = array_diff ($providers_current, $providers_new);
354 foreach ($r1 as $to_be_removed) {
355 sqlQuery("DELETE FROM openemr_postcalendar_events WHERE pc_aid=? AND pc_multiple=?", array($to_be_removed,$row['pc_multiple']) );
359 // perform a check to see if user changed event date
360 // this is important when editing an existing recurring event
362 if ($_POST['form_date'] == $_POST['selected_date']) {
363 // user has NOT changed the start date of the event
364 $event_date = fixDate($_POST['event_start_date']);
367 // this difference means that some providers were added
368 // so we must insert this event for them
369 $r2 = array_diff ($providers_new, $providers_current);
371 foreach ($r2 as $to_be_inserted) {
373 // specify some special variables needed for the INSERT
374 $args['new_multiple_value'] = $row['pc_multiple'];
375 $args['form_provider'] = $to_be_inserted;
376 $args['event_date'] = $event_date;
377 $args['duration'] = $duration * 60;
378 $args['recurrspec'] = $recurrspec;
379 $args['starttime'] = $starttime;
380 $args['endtime'] = $endtime;
381 $args['locationspec'] = $locationspec;
386 // after the two diffs above, we must update for remaining providers
387 // those who are intersected in $providers_current and $providers_new
388 foreach ($_POST['form_provider'] as $provider) {
389 sqlStatement("UPDATE openemr_postcalendar_events SET " .
390 "pc_catid = '" . add_escape_custom($_POST['form_category']) . "', " .
391 "pc_pid = '" . add_escape_custom($_POST['form_pid']) . "', " .
392 "pc_title = '" . add_escape_custom($_POST['form_title']) . "', " .
393 "pc_time = NOW(), " .
394 "pc_hometext = '" . add_escape_custom($_POST['form_comments']) . "', " .
395 "pc_informant = '" . add_escape_custom($_SESSION['authUserID']) . "', " .
396 "pc_eventDate = '" . add_escape_custom($event_date) . "', " .
397 "pc_endDate = '" . add_escape_custom(fixDate($_POST['form_enddate'])) . "', " .
398 "pc_duration = '" . add_escape_custom(($duration * 60)) . "', " .
399 "pc_recurrtype = '" . add_escape_custom(($_POST['form_repeat'] ?
'1' : '0')) . "', " .
400 "pc_recurrspec = '" . add_escape_custom(serialize($recurrspec)) . "', " .
401 "pc_startTime = '" . add_escape_custom($starttime) . "', " .
402 "pc_endTime = '" . add_escape_custom($endtime) . "', " .
403 "pc_alldayevent = '" . add_escape_custom($_POST['form_allday']) . "', " .
404 "pc_apptstatus = '" . add_escape_custom($_POST['form_apptstatus']) . "', " .
405 "pc_prefcatid = '" . add_escape_custom($_POST['form_prefcat']) . "' ," .
406 "pc_facility = '" . add_escape_custom((int)$_POST['facility']) ."' ," . // FF stuff
407 "pc_billing_location = '" . add_escape_custom((int)$_POST['billing_facility']) ."' " .
408 "WHERE pc_aid = ? AND pc_multiple=?", array($provider,$row['pc_multiple']) );
413 // ====================================
415 // ====================================
416 } elseif ( !$row['pc_multiple'] ) {
417 if ( $GLOBALS['select_multi_providers'] ) {
418 $prov = $_POST['form_provider'][0];
420 $prov = $_POST['form_provider'];
423 if ($_POST['recurr_affect'] == 'current') {
424 // get the original event's repeat specs
425 $origEvent = sqlQuery("SELECT pc_recurrspec FROM openemr_postcalendar_events WHERE pc_eid = ?", array($eid) );
426 $oldRecurrspec = unserialize($origEvent['pc_recurrspec']);
427 $selected_date = date("Ymd", strtotime($_POST['selected_date']));
428 if ($oldRecurrspec['exdate'] != "") { $oldRecurrspec['exdate'] .= ",".$selected_date; }
429 else { $oldRecurrspec['exdate'] .= $selected_date; }
431 // mod original event recur specs to exclude this date
432 sqlStatement("UPDATE openemr_postcalendar_events SET " .
433 " pc_recurrspec = ? ".
434 " WHERE pc_eid = ?", array(serialize($oldRecurrspec),$eid) );
436 // insert a new event on this date with POST form data
438 // specify some special variables needed for the INSERT
439 $args['event_date'] = $event_date;
440 $args['duration'] = $duration * 60;
441 // this event is forced to NOT REPEAT
442 $args['form_repeat'] = "0";
443 $args['recurrspec'] = $noRecurrspec;
444 $args['form_enddate'] = "0000-00-00";
445 $args['starttime'] = $starttime;
446 $args['endtime'] = $endtime;
447 $args['locationspec'] = $locationspec;
450 else if ($_POST['recurr_affect'] == 'future') {
451 // mod original event to stop recurring on this date-1
452 $selected_date = date("Ymd", (strtotime($_POST['selected_date'])-24*60*60));
453 sqlStatement("UPDATE openemr_postcalendar_events SET " .
455 " WHERE pc_eid = ?", array($selected_date,$eid) );
457 // insert a new event starting on this date with POST form data
459 // specify some special variables needed for the INSERT
460 $args['event_date'] = $event_date;
461 $args['duration'] = $duration * 60;
462 $args['recurrspec'] = $recurrspec;
463 $args['starttime'] = $starttime;
464 $args['endtime'] = $endtime;
465 $args['locationspec'] = $locationspec;
470 // perform a check to see if user changed event date
471 // this is important when editing an existing recurring event
473 if ($_POST['form_date'] == $_POST['selected_date']) {
474 // user has NOT changed the start date of the event
475 $event_date = fixDate($_POST['event_start_date']);
478 // mod the SINGLE event or ALL EVENTS in a repeating series
479 // simple provider case
480 sqlStatement("UPDATE openemr_postcalendar_events SET " .
481 "pc_catid = '" . add_escape_custom($_POST['form_category']) . "', " .
482 "pc_aid = '" . add_escape_custom($prov) . "', " .
483 "pc_pid = '" . add_escape_custom($_POST['form_pid']) . "', " .
484 "pc_title = '" . add_escape_custom($_POST['form_title']) . "', " .
485 "pc_time = NOW(), " .
486 "pc_hometext = '" . add_escape_custom($_POST['form_comments']) . "', " .
487 "pc_informant = '" . add_escape_custom($_SESSION['authUserID']) . "', " .
488 "pc_eventDate = '" . add_escape_custom($event_date) . "', " .
489 "pc_endDate = '" . add_escape_custom(fixDate($_POST['form_enddate'])) . "', " .
490 "pc_duration = '" . add_escape_custom(($duration * 60)) . "', " .
491 "pc_recurrtype = '" . add_escape_custom(($_POST['form_repeat'] ?
'1' : '0')) . "', " .
492 "pc_recurrspec = '" . add_escape_custom(serialize($recurrspec)) . "', " .
493 "pc_startTime = '" . add_escape_custom($starttime) . "', " .
494 "pc_endTime = '" . add_escape_custom($endtime) . "', " .
495 "pc_alldayevent = '" . add_escape_custom($_POST['form_allday']) . "', " .
496 "pc_apptstatus = '" . add_escape_custom($_POST['form_apptstatus']) . "', " .
497 "pc_prefcatid = '" . add_escape_custom($_POST['form_prefcat']) . "' ," .
498 "pc_facility = '" . add_escape_custom((int)$_POST['facility']) ."' ," . // FF stuff
499 "pc_billing_location = '" . add_escape_custom((int)$_POST['billing_facility']) ."' " .
500 "WHERE pc_eid = ?", array($eid) );
504 // =======================================
505 // end Update Multi providers case
506 // =======================================
508 // EVENTS TO FACILITIES
513 /* =======================================================
514 * INSERT NEW EVENT(S)
515 * ======================================================*/
521 // done with EVENT insert/update statements
527 // =======================================
529 // =======================================
530 else if ($_POST['form_action'] == "delete") {
531 // =======================================
532 // multi providers event
533 // =======================================
534 if ($GLOBALS['select_multi_providers']) {
536 // what is multiple key around this $eid?
537 $row = sqlQuery("SELECT pc_multiple FROM openemr_postcalendar_events WHERE pc_eid = ?", array($eid) );
539 // obtain current list of providers regarding the multiple key
540 $providers_current = array();
541 $up = sqlStatement("SELECT pc_aid FROM openemr_postcalendar_events WHERE pc_multiple=?", array($row['pc_multiple']) );
542 while ($current = sqlFetchArray($up)) { $providers_current[] = $current['pc_aid']; }
544 // establish a WHERE clause
545 if ( $row['pc_multiple'] ) { $whereClause = "pc_multiple = '{$row['pc_multiple']}'"; }
546 else { $whereClause = "pc_eid = '$eid'"; }
548 if ($_POST['recurr_affect'] == 'current') {
549 // update all existing event records to exlude the current date
550 foreach ($providers_current as $provider) {
551 // update the provider's original event
552 // get the original event's repeat specs
553 $origEvent = sqlQuery("SELECT pc_recurrspec FROM openemr_postcalendar_events ".
554 " WHERE pc_aid = ? AND pc_multiple=?", array($provider,$row['pc_multiple']) );
555 $oldRecurrspec = unserialize($origEvent['pc_recurrspec']);
556 $selected_date = date("Ymd", strtotime($_POST['selected_date']));
557 if ($oldRecurrspec['exdate'] != "") { $oldRecurrspec['exdate'] .= ",".$selected_date; }
558 else { $oldRecurrspec['exdate'] .= $selected_date; }
560 // mod original event recur specs to exclude this date
561 sqlStatement("UPDATE openemr_postcalendar_events SET " .
562 " pc_recurrspec = ? ".
563 " WHERE ". $whereClause, array(serialize($oldRecurrspec)) );
566 else if ($_POST['recurr_affect'] == 'future') {
567 // update all existing event records to stop recurring on this date-1
568 $selected_date = date("Ymd", (strtotime($_POST['selected_date'])-24*60*60));
569 foreach ($providers_current as $provider) {
570 // update the provider's original event
571 sqlStatement("UPDATE openemr_postcalendar_events SET " .
573 " WHERE ".$whereClause, array($selected_date) );
577 // really delete the event from the database
578 sqlStatement("DELETE FROM openemr_postcalendar_events WHERE ".$whereClause);
582 // =======================================
583 // single provider event
584 // =======================================
587 if ($_POST['recurr_affect'] == 'current') {
588 // mod original event recur specs to exclude this date
590 // get the original event's repeat specs
591 $origEvent = sqlQuery("SELECT pc_recurrspec FROM openemr_postcalendar_events WHERE pc_eid = ?", array($eid) );
592 $oldRecurrspec = unserialize($origEvent['pc_recurrspec']);
593 $selected_date = date("Ymd", strtotime($_POST['selected_date']));
594 if ($oldRecurrspec['exdate'] != "") { $oldRecurrspec['exdate'] .= ",".$selected_date; }
595 else { $oldRecurrspec['exdate'] .= $selected_date; }
596 sqlStatement("UPDATE openemr_postcalendar_events SET " .
597 " pc_recurrspec = ? ".
598 " WHERE pc_eid = ?", array(serialize($oldRecurrspec),$eid) );
601 else if ($_POST['recurr_affect'] == 'future') {
602 // mod original event to stop recurring on this date-1
603 $selected_date = date("Ymd", (strtotime($_POST['selected_date'])-24*60*60));
604 sqlStatement("UPDATE openemr_postcalendar_events SET " .
606 " WHERE pc_eid = ?", array($selected_date,$eid) );
610 // fully delete the event from the database
611 sqlStatement("DELETE FROM openemr_postcalendar_events WHERE pc_eid = ?", array($eid) );
616 if ($_POST['form_action'] != "") {
617 // Close this window and refresh the calendar display.
618 echo "<html>\n<body>\n<script language='JavaScript'>\n";
619 if ($info_msg) echo " alert('" . addslashes($info_msg) . "');\n";
620 echo " if (opener && !opener.closed && opener.refreshme) opener.refreshme();\n";
621 echo " window.close();\n";
622 echo "</script>\n</body>\n</html>\n";
626 //*********************************
627 // If we get this far then we are displaying the form.
628 //*********************************
630 /*********************************************************************
631 This has been migrate to the administration->lists
634 '*' => xl('* Reminder done'),
635 '+' => xl('+ Chart pulled'),
636 'x' => xl('x Cancelled'), // added Apr 2008 by JRM
637 '?' => xl('? No show'),
638 '@' => xl('@ Arrived'),
639 '~' => xl('~ Arrived late'),
640 '!' => xl('! Left w/o visit'),
641 '#' => xl('# Ins/fin issue'),
642 '<' => xl('< In exam room'),
643 '>' => xl('> Checked out'),
644 '$' => xl('$ Coding done'),
645 '%' => xl('% Cancelled < 24h ')
647 *********************************************************************/
649 $repeats = 0; // if the event repeats
653 if ($_REQUEST['patientid']) $patientid = $_REQUEST['patientid'];
654 $patientname = xl('Click to select');
660 // If we are editing an existing event, then get its data.
662 // $row = sqlQuery("SELECT * FROM openemr_postcalendar_events WHERE pc_eid = $eid");
664 $row = sqlQuery("SELECT e.*, u.fname, u.mname, u.lname " .
665 "FROM openemr_postcalendar_events AS e " .
666 "LEFT OUTER JOIN users AS u ON u.id = e.pc_informant " .
667 "WHERE pc_eid = ?", array($eid) );
668 $informant = $row['fname'] . ' ' . $row['mname'] . ' ' . $row['lname'];
670 // instead of using the event's starting date, keep what has been provided
671 // via the GET array, see the top of this file
672 if (empty($_GET['date'])) $date = $row['pc_eventDate'];
673 $eventstartdate = $row['pc_eventDate']; // for repeating event stuff - JRM Oct-08
674 $userid = $row['pc_aid'];
675 $patientid = $row['pc_pid'];
676 $starttimeh = substr($row['pc_startTime'], 0, 2) +
0;
677 $starttimem = substr($row['pc_startTime'], 3, 2);
678 $repeats = $row['pc_recurrtype'];
679 $multiple_value = $row['pc_multiple'];
681 // parse out the repeating data, if any
682 $rspecs = unserialize($row['pc_recurrspec']); // extract recurring data
683 $repeattype = $rspecs['event_repeat_freq_type'];
684 $repeatfreq = $rspecs['event_repeat_freq'];
685 $repeatexdate = $rspecs['exdate']; // repeating date exceptions
687 $hometext = $row['pc_hometext'];
688 if (substr($hometext, 0, 6) == ':text:') $hometext = substr($hometext, 6);
692 $eventstartdate = $date; // for repeating event stuff - JRM Oct-08
694 //-------------------------------------
696 //Set default facility for a new event based on the given 'userid'
698 /*************************************************************
699 $pref_facility = sqlFetchArray(sqlStatement("SELECT facility_id, facility FROM users WHERE id = $userid"));
700 *************************************************************/
701 if ($_SESSION['pc_facility']) {
702 $pref_facility = sqlFetchArray(sqlStatement("
703 SELECT f.id as facility_id,
708 array($_SESSION['pc_facility'])
711 $pref_facility = sqlFetchArray(sqlStatement("
712 SELECT u.facility_id,
715 LEFT JOIN facility f on (u.facility_id = f.id)
717 ", array($userid) ));
719 /************************************************************/
720 $e2f = $pref_facility['facility_id'];
721 $e2f_name = $pref_facility['facility'];
723 //END of CHEMED -----------------------
726 // If we have a patient ID, get the name and phone numbers to display.
728 $prow = sqlQuery("SELECT lname, fname, phone_home, phone_biz, DOB " .
729 "FROM patient_data WHERE pid = ?", array($patientid) );
730 $patientname = $prow['lname'] . ", " . $prow['fname'];
731 if ($prow['phone_home']) $patienttitle .= " H=" . $prow['phone_home'];
732 if ($prow['phone_biz']) $patienttitle .= " W=" . $prow['phone_biz'];
735 // Get the providers list.
736 $ures = sqlStatement("SELECT id, username, fname, lname FROM users WHERE " .
737 "authorized != 0 AND active = 1 ORDER BY lname, fname");
739 // Get event categories.
740 $cres = sqlStatement("SELECT pc_catid, pc_catname, pc_recurrtype, pc_duration, pc_end_all_day " .
741 "FROM openemr_postcalendar_categories ORDER BY pc_catname");
743 // Fix up the time format for AM/PM.
745 if ($starttimeh >= 12) { // p.m. starts at noon and not 12:01
747 if ($starttimeh > 12) $starttimeh -= 12;
753 <?php
html_header_show(); ?
>
754 <title
><?php
echo $eid ?
xlt('Edit') : xlt('Add New') ?
> <?php
echo xlt('Event');?
></title
>
755 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
758 td
{ font
-size
:0.8em
; }
761 <style type
="text/css">@import
url(../../../library
/dynarch_calendar
.css
);</style
>
762 <script type
="text/javascript" src
="../../../library/topdialog.js"></script
>
763 <script type
="text/javascript" src
="../../../library/dialog.js"></script
>
764 <script type
="text/javascript" src
="../../../library/textformat.js"></script
>
765 <script type
="text/javascript" src
="../../../library/dynarch_calendar.js"></script
>
766 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
767 <script type
="text/javascript" src
="../../../library/dynarch_calendar_setup.js"></script
>
769 <script language
="JavaScript">
771 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
773 var durations
= new Array();
774 // var rectypes = new Array();
776 // Read the event categories, generate their options list, and get
777 // the default event duration from them if this is a new event.
779 if($_GET['prov']==true){
782 $cres = sqlStatement("SELECT pc_catid, pc_catname, pc_recurrtype, pc_duration, pc_end_all_day " .
783 "FROM openemr_postcalendar_categories WHERE pc_cattype=? ORDER BY pc_catname", array($cattype) );
785 $prefcat_options = " <option value='0'>-- " . xlt("None") . " --</option>\n";
788 $thisduration = $row['pc_alldayevent'] ?
1440 : round($row['pc_duration'] / 60);
790 while ($crow = sqlFetchArray($cres)) {
791 $duration = round($crow['pc_duration'] / 60);
792 if ($crow['pc_end_all_day']) $duration = 1440;
793 echo " durations[" . attr($crow['pc_catid']) . "] = " . attr($duration) . "\n";
794 // echo " rectypes[" . $crow['pc_catid'] . "] = " . $crow['pc_recurrtype'] . "\n";
795 $catoptions .= " <option value='" . attr($crow['pc_catid']) . "'";
797 if ($crow['pc_catid'] == $row['pc_catid']) $catoptions .= " selected";
799 if ($crow['pc_catid'] == $default_catid) {
800 $catoptions .= " selected";
801 $thisduration = $duration;
804 $catoptions .= ">" . text(xl_appt_category($crow['pc_catname'])) . "</option>\n";
806 // This section is to build the list of preferred categories:
808 $prefcat_options .= " <option value='" . attr($crow['pc_catid']) . "'";
810 if ($crow['pc_catid'] == $row['pc_prefcatid']) $prefcat_options .= " selected";
812 $prefcat_options .= ">" . text(xl_appt_category($crow['pc_catname'])) . "</option>\n";
818 <?php
require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
820 // This is for callback by the find-patient popup.
821 function setpatient(pid
, lname
, fname
, dob
) {
822 var f
= document
.forms
[0];
823 f
.form_patient
.value
= lname +
', ' + fname
;
824 f
.form_pid
.value
= pid
;
825 dobstyle
= (dob
== '' || dob
.substr(5, 10) == '00-00') ?
'' : 'none';
826 document
.getElementById('dob_row').style
.display
= dobstyle
;
829 // This invokes the find-patient popup.
830 function sel_patient() {
831 dlgopen('find_patient_popup.php', '_blank', 500, 400);
834 // Do whatever is needed when a new event category is selected.
835 // For now this means changing the event title and duration.
836 function set_display() {
837 var f
= document
.forms
[0];
838 var s
= f
.form_category
;
839 if (s
.selectedIndex
>= 0) {
840 var catid
= s
.options
[s
.selectedIndex
].value
;
841 var style_apptstatus
= document
.getElementById('title_apptstatus').style
;
842 var style_prefcat
= document
.getElementById('title_prefcat').style
;
843 if (catid
== '2') { // In Office
844 style_apptstatus
.display
= 'none';
845 style_prefcat
.display
= '';
846 f
.form_apptstatus
.style
.display
= 'none';
847 f
.form_prefcat
.style
.display
= '';
849 style_prefcat
.display
= 'none';
850 style_apptstatus
.display
= '';
851 f
.form_prefcat
.style
.display
= 'none';
852 f
.form_apptstatus
.style
.display
= '';
857 // Do whatever is needed when a new event category is selected.
858 // For now this means changing the event title and duration.
859 function set_category() {
860 var f
= document
.forms
[0];
861 var s
= f
.form_category
;
862 if (s
.selectedIndex
>= 0) {
863 var catid
= s
.options
[s
.selectedIndex
].value
;
864 f
.form_title
.value
= s
.options
[s
.selectedIndex
].text
;
865 f
.form_duration
.value
= durations
[catid
];
870 // Modify some visual attributes when the all-day or timed-event
871 // radio buttons are clicked.
872 function set_allday() {
873 var f
= document
.forms
[0];
874 var color1
= '#777777';
875 var color2
= '#777777';
876 var disabled2
= true;
877 if (document
.getElementById('rballday1').checked
) {
880 if (document
.getElementById('rballday2').checked
) {
884 document
.getElementById('tdallday1').style
.color
= color1
;
885 document
.getElementById('tdallday2').style
.color
= color2
;
886 document
.getElementById('tdallday3').style
.color
= color2
;
887 document
.getElementById('tdallday4').style
.color
= color2
;
888 document
.getElementById('tdallday5').style
.color
= color2
;
889 f
.form_hour
.disabled
= disabled2
;
890 f
.form_minute
.disabled
= disabled2
;
891 f
.form_ampm
.disabled
= disabled2
;
892 f
.form_duration
.disabled
= disabled2
;
895 // Modify some visual attributes when the Repeat checkbox is clicked.
896 function set_repeat() {
897 var f
= document
.forms
[0];
898 var isdisabled
= true;
899 var mycolor
= '#777777';
900 var myvisibility
= 'hidden';
901 if (f
.form_repeat
.checked
) {
904 myvisibility
= 'visible';
906 f
.form_repeat_type
.disabled
= isdisabled
;
907 f
.form_repeat_freq
.disabled
= isdisabled
;
908 f
.form_enddate
.disabled
= isdisabled
;
909 document
.getElementById('tdrepeat1').style
.color
= mycolor
;
910 document
.getElementById('tdrepeat2').style
.color
= mycolor
;
911 document
.getElementById('img_enddate').style
.visibility
= myvisibility
;
914 // This is for callback by the find-available popup.
915 function setappt(year
,mon
,mday
,hours
,minutes
) {
916 var f
= document
.forms
[0];
917 f
.form_date
.value
= '' + year +
'-' +
918 ('' +
(mon +
100)).substring(1) +
'-' +
919 ('' +
(mday +
100)).substring(1);
920 f
.form_ampm
.selectedIndex
= (hours
>= 12) ?
1 : 0;
921 f
.form_hour
.value
= (hours
> 12) ? hours
- 12 : hours
;
922 f
.form_minute
.value
= ('' +
(minutes +
100)).substring(1);
925 // Invoke the find-available popup.
926 function find_available(extra
) {
927 top
.restoreSession();
928 // (CHEMED) Conditional value selection, because there is no <select> element
929 // when making an appointment for a specific provider
930 var s
= document
.forms
[0].form_provider
;
931 var f
= document
.forms
[0].facility
;
932 <?php
if ($userid != 0) { ?
>
933 s
= document
.forms
[0].form_provider
.value
;
934 f
= document
.forms
[0].facility
.value
;
936 s
= document
.forms
[0].form_provider
.options
[s
.selectedIndex
].value
;
937 f
= document
.forms
[0].facility
.options
[f
.selectedIndex
].value
;
939 var c
= document
.forms
[0].form_category
;
940 var formDate
= document
.forms
[0].form_date
;
941 dlgopen('<?php echo $GLOBALS['web_root
']; ?>/interface/main/calendar/find_appt_popup.php' +
943 '&catid=' + c
.options
[c
.selectedIndex
].value +
945 '&startdate=' + formDate
.value +
946 '&evdur=' + document
.forms
[0].form_duration
.value +
947 '&eid=<?php echo 0 + $eid; ?>' +
950 //END (CHEMED) modifications
955 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8" />
959 <body
class="body_top" onunload
='imclosing()'>
961 <form method
='post' name
='theform' id
='theform' action
='add_edit_event.php?eid=<?php echo attr($eid) ?>' />
962 <!-- ViSolve
: Requirement
- Redirect to Create
New Patient Page
-->
963 <input type
='hidden' size
='2' name
='resname' value
='empty' />
965 if ($_POST["resname"]=="noresult"){
967 <script language="Javascript">
968 // refresh and redirect the parent window
969 if (!opener.closed && opener.refreshme) opener.refreshme();
970 top.restoreSession();
971 opener.document.location="../../new/new.php";
976 $classprov='current';
979 <!-- ViSolve
: Requirement
- Redirect to Create
New Patient Page
-->
980 <input type
="hidden" name
="form_action" id
="form_action" value
="">
981 <input type
="hidden" name
="recurr_affect" id
="recurr_affect" value
="">
982 <!-- used
for recurring events
-->
983 <input type
="hidden" name
="selected_date" id
="selected_date" value
="<?php echo attr($date); ?>">
984 <input type
="hidden" name
="event_start_date" id
="event_start_date" value
="<?php echo attr($eventstartdate); ?>">
990 if($_GET['prov']==true){
991 $provider_class="class='current'";
994 $normal="class='current'";
997 <tr
><th
><ul
class="tabNav">
999 $eid=$_REQUEST["eid"];
1000 $startm=$_REQUEST["startampm"];
1001 $starth=$_REQUEST["starttimeh"];
1002 $uid=$_REQUEST["userid"];
1003 $starttm=$_REQUEST["starttimem"];
1004 $dt=$_REQUEST["date"];
1005 $cid=$_REQUEST["catid"];
1007 <li
<?php
echo $normal;?
>>
1008 <a href
='add_edit_event.php?eid=<?php echo attr($eid);?>&startampm=<?php echo attr($startm);?>&starttimeh=<?php echo attr($starth);?>&userid=<?php echo attr($uid);?>&starttimem=<?php echo attr($starttm);?>&date=<?php echo attr($dt);?>&catid=<?php echo attr($cid);?>'>
1009 <?php
echo xlt('Patient');?
></a
>
1011 <li
<?php
echo $provider_class;?
>>
1012 <a href
='add_edit_event.php?prov=true&eid=<?php echo attr($eid);?>&startampm=<?php echo attr($startm);?>&starttimeh=<?php echo attr($starth);?>&userid=<?php echo attr($uid);?>&starttimem=<?php echo attr($starttm);?>&date=<?php echo attr($dt);?>&catid=<?php echo attr($cid);?>'>
1013 <?php
echo xlt('Provider');?
></a
>
1017 <tr
><td colspan
='10'>
1018 <table border
='0' width
='100%' bgcolor
='#DDDDDD' >
1021 <td width
='1%' nowrap
>
1022 <b
><?php
echo ($GLOBALS['athletic_team'] ?
xlt('Team/Squad') : xlt('Category')); ?
>:</b
>
1025 <select name
='form_category' onchange
='set_category()' style
='width:100%'>
1026 <?php
echo $catoptions ?
>
1029 <td width
='1%' nowrap
>
1031 <input type
='radio' name
='form_allday' onclick
='set_allday()' value
='1' id
='rballday1'
1032 <?php
if ($thisduration == 1440) echo "checked " ?
>/>
1034 <td colspan
='2' nowrap id
='tdallday1'>
1035 <?php
echo xlt('All day event'); ?
>
1041 <b
><?php
echo xlt('Date'); ?
>:</b
>
1044 <input type
='text' size
='10' name
='form_date' id
='form_date'
1045 value
='<?php echo attr($date) ?>'
1046 title
='<?php echo xla('yyyy
-mm
-dd event date
or starting date
'); ?>'
1047 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' />
1048 <img src
='../../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
1049 id
='img_date' border
='0' alt
='[?]' style
='cursor:pointer;cursor:hand'
1050 title
='<?php echo xla('Click here to choose a date
'); ?>'>
1054 <input type
='radio' name
='form_allday' onclick
='set_allday()' value
='0' id
='rballday2' <?php
if ($thisduration != 1440) echo "checked " ?
>/>
1056 <td width
='1%' nowrap id
='tdallday2'>
1057 <?php
echo xlt('Time'); ?
>
1059 <td width
='1%' nowrap id
='tdallday3'>
1060 <input type
='text' size
='2' name
='form_hour' value
='<?php echo attr($starttimeh) ?>'
1061 title
='<?php echo xla('Event start time
'); ?>' /> :
1062 <input type
='text' size
='2' name
='form_minute' value
='<?php echo attr($starttimem) ?>'
1063 title
='<?php echo xla('Event start time
'); ?>' /> 
;
1064 <select name
='form_ampm' title
='<?php echo xla("Note: 12:00 noon is PM, not AM"); ?>'>
1065 <option value
='1'><?php
echo xlt('AM'); ?
></option
>
1066 <option value
='2'<?php
if ($startampm == '2') echo " selected" ?
>><?php
echo xlt('PM'); ?
></option
>
1073 <b
><?php
echo ($GLOBALS['athletic_team'] ?
xlt('Team/Squad') : xlt('Title')); ?
>:</b
>
1076 <input type
='text' size
='10' name
='form_title' value
='<?php echo attr($row['pc_title
']); ?>'
1078 title
='<?php echo xla('Event title
'); ?>' />
1083 <td nowrap id
='tdallday4'><?php
echo xlt('duration'); ?
>
1085 <td nowrap id
='tdallday5'>
1086 <input type
='text' size
='4' name
='form_duration' value
='<?php echo attr($thisduration) ?>' title
='<?php echo xla('Event duration in minutes
'); ?>' />
1087 <?php
echo xlt('minutes'); ?
>
1092 <td nowrap
><b
><?php
echo xlt('Facility'); ?
>:</b
></td
>
1094 <select name
="facility" id
="facility" >
1097 // ===========================
1098 // EVENTS TO FACILITIES
1099 //(CHEMED) added service_location WHERE clause
1100 // get the facilities
1101 /***************************************************************
1102 $qsql = sqlStatement("SELECT * FROM facility WHERE service_location != 0");
1103 ***************************************************************/
1104 $facils = getUserFacilities($_SESSION['authId']);
1105 $qsql = sqlStatement("SELECT id, name FROM facility WHERE service_location != 0");
1106 /**************************************************************/
1107 while ($facrow = sqlFetchArray($qsql)) {
1108 /*************************************************************
1109 $selected = ( $facrow['id'] == $e2f ) ? 'selected="selected"' : '' ;
1110 echo "<option value={$facrow['id']} $selected>{$facrow['name']}</option>";
1111 *************************************************************/
1112 if ($_SESSION['authorizedUser'] ||
in_array($facrow, $facils)) {
1113 $selected = ( $facrow['id'] == $e2f ) ?
'selected="selected"' : '' ;
1114 echo "<option value='" . attr($facrow['id']) . "' $selected>" . text($facrow['name']) . "</option>";
1117 $selected = ( $facrow['id'] == $e2f ) ?
'selected="selected"' : '' ;
1118 echo "<option value='" . attr($facrow['id']) . "' $selected>" . text($facrow['name']) . "</option>";
1120 /************************************************************/
1123 // ===========================
1126 //END (CHEMED) IF ?>
1132 <b
><?php
echo xlt('Billing Facility'); ?
>:</b
>
1136 billing_facility('billing_facility',$row['pc_billing_location']);
1141 if($_GET['prov']!=true){
1143 <tr id
="patient_details">
1145 <b
><?php
echo xlt('Patient'); ?
>:</b
>
1148 <input type
='text' size
='10' name
='form_patient' style
='width:100%;cursor:pointer;cursor:hand' value
='<?php echo attr($patientname); ?>' onclick
='sel_patient()' title
='<?php echo xla('Click to select patient
'); ?>' readonly
/>
1149 <input type
='hidden' name
='form_pid' value
='<?php echo attr($patientid) ?>' />
1151 <td colspan
='3' nowrap style
='font-size:8pt'>
1153 <span
class="infobox">
1154 <?php
if ($patienttitle != "") { echo $patienttitle; } ?
>
1163 <b
><?php
echo xlt('Provider'); ?
>:</b
>
1169 // =======================================
1171 // =======================================
1172 if ($GLOBALS['select_multi_providers']) {
1174 // there are two posible situations: edit and new record
1176 // this is executed only on edit ($eid)
1178 if ( $multiple_value ) {
1179 // find all the providers around multiple key
1180 $qall = sqlStatement ("SELECT pc_aid AS providers FROM openemr_postcalendar_events WHERE pc_multiple = ?", array($multiple_value) );
1181 while ($r = sqlFetchArray($qall)) {
1182 $providers_array[] = $r['providers'];
1185 $qall = sqlStatement ("SELECT pc_aid AS providers FROM openemr_postcalendar_events WHERE pc_eid = ?", array($eid) );
1186 $providers_array = sqlFetchArray($qall);
1190 // build the selection tool
1191 echo "<select name='form_provider[]' style='width:100%' multiple='multiple' size='5' >";
1193 while ($urow = sqlFetchArray($ures)) {
1194 echo " <option value='" . attr($urow['id']) . "'";
1197 if ( in_array($urow['id'], $providers_array) ||
($urow['id'] == $userid) ) echo " selected";
1200 echo ">" . text($urow['lname']);
1201 if ($urow['fname']) echo ", " . text($urow['fname']);
1207 // =======================================
1209 // =======================================
1213 // get provider from existing event
1214 $qprov = sqlStatement ("SELECT pc_aid FROM openemr_postcalendar_events WHERE pc_eid = ?", array($eid) );
1215 $provider = sqlFetchArray($qprov);
1216 $defaultProvider = $provider['pc_aid'];
1219 // this is a new event so smartly choose a default provider
1220 /*****************************************************************
1222 // Provider already given to us as a GET parameter.
1223 $defaultProvider = $userid;
1226 // default to the currently logged-in user
1227 $defaultProvider = $_SESSION['authUserID'];
1228 // or, if we have chosen a provider in the calendar, default to them
1229 // choose the first one if multiple have been selected
1230 if (count($_SESSION['pc_username']) >= 1) {
1231 // get the numeric ID of the first provider in the array
1232 $pc_username = $_SESSION['pc_username'];
1233 $firstProvider = sqlFetchArray(sqlStatement("select id from users where username='".$pc_username[0]."'"));
1234 $defaultProvider = $firstProvider['id'];
1239 echo "<select name='form_provider' style='width:100%' />";
1240 while ($urow = sqlFetchArray($ures)) {
1241 echo " <option value='" . $urow['id'] . "'";
1242 if ($urow['id'] == $defaultProvider) echo " selected";
1243 echo ">" . $urow['lname'];
1244 if ($urow['fname']) echo ", " . $urow['fname'];
1248 *****************************************************************/
1249 // default to the currently logged-in user
1250 $defaultProvider = $_SESSION['authUserID'];
1251 // or, if we have chosen a provider in the calendar, default to them
1252 // choose the first one if multiple have been selected
1253 if (count($_SESSION['pc_username']) >= 1) {
1254 // get the numeric ID of the first provider in the array
1255 $pc_username = $_SESSION['pc_username'];
1256 $firstProvider = sqlFetchArray(sqlStatement("select id from users where username=?", array($pc_username[0]) ));
1257 $defaultProvider = $firstProvider['id'];
1259 // if we clicked on a provider's schedule to add the event, use THAT.
1260 if ($userid) $defaultProvider = $userid;
1262 echo "<select name='form_provider' style='width:100%' />";
1263 while ($urow = sqlFetchArray($ures)) {
1264 echo " <option value='" . attr($urow['id']) . "'";
1265 if ($urow['id'] == $defaultProvider) echo " selected";
1266 echo ">" . text($urow['lname']);
1267 if ($urow['fname']) echo ", " . text($urow['fname']);
1271 /****************************************************************/
1279 <input type
='checkbox' name
='form_repeat' onclick
='set_repeat(this)' value
='1'<?php
if ($repeats) echo " checked" ?
>/>
1280 <input type
='hidden' name
='form_repeat_exdate' id
='form_repeat_exdate' value
='<?php echo attr($repeatexdate); ?>' /> <!-- dates excluded from the repeat
-->
1282 <td nowrap id
='tdrepeat1'><?php
echo xlt('Repeats'); ?
>
1286 <select name
='form_repeat_freq' title
='<?php echo xla('Every
, every other
, every
3rd
, etc
.'); ?>'>
1288 foreach (array(1 => xl('every'), 2 => xl('2nd'), 3 => xl('3rd'), 4 => xl('4th'), 5 => xl('5th'), 6 => xl('6th'))
1291 echo " <option value='" . attr($key) . "'";
1292 if ($key == $repeatfreq) echo " selected";
1293 echo ">" . text($value) . "</option>\n";
1298 <select name
='form_repeat_type'>
1300 // See common.api.php for these:
1301 foreach (array(0 => xl('day') , 4 => xl('workday'), 1 => xl('week'), 2 => xl('month'), 3 => xl('year'))
1304 echo " <option value='" . attr($key) . "'";
1305 if ($key == $repeattype) echo " selected";
1306 echo ">" . text($value) . "</option>\n";
1316 <span id
='title_apptstatus'><b
><?php
echo ($GLOBALS['athletic_team'] ?
xlt('Session Type') : xlt('Status')); ?
>:</b
></span
>
1317 <span id
='title_prefcat' style
='display:none'><b
><?php
echo xlt('Pref Cat'); ?
>:</b
></span
>
1322 generate_form_field(array('data_type'=>1,'field_id'=>'apptstatus','list_id'=>'apptstat','empty_title'=>'SKIP'), $row['pc_apptstatus']);
1325 The following
list will be invisible unless this is an In Office
1326 event
, in which
case form_apptstatus (above
) is to be invisible
.
1328 <select name
='form_prefcat' style
='width:100%;display:none' title
='<?php echo xla('Preferred Event Category
');?>'>
1329 <?php
echo $prefcat_options ?
>
1336 <td nowrap id
='tdrepeat2'><?php
echo xlt('until'); ?
>
1339 <input type
='text' size
='10' name
='form_enddate' id
='form_enddate' value
='<?php echo attr($row['pc_endDate
']) ?>' onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='<?php echo xla('yyyy
-mm
-dd last date of this event
');?>' />
1340 <img src
='../../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
1341 id
='img_enddate' border
='0' alt
='[?]' style
='cursor:pointer;cursor:hand'
1342 title
='<?php echo xla('Click here to choose a date
');?>'>
1344 if ($repeatexdate != "") {
1345 $tmptitle = "The following dates are excluded from the repeating series";
1346 if ($multiple_value) { $tmptitle .= " for one or more providers:\n"; }
1347 else { $tmptitle .= "\n"; }
1348 $exdates = explode(",", $repeatexdate);
1349 foreach ($exdates as $exdate) {
1350 $tmptitle .= date("d M Y", strtotime($exdate))."\n";
1352 echo "<a href='#' title='" . attr($tmptitle) . "' alt='" . attr($tmptitle) . "'><img src='../../pic/warning.gif' title='" . attr($tmptitle) . "' alt='*!*' style='border:none;'/></a>";
1360 <b
><?php
echo xlt('Comments'); ?
>:</b
>
1362 <td colspan
='4' nowrap
>
1363 <input type
='text' size
='40' name
='form_comments' style
='width:100%' value
='<?php echo attr($hometext); ?>' title
='<?php echo xla('Optional information about this event
');?>' />
1368 // DOB is important for the clinic, so if it's missing give them a chance
1369 // to enter it right here. We must display or hide this row dynamically
1370 // in case the patient-select popup is used.
1371 $patient_dob = trim($prow['DOB']);
1372 $dobstyle = ($prow && (!$patient_dob ||
substr($patient_dob, 5) == '00-00')) ?
1375 <tr id
='dob_row' style
='display:<?php echo $dobstyle ?>'>
1376 <td colspan
='4' nowrap
>
1377 <b
><font color
='red'><?php
echo xlt('DOB is missing, please enter if possible'); ?
>:</font
></b
>
1380 <input type
='text' size
='10' name
='form_dob' id
='form_dob' title
='<?php echo xla('yyyy
-mm
-dd date of birth
');?>' onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' />
1381 <img src
='../../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
1382 id
='img_dob' border
='0' alt
='[?]' style
='cursor:pointer;cursor:hand'
1383 title
='<?php echo xla('Click here to choose a date
');?>'>
1388 <tr
class='text'><td colspan
='10'>
1390 <input type
='button' name
='form_save' id
='form_save' value
='<?php echo xla('Save
');?>' />
1392 <input type
='button' id
='find_available' value
='<?php echo xla('Find Available
');?>' />
1394 <input type
='button' name
='form_delete' id
='form_delete' value
='<?php echo xla('Delete
');?>'<?php
if (!$eid) echo " disabled" ?
> />
1396 <input type
='button' id
='cancel' value
='<?php echo xla('Cancel
');?>' />
1398 <input type
='button' name
='form_duplicate' id
='form_duplicate' value
='<?php echo xla('Create Duplicate
');?>' />
1399 </p
></td
></tr
></table
>
1400 <?php
if ($informant) echo "<p class='text'>" . xlt('Last update by') . " text($informant) " . xlt('on') . " " . text($row['pc_time']) . "</p>\n"; ?
>
1404 <div id
="recurr_popup" style
="visibility: hidden; position: absolute; top: 50px; left: 50px; width: 400px; border: 3px outset yellow; background-color: yellow; padding: 5px;">
1405 <?php
echo xlt('Apply the changes to the Current event only, to this and all Future occurrences, or to All occurrences?') ?
>
1407 <input type
="button" name
="all_events" id
="all_events" value
=" All ">
1408 <input type
="button" name
="future_events" id
="future_events" value
="Future">
1409 <input type
="button" name
="current_event" id
="current_event" value
="Current">
1410 <input type
="button" name
="recurr_cancel" id
="recurr_cancel" value
="Cancel">
1415 <script language
='JavaScript'>
1416 <?php
if ($eid) { ?
>
1424 Calendar
.setup({inputField
:"form_date", ifFormat
:"%Y-%m-%d", button
:"img_date"});
1425 Calendar
.setup({inputField
:"form_enddate", ifFormat
:"%Y-%m-%d", button
:"img_enddate"});
1426 Calendar
.setup({inputField
:"form_dob", ifFormat
:"%Y-%m-%d", button
:"img_dob"});
1429 <script language
="javascript">
1430 // jQuery stuff to make the page a little easier to use
1432 $
(document
).ready(function(){
1433 $
("#form_save").click(function() { validate("save"); });
1434 $
("#form_duplicate").click(function() { validate("duplicate"); });
1435 $
("#find_available").click(function() { find_available(''); });
1436 $
("#form_delete").click(function() { deleteEvent(); });
1437 $
("#cancel").click(function() { window
.close(); });
1439 // buttons affecting the modification of a repeating event
1440 $
("#all_events").click(function() { $
("#recurr_affect").val("all"); EnableForm(); SubmitForm(); });
1441 $
("#future_events").click(function() { $
("#recurr_affect").val("future"); EnableForm(); SubmitForm(); });
1442 $
("#current_event").click(function() { $
("#recurr_affect").val("current"); EnableForm(); SubmitForm(); });
1443 $
("#recurr_cancel").click(function() { $
("#recurr_affect").val(""); EnableForm(); HideRecurrPopup(); });
1446 // Check for errors when the form is submitted.
1447 function validate(valu
) {
1448 var f
= document
.getElementById('theform');
1449 if (f
.form_repeat
.checked
&&
1450 (! f
.form_enddate
.value || f
.form_enddate
.value
< f
.form_date
.value
)) {
1451 alert('<?php echo addslashes(xl("An end date later than the start date is required for repeated events!")); ?>');
1455 if($_GET['prov']!=true){
1457 if(f
.form_pid
.value
== ''){
1458 alert('<?php echo addslashes(xl('Patient Name Required
'));?>');
1464 $
('#form_action').val(valu
);
1466 <?php
if ($repeats): ?
>
1467 // existing repeating events need additional prompt
1468 if ($
("#recurr_affect").val() == "") {
1470 // show the current/future/all DIV for the user to choose one
1471 $
("#recurr_popup").css("visibility", "visible");
1476 return SubmitForm();
1479 // disable all the form elements outside the recurr_popup
1480 function DisableForm() {
1481 $
("#theform").children().attr("disabled", "true");
1483 function EnableForm() {
1484 $
("#theform").children().removeAttr("disabled");
1486 // hide the recurring popup DIV
1487 function HideRecurrPopup() {
1488 $
("#recurr_popup").css("visibility", "hidden");
1491 function deleteEvent() {
1492 if (confirm("<?php echo addslashes(xl('Deleting this event cannot be undone. It cannot be recovered once it is gone.\nAre you sure you wish to delete this event?')); ?>")) {
1493 $
('#form_action').val("delete");
1495 <?php
if ($repeats): ?
>
1496 // existing repeating events need additional prompt
1497 if ($
("#recurr_affect").val() == "") {
1499 // show the current/future/all DIV for the user to choose one
1500 $
("#recurr_popup").css("visibility", "visible");
1505 return SubmitForm();
1510 function SubmitForm() {
1511 var f
= document
.forms
[0];
1512 if (f
.form_action
.value
!= 'delete') {
1513 // Check slot availability.
1514 var mins
= parseInt(f
.form_hour
.value
) * 60 +
parseInt(f
.form_minute
.value
);
1515 if (f
.form_ampm
.value
== '2' && mins
< 720) mins +
= 720;
1516 find_available('&cktime=' + mins
);
1519 top
.restoreSession();