PluginProbe
School Management System – WPSchoolPress / 2.2.43
School Management System – WPSchoolPress v2.2.43
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-editTimetable.php

wpsp-editTimetable.php in School Management System – WPSchoolPress 2.2.43, at includes/wpsp-editTimetable.php

193 lines 10.5 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;
3 $tt_table = $wpdb->prefix. "wpsp_timetable";
4 $subject_table = $wpdb->prefix . "wpsp_subject";
5 $h_table = $wpdb->prefix . "wpsp_workinghours";
6 $class_id = intval($_GET['timetable']);
7 $sess_template = isset($_POST['sessions_template']) ? sanitize_text_field($_POST['sessions_template']) : '';
8 ?>
9 <!-- This form is used for Edit Timetable Form -->
10 <section class="content">
11 <div class="wpsp-row">
12 <div class="wpsp-col-md-12">
13 <div class="wpsp-card">
14 <div class="wpsp-card-head">
15 <h3 class="wpsp-card-title"><?php esc_html_e( 'Drag and Drop Subjects', 'wpschoolpress' );?> </h3>
16 </div>
17 <div class="wpsp-card-body">
18 <?php
19 //$check_tt = $wpdb->get_row("Select heading from $tt_table where class_id='".esc_sql($class_id)."' and heading!=''");
20 $check_tt = $wpdb->get_row($wpdb->prepare("SELECT heading FROM $tt_table WHERE class_id = %d and heading!= %s",$class_id,''));
21 $error = ''; $session = array();
22 if (!empty($check_tt)) {
23 $error = 0;
24 $get_sessions = unserialize($check_tt->heading);
25 foreach ($get_sessions as $sesio) {
26 $session[] = $sesio;
27 }
28 }else {
29 $error = 1;
30 echo "<div class='wpsp-text-red'>Can't fetch template from the selected class</div>";
31 }
32 if (count($session) > 0) {
33 // $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!=''");
34 $chck_hd = $wpdb->get_row($wpdb->prepare("SELECT * FROM $tt_table WHERE class_id = %d and time_id= %s and day = %s",$class_id,'0','0'));
35 if (empty($chck_hd)) {
36 //if(count($chck_hd) == null) {
37 $ins = $wpdb->insert($tt_table, array('class_id' => $class_id,'heading' => serialize($session)));
38 }
39 } else {
40 $error = 1;
41 echo "<div class='wpsp-text-red'>No Sessions Retrieved</div>";
42 }
43 $wpsp_hours_table = $wpdb->prefix . "wpsp_workinghours";
44 $wpsp_subjects_table = $wpdb->prefix . "wpsp_subject";
45 // $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");
46 $clt = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpsp_subjects_table WHERE class_id = %d or class_id= %s order by class_id desc",$class_id,'0'));
47 if( count($clt) == 0 ) {
48 $error = 1;
49 echo "<div class='wpsp-text-red'>No Subjects retrieved, Check you have subject for this class at <a href='".esc_url(site_url()."/wp-admin/admin.php?page=sch-subject")."'>Subjects</a></div>";
50 }
51 if( $error == 0 ) {
52 $timetable = array();
53 $tt_query = $wpdb->prepare("SELECT * FROM $tt_table WHERE class_id = %d and time_id != %s",$class_id,'0');
54 $tt_days = $wpdb->get_results($tt_query,ARRAY_A);
55 foreach( $tt_days as $ttd ) {
56 $timetable[$ttd['day']][$ttd['time_id']] = $ttd['subject_id'];
57 }
58 ?>
59 <div class="wpsp-row">
60 <div class="wpsp-col-md-12">
61 <div class="wpsp-form-group">
62 <label class="wpsp-labelMain">
63 <?php esc_html_e("Class","wpschoolpress");?> : <?php echo esc_html(wpsp_GetClassName( $class_id )); ?>
64 </label>
65 </div>
66 </div>
67 </div>
68 <div class="wpsp-form-group">
69 <?php
70 foreach ($clt as $id) {
71 echo '<div class="removesubject">
72 <div class="item" id="' . esc_attr($id->id) . '" style="width:auto; color:#5cb85c; font-weight:500;">' . esc_html($id->sub_name) . '
73 </div>
74 </div>';
75 }
76 ?>
77 </div>
78 <div class="text-right" id="ajax_response_exist" style="width: auto;float: right;text-align: center;"></div>
79 <div class="right wpsp-table-responsive" id="TimetableContainer">
80 <table class="wpsp-table wpsp-table-bordered" cellspacing="0" width="100%" style="width:100%">
81 <thead>
82 <tr>
83 <th>
84 </th>
85 <?php foreach ($session as $sess) { ?>
86 <th><?php $sess = esc_sql($sess);
87 // $ses_info = $wpdb->get_row("Select * from $wpsp_hours_table where id='$sess'");
88 $ses_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpsp_hours_table WHERE id = %s",$sess));
89 echo esc_html($ses_info->begintime . " to " . $ses_info->endtime) ?></th>
90 <?php } ?>
91 </tr>
92 </thead>
93 <tbody>
94 <?php
95 $dayname = array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");
96 $leave_table=$wpdb->prefix."wpsp_leavedays"; /* Sat-sun Off */
97 // $check = $wpdb->get_row("select description from $leave_table where class_id='".esc_sql($class_id)."'");
98 $check = $wpdb->get_row($wpdb->prepare("SELECT description FROM $leave_table WHERE class_id = %s",$class_id));
99 $wd = explode(',', $check->description);
100 for ($j = 1; $j <= 7; $j++) {
101 /* Sat-sun Off */
102 if (!empty($check)) {
103 if ($wd[0] == $dayname[$j-1]) {
104 continue;
105 }
106 if (isset($wd[1])) {
107 if ($wd[1] == $dayname[$j-1]) {
108 continue;
109 }
110 }
111 }/* Sat-sun Off */
112 ?>
113 <tr id="<?php echo esc_html($j); ?>">
114 <td>
115 <span class="daynam"><?php echo esc_html($dayname[$j - 1]); ?></span>
116 </td>
117 <?php
118 $subida = array();
119 $subida1 = array();
120 $subtimesloat = array();
121 // echo "SELECT * from $tt_table where class_id=$class_id and day = $j ORDER BY session_id ASC";
122 // $get_heading = $wpdb->get_results("SELECT * from $tt_table where class_id='".esc_sql($class_id)."' and day = '".esc_sql($j)."' ORDER BY session_id ASC");
123 $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));
124 foreach ($get_heading as $subid){
125 $subida[] = $subid->subject_id;
126 $subtimesloat[] = $subid->time_id;
127 $subida1[] = $subid->is_active;
128 reset($subida);
129 reset($subida1);
130 reset($subtimesloat);
131 }
132 $pa = 0;
133 foreach ($session as $key => $ses) {
134 $ses = esc_sql($ses);
135 if($ses != $subtimesloat[$pa]){
136 // $hour_det = $wpdb->get_row("Select * from $wpsp_hours_table where id='$ses'");
137 $hour_det = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpsp_hours_table WHERE id = %s",$ses));
138 $td_class = $hour_det->type == "1" ? "drop" : "Break";
139 ?>
140 <!-- <td class = "<//?php echo esc_attr($ses); ?> " tid="<//?php echo esc_attr($subida[$pa]); ?>" data-sessionid="<//?php echo esc_attr($key); ?>"> - </td> -->
141 <td class="<?php echo esc_attr($td_class); ?>" tid="<?php if(!empty($subida[$pa])) { echo esc_attr($subida[$pa]);}else{ echo esc_attr($ses);} ?>" data-sessionid="<?php echo esc_attr($key); ?>">
142 <?php if($td_class=='Break'){ echo esc_html($td_class,'wpschoolpress');}else{ '-';} ?>
143 </td>
144 <?php
145 continue;
146 }
147 // $hour_det = $wpdb->get_row("Select * from $wpsp_hours_table where id='$ses'");
148 $hour_det = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpsp_hours_table WHERE id = %s",$ses));
149 $td_class = $hour_det->type == "1" ? "drop" : "break";
150 $sub_id = $sub_name = '';
151 if( isset($timetable[$j][$ses]) )
152 $sub_id = $timetable[$j][$ses];
153 if( $sub_id >0 ) {
154 // $sub_name_f = $wpdb->get_results("SELECT sub_name from $subject_table where id=$subida[$pa]");
155 $sub_name_f = $wpdb->get_results($wpdb->prepare("SELECT sub_name FROM $subject_table WHERE id = %s",$subida[$pa]));
156 $sub_name = isset( $sub_name_f[0]->sub_name ) ? $sub_name_f[0]->sub_name : 'N/A';
157 }
158 if( !empty( $sub_name ) ) {
159 if($td_class == "break"){
160 $sub_name = '<div class="item1 assigned wpsp-assigned-item">Break<a href="javascript:void(0)" class="" data-id='. esc_attr($key).' data-rowid='.esc_attr($j).' ></a></div>';
161 } else {
162 if($subida1[$pa] == 1){
163 $sub_name = '-';
164 } else {
165 $sub_name = '<div class="item1 assigned wpsp-assigned-item">'.esc_attr($sub_name).'<a class="daleteid wpsp-tt-delete-icon" data-id='. esc_attr($key).' data-rowid='.esc_attr($j).' ></a></div>';
166 }
167 }
168 }
169 ?>
170 <td class="<?php echo esc_attr($td_class); ?>" tid="<?php echo esc_attr($ses); ?>" data-sessionid="<?php echo esc_attr($key); ?>"><?php echo wp_kses_post($sub_name); ?> </td>
171 <?php
172 $pa++;
173 } ?>
174 </tr>
175 <?php
176 }
177 ?>
178 </tbody>
179 </table>
180 <div class="wpsp-form-group">
181 <div class="wpsp-col-md-offset-10">
182 <input type="hidden" name="class_id" id="class_id" value="<?php echo esc_attr(intval($class_id)); ?>">
183 <div id="ajax_response"></div>
184 </div>
185 </div>
186 </div>
187 <?php } ?>
188 </div>
189 </div>
190 </div>
191 </div>
192 </section>
193 <!-- End of Edit Timetable Form -->