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 include_once("../../globals.php");
24 include_once("$srcdir/patient.inc");
25 include_once("$srcdir/forms.inc");
26 include_once("$srcdir/calendar.inc");
27 include_once("$srcdir/formdata.inc.php");
28 include_once("$srcdir/options.inc.php");
30 // Things that might be passed by our opener.
32 $eid = $_GET['eid']; // only for existing events
33 $date = $_GET['date']; // this and below only for new events
34 $userid = $_GET['userid'];
35 $default_catid = $_GET['catid'] ?
$_GET['catid'] : '5';
38 $date = substr($date, 0, 4) . '-' . substr($date, 4, 2) . '-' . substr($date, 6);
40 $date = date("Y-m-d");
43 if (isset($_GET['starttimem']))
44 $starttimem = substr('00' . $_GET['starttimem'], -2);
46 if (isset($_GET['starttimeh'])) {
47 $starttimeh = $_GET['starttimeh'];
48 if (isset($_GET['startampm'])) {
49 if ($_GET['startampm'] == '2' && $starttimeh < 12)
53 $starttimeh = date("G");
61 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script
>
66 // $args is mainly filled with content from the POST http var
67 function InsertEvent($args) {
68 return sqlInsert("INSERT INTO openemr_postcalendar_events ( " .
69 "pc_catid, pc_multiple, pc_aid, pc_pid, pc_title, pc_time, pc_hometext, " .
70 "pc_informant, pc_eventDate, pc_endDate, pc_duration, pc_recurrtype, " .
71 "pc_recurrspec, pc_startTime, pc_endTime, pc_alldayevent, " .
72 "pc_apptstatus, pc_prefcatid, pc_location, pc_eventstatus, pc_sharing, pc_facility,pc_billing_location " .
74 "'" . $args['form_category'] . "', " .
75 "'" . $args['new_multiple_value'] . "', " .
76 "'" . $args['form_provider'] . "', " .
77 "'" . $args['form_pid'] . "', " .
78 "'" . formDataCore($args['form_title']) . "', " .
80 "'" . formDataCore($args['form_comments']) . "', " .
81 "'" . $_SESSION['authUserID'] . "', " .
82 "'" . $args['event_date'] . "', " .
83 "'" . fixDate($args['form_enddate']) . "', " .
84 "'" . $args['duration'] . "', " .
85 "'" . ($args['form_repeat'] ?
'1' : '0') . "', " .
86 "'" . serialize($args['recurrspec']) . "', " .
87 "'" . $args['starttime'] ."', " .
88 "'" . $args['endtime'] ."', " .
89 "'" . $args['form_allday'] . "', " .
90 "'" . $args['form_apptstatus'] . "', " .
91 "'" . $args['form_prefcat'] . "', " .
92 "'" . $args['locationspec'] ."', " .
94 "1, " .(int)$args['facility']. ",".(int)$args['billing_facility']." )"
97 //================================================================================================================
98 function InsertEventFull()
100 global $new_multiple_value,$provider,$event_date,$duration,$recurrspec,$starttime,$endtime,$locationspec;
101 // =======================================
102 // multi providers case
103 // =======================================
104 if (is_array($_POST['form_provider'])) {
106 // obtain the next available unique key to group multiple providers around some event
107 $q = sqlStatement ("SELECT MAX(pc_multiple) as max FROM openemr_postcalendar_events");
108 $max = sqlFetchArray($q);
109 $new_multiple_value = $max['max'] +
1;
111 foreach ($_POST['form_provider'] as $provider) {
113 // specify some special variables needed for the INSERT
114 $args['new_multiple_value'] = $new_multiple_value;
115 $args['form_provider'] = $provider;
116 $args['event_date'] = $event_date;
117 $args['duration'] = $duration * 60;
118 $args['recurrspec'] = $recurrspec;
119 $args['starttime'] = $starttime;
120 $args['endtime'] = $endtime;
121 $args['locationspec'] = $locationspec;
125 // ====================================
127 // ====================================
130 // specify some special variables needed for the INSERT
131 $args['new_multiple_value'] = "";
132 $args['event_date'] = $event_date;
133 $args['duration'] = $duration * 60;
134 $args['recurrspec'] = $recurrspec;
135 $args['starttime'] = $starttime;
136 $args['endtime'] = $endtime;
137 $args['locationspec'] = $locationspec;
141 function DOBandEncounter()
143 global $event_date,$info_msg;
144 // Save new DOB if it's there.
145 $patient_dob = trim($_POST['form_dob']);
146 if ($patient_dob && $_POST['form_pid']) {
147 sqlStatement("UPDATE patient_data SET DOB = '$patient_dob' WHERE " .
148 "pid = '" . $_POST['form_pid'] . "'");
151 // Auto-create a new encounter if appropriate.
153 if ($GLOBALS['auto_create_new_encounters'] &&
154 $_POST['form_apptstatus'] == '@' && $event_date == date('Y-m-d'))
156 $tmprow = sqlQuery("SELECT count(*) AS count FROM form_encounter WHERE " .
157 "pid = '" . $_POST['form_pid'] . "' AND date = '$event_date 00:00:00'");
158 if ($tmprow['count'] == 0) {
159 $tmprow = sqlQuery("SELECT username, facility, facility_id FROM users WHERE id = '" .
160 $_POST['form_provider'] . "'");
161 $username = $tmprow['username'];
162 $facility = $tmprow['facility'];
163 // $facility_id = $tmprow['facility_id'];
164 $facility_id = $_SESSION['pc_facility'] ?
$_SESSION['pc_facility'] : $tmprow['facility_id'];
165 $conn = $GLOBALS['adodb']['db'];
166 $encounter = $conn->GenID("sequences");
168 addForm($encounter, "New Patient Encounter",
169 sqlInsert("INSERT INTO form_encounter SET " .
170 "date = '$event_date', " .
171 "reason = '" . formData("form_comments") . "', " .
172 "facility = '$facility', " .
173 "facility_id = '" . (int)$_POST['facility'] . "', " .
174 "billing_facility = '" . (int)$_POST['billing_facility'] . "', " .
175 "provider_id = '" . (int)$_POST['form_provider'] . "', " .
176 "pid = '" . $_POST['form_pid'] . "', " .
177 "encounter = '$encounter', " .
178 "pc_catid = '" . $_POST['form_category'] . "'"
180 "newpatient", $_POST['form_pid'], "1", "NOW()", $username
182 $info_msg .= xl("New encounter created with id");
183 $info_msg .= " $encounter";
188 //================================================================================================================
190 // EVENTS TO FACILITIES (lemonsoftware)
191 //(CHEMED) get facility name
192 // edit event case - if there is no association made, then insert one with the first facility
195 $facility = sqlQuery("SELECT pc_facility, pc_multiple, pc_aid, facility.name
196 FROM openemr_postcalendar_events
197 LEFT JOIN facility ON (openemr_postcalendar_events.pc_facility = facility.id)
198 WHERE pc_eid = $eid");
199 // if ( !$facility['pc_facility'] ) {
200 if ( is_array($facility) && !$facility['pc_facility'] ) {
201 $qmin = sqlQuery("SELECT facility_id as minId, facility FROM users WHERE id = ".$facility['pc_aid']);
202 $min = $qmin['minId'];
203 $min_name = $qmin['facility'];
205 // multiple providers case
206 if ( $GLOBALS['select_multi_providers'] ) {
207 $mul = $facility['pc_multiple'];
208 sqlStatement("UPDATE openemr_postcalendar_events SET pc_facility = $min WHERE pc_multiple = $mul");
212 sqlStatement("UPDATE openemr_postcalendar_events SET pc_facility = $min WHERE pc_eid = $eid");
214 $e2f_name = $min_name;
217 if (!$facility['pc_facility'] && $_SESSION['pc_facility']) {
218 $e2f = $_SESSION['pc_facility'];
219 } elseif (!$facility['pc_facility'] && $_COOKIE['pc_facility'] && $GLOBALS['set_facility_cookie']) {
220 $e2f = $_COOKIE['pc_facility'];
222 $e2f = $facility['pc_facility'];
223 $e2f_name = $facility['name'];
228 // ===========================
229 //=============================================================================================================================
230 if ($_POST['form_action'] == "duplicate" ||
$_POST['form_action'] == "save")
232 // the starting date of the event, pay attention with this value
233 // when editing recurring events -- JRM Oct-08
234 $event_date = fixDate($_POST['form_date']);
236 // Compute start and end time strings to be saved.
237 if ($_POST['form_allday']) {
242 $tmph = $_POST['form_hour'] +
0;
243 $tmpm = $_POST['form_minute'] +
0;
244 if ($_POST['form_ampm'] == '2' && $tmph < 12) $tmph +
= 12;
245 $duration = $_POST['form_duration'];
247 $starttime = "$tmph:$tmpm:00";
250 while ($tmpm >= 60) {
254 $endtime = "$tmph:$tmpm:00";
256 // Useless garbage that we must save.
257 $locationspecs = array("event_location" => "",
258 "event_street1" => "",
259 "event_street2" => "",
264 $locationspec = serialize($locationspecs);
266 // capture the recurring specifications
267 $recurrspec = array("event_repeat_freq" => $_POST['form_repeat_freq'],
268 "event_repeat_freq_type" => $_POST['form_repeat_type'],
269 "event_repeat_on_num" => "1",
270 "event_repeat_on_day" => "0",
271 "event_repeat_on_freq" => "0",
272 "exdate" => $_POST['form_repeat_exdate']
275 // no recurr specs, this is used for adding a new non-recurring event
276 $noRecurrspec = array("event_repeat_freq" => "",
277 "event_repeat_freq_type" => "",
278 "event_repeat_on_num" => "1",
279 "event_repeat_on_day" => "0",
280 "event_repeat_on_freq" => "0",
284 }//if ($_POST['form_action'] == "duplicate" || $_POST['form_action'] == "save")
285 //=============================================================================================================================
286 if ($_POST['form_action'] == "duplicate") {
293 // If we are saving, then save and close the window.
295 if ($_POST['form_action'] == "save") {
296 /* =======================================================
298 * =====================================================*/
301 // what is multiple key around this $eid?
302 $row = sqlQuery("SELECT pc_multiple FROM openemr_postcalendar_events WHERE pc_eid = $eid");
304 // ====================================
305 // multiple providers
306 // ====================================
307 if ($GLOBALS['select_multi_providers'] && $row['pc_multiple']) {
309 // obtain current list of providers regarding the multiple key
310 $up = sqlStatement("SELECT pc_aid FROM openemr_postcalendar_events WHERE pc_multiple={$row['pc_multiple']}");
311 while ($current = sqlFetchArray($up)) { $providers_current[] = $current['pc_aid']; }
313 // get the new list of providers from the submitted form
314 $providers_new = $_POST['form_provider'];
316 // ===== Only current event of repeating series =====
317 if ($_POST['recurr_affect'] == 'current') {
319 // update all existing event records to exlude the current date
320 foreach ($providers_current as $provider) {
321 // update the provider's original event
322 // get the original event's repeat specs
323 $origEvent = sqlQuery("SELECT pc_recurrspec FROM openemr_postcalendar_events ".
324 " WHERE pc_aid = '$provider' AND pc_multiple={$row['pc_multiple']}");
325 $oldRecurrspec = unserialize($origEvent['pc_recurrspec']);
326 $selected_date = date("Ymd", strtotime($_POST['selected_date']));
327 if ($oldRecurrspec['exdate'] != "") { $oldRecurrspec['exdate'] .= ",".$selected_date; }
328 else { $oldRecurrspec['exdate'] .= $selected_date; }
330 // mod original event recur specs to exclude this date
331 sqlStatement("UPDATE openemr_postcalendar_events SET " .
332 " pc_recurrspec = '" . serialize($oldRecurrspec) ."' ".
333 " WHERE pc_aid = '$provider' AND pc_multiple={$row['pc_multiple']}");
336 // obtain the next available unique key to group multiple providers around some event
337 $q = sqlStatement ("SELECT MAX(pc_multiple) as max FROM openemr_postcalendar_events");
338 $max = sqlFetchArray($q);
339 $new_multiple_value = $max['max'] +
1;
341 // insert a new event record for each provider selected on the form
342 foreach ($providers_new as $provider) {
343 // insert a new event on this date with POST form data
345 // specify some special variables needed for the INSERT
346 $args['new_multiple_value'] = $new_multiple_value;
347 $args['form_provider'] = $provider;
348 $args['event_date'] = $event_date;
349 $args['duration'] = $duration * 60;
350 // this event is forced to NOT REPEAT
351 $args['form_repeat'] = "0";
352 $args['recurrspec'] = $noRecurrspec;
353 $args['form_enddate'] = "0000-00-00";
354 $args['starttime'] = $starttime;
355 $args['endtime'] = $endtime;
356 $args['locationspec'] = $locationspec;
361 // ===== Future Recurring events of a repeating series =====
362 else if ($_POST['recurr_affect'] == 'future') {
363 // update all existing event records to
364 // stop recurring on this date-1
365 $selected_date = date("Ymd", (strtotime($_POST['selected_date'])-24*60*60));
366 foreach ($providers_current as $provider) {
367 // mod original event recur specs to end on this date
368 sqlStatement("UPDATE openemr_postcalendar_events SET " .
369 " pc_enddate = '" . $selected_date ."' ".
370 " WHERE pc_aid = '$provider' AND pc_multiple={$row['pc_multiple']}");
373 // obtain the next available unique key to group multiple providers around some event
374 $q = sqlStatement ("SELECT MAX(pc_multiple) as max FROM openemr_postcalendar_events");
375 $max = sqlFetchArray($q);
376 $new_multiple_value = $max['max'] +
1;
378 // insert a new event record for each provider selected on the form
379 foreach ($providers_new as $provider) {
380 // insert a new event on this date with POST form data
382 // specify some special variables needed for the INSERT
383 $args['new_multiple_value'] = $new_multiple_value;
384 $args['form_provider'] = $provider;
385 $args['event_date'] = $event_date;
386 $args['duration'] = $duration * 60;
387 $args['recurrspec'] = $recurrspec;
388 $args['starttime'] = $starttime;
389 $args['endtime'] = $endtime;
390 $args['locationspec'] = $locationspec;
396 /* =================================================================== */
397 // ===== a Single event or All events in a repeating series ==========
398 /* =================================================================== */
400 // this difference means that some providers from current was UNCHECKED
401 // so we must delete this event for them
402 $r1 = array_diff ($providers_current, $providers_new);
404 foreach ($r1 as $to_be_removed) {
405 sqlQuery("DELETE FROM openemr_postcalendar_events WHERE pc_aid='$to_be_removed' AND pc_multiple={$row['pc_multiple']}");
409 // perform a check to see if user changed event date
410 // this is important when editing an existing recurring event
412 if ($_POST['form_date'] == $_POST['selected_date']) {
413 // user has NOT changed the start date of the event
414 $event_date = fixDate($_POST['event_start_date']);
417 // this difference means that some providers were added
418 // so we must insert this event for them
419 $r2 = array_diff ($providers_new, $providers_current);
421 foreach ($r2 as $to_be_inserted) {
423 // specify some special variables needed for the INSERT
424 $args['new_multiple_value'] = $row['pc_multiple'];
425 $args['form_provider'] = $to_be_inserted;
426 $args['event_date'] = $event_date;
427 $args['duration'] = $duration * 60;
428 $args['recurrspec'] = $recurrspec;
429 $args['starttime'] = $starttime;
430 $args['endtime'] = $endtime;
431 $args['locationspec'] = $locationspec;
436 // after the two diffs above, we must update for remaining providers
437 // those who are intersected in $providers_current and $providers_new
438 foreach ($_POST['form_provider'] as $provider) {
439 sqlStatement("UPDATE openemr_postcalendar_events SET " .
440 "pc_catid = '" . $_POST['form_category'] . "', " .
441 "pc_pid = '" . $_POST['form_pid'] . "', " .
442 "pc_title = '" . formData("form_title") . "', " .
443 "pc_time = NOW(), " .
444 "pc_hometext = '" . formData("form_comments") . "', " .
445 "pc_informant = '" . $_SESSION['authUserID'] . "', " .
446 "pc_eventDate = '" . $event_date . "', " .
447 "pc_endDate = '" . fixDate($_POST['form_enddate']) . "', " .
448 "pc_duration = '" . ($duration * 60) . "', " .
449 "pc_recurrtype = '" . ($_POST['form_repeat'] ?
'1' : '0') . "', " .
450 "pc_recurrspec = '" . serialize($recurrspec) . "', " .
451 "pc_startTime = '$starttime', " .
452 "pc_endTime = '$endtime', " .
453 "pc_alldayevent = '" . $_POST['form_allday'] . "', " .
454 "pc_apptstatus = '" . $_POST['form_apptstatus'] . "', " .
455 "pc_prefcatid = '" . $_POST['form_prefcat'] . "' ," .
456 "pc_facility = '" .(int)$_POST['facility'] ."' ," . // FF stuff
457 "pc_billing_location = '" .(int)$_POST['billing_facility'] ."' " .
458 "WHERE pc_aid = '$provider' AND pc_multiple={$row['pc_multiple']}");
463 // ====================================
465 // ====================================
466 } elseif ( !$row['pc_multiple'] ) {
467 if ( $GLOBALS['select_multi_providers'] ) {
468 $prov = $_POST['form_provider'][0];
470 $prov = $_POST['form_provider'];
473 if ($_POST['recurr_affect'] == 'current') {
474 // get the original event's repeat specs
475 $origEvent = sqlQuery("SELECT pc_recurrspec FROM openemr_postcalendar_events WHERE pc_eid = $eid");
476 $oldRecurrspec = unserialize($origEvent['pc_recurrspec']);
477 $selected_date = date("Ymd", strtotime($_POST['selected_date']));
478 if ($oldRecurrspec['exdate'] != "") { $oldRecurrspec['exdate'] .= ",".$selected_date; }
479 else { $oldRecurrspec['exdate'] .= $selected_date; }
481 // mod original event recur specs to exclude this date
482 sqlStatement("UPDATE openemr_postcalendar_events SET " .
483 " pc_recurrspec = '" . serialize($oldRecurrspec) ."' ".
484 " WHERE pc_eid = '$eid'");
486 // insert a new event on this date with POST form data
488 // specify some special variables needed for the INSERT
489 $args['event_date'] = $event_date;
490 $args['duration'] = $duration * 60;
491 // this event is forced to NOT REPEAT
492 $args['form_repeat'] = "0";
493 $args['recurrspec'] = $noRecurrspec;
494 $args['form_enddate'] = "0000-00-00";
495 $args['starttime'] = $starttime;
496 $args['endtime'] = $endtime;
497 $args['locationspec'] = $locationspec;
500 else if ($_POST['recurr_affect'] == 'future') {
501 // mod original event to stop recurring on this date-1
502 $selected_date = date("Ymd", (strtotime($_POST['selected_date'])-24*60*60));
503 sqlStatement("UPDATE openemr_postcalendar_events SET " .
504 " pc_enddate = '" . $selected_date ."' ".
505 " WHERE pc_eid = '$eid'");
507 // insert a new event starting on this date with POST form data
509 // specify some special variables needed for the INSERT
510 $args['event_date'] = $event_date;
511 $args['duration'] = $duration * 60;
512 $args['recurrspec'] = $recurrspec;
513 $args['starttime'] = $starttime;
514 $args['endtime'] = $endtime;
515 $args['locationspec'] = $locationspec;
520 // perform a check to see if user changed event date
521 // this is important when editing an existing recurring event
523 if ($_POST['form_date'] == $_POST['selected_date']) {
524 // user has NOT changed the start date of the event
525 $event_date = fixDate($_POST['event_start_date']);
528 // mod the SINGLE event or ALL EVENTS in a repeating series
529 // simple provider case
530 sqlStatement("UPDATE openemr_postcalendar_events SET " .
531 "pc_catid = '" . $_POST['form_category'] . "', " .
532 "pc_aid = '" . $prov . "', " .
533 "pc_pid = '" . $_POST['form_pid'] . "', " .
534 "pc_title = '" . formData("form_title") . "', " .
535 "pc_time = NOW(), " .
536 "pc_hometext = '" . formData("form_comments") . "', " .
537 "pc_informant = '" . $_SESSION['authUserID'] . "', " .
538 "pc_eventDate = '" . $event_date . "', " .
539 "pc_endDate = '" . fixDate($_POST['form_enddate']) . "', " .
540 "pc_duration = '" . ($duration * 60) . "', " .
541 "pc_recurrtype = '" . ($_POST['form_repeat'] ?
'1' : '0') . "', " .
542 "pc_recurrspec = '" . serialize($recurrspec) . "', " .
543 "pc_startTime = '$starttime', " .
544 "pc_endTime = '$endtime', " .
545 "pc_alldayevent = '" . $_POST['form_allday'] . "', " .
546 "pc_apptstatus = '" . $_POST['form_apptstatus'] . "', " .
547 "pc_prefcatid = '" . $_POST['form_prefcat'] . "' ," .
548 "pc_facility = '" .(int)$_POST['facility'] ."' ," . // FF stuff
549 "pc_billing_location = '" .(int)$_POST['billing_facility'] ."' " .
550 "WHERE pc_eid = '$eid'");
554 // =======================================
555 // end Update Multi providers case
556 // =======================================
558 // EVENTS TO FACILITIES
563 /* =======================================================
564 * INSERT NEW EVENT(S)
565 * ======================================================*/
571 // done with EVENT insert/update statements
577 // =======================================
579 // =======================================
580 else if ($_POST['form_action'] == "delete") {
581 // =======================================
582 // multi providers event
583 // =======================================
584 if ($GLOBALS['select_multi_providers']) {
586 // what is multiple key around this $eid?
587 $row = sqlQuery("SELECT pc_multiple FROM openemr_postcalendar_events WHERE pc_eid = $eid");
589 // obtain current list of providers regarding the multiple key
590 $providers_current = array();
591 $up = sqlStatement("SELECT pc_aid FROM openemr_postcalendar_events WHERE pc_multiple={$row['pc_multiple']}");
592 while ($current = sqlFetchArray($up)) { $providers_current[] = $current['pc_aid']; }
594 // establish a WHERE clause
595 if ( $row['pc_multiple'] ) { $whereClause = "pc_multiple = {$row['pc_multiple']}"; }
596 else { $whereClause = "pc_eid = $eid"; }
598 if ($_POST['recurr_affect'] == 'current') {
599 // update all existing event records to exlude the current date
600 foreach ($providers_current as $provider) {
601 // update the provider's original event
602 // get the original event's repeat specs
603 $origEvent = sqlQuery("SELECT pc_recurrspec FROM openemr_postcalendar_events ".
604 " WHERE pc_aid = '$provider' AND pc_multiple={$row['pc_multiple']}");
605 $oldRecurrspec = unserialize($origEvent['pc_recurrspec']);
606 $selected_date = date("Ymd", strtotime($_POST['selected_date']));
607 if ($oldRecurrspec['exdate'] != "") { $oldRecurrspec['exdate'] .= ",".$selected_date; }
608 else { $oldRecurrspec['exdate'] .= $selected_date; }
610 // mod original event recur specs to exclude this date
611 sqlStatement("UPDATE openemr_postcalendar_events SET " .
612 " pc_recurrspec = '" . serialize($oldRecurrspec) ."' ".
613 " WHERE ". $whereClause);
616 else if ($_POST['recurr_affect'] == 'future') {
617 // update all existing event records to stop recurring on this date-1
618 $selected_date = date("Ymd", (strtotime($_POST['selected_date'])-24*60*60));
619 foreach ($providers_current as $provider) {
620 // update the provider's original event
621 sqlStatement("UPDATE openemr_postcalendar_events SET " .
622 " pc_enddate = '" . $selected_date ."' ".
623 " WHERE ".$whereClause);
627 // really delete the event from the database
628 sqlStatement("DELETE FROM openemr_postcalendar_events WHERE ".$whereClause);
632 // =======================================
633 // single provider event
634 // =======================================
637 if ($_POST['recurr_affect'] == 'current') {
638 // mod original event recur specs to exclude this date
640 // get the original event's repeat specs
641 $origEvent = sqlQuery("SELECT pc_recurrspec FROM openemr_postcalendar_events WHERE pc_eid = $eid");
642 $oldRecurrspec = unserialize($origEvent['pc_recurrspec']);
643 $selected_date = date("Ymd", strtotime($_POST['selected_date']));
644 if ($oldRecurrspec['exdate'] != "") { $oldRecurrspec['exdate'] .= ",".$selected_date; }
645 else { $oldRecurrspec['exdate'] .= $selected_date; }
646 sqlStatement("UPDATE openemr_postcalendar_events SET " .
647 " pc_recurrspec = '" . serialize($oldRecurrspec) ."' ".
648 " WHERE pc_eid = '$eid'");
651 else if ($_POST['recurr_affect'] == 'future') {
652 // mod original event to stop recurring on this date-1
653 $selected_date = date("Ymd", (strtotime($_POST['selected_date'])-24*60*60));
654 sqlStatement("UPDATE openemr_postcalendar_events SET " .
655 " pc_enddate = '" . $selected_date ."' ".
656 " WHERE pc_eid = '$eid'");
660 // fully delete the event from the database
661 sqlStatement("DELETE FROM openemr_postcalendar_events WHERE pc_eid = '$eid'");
666 if ($_POST['form_action'] != "") {
667 // Close this window and refresh the calendar display.
668 echo "<html>\n<body>\n<script language='JavaScript'>\n";
669 if ($info_msg) echo " alert('$info_msg');\n";
670 echo " if (opener && !opener.closed && opener.refreshme) opener.refreshme();\n";
671 echo " window.close();\n";
672 echo "</script>\n</body>\n</html>\n";
676 //*********************************
677 // If we get this far then we are displaying the form.
678 //*********************************
680 /*********************************************************************
681 This has been migrate to the administration->lists
684 '*' => xl('* Reminder done'),
685 '+' => xl('+ Chart pulled'),
686 'x' => xl('x Cancelled'), // added Apr 2008 by JRM
687 '?' => xl('? No show'),
688 '@' => xl('@ Arrived'),
689 '~' => xl('~ Arrived late'),
690 '!' => xl('! Left w/o visit'),
691 '#' => xl('# Ins/fin issue'),
692 '<' => xl('< In exam room'),
693 '>' => xl('> Checked out'),
694 '$' => xl('$ Coding done'),
695 '%' => xl('% Cancelled < 24h ')
697 *********************************************************************/
699 $repeats = 0; // if the event repeats
703 if ($_REQUEST['patientid']) $patientid = $_REQUEST['patientid'];
704 $patientname = xl('Click to select');
710 // If we are editing an existing event, then get its data.
712 // $row = sqlQuery("SELECT * FROM openemr_postcalendar_events WHERE pc_eid = $eid");
714 $row = sqlQuery("SELECT e.*, u.fname, u.mname, u.lname " .
715 "FROM openemr_postcalendar_events AS e " .
716 "LEFT OUTER JOIN users AS u ON u.id = e.pc_informant " .
717 "WHERE pc_eid = $eid");
718 $informant = $row['fname'] . ' ' . $row['mname'] . ' ' . $row['lname'];
720 // instead of using the event's starting date, keep what has been provided
721 // via the GET array, see the top of this file
722 if (empty($_GET['date'])) $date = $row['pc_eventDate'];
723 $eventstartdate = $row['pc_eventDate']; // for repeating event stuff - JRM Oct-08
724 $userid = $row['pc_aid'];
725 $patientid = $row['pc_pid'];
726 $starttimeh = substr($row['pc_startTime'], 0, 2) +
0;
727 $starttimem = substr($row['pc_startTime'], 3, 2);
728 $repeats = $row['pc_recurrtype'];
729 $multiple_value = $row['pc_multiple'];
731 // parse out the repeating data, if any
732 $rspecs = unserialize($row['pc_recurrspec']); // extract recurring data
733 $repeattype = $rspecs['event_repeat_freq_type'];
734 $repeatfreq = $rspecs['event_repeat_freq'];
735 $repeatexdate = $rspecs['exdate']; // repeating date exceptions
737 $hometext = $row['pc_hometext'];
738 if (substr($hometext, 0, 6) == ':text:') $hometext = substr($hometext, 6);
742 $eventstartdate = $date; // for repeating event stuff - JRM Oct-08
744 //-------------------------------------
746 //Set default facility for a new event based on the given 'userid'
748 /*************************************************************
749 $pref_facility = sqlFetchArray(sqlStatement("SELECT facility_id, facility FROM users WHERE id = $userid"));
750 *************************************************************/
751 if ($_SESSION['pc_facility']) {
752 $pref_facility = sqlFetchArray(sqlStatement(sprintf("
753 SELECT f.id as facility_id,
758 $_SESSION['pc_facility']
761 $pref_facility = sqlFetchArray(sqlStatement("
762 SELECT u.facility_id,
765 LEFT JOIN facility f on (u.facility_id = f.id)
769 /************************************************************/
770 $e2f = $pref_facility['facility_id'];
771 $e2f_name = $pref_facility['facility'];
773 //END of CHEMED -----------------------
776 // If we have a patient ID, get the name and phone numbers to display.
778 $prow = sqlQuery("SELECT lname, fname, phone_home, phone_biz, DOB " .
779 "FROM patient_data WHERE pid = '" . $patientid . "'");
780 $patientname = $prow['lname'] . ", " . $prow['fname'];
781 if ($prow['phone_home']) $patienttitle .= " H=" . $prow['phone_home'];
782 if ($prow['phone_biz']) $patienttitle .= " W=" . $prow['phone_biz'];
785 // Get the providers list.
786 $ures = sqlStatement("SELECT id, username, fname, lname FROM users WHERE " .
787 "authorized != 0 AND active = 1 ORDER BY lname, fname");
789 // Get event categories.
790 $cres = sqlStatement("SELECT pc_catid, pc_catname, pc_recurrtype, pc_duration, pc_end_all_day " .
791 "FROM openemr_postcalendar_categories ORDER BY pc_catname");
793 // Fix up the time format for AM/PM.
795 if ($starttimeh >= 12) { // p.m. starts at noon and not 12:01
797 if ($starttimeh > 12) $starttimeh -= 12;
803 <?php
html_header_show(); ?
>
804 <title
><?php
echo $eid ?
xl('Edit','e') : xl('Add New','e') ?
> <?php
xl('Event','e');?
></title
>
805 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
808 td
{ font
-size
:0.8em
; }
811 <style type
="text/css">@import
url(../../../library
/dynarch_calendar
.css
);</style
>
812 <script type
="text/javascript" src
="../../../library/topdialog.js"></script
>
813 <script type
="text/javascript" src
="../../../library/dialog.js"></script
>
814 <script type
="text/javascript" src
="../../../library/textformat.js"></script
>
815 <script type
="text/javascript" src
="../../../library/dynarch_calendar.js"></script
>
816 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
817 <script type
="text/javascript" src
="../../../library/dynarch_calendar_setup.js"></script
>
819 <script language
="JavaScript">
821 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
823 var durations
= new Array();
824 // var rectypes = new Array();
826 // Read the event categories, generate their options list, and get
827 // the default event duration from them if this is a new event.
829 if($_GET['prov']==true){
832 $cres = sqlStatement("SELECT pc_catid, pc_catname, pc_recurrtype, pc_duration, pc_end_all_day " .
833 "FROM openemr_postcalendar_categories WHERE pc_cattype='".$cattype."' ORDER BY pc_catname");
835 $prefcat_options = " <option value='0'>-- None --</option>\n";
838 $thisduration = $row['pc_alldayevent'] ?
1440 : round($row['pc_duration'] / 60);
840 while ($crow = sqlFetchArray($cres)) {
841 $duration = round($crow['pc_duration'] / 60);
842 if ($crow['pc_end_all_day']) $duration = 1440;
843 echo " durations[" . $crow['pc_catid'] . "] = $duration\n";
844 // echo " rectypes[" . $crow['pc_catid'] . "] = " . $crow['pc_recurrtype'] . "\n";
845 $catoptions .= " <option value='" . $crow['pc_catid'] . "'";
847 if ($crow['pc_catid'] == $row['pc_catid']) $catoptions .= " selected";
849 if ($crow['pc_catid'] == $default_catid) {
850 $catoptions .= " selected";
851 $thisduration = $duration;
854 $catoptions .= ">" . xl_appt_category($crow['pc_catname']) . "</option>\n";
856 // This section is to build the list of preferred categories:
858 $prefcat_options .= " <option value='" . $crow['pc_catid'] . "'";
860 if ($crow['pc_catid'] == $row['pc_prefcatid']) $prefcat_options .= " selected";
862 $prefcat_options .= ">" . xl_appt_category($crow['pc_catname']) . "</option>\n";
868 <?php
require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
870 // This is for callback by the find-patient popup.
871 function setpatient(pid
, lname
, fname
, dob
) {
872 var f
= document
.forms
[0];
873 f
.form_patient
.value
= lname +
', ' + fname
;
874 f
.form_pid
.value
= pid
;
875 dobstyle
= (dob
== '' || dob
.substr(5, 10) == '00-00') ?
'' : 'none';
876 document
.getElementById('dob_row').style
.display
= dobstyle
;
879 // This invokes the find-patient popup.
880 function sel_patient() {
881 dlgopen('find_patient_popup.php', '_blank', 500, 400);
884 // Do whatever is needed when a new event category is selected.
885 // For now this means changing the event title and duration.
886 function set_display() {
887 var f
= document
.forms
[0];
888 var s
= f
.form_category
;
889 if (s
.selectedIndex
>= 0) {
890 var catid
= s
.options
[s
.selectedIndex
].value
;
891 var style_apptstatus
= document
.getElementById('title_apptstatus').style
;
892 var style_prefcat
= document
.getElementById('title_prefcat').style
;
893 if (catid
== '2') { // In Office
894 style_apptstatus
.display
= 'none';
895 style_prefcat
.display
= '';
896 f
.form_apptstatus
.style
.display
= 'none';
897 f
.form_prefcat
.style
.display
= '';
899 style_prefcat
.display
= 'none';
900 style_apptstatus
.display
= '';
901 f
.form_prefcat
.style
.display
= 'none';
902 f
.form_apptstatus
.style
.display
= '';
907 // Do whatever is needed when a new event category is selected.
908 // For now this means changing the event title and duration.
909 function set_category() {
910 var f
= document
.forms
[0];
911 var s
= f
.form_category
;
912 if (s
.selectedIndex
>= 0) {
913 var catid
= s
.options
[s
.selectedIndex
].value
;
914 f
.form_title
.value
= s
.options
[s
.selectedIndex
].text
;
915 f
.form_duration
.value
= durations
[catid
];
920 // Modify some visual attributes when the all-day or timed-event
921 // radio buttons are clicked.
922 function set_allday() {
923 var f
= document
.forms
[0];
924 var color1
= '#777777';
925 var color2
= '#777777';
926 var disabled2
= true;
927 if (document
.getElementById('rballday1').checked
) {
930 if (document
.getElementById('rballday2').checked
) {
934 document
.getElementById('tdallday1').style
.color
= color1
;
935 document
.getElementById('tdallday2').style
.color
= color2
;
936 document
.getElementById('tdallday3').style
.color
= color2
;
937 document
.getElementById('tdallday4').style
.color
= color2
;
938 document
.getElementById('tdallday5').style
.color
= color2
;
939 f
.form_hour
.disabled
= disabled2
;
940 f
.form_minute
.disabled
= disabled2
;
941 f
.form_ampm
.disabled
= disabled2
;
942 f
.form_duration
.disabled
= disabled2
;
945 // Modify some visual attributes when the Repeat checkbox is clicked.
946 function set_repeat() {
947 var f
= document
.forms
[0];
948 var isdisabled
= true;
949 var mycolor
= '#777777';
950 var myvisibility
= 'hidden';
951 if (f
.form_repeat
.checked
) {
954 myvisibility
= 'visible';
956 f
.form_repeat_type
.disabled
= isdisabled
;
957 f
.form_repeat_freq
.disabled
= isdisabled
;
958 f
.form_enddate
.disabled
= isdisabled
;
959 document
.getElementById('tdrepeat1').style
.color
= mycolor
;
960 document
.getElementById('tdrepeat2').style
.color
= mycolor
;
961 document
.getElementById('img_enddate').style
.visibility
= myvisibility
;
964 // This is for callback by the find-available popup.
965 function setappt(year
,mon
,mday
,hours
,minutes
) {
966 var f
= document
.forms
[0];
967 f
.form_date
.value
= '' + year +
'-' +
968 ('' +
(mon +
100)).substring(1) +
'-' +
969 ('' +
(mday +
100)).substring(1);
970 f
.form_ampm
.selectedIndex
= (hours
>= 12) ?
1 : 0;
971 f
.form_hour
.value
= (hours
> 12) ? hours
- 12 : hours
;
972 f
.form_minute
.value
= ('' +
(minutes +
100)).substring(1);
975 // Invoke the find-available popup.
976 function find_available() {
977 top
.restoreSession();
978 // (CHEMED) Conditional value selection, because there is no <select> element
979 // when making an appointment for a specific provider
980 var s
= document
.forms
[0].form_provider
;
981 var f
= document
.forms
[0].facility
;
982 <?php
if ($userid != 0) { ?
>
983 s
= document
.forms
[0].form_provider
.value
;
984 f
= document
.forms
[0].facility
.value
;
986 s
= document
.forms
[0].form_provider
.options
[s
.selectedIndex
].value
;
987 f
= document
.forms
[0].facility
.options
[f
.selectedIndex
].value
;
989 var c
= document
.forms
[0].form_category
;
990 var formDate
= document
.forms
[0].form_date
;
991 dlgopen('find_appt_popup.php?providerid=' + s +
992 '&catid=' + c
.options
[c
.selectedIndex
].value +
994 '&startdate=' + formDate
.value
, '_blank', 500, 400);
995 //END (CHEMED) modifications
1000 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8" />
1004 <body
class="body_top" onunload
='imclosing()'>
1006 <form method
='post' name
='theform' id
='theform' action
='add_edit_event.php?eid=<?php echo $eid ?>' />
1007 <!-- ViSolve
: Requirement
- Redirect to Create
New Patient Page
-->
1008 <input type
='hidden' size
='2' name
='resname' value
='empty' />
1010 if ($_POST["resname"]=="noresult"){
1012 <script language="Javascript">
1013 // refresh and redirect the parent window
1014 if (!opener.closed && opener.refreshme) opener.refreshme();
1015 top.restoreSession();
1016 opener.document.location="../../new/new.php";
1021 $classprov='current';
1024 <!-- ViSolve
: Requirement
- Redirect to Create
New Patient Page
-->
1025 <input type
="hidden" name
="form_action" id
="form_action" value
="">
1026 <input type
="hidden" name
="recurr_affect" id
="recurr_affect" value
="">
1027 <!-- used
for recurring events
-->
1028 <input type
="hidden" name
="selected_date" id
="selected_date" value
="<?php echo $date; ?>">
1029 <input type
="hidden" name
="event_start_date" id
="event_start_date" value
="<?php echo $eventstartdate; ?>">
1035 if($_GET['prov']==true){
1036 $provider_class="class='current'";
1039 $normal="class='current'";
1042 <tr
><th
><ul
class="tabNav">
1044 $eid=$_REQUEST["eid"];
1045 $startm=$_REQUEST["startampm"];
1046 $starth=$_REQUEST["starttimeh"];
1047 $uid=$_REQUEST["userid"];
1048 $starttm=$_REQUEST["starttimem"];
1049 $dt=$_REQUEST["date"];
1050 $cid=$_REQUEST["catid"];
1052 <li
<?php
echo $normal;?
>>
1053 <a href
='add_edit_event.php?eid=<?php echo $eid;?>&startampm=<?php echo $startm;?>&starttimeh=<?php echo $starth;?>&userid=<?php echo $uid;?>&starttimem=<?php echo $starttm;?>&date=<?php echo $dt;?>&catid=<?php echo $cid;?>'>
1054 <?php
echo htmlspecialchars(xl('Patient'),ENT_QUOTES
);?
></a
>
1056 <li
<?php
echo $provider_class;?
>>
1057 <a href
='add_edit_event.php?prov=true&eid=<?php echo $eid;?>&startampm=<?php echo $startm;?>&starttimeh=<?php echo $starth;?>&userid=<?php echo $uid;?>&starttimem=<?php echo $starttm;?>&date=<?php echo $dt;?>&catid=<?php echo $cid;?>'>
1058 <?php
echo htmlspecialchars(xl('Provider'),ENT_QUOTES
);?
></a
>
1062 <tr
><td colspan
='10'>
1063 <table border
='0' width
='100%' bgcolor
='#DDDDDD' >
1066 <td width
='1%' nowrap
>
1067 <b
><?php
echo htmlspecialchars($GLOBALS['athletic_team'] ?
xl('Team/Squad') : xl('Category')); ?
>:</b
>
1070 <select name
='form_category' onchange
='set_category()' style
='width:100%'>
1071 <?php
echo $catoptions ?
>
1074 <td width
='1%' nowrap
>
1076 <input type
='radio' name
='form_allday' onclick
='set_allday()' value
='1' id
='rballday1'
1077 <?php
if ($thisduration == 1440) echo "checked " ?
>/>
1079 <td colspan
='2' nowrap id
='tdallday1'>
1080 <?php
xl('All day event','e'); ?
>
1086 <b
><?php
xl('Date','e'); ?
>:</b
>
1089 <input type
='text' size
='10' name
='form_date' id
='form_date'
1090 value
='<?php echo $date ?>'
1091 title
='<?php xl('yyyy
-mm
-dd event date
or starting date
','e
'); ?>'
1092 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' />
1093 <img src
='../../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
1094 id
='img_date' border
='0' alt
='[?]' style
='cursor:pointer;cursor:hand'
1095 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
1099 <input type
='radio' name
='form_allday' onclick
='set_allday()' value
='0' id
='rballday2' <?php
if ($thisduration != 1440) echo "checked " ?
>/>
1101 <td width
='1%' nowrap id
='tdallday2'>
1102 <?php
xl('Time','e'); ?
>
1104 <td width
='1%' nowrap id
='tdallday3'>
1105 <input type
='text' size
='2' name
='form_hour' value
='<?php echo $starttimeh ?>'
1106 title
='<?php xl('Event start time
','e
'); ?>' /> :
1107 <input type
='text' size
='2' name
='form_minute' value
='<?php echo $starttimem ?>'
1108 title
='<?php xl('Event start time
','e
'); ?>' /> 
;
1109 <select name
='form_ampm' title
='Note: 12:00 noon is PM, not AM'>
1110 <option value
='1'><?php
xl('AM','e'); ?
></option
>
1111 <option value
='2'<?php
if ($startampm == '2') echo " selected" ?
>><?php
xl('PM','e'); ?
></option
>
1118 <b
><?php
echo htmlspecialchars($GLOBALS['athletic_team'] ?
xl('Team/Squad') : xl('Title')); ?
>:</b
>
1121 <input type
='text' size
='10' name
='form_title' value
='<?php echo htmlspecialchars($row['pc_title
'], ENT_QUOTES); ?>'
1123 title
='<?php xl('Event title
','e
'); ?>' />
1128 <td nowrap id
='tdallday4'><?php
xl('duration','e'); ?
>
1130 <td nowrap id
='tdallday5'>
1131 <input type
='text' size
='4' name
='form_duration' value
='<?php echo $thisduration ?>' title
='<?php xl('Event duration in minutes
','e
'); ?>' />
1132 <?php
xl('minutes','e'); ?
>
1137 <td nowrap
><b
><?php
xl('Facility','e'); ?
>:</b
></td
>
1139 <select name
="facility" id
="facility" >
1142 // ===========================
1143 // EVENTS TO FACILITIES
1144 //(CHEMED) added service_location WHERE clause
1145 // get the facilities
1146 /***************************************************************
1147 $qsql = sqlStatement("SELECT * FROM facility WHERE service_location != 0");
1148 ***************************************************************/
1149 $facils = getUserFacilities($_SESSION['authId']);
1150 $qsql = sqlStatement("SELECT id, name FROM facility WHERE service_location != 0");
1151 /**************************************************************/
1152 while ($facrow = sqlFetchArray($qsql)) {
1153 /*************************************************************
1154 $selected = ( $facrow['id'] == $e2f ) ? 'selected="selected"' : '' ;
1155 echo "<option value={$facrow['id']} $selected>{$facrow['name']}</option>";
1156 *************************************************************/
1157 if ($_SESSION['authorizedUser'] ||
in_array($facrow, $facils)) {
1158 $selected = ( $facrow['id'] == $e2f ) ?
'selected="selected"' : '' ;
1159 echo "<option value={$facrow['id']} $selected>{$facrow['name']}</option>";
1162 $selected = ( $facrow['id'] == $e2f ) ?
'selected="selected"' : '' ;
1163 echo "<option value={$facrow['id']} $selected>{$facrow['name']}</option>";
1165 /************************************************************/
1168 // ===========================
1171 //END (CHEMED) IF ?>
1177 <b
><?php
echo htmlspecialchars( xl('Billing Facility'), ENT_NOQUOTES
); ?
>:</b
>
1181 billing_facility('billing_facility',$row['pc_billing_location']);
1186 if($_GET['prov']!=true){
1188 <tr id
="patient_details">
1190 <b
><?php
xl('Patient','e'); ?
>:</b
>
1193 <input type
='text' size
='10' name
='form_patient' style
='width:100%;cursor:pointer;cursor:hand' value
='<?php echo htmlspecialchars($patientname, ENT_QUOTES); ?>' onclick
='sel_patient()' title
='<?php xl('Click to select patient
','e
'); ?>' readonly
/>
1194 <input type
='hidden' name
='form_pid' value
='<?php echo $patientid ?>' />
1196 <td colspan
='3' nowrap style
='font-size:8pt'>
1198 <span
class="infobox">
1199 <?php
if ($patienttitle != "") { echo $patienttitle; } ?
>
1208 <b
><?php
xl('Provider','e'); ?
>:</b
>
1214 // =======================================
1216 // =======================================
1217 if ($GLOBALS['select_multi_providers']) {
1219 // there are two posible situations: edit and new record
1221 // this is executed only on edit ($eid)
1223 if ( $multiple_value ) {
1224 // find all the providers around multiple key
1225 $qall = sqlStatement ("SELECT pc_aid AS providers FROM openemr_postcalendar_events WHERE pc_multiple = $multiple_value");
1226 while ($r = sqlFetchArray($qall)) {
1227 $providers_array[] = $r['providers'];
1230 $qall = sqlStatement ("SELECT pc_aid AS providers FROM openemr_postcalendar_events WHERE pc_eid = $eid");
1231 $providers_array = sqlFetchArray($qall);
1235 // build the selection tool
1236 echo "<select name='form_provider[]' style='width:100%' multiple='multiple' size='5' >";
1238 while ($urow = sqlFetchArray($ures)) {
1239 echo " <option value='" . $urow['id'] . "'";
1242 if ( in_array($urow['id'], $providers_array) ||
($urow['id'] == $userid) ) echo " selected";
1245 echo ">" . $urow['lname'];
1246 if ($urow['fname']) echo ", " . $urow['fname'];
1252 // =======================================
1254 // =======================================
1258 // get provider from existing event
1259 $qprov = sqlStatement ("SELECT pc_aid FROM openemr_postcalendar_events WHERE pc_eid = $eid");
1260 $provider = sqlFetchArray($qprov);
1261 $defaultProvider = $provider['pc_aid'];
1264 // this is a new event so smartly choose a default provider
1265 /*****************************************************************
1267 // Provider already given to us as a GET parameter.
1268 $defaultProvider = $userid;
1271 // default to the currently logged-in user
1272 $defaultProvider = $_SESSION['authUserID'];
1273 // or, if we have chosen a provider in the calendar, default to them
1274 // choose the first one if multiple have been selected
1275 if (count($_SESSION['pc_username']) >= 1) {
1276 // get the numeric ID of the first provider in the array
1277 $pc_username = $_SESSION['pc_username'];
1278 $firstProvider = sqlFetchArray(sqlStatement("select id from users where username='".$pc_username[0]."'"));
1279 $defaultProvider = $firstProvider['id'];
1284 echo "<select name='form_provider' style='width:100%' />";
1285 while ($urow = sqlFetchArray($ures)) {
1286 echo " <option value='" . $urow['id'] . "'";
1287 if ($urow['id'] == $defaultProvider) echo " selected";
1288 echo ">" . $urow['lname'];
1289 if ($urow['fname']) echo ", " . $urow['fname'];
1293 *****************************************************************/
1294 // default to the currently logged-in user
1295 $defaultProvider = $_SESSION['authUserID'];
1296 // or, if we have chosen a provider in the calendar, default to them
1297 // choose the first one if multiple have been selected
1298 if (count($_SESSION['pc_username']) >= 1) {
1299 // get the numeric ID of the first provider in the array
1300 $pc_username = $_SESSION['pc_username'];
1301 $firstProvider = sqlFetchArray(sqlStatement("select id from users where username='".$pc_username[0]."'"));
1302 $defaultProvider = $firstProvider['id'];
1304 // if we clicked on a provider's schedule to add the event, use THAT.
1305 if ($userid) $defaultProvider = $userid;
1307 echo "<select name='form_provider' style='width:100%' />";
1308 while ($urow = sqlFetchArray($ures)) {
1309 echo " <option value='" . $urow['id'] . "'";
1310 if ($urow['id'] == $defaultProvider) echo " selected";
1311 echo ">" . $urow['lname'];
1312 if ($urow['fname']) echo ", " . $urow['fname'];
1316 /****************************************************************/
1324 <input type
='checkbox' name
='form_repeat' onclick
='set_repeat(this)' value
='1'<?php
if ($repeats) echo " checked" ?
>/>
1325 <input type
='hidden' name
='form_repeat_exdate' id
='form_repeat_exdate' value
='<?php echo $repeatexdate; ?>' /> <!-- dates excluded from the repeat
-->
1327 <td nowrap id
='tdrepeat1'><?php
xl('Repeats','e'); ?
>
1331 <select name
='form_repeat_freq' title
=<?php
xl('Every, every other, every 3rd, etc.','e','\'','\''); ?
>>
1333 foreach (array(1 => xl('every'), 2 => xl('2nd'), 3 => xl('3rd'), 4 => xl('4th'), 5 => xl('5th'), 6 => xl('6th'))
1336 echo " <option value='$key'";
1337 if ($key == $repeatfreq) echo " selected";
1338 echo ">$value</option>\n";
1343 <select name
='form_repeat_type'>
1345 // See common.api.php for these:
1346 foreach (array(0 => xl('day') , 4 => xl('workday'), 1 => xl('week'), 2 => xl('month'), 3 => xl('year'))
1349 echo " <option value='$key'";
1350 if ($key == $repeattype) echo " selected";
1351 echo ">$value</option>\n";
1361 <span id
='title_apptstatus'><b
><?php
echo htmlspecialchars($GLOBALS['athletic_team'] ?
xl('Session Type') : xl('Status')); ?
>:</b
></span
>
1362 <span id
='title_prefcat' style
='display:none'><b
><?php
xl('Pref Cat','e'); ?
>:</b
></span
>
1367 generate_form_field(array('data_type'=>1,'field_id'=>'apptstatus','list_id'=>'apptstat','empty_title'=>'SKIP'), $row['pc_apptstatus']);
1370 The following
list will be invisible unless this is an In Office
1371 event
, in which
case form_apptstatus (above
) is to be invisible
.
1373 <select name
='form_prefcat' style
='width:100%;display:none' title
='<?php xl('Preferred Event Category
','e
');?>'>
1374 <?php
echo $prefcat_options ?
>
1381 <td nowrap id
='tdrepeat2'><?php
xl('until','e'); ?
>
1384 <input type
='text' size
='10' name
='form_enddate' id
='form_enddate' value
='<?php echo $row['pc_endDate
'] ?>' onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='<?php xl('yyyy
-mm
-dd last date of this event
','e
');?>' />
1385 <img src
='../../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
1386 id
='img_enddate' border
='0' alt
='[?]' style
='cursor:pointer;cursor:hand'
1387 title
='<?php xl('Click here to choose a date
','e
');?>'>
1389 if ($repeatexdate != "") {
1390 $tmptitle = "The following dates are excluded from the repeating series";
1391 if ($multiple_value) { $tmptitle .= " for one or more providers:\n"; }
1392 else { $tmptitle .= "\n"; }
1393 $exdates = explode(",", $repeatexdate);
1394 foreach ($exdates as $exdate) {
1395 $tmptitle .= date("d M Y", strtotime($exdate))."\n";
1397 echo "<a href='#' title='$tmptitle' alt='$tmptitle'><img src='../../pic/warning.gif' title='$tmptitle' alt='*!*' style='border:none;'/></a>";
1405 <b
><?php
xl('Comments','e'); ?
>:</b
>
1407 <td colspan
='4' nowrap
>
1408 <input type
='text' size
='40' name
='form_comments' style
='width:100%' value
='<?php echo htmlspecialchars($hometext, ENT_QUOTES); ?>' title
='<?php xl('Optional information about this event
','e
');?>' />
1413 // DOB is important for the clinic, so if it's missing give them a chance
1414 // to enter it right here. We must display or hide this row dynamically
1415 // in case the patient-select popup is used.
1416 $patient_dob = trim($prow['DOB']);
1417 $dobstyle = ($prow && (!$patient_dob ||
substr($patient_dob, 5) == '00-00')) ?
1420 <tr id
='dob_row' style
='display:<?php echo $dobstyle ?>'>
1421 <td colspan
='4' nowrap
>
1422 <b
><font color
='red'><?php
xl('DOB is missing, please enter if possible','e'); ?
>:</font
></b
>
1425 <input type
='text' size
='10' name
='form_dob' id
='form_dob' title
='<?php xl('yyyy
-mm
-dd date of birth
','e
');?>' onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' />
1426 <img src
='../../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
1427 id
='img_dob' border
='0' alt
='[?]' style
='cursor:pointer;cursor:hand'
1428 title
='<?php xl('Click here to choose a date
','e
');?>'>
1433 <tr
class='text'><td colspan
='10'>
1435 <input type
='button' name
='form_save' id
='form_save' value
='<?php xl('Save
','e
');?>' />
1437 <input type
='button' id
='find_available' value
='<?php xl('Find Available
','e
');?>' />
1439 <input type
='button' name
='form_delete' id
='form_delete' value
='<?php xl('Delete
','e
');?>'<?php
if (!$eid) echo " disabled" ?
> />
1441 <input type
='button' id
='cancel' value
='<?php xl('Cancel
','e
');?>' />
1443 <input type
='button' name
='form_duplicate' id
='form_duplicate' value
='<?php xl('Create Duplicate
','e
');?>' />
1444 </p
></td
></tr
></table
>
1445 <?php
if ($informant) echo "<p class='text'>" . xl('Last update by') . " $informant " . xl('on') . " " . $row['pc_time'] . "</p>\n"; ?
>
1449 <div id
="recurr_popup" style
="visibility: hidden; position: absolute; top: 50px; left: 50px; width: 400px; border: 3px outset yellow; background-color: yellow; padding: 5px;">
1450 <?php
echo htmlspecialchars(xl('Apply the changes to the Current event only, to this and all Future occurrences, or to All occurrences?')) ?
>
1452 <input type
="button" name
="all_events" id
="all_events" value
=" All ">
1453 <input type
="button" name
="future_events" id
="future_events" value
="Future">
1454 <input type
="button" name
="current_event" id
="current_event" value
="Current">
1455 <input type
="button" name
="recurr_cancel" id
="recurr_cancel" value
="Cancel">
1460 <script language
='JavaScript'>
1461 <?php
if ($eid) { ?
>
1469 Calendar
.setup({inputField
:"form_date", ifFormat
:"%Y-%m-%d", button
:"img_date"});
1470 Calendar
.setup({inputField
:"form_enddate", ifFormat
:"%Y-%m-%d", button
:"img_enddate"});
1471 Calendar
.setup({inputField
:"form_dob", ifFormat
:"%Y-%m-%d", button
:"img_dob"});
1474 <script language
="javascript">
1475 // jQuery stuff to make the page a little easier to use
1477 $
(document
).ready(function(){
1478 $
("#form_save").click(function() { validate("save"); });
1479 $
("#form_duplicate").click(function() { validate("duplicate"); });
1480 $
("#find_available").click(function() { find_available(); });
1481 $
("#form_delete").click(function() { deleteEvent(); });
1482 $
("#cancel").click(function() { window
.close(); });
1484 // buttons affecting the modification of a repeating event
1485 $
("#all_events").click(function() { $
("#recurr_affect").val("all"); EnableForm(); SubmitForm(); });
1486 $
("#future_events").click(function() { $
("#recurr_affect").val("future"); EnableForm(); SubmitForm(); });
1487 $
("#current_event").click(function() { $
("#recurr_affect").val("current"); EnableForm(); SubmitForm(); });
1488 $
("#recurr_cancel").click(function() { $
("#recurr_affect").val(""); EnableForm(); HideRecurrPopup(); });
1491 // Check for errors when the form is submitted.
1492 function validate(valu
) {
1493 var f
= document
.getElementById('theform');
1494 if (f
.form_repeat
.checked
&&
1495 (! f
.form_enddate
.value || f
.form_enddate
.value
< f
.form_date
.value
)) {
1496 alert('An end date later than the start date is required for repeated events!');
1500 if($_GET['prov']!=true){
1502 if(f
.form_pid
.value
== ''){
1503 alert('<?php echo htmlspecialchars(xl('Patient Name Required
'),ENT_QUOTES);?>');
1509 $
('#form_action').val(valu
);
1511 <?php
if ($repeats): ?
>
1512 // existing repeating events need additional prompt
1513 if ($
("#recurr_affect").val() == "") {
1515 // show the current/future/all DIV for the user to choose one
1516 $
("#recurr_popup").css("visibility", "visible");
1521 return SubmitForm();
1524 // disable all the form elements outside the recurr_popup
1525 function DisableForm() {
1526 $
("#theform").children().attr("disabled", "true");
1528 function EnableForm() {
1529 $
("#theform").children().removeAttr("disabled");
1531 // hide the recurring popup DIV
1532 function HideRecurrPopup() {
1533 $
("#recurr_popup").css("visibility", "hidden");
1536 function deleteEvent() {
1537 if (confirm("Deleting this event cannot be undone. It cannot be recovered once it is gone.\nAre you sure you wish to delete this event?")) {
1538 $
('#form_action').val("delete");
1540 <?php
if ($repeats): ?
>
1541 // existing repeating events need additional prompt
1542 if ($
("#recurr_affect").val() == "") {
1544 // show the current/future/all DIV for the user to choose one
1545 $
("#recurr_popup").css("visibility", "visible");
1550 return SubmitForm();
1555 function SubmitForm() {
1556 $
('#theform').submit();
1557 top
.restoreSession();