if (User_Validate_Simple_Field($_POST['description'], 100) <= 0) {
     $error[$num_errors++] = "The appointment description must be informed";
 }
 if ($_POST['beg_time'] >= $_POST['end_time']) {
     $error[$num_errors++] = "The ending time must be greater than the beginning time";
 }
 $check = Check_Weekly_Appointment_Overlap($account_id, $_POST['day'], $_POST['beg_time'], $_POST['end_time'], $app_id, $bd);
 if ($check) {
     $error[$num_errors++] = "There is another weekly appointment within this time span";
 }
 if ($ins_at_master) {
     $apps_bef = List_Weekly_Appointments($account_id, '', '', '', '', '', '', '', '', $app_id, '', $cfg['time'], $array_type, $array_color, $array_image, $cfg['days'], $bd);
     $apps = List_Weekly_Appointments($owner, '', '', '', '', $apps_bef[0][15], $apps_bef[0][15], $apps_bef[0][7], $apps_bef[0][9], '', '', $cfg['time'], $array_type, $array_color, $array_image, $cfg['days'], $bd);
     if (!empty($apps)) {
         $app_id_owner = $apps[0][0];
         $check = Check_Weekly_Appointments_Overlap($owner, $_POST['day'], $_POST['beg_time'], $_POST['end_time'], $app_id_owner, $bd);
         if ($check) {
             $error[$num_errors++] = "There is another weekly appointment on the owner's\n\t\t\t\t\t\t schedule within this time span";
         }
     }
 }
 if (empty($error)) {
     Update_Weekly_Appointment($app_id, $_POST['description'], $_POST['type'], $_POST['day'], $_POST['beg_time'], $_POST['end_time'], $_POST['url'], $bd);
     $alert[$num_alerts++] = "Appointment Modified Successfully";
     if ($ins_at_master) {
         Update_Weekly_Appointment($app_id_owner, $_POST['description'], $_POST['type'], $_POST['day'], $_POST['beg_time'], $_POST['end_time'], $_POST['url'], $bd);
         $alert[$num_alerts++] = "Appointment Modified Successfully at Owner's Schedule";
     }
     if (!$is_pop) {
         include "scheduling.php";
         exit;
 }
 if ($_POST['beg_time'] >= $_POST['end_time']) {
     $error[$num_errors++] = "The ending time must be greater than the beginning time";
 }
 $check = Check_Weekly_Appointment_Overlap($account_id, $_POST['day'], $_POST['beg_time'], $_POST['end_time'], '', $bd);
 if ($check) {
     $error[$num_errors++] = "There is another weekly appointment within this time span";
 }
 if ($ins_at_master) {
     $check = Check_Weekly_Appointments_Overlap($owner, $_POST['day'], $_POST['beg_time'], $_POST['end_time'], '', $bd);
     if ($check) {
         $error[$num_errors++] = "There is another weekly appointment on the owner's schedule within this time span";
     }
 }
 if ($_POST['room']) {
     $check = Check_Weekly_Appointments_Overlap($_POST['room'], $_POST['day'], $_POST['beg_time'], $_POST['end_time'], '', $bd);
     if ($check) {
         $error[$num_errors++] = "There is another weekly appointment in the rooms' schedule within this time span";
     }
 }
 if (empty($error)) {
     Insert_Weekly_Appointment($account_id, $_POST['description'], $_POST['type'], $_POST['day'], $_POST['beg_time'], $_POST['end_time'], $_POST['url'], $owner, 0, 0, 1, $bd);
     $alert[$num_alerts++] = "Appointment Inserted Successfully";
     if ($ins_at_master) {
         Insert_Weekly_Appointment($owner, $_POST['description'], $_POST['type'], $_POST['day'], $_POST['beg_time'], $_POST['end_time'], $_POST['url'], $owner, 0, 0, 1, $bd);
         $alert[$num_alerts++] = "Appointment Inserted Successfully at Owner's Schedule";
     }
     if (!$is_pop) {
         include "scheduling.php";
         exit;
     } else {