<?php if ($already_initialized != 1) { require "./inc/script_inicialization.php"; require "./inc/nrp_api.php"; } if (!isset($num_errors)) { $num_errors = 0; } if (!isset($num_alerts)) { $num_alerts = 0; } if (Validate_Session($complete_sess_id, $_SERVER['REMOTE_ADDR'], $bd)) { Get_Account_Id($sess_id, $account_id, $bd); if ($account_id != 'admin') { $error[$num_errors++] = "You are not the administrator"; include "logout.php"; exit; } } else { $error[$num_errors++] = "Invalid Session ID"; include "logout.php"; exit; } $result_xsl = "xsl/" . $default_xsl . "/adm_accounts.xsl"; $smarty->assign("nrpTransform", $result_xsl); $smarty->assign("nrpSchErrors", $error); $smarty->assign("nrpSchAlerts", $alert); $smarty->assign("nrpMasterSessId", $master_session); $smarty->assign("nrpSessId", $complete_sess_id); $smarty->assign("nrpUserId", $account_id);
Get_Account_Id($sess_id, $account_id, $bd); if ($_GET['is_pop'] || $_POST['is_pop']) { $is_pop = 1; } if (!empty($_GET['is_pop'])) { $_POST['beg_time'] = $_GET['beg_time']; $_POST['end_time'] = $_GET['end_time']; $_POST['day'] = $_GET['day']; $_POST['month'] = $_GET['month']; $_POST['year'] = $_GET['year']; } $m_session = Get_Master_Session($sess_id, $bd); if (!$master_session) { $owner = $account_id; } else { Get_Account_Id($m_session, $owner, $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]; if ($is_pop) { $result_xsl = "xsl/" . $default_xsl . "/sch_ins_app_pop.xsl"; } else { $result_xsl = "xsl/" . $default_xsl . "/sch_ins_app.xsl"; }
require "./inc/script_inicialization.php"; require_once "./inc/nrp_api.php"; } if (!isset($num_errors)) { $num_errors = 0; } if (!isset($num_alerts)) { $num_alerts = 0; } if (Validate_Session($complete_sess_id, $_SERVER['REMOTE_ADDR'], $bd)) { Get_Account_Id($sess_id, $account_id, $bd); $master_session = Get_Crypt_Master_Session($sess_id, $bd); if (!$master_session) { $owner = $account_id; } else { Get_Account_Id($master_session, $owner, $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]; if (!empty($_POST['search'])) { $apps1 = Search_Appointments($account_id, $_POST['key'], $cfg['time'], $array_type, $array_color, $array_image, $cfg['days'], $bd); $apps2 = Search_Weekly_Appointments($account_id, $_POST['key'], $cfg['time'], $array_type, $array_color, $array_image, $cfg['days'], $bd); $apps = array_merge($apps1, $apps2); $result_xsl = "xsl/" . $cfg['default_xsl'] . "/search_res.xsl";
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; }