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-parentList.php

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

221 lines 14.3 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 $proversion = wpsp_check_pro_version();
4 $proclass = !$proversion['status'] && isset( $proversion['class'] )? $proversion['class'] : '';
5 $protitle = !$proversion['status'] && isset( $proversion['message'] )? $proversion['message'] : '';
6 $prodisable = !$proversion['status'] ? 'disabled="disabled"' : '';
7 $parentFieldList = array( 'p_fname' => __('First Name', 'wpschoolpress'),
8 'p_mname' => __('Middle Name', 'wpschoolpress'),
9 'p_lname' => __('Last Name', 'wpschoolpress'),
10 's_fname' => __('Student Name', 'wpschoolpress'),
11 'user_email' => __('Parent Email ID', 'wpschoolpress'),
12 'p_edu' => __('Education', 'wpschoolpress'),
13 'p_gender' => __('Gender', 'wpschoolpress'),
14 'p_profession' => __('Profession', 'wpschoolpress'),
15 'p_bloodgrp' => __('Blood Group', 'wpschoolpress'),
16 );
17 $sel_classid = isset( $_POST['ClassID'] ) ? sanitize_text_field($_POST['ClassID']) : '';
18 $class_table = $wpdb->prefix."wpsp_class";
19 $classQuery = "select cid,c_name from $class_table Order By cid ASC";
20 $sel_class = $wpdb->get_results( $classQuery );
21 global $current_user;
22 $role = $current_user->roles;
23 $cuserId = $current_user->ID;
24 ?>
25 <!-- This file form is used for ParentList -->
26 <div class="wpsp-card">
27 <div class="wpsp-card-head">
28 <div class="subject-inner wpsp-left wpsp-class-filter">
29 <form name="ClassForm" id="ClassForm" method="post" action="">
30 <label class="wpsp-labelMain"><?php esc_html_e( 'Select Class Name', 'wpschoolpress' );?></label>
31 <select name="ClassID" id="ClassID" class="wpsp-form-control">
32 <option value="all" <?php if($sel_classid=='all') echo esc_html("selected","wpschoolpress"); ?>><?php echo esc_html("All","wpschoolpress");?></option> <?php
33 foreach( $sel_class as $classes ) { ?> <option value="<?php echo esc_attr($classes->cid);?>" <?php if($sel_classid==$classes->cid) echo esc_html("selected","wpschoolpress"); ?>> <?php echo esc_html($classes->c_name);?> </option> <?php }
34 if($current_user_role=='administrator' ) { ?> <?php } ?>
35 </select>
36 </form>
37 </div>
38 <div class="wpsp-right wpsp-import-export">
39 <div class="wpsp-btn-lists" title="<?php echo esc_attr($protitle);?>" <?php echo esc_html($prodisable);?>> <?php if ( in_array( 'teacher', $role ) ) {?> <div class="wpsp-btn-list" <?php if($proversion['status'] != "1") {?> wpsp-tooltip="<?php echo esc_attr($protitle);?>" <?php } ?>>
40 <div class="wpsp-button-group wpsp-dropdownmain wpsp-left">
41 <button type="button" class="wpsp-btn wpsp-btn-success print" id="PrintParent" <?php echo esc_html($prodisable);?> title="<?php //echo esc_attr($protitle);?>">
42 <i class="fa fa-print"></i> <?php echo esc_html("Print","wpschoolpress");?></button>
43 <button type="button" class="wpsp-btn wpsp-btn-success wpsp-dropdown-toggle" <?php echo esc_html($prodisable);?> title="<?php //echo esc_attr($protitle);?>">
44 <!--
45 <span class="caret"></span>
46 <span class="sr-only">Toggle Dropdown</span> -->
47 </button>
48 <div class="wpsp-dropdown wpsp-dropdown-md">
49 <ul>
50 <form id="ParentColumnForm" name="ParentColumnForm">
51 <li class="wpsp-drop-title wpsp-checkList"> <?php echo esc_html("Select Columns to Print","wpschoolpress");?></li> <?php foreach( $parentFieldList as $key=>$value ) { ?> <li class="wpsp-checkList">
52 <input type="checkbox" name="ParentColumn[]" value="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" checked="checked">
53 <label class="wpsp-label" for="<?php echo esc_attr($key); ?>"><?php echo esc_html($value); ?></label>
54 </li> <?php } ?> <?php $currentSelectClass = isset($_POST['ClassID']) ? intval($_POST['ClassID']) : '0'; ?> <input type="hidden" name="ClassID" value="<?php echo esc_attr($currentSelectClass); ?>">
55 </form>
56 </ul>
57 </div>
58 </div>
59 </div>
60 <div class="wpsp-btn-list" <?php if($proversion['status'] != "1") {?> wpsp-tooltip="<?php echo esc_attr($protitle);?>" <?php } ?>>
61 <div class="psp-dropdownmain wpsp-button-group">
62 <button type="button" class="wpsp-btn print" id="ExportParents" <?php echo esc_html($prodisable);?> title="<?php echo esc_attr($protitle);?>"><i class="fa fa-upload"></i> <?php echo esc_html("Export","wpschoolpress");?> </button>
63 <button type="button" class="wpsp-btn wpsp-btn-blue wpsp-dropdown-toggle" <?php echo esc_html($prodisable);?> title="<?php echo esc_attr($protitle);?>">
64 <!-- <span class="caret"></span>
65 <span class="sr-only">Toggle Dropdown</span> -->
66 </button>
67 <div id="exportcontainer" style="display:none;"></div>
68 <div class="wpsp-dropdown wpsp-dropdown-md wpsp-dropdown-right">
69 <ul>
70 <form id="ExportColumnForm" name="ExportParentColumn" method="POST">
71 <li class="wpsp-drop-title wpsp-checkList"> <?php echo esc_html("Select Columns to Export","wpschoolpress");?></li> <?php foreach( $parentFieldList as $key=>$value ) { ?> <li class="wpsp-checkList">
72 <input type="checkbox" name="ParentColumn[]" value="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" checked="checked">
73 <label for="<?php echo esc_attr($key); ?>"><?php echo esc_html($value); ?></label>
74 </li> <?php } ?> <?php $currentSelectClass = isset($_POST['ClassID']) ? intval($_POST['ClassID']) : '0'; ?> <input type="hidden" name="ClassID" value="<?php echo esc_attr($currentSelectClass); ?>">
75 <input type="hidden" name="exportparent" value="exportparent">
76 </form>
77 </ul>
78 </div>
79 </div>
80 </div> <?php } ?> <?php if ( in_array( 'administrator', $role ) ) {?> <div class="wpsp-btn-list" <?php if($proversion['status'] != "1") {?> wpsp-tooltip="<?php echo esc_attr($protitle);?>" <?php } ?>>
81 <div class="wpsp-button-group wpsp-dropdownmain wpsp-left">
82 <button type="button" class="wpsp-btn wpsp-btn-success print" id="PrintParent" <?php echo esc_html($prodisable);?> title="<?php //echo $protitle;?>">
83 <i class="fa fa-print"></i> <?php echo esc_html("Print","wpschoolpress");?> </button>
84 <button type="button" class="wpsp-btn wpsp-btn-success wpsp-dropdown-toggle" <?php echo esc_html($prodisable);?> title="<?php //echo $protitle;?>">
85 <!--
86 <span class="caret"></span>
87 <span class="sr-only">Toggle Dropdown</span> -->
88 </button>
89 <div class="wpsp-dropdown wpsp-dropdown-md">
90 <ul>
91 <form id="ParentColumnForm" name="ParentColumnForm">
92 <li class="wpsp-drop-title wpsp-checkList"> <?php echo esc_html("Select Columns to Print","wpschoolpress");?></li> <?php foreach( $parentFieldList as $key=>$value ) { ?> <li class="wpsp-checkList">
93 <input type="checkbox" name="ParentColumn[]" value="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" checked="checked">
94 <label class="wpsp-label" for="<?php echo esc_attr($key); ?>"><?php echo esc_html($value); ?></label>
95 </li> <?php } ?> <?php $currentSelectClass = isset($_POST['ClassID']) ? intval($_POST['ClassID']) : '0'; ?> <input type="hidden" name="ClassID" value="<?php echo esc_attr($currentSelectClass); ?>">
96 </form>
97 </ul>
98 </div>
99 </div>
100 </div>
101 <div class="wpsp-btn-list" <?php if($proversion['status'] != "1") {?> wpsp-tooltip="<?php echo esc_attr($protitle);?>" <?php } ?>>
102 <div class="psp-dropdownmain wpsp-button-group">
103 <button type="button" class="wpsp-btn print" id="ExportParents" <?php echo esc_html($prodisable,'wpschoolpress');?> title="<?php echo esc_attr($protitle);?>"><i class="fa fa-upload"></i> <?php echo esc_html("Export","wpschoolpress");?> </button>
104 <button type="button" class="wpsp-btn wpsp-btn-blue wpsp-dropdown-toggle" <?php echo esc_html($prodisable);?> title="<?php echo esc_attr($protitle);?>">
105 <!-- <span class="caret"></span>
106 <span class="sr-only">Toggle Dropdown</span> -->
107 </button>
108 <div id="exportcontainer" style="display:none;"></div>
109 <div class="wpsp-dropdown wpsp-dropdown-md wpsp-dropdown-right">
110 <ul>
111 <form id="ExportColumnForm" name="ExportParentColumn" method="POST">
112 <li class="wpsp-drop-title wpsp-checkList"> <?php echo esc_html("Select Columns to Export","wpschoolpress");?> </li> <?php foreach( $parentFieldList as $key=>$value ) { ?> <li class="wpsp-checkList">
113 <input type="checkbox" name="ParentColumn[]" value="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" checked="checked">
114 <label for="<?php echo esc_attr($key); ?>"><?php echo esc_html($value); ?></label>
115 </li> <?php } ?> <input type="hidden" name="ClassID" value="<?php if(isset($_POST['ClassID'])) echo esc_attr(sanitize_text_field($_POST['ClassID'])); else echo 0; ?>">
116 <input type="hidden" name="exportparent" value="exportparent">
117 </form>
118 </ul>
119 </div>
120 </div>
121 </div> <?php }?>
122 </div>
123 </div>
124 </div>
125 <div class="wpsp-card-body"> <?php if( empty( $sel_class ) && $current_user_role=='teacher' ) {
126 echo '<div class="alert alert-danger wpsp-col-lg-2">'.esc_html($msg).'</div>';
127 } else { ?> <div class="wpsp-row">
128 <div class="wpsp-col-md-12 table-responsive">
129 <table id="parent_table" class="wpsp-table" cellspacing="0" width="100%" style="width:100%">
130 <thead>
131 <tr>
132 <th><?php echo esc_html( 'Parent Name', 'wpschoolpress' ); ?></th>
133 <th><?php echo esc_html("Student Name","wpschoolpress");?></th>
134 <th><?php echo esc_html( 'Parent Email ID', 'wpschoolpress' ); ?></th>
135 <th align="center" class="nosort"><?php echo esc_html("Action","wpschoolpress");?></th>
136 </tr>
137 </thead>
138 <tbody> <?php
139 $student_table = $wpdb->prefix."wpsp_student";
140 $users_table = $wpdb->prefix."users";
141 $class_id='';
142 if( isset($_POST['ClassID'] ) && $_POST['ClassID'] != 'all' ) {
143 $class_id=intval($_POST['ClassID']);
144 $stl = [];
145 // $parentlist = $wpdb->get_results("select class_id, sid from $student_table WHERE parent_wp_usr_id!='0'");
146 $parentlist = $wpdb->get_results($wpdb->prepare("SELECT class_id, sid FROM $student_table WHERE parent_wp_usr_id != %d",0));
147 foreach ($parentlist as $stu) {
148 if(is_numeric($stu->class_id) ){
149 if($stu->class_id == $class_id){
150 $stl[] = $stu->sid;
151 }
152 }else{
153 $class_id_array = unserialize( $stu->class_id );
154 if(is_array($class_id_array)){
155 if(in_array($class_id, $class_id_array)){
156 $stl[] = $stu->sid;
157 }
158 }
159 }
160 }
161 }else if(!isset($_POST['ClassID']) || $_POST['ClassID'] == 'all' ){
162 if($current_user_role =='administrator'){
163 // $studentlists = $wpdb->get_results("select sid from $student_table WHERE parent_wp_usr_id!='0'");
164 $studentlists = $wpdb->get_results($wpdb->prepare("SELECT sid FROM $student_table WHERE parent_wp_usr_id != %d",0));
165 foreach ($studentlists as $stu) {
166 $stl[] = $stu->sid;
167 }
168 }else if($current_user_role =='teacher'){
169 // print_r($sel_class);
170 $stl = [];
171 foreach ($sel_class as $key => $value) {
172 //$studentlists = $wpdb->get_results("select class_id, sid from $student_table WHERE parent_wp_usr_id!='0'");
173 $studentlists = $wpdb->get_results($wpdb->prepare("SELECT class_id, sid FROM $student_table WHERE parent_wp_usr_id != %d",0));
174 foreach ($studentlists as $stu) {
175 if(is_numeric($stu->class_id) ){
176 if($stu->class_id == $value->cid){
177 $stl[] = $stu->sid;
178 }
179 }else{
180 $class_id_array = unserialize( $stu->class_id );
181 if(is_array($class_id_array)){
182 if(in_array($value->cid, $class_id_array)){
183 $stl[] = $stu->sid;
184 }
185 }
186 }
187 }
188 }
189 }
190 }
191 $parent_ids=array();
192 foreach($stl as $plist){
193 $parent_ids[]= $wpdb->get_row("SELECT DISTINCT u.user_email, CONCAT_WS(' ', p_fname, p_mname, p_lname ) AS full_name, p.s_fname,p.s_lname, p.wp_usr_id, p.parent_wp_usr_id from $student_table p LEFT JOIN $users_table u ON u.ID = p.parent_wp_usr_id WHERE p.sid = $plist ");
194 }
195 foreach($parent_ids as $key=>$pinfo){
196 ?> <tr>
197 <td><?php echo esc_html($pinfo->full_name);?></td>
198 <td><?php echo esc_html($pinfo->s_fname." ".$pinfo->s_lname); ?> </td>
199 <td><?php echo esc_html($pinfo->user_email);?></td>
200 <td align="center">
201 <div class="wpsp-action-col">
202 <a href="javascript:void(0)" title="View" data-pop="ViewModal" data-id="<?php echo esc_attr(intval($pinfo->parent_wp_usr_id));?>" class="ViewParent wpsp-popclick">
203 <i class="icon dashicons dashicons-visibility wpsp-view-icon"></i></a>
204 <a href="<?php echo esc_url(wpsp_admin_url().'sch-student&id='.esc_attr(intval($pinfo->wp_usr_id)).'&edit=true#parent-field-lists');?>" title="Edit"><i class="icon dashicons dashicons-edit wpsp-edit-icon"></i></a>
205 </div>
206 </td>
207 </tr> <?php
208 }
209 ?> </tbody>
210 <tfoot>
211 <tr>
212 <th><?php echo esc_html__( 'Parent Name', 'wpschoolpress' ); ?></th>
213 <th><?php echo esc_html("Student Name","wpschoolpress");?></th>
214 <th><?php echo esc_html__( 'Parent Email ID', 'wpschoolpress' ); ?></th>
215 <th align="center"><?php echo esc_html("Action","wpschoolpress");?></th>
216 </tr>
217 </tfoot>
218 </table>
219 </div>
220 </div> <?php } ?> </div>
221 </div>