3 * Add or edit an event in the calendar.
5 * Can be displayed as a popup window, or as an iframe via
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 * //------------------------------------------------------------//
24 * Copyright (C) 2005-2013 Rod Roark <rod@sunsetsystems.com>
25 * Copyright (C) 2017 Brady Miller <brady.g.miller@gmail.com>
27 * LICENSE: This program is free software; you can redistribute it and/or
28 * modify it under the terms of the GNU General Public License
29 * as published by the Free Software Foundation; either version 3
30 * of the License, or (at your option) any later version.
31 * This program is distributed in the hope that it will be useful,
32 * but WITHOUT ANY WARRANTY; without even the implied warranty of
33 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34 * GNU General Public License for more details.
35 * You should have received a copy of the GNU General Public License
36 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
39 * @author Rod Roark <rod@sunsetsystems.com>
40 * @author Brady Miller <brady.g.miller@gmail.com>
41 * @link http://www.open-emr.org
45 $fake_register_globals=false;
46 $sanitize_all_escapes=true;
48 require_once('../../globals.php');
49 require_once($GLOBALS['srcdir'].'/patient.inc');
50 require_once($GLOBALS['srcdir'].'/forms.inc');
51 require_once($GLOBALS['srcdir'].'/calendar.inc');
52 require_once($GLOBALS['srcdir'].'/options.inc.php');
53 require_once($GLOBALS['srcdir'].'/encounter_events.inc.php');
54 require_once($GLOBALS['srcdir'].'/acl.inc');
55 require_once($GLOBALS['srcdir'].'/patient_tracker.inc.php');
56 require_once($GLOBALS['incdir']."/main/holidays/Holidays_Controller.php");
57 require_once($GLOBALS['srcdir'].'/group.inc');
59 //Check access control
60 if (!acl_check('patients','appt','',array('write','wsome') ))
61 die(xl('Access not allowed'));
63 /* Things that might be passed by our opener. */
64 $eid = $_GET['eid']; // only for existing events
65 $date = $_GET['date']; // this and below only for new events
66 $userid = $_GET['userid'];
67 $default_catid = $_GET['catid'] ?
$_GET['catid'] : '5';
70 $date = substr($date, 0, 4) . '-' . substr($date, 4, 2) . '-' . substr($date, 6);
72 $date = date("Y-m-d");
75 if (isset($_GET['starttimem']))
76 $starttimem = substr('00' . $_GET['starttimem'], -2);
78 if (isset($_GET['starttimeh'])) {
79 $starttimeh = $_GET['starttimeh'];
80 if (isset($_GET['startampm'])) {
81 if ($_GET['startampm'] == '2' && $starttimeh < 12)
85 $starttimeh = date("G");
92 <script type
="text/javascript" src
="<?php echo $webroot ?>/interface/main/tabs/js/include_opener.js?v=<?php echo $v_js_includes; ?>"></script
>
93 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative'] ?>/jquery-min-3-1-1/index.js"></script
>
95 <!-- validation library
-->
96 <!--//Not lbf forms use the new validation, please make sure you have the corresponding values in the list Page validation-->
97 <?php
$use_validate_js = 1;?
>
98 <?php
require_once($GLOBALS['srcdir'] . "/validation/validation_script.js.php"); ?
>
100 //Gets validation rules from Page Validation list.
101 //Note that for technical reasons, we are bypassing the standard validateUsingPageRules() call.
102 if($_GET['group'] == true)
104 $collectthis = collectValidationPageRules("/interface/main/calendar/add_edit_event.php?group=true");
105 elseif($_GET['prov'])
110 $collectthis = collectValidationPageRules("/interface/main/calendar/add_edit_event.php");
112 if (empty($collectthis)) {
113 $collectthis = "undefined";
116 $collectthis = $collectthis[array_keys($collectthis)[0]]["rules"];
122 function InsertEventFull()
124 global $new_multiple_value,$provider,$event_date,$duration,$recurrspec,$starttime,$endtime,$locationspec;
125 // =======================================
126 // multi providers case
127 // =======================================
128 if (is_array($_POST['form_provider'])) {
130 // obtain the next available unique key to group multiple providers around some event
131 $q = sqlStatement ("SELECT MAX(pc_multiple) as max FROM openemr_postcalendar_events");
132 $max = sqlFetchArray($q);
133 $new_multiple_value = $max['max'] +
1;
136 foreach ($_POST['form_provider'] as $provider) {
138 // specify some special variables needed for the INSERT
139 $args['new_multiple_value'] = $new_multiple_value;
140 $args['form_provider'] = $provider;
141 $args['event_date'] = $event_date;
142 $args['duration'] = $duration * 60;
143 $args['recurrspec'] = $recurrspec;
144 $args['starttime'] = $starttime;
145 $args['endtime'] = $endtime;
146 $args['locationspec'] = $locationspec;
147 $pc_eid_temp = InsertEvent($args);
148 if($pc_eid == null) $pc_eid = $pc_eid_temp;
153 // ====================================
155 // ====================================
158 // specify some special variables needed for the INSERT
159 $args['new_multiple_value'] = "";
160 $args['event_date'] = $event_date;
161 $args['duration'] = $duration * 60;
162 $args['recurrspec'] = $recurrspec;
163 $args['starttime'] = $starttime;
164 $args['endtime'] = $endtime;
165 $args['locationspec'] = $locationspec;
166 $pc_eid = InsertEvent($args);
170 function DOBandEncounter($pc_eid)
172 global $event_date,$info_msg;
173 // Save new DOB if it's there.
174 $patient_dob = trim($_POST['form_dob']);
175 $tmph = $_POST['form_hour'] +
0;
176 $tmpm = $_POST['form_minute'] +
0;
177 if ($_POST['form_ampm'] == '2' && $tmph < 12) $tmph +
= 12;
178 $appttime = "$tmph:$tmpm:00";
180 if ($patient_dob && $_POST['form_pid']) {
181 sqlStatement("UPDATE patient_data SET DOB = ? WHERE " .
182 "pid = ?", array($patient_dob,$_POST['form_pid']) );
185 // Manage tracker status.
186 // And auto-create a new encounter if appropriate.
187 if (!empty($_POST['form_pid'])) {
188 if ($GLOBALS['auto_create_new_encounters'] && $event_date == date('Y-m-d') && (is_checkin($_POST['form_apptstatus']) == '1') && !is_tracker_encounter_exist($event_date,$appttime,$_POST['form_pid'],$_GET['eid']))
190 $encounter = todaysEncounterCheck($_POST['form_pid'], $event_date, $_POST['form_comments'], $_POST['facility'], $_POST['billing_facility'], $_POST['form_provider'], $_POST['form_category'], false);
192 $info_msg .= xl("New encounter created with id");
193 $info_msg .= " $encounter";
195 # Capture the appt status and room number for patient tracker. This will map the encounter to it also.
196 if ( isset($GLOBALS['temporary-eid-for-manage-tracker']) ||
!empty($_GET['eid']) ) {
197 // Note that the temporary-eid-for-manage-tracker is used to capture the eid for new appointments and when separate a recurring
198 // appointment. It is set in the InsertEvent() function. Note that in the case of spearating a recurrent appointment, the get eid
199 // parameter is actually erroneous(is eid of the recurrent appt and not the new separated appt), so need to use the
200 // temporary-eid-for-manage-tracker global instead.
201 $temp_eid = (isset($GLOBALS['temporary-eid-for-manage-tracker'])) ?
$GLOBALS['temporary-eid-for-manage-tracker'] : $_GET['eid'];
202 manage_tracker_status($event_date,$appttime,$temp_eid,$_POST['form_pid'],$_SESSION["authUser"],$_POST['form_apptstatus'],$_POST['form_room'],$encounter);
207 # Capture the appt status and room number for patient tracker.
208 if (!empty($_GET['eid'])) {
209 manage_tracker_status($event_date,$appttime,$_GET['eid'],$_POST['form_pid'],$_SESSION["authUser"],$_POST['form_apptstatus'],$_POST['form_room']);
213 // auto create encounter for therapy group
214 if(!empty($_POST['form_gid'])){
215 // status Took Place is the check in of therapy group
216 if ($GLOBALS['auto_create_new_encounters'] && $event_date == date('Y-m-d') && $_POST['form_apptstatus'] == '=') {
217 $encounter = todaysTherapyGroupEncounterCheck($_POST['form_gid'], $event_date, $_POST['form_comments'], $_POST['facility'], $_POST['billing_facility'], $_POST['form_provider'], $_POST['form_category'], false, $pc_eid);
219 $info_msg .= xl("New group encounter created with id");
220 $info_msg .= " $encounter";
228 /*This function is used for setting the date of the first event when using the "day_every_week" repetition mechanism.
229 When the 'start date' is not one of the days chosen for the repetition, the start date needs to be changed to the first
230 occurrence of one of these set days. */
231 function setEventDate($start_date, $recurrence){
232 $timestamp = strtotime($start_date);
233 $day = date('w', $timestamp);
234 //If the 'start date' is one of the set days
235 if(in_array(($day+
1), explode(',',$recurrence))){
238 //else: (we need to change start date to first occurrence of one of the set days)
240 $new_date = getTheNextAppointment($start_date, $recurrence);
246 //================================================================================================================
248 // EVENTS TO FACILITIES (lemonsoftware)
249 //(CHEMED) get facility name
250 // edit event case - if there is no association made, then insert one with the first facility
253 $facility = sqlQuery("SELECT pc_facility, pc_multiple, pc_aid, facility.name
254 FROM openemr_postcalendar_events
255 LEFT JOIN facility ON (openemr_postcalendar_events.pc_facility = facility.id)
256 WHERE pc_eid = ?", array($eid) );
257 // if ( !$facility['pc_facility'] ) {
258 if ( is_array($facility) && !$facility['pc_facility'] ) {
259 $qmin = sqlQuery("SELECT facility_id as minId, facility FROM users WHERE id = ?", array($facility['pc_aid']) );
260 $min = $qmin['minId'];
261 $min_name = $qmin['facility'];
263 // multiple providers case
264 if ( $GLOBALS['select_multi_providers'] ) {
265 $mul = $facility['pc_multiple'];
266 sqlStatement("UPDATE openemr_postcalendar_events SET pc_facility = ? WHERE pc_multiple = ?", array($min,$mul) );
270 sqlStatement("UPDATE openemr_postcalendar_events SET pc_facility = ? WHERE pc_eid = ?", array($min,$eid) );
272 $e2f_name = $min_name;
275 if (!$facility['pc_facility'] && $_SESSION['pc_facility']) {
276 $e2f = $_SESSION['pc_facility'];
277 } elseif (!$facility['pc_facility'] && $_COOKIE['pc_facility'] && $GLOBALS['set_facility_cookie']) {
278 $e2f = $_COOKIE['pc_facility'];
280 $e2f = $facility['pc_facility'];
281 $e2f_name = $facility['name'];
286 // ===========================
287 //=============================================================================================================================
288 if ($_POST['form_action'] == "duplicate" ||
$_POST['form_action'] == "save")
291 // Compute start and end time strings to be saved.
292 if ($_POST['form_allday']) {
297 $tmph = $_POST['form_hour'] +
0;
298 $tmpm = $_POST['form_minute'] +
0;
299 if ($_POST['form_ampm'] == '2' && $tmph < 12) $tmph +
= 12;
300 $duration = abs($_POST['form_duration']); // fixes #395
302 $starttime = "$tmph:$tmpm:00";
305 while ($tmpm >= 60) {
309 $endtime = "$tmph:$tmpm:00";
311 // Set up working variables related to repeated events.
313 $my_repeat_freq = 0 +
$_POST['form_repeat_freq'];
314 $my_repeat_type = 0 +
$_POST['form_repeat_type'];
315 $my_repeat_on_num = 1;
316 $my_repeat_on_day = 0;
317 $my_repeat_on_freq = 0;
319 // the starting date of the event, pay attention with this value
320 // when editing recurring events -- JRM Oct-08
321 $event_date = fixDate($_POST['form_date']);
323 //If used new recurrence mechanism of set days every week
324 if(!empty($_POST['days_every_week'])){
326 //loop through checkboxes and insert encounter days into array
327 $days_every_week_arr = array();
328 for($i=1; $i<=7; $i++
){
329 if(!empty($_POST['day_' . $i])){
330 array_push($days_every_week_arr, $i);
333 $my_repeat_freq = implode(",",$days_every_week_arr);
335 $event_date = fixDate(setEventDate($_POST['form_date'], $my_repeat_freq));
338 elseif (!empty($_POST['form_repeat'])){
341 if ($my_repeat_type > 4) {
343 $time = strtotime($event_date);
344 $my_repeat_on_day = 0 +
date('w', $time);
345 $my_repeat_on_freq = $my_repeat_freq;
346 if ($my_repeat_type == 5) {
347 $my_repeat_on_num = intval((date('j', $time) - 1) / 7) +
1;
349 // Last occurence of this weekday on the month
350 $my_repeat_on_num = 5;
352 // Maybe not needed, but for consistency with postcalendar:
359 // Useless garbage that we must save.
360 $locationspecs = array("event_location" => "",
361 "event_street1" => "",
362 "event_street2" => "",
367 $locationspec = serialize($locationspecs);
369 // capture the recurring specifications
370 $recurrspec = array("event_repeat_freq" => "$my_repeat_freq",
371 "event_repeat_freq_type" => "$my_repeat_type",
372 "event_repeat_on_num" => "$my_repeat_on_num",
373 "event_repeat_on_day" => "$my_repeat_on_day",
374 "event_repeat_on_freq" => "$my_repeat_on_freq",
375 "exdate" => $_POST['form_repeat_exdate']
379 if($my_recurrtype == 2) { // Added by epsdky 2016 (details in commit)
380 if($_POST['old_repeats'] == 2) {
381 if($_POST['rt2_flag2']) $recurrspec['rt2_pf_flag'] = "1";
382 } else $recurrspec['rt2_pf_flag'] = "1";
383 } // End of addition by epsdky
385 // no recurr specs, this is used for adding a new non-recurring event
386 $noRecurrspec = array("event_repeat_freq" => "",
387 "event_repeat_freq_type" => "",
388 "event_repeat_on_num" => "1",
389 "event_repeat_on_day" => "0",
390 "event_repeat_on_freq" => "0",
394 }//if ($_POST['form_action'] == "duplicate" || $_POST['form_action'] == "save")
395 //=============================================================================================================================
396 if ($_POST['form_action'] == "duplicate") {
398 $eid = InsertEventFull();
399 DOBandEncounter($eid);
403 // If we are saving, then save and close the window.
405 if ($_POST['form_action'] == "save") {
406 /* =======================================================
408 * =====================================================*/
411 // what is multiple key around this $eid?
412 $row = sqlQuery("SELECT pc_multiple FROM openemr_postcalendar_events WHERE pc_eid = ?", array($eid) );
414 // ====================================
415 // multiple providers
416 // ====================================
417 if ($GLOBALS['select_multi_providers'] && $row['pc_multiple']) {
419 // obtain current list of providers regarding the multiple key
420 $up = sqlStatement("SELECT pc_aid FROM openemr_postcalendar_events WHERE pc_multiple=?", array($row['pc_multiple']) );
421 while ($current = sqlFetchArray($up)) { $providers_current[] = $current['pc_aid']; }
423 // get the new list of providers from the submitted form
424 $providers_new = $_POST['form_provider'];
426 // ===== Only current event of repeating series =====
427 if ($_POST['recurr_affect'] == 'current') {
429 // update all existing event records to exlude the current date
430 foreach ($providers_current as $provider) {
431 // update the provider's original event
432 // get the original event's repeat specs
433 $origEvent = sqlQuery("SELECT pc_recurrspec FROM openemr_postcalendar_events ".
434 " WHERE pc_aid = ? AND pc_multiple=?", array($provider,$row['pc_multiple']) );
435 $oldRecurrspec = unserialize($origEvent['pc_recurrspec']);
436 $selected_date = date("Ymd", strtotime($_POST['selected_date']));
437 if ($oldRecurrspec['exdate'] != "") { $oldRecurrspec['exdate'] .= ",".$selected_date; }
438 else { $oldRecurrspec['exdate'] .= $selected_date; }
440 // mod original event recur specs to exclude this date
441 sqlStatement("UPDATE openemr_postcalendar_events SET " .
442 " pc_recurrspec = ? ".
443 " WHERE pc_aid = ? AND pc_multiple=?", array(serialize($oldRecurrspec),$provider,$row['pc_multiple']) );
446 // obtain the next available unique key to group multiple providers around some event
447 $q = sqlStatement ("SELECT MAX(pc_multiple) as max FROM openemr_postcalendar_events");
448 $max = sqlFetchArray($q);
449 $new_multiple_value = $max['max'] +
1;
451 // insert a new event record for each provider selected on the form
452 foreach ($providers_new as $provider) {
453 // insert a new event on this date with POST form data
455 // specify some special variables needed for the INSERT
456 $args['new_multiple_value'] = $new_multiple_value;
457 $args['form_provider'] = $provider;
458 $args['event_date'] = $event_date;
459 $args['duration'] = $duration * 60;
460 // this event is forced to NOT REPEAT
461 $args['form_repeat'] = "0";
462 $args['days_every_week'] = "0";
463 $args['recurrspec'] = $noRecurrspec;
464 $args['form_enddate'] = "0000-00-00";
465 $args['starttime'] = $starttime;
466 $args['endtime'] = $endtime;
467 $args['locationspec'] = $locationspec;
472 // ===== Future Recurring events of a repeating series =====
473 else if ($_POST['recurr_affect'] == 'future') {
474 // update all existing event records to
475 // stop recurring on this date-1
476 $selected_date = date("Y-m-d", (strtotime($_POST['selected_date'])-24*60*60));
477 foreach ($providers_current as $provider) {
478 // In case of a change in the middle of the event
479 if (strcmp($_POST['event_start_date'],$_POST['selected_date'])!=0) {
480 // mod original event recur specs to end on this date
481 sqlStatement("UPDATE openemr_postcalendar_events SET " .
483 " WHERE pc_aid = ? AND pc_multiple=?", array($selected_date, $provider, $row['pc_multiple']));
485 // In case of a change in the event head
487 sqlStatement("DELETE FROM openemr_postcalendar_events " .
488 " WHERE pc_aid = ? AND pc_multiple=?" , array($provider, $row['pc_multiple']));
493 // obtain the next available unique key to group multiple providers around some event
494 $q = sqlStatement ("SELECT MAX(pc_multiple) as max FROM openemr_postcalendar_events");
495 $max = sqlFetchArray($q);
496 $new_multiple_value = $max['max'] +
1;
498 // insert a new event record for each provider selected on the form
499 foreach ($providers_new as $provider) {
500 // insert a new event on this date with POST form data
502 // specify some special variables needed for the INSERT
503 $args['new_multiple_value'] = $new_multiple_value;
504 $args['form_provider'] = $provider;
505 $args['event_date'] = $event_date;
506 $args['duration'] = $duration * 60;
507 $args['recurrspec'] = $recurrspec;
508 $args['starttime'] = $starttime;
509 $args['endtime'] = $endtime;
510 $args['locationspec'] = $locationspec;
516 /* =================================================================== */
517 // ===== a Single event or All events in a repeating series ==========
518 /* =================================================================== */
520 // this difference means that some providers from current was UNCHECKED
521 // so we must delete this event for them
522 $r1 = array_diff ($providers_current, $providers_new);
524 foreach ($r1 as $to_be_removed) {
525 sqlQuery("DELETE FROM openemr_postcalendar_events WHERE pc_aid=? AND pc_multiple=?", array($to_be_removed,$row['pc_multiple']) );
529 // perform a check to see if user changed event date
530 // this is important when editing an existing recurring event
532 if ($_POST['form_date'] == $_POST['selected_date']) {
533 // user has NOT changed the start date of the event (and not recurrtype 3)
534 if($my_recurrtype != 3) $event_date = fixDate($_POST['event_start_date']);
537 // this difference means that some providers were added
538 // so we must insert this event for them
539 $r2 = array_diff ($providers_new, $providers_current);
541 foreach ($r2 as $to_be_inserted) {
543 // specify some special variables needed for the INSERT
544 $args['new_multiple_value'] = $row['pc_multiple'];
545 $args['form_provider'] = $to_be_inserted;
546 $args['event_date'] = $event_date;
547 $args['duration'] = $duration * 60;
548 $args['recurrspec'] = $recurrspec;
549 $args['starttime'] = $starttime;
550 $args['endtime'] = $endtime;
551 $args['locationspec'] = $locationspec;
556 // after the two diffs above, we must update for remaining providers
557 // those who are intersected in $providers_current and $providers_new
558 foreach ($_POST['form_provider'] as $provider) {
559 sqlStatement("UPDATE openemr_postcalendar_events SET " .
560 "pc_catid = '" . add_escape_custom($_POST['form_category']) . "', " .
561 "pc_pid = '" . add_escape_custom($_POST['form_pid']) . "', " .
562 "pc_title = '" . add_escape_custom($_POST['form_title']) . "', " .
563 "pc_time = NOW(), " .
564 "pc_hometext = '" . add_escape_custom($_POST['form_comments']) . "', " .
565 "pc_room = '" . add_escape_custom($_POST['form_room']) . "', " .
566 "pc_informant = '" . add_escape_custom($_SESSION['authUserID']) . "', " .
567 "pc_eventDate = '" . add_escape_custom($event_date) . "', " .
568 "pc_endDate = '" . add_escape_custom(fixDate($_POST['form_enddate'])) . "', " .
569 "pc_duration = '" . add_escape_custom(($duration * 60)) . "', " .
570 "pc_recurrtype = '" . add_escape_custom($my_recurrtype) . "', " .
571 "pc_recurrspec = '" . add_escape_custom(serialize($recurrspec)) . "', " .
572 "pc_startTime = '" . add_escape_custom($starttime) . "', " .
573 "pc_endTime = '" . add_escape_custom($endtime) . "', " .
574 "pc_alldayevent = '" . add_escape_custom($_POST['form_allday']) . "', " .
575 "pc_apptstatus = '" . add_escape_custom($_POST['form_apptstatus']) . "', " .
576 "pc_prefcatid = '" . add_escape_custom($_POST['form_prefcat']) . "' ," .
577 "pc_facility = '" . add_escape_custom((int)$_POST['facility']) ."' ," . // FF stuff
578 "pc_billing_location = '" . add_escape_custom((int)$_POST['billing_facility']) ."' " .
579 "WHERE pc_aid = '" . add_escape_custom($provider) . "' AND pc_multiple = '" . add_escape_custom($row['pc_multiple']) . "'");
583 // ====================================
585 // ====================================
586 } elseif ( !$row['pc_multiple'] ) {
587 if ( $GLOBALS['select_multi_providers'] ) {
588 $prov = $_POST['form_provider'][0];
590 $prov = $_POST['form_provider'];
593 if ($_POST['recurr_affect'] == 'current') {
594 // get the original event's repeat specs
595 $origEvent = sqlQuery("SELECT pc_recurrspec FROM openemr_postcalendar_events WHERE pc_eid = ?", array($eid) );
596 $oldRecurrspec = unserialize($origEvent['pc_recurrspec']);
597 $selected_date = date("Ymd", strtotime($_POST['selected_date']));
598 if ($oldRecurrspec['exdate'] != "") { $oldRecurrspec['exdate'] .= ",".$selected_date; }
599 else { $oldRecurrspec['exdate'] .= $selected_date; }
601 // mod original event recur specs to exclude this date
602 sqlStatement("UPDATE openemr_postcalendar_events SET " .
603 " pc_recurrspec = ? ".
604 " WHERE pc_eid = ?", array(serialize($oldRecurrspec),$eid) );
606 // insert a new event on this date with POST form data
608 // specify some special variables needed for the INSERT
609 $args['event_date'] = $event_date;
610 $args['duration'] = $duration * 60;
611 // this event is forced to NOT REPEAT
612 $args['form_repeat'] = "0";
613 $args['days_every_week'] = "0";
614 $args['recurrspec'] = $noRecurrspec;
615 $args['form_enddate'] = "0000-00-00";
616 $args['starttime'] = $starttime;
617 $args['endtime'] = $endtime;
618 $args['locationspec'] = $locationspec;
621 else if ($_POST['recurr_affect'] == 'future') {
622 // mod original event to stop recurring on this date-1
623 $selected_date = date("Ymd", (strtotime($_POST['selected_date'])-24*60*60));
624 sqlStatement("UPDATE openemr_postcalendar_events SET " .
626 " WHERE pc_eid = ?", array($selected_date,$eid) );
628 // insert a new event starting on this date with POST form data
630 // specify some special variables needed for the INSERT
631 $args['event_date'] = $event_date;
632 $args['duration'] = $duration * 60;
633 $args['recurrspec'] = $recurrspec;
634 $args['starttime'] = $starttime;
635 $args['endtime'] = $endtime;
636 $args['locationspec'] = $locationspec;
641 // perform a check to see if user changed event date
642 // this is important when editing an existing recurring event
644 if ($_POST['form_date'] == $_POST['selected_date']) {
645 // user has NOT changed the start date of the event (and not recurrtype 3)
646 if($my_recurrtype != 3) $event_date = fixDate($_POST['event_start_date']);
649 // mod the SINGLE event or ALL EVENTS in a repeating series
650 // simple provider case
651 sqlStatement("UPDATE openemr_postcalendar_events SET " .
652 "pc_catid = '" . add_escape_custom($_POST['form_category']) . "', " .
653 "pc_aid = '" . add_escape_custom($prov) . "', " .
654 "pc_pid = '" . add_escape_custom($_POST['form_pid']) . "', " .
655 "pc_title = '" . add_escape_custom($_POST['form_title']) . "', " .
656 "pc_time = NOW(), " .
657 "pc_hometext = '" . add_escape_custom($_POST['form_comments']) . "', " .
658 "pc_room = '" . add_escape_custom($_POST['form_room']) . "', " .
659 "pc_informant = '" . add_escape_custom($_SESSION['authUserID']) . "', " .
660 "pc_eventDate = '" . add_escape_custom($event_date) . "', " .
661 "pc_endDate = '" . add_escape_custom(fixDate($_POST['form_enddate'])) . "', " .
662 "pc_duration = '" . add_escape_custom(($duration * 60)) . "', " .
663 "pc_recurrtype = '" . add_escape_custom($my_recurrtype) . "', " .
664 "pc_recurrspec = '" . add_escape_custom(serialize($recurrspec)) . "', " .
665 "pc_startTime = '" . add_escape_custom($starttime) . "', " .
666 "pc_endTime = '" . add_escape_custom($endtime) . "', " .
667 "pc_alldayevent = '" . add_escape_custom($_POST['form_allday']) . "', " .
668 "pc_apptstatus = '" . add_escape_custom($_POST['form_apptstatus']) . "', " .
669 "pc_prefcatid = '" . add_escape_custom($_POST['form_prefcat']) . "' ," .
670 "pc_facility = '" . add_escape_custom((int)$_POST['facility']) ."' ," . // FF stuff
671 "pc_billing_location = '" . add_escape_custom((int)$_POST['billing_facility']) ."' " .
672 "WHERE pc_eid = '" . add_escape_custom($eid) . "'");
676 // =======================================
677 // end Update Multi providers case
678 // =======================================
680 // EVENTS TO FACILITIES
685 /* =======================================================
686 * INSERT NEW EVENT(S)
687 * ======================================================*/
689 $eid = InsertEventFull();
693 // done with EVENT insert/update statements
695 DOBandEncounter(isset($eid) ?
$eid : null);
699 // =======================================
701 // =======================================
702 else if ($_POST['form_action'] == "delete") {
703 // =======================================
704 // multi providers event
705 // =======================================
706 if ($GLOBALS['select_multi_providers']) {
708 // what is multiple key around this $eid?
709 $row = sqlQuery("SELECT pc_multiple FROM openemr_postcalendar_events WHERE pc_eid = ?", array($eid) );
711 // obtain current list of providers regarding the multiple key
712 $providers_current = array();
713 $up = sqlStatement("SELECT pc_aid FROM openemr_postcalendar_events WHERE pc_multiple=?", array($row['pc_multiple']) );
714 while ($current = sqlFetchArray($up)) { $providers_current[] = $current['pc_aid']; }
716 // establish a WHERE clause
717 if ( $row['pc_multiple'] ) { $whereClause = "pc_multiple = '{$row['pc_multiple']}'"; }
718 else { $whereClause = "pc_eid = '$eid'"; }
720 if ($_POST['recurr_affect'] == 'current') {
721 // update all existing event records to exlude the current date
722 foreach ($providers_current as $provider) {
723 // update the provider's original event
724 // get the original event's repeat specs
725 $origEvent = sqlQuery("SELECT pc_recurrspec FROM openemr_postcalendar_events ".
726 " WHERE pc_aid <=> ? AND pc_multiple=?", array($provider,$row['pc_multiple']) );
727 $oldRecurrspec = unserialize($origEvent['pc_recurrspec']);
728 $selected_date = date("Ymd", strtotime($_POST['selected_date']));
729 if ($oldRecurrspec['exdate'] != "") { $oldRecurrspec['exdate'] .= ",".$selected_date; }
730 else { $oldRecurrspec['exdate'] .= $selected_date; }
732 // mod original event recur specs to exclude this date
733 sqlStatement("UPDATE openemr_postcalendar_events SET " .
734 " pc_recurrspec = ? ".
735 " WHERE ". $whereClause, array(serialize($oldRecurrspec)) );
738 else if ($_POST['recurr_affect'] == 'future') {
739 // update all existing event records to stop recurring on this date-1
740 $selected_date = date("Ymd", (strtotime($_POST['selected_date'])-24*60*60));
741 foreach ($providers_current as $provider) {
742 // update the provider's original event
743 sqlStatement("UPDATE openemr_postcalendar_events SET " .
745 " WHERE ".$whereClause, array($selected_date) );
749 // really delete the event from the database
750 sqlStatement("DELETE FROM openemr_postcalendar_events WHERE ".$whereClause);
754 // =======================================
755 // single provider event
756 // =======================================
759 if ($_POST['recurr_affect'] == 'current') {
760 // mod original event recur specs to exclude this date
762 // get the original event's repeat specs
763 $origEvent = sqlQuery("SELECT pc_recurrspec FROM openemr_postcalendar_events WHERE pc_eid = ?", array($eid) );
764 $oldRecurrspec = unserialize($origEvent['pc_recurrspec']);
765 $selected_date = date("Ymd", strtotime($_POST['selected_date']));
766 if ($oldRecurrspec['exdate'] != "") { $oldRecurrspec['exdate'] .= ",".$selected_date; }
767 else { $oldRecurrspec['exdate'] .= $selected_date; }
768 sqlStatement("UPDATE openemr_postcalendar_events SET " .
769 " pc_recurrspec = ? ".
770 " WHERE pc_eid = ?", array(serialize($oldRecurrspec),$eid) );
773 else if ($_POST['recurr_affect'] == 'future') {
774 // mod original event to stop recurring on this date-1
775 $selected_date = date("Ymd", (strtotime($_POST['selected_date'])-24*60*60));
776 sqlStatement("UPDATE openemr_postcalendar_events SET " .
778 " WHERE pc_eid = ?", array($selected_date,$eid) );
782 // fully delete the event from the database
783 sqlStatement("DELETE FROM openemr_postcalendar_events WHERE pc_eid = ?", array($eid) );
788 if ($_POST['form_action'] != "") {
789 // Close this window and refresh the calendar (or the patient_tracker) display.
790 echo "<html>\n<body>\n<script language='JavaScript'>\n";
791 if ($info_msg) echo " alert('" . addslashes($info_msg) . "');\n";
792 echo " if (opener && !opener.closed && opener.refreshme) {\n " .
793 " opener.refreshme();\n " . // This is for standard calendar page refresh
795 " if(window.opener.pattrk){" .
796 " window.opener.pattrk.submit()\n " . // This is for patient flow board page refresh}
798 echo " window.close();\n";
799 echo "</script>\n</body>\n</html>\n";
803 //*********************************
804 // If we get this far then we are displaying the form.
805 //*********************************
807 /*********************************************************************
808 This has been migrate to the administration->lists
811 '*' => xl('* Reminder done'),
812 '+' => xl('+ Chart pulled'),
813 'x' => xl('x Cancelled'), // added Apr 2008 by JRM
814 '?' => xl('? No show'),
815 '@' => xl('@ Arrived'),
816 '~' => xl('~ Arrived late'),
817 '!' => xl('! Left w/o visit'),
818 '#' => xl('# Ins/fin issue'),
819 '<' => xl('< In exam room'),
820 '>' => xl('> Checked out'),
821 '$' => xl('$ Coding done'),
822 '%' => xl('% Cancelled < 24h ')
824 *********************************************************************/
826 $repeats = 0; // if the event repeats
830 if ($_REQUEST['patientid']) $patientid = $_REQUEST['patientid'];
832 $patienttitle = Array();
838 if ($_REQUEST['groupid']) $groupid = $_REQUEST['groupid'];
840 $group_statuses = getGroupStatuses();
843 // If we are editing an existing event, then get its data.
845 // $row = sqlQuery("SELECT * FROM openemr_postcalendar_events WHERE pc_eid = $eid");
847 $row = sqlQuery("SELECT e.*, u.fname, u.mname, u.lname " .
848 "FROM openemr_postcalendar_events AS e " .
849 "LEFT OUTER JOIN users AS u ON u.id = e.pc_informant " .
850 "WHERE pc_eid = ?", array($eid) );
851 $informant = $row['fname'] . ' ' . $row['mname'] . ' ' . $row['lname'];
853 // instead of using the event's starting date, keep what has been provided
854 // via the GET array, see the top of this file
855 if (empty($_GET['date'])) $date = $row['pc_eventDate'];
856 $eventstartdate = $row['pc_eventDate']; // for repeating event stuff - JRM Oct-08
857 $userid = $row['pc_aid'];
858 $patientid = $row['pc_pid'];
859 $groupid = $row['pc_gid'];
860 $starttimeh = substr($row['pc_startTime'], 0, 2) +
0;
861 $starttimem = substr($row['pc_startTime'], 3, 2);
862 $repeats = $row['pc_recurrtype'];
863 $multiple_value = $row['pc_multiple'];
865 // parse out the repeating data, if any
866 $rspecs = unserialize($row['pc_recurrspec']); // extract recurring data
867 $repeattype = $rspecs['event_repeat_freq_type'];
868 $repeatfreq = $rspecs['event_repeat_freq'];
869 $repeatexdate = $rspecs['exdate']; // repeating date exceptions
871 // Adjustments for repeat type 2, a particular weekday of the month.
873 $repeatfreq = $rspecs['event_repeat_on_freq'];
874 if ($rspecs['event_repeat_on_num'] < 5) {
881 $recurrence_end_date = ($row['pc_endDate'] && $row['pc_endDate'] != '0000-00-00') ?
$row['pc_endDate'] : NULL;
882 $pcroom = $row['pc_room'];
883 $hometext = $row['pc_hometext'];
884 if (substr($hometext, 0, 6) == ':text:') $hometext = substr($hometext, 6);
888 $eventstartdate = $date; // for repeating event stuff - JRM Oct-08
890 //-------------------------------------
892 //Set default facility for a new event based on the given 'userid'
894 /*************************************************************
895 $pref_facility = sqlFetchArray(sqlStatement("SELECT facility_id, facility FROM users WHERE id = $userid"));
896 *************************************************************/
897 if ($_SESSION['pc_facility']) {
898 $pref_facility = sqlFetchArray(sqlStatement("
899 SELECT f.id as facility_id,
904 array($_SESSION['pc_facility'])
907 $pref_facility = sqlFetchArray(sqlStatement("
908 SELECT u.facility_id,
911 LEFT JOIN facility f on (u.facility_id = f.id)
913 ", array($userid) ));
915 /************************************************************/
916 $e2f = $pref_facility['facility_id'];
917 $e2f_name = $pref_facility['facility'];
919 //END of CHEMED -----------------------
922 // If we have a patient ID, get the name and phone numbers to display.
924 $prow = sqlQuery("SELECT lname, fname, phone_home, phone_biz, DOB " .
925 "FROM patient_data WHERE pid = ?", array($patientid) );
926 $patientname = $prow['lname'] . ", " . $prow['fname'];
927 if ($prow['phone_home']) $patienttitle['phone_home'] = xl("Home Phone").": " . $prow['phone_home'];
928 if ($prow['phone_biz']) $patienttitle['phone_biz'] = xl("Work Phone").": " . $prow['phone_biz'];
931 // If we have a group id, get group data
933 $group_data = getGroup($groupid);
934 $groupname = $group_data['group_name'];
935 $group_end_date = $group_data['group_end_date'];
936 if(!$recurrence_end_date && $group_end_date && $group_end_date != '0000-00-00'){
937 $recurrence_end_date = $group_end_date;// If there is no recurr end date get group's end date as default (only if group has an end date)
941 // Get the providers list.
942 $ures = sqlStatement("SELECT id, username, fname, lname FROM users WHERE " .
943 "authorized != 0 AND active = 1 ORDER BY lname, fname");
945 // Get event categories.
946 $cres = sqlStatement("SELECT pc_catid, pc_catname, pc_recurrtype, pc_duration, pc_end_all_day " .
947 "FROM openemr_postcalendar_categories where pc_active = 1 ORDER BY pc_seq");
949 // Fix up the time format for AM/PM.
951 if ($starttimeh >= 12) { // p.m. starts at noon and not 12:01
953 if ($starttimeh > 12) $starttimeh -= 12;
959 <?php
html_header_show(); ?
>
960 <title
><?php
echo $eid ?
xlt('Edit') : xlt('Add New') ?
> <?php
echo xlt('Event');?
></title
>
961 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
962 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
965 td
{ font
-size
:0.8em
; }
968 <script type
="text/javascript" src
="../../../library/topdialog.js?v=<?php echo $v_js_includes; ?>"></script
>
969 <script type
="text/javascript" src
="../../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
970 <script type
="text/javascript" src
="../../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script
>
971 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script
>
973 <script language
="JavaScript">
975 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
977 var durations
= new Array();
978 // var rectypes = new Array();
980 // Read the event categories, generate their options list, and get
981 // the default event duration from them if this is a new event.
983 if($_GET['prov']==true){
986 if($_GET['group'] == true){
989 $cres = sqlStatement("SELECT pc_catid, pc_cattype, pc_catname, " .
990 "pc_recurrtype, pc_duration, pc_end_all_day " .
991 "FROM openemr_postcalendar_categories where pc_active = 1 ORDER BY pc_seq");
993 $prefcat_options = " <option value='0'>-- " . xlt("None") . " --</option>\n";
996 $thisduration = $row['pc_alldayevent'] ?
1440 : round($row['pc_duration'] / 60);
998 while ($crow = sqlFetchArray($cres)) {
999 $duration = round($crow['pc_duration'] / 60);
1000 if ($crow['pc_end_all_day']) $duration = 1440;
1002 // This section is to build the list of preferred categories:
1004 $prefcat_options .= " <option value='" . attr($crow['pc_catid']) . "'";
1006 if ($crow['pc_catid'] == $row['pc_prefcatid']) $prefcat_options .= " selected";
1008 $prefcat_options .= ">" . text(xl_appt_category($crow['pc_catname'])) . "</option>\n";
1011 if ($crow['pc_cattype'] != $cattype) continue;
1013 echo " durations[" . attr($crow['pc_catid']) . "] = " . attr($duration) . "\n";
1014 // echo " rectypes[" . $crow['pc_catid'] . "] = " . $crow['pc_recurrtype'] . "\n";
1015 $catoptions .= " <option value='" . attr($crow['pc_catid']) . "'";
1017 if ($crow['pc_catid'] == $row['pc_catid']) $catoptions .= " selected";
1019 if ($crow['pc_catid'] == $default_catid) {
1020 $catoptions .= " selected";
1021 $thisduration = $duration;
1024 $catoptions .= ">" . text(xl_appt_category($crow['pc_catname'])) . "</option>\n";
1028 <?php
require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
1030 // This is for callback by the find-patient popup.
1031 function setpatient(pid
, lname
, fname
, dob
) {
1032 var f
= document
.forms
[0];
1033 f
.form_patient
.value
= lname +
', ' + fname
;
1034 f
.form_pid
.value
= pid
;
1035 dobstyle
= (dob
== '' || dob
.substr(5, 10) == '00-00') ?
'' : 'none';
1036 document
.getElementById('dob_row').style
.display
= dobstyle
;
1039 // This invokes the find-patient popup.
1040 function sel_patient() {
1041 dlgopen('find_patient_popup.php', '_blank', 500, 400);
1044 // This is for callback by the find-group popup.
1045 function setgroup(gid
, name
, end_date
) {
1046 var f
= document
.forms
[0];
1047 f
.form_group
.value
= name
;
1048 f
.form_gid
.value
= gid
;
1049 if(f
.form_enddate
.value
== ""){
1050 f
.form_enddate
.value
= end_date
;
1055 // This invokes the find-group popup.
1056 function sel_group() {
1057 top
.restoreSession();
1058 dlgopen('find_group_popup.php', '_blank', 500, 400);
1061 // Do whatever is needed when a new event category is selected.
1062 // For now this means changing the event title and duration.
1063 function set_display() {
1064 var f
= document
.forms
[0];
1065 var s
= f
.form_category
;
1066 if (s
.selectedIndex
>= 0) {
1067 var catid
= s
.options
[s
.selectedIndex
].value
;
1068 var style_apptstatus
= document
.getElementById('title_apptstatus').style
;
1069 var style_prefcat
= document
.getElementById('title_prefcat').style
;
1070 if (catid
== '2') { // In Office
1071 style_apptstatus
.display
= 'none';
1072 style_prefcat
.display
= '';
1073 f
.form_apptstatus
.style
.display
= 'none';
1074 f
.form_prefcat
.style
.display
= '';
1076 style_prefcat
.display
= 'none';
1077 style_apptstatus
.display
= '';
1078 f
.form_prefcat
.style
.display
= 'none';
1079 f
.form_apptstatus
.style
.display
= '';
1084 // Do whatever is needed when a new event category is selected.
1085 // For now this means changing the event title and duration.
1086 function set_category() {
1087 var f
= document
.forms
[0];
1088 var s
= f
.form_category
;
1089 if (s
.selectedIndex
>= 0) {
1090 var catid
= s
.options
[s
.selectedIndex
].value
;
1091 f
.form_title
.value
= s
.options
[s
.selectedIndex
].text
;
1092 f
.form_duration
.value
= durations
[catid
];
1097 // Modify some visual attributes when the all-day or timed-event
1098 // radio buttons are clicked.
1099 function set_allday() {
1100 var f
= document
.forms
[0];
1101 var color1
= '#777777';
1102 var color2
= '#777777';
1103 var disabled2
= true;
1104 if (document
.getElementById('rballday1').checked
) {
1107 if (document
.getElementById('rballday2').checked
) {
1111 document
.getElementById('tdallday1').style
.color
= color1
;
1112 document
.getElementById('tdallday2').style
.color
= color2
;
1113 document
.getElementById('tdallday3').style
.color
= color2
;
1114 document
.getElementById('tdallday4').style
.color
= color2
;
1115 document
.getElementById('tdallday5').style
.color
= color2
;
1116 f
.form_hour
.disabled
= disabled2
;
1117 f
.form_minute
.disabled
= disabled2
;
1118 f
.form_ampm
.disabled
= disabled2
;
1119 f
.form_duration
.disabled
= disabled2
;
1122 // Modify some visual attributes when the Repeat checkbox is clicked.
1123 function set_repeat() {
1124 var f
= document
.forms
[0];
1125 var isdisabled
= true;
1126 var mycolor
= '#777777';
1127 var myvisibility
= 'hidden';
1128 if (f
.form_repeat
.checked
) {
1129 f
.days_every_week
.checked
= false;
1130 document
.getElementById("days_label").style
.color
= mycolor
;
1131 var days
= document
.getElementById("days").getElementsByTagName('input');
1132 var labels
= document
.getElementById("days").getElementsByTagName('label');
1133 for(var i
=0; i
< days
.length
; i++
){
1134 days
[i
].disabled
= isdisabled
;
1135 labels
[i
].style
.color
= mycolor
;
1138 mycolor
= '#000000';
1139 myvisibility
= 'visible';
1141 f
.form_repeat_type
.disabled
= isdisabled
;
1142 f
.form_repeat_freq
.disabled
= isdisabled
;
1143 f
.form_enddate
.disabled
= isdisabled
;
1144 document
.getElementById('tdrepeat1').style
.color
= mycolor
;
1145 document
.getElementById('tdrepeat2').style
.color
= mycolor
;
1148 // Event when days_every_week is checked.
1149 function set_days_every_week() {
1150 var f
= document
.forms
[0];
1151 if (f
.days_every_week
.checked
) {
1152 //disable regular repeat
1153 f
.form_repeat
.checked
= false;
1154 f
.form_repeat_type
.disabled
= true;
1155 f
.form_repeat_freq
.disabled
= true;
1156 document
.getElementById('tdrepeat1').style
.color
= '#777777';
1158 //enable end_date setting
1159 document
.getElementById('tdrepeat2').style
.color
= '#000000';
1160 f
.form_enddate
.disabled
= false;
1162 var isdisabled
= false;
1163 var mycolor
= '#000000';
1164 var myvisibility
= 'visible';
1167 var isdisabled
= true;
1168 var mycolor
= '#777777';
1169 var myvisibility
= 'hidden';
1171 document
.getElementById("days_label").style
.color
= mycolor
;
1172 var days
= document
.getElementById("days").getElementsByTagName('input');
1173 var labels
= document
.getElementById("days").getElementsByTagName('label');
1174 for(var i
=0; i
< days
.length
; i++
){
1175 days
[i
].disabled
= isdisabled
;
1176 labels
[i
].style
.color
= mycolor
;
1179 //If no repetition is checked, disable end_date setting.
1180 if(!f
.days_every_week
.checked
&& !f
.form_repeat
.checked
){
1181 //disable end_date setting
1182 document
.getElementById('tdrepeat2').style
.color
= mycolor
;
1183 f
.form_enddate
.disabled
= isdisabled
;
1189 // Constants used by dateChanged() function.
1190 var occurNames
= new Array(
1191 '<?php echo xls("1st"); ?>',
1192 '<?php echo xls("2nd"); ?>',
1193 '<?php echo xls("3rd"); ?>',
1194 '<?php echo xls("4th"); ?>'
1197 var weekDays
= new Array(
1198 '<?php echo xls("Sunday"); ?>',
1199 '<?php echo xls("Monday"); ?>',
1200 '<?php echo xls("Tuesday"); ?>',
1201 '<?php echo xls("Wednesday"); ?>',
1202 '<?php echo xls("Thursday"); ?>',
1203 '<?php echo xls("Friday"); ?>',
1204 '<?php echo xls("Saturday"); ?>'
1207 // Monitor start date changes to adjust repeat type options.
1208 function dateChanged() {
1209 var f
= document
.forms
[0];
1210 if (!f
.form_date
.value
) return;
1211 var d
= new Date(f
.form_date
.value
);
1212 var downame
= weekDays
[d
.getUTCDay()];
1214 var occur
= Math
.floor((d
.getUTCDate() - 1) / 7);
1215 if (occur
< 4) { // 5th is not allowed
1216 nthtext
= occurNames
[occur
] +
' ' + downame
;
1219 var tmp
= new Date(d
.getUTCFullYear(), d
.getUTCMonth() +
1, 0);
1220 if (tmp
.getDate() - d
.getUTCDate() < 7) { // Modified by epsdky 2016 (details in commit)
1221 // This is a last occurrence of the specified weekday in the month,
1222 // so permit that as an option.
1223 lasttext
= '<?php echo xls("Last"); ?> ' + downame
;
1225 var si
= f
.form_repeat_type
.selectedIndex
;
1226 var opts
= f
.form_repeat_type
.options
;
1227 opts
.length
= 5; // remove any nth and Last entries
1228 if (nthtext
) opts
[opts
.length
] = new Option(nthtext
, '5');
1229 if (lasttext
) opts
[opts
.length
] = new Option(lasttext
, '6');
1230 if (si
< opts
.length
) f
.form_repeat_type
.selectedIndex
= si
;
1231 else f
.form_repeat_type
.selectedIndex
= 5; // Added by epsdky 2016 (details in commit)
1234 // This is for callback by the find-available popup.
1235 function setappt(year
,mon
,mday
,hours
,minutes
) {
1236 var f
= document
.forms
[0];
1237 f
.form_date
.value
= '' + year +
'-' +
1238 ('' +
(mon +
100)).substring(1) +
'-' +
1239 ('' +
(mday +
100)).substring(1);
1240 f
.form_ampm
.selectedIndex
= (hours
>= 12) ?
1 : 0;
1241 f
.form_hour
.value
= (hours
> 12) ? hours
- 12 : hours
;
1242 f
.form_minute
.value
= ('' +
(minutes +
100)).substring(1);
1245 // Invoke the find-available popup.
1246 function find_available(extra
) {
1247 top
.restoreSession();
1248 // (CHEMED) Conditional value selection, because there is no <select> element
1249 // when making an appointment for a specific provider
1250 var s
= document
.forms
[0].form_provider
;
1251 var f
= document
.forms
[0].facility
;
1252 <?php
if ($userid != 0) { ?
>
1253 s
= document
.forms
[0].form_provider
.value
;
1254 f
= document
.forms
[0].facility
.value
;
1256 s
= document
.forms
[0].form_provider
.options
[s
.selectedIndex
].value
;
1257 f
= document
.forms
[0].facility
.options
[f
.selectedIndex
].value
;
1259 var c
= document
.forms
[0].form_category
;
1260 var formDate
= document
.forms
[0].form_date
;
1261 dlgopen('<?php echo $GLOBALS['web_root
']; ?>/interface/main/calendar/find_appt_popup.php' +
1262 '?providerid=' + s +
1263 '&catid=' + c
.options
[c
.selectedIndex
].value +
1265 '&startdate=' + formDate
.value +
1266 '&evdur=' + document
.forms
[0].form_duration
.value +
1267 '&eid=<?php echo 0 + $eid; ?>' +
1269 '_blank', 500, 400);
1276 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8" />
1280 <body
class="body_top main-calendar-add_edit_event" onunload
='imclosing()'>
1282 <form method
='post' name
='theform' id
='theform' action
='add_edit_event.php?eid=<?php echo attr($eid) ?>' />
1283 <!-- ViSolve
: Requirement
- Redirect to Create
New Patient Page
-->
1284 <input type
='hidden' size
='2' name
='resname' value
='empty' />
1286 if ($_POST["resname"]=="noresult"){
1288 <script language="Javascript">
1289 // refresh and redirect the parent window
1290 if (!opener.closed && opener.refreshme) opener.refreshme();
1291 top.restoreSession();
1292 opener.document.location="../../new/new.php";
1297 $classprov='current';
1300 <!-- ViSolve
: Requirement
- Redirect to Create
New Patient Page
-->
1301 <input type
="hidden" name
="form_action" id
="form_action" value
="">
1302 <input type
="hidden" name
="recurr_affect" id
="recurr_affect" value
="">
1303 <!-- used
for recurring events
-->
1304 <input type
="hidden" name
="selected_date" id
="selected_date" value
="<?php echo attr($date); ?>">
1305 <input type
="hidden" name
="event_start_date" id
="event_start_date" value
="<?php echo attr($eventstartdate); ?>">
1306 <!-- Following added by epsdky
2016 (details in commit
) -->
1307 <input type
="hidden" name
="old_repeats" id
="old_repeats" value
="<?php echo attr($repeats); ?>">
1308 <input type
="hidden" name
="rt2_flag2" id
="rt2_flag2" value
="<?php echo attr(isset($rspecs['rt2_pf_flag']) ? $rspecs['rt2_pf_flag'] : '0'); ?>">
1309 <!-- End of addition by epsdky
-->
1316 if($_GET['prov']==true){
1317 $provider_class="class='current'";
1319 elseif($_GET['group']==true){
1320 $group_class="class='current'";
1323 $normal="class='current'";
1326 <tr
><th
><ul
class="tabNav">
1328 $eid=$_REQUEST["eid"];
1329 $startm=$_REQUEST["startampm"];
1330 $starth=$_REQUEST["starttimeh"];
1331 $uid=$_REQUEST["userid"];
1332 $starttm=$_REQUEST["starttimem"];
1333 $dt=$_REQUEST["date"];
1334 $cid=$_REQUEST["catid"];
1336 <li
<?php
echo $normal;?
>>
1337 <a href
='add_edit_event.php?startampm=<?php echo attr($startm);?>&starttimeh=<?php echo attr($starth);?>&userid=<?php echo attr($uid);?>&starttimem=<?php echo attr($starttm);?>&date=<?php echo attr($dt);?>&catid=<?php echo attr($cid);?>'>
1338 <?php
echo xlt('Patient');?
></a
>
1340 <li
<?php
echo $provider_class;?
>>
1341 <a href
='add_edit_event.php?prov=true&startampm=<?php echo attr($startm);?>&starttimeh=<?php echo attr($starth);?>&userid=<?php echo attr($uid);?>&starttimem=<?php echo attr($starttm);?>&date=<?php echo attr($dt);?>&catid=<?php echo attr($cid);?>'>
1342 <?php
echo xlt('Provider');?
></a
>
1344 <?php
if($GLOBALS['enable_group_therapy']) :?
>
1345 <li
<?php
echo $group_class ;?
>>
1346 <a href
='add_edit_event.php?group=true&startampm=<?php echo attr($startm);?>&starttimeh=<?php echo attr($starth);?>&userid=<?php echo attr($uid);?>&starttimem=<?php echo attr($starttm);?>&date=<?php echo attr($dt);?>&catid=<?php echo attr($cid);?>'>
1347 <?php
echo xlt('Group');?
></a
>
1352 <tr
><td colspan
='10'>
1353 <table border
='0' width
='100%' bgcolor
='#DDDDDD'>
1355 <td width
='1%' nowrap
>
1356 <b
><?php
echo xlt('Category'); ?
>:</b
>
1359 <select name
='form_category' onchange
='set_category()' style
='width:100%'>
1360 <?php
echo $catoptions ?
>
1363 <td width
='1%' nowrap
>
1365 <input type
='radio' name
='form_allday' onclick
='set_allday()' value
='1' id
='rballday1'
1366 <?php
if ($thisduration == 1440) echo "checked " ?
>/>
1368 <td colspan
='2' nowrap id
='tdallday1'>
1369 <?php
echo xlt('All day event'); ?
>
1374 <b
><?php
echo xlt('Date'); ?
>:</b
>
1377 <input type
='text' size
='10' class='datepicker' name
='form_date' id
='form_date'
1378 value
='<?php echo attr($date) ?>'
1379 title
='<?php echo xla('yyyy
-mm
-dd event date
or starting date
'); ?>'
1380 onchange
='dateChanged()' />
1384 <input type
='radio' name
='form_allday' onclick
='set_allday()' value
='0' id
='rballday2' <?php
if ($thisduration != 1440) echo "checked " ?
>/>
1386 <td width
='1%' nowrap id
='tdallday2'>
1387 <?php
echo xlt('Time'); ?
>
1389 <td width
='1%' nowrap id
='tdallday3'>
1391 <input type
='text' size
='2' name
='form_hour' value
='<?php echo attr($starttimeh) ?>'
1392 title
='<?php echo xla('Event start time
'); ?>' /> :
1393 <input type
='text' size
='2' name
='form_minute' value
='<?php echo attr($starttimem) ?>'
1394 title
='<?php echo xla('Event start time
'); ?>' /> 
;
1396 <select name
='form_ampm' title
='<?php echo xla("Note: 12:00 noon is PM, not AM"); ?>'>
1397 <option value
='1'><?php
echo xlt('AM'); ?
></option
>
1398 <option value
='2'<?php
if ($startampm == '2') echo " selected" ?
>><?php
echo xlt('PM'); ?
></option
>
1404 <b
><?php
echo xlt('Title'); ?
>:</b
>
1407 <input type
='text' size
='10' name
='form_title' value
='<?php echo attr($row['pc_title
']); ?>'
1409 title
='<?php echo xla('Event title
'); ?>' />
1414 <td nowrap id
='tdallday4'><?php
echo xlt('duration'); ?
>
1416 <td nowrap id
='tdallday5'>
1417 <input type
='text' size
='4' name
='form_duration' value
='<?php echo attr($thisduration) ?>' title
='<?php echo xla('Event duration in minutes
'); ?>' />
1418 <?php
echo xlt('minutes'); ?
>
1423 <td nowrap
><b
><?php
echo xlt('Facility'); ?
>:</b
></td
>
1425 <select name
="facility" id
="facility" >
1428 // ===========================
1429 // EVENTS TO FACILITIES
1430 //(CHEMED) added service_location WHERE clause
1431 // get the facilities
1432 /***************************************************************
1433 $qsql = sqlStatement("SELECT * FROM facility WHERE service_location != 0");
1434 ***************************************************************/
1435 $facils = getUserFacilities($_SESSION['authId']);
1436 $qsql = sqlStatement("SELECT id, name FROM facility WHERE service_location != 0");
1437 /**************************************************************/
1438 while ($facrow = sqlFetchArray($qsql)) {
1439 /*************************************************************
1440 $selected = ( $facrow['id'] == $e2f ) ? 'selected="selected"' : '' ;
1441 echo "<option value={$facrow['id']} $selected>{$facrow['name']}</option>";
1442 *************************************************************/
1443 if ($_SESSION['authorizedUser'] ||
in_array($facrow, $facils)) {
1444 $selected = ( $facrow['id'] == $e2f ) ?
'selected="selected"' : '' ;
1445 echo "<option value='" . attr($facrow['id']) . "' $selected>" . text($facrow['name']) . "</option>";
1448 $selected = ( $facrow['id'] == $e2f ) ?
'selected="selected"' : '' ;
1449 echo "<option value='" . attr($facrow['id']) . "' $selected>" . text($facrow['name']) . "</option>";
1451 /************************************************************/
1454 // ===========================
1457 //END (CHEMED) IF ?>
1463 <b
><?php
echo xlt('Billing Facility'); ?
>:</b
>
1467 billing_facility('billing_facility',$row['pc_billing_location']);
1472 if($_GET['prov']!=true && $_GET['group']!=true){
1474 <tr id
="patient_details">
1476 <b
><?php
echo xlt('Patient'); ?
>:</b
>
1479 <input type
='text' size
='10' name
='form_patient' id
="form_patient" style
='width:100%;cursor:pointer;cursor:hand' placeholder
='<?php echo xla('Click to select
');?>' value
='<?php echo is_null($patientname) ? '' : attr($patientname); ?>' onclick
='sel_patient()' title
='<?php echo xla('Click to select patient
'); ?>' readonly
/>
1480 <input type
='hidden' name
='form_pid' value
='<?php echo attr($patientid) ?>' />
1482 <td colspan
='3' nowrap style
='font-size:8pt'>
1483 <span
class="infobox">
1484 <?php
foreach($patienttitle as $value){
1486 echo text(trim($value));
1489 if(count($patienttitle) > 1){
1501 if($_GET['group']==true){
1503 <tr id
="group_details">
1505 <b
><?php
echo xlt('Group'); ?
>:</b
>
1508 <input type
='text' size
='10' name
='form_group' id
="form_group" style
='width:100%;cursor:pointer;cursor:hand' placeholder
='<?php echo xla('Click to select
');?>' value
='<?php echo is_null($groupname) ? '' : attr($groupname); ?>' onclick
='sel_group()' title
='<?php echo xla('Click to select group
'); ?>' readonly
/>
1509 <input type
='hidden' name
='form_gid' value
='<?php echo attr($groupid) ?>' />
1511 <td colspan
='3' nowrap style
='font-size:8pt'>
1512 <span
class="infobox">
1513 <?php
foreach($patienttitle as $value){
1518 if(count($patienttitle) > 1){
1531 <b
><?php
if($_GET['group']==true) echo xlt('Coordinating Counselors'); else echo xlt('Provider'); ?
>:</b
>
1537 // =======================================
1539 // =======================================
1540 if ($GLOBALS['select_multi_providers']) {
1542 // there are two posible situations: edit and new record
1543 $providers_array = array();
1544 // this is executed only on edit ($eid)
1546 if ( $multiple_value ) {
1547 // find all the providers around multiple key
1548 $qall = sqlStatement ("SELECT pc_aid AS providers FROM openemr_postcalendar_events WHERE pc_multiple = ?", array($multiple_value) );
1549 while ($r = sqlFetchArray($qall)) {
1550 $providers_array[] = $r['providers'];
1553 $qall = sqlStatement ("SELECT pc_aid AS providers FROM openemr_postcalendar_events WHERE pc_eid = ?", array($eid) );
1554 $providers_array = sqlFetchArray($qall);
1558 // build the selection tool
1559 echo "<select name='form_provider[]' style='width:100%' multiple='multiple' size='5' >";
1561 while ($urow = sqlFetchArray($ures)) {
1562 echo " <option value='" . attr($urow['id']) . "'";
1565 if ( in_array($urow['id'], $providers_array) ||
($urow['id'] == $userid) ) echo " selected";
1568 echo ">" . text($urow['lname']);
1569 if ($urow['fname']) echo ", " . text($urow['fname']);
1575 // =======================================
1577 // =======================================
1581 // get provider from existing event
1582 $qprov = sqlStatement ("SELECT pc_aid FROM openemr_postcalendar_events WHERE pc_eid = ?", array($eid) );
1583 $provider = sqlFetchArray($qprov);
1584 $defaultProvider = $provider['pc_aid'];
1587 // this is a new event so smartly choose a default provider
1588 /*****************************************************************
1590 // Provider already given to us as a GET parameter.
1591 $defaultProvider = $userid;
1594 // default to the currently logged-in user
1595 $defaultProvider = $_SESSION['authUserID'];
1596 // or, if we have chosen a provider in the calendar, default to them
1597 // choose the first one if multiple have been selected
1598 if (count($_SESSION['pc_username']) >= 1) {
1599 // get the numeric ID of the first provider in the array
1600 $pc_username = $_SESSION['pc_username'];
1601 $firstProvider = sqlFetchArray(sqlStatement("select id from users where username='".$pc_username[0]."'"));
1602 $defaultProvider = $firstProvider['id'];
1607 echo "<select name='form_provider' style='width:100%' />";
1608 while ($urow = sqlFetchArray($ures)) {
1609 echo " <option value='" . $urow['id'] . "'";
1610 if ($urow['id'] == $defaultProvider) echo " selected";
1611 echo ">" . $urow['lname'];
1612 if ($urow['fname']) echo ", " . $urow['fname'];
1616 *****************************************************************/
1617 // default to the currently logged-in user
1618 $defaultProvider = $_SESSION['authUserID'];
1619 // or, if we have chosen a provider in the calendar, default to them
1620 // choose the first one if multiple have been selected
1621 if (count($_SESSION['pc_username']) >= 1) {
1622 // get the numeric ID of the first provider in the array
1623 $pc_username = $_SESSION['pc_username'];
1624 $firstProvider = sqlFetchArray(sqlStatement("select id from users where username=?", array($pc_username[0]) ));
1625 $defaultProvider = $firstProvider['id'];
1627 // if we clicked on a provider's schedule to add the event, use THAT.
1628 if ($userid) $defaultProvider = $userid;
1630 echo "<select name='form_provider' style='width:100%' />";
1631 while ($urow = sqlFetchArray($ures)) {
1632 echo " <option value='" . attr($urow['id']) . "'";
1633 if ($urow['id'] == $defaultProvider) echo " selected";
1634 echo ">" . text($urow['lname']);
1635 if ($urow['fname']) echo ", " . text($urow['fname']);
1639 /****************************************************************/
1648 //Check if repeat is using the new 'days every week' mechanism.
1649 function isDaysEveryWeek($repeat){
1658 //Check if using the regular repeat mechanism.
1659 function isRegularRepeat($repeat){
1660 if($repeat == 1 ||
$repeat == 2){
1670 If the appointment was set with the regular (old) repeat mechanism (using 'every', 'every 2', etc.), then will be
1671 checked when editing and will select the proper recurrence pattern. If using the new repeat mechanism, then only that box (and the proper set
1672 days) will be checked. That's why I had to add the functions 'isRegularRepeat' and 'isDaysEveryWeek', to check which
1673 repeating mechanism is being used, and load settings accordingly.
1676 <input type
='checkbox' name
='form_repeat' id
="form_repeat" onclick
='set_repeat(this)' value
='1'<?php
if (isRegularRepeat($repeats)) echo " checked" ?
>/>
1677 <input type
='hidden' name
='form_repeat_exdate' id
='form_repeat_exdate' value
='<?php echo attr($repeatexdate); ?>' /> <!-- dates excluded from the repeat
-->
1679 <td nowrap id
='tdrepeat1'><?php
echo xlt('Repeats'); ?
>
1683 <select name
='form_repeat_freq' title
='<?php echo xla('Every
, every other
, every
3rd
, etc
.'); ?>'>
1685 foreach (array(1 => xl('every'), 2 => xl('2nd'), 3 => xl('3rd'), 4 => xl('4th'), 5 => xl('5th'), 6 => xl('6th'))
1688 echo " <option value='" . attr($key) . "'";
1689 if ($key == $repeatfreq && isRegularRepeat($repeats)) echo " selected";
1690 echo ">" . text($value) . "</option>\n";
1695 <select name
='form_repeat_type'>
1697 // See common.api.php for these. Options 5 and 6 will be dynamically filled in
1698 // when the start date is set.
1699 foreach (array(0 => xl('day') , 4 => xl('workday'), 1 => xl('week'), 2 => xl('month'), 3 => xl('year'),
1700 5 => '?', 6 => '?') as $key => $value)
1702 echo " <option value='" . attr($key) . "'";
1703 if ($key == $repeattype && isRegularRepeat($repeats)) echo " selected";
1704 echo ">" . text($value) . "</option>\n";
1713 #days_every_week_row input[type="checkbox"]{float:right;}
1714 #days_every_week_row div{display: inline-block; text-align: center; width: 12%;}
1715 #days_every_week_row div input{width: 100%;}
1718 <tr id
="days_every_week_row">
1721 <td
><input type
='checkbox' id
='days_every_week' name
='days_every_week' onclick
='set_days_every_week()' <?php
if (isDaysEveryWeek($repeats)) echo " checked" ?
>/></td
>
1722 <td id
="days_label"><?php
echo xlt('Days Of Week') . ": "; ?
></td
>
1725 foreach (array(1 => xl('Su{{Sunday}}') , 2 => xl('Mo{{Monday}}'), 3 => xl('Tu{{Tuesday}}'), 4 => xl('We{{Wednesday}}'),
1726 5 => xl('Th{{Thursday}}'), 6 => xl('Fr{{Friday}}'), 7 => xl('Sa{{Saturday}}')) as $key => $value)
1728 echo " <div><input type='checkbox' name='day_". attr($key) ."'";
1729 //Checks appropriate days according to days in recurrence string.
1730 if (in_array($key, explode(',',$repeatfreq)) && isDaysEveryWeek($repeats)) echo " checked";
1731 echo " /><label>" . text($value) . "</label></div>\n";
1741 <span id
='title_apptstatus'><b
><?php
echo xlt('Status'); ?
>:</b
></span
>
1742 <span id
='title_prefcat' style
='display:none'><b
><?php
echo xlt('Pref Cat'); ?
>:</b
></span
>
1747 if($_GET['group']!=true) {
1748 generate_form_field(array('data_type' => 1, 'field_id' => 'apptstatus', 'list_id' => 'apptstat', 'empty_title' => 'SKIP'), $row['pc_apptstatus']);
1751 generate_form_field(array('data_type' => 1, 'field_id' => 'apptstatus', 'list_id' => 'groupstat', 'empty_title' => 'SKIP'), $row['pc_apptstatus']);
1756 The following
list will be invisible unless this is an In Office
1757 event
, in which
case form_apptstatus (above
) is to be invisible
.
1759 <select name
='form_prefcat' style
='width:100%;display:none' title
='<?php echo xla('Preferred Event Category
');?>'>
1760 <?php
echo $prefcat_options ?
>
1767 <td nowrap id
='tdrepeat2'><?php
echo xlt('until'); ?
>
1770 <input type
='text' size
='10' class='datepicker' name
='form_enddate' id
='form_enddate' value
='<?php echo attr($recurrence_end_date) ?>' title
='<?php echo xla('yyyy
-mm
-dd last date of this event
');?>' />
1772 if ($repeatexdate != "") {
1773 $tmptitle = "The following dates are excluded from the repeating series";
1774 if ($multiple_value) { $tmptitle .= " for one or more providers:\n"; }
1775 else { $tmptitle .= "\n"; }
1776 $max = $GLOBALS['number_of_ex_appts_to_show'];
1778 $exdates = explode(",", $repeatexdate);
1779 if(!empty($exdates)){
1780 $exdates=array_slice($exdates,0,$max,true);
1782 foreach ($exdates as $exdate) {
1783 $tmptitle .= date("d M Y", strtotime($exdate))."\n";
1785 echo "<a href='#' title='" . attr($tmptitle) . "' alt='" . attr($tmptitle) . "'><img src='../../pic/warning.gif' title='" . attr($tmptitle) . "' alt='*!*' style='border:none;'/></a>";
1791 if($_GET['prov']!=true){
1795 <b
><?php
echo xlt('Room Number'); ?
>:</b
>
1797 <td colspan
='4' nowrap
>
1799 echo generate_select_list('form_room', 'patient_flow_board_rooms',$pcroom, xl('Room Number'));
1806 <b
><?php
echo xlt('Comments'); ?
>:</b
>
1808 <td colspan
='4' nowrap
>
1809 <input type
='text' size
='40' name
='form_comments' style
='width:100%' value
='<?php echo attr($hometext); ?>' title
='<?php echo xla('Optional information about this event
');?>' />
1815 // DOB is important for the clinic, so if it's missing give them a chance
1816 // to enter it right here. We must display or hide this row dynamically
1817 // in case the patient-select popup is used.
1818 $patient_dob = trim($prow['DOB']);
1819 $is_group = $groupname;
1820 $dobstyle = ($prow && (!$patient_dob ||
substr($patient_dob, 5) == '00-00') && !$is_group) ?
1823 <tr id
='dob_row' style
='display:<?php echo $dobstyle ?>'>
1824 <td colspan
='4' nowrap
>
1825 <b
><font color
='red'><?php
echo xlt('DOB is missing, please enter if possible'); ?
>:</font
></b
>
1828 <input type
='text' size
='10' class='datepicker' name
='form_dob' id
='form_dob' title
='<?php echo xla('yyyy
-mm
-dd date of birth
');?>' />
1833 <tr
class='text'><td colspan
='10' class="buttonbar">
1835 <input type
='button' name
='form_save' id
='form_save' value
='<?php echo xla('Save
');?>' />
1838 <?php
if (!($GLOBALS['select_multi_providers'])) { //multi providers appt is not supported by check slot avail window, so skip ?>
1839 <input type
='button' id
='find_available' value
='<?php echo xla('Find Available
');?>' />
1843 <input type
='button' name
='form_delete' id
='form_delete' value
='<?php echo xla('Delete
');?>'<?php
if (!$eid) echo " disabled" ?
> />
1845 <input type
='button' id
='cancel' value
='<?php echo xla('Cancel
');?>' />
1847 <input type
='button' name
='form_duplicate' id
='form_duplicate' value
='<?php echo xla('Create Duplicate
');?>' />
1848 </p
></td
></tr
></table
>
1849 <?php
if ($informant) echo "<p class='text'>" . xlt('Last update by') . " " .
1850 text($informant) . " " . xlt('on') . " " . text($row['pc_time']) . "</p>\n"; ?
>
1854 <div id
="recurr_popup" style
="visibility: hidden; position: absolute; top: 50px; left: 50px; width: 400px; border: 3px outset yellow; background-color: yellow; padding: 5px;">
1855 <?php
echo xlt('Apply the changes to the Current event only, to this and all Future occurrences, or to All occurrences?') ?
>
1857 <?php
if($GLOBALS['submit_changes_for_all_appts_at_once']) {?
>
1858 <input type
="button" name
="all_events" id
="all_events" value
=" <?php echo xla('All'); ?> ">
1860 <input type
="button" name
="future_events" id
="future_events" value
="<?php echo xla('Future'); ?>">
1861 <input type
="button" name
="current_event" id
="current_event" value
="<?php echo xla('Current'); ?>">
1862 <input type
="button" name
="recurr_cancel" id
="recurr_cancel" value
="<?php echo xla('Cancel'); ?>">
1867 <script language
='JavaScript'>
1868 <?php
if ($eid) { ?
>
1875 set_days_every_week();
1879 <script language
="javascript">
1880 // jQuery stuff to make the page a little easier to use
1882 $
(document
).ready(function(){
1883 $
("#form_save").click(function(e
) { validateform(e
,"save"); });
1884 $
("#form_duplicate").click(function(e
) { validateform(e
,"duplicate"); });
1885 $
("#find_available").click(function() { find_available(''); });
1886 $
("#form_delete").click(function() { deleteEvent(); });
1887 $
("#cancel").click(function() { window
.close(); });
1889 // buttons affecting the modification of a repeating event
1890 $
("#all_events").click(function() { $
("#recurr_affect").val("all"); EnableForm(); SubmitForm(); });
1891 $
("#future_events").click(function() { $
("#recurr_affect").val("future"); EnableForm(); SubmitForm(); });
1892 $
("#current_event").click(function() { $
("#recurr_affect").val("current"); EnableForm(); SubmitForm(); });
1893 $
("#recurr_cancel").click(function() { $
("#recurr_affect").val(""); EnableForm(); HideRecurrPopup(); });
1895 // Initialize repeat options.
1898 $
('.datepicker').datetimepicker({
1899 <?php
$datetimepicker_timepicker = false; ?
>
1900 <?php
$datetimepicker_showseconds = false; ?
>
1901 <?php
$datetimepicker_formatInput = false; ?
>
1902 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
1903 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
1908 function are_days_checked(){
1909 var days
= document
.getElementById("days").getElementsByTagName('input');
1911 for(var i
=0; i
< days
.length
; i++
){
1912 if(days
[i
].checked
){
1920 * validation on the form with new client side validation (using validate.js).
1921 * this enable to add new rules for this form in the pageValidation list.
1923 var collectvalidation
= <?php
echo($collectthis); ?
>;
1924 function validateform(event
,valu
){
1926 $
('#form_save').attr('disabled', true);
1928 //Make sure if days_every_week is checked that at least one weekday is checked.
1929 if($
('#days_every_week').is(':checked') && !are_days_checked()){
1930 alert('<?php echo xls("Must choose at least one day!"); ?>');
1931 $
('#form_save').attr('disabled', false);
1935 //add rule if choose repeating event
1936 if ($
('#form_repeat').is(':checked') || $
('#days_every_week').is(':checked')){
1937 collectvalidation
.form_enddate
= {
1940 earliest
: $
('#form_date').val(),
1941 message
: "An end date later than the start date is required for repeated events!"
1946 if(typeof (collectvalidation
) != 'undefined'){
1947 delete collectvalidation
.form_enddate
;
1953 if($GLOBALS['select_multi_providers']){
1955 //If multiple providers is enabled, create provider validation (Note: if no provider is chosen it causes bugs when deleting recurrent events).
1956 collectvalidation
.form_provider
= {presence
: true};
1962 var submit
= submitme(1, event
, 'theform', collectvalidation
);
1963 if(!submit
)return $
('#form_save').attr('disabled', false);
1965 $
('#form_action').val(valu
);
1967 <?php
if ($repeats): ?
>
1968 // existing repeating events need additional prompt
1969 if ($
("#recurr_affect").val() == "") {
1971 // show the current/future/all DIV for the user to choose one
1972 $
("#recurr_popup").css("visibility", "visible");
1973 $
('#form_save').attr('disabled', false);
1982 // disable all the form elements outside the recurr_popup
1983 function DisableForm() {
1984 $
("#theform").children().attr("disabled", "true");
1986 function EnableForm() {
1987 $
("#theform").children().removeAttr("disabled");
1989 // hide the recurring popup DIV
1990 function HideRecurrPopup() {
1991 $
("#recurr_popup").css("visibility", "hidden");
1994 function deleteEvent() {
1995 if (confirm("<?php echo addslashes(xl('Deleting this event cannot be undone. It cannot be recovered once it is gone. Are you sure you wish to delete this event?')); ?>")) {
1996 $
('#form_action').val("delete");
1998 <?php
if ($repeats): ?
>
1999 // existing repeating events need additional prompt
2000 if ($
("#recurr_affect").val() == "") {
2002 // show the current/future/all DIV for the user to choose one
2003 $
("#recurr_popup").css("visibility", "visible");
2008 return SubmitForm();
2013 function SubmitForm() {
2014 var f
= document
.forms
[0];
2015 <?php
if (!($GLOBALS['select_multi_providers'])) { // multi providers appt is not supported by check slot avail window, so skip ?>
2016 if (f
.form_action
.value
!= 'delete') {
2017 // Check slot availability.
2018 var mins
= parseInt(f
.form_hour
.value
) * 60 +
parseInt(f
.form_minute
.value
);
2019 if (f
.form_ampm
.value
== '2' && mins
< 720) mins +
= 720;
2020 find_available('&cktime=' + mins
);
2023 top
.restoreSession();
2027 top
.restoreSession();