-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass_student_edit_OLD01.php
More file actions
193 lines (163 loc) · 6.57 KB
/
Copy pathclass_student_edit_OLD01.php
File metadata and controls
193 lines (163 loc) · 6.57 KB
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
<?php
ob_start();
include("../includes/pttec_includes.phtml");
// printarray($_REQUEST);
MySQL_PaulTheTutor_Connect();
put_ptts_header("", $strAbsPath, "admin",'popup');
$strTableName = $_REQUEST['tab'];
if ($_REQUEST[tab] == "TP_Seminar_Reg")
$sem = 1;
if ($sem == 1)
$strTableName2 = "TP_Seminar_Info";
else
$strTableName2 = "PT_SAT_Class_Info";
$id = $_REQUEST['student_id'];
?>
<table cellspacing="0" cellpadding="0" width="100%">
<tr bgcolor="#FFFFFF">
<td>
<form method="post" name="form1">
<table cellspacing="0" cellpadding="0" width="100%">
<tr><td><fieldset>
<legend>Student Info</legend>
<div style="padding:10px"><table cellspacing="0" cellpadding="0">
<?php
$QStr = "select * from $strTableName where id = $id";
if ($_REQUEST[action]){
if ($id){
$FieldsRS = runquery($QStr);
$arFieldsVals = mysql_fetch_array($FieldsRS);
}
// the student_id was passed, so it will be used to determine the family_id (fid)
if(!(isEmpty($_REQUEST['student_id']))){
$student_id = $_REQUEST['student_id'];
$SQS = "select first_name, last_name, fid from PTStudentInfo_New where id = $student_id";
$SRS = runquery($SQS);
$Sar = mysql_fetch_array($SRS);
$_REQUEST['fid'] = $Sar[fid];
$_REQUEST['student_name'] = "$Sar[first_name] $Sar[last_name]";
$_REQUEST['username'] = $Sar[first_name];
$_REQUEST['password'] = $Sar[last_name];
}
if (($_REQUEST['fid']!=$arFieldsVals['fid'] && $arFieldsVals['fid']) || !$arFieldsVals['fid']){
$Fres = runquery("select main_name, main_email, main_phone from PT_Family_Info where id = '".$_REQUEST['fid']."'");
$frow = mysql_fetch_array($Fres);
$_REQUEST['name'] = $frow['main_name'];
$_REQUEST['parent_name'] = $frow['main_name'];
$_REQUEST['email'] = $frow['main_email'];
$_REQUEST['phone_number'] = $frow['main_phone'];
}
$_REQUEST[strNotUsed] = "id";
If($_REQUEST[action] == "update" and isset($_REQUEST[id]) and isset($_REQUEST[strTableName])){
$strWhere = " id = $id";
if (!$_REQUEST[username])
$_REQUEST[username] = $arFieldsVals[username];
if (!$_REQUEST[password])
$_REQUEST[password] = $arFieldsVals[password];
$msg = UpdateFields($_REQUEST[strTableName], $_REQUEST, $arMandFields, $_REQUEST[strNotUsed], $tdStyle, $strWhere);
} elseif ($_REQUEST[action] == "insert"){
/*********************************************************************************
VWORKER CODERS, THIS IS THE PART THAT ACTUALLY ADDS THE PERSON TO A CLASS AND PUTS THE BILL(S) USING session_add2.
*****************************************************************************************/
$msg = InsertFields($_REQUEST[strTableName], $_REQUEST, $arMandFields, '', $tdStyle, $strWhere);
// If the user added one-on-one tutoring or a seminar, we don't send a bill
if (!$sem && is_int($msg) && $_REQUEST['class'] <> 1){ //setup the two billing sessions for the student
$res_cl = runquery("select id,cost,start_date from $strTableName2 WHERE id='".$_REQUEST['class']."' LIMIT 1");
$row_cl = mysql_fetch_array($res_cl);
$dep_rate = $row_cl['cost']-$_REQUEST['paid']; //what they owe is fee MINUS what they have paid
$start_date=$row_cl['start_date'];
$dep_date = last_saturday_of_last_month($start_date);
// added by Paul the Tutor on 2012/01/09
if($_REQUEST['deposit'] <> 0) { // If they have to pay a deposit
session_add2(date('Y-m-d'), "10:00:00", $_REQUEST['fid'], 1, 50, 0, 2000, '', (int)$msg, $_REQUEST['student_name'],'','Deposit for LD SAT Prep Session '.$_REQUEST['class']);
$dep_rate = $dep_rate-50; // what they will have to
} // No Deposit
if ($dep_rate > 0) { // don't send any bill if they have already paid everything
session_add2($dep_date, "10:00:00", $_REQUEST['fid'], 1, $dep_rate,0, 2000, '', (int)$msg, $_REQUEST['student_name'],'','For LD SAT Prep Session '.$_REQUEST['class']);
}
// END ADDED BY PAUL 2012/01/09
}
}
if (!$msg || is_int($msg))
echo "<div class=text_success style='text-align:center'>The data has been saved.</div>";
else
echo $msg;
echo "<br>";
echo '<script type="text/javascript">opener_reload();</script>';
}
if ($id){
$FieldsRS = runquery($QStr);
$arFieldsVals = mysql_fetch_array($FieldsRS);
}
$arr_classes[1] = "One on one Tutoring";
$QStrsi = runquery("select id, class_name from $strTableName2 ORDER BY id desc");
while($arsi = mysql_fetch_array($QStrsi)){
$text_class = ($sem == 1 ? "Seminar" : "Class ").$arsi[class_name];
$arr_classes[$arsi[id]] = $text_class;
if ($arFieldsVals[($sem == 1 ? "seminar_id" : "class")] == $arsi[id])
$class_sel = $text_class;
}
if ($id){
putHiddenField("id", $id);
putHiddenField("action", "update");
$strNotUsed = "id,fid,class,seminar_id";
}else{
putHiddenField("action", "insert");
$strNotUsed = "id,fid,class,seminar_id,name,username,password,phone_number,email,parent_name";
}
$strNotUsed = $strNotUsed . ", student_id, student_name";
putHiddenField("strNotUsed", $strNotUsed);
?>
<tr><td align=right > Select the Student<font color="#FF0000">*</font> </td><td>
<select name="student_id" id="student_id" >
<option>Select a Student</option>
<?
$SQS = "select id, first_name, last_name from PTStudentInfo_New order by first_name";
$SRS = runquery($SQS);
While($arTI = mysql_fetch_array($SRS)){
// if a student is being edited, make sure that student is selected
if($_REQUEST[student_id] == $arTI[0]){
$selected = "selected";
} else {
$selected = "";
}
?>
<option value="<?="$arTI[0] $selected";?>">
<?
echo "$arTI[1] $arTI[last_name] $_REQUEST[student_id] == $arTI[0]";
?>
</option>
<? } ?>
</select>
</td></tr>
<tr height=10><td></td></tr>
<?
putSelectInput(($sem == 1 ? "Seminar" : "Class").'<font color="#FF0000">*</font> ', ($sem == 1 ? 'seminar_id' : 'class'), $arr_classes, ($class_sel!='' ? $class_sel : $_REQUEST['cls']), '', '','Choose');
echo '<tr height=10><td></td></tr>';
?>
<tr>
<td colspan="2">
<?
MySQL_JustForm($strTableName, "", $arFieldsVals, $arFieldComments, $arHidden, $strNotUsed, $formName);
?>
</td>
</tr>
<?php
$arRequired = array();
$ardis[1] = "yes";
$ardis[0] = "no";
putSelectInput('Deposit Required', 'deposit', $ardis, '', 'Is a deposit required', 'required', $labelFirst ='');
MySQL_JustForm_End($arRequired, "form1","");
?>
</table></div>
</fieldset></td></tr>
<tr>
<td><fieldset class="submit">
<button type="submit" name="Submit">Save</button>
<button onclick="popup_close()">Close</button>
</fieldset></td>
</tr>
</form></td></tr></table>
<?
put_ptts_footer("popup");
?>