/
MassAssignFees.php
105 lines (83 loc) · 2.54 KB
/
MassAssignFees.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
<?php
if ( $_REQUEST['modfunc'] === 'save' )
{
if ( ! empty( $_REQUEST['student'] )
&& AllowEdit() )
{
//FJ fix SQL bug invalid amount
if ( is_numeric( $_REQUEST['amount'] ) )
{
$due_date = RequestedDate( 'due', '' );
// Group SQL inserts.
$sql = '';
foreach ( (array) $_REQUEST['student'] as $student_id )
{
$sql .= "INSERT INTO BILLING_FEES (STUDENT_ID,ID,TITLE,AMOUNT,SYEAR,SCHOOL_ID,ASSIGNED_DATE,DUE_DATE,COMMENTS)
VALUES('" . $student_id . "'," . db_seq_nextval( 'billing_fees_id_seq' ) . ",
'" . $_REQUEST['title'] . "','" . preg_replace( '/[^0-9.-]/', '', $_REQUEST['amount'] ) . "',
'" . UserSyear() . "','" . UserSchool() . "','" . DBDate() . "','" . $due_date . "',
'" . $_REQUEST['comments'] . "');";
}
if ( $sql )
{
DBQuery( $sql );
$note[] = button( 'check' ) . ' ' . _( 'That fee has been added to the selected students.' );
}
}
else
{
$error[] = _( 'Please enter a valid Amount.' );
}
}
else
{
$error[] = _( 'You must choose at least one student.' );
}
// Unset modfunc & redirect URL.
RedirectURL( 'modfunc' );
}
if ( ! $_REQUEST['modfunc'] )
{
DrawHeader( ProgramTitle() );
echo ErrorMessage( $error );
echo ErrorMessage( $note, 'note' );
if ( $_REQUEST['search_modfunc'] === 'list' )
{
echo '<form action="' . URLEscape( 'Modules.php?modname=' . $_REQUEST['modname'] . '&modfunc=save' ) . '" method="POST">';
DrawHeader( '', SubmitButton( _( 'Add Fee to Selected Students' ) ) );
echo '<br />';
PopTable( 'header', _( 'Fee' ) );
echo '<table><tr><td>' . TextInput(
'',
'title',
_( 'Title' ),
'required size="20"'
) . '</td></tr>';
echo '<tr><td>' . TextInput(
'',
'amount',
_( 'Amount' ),
' type="number" step="0.01" max="999999999999" min="-999999999999" required'
) . '</td></tr>';
echo '<tr><td>' . DateInput( '', 'due', _( 'Due Date' ), false ) . '</td></tr>';
echo '<tr><td>' . TextInput(
'',
'comments',
_( 'Comment' ),
'maxlength="1000" size="25"'
) . '</td></tr></table>';
PopTable( 'footer' );
echo '<br />';
}
$extra['link'] = [ 'FULL_NAME' => false ];
$extra['SELECT'] = ",NULL AS CHECKBOX";
$extra['functions'] = [ 'CHECKBOX' => 'MakeChooseCheckbox' ];
$extra['columns_before'] = [ 'CHECKBOX' => MakeChooseCheckbox( '', 'STUDENT_ID', 'student' ) ];
$extra['new'] = true;
Search( 'student_id', $extra );
if ( $_REQUEST['search_modfunc'] === 'list' )
{
echo '<br /><div class="center">' . SubmitButton( _( 'Add Fee to Selected Students' ) ) . '</div>';
echo '</form>';
}
}