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 / pages / wpsp-dashboard.php

wpsp-dashboard.php in School Management System – WPSchoolPress 2.2.43, at pages/wpsp-dashboard.php

624 lines 30.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('No Such File');
3 wpsp_header();
4 if( is_user_logged_in() ) {
5 global $current_user, $wp_roles, $wpdb;
6 //get_currentuserinfo();
7 $propayment = wpsp_check_pro_version('pay_WooCommerce');
8 $propayment = !$propayment['status'] ? 'notinstalled' : 'installed';
9 $current_user_role=$current_user->roles[0];
10 if( $current_user_role == 'administrator' || $current_user_role == 'teacher' || $current_user_role == 'parent' || $current_user_role == 'student' ) {
11 wpsp_topbar();
12 wpsp_sidebar();
13 wpsp_body_start();
14 global $wpdb;
15 $user_table = $wpdb->prefix."users";
16 $student_table = $wpdb->prefix."wpsp_student";
17 $teacher_table = $wpdb->prefix."wpsp_teacher";
18 $class_table = $wpdb->prefix."wpsp_class";
19 $attendance_table = $wpdb->prefix."wpsp_attendance";
20 $usercount = $wpdb->get_row("SELECT count(sid) as countstudent FROM $student_table JOIN $user_table ON $user_table.ID = $student_table.wp_usr_id");
21 $teachercount = $wpdb->get_row("SELECT count(tid) as countteacher FROM $teacher_table JOIN $user_table ON $user_table.ID = $teacher_table.wp_usr_id");
22 $parentscount = $wpdb->get_row("SELECT count(sid) as countparents FROM $student_table JOIN $user_table ON $user_table.ID = $student_table.parent_wp_usr_id");
23 $users_count = $wpdb->get_row("SELECT(SELECT COUNT(*)FROM $student_table )AS stcount,(SELECT COUNT(*)FROM $teacher_table) AS tcount,(SELECT COUNT(DISTINCT parent_wp_usr_id) FROM $student_table where `parent_wp_usr_id`!='') AS pcount,(SELECT COUNT(*) FROM $class_table) AS clcount");
24 if( $current_user_role == 'parent') {
25 $paymenconfirmationid = 0;?> <?php $stable = $wpdb->prefix."wpsp_student";
26 $ctlass = $wpdb->prefix."wpsp_class";
27 $cteacher = $wpdb->prefix."wpsp_teacher";
28 $ftlass = $wpdb->prefix."wpsp_fees";
29 // $wpsp_classes =$wpdb->get_results("SELECT * FROM $stable where parent_wp_usr_id = '$current_user->ID'");
30 $wpsp_classes = $wpdb->get_results($wpdb->prepare("SELECT * FROM $stable WHERE parent_wp_usr_id = %d",$current_user->ID));
31 $args = array(
32 'post_type' => 'product',
33 'posts_per_page' => -1,
34
35 );
36 $siid = array();
37 $results = $wpdb->get_results("SELECT s.wp_usr_id,f.student_id,f.order_id FROM $stable AS s INNER JOIN $ftlass AS f ON f.student_id = s.wp_usr_id");
38 foreach($results as $res){
39 $siid[] = $res->wp_usr_id;
40 }
41 $productloop = new WP_Query( $args );
42 foreach ($wpsp_classes as $sclas) {
43 if (is_numeric($sclas->class_id)){
44 $classIDArray[] = $sclas->class_id;
45 }else{
46 $classIDArray = unserialize($sclas->class_id);
47 }
48 $classIDArray = array_map('intval', $classIDArray);
49 foreach ($classIDArray as $idsvalue){
50 $idsvalue = sanitize_text_field($idsvalue);
51 //$clasname = $wpdb->get_row("SELECT * FROM $ctlass where cid='".esc_sql($idsvalue)."'");
52 $clasname = $wpdb->get_row($wpdb->prepare("SELECT * FROM $ctlass WHERE cid = %d",$idsvalue));
53 if($clasname->c_fee_type == 'free'){
54 $nonemenu = 'nopayment-none';
55 }else {
56 //$wpsp_tech_data =$wpdb->get_results("SELECT * FROM $cteacher t INNER JOIN $ctlass c ON t.wp_usr_id=c.teacher_id where c.cid = '".esc_sql($idsvalue)."' and c.c_fee_type = 'paid'");
57 $wpsp_tech_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM $cteacher t INNER JOIN $ctlass c ON t.wp_usr_id=c.teacher_id WHERE c.cid = %d AND c.c_fee_type = %s",$idsvalue,'paid'));
58
59 $courses1 = get_user_meta($current_user->ID, '_pay_woocommerce_enrolled_class_access_counter');
60 $courses2 = get_user_meta($sclas->wp_usr_id, '_pay_woocommerce_enrolled_class_access_counter' );
61 $courses = array_merge($courses1,$courses2);
62 if ( ! empty( $courses ) ) {
63 $courses = maybe_unserialize( $courses );
64 } else {
65 $courses = array();
66 }
67 $courses_check=array();
68 $courses_value=array();
69 foreach($courses as $key => $value){
70 foreach($value as $key1 => $value1){
71 if(!empty($value1)){
72 $courses_check[] = $key1;
73 $courses_value[] = $value1;
74 }
75 }
76 }
77 if(in_array($sclas->wp_usr_id, $siid)){
78 echo"";
79 // echo $paymenconfirmationid;
80 }else{
81 echo "";
82 $paymenconfirmationid++;
83 // echo $paymenconfirmationid;
84 }
85 }
86 }
87 }
88 $nocount = 0;
89 // echo $paymenconfirmationid;
90 if($paymenconfirmationid > 0){
91 $nonemenu = ' nopayment-none1';
92 }else{
93 $nonemenu = ' nopayment-none';
94 }
95 $args = array(
96 'post_type' => 'product',
97 'posts_per_page' => -1
98 );
99 $obituary_query = new WP_Query($args);
100 while ($obituary_query->have_posts()) : $obituary_query->the_post();
101 global $product;
102 $product_title= get_the_title();
103 if (in_array('woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins')))) {
104 $currency = get_woocommerce_currency_symbol();
105 }
106 $price = get_post_meta( get_the_ID(), '_regular_price', true);
107 $courses1 = get_post_meta( get_the_ID(), '_related_class', true );
108 if ( ! empty( $courses1 ) ) {
109 $courses1 = maybe_unserialize( $courses1 );
110 } else {
111 $courses1 = array();
112 }
113 foreach($courses1 as $key => $value){
114 if(in_array($value, $classIDArray)){
115 $nocount++;
116 }
117 }
118 endwhile;
119 wp_reset_query();
120 ?> <style type="text/css">
121 .nopayment-none10 {
122 display: block !important;
123 }
124 </style>
125 <?php if($propayment == "installed"){ ?>
126 <table class="wpsp-table <?php echo esc_attr($nonemenu);?>" id="status-table" cellspacing="0" width="100%" style="width:100%;margin-bottom: 30px !important;">
127 <thead>
128 <tr>
129 <th><?php esc_html_e( 'Student Name', 'wpschoolpress' ); ?></th>
130 <th><?php esc_html_e( 'Roll No', 'wpschoolpress' ); ?></th>
131 <th><?php esc_html_e( 'Class Name', 'wpschoolpress' ); ?></th>
132 <th><?php esc_html_e( 'Class Teacher Name', 'wpschoolpress' ); ?></th>
133 <th><?php esc_html_e( 'Class Fee Status', 'wpschoolpress' ); ?></th>
134 <th><?php esc_html_e( 'Fees For', 'wpschoolpress' ); ?></th>
135 <th><?php esc_html_e( 'Pay Now', 'wpschoolpress' ); ?></th>
136 </tr>
137 </thead>
138 <tbody> <?php
139 }
140 $siid = array();
141 $results = $wpdb->get_results("SELECT s.wp_usr_id,f.student_id,f.order_id FROM $stable AS s INNER JOIN $ftlass AS f ON f.student_id = s.wp_usr_id");
142 foreach($results as $res){
143 $siid[] = $res->wp_usr_id;
144 }
145 foreach ($wpsp_classes as $sclas) {
146 if (is_numeric($sclas->class_id)){
147 $classIDArray[] = $sclas->class_id;
148 }else{
149 $classIDArray = unserialize($sclas->class_id);
150 }
151 $classIDArray = array_map('intval', $classIDArray);
152 foreach ($classIDArray as $idsvalue){
153 $idsvalue = sanitize_text_field($idsvalue);
154 // $clasname = $wpdb->get_row("SELECT * FROM $ctlass where cid='".esc_sql($idsvalue)."'");
155 $clasname = $wpdb->get_row($wpdb->prepare("SELECT * FROM $ctlass WHERE cid = %d",$idsvalue));
156 if($clasname->c_fee_type == 'free'){
157 $nonemenu = 'nopayment-none';
158 }else {
159 // $wpsp_tech_data =$wpdb->get_results("SELECT * FROM $cteacher t INNER JOIN $ctlass c ON t.wp_usr_id=c.teacher_id where c.cid = '".esc_sql($idsvalue)."' and c.c_fee_type = 'paid'");
160 $wpsp_tech_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM $cteacher t INNER JOIN $ctlass c ON t.wp_usr_id=c.teacher_id WHERE c.cid = %d AND c.c_fee_type = %s",$idsvalue,'paid'));
161 $courses1 = get_user_meta($current_user->ID, '_pay_woocommerce_enrolled_class_access_counter');
162 $courses2 = get_user_meta($sclas->wp_usr_id, '_pay_woocommerce_enrolled_class_access_counter' );
163 $courses = array_merge($courses1,$courses2);
164 if ( ! empty( $courses ) ) {
165 $courses = maybe_unserialize( $courses );
166 } else {
167 $courses = array();
168 }
169 $courses_check=array();
170 $courses_value=array();
171 foreach($courses as $key => $value){
172 foreach($value as $key1 => $value1){
173 if(!empty($value1)){
174 $courses_check[] = $key1;
175 $courses_value[] = $value1;
176 }
177 }
178 }
179 if(in_array($idsvalue, $courses_check)){
180 }else{
181 $paymenconfirmationid++;
182 }
183 if($paymenconfirmationid > 0){
184 $nonemenu = ' nopayment-none';
185 }else{
186 $nonemenu = ' nopayment-none1';
187 }
188 $courses_valu_final = array();
189 foreach($courses_value as $key => $value){
190 foreach($value as $key1 => $value1){
191 $courses_valu_final[] = $value1;
192 }
193 }
194 $product_id=array();
195 foreach($courses_valu_final as $key => $value ){
196 $order = wc_get_order($value);
197 $items = $order->get_items();
198 foreach ( $items as $item ){
199 $product_id[] = $item['product_id'];
200 }
201 }
202 if ( $productloop->have_posts() ) :
203 while ( $productloop->have_posts() ) : $productloop->the_post();
204 global $product;
205 $product_title= get_the_title();
206 if (in_array('woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins')))) {
207 $currency = get_woocommerce_currency_symbol();
208 }
209 $price = get_post_meta( get_the_ID(), '_sale_price', true ) ?: get_post_meta( get_the_ID(), '_price', true );
210 $courses1 = get_post_meta( get_the_ID(), '_related_class', true );
211 // echo "<pre>";print_r($courses_check);
212 // echo "<pre>";print_r($siid);
213 if ( ! empty( $courses1 ) ) {
214 $courses1 = maybe_unserialize( $courses1 );
215 } else {
216 $courses1 = array();
217 }
218 foreach($courses1 as $key => $value){
219 if(!in_array($sclas->wp_usr_id, $siid)){
220 if(in_array($value, $classIDArray)){
221 $stable=$wpdb->prefix."wpsp_student";
222 $ctlass=$wpdb->prefix."wpsp_class";
223 $cteacher =$wpdb->prefix."wpsp_teacher";
224 // $wpsp_cls_data =$wpdb->get_results("SELECT * FROM $ctlass where cid = '".$value."' and c_fee_type = 'paid'");
225 $wpsp_cls_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM $ctlass WHERE cid = %d and c_fee_type=%s",$value,'paid'));
226 if($propayment == "installed"){
227 ?>
228 <tbody>
229 <tr>
230 <td><?php echo esc_html($sclas->s_fname.' '.$sclas->s_lname);?></td>
231 <td><?php echo esc_html($sclas->s_rollno);?></td>
232 <td><?php echo esc_html($wpsp_cls_data[0]->c_name);?></td>
233 <td><?php echo esc_html($wpsp_tech_data[0]->first_name.' '.$wpsp_tech_data[0]->last_name);?></td>
234 <td><?php echo esc_html('Not Paid','wpschoolpress')?> </td>
235 <td><?php echo esc_html($product_title);?></td>
236 <td><a class="wpsp-btn" href="<?php echo esc_url(get_permalink());?>?sid=<?php echo esc_attr($sclas->wp_usr_id);?>&cid=<?php echo esc_attr($value);?>" target="_blank"> <?php echo esc_html($currency."".$price) ;?> <?php echo esc_html('Pay Now','wpschoolpress');?></a></td>
237 </tr>
238 </tbody> <?php
239 }
240 }
241 }
242 }
243 endwhile;
244 break;
245 wp_reset_query();
246 endif;
247 }
248 }
249 }
250 ?>
251 </tbody>
252 </table> <?php
253 }
254
255 if( $current_user_role == 'student') {
256
257 $stable=$wpdb->prefix."wpsp_student";
258 $ctlass=$wpdb->prefix."wpsp_class";
259 $user_id = esc_sql($current_user->ID);
260 // $wpsp_stud_data = $wpdb->get_results("SELECT s.class_id,s.parent_wp_usr_id FROM $stable s INNER JOIN $ctlass c where s.wp_usr_id = '".$user_id."' and c.c_fee_type = 'paid'");
261 $wpsp_tech_data = $wpdb->get_results($wpdb->prepare("SELECT s.class_id,s.parent_wp_usr_id FROM $stable s INNER JOIN $ctlass c WHERE s.wp_usr_id = %d AND c.c_fee_type = %s",$user_id,'paid'));
262 $cid = [];
263
264 if(!empty($wpsp_stud_data)){
265 if(is_numeric($wpsp_stud_data[0]->class_id) ){
266 $cid[] = $wpsp_stud_data[0]->class_id;
267 }else{
268 $class_id_array = unserialize( $wpsp_stud_data[0]->class_id );
269 foreach($class_id_array as $id){
270 $cid[] = $id;
271 }
272 }
273 }
274 if($propayment == "installed"){
275 $cteacher =$wpdb->prefix."wpsp_teacher";
276 $paymenconfirmationid = 0;
277 $class_id_array = array_map('intval', $class_id_array);
278 foreach ($class_id_array as $id ){
279 $id = esc_sql($id);
280 //$clasname = $wpdb->get_row("SELECT * FROM $ctlass where cid='".$id."'");
281 $clasname = $wpdb->get_row($wpdb->prepare("SELECT * FROM $ctlass WHERE cid = %d",$id));
282 if($clasname->c_fee_type == 'free'){
283 $nonemenu = 'nopayment-none';
284 } else {
285 // $wpsp_tech_data =$wpdb->get_results("SELECT * FROM $cteacher t INNER JOIN $ctlass c ON t.wp_usr_id=c.teacher_id where c.cid = '".$id."' and c.c_fee_type = 'paid'");
286 $wpsp_tech_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM $cteacher t INNER JOIN $ctlass c ON t.wp_usr_id=c.teacher_id WHERE c.cid = %d AND c.c_fee_type = %s",$id,'paid'));
287 $courses1 = get_user_meta($wpsp_stud_data[0]->parent_wp_usr_id, '_pay_woocommerce_enrolled_class_access_counter' );
288 $courses2 = get_user_meta( $user_id, '_pay_woocommerce_enrolled_class_access_counter' );
289 $courses = array_merge($courses1,$courses2);
290 if ( ! empty( $courses ) ) {
291 $courses = maybe_unserialize( $courses );
292 } else {
293 $courses = array();
294 }
295 $courses_check=array();
296 foreach($courses as $key => $value){
297 foreach($value as $key1 => $value1) {
298 if(!empty($value1)){
299 $courses_check[] = $key1;
300 }
301 }
302 }
303 if(in_array($id, $courses_check)){
304 }else{
305 $paymenconfirmationid++;
306 }
307 }
308 }
309 if($paymenconfirmationid > 0){
310 $nonemenu = ' nopayment1-none1';
311 }else {
312 $nonemenu = ' nopayment-none';
313 }
314 $args = array(
315 'post_type' => 'product',
316 'posts_per_page' => -1
317 );
318 $obituary_query = new WP_Query($args);
319 while ($obituary_query->have_posts()) : $obituary_query->the_post();
320 global $product;
321 $product_title= get_the_title();
322 if (in_array('woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins')))) {
323 $currency = get_woocommerce_currency_symbol();
324 }
325 $price = get_post_meta( get_the_ID(), '_regular_price', true);
326 $courses1 = get_post_meta( get_the_ID(), '_related_class', true );
327
328 if ( ! empty( $courses1 ) ) {
329 $courses1 = maybe_unserialize( $courses1 );
330 } else {
331 $courses1 = array();
332 }
333 foreach($courses1 as $key => $value){
334 if(in_array($value, $cid)){
335 $nocount++;
336 }
337 }
338
339 endwhile;
340
341 wp_reset_query();
342 if($nocount > 0){
343 $nonemenu = ' nopayment-none1';
344 }else{
345 $nonemenu = ' nopayment-none';
346 }
347
348 ?>
349 <table class="wpsp-table <?php echo esc_attr($nonemenu); ?>" id="status-table" cellspacing="0" width="100%" style="width:100%;margin-bottom: 30px !important;">
350 <thead>
351 <tr>
352 <th><?php esc_html_e( 'Student Name', 'wpschoolpress' ); ?></th>
353 <th><?php esc_html_e( 'Roll No', 'wpschoolpress' ); ?></th>
354 <th><?php esc_html_e( 'Class Name', 'wpschoolpress' ); ?></th>
355 <th><?php esc_html_e( 'Class Teacher Name', 'wpschoolpress' ); ?></th>
356 <th><?php esc_html_e( 'Class Fee Status', 'wpschoolpress' ); ?></th>
357 <th><?php esc_html_e( 'Fees For', 'wpschoolpress' ); ?></th>
358 <th><?php esc_html_e( 'Pay Now', 'wpschoolpress' );?></th>
359 </tr>
360 </thead> <?php
361 }
362
363 if($propayment == "installed"){
364
365 // $wpsp_tech_data =$wpdb->get_results("SELECT * FROM $cteacher t INNER JOIN $ctlass c ON t.wp_usr_id=c.teacher_id where c.cid = '".$cid."' and c.c_fee_type = 'paid'");
366 $wpsp_tech_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM $cteacher t INNER JOIN $ctlass c ON t.wp_usr_id=c.teacher_id WHERE c.cid = %d AND c.c_fee_type = %s",$id,'paid'));
367 if ( ! empty( $courses ) ) {
368 $courses = maybe_unserialize( $courses );
369 } else {
370 $courses = array();
371 }
372 $courses_check=array();
373 $courses_value=array();
374 foreach($courses as $key => $value){
375 foreach($value as $key1 => $value1){
376 if(!empty($value1)){
377 $courses_check[] = $key1;
378 $courses_value[] = $value1;
379 }
380 }
381 }
382 $courses_valu_final = array();
383 foreach($courses_value as $key => $value){
384 foreach($value as $key1 => $value1){
385 $courses_valu_final[] = $value1;
386 }
387 }
388 $product_id=array();
389 foreach($courses_valu_final as $key => $value ){
390 $order = wc_get_order($value);
391 $items = $order->get_items();
392 foreach($items as $item ){
393 $product_id[] = $item['product_id'];
394 }
395 }
396 if(!empty($cid)){
397 foreach($cid as $cid1){
398 if(in_array($cid1, $courses_check)){
399 $nonemenu = ' nopayment1-none1';
400 } else {
401 $nonemenu = ' nopayment-none';
402 }
403 }
404 }
405 $args = array('post_type' => 'product',
406 'posts_per_page' => -1);
407 $obituary_query = new WP_Query($args);
408 while ($obituary_query->have_posts()) : $obituary_query->the_post();
409 global $product;
410 $product_title= get_the_title();
411 if (in_array('woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins')))) {
412 $currency = get_woocommerce_currency_symbol();
413 }
414 $price = get_post_meta( get_the_ID(), '_regular_price', true);
415 $courses1 = get_post_meta( get_the_ID(), '_related_class', true );
416 if ( ! empty( $courses1 ) ) {
417 $courses1 = maybe_unserialize( $courses1 );
418 } else {
419 $courses1 = array();
420 }
421 foreach($courses1 as $key => $value){
422 if(!in_array(get_the_ID(), $product_id)){
423 if(in_array($value, $cid)){
424 $stable=$wpdb->prefix."wpsp_student";
425 $ctlass=$wpdb->prefix."wpsp_class";
426 $cteacher =$wpdb->prefix."wpsp_teacher";
427 // $wpsp_stud_data =$wpdb->get_results("SELECT * FROM $stable s INNER JOIN $ctlass c where s.wp_usr_id = '".$user_id."' and c.c_fee_type = 'paid' and c.cid = ".$value);
428 $wpsp_stud_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM $stable s INNER JOIN $ctlass c WHERE s.wp_usr_id = %d AND c.c_fee_type = %s and c.cid = %d",$user_id,'paid',$value));
429
430 // $wpsp_tech_data =$wpdb->get_results("SELECT * FROM $cteacher t INNER JOIN $ctlass c ON t.wp_usr_id=c.teacher_id where c.cid = '".$value."' and c.c_fee_type = 'paid'");
431 $wpsp_tech_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM $cteacher t INNER JOIN $ctlass c ON t.wp_usr_id=c.teacher_id WHERE c.cid = %d AND c.c_fee_type = %s",$value,'paid'));
432 if($propayment == "installed"){ ?>
433 <tbody>
434 <tr>
435 <td><?php echo esc_html($wpsp_stud_data[0]->s_fname.' '.$wpsp_stud_data[0]->s_lname);?></td>
436 <td><?php echo esc_html($wpsp_stud_data[0]->s_rollno);?></td>
437 <td> <?php echo esc_html($wpsp_stud_data[0]->c_name);?></td>
438 <td> <?php echo esc_html($wpsp_tech_data[0]->first_name.' '.$wpsp_tech_data[0]->last_name);?></td>
439 <td><?php esc_html_e( 'Not Paid', 'wpschoolpress' ); ?></td>
440 <td> <?php echo esc_html($product_title);?></td>
441 <td><a class="wpsp-btn" href="<?php echo esc_url(get_permalink());?>" target="_blank"><?php echo esc_html($currency."".$price) ;?> <?php esc_html_e( 'Pay Now', 'wpschoolpress' ); ?></a></td>
442 </tr>
443 </tbody>
444 <?php
445 }
446 $nonemenu = ' nopayment-none';
447 }
448 }
449 }
450 endwhile;
451 wp_reset_query();
452 }
453 }
454 if($propayment == "installed"){
455 if( $current_user_role == 'student') {
456 if($nocount > 0){?>
457 </table>
458 <?php } else {
459 ?> </table> <?php
460 }
461 }
462 }
463 if($propayment != "installed"){
464 $nonemenu='';
465 }
466 if( $current_user_role=='administrator' || $current_user_role == 'parent'){?> <div class="wpsp-row "><?php } else { ?> <div class="wpsp-row"> <?php } ?> <div class="wpsp-col-sm-3 wpsp-col-xs-6">
467 <a class="wpsp-colorBox" <?php if($current_user_role == 'parent' || $current_user_role == 'student'){ }else {?> href="<?php echo esc_url(wpsp_admin_url());?>sch-student" <?php } ?>>
468 <span class="wpsp-colorBox-title"><?php echo esc_html(apply_filters('wpsp_sidebar_student_title_menu','Students'),'wpschoolpress'); ?></span>
469 <h4 class="wpsp-colorBox-head"><?php echo isset( $usercount->countstudent ) ? intval($usercount->countstudent) : 0; ?><sup>+</sup></h4>
470 </a>
471 </div>
472 <div class="wpsp-col-sm-3 wpsp-col-xs-6">
473 <a class="wpsp-colorBox wpsp-orangebox wpsp-teacherInfo" <?php if($current_user_role == 'parent' || $current_user_role == 'student'){ }else {?> href="<?php echo esc_url(wpsp_admin_url());?>sch-teacher" <?php } ?>>
474 <span class="wpsp-colorBox-title"><?php echo esc_html(apply_filters('wpsp_sidebar_teacher_title_menu','Teachers'),'wpschoolpress'); ?></span>
475 <h4 class="wpsp-colorBox-head"><?php echo isset($teachercount->countteacher) ? intval($teachercount->countteacher) : 0; ?><sup>+</sup></h4>
476 </a>
477 </div>
478 <div class="wpsp-col-sm-3 wpsp-col-xs-6">
479 <a class="wpsp-colorBox wpsp-yellowbox wpsp-parentsInfo" <?php if($current_user_role == 'parent' || $current_user_role == 'student'){ }else {?> href="<?php echo esc_url(wpsp_admin_url());?>sch-parent" <?php } ?>>
480 <span class="wpsp-colorBox-title"><?php echo esc_html(apply_filters('wpsp_sidebar_parent_title_menu','Parents'),'wpschoolpress'); ?></span>
481 <h4 class="wpsp-colorBox-head"><?php echo isset($parentscount->countparents) ? intval($parentscount->countparents) : 0; ?><sup>+</sup></h4>
482 </a>
483 </div>
484 <div class="wpsp-col-sm-3 wpsp-col-xs-6">
485 <a class="wpsp-colorBox wpsp-greenbox wpsp-classInfo" <?php if($current_user_role == 'parent' || $current_user_role == 'student'){ }else {?> href="<?php echo esc_url(wpsp_admin_url());?>sch-class" <?php } ?>>
486 <span class="wpsp-colorBox-title"><?php echo esc_html(apply_filters('wpsp_sidebar_classes_title_menu','Classes'),'wpschoolpress');?></span>
487 <h4 class="wpsp-colorBox-head"><?php echo isset( $users_count->clcount ) ? intval($users_count->clcount) : 0; ?><sup>+</sup></h4>
488 </a>
489 </div>
490 </div>
491 <!-- Info boxes --> <?php if( $current_user_role=='administrator' || $current_user_role == 'parent' ){?> <div class="wpsp-row "><?php } else { ?> <div class="wpsp-row"> <?php } ?>
492 <!-- Left col -->
493 <div class="wpsp-col-lg-8 wpsp-col-xs-12">
494 <div class="wpsp-card">
495 <div class="wpsp-card-head">
496 <div class="wpsp-left">
497 <h3 class="wpsp-card-title"><?php esc_html_e( 'Activities Calendar', 'wpschoolpress' )?></h3>
498 </div>
499 <ul class="wpsp-cards-indicators wpsp-right">
500 <li><span class="wpsp-indic wpsp-blue-indic"></span> <?php esc_html_e( 'Events', 'wpschoolpress' ); ?></li>
501 <li><span class="wpsp-indic wpsp-red-indic"></span> <?php esc_html_e( 'Exams', 'wpschoolpress' ); ?></li>
502 <li><span class="wpsp-indic wpsp-green-indic"></span> <?php esc_html_e( 'Holidays', 'wpschoolpress' );?></li>
503 </ul>
504 </div>
505 <div class="wpsp-card-body">
506 <div id="multiple-events"></div>
507 </div>
508 </div>
509 </div>
510 <div class="wpsp-col-lg-4 wpsp-col-xs-12">
511 <div class="wpsp-card">
512 <div class="wpsp-card-head">
513 <h3 class="wpsp-card-title"><?php esc_html_e( 'Exam', 'wpschoolpress' )?></h3>
514 </div>
515 <div class="wpsp-card-body"> <?php if($current_user_role == 'student' ) {
516 $current_user_id = get_current_user_id();
517 $Student_table=$wpdb->prefix."wpsp_student";
518
519 // $examinfo=$wpdb->get_row("select class_id from $Student_table where wp_usr_id = '$current_user_id'");
520 $examinfo = $wpdb->get_row($wpdb->prepare("SELECT class_id FROM $Student_table WHERE wp_usr_id = %d",$current_user_id));
521 $examclassid = unserialize($examinfo->class_id);
522
523 $exam_table=$wpdb->prefix."wpsp_exam";
524 foreach($examclassid as $class_id ) {
525 //$examinfo = $wpdb->get_results("select * from $exam_table where classid = '$class_id' order by e_s_date ASC");
526 $examinfo = $wpdb->get_results($wpdb->prepare("SELECT * FROM $exam_table WHERE classid = %d order by e_s_date ASC",$class_id));
527 }
528 if(!empty($examinfo)){
529 ?> <table class="wpsp-table">
530 <thead>
531 <tr>
532 <th><?php esc_html_e( 'Date', 'wpschoolpress' );?></th>
533 <th><?php esc_html_e( 'Exam', 'wpschoolpress' );?></th>
534 </tr>
535 </thead>
536 <tbody> <?php foreach($examinfo as $exam) { ?> <tr>
537 <td><?php echo esc_html(wpsp_ViewDate($exam->e_s_date),'wpschoolpress')." TO ".esc_html(wpsp_ViewDate($exam->e_e_date),'wpschoolpress');?></td>
538 <td><?php echo esc_html($exam->e_name); ?></td>
539 </tr> <?php } ?> </tbody>
540 </table> <?php } } elseif($current_user_role == 'parent')
541 {
542 $parentexam = array();
543 $clasid = array();
544 $current_user_id = get_current_user_id();
545 $Student_table=$wpdb->prefix."wpsp_student";
546
547 //$examinfo=$wpdb->get_results("select * from $Student_table where parent_wp_usr_id = '$current_user_id'");
548 $examinfo = $wpdb->get_results($wpdb->prepare("SELECT * FROM $Student_table WHERE parent_wp_usr_id = %d",$current_user_id));
549
550 foreach($examinfo as $class_id_f ) {
551 $parentexam[] = $class_id_f->class_id;
552 }
553
554 foreach($parentexam as $parray){
555
556 $examclassid = unserialize($parray);
557
558 $exam_table=$wpdb->prefix."wpsp_exam";
559 foreach($examclassid as $class_id ) {
560
561 $clasid[] = $class_id;
562
563 }
564 }
565
566 // $parentchildcls = explode(',', $clasid);
567
568 $parentchildcls = array_map('intval', $clasid); // sanitize integers
569 $in_placeholders = implode(',', array_fill(0, count($parentchildcls), '%d'));
570 // $examinfo = $wpdb->get_results("select * from $exam_table where classid IN (".$parentchildcls.") order by e_s_date ASC");
571 $query = $wpdb->prepare("SELECT * FROM $exam_table WHERE classid IN ($in_placeholders) ORDER BY e_s_date ASC", ...$parentchildcls);
572 $examinfo = $wpdb->get_results($query);
573
574
575 if(!empty($examinfo)){
576 ?> <table class="wpsp-table">
577 <thead>
578 <tr>
579 <th><?php esc_html_e( 'Date', 'wpschoolpress' );?></th>
580 <th><?php esc_html_e( 'Exam', 'wpschoolpress' );?></th>
581 </tr>
582 </thead>
583 <tbody> <?php foreach($examinfo as $exam) { ?> <tr>
584 <td><?php echo esc_html(wpsp_ViewDate($exam->e_s_date),'wpschoolpress')." TO ".esc_html(wpsp_ViewDate($exam->e_e_date),'wpschoolpress');?></td>
585 <td><?php echo esc_html($exam->e_name); ?></td>
586 </tr> <?php } ?> </tbody>
587 </table> <?php }}else {
588 $exam_table=$wpdb->prefix."wpsp_exam";
589 $class_table=$wpdb->prefix."wpsp_class";
590
591 $examinfo=$wpdb->get_results("SELECT u.*, c.*
592 FROM $exam_table u
593 INNER JOIN $class_table c ON u.classid= c.cid
594 order by u. e_s_date ASC");
595 if(!empty($examinfo)){?> <table class="wpsp-table">
596 <thead>
597 <tr>
598 <th><?php esc_html_e( 'Date', 'wpschoolpress' );?></th>
599 <th><?php esc_html_e( 'Exam', 'wpschoolpress' );?></th>
600 </tr>
601 </thead>
602 <tbody> <?php foreach($examinfo as $exam) { ?> <tr>
603 <td><?php echo esc_html(wpsp_ViewDate($exam->e_s_date),'wpschoolpress')." TO ".esc_html(wpsp_ViewDate($exam->e_e_date),'wpschoolpress');?></td>
604 <td><?php echo esc_html($exam->e_name."(".$exam->c_name.")"); ?></td>
605 </tr> <?php } ?> </tbody>
606 </table> <?php } } ?> </div>
607 </div>
608 </div>
609 </div>
610 <div id="eventContent" title="Event Details" style="display:none;">
611 <div class="modal-content">
612 <span class="close">&times;</span>
613 <h4><?php esc_html_e( 'Event Name', 'wpschoolpress' )?> : <span id="viewEventTitle"></span></h4> <?php esc_html_e( 'Start', 'wpschoolpress' );?>: <span id="eventStart"></span><br> <?php esc_html_e( 'End', 'wpschoolpress' );?>: <span id="eventEnd"></span><br>
614 </div>
615 </div> <?php
616 wpsp_body_end();
617 wpsp_footer();
618 } else {
619 echo esc_html(WPSP_PERMISSION_MSG,'wpschoolpress');
620 }
621 } else {
622 include_once( WPSP_PLUGIN_PATH .'/includes/wpsp-login.php');
623 }
624 ?>