PluginProbe
School Management System – WPSchoolPress / 2.2.38
School Management System – WPSchoolPress v2.2.38
2.2.48 2.2.47 2.2.46 2.2.45 2.2.44 2.2.43 2.2.42 2.2.41 2.2.40 2.2.39 2.2.38 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 All 103 releases
wpschoolpress / includes / wpsp-viewTimetable.php

wpsp-viewTimetable.php in School Management System – WPSchoolPress 2.2.38, at includes/wpsp-viewTimetable.php

143 lines 8.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined( 'ABSPATH' ) )exit('No Such File');
3 function wpsp_ViewTimetable($class_id){
4 global $wpdb;
5 $tt_table = $wpdb->prefix . "wpsp_timetable";
6 $subject_table = $wpdb->prefix . "wpsp_subject";
7 $wpsp_hours_table = $wpdb->prefix . "wpsp_workinghours";
8 // $get_heading = $wpdb->get_row("SELECT * from $tt_table where class_id='".esc_sql($class_id)."' and heading != ' ' ");
9 $get_heading = $wpdb->get_row($wpdb->prepare("SELECT * FROM $tt_table WHERE class_id = %d and heading != %s",$class_id,''));
10 $response = array();
11 ob_start();
12 if ($get_heading == null) {
13 echo '<section class="content">
14 <div class="wpsp-text-red">Timetable Has Not Created For This Class.</div>
15 </section> </div></div>';
16 $response['status'] = 1;
17 } else {
18 $response['status'] = 2;
19 $session = unserialize($get_heading->heading);
20 $tt_query = $wpdb->prepare("SELECT * FROM $tt_table WHERE class_id = %d",$class_id);
21 $tt_days=$wpdb->get_results($tt_query,ARRAY_A);
22 foreach($tt_days as $ttd){
23 $timetable[$ttd['day']][$ttd['time_id']]=$ttd['subject_id'];
24 }
25 $ses_info = $wpdb->get_results("Select * from $wpsp_hours_table");
26 foreach($ses_info as $time){
27 $period_times[$time->id]=array('start'=>$time->begintime,'end'=>$time->endtime,'type'=>$time->type);
28 }
29 ?>
30 <section>
31
32 <div class="wpsp-row">
33 <div class="wpsp-col-md-12">
34 <table class="wpsp-table wpsp-table-bordered" id="timetable_table" cellspacing="0" width="100%" style="width:100%">
35 <thead>
36 <tr>
37 <th><?php esc_html_e( 'Week', 'wpschoolpress' ); ?></th>
38 <?php foreach ($session as $sess) { ?>
39 <th><?php echo isset( $period_times[$sess]['start'] ) ? esc_html($period_times[$sess]['start']) :'';
40 echo " - " ;
41 echo isset( $period_times[$sess]['end'] ) ? esc_html($period_times[$sess]['end']) :''; ?></th>
42 <?php
43 }
44 ?>
45 </tr>
46 </thead>
47 <tbody>
48 <?php
49 $week_days=array('1'=>'Monday','2'=>'Tuesday','3'=>'Wednesday','4'=>'Thursday','5'=>'Friday','6'=>'Saturday','7'=>'Sunday');
50 $leave_table = $wpdb->prefix . "wpsp_leavedays";
51 // $check = $wpdb->get_row("select description from $leave_table where class_id='" . esc_sql($class_id) . "'");
52 $check = $wpdb->get_row($wpdb->prepare("SELECT description FROM $leave_table WHERE class_id = %s",$class_id));
53 $wd = explode(',', $check->description);
54 for ($j = 1; $j <= 7; $j++) {
55 /* Sat-sun Off */
56 if (!empty($check)) {
57 if ($wd[0] == $week_days[$j]) {
58 continue;
59 }
60 if (isset($wd[1])) {
61 if ($wd[1] == $week_days[$j]) {
62 continue;
63 }
64 }
65 } /* Sat-sun Off */
66 if(empty($timetable[$j])){
67 continue;
68 }
69 ?>
70 <tr id="<?php echo esc_attr($j); ?>">
71 <td><span class="daynam"><?php echo esc_attr($week_days[$j]);?></span></td>
72 <?php
73 $subida = array();
74 $subida1 = array();
75 $subtimesloat = array();
76
77 // $get_heading = $wpdb->get_results("SELECT * from $tt_table where class_id='".esc_sql($class_id)."' and day = '$j' ORDER BY session_id ASC");
78 $get_heading = $wpdb->get_results($wpdb->prepare("SELECT * FROM $tt_table WHERE class_id = %s and day = %s ORDER BY session_id ASC",$class_id,$j));
79
80 foreach ($get_heading as $subid){
81 $subida[] = $subid->subject_id;
82 $subtimesloat[] = $subid->time_id;
83 $subida1[] = $subid->is_active;
84 reset($subida);
85 reset($subida1);
86 reset($subtimesloat);
87 }
88 $pa = 0;
89 foreach($session as $ses){
90 if($ses != $subtimesloat[$pa]){
91 // $hour_det = $wpdb->get_row("Select * from $wpsp_hours_table where id='$ses'");
92 $hour_det = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpsp_hours_table WHERE id = %s ",$ses));
93 $brk = $hour_det->type == "0" ? "Break" : "";
94 ?>
95 <td class = "<?php echo esc_attr($ses); ?> " tid="<?php echo esc_attr($subida[$pa]); ?>" data-sessionid="<?php echo esc_attr($key); ?>">
96 <?php echo $brk;?></td>
97
98 <?php
99 continue;
100 }
101 $ses_type = isset( $period_times[$ses]['type'] ) ? esc_html($period_times[$ses]['type']) :'';
102 if(isset($timetable[$j][$ses]))
103 $sub_id=$timetable[$j][$ses];
104 else
105 $sub_id='';
106 if ($sub_id == '') {
107 if($ses_type==0)
108 $sub_name = '<i>Break</i>';
109 else
110 $sub_name='-';
111 } else {
112 // $sub_name_f = $wpdb->get_results("SELECT sub_name from $subject_table where id=$subida[$pa]");
113 $sub_name_f = $wpdb->get_results($wpdb->prepare("SELECT sub_name FROM $subject_table WHERE id = %s ",$subida[$pa]));
114 if($subida1[$pa] == 1){
115 $sub_name = '-';
116 } else {
117 $sub_name = isset( $sub_name_f[0]->sub_name ) ? $sub_name_f[0]->sub_name : 'N/A';
118 }
119 }
120 ?>
121 <td class = "<?php echo esc_attr($subtimesloat[$pa]); ?> " tid="<?php echo esc_attr($subida[$pa]); ?>" data-sessionid="<?php echo esc_attr($key); ?>"> <?php echo esc_html($sub_name); ?> </td>
122 <?php
123 $pa++;
124 reset($subida);
125 reset($subida1);
126 reset($subtimesloat);
127 } ?>
128 </tr>
129 <?php
130 }
131 ?>
132 </tbody>
133 </table>
134 </div>
135 </div>
136 </section>
137 </div>
138 </div>
139 <?php
140 }
141 $response['msg'] = ob_get_clean();
142 return $response;
143 }?>