From e5298334f04f4da0b5d712fc598d6fd0f8b7ae3b Mon Sep 17 00:00:00 2001 From: Ken Chapple Date: Wed, 13 Apr 2011 11:32:52 -0700 Subject: [PATCH] fixed recurring appointment miscalculation, and facility filtering in appointments report --- library/appointments.inc.php | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/library/appointments.inc.php b/library/appointments.inc.php index e828456d0..feac1d8a4 100644 --- a/library/appointments.inc.php +++ b/library/appointments.inc.php @@ -81,7 +81,8 @@ function fetchAllEvents( $from_date, $to_date, $provider_id = null, $facility_id $facility_filter = ''; if ( $facility_id ) { $event_facility_filter = " AND e.pc_facility = '$facility_id'"; - $provider_facility_filter = " AND users.facility_id = '$facility_id'"; + $provider_facility_filter = " AND u.facility_id = '$facility_id'"; + $facility_filter = $event_facility_filter . $provider_facility_filter; } $where .= $facility_filter; @@ -102,7 +103,8 @@ function fetchAppointments( $from_date, $to_date, $patient_id = null, $provider_ $facility_filter = ''; if ( $facility_id ) { $event_facility_filter = " AND e.pc_facility = '$facility_id'"; - $provider_facility_filter = " AND users.facility_id = '$facility_id'"; + $provider_facility_filter = " AND u.facility_id = '$facility_id'"; + $facility_filter = $event_facility_filter . $provider_facility_filter; } $where .= $facility_filter; @@ -115,7 +117,7 @@ function getRecurringEvents( $event, $from_date, $to_date ) $repeatEvents = array(); $from_date_time = strtotime( $from_date . " 00:00:00" ); $thistime = strtotime( $event['pc_eventDate'] . " 00:00:00" ); - $thistime = max( $thistime, $from_date_time ); + //$thistime = max( $thistime, $from_date_time ); if ( $event['pc_recurrtype'] ) { preg_match( '/"event_repeat_freq_type";s:1:"(\d)"/', $event['pc_recurrspec'], $matches ); @@ -134,13 +136,15 @@ function getRecurringEvents( $event, $from_date, $to_date ) { // Skip the event if a repeat frequency > 1 was specified and this is // not the desired occurrence. - if ( !$repeatix) - { - $newEvent = $event; - $eventDate = date( "Y-m-d", $thistime ); - $newEvent['pc_eventDate'] = $eventDate; - $newEvent['pc_endDate'] = $eventDate; - $repeatEvents []= $newEvent; + if ( !$repeatix ) { + $inRange = ( $thistime >= $from_date_time && $thistime < $upToDate ); + if ( $inRange ) { + $newEvent = $event; + $eventDate = date( "Y-m-d", $thistime ); + $newEvent['pc_eventDate'] = $eventDate; + $newEvent['pc_endDate'] = $eventDate; + $repeatEvents []= $newEvent; + } } if ( ++$repeatix >= $repeatfreq ) $repeatix = 0; -- 2.11.4.GIT