function display() { ob_start(); if (isset($GLOBALS['cal_strings'])) { return parent::display() . "Only one Calendar dashlet is allowed."; } require_once 'modules/Calendar/Calendar.php'; require_once 'modules/Calendar/CalendarDisplay.php'; require_once "modules/Calendar/CalendarGrid.php"; global $cal_strings, $current_language; $cal_strings = return_module_language($current_language, 'Calendar'); if (!ACLController::checkAccess('Calendar', 'list', true)) { ACLController::displayNoAccess(true); } $cal = new Calendar($this->view); $cal->dashlet = true; $cal->add_activities($GLOBALS['current_user']); $cal->load_activities(); $display = new CalendarDisplay($cal, $this->id); $display->display_calendar_header(false); $display->display(); $str = ob_get_contents(); ob_end_clean(); return parent::display() . $str; }
function display() { $smarty = new Sugar_Smarty(); parent::display(); $db = DBManagerFactory::getInstance(); //$myquery = 'SELECT tab4.first_name fname, tab4.last_name lname, tab5.mrn_c mrn, tab4.id patid, tab5.location_c location, tab5.active_c active, ( SELECT tab1.reg_patient_reg_encounterreg_encounter_idb enclink FROM reg_patient_reg_encounter_c tab1 WHERE tab1.reg_patient_reg_encounterreg_patient_ida = patid AND tab1.date_modified = (SELECT max( date_modified ) dat FROM reg_patient_reg_encounter_c enc1 WHERE enc1.reg_patient_reg_encounterreg_patient_ida = patid) ) enclink, ( SELECT DATE_FORMAT(tab3.next_rx_refill_due_c,"%m/%d/%Y") ref1 FROM reg_encounter_cstm tab3 where tab3.id_c = enclink ) refill, ( SELECT DATE_FORMAT(tab3.last_uts_c,"%m/%d/%Y") uts1 FROM reg_encounter_cstm tab3 where tab3.id_c = enclink ) last_uts , ( SELECT DATE_FORMAT(tab3.next_uts_due_c,"%m/%d/%Y") uts11 FROM reg_encounter_cstm tab3 where tab3.id_c = enclink ) uts , (SELECT DATE_FORMAT(tab3.next_pcp_visit_c,"%m/%d/%Y") pcp11 FROM reg_encounter_cstm tab3 where tab3.id_c = enclink ) next_pcp, (SELECT p1b.name provname from reg_provider p1b, reg_provider_reg_patient_c p2b WHERE p2b.reg_provider_reg_patientreg_provider_ida = p1b.id AND p2b.reg_provider_reg_patientreg_patient_idb = patid) provname, ( SELECT risklvl_c risk1 FROM reg_encounter_cstm tab3 where tab3.id_c = enclink ) risk FROM reg_patient tab4, reg_patient_cstm tab5, reg_patient_reg_encounter_c tab1, ( SELECT max( date_modified ) dat, reg_patient_reg_encounterreg_patient_ida pat FROM reg_patient_reg_encounter_c GROUP BY reg_patient_reg_encounterreg_patient_ida) tab2, reg_encounter_cstm tab3 WHERE tab5.id_c = tab4.id AND tab1.date_modified = tab2.dat AND tab1.reg_patient_reg_encounterreg_patient_ida = tab2.pat AND tab3.id_c = tab1.reg_patient_reg_encounterreg_encounter_idb AND tab4.id = tab2.pat'; $myquery = 'SELECT tab4.first_name fname, tab4.last_name lname, tab5.mrn_c mrn, tab4.id patid, tab5.location_c location, tab5.active_c active, ( SELECT tab1.reg_patient_reg_encounterreg_encounter_idb enclink FROM reg_patient_reg_encounter_c tab1 WHERE tab1.reg_patient_reg_encounterreg_patient_ida = patid AND tab1.date_modified = (SELECT max( date_modified ) dat FROM reg_patient_reg_encounter_c enc1 WHERE enc1.reg_patient_reg_encounterreg_patient_ida = patid) ) enclink, ( SELECT DATE_FORMAT(tab3.next_rx_refill_due_c,"%m/%d/%Y") ref1 FROM reg_encounter_cstm tab3 where tab3.id_c = enclink ) refill, ( SELECT DATE_FORMAT(tab3.last_uts_c,"%m/%d/%Y") uts1 FROM reg_encounter_cstm tab3 where tab3.id_c = enclink ) last_uts , ( SELECT DATE_FORMAT(tab3.next_uts_due_c,"%m/%d/%Y") uts11 FROM reg_encounter_cstm tab3 where tab3.id_c = enclink ) uts , (SELECT DATE_FORMAT(tab3.next_pcp_visit_c,"%m/%d/%Y") pcp11 FROM reg_encounter_cstm tab3 where tab3.id_c = enclink ) next_pcp, (SELECT p1b.name provname from reg_provider p1b, reg_provider_reg_patient_c p2b WHERE p2b.reg_provider_reg_patientreg_provider_ida = p1b.id AND p2b.reg_provider_reg_patientreg_patient_idb = patid) provname, ( SELECT risklvl_c risk1 FROM reg_encounter_cstm tab3 where tab3.id_c = enclink ) risk FROM reg_patient tab4, reg_patient_cstm tab5 WHERE tab5.id_c = tab4.id '; $result = $db->query($myquery); $mydata = null; while ($row = $db->fetchRow($result)) { $mydata[] = $row; } global $cal_strings, $current_language; $cal_strings = return_module_language($current_language, 'Calendar'); if (empty($_REQUEST['view'])) { $_REQUEST['view'] = SugarConfig::getInstance()->get('calendar.default_view', 'week'); } $cal = new Calendar($_REQUEST['view']); if (in_array($cal->view, array('day', 'week', 'month'))) { $cal->add_activities($GLOBALS['current_user']); } else { if ($cal->view == 'shared') { $cal->init_shared(); global $shared_user; $shared_user = new User(); foreach ($cal->shared_ids as $member) { $shared_user->retrieve($member); $cal->add_activities($shared_user); } } } if (in_array($cal->view, array("day", "week", "month", "shared"))) { $cal->load_activities(); } if (!empty($_REQUEST['print']) && $_REQUEST['print'] == 'true') { $cal->setPrint(true); } $display = new CalendarDisplay($cal); $smarty->assign("mydata", $mydata); echo "<table><tr><td>"; $smarty->display($this->lv->tpl); echo "</td>"; echo "<td style='width:100%;vertical-align:top'>"; $caltest = new caltest(); $caltest->test(); echo "</td></tr></table>"; }
public function test() { global $cal_strings, $current_language; $cal_strings = return_module_language($current_language, 'Calendar'); if (empty($_REQUEST['view'])) { $_REQUEST['view'] = SugarConfig::getInstance()->get('calendar.default_view', 'week'); } $cal = new Calendar($_REQUEST['view']); if (in_array($cal->view, array('day', 'week', 'month'))) { $cal->add_activities($GLOBALS['current_user']); } else { if ($cal->view == 'shared') { $cal->init_shared(); global $shared_user; $shared_user = new User(); foreach ($cal->shared_ids as $member) { $shared_user->retrieve($member); $cal->add_activities($shared_user); } } } if (in_array($cal->view, array("day", "week", "month", "shared"))) { $cal->load_activities(); } if (!empty($_REQUEST['print']) && $_REQUEST['print'] == 'true') { $cal->setPrint(true); } /* $_REQUEST['year']='2014'; $_REQUEST['month']='12'; $_REQUEST['day']='8';*/ //var_dump($_REQUEST); $display = new CalendarDisplay($cal); echo "<div style='width:448px'>"; $display->display_calendar_header(false); $display->display(); echo "</div>"; }
public function testCalendarLoadActivities() { $cal = new Calendar('month'); $cal->add_activities($GLOBALS['current_user']); $format = $GLOBALS['current_user']->getUserDateTimePreferences(); $meeting = new Meeting(); $meeting->meeting_id = uniqid(); $meeting->date_start = $this->time_date->swap_formats("2012-01-01 11:00pm", 'Y-m-d h:ia', $format['date'] . ' ' . $format['time']); $meeting->name = "test"; $cal->acts_arr = array(); $cal->acts_arr[$GLOBALS['current_user']->id] = array(); $cal->acts_arr[$GLOBALS['current_user']->id][] = new CalendarActivity($meeting); $cal->load_activities(); $this->assertEquals($cal->items[0]['time_start'], $this->time_date->swap_formats("2012-01-01 11:00pm", 'Y-m-d h:ia', $format['time']), "Time should remain the same after load_activities"); }
protected function action_getActivities() { $this->view = 'json'; if (!ACLController::checkAccess('Calendar', 'list', true)) { ACLController::displayNoAccess(true); } require_once 'modules/Calendar/Calendar.php'; $cal = new Calendar($_REQUEST['view']); if (in_array($cal->view, array('day', 'week', 'month'))) { $cal->add_activities($GLOBALS['current_user']); } else { if ($cal->view == 'shared') { $cal->init_shared(); $sharedUser = new User(); foreach ($cal->shared_ids as $member) { $sharedUser->retrieve($member); $cal->add_activities($sharedUser); } } } $cal->load_activities(); $this->view_object_map['jsonData'] = $cal->items; }
if (empty($_REQUEST['view'])) { if (isset($_SESSION['CALENDAR_VIEW']) && in_array($_SESSION['CALENDAR_VIEW'], $views)) { $_REQUEST['view'] = $_SESSION['CALENDAR_VIEW']; } else { $_REQUEST['view'] = SugarConfig::getInstance()->get('calendar.default_view', 'week'); } } $_SESSION['CALENDAR_VIEW'] = $_REQUEST['view']; $cal = new Calendar($_REQUEST['view'], array(), $views); if ($cal->view == "sharedMonth" || $cal->view == "sharedWeek") { $cal->init_shared(); global $shared_user; $shared_user = new User(); foreach ($cal->shared_ids as $member) { $shared_user->retrieve($member); $cal->add_activities($shared_user); } } else { if (array_key_exists($cal->view, $views)) { $cal->add_activities($GLOBALS['current_user']); } } if (array_key_exists($cal->view, $views)) { $cal->load_activities(); } if (!empty($_REQUEST['print']) && $_REQUEST['print'] == 'true') { $cal->setPrint(true); } $display = new CalendarDisplay($cal, "", $views); $display->display_title(); if ($cal->view == "sharedMonth" || $cal->view == "sharedWeek") {
function template_shared_calendar(&$args) { global $current_user; global $app_strings; global $mod_strings; $date_arr = array("activity_focus" => $args['activity_focus']); $calendar = new Calendar("day", $date_arr); $calendar->show_tasks = false; $calendar->toggle_appt = false; foreach ($args['users'] as $user) { /* if ($user->id != $current_user->id) { */ $calendar->add_activities($user, 'vfb'); /* } */ } ?> <p> <table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td><h5 class="listViewSubHeadS1"><?php echo $mod_strings['LBL_USER_CALENDARS']; ?> </h5> </td> <td align=right> <h5 class="listViewSubHeadS1"><?php template_echo_date_info("day", $calendar->date_time); ?> </h5> </td></tr></table> <table cellpadding="0" cellspacing="0" width="100%" border="0" class="listView"> <tr height="20"> <td scope="col" width="25%" class="listViewThS1"><?php echo $app_strings['LBL_LIST_NAME']; ?> </td> <?php $start_slice_idx = $calendar->get_start_slice_idx(); $end_slice_idx = $calendar->get_end_slice_idx(); $cur_slice_idx = 1; $slice_args = array(); for ($cur_slice_idx = $start_slice_idx; $cur_slice_idx <= $end_slice_idx; $cur_slice_idx++) { $slice_args['slice'] = $calendar->slice_hash[$calendar->slices_arr[$cur_slice_idx]]; $slice_args['calendar'] = $calendar; //print_r($cur_time); ?> <td class="listViewThS1"><?php template_echo_slice_date($slice_args); ?> </td> <?php } ?> </tr> <?php global $hilite_bg, $click_bg, $odd_bg, $even_bg; $oddRow = true; foreach ($args['users'] as $curr_user) { if ($oddRow) { $bg_color = $odd_bg; $row_class = 'oddListRowS1'; } else { $bg_color = $even_bg; $row_class = 'evenListRowS1'; } $oddRow = !$oddRow; ?> <tr height="20"> <td scope="row" valign=TOP class="<?php echo $row_class; ?> " bgcolor="<?php echo $bg_color; ?> "><a href="index.php?action=DetailView&module=Users&record=<?php echo $curr_user->id; ?> " class="listViewTdLinkS1"> <?php echo $curr_user->full_name; ?> </a></td> <?php // loop through each slice for this user and show free/busy for ($cur_slice_idx = $start_slice_idx; $cur_slice_idx <= $end_slice_idx; $cur_slice_idx++) { $cur_slice = $calendar->slice_hash[$calendar->slices_arr[$cur_slice_idx]]; // if this current activitiy occurs within this time slice if (Calendar::occurs_within_slice($cur_slice, $calendar->activity_focus)) { /* $got_conflict = 0; if ( isset($cur_slice->acts_arr[$curr_user->id]) ) { foreach( $cur_slice->acts_arr[$curr_user->id] as $act) { if ($act->sugar_bean->id != $calendar->activity_focus->sugar_bean->id) { $got_conflict = 1; } } } */ if (isset($cur_slice->acts_arr[$curr_user->id]) && count($cur_slice->acts_arr[$curr_user->id]) > 1) { ?> <td class="listViewCalConflictAppt"> </td> <?php } else { ?> <td class="listViewCalCurrentAppt"> </td> <?php } } else { if (isset($cur_slice->acts_arr[$curr_user->id])) { ?> <td class="listViewCalOtherAppt"> </td> <?php } else { ?> <td class="<?php echo $row_class; ?> " bgcolor="<?php echo $bg_color; ?> "> </td> <?php } } } ?> </tr> <tr><td colspan="20" class="listViewHRS1"></td></tr> <?php } ?> </table> <table width="100%" cellspacing="2" cellpadding="0" border="0"> <tr height="15"> <td width="100%"></td> <td class="listViewCalCurrentApptLgnd"><img src="include/images/blank.gif" alt="<?php echo $mod_strings['LBL_SCHEDULED']; ?> " width="15" height="15"> </td> <td> <?php echo $mod_strings['LBL_SCHEDULED']; ?> </td> <td class="listViewCalOtherApptLgnd"><img src="include/images/blank.gif" alt="<?php echo $mod_strings['LBL_BUSY']; ?> " width="15" height="15"> </td> <td> <?php echo $mod_strings['LBL_BUSY']; ?> </td> <td class="listViewCalConflictApptLgnd"><img src="include/images/blank.gif" alt="<?php echo $mod_strings['LBL_CONFLICT']; ?> " width="15" height="15"> </td> <td> <?php echo $mod_strings['LBL_CONFLICT']; ?> </td> </tr> </table> </p> <?php }