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

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

288 lines 20.8 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, $wpdb;
6 $current_user_role=$current_user->roles[0];
7 if( $current_user_role=='administrator' || $current_user_role=='teacher'){
8 wpsp_topbar();
9 wpsp_sidebar();
10 wpsp_body_start();
11 $id = sanitize_text_field(stripslashes($_GET['id']));
12 $user_id = esc_sql(base64_decode($id));
13 ?>
14 <div class="wpsp-row">
15 <div class="wpsp-col-md-12">
16 <div class="wpsp-card">
17 <div class="wpsp-card-head ui-sortable-handle">
18 <h3 class="wpsp-card-title"><?php esc_html_e( 'Payment Details', 'wpschoolpress' ); ?></h3>
19 </div>
20 <div class="wpsp-card-body">
21 <table id="class_table" class="wpsp-table wpsp-table-bordered wpsp-table-striped" cellspacing="0" width="100%" style="width:100%">
22 <thead>
23 <tr>
24 <th><?php esc_html_e( 'Student Name', 'wpschoolpress' ); ?></th>
25 <th><?php esc_html_e( 'Roll No', 'wpschoolpress' ); ?></th>
26 <th><?php esc_html_e( 'Class Name', 'wpschoolpress' ); ?></th>
27 <th><?php esc_html_e( 'Class Teacher Name', 'wpschoolpress' ); ?></th>
28 <th><?php esc_html_e( 'Amount', 'wpschoolpress' ); ?></th>
29 <th><?php esc_html_e( 'Date', 'wpschoolpress' ); ?></th>
30 <th><?php esc_html_e( 'Class Fee Status', 'wpschoolpress' ); ?></th>
31 </tr>
32 </thead>
33 <tbody>
34 <?php
35 $classid = array();
36 $productid = array();
37 $stable=$wpdb->prefix."wpsp_student";
38 $ctlass=$wpdb->prefix."wpsp_class";
39 $ftlass=$wpdb->prefix."wpsp_fees";
40 $cteacher =$wpdb->prefix."wpsp_teacher";
41 /* $wpsp_stud_data =$wpdb->get_results("SELECT * FROM $stable s
42 INNER JOIN $ctlass c
43 where s.wp_usr_id = '".$user_id."'"); */
44 $wpsp_stud_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM $stable s
45 INNER JOIN $ctlass c
46 where s.wp_usr_id WHERE s.wp_usr_id = %d",$user_id));
47 $classid_da = maybe_unserialize($wpsp_stud_data[0]->class_id);
48 $courses1 = get_user_meta($wpsp_stud_data[0]->parent_wp_usr_id, '_pay_woocommerce_enrolled_class_access_counter' );
49 $courses2 = get_user_meta( $user_id, '_pay_woocommerce_enrolled_class_access_counter');
50 $courses = array_merge($courses1,$courses2);
51 if ( ! empty( $courses ) ) {
52 $courses = maybe_unserialize( $courses );
53 } else {
54 $courses = array();
55 }
56 $courses_check=array();
57 $courses_value=array();
58 $courses_value1=array();
59 foreach($courses as $key => $value){
60 foreach($value as $key1 => $value1){
61 $courses_check[] = $key1;
62 $courses_value[] = $value1;
63 }
64 $pr++;
65 }
66 foreach($courses_value as $valueorder){
67 $courses_value1[] = $valueorder[0];
68 }
69 $wpsp_clas_data =$wpdb->get_results("SELECT * FROM $ctlass
70 where cid IN('".implode("','",$classid_da)."') and c_fee_type = 'paid'");
71 $proid = 0;
72 $wpsp_fees_data = $wpdb->get_results("SELECT s.wp_usr_id,f.student_id,f.order_id FROM $stable AS s INNER JOIN wp_wpsp_fees AS f ON f.student_id = s.wp_usr_id");
73 foreach($wpsp_fees_data as $res){
74 $siid[] = $res->wp_usr_id;
75 }
76 foreach($wpsp_clas_data as $clsloop){
77 /* $wpsp_teacher_data =$wpdb->get_results("SELECT * FROM $cteacher
78 where wp_usr_id = '".esc_sql($clsloop->teacher_id)."'"); */
79 $wpsp_teacher_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM $cteacher WHERE wp_usr_id = %d",$clsloop->teacher_id));
80 // $wpsp_order_data =$wpdb->get_results("SELECT c.cid,f.class_id,f.fees_amount,f.created_date FROM wp_wpsp_class as c INNER JOIN wp_wpsp_fees AS f ON f.class_id = c.cid where f.class_id = '".esc_sql($clsloop->cid)."'");
81 $wpsp_order_data = $wpdb->get_results($wpdb->prepare("SELECT c.cid,f.class_id,f.fees_amount,f.created_date FROM $ctlass as c INNER JOIN wp_wpsp_fees AS f ON f.class_id = c.cid where f.class_id = %d",$clsloop->teacher_id));
82 $lastKey = key(array_slice($wpsp_order_data, -1, 1, true));
83 if(in_array($wpsp_stud_data[0]->wp_usr_id, $siid)){
84 $paid = esc_html('Paid','wpschoolpress');
85 }else{
86 $paid = esc_html('Not Paid','wpschoolpress');
87 }
88 if(in_array($wpsp_stud_data[0]->wp_usr_id, $siid)){
89 $order_date_created = $wpsp_order_data[$lastKey]->created_date;
90 $newDate = date("F d, Y", strtotime($order_date_created));
91 $price = $wpsp_order_data[$lastKey]->fees_amount.'.00';
92 }
93 ?>
94 <tr>
95 <td><?php echo esc_html($wpsp_stud_data[0]->s_fname.' '.$wpsp_stud_data[0]->s_lname);?></td>
96 <td><?php echo esc_html($wpsp_stud_data[0]->s_rollno);?></td>
97 <td><?php echo esc_html($clsloop->c_name);?></td>
98 <td><?php echo esc_html($wpsp_teacher_data[0]->first_name.' '. $wpsp_teacher_data[0]->last_name) ;?></td>
99 <td><?php if($price != ''){ echo esc_html(get_woocommerce_currency_symbol()) .esc_html($price); }else { echo '-'; }?></td>
100 <td><?php if($newDate != ''){ echo esc_html($newDate); }else { echo '-'; }?></td>
101 <td><?php echo esc_html($paid);?></td>
102 </tr>
103 <?php
104 // $pr++;
105 }?>
106 </tbody>
107 </table>
108 </div>
109 </div>
110 </div>
111 </div>
112 <?php
113 wpsp_body_end();
114 wpsp_footer();
115 }else if($current_user_role=='parent' || $current_user_role='student'){
116 wpsp_topbar();
117 wpsp_sidebar();
118 wpsp_body_start();
119 ?>
120 <div class="wpsp-row">
121 <div class="wpsp-col-md-12">
122 <div class="wpsp-card">
123 <div class="wpsp-card-head ui-sortable-handle">
124 <h3 class="wpsp-card-title"><?php esc_html_e( 'Payment Details', 'wpschoolpress' )?> </h3>
125 </div>
126 <div class="wpsp-card-body">
127 <table id="class_table" class="wpsp-table wpsp-table-bordered wpsp-table-striped" cellspacing="0" width="100%" style="width:100%">
128 <thead>
129 <tr>
130 <th><?php esc_html_e( 'Student Name', 'wpschoolpress' ); ?></th>
131 <th><?php esc_html_e( 'Roll No', 'wpschoolpress' ); ?></th>
132 <th><?php esc_html_e( 'Class Name', 'wpschoolpress' ); ?></th>
133 <th><?php esc_html_e( 'Class Teacher Name', 'wpschoolpress' ); ?></th>
134 <th><?php esc_html_e( 'Amount', 'wpschoolpress' ); ?></th>
135 <th><?php esc_html_e( 'Date', 'wpschoolpress' ); ?></th>
136 <th><?php esc_html_e( 'Class Fee Status', 'wpschoolpress' ); ?></th>
137 </tr>
138 </thead>
139 <tbody>
140 <?php
141 $proid = 0;
142 $proid1 = 0;
143 $classid = array();
144 $productid = array();
145 $stable=$wpdb->prefix."wpsp_student";
146 $ctlass=$wpdb->prefix."wpsp_class";
147 $cteacher =$wpdb->prefix."wpsp_teacher";
148 $ftlass=$wpdb->prefix."wpsp_fees";
149 if($current_user_role == 'parent'){
150 // $user_id = $wpdb->get_var("SELECT wp_usr_id FROM $stable where parent_wp_usr_id = '".esc_sql($current_user->ID)."'");
151 $user_id = $wpdb->get_var($wpdb->prepare("SELECT wp_usr_id FROM $stable WHERE parent_wp_usr_id = %d",$current_user->ID));
152 }else {
153 $user_id = esc_sql($current_user->ID);
154 }
155 if($current_user_role == 'parent'){
156 // $wpsp_stud_data =$wpdb->get_results("SELECT * FROM $stable s INNER JOIN $ctlass c where s.parent_wp_usr_id = '".$current_user->ID."' and c.c_fee_type = 'paid'");
157 $wpsp_stud_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM $stable s INNER JOIN $ctlass c where s.parent_wp_usr_id = %d and c.c_fee_type = %s",$current_user->ID,'paid'));
158 }else {
159 $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'");
160 $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",$user_id,'paid'));
161 }
162 $classid_da = maybe_unserialize($wpsp_stud_data[0]->class_id);
163 $cid = [];
164 if(is_numeric($wpsp_stud_data[0]->class_id) ){
165 $cid[] = $wpsp_stud_data[0]->class_id;
166 }else{
167 $class_id_array = unserialize( $wpsp_stud_data[0]->class_id );
168 $cid[] = $class_id_array;
169 }
170 if($current_user_role == 'parent'){
171 $courses1 = get_user_meta( $current_user->ID, '_pay_woocommerce_enrolled_class_access_counter');
172 $courses2 = get_user_meta($wpsp_stud_data[0]->wp_usr_id, '_pay_woocommerce_enrolled_class_access_counter' );
173 $courses = array_merge($courses1,$courses2);
174 }else {
175 $courses1 = get_user_meta($wpsp_stud_data[0]->parent_wp_usr_id, '_pay_woocommerce_enrolled_class_access_counter' );
176 $courses2 = get_user_meta( $user_id, '_pay_woocommerce_enrolled_class_access_counter' );
177 $courses = array_merge($courses1,$courses2);
178 }
179 if ( ! empty( $courses ) ) {
180 $courses = maybe_unserialize( $courses );
181 } else {
182 $courses = array();
183 }
184 $courses_check=array();
185 $courses_value=array();
186 $courses_value1=array();
187 $courses_check=array();
188 foreach($courses as $key => $value){
189 foreach($value as $key1 => $value1){
190 if(!empty($value1)){
191 $courses_check[] = $key1;
192 $courses_value[] = $value1;
193 }
194 }
195 }
196 foreach($courses_value as $valueorder){
197 $courses_value1[] = $valueorder[0];
198 }
199 $courses_valu_final = array();
200 foreach($courses_value as $key => $value){
201 foreach($value as $key1 => $value1){
202 $courses_valu_final[] = $value1;
203 }
204 }
205 $product_id=array();
206 $tes = arsort($courses_valu_final);
207 foreach($courses_valu_final as $key => $value ){
208 $order = wc_get_order($value);
209 $items = $order->get_items();
210 foreach ( $items as $item ) {
211 $product_id[] = $item['product_id'];
212 }
213 }
214 // $wpsp_teacher_data = $wpdb->get_results("SELECT * FROM $cteacher where wp_usr_id = '".$clsloop->teacher_id."'");
215 $wpsp_teacher_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM $cteacher WHERE wp_usr_id = %d",$clsloop->teacher_id));
216 if(in_array($clsloop->cid, $courses_check)){
217 $paid = esc_html('Paid','wpschoolpress');
218 }else{
219 $paid = esc_html('Not Paid','wpschoolpress');
220 }
221 $args = array(
222 'post_type' => 'product',
223 'orderby' => 'publish_date',
224 'order' => 'DESC',
225 'posts_per_page' => -1
226 );
227 // $wpsp_fees_data = $wpdb->get_results("SELECT s.wp_usr_id,f.student_id,f.class_id,f.order_id FROM $stable AS s INNER JOIN wp_wpsp_fees AS f ON f.student_id = s.wp_usr_id where s.parent_wp_usr_id = '".$current_user->ID."'");
228 $wpsp_fees_data = $wpdb->get_results($wpdb->prepare("SELECT s.wp_usr_id,f.student_id,f.class_id,f.order_id FROM $stable AS s INNER JOIN wp_wpsp_fees AS f ON f.student_id = s.wp_usr_id WHERE s.parent_wp_usr_id = %d",$current_user->ID));
229 foreach($wpsp_fees_data as $res){
230 $siid[] = $res->wp_usr_id;
231 $ciid = $res->class_id;
232 }
233 // $wpsp_stud =$wpdb->get_results("SELECT * FROM $stable s where s.parent_wp_usr_id = '".esc_sql($current_user->ID)."' ORDER BY s.wp_usr_id DESC");
234 $wpsp_stud = $wpdb->get_results($wpdb->prepare("SELECT * FROM $stable WHERE s.parent_wp_usr_id = %d ORDER BY s.wp_usr_id DESC",$current_user->ID));
235 $wpsp_tech =$wpdb->get_results("SELECT s.class_id,c.cid,c.teacher_id FROM $ftlass AS s INNER JOIN $ctlass AS c ON c.cid=s.class_id");
236 foreach($wpsp_tech as $key =>$value11 ){
237 $tech_id = $value11->teacher_id;
238 }
239 foreach($wpsp_stud as $value){
240 if(in_array($value->wp_usr_id, $siid)){
241 // $wpsp_cls_data =$wpdb->get_results("SELECT s.order_id,s.fees_amount,s.created_date,s.student_id,s.class_id,c.cid,c.c_name,c.teacher_id FROM wp_wpsp_fees AS s INNER JOIN wp_wpsp_class AS c ON c.cid=s.class_id where student_id = '".esc_sql($value->wp_usr_id)."' ORDER BY s.student_id DESC");
242 $wpsp_cls_data = $wpdb->get_results($wpdb->prepare("SELECT s.order_id,s.fees_amount,s.created_date,s.student_id,s.class_id,c.cid,c.c_name,c.teacher_id FROM $ftlass AS s INNER JOIN $ctlass AS c ON c.cid=s.class_id WHERE s.parent_wp_usr_id = %d ORDER BY s.wp_usr_id DESC",$current_user->ID));
243 // $wpsp_teacher_data =$wpdb->get_results("SELECT t.first_name,t.last_name, c.teacher_id FROM wp_wpsp_teacher as t INNER JOIN wp_wpsp_class AS c ON c.teacher_id=t.wp_usr_id where wp_usr_id = '".$wpsp_cls_data[0]->teacher_id."'");
244 $wpsp_teacher_data = $wpdb->get_results($wpdb->prepare("SELECT t.first_name,t.last_name, c.teacher_id FROM $cteacher AS t INNER JOIN $ctlass AS c ON c.teacher_id=t.wp_usr_id WHERE s.wp_usr_id = %d",$wpsp_cls_data[0]->teacher_id));
245 // echo"<pre>";print_r($wpsp_teacher_data);
246 ?>
247 <tr>
248 <td><?php echo esc_html($value->s_fname.' '.$value->s_lname);?></td>
249 <td><?php echo esc_html($value->s_rollno);?></td>
250 <td><?php echo esc_html($wpsp_cls_data[0]->c_name)?></td>
251 <td><?php echo esc_html($wpsp_teacher_data[0]->first_name.' '.$wpsp_teacher_data[0]->last_name);?></td>
252 <td><?php
253 $price = esc_html($wpsp_cls_data[0]->fees_amount);
254 if($price != ''){ echo esc_html(get_woocommerce_currency_symbol()).esc_html($price) .'.00'; }else { echo '-'; }?>
255 </td>
256 <td>
257 <?php
258 // ->date('Y F j, g:i A');
259 $order_date_created = esc_html($wpsp_cls_data[0]->created_date);
260 if($order_date_created != ''){ echo esc_html($newDate = date("F d, Y", strtotime($order_date_created))); }else { echo '-'; }?>
261 </td>
262 <td><?php
263 echo esc_html("Fees Paid","wpschoolpress");?></td>
264 <!-- <td><a class="wpsp-btn" href="<?php echo esc_url(get_permalink());?>" target="_blank">Pay Now</a></td> -->
265 </tr>
266 <?php
267 // $pro2++;
268 }
269 }
270 // endwhile;
271 wp_reset_query();
272 ?>
273 </tbody>
274 </table>
275 </div>
276 </div>
277 </div>
278 </div>
279 <?php
280 wpsp_body_end();
281 wpsp_footer();
282 }
283 }else{
284 //Include Login Section
285 include_once( WPSP_PLUGIN_PATH .'/includes/wpsp-login.php');
286 }
287 ?>
288