-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathindex.php
198 lines (168 loc) · 7.4 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<?php
/************************************************************************/
/* ATutor */
/************************************************************************/
/* Copyright (c) 2002 - 2013 */
/* ATutorSpaces */
/* https://atutorspaces.com */
/* This program is free software. You can redistribute it and/or */
/* modify it under the terms of the GNU General Public License */
/* as published by the Free Software Foundation. */
/************************************************************************/
$_user_location = 'users';
define('AT_INCLUDE_PATH', '../../include/');
require (AT_INCLUDE_PATH.'vitals.inc.php');
require ('include/payments.lib.php');
require (AT_INCLUDE_PATH.'header.inc.php');
function is_enrolled($member_id, $course_id) {
$sql = "SELECT approved FROM %scourse_enrollment WHERE course_id=%d AND member_id=%d AND approved<>'n'";
$rows_enrollments_approved = queryDB($sql,array(TABLE_PREFIX, $course_id, $member_id));
return $rows_enrollments_approved;
}
/// Get a list of enrolled courses or pending enrollments, and display their fee payment status
$payment_count = 0; // num listed courses
$sql = "SELECT course_id, approved FROM %scourse_enrollment WHERE member_id=%d && role <> 'Instructor'";
$rows_enrollments = queryDB($sql, array(TABLE_PREFIX, $_SESSION['member_id']));
if(count($rows_enrollments) > 0){?>
<h3><?php echo _AT('enrollment'); ?></h3>
<table class="data static" rules="rows" summary="">
<thead>
<tr>
<th scope="col"><?php echo _AT('course'); ?></th>
<th scope="col"><?php echo _AT('ec_this_course_fee'); ?></th>
<th scope="col"><?php echo _AT('ec_payment_made'); ?></th>
<th scope="col"><?php echo _AT('ec_enroll_approved'); ?></th>
<th scope="col"><?php echo _AT('date'); ?></th>
<th scope="col"><?php echo _AT('ec_action'); ?></th>
</tr>
</thead>
<?php
foreach($rows_enrollments as $row){
if ($_SESSION['member_id'] == $system_courses[$row['course_id']]['member_id']) {
continue; // this member is the course instructor so ignore enrollment
}
$sql2 = "SELECT course_fee FROM %sec_course_fees WHERE course_id=%d AND course_fee > '0'";
$this_course_fee = queryDB($sql2, array(TABLE_PREFIX, $row['course_id']), TRUE);
if (count($this_course_fee) > 0) {
$this_course_fee = $this_course_fee['course_fee'];
}
$sql3 = "SELECT amount, timestamp, approved, transaction_id FROM %spayments WHERE course_id=%d AND member_id = %d";
$this_course_pid = queryDB($sql3, array(TABLE_PREFIX, $row['course_id'], $_SESSION['member_id']), TRUE);
if (count($this_course_pid) > 0 && $this_course_pid['transaction_id'] != '') {
$this_course_paid = $this_course_pid['amount'];
$this_payment_date = $this_course_pid['timestamp'];
$this_enrollment_approved = $rows_enrollments['approved'];
$this_transaction = $this_course_pid['transaction_id'];
} else{
$this_course_paid = '0.00';
}
$payment_count++;
if(is_int($payment_count/2)){
$rowcolor = "odd";
} else{
$rowcolor = "even";
}
echo '<tr class="'.$rowcolor.'">';
if(is_enrolled($_SESSION['member_id'], $row['course_id'])){
echo '<td><a href="bounce.php?course='.$row['course_id'].'">'.$system_courses[$row['course_id']]['title'].'</a></td>';
}else{
echo '<td>'.$system_courses[$row['course_id']]['title'].'</td>';
}
echo '<td align="center">'.$_config['ec_currency_symbol'].number_format($this_course_fee, 2).' '.$_config['ec_currency'].'</td>';
echo '<td align="center">'.$_config['ec_currency_symbol'].number_format($this_course_paid , 2).' '.$_config['ec_currency'].'</td>';
if ($row['approved'] == 'y'){
echo '<td align="center">'._AT('yes').'</td>';
} else {
echo '<td align="center">'._AT('no').'</td>';
}
echo '<td align="center">'.$this_payment_date.'</td>';
if ($row['approved'] == 'y'){
echo '<td><a href="bounce.php?course='.$row['course_id'].'">'._AT('login').'</a></td>';
}else if ($this_course_pid['transaction_id'] != '' && $row['approved'] != 'y'){
echo '<td>'._AT('pending_approval').'</td>';
}else{
echo '<td align="center"><a href="mods/payments/payment.php?course_id='.$row['course_id'].'">'._AT('ec_make_payment').'</a></td>';
}
echo '</tr>';
}
echo '</table><p><br /></p>';
if($payment_count == 0){
$msg->printInfos('EC_NO_PAID_COURSES');
}
}
$sql = "SELECT * from %spayments WHERE member_id=%d ORDER BY timestamp DESC";
$rows_payments = queryDB($sql, array(TABLE_PREFIX, $_SESSION['member_id']));
if(count($rows_payments) > 0){
?>
<table class="data static" rules="rows" summary="">
<thead>
<tr>
<th scope="col"><?php echo _AT('course'); ?></th>
<th scope="col"><?php echo _AT('ec_fees'); ?></th>
<th scope="col"><?php echo _AT('ec_payment_made'); ?></th>
<th scope="col"><?php echo _AT('ec_enroll_approved'); ?></th>
<th scope="col"><?php echo _AT('date'); ?></th>
<th scope="col"><?php echo _AT('ec_action'); ?></th>
</tr>
</thead>
<?php
foreach($rows_payments as $row){
$this_course_fee = $row['amount'];
$payment_count++;
if(is_int($payment_count/2)){
$rowcolor = "even";
} else{
$rowcolor = "odd";
}
if(count($rows_payments) > 0){
echo '<tr class="'.$rowcolor.'">';
if ($row['approved'] == '2'){
echo '<td><a href="bounce.php?course='.$row['course_id'].'">'.$system_courses[$row['course_id']]['title'].'</a></td>';
}else{
echo '<td>'.$system_courses[$row['course_id']]['title'].'</td>';
}
echo '<td align="center">'.$_config['ec_currency_symbol'].number_format($this_course_fee, 2).' '.$_config['ec_currency'].'</td>';
if ($row['transaction_id'] != ''){
echo '<td align="center">'.$_config['ec_currency_symbol'].number_format($row['amount'], 2).' '.$_config['ec_currency'].'</td>';
} else if ($row['approved'] == 0){
echo '<td align="center">0.00</td>';
}
if (is_enrolled($_SESSION['member_id'], $row['course_id'])){
echo '<td align="center">'._AT('yes').'</td>';
}else{
echo '<td align="center">'._AT('no').'</td>';
}
echo '<td align="center">'.$row['timestamp'].'</td>';
if ($row['transaction_id'] != ''){
echo '<td align="center">'._AT('ec_full_payment_recieved').'</td>';
}else{
echo '<td align="center"><a href="mods/payments/payment.php?course_id='.$row['course_id'].'">'._AT('ec_make_payment').'</a></td>';
}
echo '</tr>';
}
}
echo '</table>';
if($payment_count == 0){
$msg->printInfos('EC_NO_PAID_COURSES');
}
} else {
?>
<table class="data static" rules="rows" summary="">
<thead>
<tr>
<th scope="col"><?php echo _AT('course'); ?></th>
<th scope="col"><?php echo _AT('ec_fees'); ?></th>
<th scope="col"><?php echo _AT('ec_payment_made'); ?></th>
<th scope="col"><?php echo _AT('ec_enroll_approved'); ?></th>
<th scope="col"><?php echo _AT('date'); ?></th>
<th scope="col"><?php echo _AT('ec_action'); ?></th>
</tr>
</thead>
<tr>
<td><?php echo _AT('none_found');?>
</td>
</tr>
</table>
<?php
}
require (AT_INCLUDE_PATH.'footer.inc.php'); ?>