prefix . "wpsp_timetable"; $wh_table = $wpdb->prefix . "wpsp_workinghours"; $wpsp_class_id = intval($_POST['wpsp_class_name']); $noh = intval($_POST['noh']); $sess_template = sanitize_text_field($_POST['sessions_template']); $sql_query = $wpdb->prepare("SELECT heading FROM $tt_table WHERE class_id = %d AND heading != %s",$wpsp_class_id,''); // Get the row using the prepared query. $check_tt = $wpdb->get_row($sql_query, ARRAY_N); //$check_tt = $wpdb->get_row("Select heading from $tt_table where class_id='".esc_sql($wpsp_class_id)."' and heading!=''", ARRAY_N); if (!empty($check_tt)) { $_POST['sessions_template'] = 'available'; $skip_hours = TRUE; } else { $sessions = $wpdb->get_results("SELECT * from $wh_table"); if (empty($sessions)) { echo "
No Working Hours added. Please add at Settings
"; return false; } ?>

prefix . "wpsp_timetable"; $subject_table = $wpdb->prefix . "wpsp_subject"; $h_table = $wpdb->prefix . "wpsp_workinghours"; $class_id = sanitize_text_field($_POST['wpsp_class_name']); $sess_template = sanitize_text_field($_POST['sessions_template']); ?>

get_row($wpdb->prepare("SELECT heading FROM $tt_table WHERE class_id = %d AND heading != %s",$wpsp_class_id,'')); if (!empty($check_tt)) { $get_sessions = unserialize($check_tt->heading); foreach ($get_sessions as $sesio) { $session[] = $sesio; } $error = 0; } else { $error = 1; echo "
Can't fetch template from the selected class
"; } } if (count($session) > 0) { //$chck_hd = $wpdb->get_row("SELECT * from $tt_table where class_id='".esc_sql($class_id)."' and time_id='0' and day='0' and heading!=''"); $chck_hd = $wpdb->get_row($wpdb->prepare("SELECT * FROM $tt_table WHERE class_id = %d and time_id='%s' and day='%s' AND heading != %s",$wpsp_class_id,'0','0','')); if (empty($chck_hd)) { $ins = $wpdb->insert($tt_table, array( 'class_id' => $class_id, 'heading' => serialize($session) )); } else { // echo "*Sessions already available in order to edit session delete and regenerate timetable."; } $error = 0; } else { $error = 1; echo "
No Sessions Retrieved
"; } $wpsp_hours_table = $wpdb->prefix . "wpsp_workinghours"; $wpsp_subjects_table = $wpdb->prefix . "wpsp_subject"; //$clt = $wpdb->get_results("SELECT * FROM $wpsp_subjects_table WHERE class_id='".esc_sql($class_id)."' or class_id=0 order by class_id desc"); $clt = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpsp_subjects_table WHERE class_id = %d or class_id = %d order by class_id desc",$class_id,0)); if (count($clt) == 0) { $error = 1; echo "
No Subjects retrieved, Check you have subject for this class at Subjects
"; } if ($error == 0) { $timetable = array(); //$tt_days = $wpdb->get_results("select * from $tt_table where class_id='".esc_sql($class_id)."' and time_id !='0' ", ARRAY_A); $tt_query = $wpdb->prepare("SELECT * FROM $tt_table WHERE class_id = %d or time_id = %s",$class_id,'0'); $tt_days = $wpdb->get_results($tt_query, ARRAY_A); foreach ($tt_days as $ttd) { $timetable[$ttd['day']][$ttd['time_id']] = $ttd['subject_id']; } ?>
' . $id->sub_name . '
';*/ echo '
' . esc_html($id->sub_name) . '
'; } ?>
prefix."wpsp_leavedays";/* Sat-sun Off */ // $check = $wpdb->get_row("select description from $leave_table where class_id='".esc_sql($class_id)."'"); $check = $wpdb->get_row($wpdb->prepare("SELECT description FROM $leave_table WHERE class_id = %d",$class_id)); $wd = explode(',', $check->description); for ($j = 1; $j <= 7; $j++) { /* Sat-sun Off */ if (!empty($check)) { if ($wd[0] == $dayname[$j-1]) { continue; } if (isset($wd[1])) { if ($wd[1] == $dayname[$j-1]) { continue; } } }/* Sat-sun Off */ ?> $ses) { $ses = esc_sql($ses); // $hour_det = $wpdb->get_row("Select * from $wpsp_hours_table where id='$ses'"); $hour_det = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpsp_hours_table WHERE id = %s",$ses)); if ($hour_det->type == "1") { $td_class = "drop"; } else { $td_class = "break"; /* $sub_name='
Break
'; */ } $sub_id = ''; $sub_name = ''; if (isset($timetable[$j][$ses])) $sub_id = $timetable[$j][$ses]; if ($sub_id > 0) { //$sub_name_f = $wpdb->get_row("SELECT sub_name from $subject_table where id='".esc_sql($sub_id)."'"); $sub_name_f = $wpdb->get_row($wpdb->prepare("SELECT sub_name FROM $subject_table WHERE id = %d",$sub_id)); $sub_name = $sub_name_f->sub_name; } if ($sub_name != '') { $sub_name='
'. esc_html($sub_name).'
'; } else { $sub_name = $sub_name; } if($td_class == "break"){ // $sub_name_f1 = $wpdb->get_row("SELECT id from $subject_table where sub_name='Break'"); $sub_name_f1 = $wpdb->get_row($wpdb->prepare("SELECT id FROM $subject_table WHERE sub_name = %s",'Break')); $time_table = $wpdb->prefix . "wpsp_timetable"; $time_table_data = array( 'class_id' => $class_id, 'time_id' => $ses, 'subject_id' => $sub_name_f1->id, 'session_id' => $key, 'day' => $j ); $ins = $wpdb->insert($time_table, $time_table_data); } ?>
get_row("Select * from $wpsp_hours_table where id='$sess'"); $ses_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpsp_hours_table WHERE id = %s",$sess)); echo esc_html($ses_info->begintime . " to " . $ses_info->endtime); ?>
prefix . "wpsp_timetable"; $class_table = $wpdb->prefix . "wpsp_class"; $classQuery = $wpdb->prepare("select cid,c_name from $class_table Order By cid ASC"); $msg = esc_html("Please Add Class Before Adding Subjects", "wpschoolpress"); if ($current_usr_rle == 'teacher') { $cuserId = esc_sql($current_user->ID); $classQuery = $wpdb->prepare("select cid,c_name from $class_table where teacher_id='%d'",$cuserId); } $classes = $wpdb->get_results($classQuery); $class_names = array(); foreach ($classes as $cnames) { $class_names[$cnames->cid] = $cnames->c_name; } ?>

get_results("SELECT t.class_id from $tt_table t, $class_table c where heading!='' and day=0 and c.cid=t.class_id"); $avail_sess = $wpdb->get_results($wpdb->prepare("SELECT t.class_id FROM $tt_table t $class_table c WHERE heading!= %s and day = %d and c.cid=t.class_id",'',0)); ?>