} else { $owner = ''; } $master_session = Get_Crypt_Master_Session($sess_id, $bd); if (Validate_Session($complete_sess_id, $_SERVER['REMOTE_ADDR'], $bd)) { Get_Account_Id($sess_id, $account_id, $bd); $query = "SELECT * FROM accounts WHERE account_id = '{$account_id}'"; $result = $bd->Query($query); $role = $bd->FetchResult($result, 0, 'role'); $var_type = $role . '_type'; $var_color = $role . '_color'; $var_image = $role . '_icon'; $array_type = $cfg[$var_type]; $array_color = $cfg[$var_color]; $array_image = $cfg[$var_image]; $apps = List_Appointments($account_id, 0, '', '', '', '', '', '', '', $owner, $cfg['time'], $array_type, $array_color, $array_image, $cfg['days'], $bd); $result_xsl = "xsl/" . $default_xsl . "/sch_mod_app.xsl"; } else { $error[$num_errors++] = "Invalid Session ID"; include "logout.php"; exit; } $smarty->assign("nrpTransform", $result_xsl); $smarty->assign("nrpSchErrors", $error); $smarty->assign("nrpSchAlerts", $alert); $smarty->assign("nrpMasterSession", $master_session); $smarty->assign("nrpSessId", $complete_sess_id); $smarty->assign("nrpUserId", $account_id); $smarty->assign("nrpSchSpan", 'all'); $smarty->assign("nrpMainApp", $apps); $result_xml = $smarty->fetch("xml/sch_del_app.xml");
function Group_Delete_Appointment($ref_app_id, $account_id, $bd) { $ref_app = List_Appointments($account_id, 1, '', '', '', '', '', '', $ref_app_id, '', '', '', '', '', '', $bd); $beg_time = $ref_app[0][7]; $end_time = $ref_app[0][9]; $date = $ref_app[0][6] . "-" . $ref_app[0][5] . "-" . $ref_app[0][4]; $group_id = $ref_app[0][19]; $query = "DELETE FROM appointments WHERE (is_group_app = 1) AND (beg_time = {$beg_time})\n\t\tAND (end_time = {$end_time}) AND (date = '{$date}') AND (group_id = {$group_id})"; $bd->Query($query); }
for ($u_date = $u_beg_date; $u_date <= $u_end_date; $u_date += 24 * 60 * 60, $num_day++) { $days[$num_day - $first_day_week][0] = $num_day; $days[$num_day - $first_day_week][1] = $num_week; $days[$num_day - $first_day_week][2] = date('d', $u_date); $days[$num_day - $first_day_week][3] = date('m', $u_date); $days[$num_day - $first_day_week][4] = date('Y', $u_date); if (($num_day + 1) % 7 == 0) { $num_week++; $weeks[$num_week] = $num_week; } $days[$num_day - $first_day_week][5] = date('w', $u_date); $day_of_week = $days[$num_day][5]; $days[$num_day - $first_day_week][6] = $cfg['days'][$day_of_week]; } $apps = Retrieve_Appointments($account_id, $beg_day, $end_day, '', '', '', $cfg['time'], $array_type, $array_color, $array_image, $cfg['days'], $fake, $bd); $unauth_apps = List_Appointments($account_id, '', '', 0, '', '', '', '', '', $owner, '', '', '', '', '', $bd); } else { $error[$num_errors++] = "Invalid Session ID"; include "logout.php"; exit; } $time_count = count($cfg['time']); for ($i = 0; $i < $time_count - 1; $i++) { $new_time[$i] = $cfg['time'][$i]; } $smarty->assign("nrpTransform", $result_xsl); $smarty->assign("nrpMainTime", $new_time); $smarty->assign("nrpMainErrors", $error); $smarty->assign("nrpMainAlerts", $alert); $smarty->assign("nrpSpanStart", $span_start); $smarty->assign("nrpSpanEnd", $span_end);
function listAppointments($complete_sess_id, $beg_date, $end_date, $beg_time, $end_time, $type) { // Validate user session code if (!Validate_Session($complete_sess_id, $_SERVER['REMOTE_ADDR'], $GLOBALS['bd'])) { return "Invalid session ID!"; } // Get the user account ID $sess_id = substr($complete_sess_id, 32); Get_Account_Id($sess_id, $account_id, $GLOBALS['bd']); // Get information about appointments types available $query = "SELECT * FROM accounts WHERE account_id = '{$account_id}'"; $result = $GLOBALS['bd']->Query($query); $role = $GLOBALS['bd']->FetchResult($result, 0, 'role'); $var_type = $role . '_type'; // Set app types, times and days of week (see inc/config.inc.php) $app_times = $GLOBALS['cfg']['time']; $app_types = $GLOBALS['cfg'][$var_type]; $days_of_week = $GLOBALS['cfg']['days']; // Convert $beg_time and $end_time to NoRisk values // see (inc/config.inc.php to see how norisk store this values // XXX Check if value is between first_time and last_time? $aux = split(":", $beg_time); $nrp_beg_time = $aux[0] - $GLOBALS['cfg']['first_time']; $aux = split(":", $end_time); $nrp_end_time = $aux[0] - $GLOBALS['cfg']['first_time']; // Get the list of appointments for this user // (does not include the weekly ones) $apps = List_Appointments($account_id, '', '', '', $beg_date, $end_date, $nrp_beg_time, $nrp_end_time, '', '', $app_times, $app_types, '', '', $days_of_week, $GLOBALS['bd']); // If there are no results, return an empty array instead of a null if ($apps == null) { return array(); } // Make the returning array $apps_list = array(); foreach ($apps as $app) { $aux = array('app_id' => $app['0'], 'description' => $app['2'], 'beg_time' => $app['8'], 'end_time' => $app['10'], 'date' => $app['16'], 'type' => $app['12'], 'url' => $app['17'], 'owner' => $app['18']); array_push($apps_list, $aux); } // Return the appotinments list return $apps_list; }
$apps = array(); $overlap_apps = Check_Weekly_Appointment_Overlap($account_id, $app[0][15], $app[0][7], $app[0][9], '', $bd); echo $app[0][15]; if ($overlap_apps) { for ($i = 0; $i < $bd->NumberOfRows($overlap_apps); $i++) { $cur_app = $bd->FetchResult($overlap_apps, $i, 'app_id'); $res_app = List_Weekly_Appointments($account_id, '', '', 1, '', '', '', '', $cur_app, '', $cfg['time'], $array_type, $array_color, $array_image, $cfg['days'], $bd); $apps = array_merge($apps, $res_app); } } if ($perio == 'common') { $overlap_apps = Check_Appointment_Overlap($account_id, $app[0][4], $app[0][5], $app[0][6], $app[0][7], $app[0][9], '', $bd); if ($overlap_apps) { for ($i = 0; $i < $bd->NumberOfRows($overlap_apps); $i++) { $cur_app = $bd->FetchResult($overlap_apps, $i, 'app_id'); $res_app = List_Appointments($account_id, '', '', 1, '', '', '', '', $cur_app, '', $cfg['time'], $array_type, $array_color, $array_image, $cfg['days'], $bd); $apps = array_merge($apps, $res_app); } } } if (count($apps) == 0) { $update = "UPDATE appointments SET authorized = 1 WHERE\n\t\t\t\t\tapp_id = " . $app[0][0]; $bd->Query($update); $alert[$num_alerts++] = "Appointment authorized successfully."; include "sch_auth.php"; exit; } $result_xsl = "xsl/" . $default_xsl . "/sch_auth_conf.xsl"; } else { $result_xsl = "xsl/" . $default_xsl . "/sch_auth_conf_no.xsl"; }
function Search_Appointments($account_id, $key, $app_times, $app_types, $app_colors, $app_images, $days_of_week, $bd) { $query = "SELECT app_id FROM appointments WHERE\n\t\taccount_id = '{$account_id}' AND ((description LIKE '{$key}')\n\t\tOR (description LIKE '%{$key}') OR (description LIKE '{$key}%')\n\t\tOR (description LIKE '%{$key}%'))"; $result = $bd->Query($query); for ($i = 0; $i < $bd->NumberOfRows($result); $i++) { $app_id = $bd->FetchResult($result, $i, 'app_id'); $app = List_Appointments($account_id, '', '', 1, '', '', '', '', $app_id, '', $app_times, $app_types, $app_colors, $app_images, $days_of_week, $bd); $final_apps[] = $app[0]; } return $final_apps; }