Beispiel #1
0
function Group_Delete_Weekly_Appointment($ref_app_id, $account_id, $bd)
{
    $ref_app = List_Weekly_Appointments($account_id, 1, '', '', '', '', '', '', $ref_app_id, '', '', '', '', '', '', $bd);
    $beg_time = $ref_app[0][7];
    $end_time = $ref_app[0][9];
    $day = $ref_app[0][15];
    $group_id = $ref_app[0][19];
    $query = "DELETE FROM weekly_appointments WHERE (is_group_app = 1) AND (beg_time = {$beg_time})\n\t\tAND (end_time = {$end_time}) AND (day = {$day}) AND (group_id = {$group_id})";
    $bd->Query($query);
}
} 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_Weekly_Appointments($account_id, 0, '', 1, '', '', '', '', '', $owner, $cfg['time'], $array_type, $array_color, $array_image, $cfg['days'], $bd);
    $result_xsl = "xsl/" . $default_xsl . "/sch_mod_week_app.xsl";
} else {
    $error[$num_errors++] = "Invalid Session ID";
    include "logout.php";
    exit;
}
$smarty->assign("nrpTransform", $result_xsl);
$smarty->assign("nrpMasterSession", $master_Session);
$smarty->assign("nrpSchErrors", $error);
$smarty->assign("nrpSchAlerts", $alert);
$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");
     } else {
         if ($conf == 'no') {
             $alert[$num_alerts++] = "Unauthorized Appointment removing cancelled.";
         }
     }
     include "sch_auth.php";
     exit;
 } else {
     if ($conf == 'yes') {
         $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];
                Group_Delete_Weekly_Appointment($_POST['app_id'], $account_id, $bd);
                $alert[$num_alerts++] = 'Appointment deleted successfully';
                if (!empty($_POST['master_del'])) {
                    $apps = List_Weekly_Appointments($account_id, 1, $group_id, '', '', '', '', '', $_POST['app_id'], '', $cfg['time'], $array_type, $array_color, $array_image, $cfg['days'], $bd);
                }
            } else {
                $alert[$num_alerts++] = 'Appointment deletion cancelled';
            }
            if (!$is_pop) {
                include "groups_schedule.php";
                exit;
            } else {
                $result_xsl = "xsl/" . $default_xsl . "/groups_sch_pop_final.xsl";
            }
        } else {
            $apps = List_Weekly_Appointments($account_id, 1, $group_id, '', '', '', '', '', $_POST['app_id'], $owner, $cfg['time'], $array_type, $array_color, $array_image, $cfg['days'], $bd);
            $result_xsl = "xsl/" . $default_xsl . "/groups_sch_del_week_app.xsl";
        }
    }
} else {
    $error[$num_errors++] = "Invalid Session ID";
    include "logout.php";
    exit;
}
$group = List_Groups($group_id, '', '', '', 0, $bd);
$smarty->assign("nrpTransform", $result_xsl);
$smarty->assign("nrpMasterSessId", $master_Session);
$smarty->assign("nrpSchErrors", $error);
$smarty->assign("nrpSchAlerts", $alert);
$smarty->assign("nrpSessId", $complete_sess_id);
$smarty->assign("nrpUserId", $account_id);
function Search_Weekly_Appointments($account_id, $key, $app_times, $app_types, $app_colors, $app_images, $days_of_week, $bd)
{
    $query = "SELECT app_id FROM weekly_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_Weekly_Appointments($account_id, '', '', '', '', '', '', '', $app_id, '', $app_times, $app_types, $app_colors, $app_images, $days_of_week, $bd);
        $final_apps[] = $app[0];
    }
    return $final_apps;
}