2 // Copyright (C) 2005-2006 Rod Roark <rod@sunsetsystems.com>
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 // The event editor looks something like this:
11 //------------------------------------------------------------//
12 // Category __________________V O All day event //
13 // Date _____________ [?] O Time ___:___ __V //
14 // Title ___________________ duration ____ minutes //
15 // Patient _(Click_to_select)_ //
16 // Provider __________________V X Repeats ______V ______V //
17 // Status __________________V until __________ [?] //
18 // Comments ________________________________________________ //
20 // [Save] [Find Available] [Delete] [Cancel] //
21 //------------------------------------------------------------//
23 include_once("../../globals.php");
24 include_once("$srcdir/patient.inc");
25 include_once("$srcdir/forms.inc");
26 include_once("$srcdir/calendar.inc");
27 include_once("$srcdir/formdata.inc.php");
29 // Things that might be passed by our opener.
31 $eid = $_GET['eid']; // only for existing events
32 $date = $_GET['date']; // this and below only for new events
33 $userid = $_GET['userid'];
34 $default_catid = $_GET['catid'] ?
$_GET['catid'] : '5';
37 $date = substr($date, 0, 4) . '-' . substr($date, 4, 2) . '-' . substr($date, 6);
39 $date = date("Y-m-d");
42 if (isset($_GET['starttimem']))
43 $starttimem = substr('00' . $_GET['starttimem'], -2);
45 if (isset($_GET['starttimeh'])) {
46 $starttimeh = $_GET['starttimeh'];
47 if (isset($_GET['startampm'])) {
48 if ($_GET['startampm'] == '2' && $starttimeh < 12)
52 $starttimeh = date("G");
58 // used for DBC Dutch System
59 $_SESSION['event_date'] = $date;
60 $link = '../../../library/DBC_functions.php'; // ajax stuff and db work
64 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script
>
69 // $args is mainly filled with content from the POST http var
70 function InsertEvent($args) {
71 return sqlInsert("INSERT INTO openemr_postcalendar_events ( " .
72 "pc_catid, pc_multiple, pc_aid, pc_pid, pc_title, pc_time, pc_hometext, " .
73 "pc_informant, pc_eventDate, pc_endDate, pc_duration, pc_recurrtype, " .
74 "pc_recurrspec, pc_startTime, pc_endTime, pc_alldayevent, " .
75 "pc_apptstatus, pc_prefcatid, pc_location, pc_eventstatus, pc_sharing, pc_facility " .
77 "'" . $args['form_category'] . "', " .
78 "'" . $args['new_multiple_value'] . "', " .
79 "'" . $args['form_provider'] . "', " .
80 "'" . $args['form_pid'] . "', " .
81 "'" . formDataCore($args['form_title']) . "', " .
83 "'" . formDataCore($args['form_comments']) . "', " .
84 "'" . $_SESSION['authUserID'] . "', " .
85 "'" . $args['event_date'] . "', " .
86 "'" . fixDate($args['form_enddate']) . "', " .
87 "'" . $args['duration'] . "', " .
88 "'" . ($args['form_repeat'] ?
'1' : '0') . "', " .
89 "'" . serialize($args['recurrspec']) . "', " .
90 "'" . $args['starttime'] ."', " .
91 "'" . $args['endtime'] ."', " .
92 "'" . $args['form_allday'] . "', " .
93 "'" . $args['form_apptstatus'] . "', " .
94 "'" . $args['form_prefcat'] . "', " .
95 "'" . $args['locationspec'] ."', " .
97 "1, " .(int)$args['facility']. " )"
101 // =====================================
103 // ACTIVITIES / TIMES
104 if ( $GLOBALS['dutchpc'] ) {
106 if ( $GLOBALS['select_multi_providers'] ) {
107 // ------------------------------------------
108 // what is multiple key around this $eid?
109 $rowmulti = sqlQuery("SELECT pc_multiple FROM openemr_postcalendar_events WHERE pc_eid = $eid");
111 // what are all pc_eid's grouped by multiple key
112 $eventsrow = array();
113 $rezev = mysql_query("SELECT pc_eid FROM openemr_postcalendar_events WHERE pc_multiple = {$rowmulti['pc_multiple']}");
114 while ( $row = mysql_fetch_array($rezev) ) {
115 $eventsrow[] = $row['pc_eid'];
118 // we look in cl_event_activiteit / cl_time_activiteit for a matching record
119 foreach ( $eventsrow as $ev) {
120 $activ = sqlQuery("SELECT * FROM cl_event_activiteit WHERE event_id = $ev");
121 if ( $activ['event_id'] ) $singleeid = $activ['event_id'];
123 $time = sqlQuery("SELECT * FROM cl_time_activiteit WHERE event_id = $ev");
124 if ( $time ) $timerow = $time;
127 // prevent blank values for $singleeid
128 if ( !$singleeid) $singleeid = $eid;
130 // ------------------------------------------
132 // ------------------------------------------
133 // single providers case
134 $timerow = sqlQuery("SELECT * FROM cl_time_activiteit WHERE event_id = $eid");
136 // ------------------------------------------
141 // EVENTS TO FACILITIES (lemonsoftware)
142 //(CHEMED) get facility name
143 // edit event case - if there is no association made, then insert one with the first facility
146 $facility = sqlQuery("SELECT pc_facility, pc_multiple, pc_aid, facility.name
147 FROM openemr_postcalendar_events
148 LEFT JOIN facility ON (openemr_postcalendar_events.pc_facility = facility.id)
149 WHERE pc_eid = $eid");
150 // if ( !$facility['pc_facility'] ) {
151 if ( is_array($facility) && !$facility['pc_facility'] ) {
152 $qmin = sqlQuery("SELECT facility_id as minId, facility FROM users WHERE id = ".$facility['pc_aid']);
153 $min = $qmin['minId'];
154 $min_name = $qmin['facility'];
156 // multiple providers case
157 if ( $GLOBALS['select_multi_providers'] ) {
158 $mul = $facility['pc_multiple'];
159 sqlStatement("UPDATE openemr_postcalendar_events SET pc_facility = $min WHERE pc_multiple = $mul");
163 sqlStatement("UPDATE openemr_postcalendar_events SET pc_facility = $min WHERE pc_eid = $eid");
165 $e2f_name = $min_name;
168 if (!$facility['pc_facility'] && $_SESSION['pc_facility']) {
169 $e2f = $_SESSION['pc_facility'];
170 } elseif (!$facility['pc_facility'] && $_COOKIE['pc_facility'] && $GLOBALS['set_facility_cookie']) {
171 $e2f = $_COOKIE['pc_facility'];
173 $e2f = $facility['pc_facility'];
174 $e2f_name = $facility['name'];
179 // ===========================
182 // If we are saving, then save and close the window.
184 if ($_POST['form_action'] == "save") {
186 // ========================================
188 // check if for activity act_3.2 we have times completed
190 if ( $GLOBALS['dutchpc'] ) {
192 if ( $sa == 'act_3.2') {
193 $duration = (int)$_POST['form_duration'];
194 if ( empty($duration) ) exit();
197 // ========================================
199 // the starting date of the event, pay attention with this value
200 // when editing recurring events -- JRM Oct-08
201 $event_date = fixDate($_POST['form_date']);
203 // Compute start and end time strings to be saved.
204 if ($_POST['form_allday']) {
209 $tmph = $_POST['form_hour'] +
0;
210 $tmpm = $_POST['form_minute'] +
0;
211 if ($_POST['form_ampm'] == '2' && $tmph < 12) $tmph +
= 12;
212 $duration = $_POST['form_duration'];
214 $starttime = "$tmph:$tmpm:00";
217 while ($tmpm >= 60) {
221 $endtime = "$tmph:$tmpm:00";
223 // Useless garbage that we must save.
224 $locationspecs = array("event_location" => "",
225 "event_street1" => "",
226 "event_street2" => "",
231 $locationspec = serialize($locationspecs);
233 // capture the recurring specifications
234 $recurrspec = array("event_repeat_freq" => $_POST['form_repeat_freq'],
235 "event_repeat_freq_type" => $_POST['form_repeat_type'],
236 "event_repeat_on_num" => "1",
237 "event_repeat_on_day" => "0",
238 "event_repeat_on_freq" => "0",
239 "exdate" => $_POST['form_repeat_exdate']
242 // no recurr specs, this is used for adding a new non-recurring event
243 $noRecurrspec = array("event_repeat_freq" => "",
244 "event_repeat_freq_type" => "",
245 "event_repeat_on_num" => "1",
246 "event_repeat_on_day" => "0",
247 "event_repeat_on_freq" => "0",
251 /* =======================================================
253 * =====================================================*/
256 // what is multiple key around this $eid?
257 $row = sqlQuery("SELECT pc_multiple FROM openemr_postcalendar_events WHERE pc_eid = $eid");
259 // timing-activity validation - larry :: DBC ????
261 if ( $GLOBALS['dutchpc'] ) {
262 if ( $_SESSION['editactiv'] ) { $activ = selected_ac(); }
263 else { $activ = what_activity($eid); }
267 // ====================================
268 // multiple providers
269 // ====================================
270 if ($GLOBALS['select_multi_providers'] && $row['pc_multiple']) {
272 // obtain current list of providers regarding the multiple key
273 $up = sqlStatement("SELECT pc_aid FROM openemr_postcalendar_events WHERE pc_multiple={$row['pc_multiple']}");
274 while ($current = sqlFetchArray($up)) { $providers_current[] = $current['pc_aid']; }
276 // get the new list of providers from the submitted form
277 $providers_new = $_POST['form_provider'];
279 // ===== Only current event of repeating series =====
280 if ($_POST['recurr_affect'] == 'current') {
282 // update all existing event records to exlude the current date
283 foreach ($providers_current as $provider) {
284 // update the provider's original event
285 // get the original event's repeat specs
286 $origEvent = sqlQuery("SELECT pc_recurrspec FROM openemr_postcalendar_events ".
287 " WHERE pc_aid = '$provider' AND pc_multiple={$row['pc_multiple']}");
288 $oldRecurrspec = unserialize($origEvent['pc_recurrspec']);
289 $selected_date = date("Ymd", strtotime($_POST['selected_date']));
290 if ($oldRecurrspec['exdate'] != "") { $oldRecurrspec['exdate'] .= ",".$selected_date; }
291 else { $oldRecurrspec['exdate'] .= $selected_date; }
293 // mod original event recur specs to exclude this date
294 sqlStatement("UPDATE openemr_postcalendar_events SET " .
295 " pc_recurrspec = '" . serialize($oldRecurrspec) ."' ".
296 " WHERE pc_aid = '$provider' AND pc_multiple={$row['pc_multiple']}");
299 // obtain the next available unique key to group multiple providers around some event
300 $q = sqlStatement ("SELECT MAX(pc_multiple) as max FROM openemr_postcalendar_events");
301 $max = sqlFetchArray($q);
302 $new_multiple_value = $max['max'] +
1;
304 // insert a new event record for each provider selected on the form
305 foreach ($providers_new as $provider) {
306 // insert a new event on this date with POST form data
308 // specify some special variables needed for the INSERT
309 $args['new_multiple_value'] = $new_multiple_value;
310 $args['form_provider'] = $provider;
311 $args['event_date'] = $event_date;
312 $args['duration'] = $duration * 60;
313 // this event is forced to NOT REPEAT
314 $args['form_repeat'] = "0";
315 $args['recurrspec'] = $noRecurrspec;
316 $args['form_enddate'] = "0000-00-00";
317 $args['starttime'] = $starttime;
318 $args['endtime'] = $endtime;
319 $args['locationspec'] = $locationspec;
324 // ===== Future Recurring events of a repeating series =====
325 else if ($_POST['recurr_affect'] == 'future') {
326 // update all existing event records to
327 // stop recurring on this date-1
328 $selected_date = date("Ymd", (strtotime($_POST['selected_date'])-24*60*60));
329 foreach ($providers_current as $provider) {
330 // mod original event recur specs to end on this date
331 sqlStatement("UPDATE openemr_postcalendar_events SET " .
332 " pc_enddate = '" . $selected_date ."' ".
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 $args['recurrspec'] = $recurrspec;
351 $args['starttime'] = $starttime;
352 $args['endtime'] = $endtime;
353 $args['locationspec'] = $locationspec;
359 /* =================================================================== */
360 // ===== a Single event or All events in a repeating series ==========
361 /* =================================================================== */
363 // this difference means that some providers from current was UNCHECKED
364 // so we must delete this event for them
365 $r1 = array_diff ($providers_current, $providers_new);
367 foreach ($r1 as $to_be_removed) {
368 sqlQuery("DELETE FROM openemr_postcalendar_events WHERE pc_aid='$to_be_removed' AND pc_multiple={$row['pc_multiple']}");
372 // perform a check to see if user changed event date
373 // this is important when editing an existing recurring event
375 if ($_POST['form_date'] == $_POST['selected_date']) {
376 // user has NOT changed the start date of the event
377 $event_date = fixDate($_POST['event_start_date']);
380 // this difference means that some providers were added
381 // so we must insert this event for them
382 $r2 = array_diff ($providers_new, $providers_current);
384 foreach ($r2 as $to_be_inserted) {
386 // specify some special variables needed for the INSERT
387 $args['new_multiple_value'] = $row['pc_multiple'];
388 $args['form_provider'] = $to_be_inserted;
389 $args['event_date'] = $event_date;
390 $args['duration'] = $duration * 60;
391 $args['recurrspec'] = $recurrspec;
392 $args['starttime'] = $starttime;
393 $args['endtime'] = $endtime;
394 $args['locationspec'] = $locationspec;
399 // after the two diffs above, we must update for remaining providers
400 // those who are intersected in $providers_current and $providers_new
401 foreach ($_POST['form_provider'] as $provider) {
402 sqlStatement("UPDATE openemr_postcalendar_events SET " .
403 "pc_catid = '" . $_POST['form_category'] . "', " .
404 "pc_pid = '" . $_POST['form_pid'] . "', " .
405 "pc_title = '" . formData("form_title") . "', " .
406 "pc_time = NOW(), " .
407 "pc_hometext = '" . formData("form_comments") . "', " .
408 "pc_informant = '" . $_SESSION['authUserID'] . "', " .
409 "pc_eventDate = '" . $event_date . "', " .
410 "pc_endDate = '" . fixDate($_POST['form_enddate']) . "', " .
411 "pc_duration = '" . ($duration * 60) . "', " .
412 "pc_recurrtype = '" . ($_POST['form_repeat'] ?
'1' : '0') . "', " .
413 "pc_recurrspec = '" . serialize($recurrspec) . "', " .
414 "pc_startTime = '$starttime', " .
415 "pc_endTime = '$endtime', " .
416 "pc_alldayevent = '" . $_POST['form_allday'] . "', " .
417 "pc_apptstatus = '" . $_POST['form_apptstatus'] . "', " .
418 "pc_prefcatid = '" . $_POST['form_prefcat'] . "' ," .
419 "pc_facility = '" .(int)$_POST['facility'] ."' " . // FF stuff
420 "WHERE pc_aid = '$provider' AND pc_multiple={$row['pc_multiple']}");
425 // ====================================
427 // ====================================
428 } elseif ( !$row['pc_multiple'] ) {
429 if ( $GLOBALS['select_multi_providers'] ) {
430 $prov = $_POST['form_provider'][0];
432 $prov = $_POST['form_provider'];
435 if ($_POST['recurr_affect'] == 'current') {
436 // get the original event's repeat specs
437 $origEvent = sqlQuery("SELECT pc_recurrspec FROM openemr_postcalendar_events WHERE pc_eid = $eid");
438 $oldRecurrspec = unserialize($origEvent['pc_recurrspec']);
439 $selected_date = date("Ymd", strtotime($_POST['selected_date']));
440 if ($oldRecurrspec['exdate'] != "") { $oldRecurrspec['exdate'] .= ",".$selected_date; }
441 else { $oldRecurrspec['exdate'] .= $selected_date; }
443 // mod original event recur specs to exclude this date
444 sqlStatement("UPDATE openemr_postcalendar_events SET " .
445 " pc_recurrspec = '" . serialize($oldRecurrspec) ."' ".
446 " WHERE pc_eid = '$eid'");
448 // insert a new event on this date with POST form data
450 // specify some special variables needed for the INSERT
451 $args['event_date'] = $event_date;
452 $args['duration'] = $duration * 60;
453 // this event is forced to NOT REPEAT
454 $args['form_repeat'] = "0";
455 $args['recurrspec'] = $noRecurrspec;
456 $args['form_enddate'] = "0000-00-00";
457 $args['starttime'] = $starttime;
458 $args['endtime'] = $endtime;
459 $args['locationspec'] = $locationspec;
462 else if ($_POST['recurr_affect'] == 'future') {
463 // mod original event to stop recurring on this date-1
464 $selected_date = date("Ymd", (strtotime($_POST['selected_date'])-24*60*60));
465 sqlStatement("UPDATE openemr_postcalendar_events SET " .
466 " pc_enddate = '" . $selected_date ."' ".
467 " WHERE pc_eid = '$eid'");
469 // insert a new event starting on this date with POST form data
471 // specify some special variables needed for the INSERT
472 $args['event_date'] = $event_date;
473 $args['duration'] = $duration * 60;
474 $args['recurrspec'] = $recurrspec;
475 $args['starttime'] = $starttime;
476 $args['endtime'] = $endtime;
477 $args['locationspec'] = $locationspec;
482 // perform a check to see if user changed event date
483 // this is important when editing an existing recurring event
485 if ($_POST['form_date'] == $_POST['selected_date']) {
486 // user has NOT changed the start date of the event
487 $event_date = fixDate($_POST['event_start_date']);
490 // mod the SINGLE event or ALL EVENTS in a repeating series
491 // simple provider case
492 sqlStatement("UPDATE openemr_postcalendar_events SET " .
493 "pc_catid = '" . $_POST['form_category'] . "', " .
494 "pc_aid = '" . $prov . "', " .
495 "pc_pid = '" . $_POST['form_pid'] . "', " .
496 "pc_title = '" . formData("form_title") . "', " .
497 "pc_time = NOW(), " .
498 "pc_hometext = '" . formData("form_comments") . "', " .
499 "pc_informant = '" . $_SESSION['authUserID'] . "', " .
500 "pc_eventDate = '" . $event_date . "', " .
501 "pc_endDate = '" . fixDate($_POST['form_enddate']) . "', " .
502 "pc_duration = '" . ($duration * 60) . "', " .
503 "pc_recurrtype = '" . ($_POST['form_repeat'] ?
'1' : '0') . "', " .
504 "pc_recurrspec = '" . serialize($recurrspec) . "', " .
505 "pc_startTime = '$starttime', " .
506 "pc_endTime = '$endtime', " .
507 "pc_alldayevent = '" . $_POST['form_allday'] . "', " .
508 "pc_apptstatus = '" . $_POST['form_apptstatus'] . "', " .
509 "pc_prefcatid = '" . $_POST['form_prefcat'] . "' ," .
510 "pc_facility = '" .(int)$_POST['facility'] ."' " . // FF stuff
511 "WHERE pc_eid = '$eid'");
515 // ===================================
516 // DBC change activity / times
517 $activ = ''; // activity could be an old value or a new one
518 if ( $GLOBALS['dutchpc'] ) {
519 if ( $_SESSION['editactiv'] ) {
520 $ac = selected_ac(); $activ = $ac;
521 $acid = what_sysid($ac);
523 if ( $acid ) sqlInsert("INSERT INTO cl_event_activiteit (event_id, activity_sysid)".
524 " VALUES ('" .$singleeid. "', '" .$acid. "') ON DUPLICATE KEY UPDATE activity_sysid = " .$acid );
526 $_SESSION['editactiv'] = FALSE; // otherwise you'll get a nasty bug!
528 $activcode = what_activity($singleeid);
529 $activ = what_code_activity($activcode);
532 // timing-activity validation
533 if ( vl_activity_travel($activ) ) {
534 $itime = (int)$_POST['form_duration_indirect']; $ttime = 0;
536 $itime = (int)$_POST['form_duration_indirect']; $ttime = (int)$_POST['form_duration_travel'];
538 sqlInsert("INSERT INTO cl_time_activiteit (event_id, indirect_time, travel_time)".
539 " VALUES ('" .$singleeid. "', '" .$itime. "', '" .$ttime. "') ON DUPLICATE KEY UPDATE indirect_time = " .$itime.
540 ", travel_time = " . $ttime);
543 // end DBC change activity / times
544 // ===================================
546 // =======================================
547 // end Update Multi providers case
548 // =======================================
550 // EVENTS TO FACILITIES
555 /* =======================================================
556 * INSERT NEW EVENT(S)
557 * ======================================================*/
559 // =======================================
560 // multi providers case
561 // =======================================
562 if (is_array($_POST['form_provider'])) {
564 // obtain the next available unique key to group multiple providers around some event
565 $q = sqlStatement ("SELECT MAX(pc_multiple) as max FROM openemr_postcalendar_events");
566 $max = sqlFetchArray($q);
567 $new_multiple_value = $max['max'] +
1;
569 foreach ($_POST['form_provider'] as $provider) {
571 // specify some special variables needed for the INSERT
572 $args['new_multiple_value'] = $new_multiple_value;
573 $args['form_provider'] = $provider;
574 $args['event_date'] = $event_date;
575 $args['duration'] = $duration * 60;
576 $args['recurrspec'] = $recurrspec;
577 $args['starttime'] = $starttime;
578 $args['endtime'] = $endtime;
579 $args['locationspec'] = $locationspec;
583 // ====================================
585 // ====================================
588 // specify some special variables needed for the INSERT
589 $args['new_multiple_value'] = "";
590 $args['event_date'] = $event_date;
591 $args['duration'] = $duration * 60;
592 $args['recurrspec'] = $recurrspec;
593 $args['starttime'] = $starttime;
594 $args['endtime'] = $endtime;
595 $args['locationspec'] = $locationspec;
599 // ==============================================
600 // DBC Dutch System (insert case)
601 $lid = mysql_insert_id($GLOBALS['dbh']); // obtain last inserted id
604 if ( $GLOBALS['dutchpc'] ) {
606 $acid = what_sysid($ac);
607 sqlInsert("INSERT INTO cl_event_activiteit (event_id, activity_sysid) VALUES ('" .$lid. "', '" .$acid. "')");
609 // timing-activity validation
610 if ( vl_activity_travel($activ) ) {
611 $itime = (int)$_POST['form_duration_indirect']; $ttime = 0;
613 $itime = (int)$_POST['form_duration_indirect']; $ttime = (int)$_POST['form_duration_travel'];
615 sqlInsert("INSERT INTO cl_time_activiteit (event_id, indirect_time, travel_time)".
616 " VALUES ('" .$lid. "', '" .$itime. "', '" .$ttime. "')");
618 // DBC Dutch System (insert case)
619 // ==============================================
622 $pid1007 = ( $_POST['form_pid'] ) ?
$_POST['form_pid'] : $pid;
624 $a = generate_id1007($pid1007, $event_date); //var_dump($a); exit();
628 // ==============================================
632 // done with EVENT insert/update statements
634 // Save new DOB if it's there.
635 $patient_dob = trim($_POST['form_dob']);
636 if ($patient_dob && $_POST['form_pid']) {
637 sqlStatement("UPDATE patient_data SET DOB = '$patient_dob' WHERE " .
638 "pid = '" . $_POST['form_pid'] . "'");
641 // Auto-create a new encounter if appropriate.
643 if ($GLOBALS['auto_create_new_encounters'] &&
644 $_POST['form_apptstatus'] == '@' && $event_date == date('Y-m-d'))
646 $tmprow = sqlQuery("SELECT count(*) AS count FROM form_encounter WHERE " .
647 "pid = '" . $_POST['form_pid'] . "' AND date = '$event_date 00:00:00'");
648 if ($tmprow['count'] == 0) {
649 $tmprow = sqlQuery("SELECT username, facility, facility_id FROM users WHERE id = '" .
650 $_POST['form_provider'] . "'");
651 $username = $tmprow['username'];
652 $facility = $tmprow['facility'];
653 // $facility_id = $tmprow['facility_id'];
654 // use the session facility if it is set, otherwise the one from the provider.
655 $facility_id = $_SESSION['pc_facility'] ?
$_SESSION['pc_facility'] : $tmprow['facility_id'];
656 $conn = $GLOBALS['adodb']['db'];
657 $encounter = $conn->GenID("sequences");
658 addForm($encounter, "New Patient Encounter",
659 sqlInsert("INSERT INTO form_encounter SET " .
660 "date = '$event_date', " .
661 "onset_date = '$event_date', " .
662 "reason = '" . formData("form_comments") . "', " .
663 "facility = '$facility', " .
664 // "facility_id = '$facility_id', " .
665 "facility_id = '" . (int)$_POST['facility'] . "', " .
666 "pid = '" . $_POST['form_pid'] . "', " .
667 "encounter = '$encounter'"
669 "newpatient", $_POST['form_pid'], "1", "NOW()", $username
671 $info_msg .= "New encounter $encounter was created. ";
676 // =======================================
678 // =======================================
679 else if ($_POST['form_action'] == "delete") {
680 // =======================================
681 // multi providers event
682 // =======================================
683 if ($GLOBALS['select_multi_providers']) {
685 // what is multiple key around this $eid?
686 $row = sqlQuery("SELECT pc_multiple FROM openemr_postcalendar_events WHERE pc_eid = $eid");
688 // obtain current list of providers regarding the multiple key
689 $providers_current = array();
690 $up = sqlStatement("SELECT pc_aid FROM openemr_postcalendar_events WHERE pc_multiple={$row['pc_multiple']}");
691 while ($current = sqlFetchArray($up)) { $providers_current[] = $current['pc_aid']; }
693 // establish a WHERE clause
694 if ( $row['pc_multiple'] ) { $whereClause = "pc_multiple = {$row['pc_multiple']}"; }
695 else { $whereClause = "pc_eid = $eid"; }
697 if ($_POST['recurr_affect'] == 'current') {
698 // update all existing event records to exlude the current date
699 foreach ($providers_current as $provider) {
700 // update the provider's original event
701 // get the original event's repeat specs
702 $origEvent = sqlQuery("SELECT pc_recurrspec FROM openemr_postcalendar_events ".
703 " WHERE pc_aid = '$provider' AND pc_multiple={$row['pc_multiple']}");
704 $oldRecurrspec = unserialize($origEvent['pc_recurrspec']);
705 $selected_date = date("Ymd", strtotime($_POST['selected_date']));
706 if ($oldRecurrspec['exdate'] != "") { $oldRecurrspec['exdate'] .= ",".$selected_date; }
707 else { $oldRecurrspec['exdate'] .= $selected_date; }
709 // mod original event recur specs to exclude this date
710 sqlStatement("UPDATE openemr_postcalendar_events SET " .
711 " pc_recurrspec = '" . serialize($oldRecurrspec) ."' ".
712 " WHERE ". $whereClause);
715 else if ($_POST['recurr_affect'] == 'future') {
716 // update all existing event records to stop recurring on this date-1
717 $selected_date = date("Ymd", (strtotime($_POST['selected_date'])-24*60*60));
718 foreach ($providers_current as $provider) {
719 // update the provider's original event
720 sqlStatement("UPDATE openemr_postcalendar_events SET " .
721 " pc_enddate = '" . $selected_date ."' ".
722 " WHERE ".$whereClause);
726 // really delete the event from the database
727 sqlStatement("DELETE FROM openemr_postcalendar_events WHERE ".$whereClause);
731 // =======================================
732 // single provider event
733 // =======================================
736 if ($_POST['recurr_affect'] == 'current') {
737 // mod original event recur specs to exclude this date
739 // get the original event's repeat specs
740 $origEvent = sqlQuery("SELECT pc_recurrspec FROM openemr_postcalendar_events WHERE pc_eid = $eid");
741 $oldRecurrspec = unserialize($origEvent['pc_recurrspec']);
742 $selected_date = date("Ymd", strtotime($_POST['selected_date']));
743 if ($oldRecurrspec['exdate'] != "") { $oldRecurrspec['exdate'] .= ",".$selected_date; }
744 else { $oldRecurrspec['exdate'] .= $selected_date; }
745 sqlStatement("UPDATE openemr_postcalendar_events SET " .
746 " pc_recurrspec = '" . serialize($oldRecurrspec) ."' ".
747 " WHERE pc_eid = '$eid'");
750 else if ($_POST['recurr_affect'] == 'future') {
751 // mod original event to stop recurring on this date-1
752 $selected_date = date("Ymd", (strtotime($_POST['selected_date'])-24*60*60));
753 sqlStatement("UPDATE openemr_postcalendar_events SET " .
754 " pc_enddate = '" . $selected_date ."' ".
755 " WHERE pc_eid = '$eid'");
759 // fully delete the event from the database
760 sqlStatement("DELETE FROM openemr_postcalendar_events WHERE pc_eid = '$eid'");
765 if ($_POST['form_action'] != "") {
766 // Close this window and refresh the calendar display.
767 echo "<html>\n<body>\n<script language='JavaScript'>\n";
768 if ($info_msg) echo " alert('$info_msg');\n";
769 echo " if (!opener.closed && opener.refreshme) opener.refreshme();\n";
770 echo " window.close();\n";
771 echo "</script>\n</body>\n</html>\n";
775 //*********************************
776 // If we get this far then we are displaying the form.
777 //*********************************
781 '*' => xl('* Reminder done'),
782 '+' => xl('+ Chart pulled'),
783 'x' => xl('x Cancelled'), // added Apr 2008 by JRM
784 '?' => xl('? No show'),
785 '@' => xl('@ Arrived'),
786 '~' => xl('~ Arrived late'),
787 '!' => xl('! Left w/o visit'),
788 '#' => xl('# Ins/fin issue'),
789 '<' => xl('< In exam room'),
790 '>' => xl('> Checked out'),
791 '$' => xl('$ Coding done'),
792 '%' => xl('% Cancelled < 24h ')
795 $repeats = 0; // if the event repeats
799 if ($_REQUEST['patientid']) $patientid = $_REQUEST['patientid'];
800 $patientname = xl('Click to select');
806 // If we are editing an existing event, then get its data.
808 // $row = sqlQuery("SELECT * FROM openemr_postcalendar_events WHERE pc_eid = $eid");
810 $row = sqlQuery("SELECT e.*, u.fname, u.mname, u.lname " .
811 "FROM openemr_postcalendar_events AS e " .
812 "LEFT OUTER JOIN users AS u ON u.id = e.pc_informant " .
813 "WHERE pc_eid = $eid");
814 $informant = $row['fname'] . ' ' . $row['mname'] . ' ' . $row['lname'];
816 // instead of using the event's starting date, keep what has been provided
817 // via the GET array, see the top of this file
818 if (empty($_GET['date'])) $date = $row['pc_eventDate'];
819 $eventstartdate = $row['pc_eventDate']; // for repeating event stuff - JRM Oct-08
820 $userid = $row['pc_aid'];
821 $patientid = $row['pc_pid'];
822 $starttimeh = substr($row['pc_startTime'], 0, 2) +
0;
823 $starttimem = substr($row['pc_startTime'], 3, 2);
824 $repeats = $row['pc_recurrtype'];
825 $multiple_value = $row['pc_multiple'];
827 // parse out the repeating data, if any
828 $rspecs = unserialize($row['pc_recurrspec']); // extract recurring data
829 $repeattype = $rspecs['event_repeat_freq_type'];
830 $repeatfreq = $rspecs['event_repeat_freq'];
831 $repeatexdate = $rspecs['exdate']; // repeating date exceptions
833 $hometext = $row['pc_hometext'];
834 if (substr($hometext, 0, 6) == ':text:') $hometext = substr($hometext, 6);
838 $eventstartdate = $date; // for repeating event stuff - JRM Oct-08
840 //-------------------------------------
842 //Set default facility for a new event based on the given 'userid'
844 /*************************************************************
845 $pref_facility = sqlFetchArray(sqlStatement("SELECT facility_id, facility FROM users WHERE id = $userid"));
846 *************************************************************/
847 if ($_SESSION['pc_facility']) {
848 $pref_facility = sqlFetchArray(sqlStatement(sprintf("
849 SELECT f.id as facility_id,
854 $_SESSION['pc_facility']
857 $pref_facility = sqlFetchArray(sqlStatement("
858 SELECT u.facility_id,
861 LEFT JOIN facility f on (u.facility_id = f.id)
865 /************************************************************/
866 $e2f = $pref_facility['facility_id'];
867 $e2f_name = $pref_facility['facility'];
869 //END of CHEMED -----------------------
872 // If we have a patient ID, get the name and phone numbers to display.
874 $prow = sqlQuery("SELECT lname, fname, phone_home, phone_biz, DOB " .
875 "FROM patient_data WHERE pid = '" . $patientid . "'");
876 $patientname = $prow['lname'] . ", " . $prow['fname'];
877 if ($prow['phone_home']) $patienttitle .= " H=" . $prow['phone_home'];
878 if ($prow['phone_biz']) $patienttitle .= " W=" . $prow['phone_biz'];
881 // Get the providers list.
882 $ures = sqlStatement("SELECT id, username, fname, lname FROM users WHERE " .
883 "authorized != 0 AND active = 1 ORDER BY lname, fname");
885 // Get event categories.
886 $cres = sqlStatement("SELECT pc_catid, pc_catname, pc_recurrtype, pc_duration, pc_end_all_day " .
887 "FROM openemr_postcalendar_categories ORDER BY pc_catname");
889 // Fix up the time format for AM/PM.
891 if ($starttimeh >= 12) { // p.m. starts at noon and not 12:01
893 if ($starttimeh > 12) $starttimeh -= 12;
899 <?php
html_header_show(); ?
>
900 <title
><?php
echo $eid ?
xl('Edit','e') : xl('Add New','e') ?
> <?php
xl('Event','e');?
></title
>
901 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
904 td
{ font
-size
:0.8em
; }
907 <style type
="text/css">@import
url(../../../library
/dynarch_calendar
.css
);</style
>
908 <script type
="text/javascript" src
="../../../library/topdialog.js"></script
>
909 <script type
="text/javascript" src
="../../../library/dialog.js"></script
>
910 <script type
="text/javascript" src
="../../../library/textformat.js"></script
>
911 <script type
="text/javascript" src
="../../../library/dynarch_calendar.js"></script
>
912 <script type
="text/javascript" src
="../../../library/dynarch_calendar_en.js"></script
>
913 <script type
="text/javascript" src
="../../../library/dynarch_calendar_setup.js"></script
>
916 // ============================================================================
917 // DBC SYSTEM JAVASCRIPT FILE
919 if ( $GLOBALS['dutchpc'] ) { ?
>
920 <script type
="text/javascript" src
="../../../library/js/add_edit_event.js"></script
>
923 // ============================================================================
926 <script language
="JavaScript">
928 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
930 var durations
= new Array();
931 // var rectypes = new Array();
933 // Read the event categories, generate their options list, and get
934 // the default event duration from them if this is a new event.
936 $prefcat_options = " <option value='0'>-- None --</option>\n";
939 $thisduration = $row['pc_alldayevent'] ?
1440 : round($row['pc_duration'] / 60);
941 while ($crow = sqlFetchArray($cres)) {
942 $duration = round($crow['pc_duration'] / 60);
943 if ($crow['pc_end_all_day']) $duration = 1440;
944 echo " durations[" . $crow['pc_catid'] . "] = $duration\n";
945 // echo " rectypes[" . $crow['pc_catid'] . "] = " . $crow['pc_recurrtype'] . "\n";
946 $catoptions .= " <option value='" . $crow['pc_catid'] . "'";
948 if ($crow['pc_catid'] == $row['pc_catid']) $catoptions .= " selected";
950 if ($crow['pc_catid'] == $default_catid) {
951 $catoptions .= " selected";
952 $thisduration = $duration;
955 $catoptions .= ">" . xl_appt_category($crow['pc_catname']) . "</option>\n";
957 // This section is to build the list of preferred categories:
959 $prefcat_options .= " <option value='" . $crow['pc_catid'] . "'";
961 if ($crow['pc_catid'] == $row['pc_prefcatid']) $prefcat_options .= " selected";
963 $prefcat_options .= ">" . xl_appt_category($crow['pc_catname']) . "</option>\n";
969 <?php
require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
971 // This is for callback by the find-patient popup.
972 function setpatient(pid
, lname
, fname
, dob
) {
973 var f
= document
.forms
[0];
974 f
.form_patient
.value
= lname +
', ' + fname
;
975 f
.form_pid
.value
= pid
;
976 dobstyle
= (dob
== '' || dob
.substr(5, 10) == '00-00') ?
'' : 'none';
977 document
.getElementById('dob_row').style
.display
= dobstyle
;
980 // This invokes the find-patient popup.
981 function sel_patient() {
982 dlgopen('find_patient_popup.php', '_blank', 500, 400);
985 // Do whatever is needed when a new event category is selected.
986 // For now this means changing the event title and duration.
987 function set_display() {
988 var f
= document
.forms
[0];
989 var s
= f
.form_category
;
990 if (s
.selectedIndex
>= 0) {
991 var catid
= s
.options
[s
.selectedIndex
].value
;
992 var style_apptstatus
= document
.getElementById('title_apptstatus').style
;
993 var style_prefcat
= document
.getElementById('title_prefcat').style
;
994 if (catid
== '2') { // In Office
995 style_apptstatus
.display
= 'none';
996 style_prefcat
.display
= '';
997 f
.form_apptstatus
.style
.display
= 'none';
998 f
.form_prefcat
.style
.display
= '';
1000 style_prefcat
.display
= 'none';
1001 style_apptstatus
.display
= '';
1002 f
.form_prefcat
.style
.display
= 'none';
1003 f
.form_apptstatus
.style
.display
= '';
1008 // Do whatever is needed when a new event category is selected.
1009 // For now this means changing the event title and duration.
1010 function set_category() {
1011 var f
= document
.forms
[0];
1012 var s
= f
.form_category
;
1013 if (s
.selectedIndex
>= 0) {
1014 var catid
= s
.options
[s
.selectedIndex
].value
;
1015 f
.form_title
.value
= s
.options
[s
.selectedIndex
].text
;
1016 f
.form_duration
.value
= durations
[catid
];
1021 // Modify some visual attributes when the all-day or timed-event
1022 // radio buttons are clicked.
1023 function set_allday() {
1024 var f
= document
.forms
[0];
1025 var color1
= '#777777';
1026 var color2
= '#777777';
1027 var disabled2
= true;
1028 if (document
.getElementById('rballday1').checked
) {
1031 if (document
.getElementById('rballday2').checked
) {
1035 document
.getElementById('tdallday1').style
.color
= color1
;
1036 document
.getElementById('tdallday2').style
.color
= color2
;
1037 document
.getElementById('tdallday3').style
.color
= color2
;
1038 document
.getElementById('tdallday4').style
.color
= color2
;
1039 document
.getElementById('tdallday5').style
.color
= color2
;
1040 f
.form_hour
.disabled
= disabled2
;
1041 f
.form_minute
.disabled
= disabled2
;
1042 f
.form_ampm
.disabled
= disabled2
;
1043 f
.form_duration
.disabled
= disabled2
;
1046 // Modify some visual attributes when the Repeat checkbox is clicked.
1047 function set_repeat() {
1048 var f
= document
.forms
[0];
1049 var isdisabled
= true;
1050 var mycolor
= '#777777';
1051 var myvisibility
= 'hidden';
1052 if (f
.form_repeat
.checked
) {
1054 mycolor
= '#000000';
1055 myvisibility
= 'visible';
1057 f
.form_repeat_type
.disabled
= isdisabled
;
1058 f
.form_repeat_freq
.disabled
= isdisabled
;
1059 f
.form_enddate
.disabled
= isdisabled
;
1060 document
.getElementById('tdrepeat1').style
.color
= mycolor
;
1061 document
.getElementById('tdrepeat2').style
.color
= mycolor
;
1062 document
.getElementById('img_enddate').style
.visibility
= myvisibility
;
1065 // This is for callback by the find-available popup.
1066 function setappt(year
,mon
,mday
,hours
,minutes
) {
1067 var f
= document
.forms
[0];
1068 f
.form_date
.value
= '' + year +
'-' +
1069 ('' +
(mon +
100)).substring(1) +
'-' +
1070 ('' +
(mday +
100)).substring(1);
1071 f
.form_ampm
.selectedIndex
= (hours
>= 12) ?
1 : 0;
1072 f
.form_hour
.value
= (hours
> 12) ? hours
- 12 : hours
;
1073 f
.form_minute
.value
= ('' +
(minutes +
100)).substring(1);
1076 // Invoke the find-available popup.
1077 function find_available() {
1078 top
.restoreSession();
1079 // (CHEMED) Conditional value selection, because there is no <select> element
1080 // when making an appointment for a specific provider
1081 var s
= document
.forms
[0].form_provider
;
1082 var f
= document
.forms
[0].facility
;
1083 <?php
if ($userid != 0) { ?
>
1084 s
= document
.forms
[0].form_provider
.value
;
1085 f
= document
.forms
[0].facility
.value
;
1087 s
= document
.forms
[0].form_provider
.options
[s
.selectedIndex
].value
;
1088 f
= document
.forms
[0].facility
.options
[f
.selectedIndex
].value
;
1090 var c
= document
.forms
[0].form_category
;
1091 var formDate
= document
.forms
[0].form_date
;
1092 dlgopen('find_appt_popup.php?providerid=' + s +
1093 '&catid=' + c
.options
[c
.selectedIndex
].value +
1095 '&startdate=' + formDate
.value
, '_blank', 500, 400);
1096 //END (CHEMED) modifications
1099 // ==============================
1101 function verify_selecteerbaar (a
) {
1102 var f
= document
.forms
[0]; var a
;
1103 if (f
.box5
.value
!= 0) a
= f
.box5
.value
;
1104 else if (f
.box4
.value
!= 0) a
= f
.box4
.value
;
1105 else if (f
.box3
.value
!= 0) a
= f
.box3
.value
;
1106 else if (f
.box2
.value
!= 0) a
= f
.box2
.value
;
1107 else if (f
.box1
.value
!= 0) a
= f
.box1
.value
;
1108 else { alert('You must choose an activity.'); return false;
1111 var answer
= $
.ajax({
1117 if ( answer
== 'false') { alert("Please select again"); return false; }
1125 if ( $GLOBALS['dutchpc'])
1128 <script type
="text/javascript">
1132 if ( $eid ) { // editing case
1136 } // EOS editing case
1142 } // EOS DBC DUTCH AJAX PART
1145 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8" />
1149 <body
class="body_top" onunload
='imclosing()'>
1151 <form method
='post' name
='theform' id
='theform' action
='add_edit_event.php?eid=<?php echo $eid ?>' />
1152 <!-- ViSolve
: Requirement
- Redirect to Create
New Patient Page
-->
1153 <input type
='hidden' size
='2' name
='resname' value
='empty' />
1155 if ($_POST["resname"]=="noresult"){
1157 <script language="Javascript">
1158 // refresh and redirect the parent window
1159 if (!opener.closed && opener.refreshme) opener.refreshme();
1160 top.restoreSession();
1161 opener.document.location="../../new/new.php";
1167 <!-- ViSolve
: Requirement
- Redirect to Create
New Patient Page
-->
1168 <input type
="hidden" name
="form_action" id
="form_action" value
="">
1169 <input type
="hidden" name
="recurr_affect" id
="recurr_affect" value
="">
1170 <!-- used
for recurring events
-->
1171 <input type
="hidden" name
="selected_date" id
="selected_date" value
="<?php echo $date; ?>">
1172 <input type
="hidden" name
="event_start_date" id
="event_start_date" value
="<?php echo $eventstartdate; ?>">
1175 <table border
='0' width
='100%'>
1178 <td width
='1%' nowrap
>
1179 <b
><?php
xl('Category','e'); ?
>:</b
>
1182 <select name
='form_category' onchange
='set_category()' style
='width:100%'>
1183 <?php
echo $catoptions ?
>
1186 <td width
='1%' nowrap
>
1188 <input type
='radio' name
='form_allday' onclick
='set_allday()' value
='1' id
='rballday1'
1189 <?php
if ($thisduration == 1440) echo "checked " ?
>/>
1191 <td colspan
='2' nowrap id
='tdallday1'>
1192 <?php
xl('All day event','e'); ?
>
1198 <b
><?php
xl('Date','e'); ?
>:</b
>
1201 <input type
='text' size
='10' name
='form_date' id
='form_date'
1202 value
='<?php echo $date ?>'
1203 title
='<?php xl('yyyy
-mm
-dd event date
or starting date
','e
'); ?>'
1204 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' />
1205 <img src
='../../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
1206 id
='img_date' border
='0' alt
='[?]' style
='cursor:pointer;cursor:hand'
1207 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
1211 <input type
='radio' name
='form_allday' onclick
='set_allday()' value
='0' id
='rballday2' <?php
if ($thisduration != 1440) echo "checked " ?
>/>
1213 <td width
='1%' nowrap id
='tdallday2'>
1214 <?php
xl('Time','e'); ?
>
1216 <td width
='1%' nowrap id
='tdallday3'>
1217 <input type
='text' size
='2' name
='form_hour' value
='<?php echo $starttimeh ?>'
1218 title
='<?php xl('Event start time
','e
'); ?>' /> :
1219 <input type
='text' size
='2' name
='form_minute' value
='<?php echo $starttimem ?>'
1220 title
='<?php xl('Event start time
','e
'); ?>' /> 
;
1221 <select name
='form_ampm' title
='Note: 12:00 noon is PM, not AM'>
1222 <option value
='1'><?php
xl('AM','e'); ?
></option
>
1223 <option value
='2'<?php
if ($startampm == '2') echo " selected" ?
>><?php
xl('PM','e'); ?
></option
>
1229 <b
><?php
xl('Title','e'); ?
>:</b
>
1232 <input type
='text' size
='10' name
='form_title' value
='<?php echo htmlspecialchars($row['pc_title
'], ENT_QUOTES); ?>'
1234 title
='<?php xl('Event title
','e
'); ?>' />
1239 <td nowrap id
='tdallday4'><?php
xl('duration','e'); ?
>
1241 <td nowrap id
='tdallday5'>
1242 <input type
='text' size
='4' name
='form_duration' value
='<?php echo $thisduration ?>' title
='<?php xl('Event duration in minutes
','e
'); ?>' />
1243 <?php
xl('minutes','e'); ?
>
1248 // =============================================
1249 // DBC DUTCH SYSTEMS
1251 if ( $GLOBALS['dutchpc'] ) { ?
>
1253 <td colspan
="3"> 
;</td
>
1255 <td
><input type
='text' name
='form_duration_indirect' id
='form_duration_indirect' size
='4'
1256 value
='<?php if ( isset($timerow['indirect_time
']) ) echo $timerow['indirect_time
']; ?>'/>minutes
</td
>
1259 <td colspan
="3"> 
;</td
>
1261 <td
><input type
='text' name
='form_duration_travel' name
='form_duration_travel' size
='4'
1262 value
='<?php if ( isset($timerow['travel_time
']) ) echo $timerow['travel_time
']; ?>'/>minutes
</td
>
1265 // =======================================================
1267 // cascading dropdowns
1268 // =======================================================
1269 if ( $GLOBALS['dutchpc'] ) {
1270 if ( $eid ) { // editing mode
1271 $activ = what_activity( $singleeid );
1273 if ( empty($activ) ) {
1274 $activ = "No activity selected.";
1276 $activ = what_full_sysid($activ);
1277 $_SESSION['editactiv'] = FALSE;
1281 // end DBC DUTCH SYSTEM
1284 <td
><b
>Current activity
:</b
><br
/><a href
="#" id
="addc"><
;<
;Add
/Change
>
;>
;</a
></td
>
1285 <td
><?
=$activ?
><br
/> <td colspan
="3"> 
;</td
></td
>
1288 <td nowrap
><b
>Activiteit
:</b
></td
>
1289 <td width
='1%' nowrap
>
1290 <select name
="box1" id
="box1">
1292 $rlvone = records_level1('ev');
1293 foreach ($rlvone as $rlv) {
1294 echo '<option value=\'' .$rlv['cl_activiteit_code']. '\'>' .$rlv['cl_activiteit_element']. '</option>';
1298 <td colspan
="3"><?php
if ( $patientid ) $are = has_ztndbc($patientid); else $are = ' '; ?
>
1299 <p style
="background-color: #78AEBC; padding: 3px; text-align: center"><?
=$are['str']?
></p
>
1303 <tr colspan
="2"><td
></td
><td
>
1304 <select id
="box2" name
="box2">
1307 <tr colspan
="2"><td
></td
><td
>
1308 <select id
="box3" name
="box3"></select
>
1311 <tr colspan
="2"><td
></td
><td
>
1312 <select id
="box4" name
="box4"></select
>
1315 <tr colspan
="2"><td
></td
><td
>
1316 <select id
="box5" name
="box5"></select
>
1322 <td nowrap
><b
><?php
xl('Facility','e'); ?
>:</b
></td
>
1325 if ($userid != 0) { ?
>
1326 <input type
='hidden' name
="facility" id
="facility" value
='<?php echo $e2f; ?>'/>
1327 <input type
='input' readonly name
="facility_txt" value
='<?php echo $e2f_name; ?>'/>
1329 <select name
="facility" id
="facility" >
1332 // ===========================
1333 // EVENTS TO FACILITIES
1334 //(CHEMED) added service_location WHERE clause
1335 // get the facilities
1336 /***************************************************************
1337 $qsql = sqlStatement("SELECT * FROM facility WHERE service_location != 0");
1338 ***************************************************************/
1339 $facils = getUserFacilities($_SESSION['authId']);
1340 $qsql = sqlStatement("SELECT id, name FROM facility WHERE service_location != 0");
1341 /**************************************************************/
1342 while ($facrow = sqlFetchArray($qsql)) {
1343 /*************************************************************
1344 $selected = ( $facrow['id'] == $e2f ) ? 'selected="selected"' : '' ;
1345 echo "<option value={$facrow['id']} $selected>{$facrow['name']}</option>";
1346 *************************************************************/
1347 if ($_SESSION['authorizedUser'] ||
in_array($facrow, $facils)) {
1348 $selected = ( $facrow['id'] == $e2f ) ?
'selected="selected"' : '' ;
1349 echo "<option value={$facrow['id']} $selected>{$facrow['name']}</option>";
1351 /************************************************************/
1354 // ===========================
1357 //END (CHEMED) IF ?>
1364 <b
><?php
xl('Patient','e'); ?
>:</b
>
1367 <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
/>
1368 <input type
='hidden' name
='form_pid' value
='<?php echo $patientid ?>' />
1370 <td colspan
='3' nowrap style
='font-size:8pt'>
1372 <span
class="infobox">
1373 <?php
if ($patienttitle != "") { echo $patienttitle; } ?
>
1380 <b
><?php
xl('Provider','e'); ?
>:</b
>
1386 // =======================================
1388 // =======================================
1389 if ($GLOBALS['select_multi_providers']) {
1391 // there are two posible situations: edit and new record
1393 // this is executed only on edit ($eid)
1395 if ( $multiple_value ) {
1396 // find all the providers around multiple key
1397 $qall = sqlStatement ("SELECT pc_aid AS providers FROM openemr_postcalendar_events WHERE pc_multiple = $multiple_value");
1398 while ($r = sqlFetchArray($qall)) {
1399 $providers_array[] = $r['providers'];
1402 $qall = sqlStatement ("SELECT pc_aid AS providers FROM openemr_postcalendar_events WHERE pc_eid = $eid");
1403 $providers_array = sqlFetchArray($qall);
1407 // build the selection tool
1408 echo "<select name='form_provider[]' style='width:100%' multiple='multiple' size='5' >";
1410 while ($urow = sqlFetchArray($ures)) {
1411 echo " <option value='" . $urow['id'] . "'";
1414 if ( in_array($urow['id'], $providers_array) ||
($urow['id'] == $userid) ) echo " selected";
1417 echo ">" . $urow['lname'];
1418 if ($urow['fname']) echo ", " . $urow['fname'];
1424 // =======================================
1426 // =======================================
1430 // get provider from existing event
1431 $qprov = sqlStatement ("SELECT pc_aid FROM openemr_postcalendar_events WHERE pc_eid = $eid");
1432 $provider = sqlFetchArray($qprov);
1433 $defaultProvider = $provider['pc_aid'];
1436 // this is a new event so smartly choose a default provider
1437 /*****************************************************************
1439 // Provider already given to us as a GET parameter.
1440 $defaultProvider = $userid;
1443 // default to the currently logged-in user
1444 $defaultProvider = $_SESSION['authUserID'];
1445 // or, if we have chosen a provider in the calendar, default to them
1446 // choose the first one if multiple have been selected
1447 if (count($_SESSION['pc_username']) >= 1) {
1448 // get the numeric ID of the first provider in the array
1449 $pc_username = $_SESSION['pc_username'];
1450 $firstProvider = sqlFetchArray(sqlStatement("select id from users where username='".$pc_username[0]."'"));
1451 $defaultProvider = $firstProvider['id'];
1456 echo "<select name='form_provider' style='width:100%' />";
1457 while ($urow = sqlFetchArray($ures)) {
1458 echo " <option value='" . $urow['id'] . "'";
1459 if ($urow['id'] == $defaultProvider) echo " selected";
1460 echo ">" . $urow['lname'];
1461 if ($urow['fname']) echo ", " . $urow['fname'];
1465 *****************************************************************/
1466 // default to the currently logged-in user
1467 $defaultProvider = $_SESSION['authUserID'];
1468 // or, if we have chosen a provider in the calendar, default to them
1469 // choose the first one if multiple have been selected
1470 if (count($_SESSION['pc_username']) >= 1) {
1471 // get the numeric ID of the first provider in the array
1472 $pc_username = $_SESSION['pc_username'];
1473 $firstProvider = sqlFetchArray(sqlStatement("select id from users where username='".$pc_username[0]."'"));
1474 $defaultProvider = $firstProvider['id'];
1476 // if we clicked on a provider's schedule to add the event, use THAT.
1477 if ($userid) $defaultProvider = $userid;
1479 echo "<select name='form_provider' style='width:100%' />";
1480 while ($urow = sqlFetchArray($ures)) {
1481 echo " <option value='" . $urow['id'] . "'";
1482 if ($urow['id'] == $defaultProvider) echo " selected";
1483 echo ">" . $urow['lname'];
1484 if ($urow['fname']) echo ", " . $urow['fname'];
1488 /****************************************************************/
1496 <input type
='checkbox' name
='form_repeat' onclick
='set_repeat(this)' value
='1'<?php
if ($repeats) echo " checked" ?
>/>
1497 <input type
='hidden' name
='form_repeat_exdate' id
='form_repeat_exdate' value
='<?php echo $repeatexdate; ?>' /> <!-- dates excluded from the repeat
-->
1499 <td nowrap id
='tdrepeat1'><?php
xl('Repeats','e'); ?
>
1503 <select name
='form_repeat_freq' title
=<?php
xl('Every, every other, every 3rd, etc.','e','\'','\''); ?
>>
1505 foreach (array(1 => xl('every'), 2 => xl('2nd'), 3 => xl('3rd'), 4 => xl('4th'), 5 => xl('5th'), 6 => xl('6th'))
1508 echo " <option value='$key'";
1509 if ($key == $repeatfreq) echo " selected";
1510 echo ">$value</option>\n";
1515 <select name
='form_repeat_type'>
1517 // See common.api.php for these:
1518 foreach (array(0 => xl('day') , 4 => xl('workday'), 1 => xl('week'), 2 => xl('month'), 3 => xl('year'))
1521 echo " <option value='$key'";
1522 if ($key == $repeattype) echo " selected";
1523 echo ">$value</option>\n";
1533 <span id
='title_apptstatus'><b
><?php
xl('Status','e'); ?
>:</b
></span
>
1534 <span id
='title_prefcat' style
='display:none'><b
><?php
xl('Pref Cat','e'); ?
>:</b
></span
>
1538 <select name
='form_apptstatus' style
='width:100%' title
='<?php xl('Appointment status
','e
'); ?>'>
1540 foreach ($statuses as $key => $value) {
1541 echo " <option value='$key'";
1542 if ($key == $row['pc_apptstatus']) echo " selected";
1543 echo ">" . htmlspecialchars($value) . "</option>\n";
1548 The following
list will be invisible unless this is an In Office
1549 event
, in which
case form_apptstatus (above
) is to be invisible
.
1551 <select name
='form_prefcat' style
='width:100%;display:none' title
='<?php xl('Preferred Event Category
','e
');?>'>
1552 <?php
echo $prefcat_options ?
>
1559 <td nowrap id
='tdrepeat2'><?php
xl('until','e'); ?
>
1562 <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
');?>' />
1563 <img src
='../../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
1564 id
='img_enddate' border
='0' alt
='[?]' style
='cursor:pointer;cursor:hand'
1565 title
='<?php xl('Click here to choose a date
','e
');?>'>
1567 if ($repeatexdate != "") {
1568 $tmptitle = "The following dates are excluded from the repeating series";
1569 if ($multiple_value) { $tmptitle .= " for one or more providers:\n"; }
1570 else { $tmptitle .= "\n"; }
1571 $exdates = explode(",", $repeatexdate);
1572 foreach ($exdates as $exdate) {
1573 $tmptitle .= date("d M Y", strtotime($exdate))."\n";
1575 echo "<a href='#' title='$tmptitle' alt='$tmptitle'><img src='../../pic/warning.gif' title='$tmptitle' alt='*!*' style='border:none;'/></a>";
1583 <b
><?php
xl('Comments','e'); ?
>:</b
>
1585 <td colspan
='4' nowrap
>
1586 <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
');?>' />
1591 // DOB is important for the clinic, so if it's missing give them a chance
1592 // to enter it right here. We must display or hide this row dynamically
1593 // in case the patient-select popup is used.
1594 $patient_dob = trim($prow['DOB']);
1595 $dobstyle = ($prow && (!$patient_dob ||
substr($patient_dob, 5) == '00-00')) ?
1598 <tr id
='dob_row' style
='display:<?php echo $dobstyle ?>'>
1599 <td colspan
='4' nowrap
>
1600 <b
><font color
='red'><?php
xl('DOB is missing, please enter if possible','e'); ?
>:</font
></b
>
1603 <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)' />
1604 <img src
='../../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
1605 id
='img_dob' border
='0' alt
='[?]' style
='cursor:pointer;cursor:hand'
1606 title
='<?php xl('Click here to choose a date
','e
');?>'>
1613 <input type
='button' name
='form_save' id
='form_save' value
='<?php xl('Save
','e
');?>' />
1615 <input type
='button' id
='find_available' value
='<?php xl('Find Available
','e
');?>' />
1617 <input type
='button' name
='form_delete' id
='form_delete' value
='<?php xl('Delete
','e
');?>'<?php
if (!$eid) echo " disabled" ?
> />
1619 <input type
='button' id
='cancel' value
='<?php xl('Cancel
','e
');?>' />
1621 <?php
if ($informant) echo "<p class='text'>" . xl('Last update by') . " $informant</p>\n"; ?
>
1625 <div id
="recurr_popup" style
="visibility: hidden; position: absolute; top: 50px; left: 50px; width: 400px; border: 3px outset yellow; background-color: yellow; padding: 5px;">
1626 Apply the changes to the Current event only
, to this
and all Future occurrences
, or to All occurances?
1628 <input type
="button" name
="all_events" id
="all_events" value
=" All ">
1629 <input type
="button" name
="future_events" id
="future_events" value
="Future">
1630 <input type
="button" name
="current_event" id
="current_event" value
="Current">
1631 <input type
="button" name
="recurr_cancel" id
="recurr_cancel" value
="Cancel">
1636 <script language
='JavaScript'>
1637 <?php
if ($eid) { ?
>
1645 Calendar
.setup({inputField
:"form_date", ifFormat
:"%Y-%m-%d", button
:"img_date"});
1646 Calendar
.setup({inputField
:"form_enddate", ifFormat
:"%Y-%m-%d", button
:"img_enddate"});
1647 Calendar
.setup({inputField
:"form_dob", ifFormat
:"%Y-%m-%d", button
:"img_dob"});
1650 <script language
="javascript">
1651 // jQuery stuff to make the page a little easier to use
1653 $
(document
).ready(function(){
1654 $
("#form_save").click(function() { validate(); });
1655 $
("#find_available").click(function() { find_available(); });
1656 $
("#form_delete").click(function() { deleteEvent(); });
1657 $
("#cancel").click(function() { window
.close(); });
1659 // buttons affecting the modification of a repeating event
1660 $
("#all_events").click(function() { $
("#recurr_affect").val("all"); EnableForm(); SubmitForm(); });
1661 $
("#future_events").click(function() { $
("#recurr_affect").val("future"); EnableForm(); SubmitForm(); });
1662 $
("#current_event").click(function() { $
("#recurr_affect").val("current"); EnableForm(); SubmitForm(); });
1663 $
("#recurr_cancel").click(function() { $
("#recurr_affect").val(""); EnableForm(); HideRecurrPopup(); });
1666 // Check for errors when the form is submitted.
1667 function validate() {
1668 var f
= document
.getElementById('theform');
1669 if (f
.form_repeat
.checked
&&
1670 (! f
.form_enddate
.value || f
.form_enddate
.value
< f
.form_date
.value
)) {
1671 alert('An end date later than the start date is required for repeated events!');
1674 $
('#form_action').val("save");
1676 <?php
if ($repeats): ?
>
1677 // existing repeating events need additional prompt
1678 if ($
("#recurr_affect").val() == "") {
1680 // show the current/future/all DIV for the user to choose one
1681 $
("#recurr_popup").css("visibility", "visible");
1686 return SubmitForm();
1689 // disable all the form elements outside the recurr_popup
1690 function DisableForm() {
1691 $
("#theform").children().attr("disabled", "true");
1693 function EnableForm() {
1694 $
("#theform").children().removeAttr("disabled");
1696 // hide the recurring popup DIV
1697 function HideRecurrPopup() {
1698 $
("#recurr_popup").css("visibility", "hidden");
1701 function deleteEvent() {
1702 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?")) {
1703 $
('#form_action').val("delete");
1705 <?php
if ($repeats): ?
>
1706 // existing repeating events need additional prompt
1707 if ($
("#recurr_affect").val() == "") {
1709 // show the current/future/all DIV for the user to choose one
1710 $
("#recurr_popup").css("visibility", "visible");
1715 return SubmitForm();
1720 function SubmitForm() {
1721 // DBC Dutch System validation
1722 <?php
if ( $GLOBALS['dutchpc'] && $_SESSION['editactiv']) { ?
>
1723 var a
= verify_selecteerbaar();
1724 if ( !a
) return false;
1728 $
('#theform').submit();
1729 top
.restoreSession();