-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStudent.php
437 lines (384 loc) · 16.7 KB
/
Student.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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Student extends CI_Controller {
/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* @see https://codeigniter.com/user_guide/general/urls.html
*/
public function __construct()
{
parent::__construct();
is_logged_in();
$this->load->model('Student_model');
$this->load->library('form_validation');
}
public function index()
{
$data['all_students'] = $this->Student_model->all_students();
$this->load->view('student/list',$data);
}
public function new_student()
{
if($this->input->post('register'))
{
$this->form_validation->set_rules('enrollement', 'Enrollement Number', 'trim|required');
$this->form_validation->set_rules('aadhar', 'Aadhar Number', 'trim');
$this->form_validation->set_rules('sname', 'Student Name', 'trim|required');
$this->form_validation->set_rules('fname', 'Father Name', 'trim|required');
$this->form_validation->set_rules('mname', 'Mother Name', 'trim');
$this->form_validation->set_rules('caste_name', 'Student Caste', 'trim|required');
$this->form_validation->set_rules('gender', 'Student Gender', 'trim|required');
$this->form_validation->set_rules('dob', 'Date of Birth', 'trim|required');
$this->form_validation->set_rules('address', 'Address', 'trim|required');
$this->form_validation->set_rules('mobile', 'Mobile', 'trim|required|is_natural_no_zero|exact_length[10]');
$this->form_validation->set_rules('alt_mobile', 'Alternate Mobile', 'trim|is_natural_no_zero|exact_length[10]');
$this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
$this->form_validation->set_rules('course_name', 'Course Name', 'trim|required');
$this->form_validation->set_rules('course_fee', 'Course Fee', 'trim|required|is_natural');
$this->form_validation->set_rules('tax', 'Tax', 'trim|required|is_natural');
$this->form_validation->set_rules('course_duration', 'Course Duration', 'trim|required');
$this->form_validation->set_rules('discount', 'Course Discount', 'trim|required|is_natural|less_than[11]');
$this->form_validation->set_rules('join_date', 'Join Date', 'trim|required');
$this->form_validation->set_rules('marksheet_sc', 'marksheet sc', 'trim');
$this->form_validation->set_rules('education_type', 'Education Type', 'trim|required');
$this->form_validation->set_rules('remark', 'Remark', 'trim');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('student/new');
}
else
{
$result = $this->Student_model->new_student();
if($result == false)
{
$this->session->set_flashdata('error_msg','Student not added, Please try again');
}
else
{
$this->session->set_flashdata('success_msg','Student added successfully');
$this->load->helper('sms');
$reg_no = $this->input->post('enrollement');
$this->load->model('Course_model');
$course = $this->Course_model->course_by_code($this->input->post('course_name'));
$mobile = $this->input->post('mobile');
$name = $this->input->post('sname');
$student_totalfee = $this->student_totalfee($reg_no);
$message = "Dear $name,Thanks for joining Excel Computer Classes for $course.Your Enrolment number is $reg_no. Course fee is $student_totalfee";
send_sms($mobile, $message);
}
redirect('student/new_student');
}
}
else
{
$this->load->view('student/new');
}
}
public function edit($student_id = '')
{
if($this->input->post('edit_student'))
{
//print_r($_POST); exit;
$this->form_validation->set_rules('enrollement', 'Enrollement Number', 'trim|required');
$this->form_validation->set_rules('aadhar', 'Aadhar Number', 'trim');
$this->form_validation->set_rules('sname', 'Student Name', 'trim|required');
$this->form_validation->set_rules('fname', 'Father Name', 'trim|required');
$this->form_validation->set_rules('mname', 'Mother Name', 'trim');
$this->form_validation->set_rules('caste_name', 'Student Caste', 'trim|required');
$this->form_validation->set_rules('gender', 'Student Gender', 'trim|required');
$this->form_validation->set_rules('dob', 'Date of Birth', 'trim|required');
$this->form_validation->set_rules('address', 'Address', 'trim|required');
$this->form_validation->set_rules('mobile', 'Mobile', 'trim|required|is_natural_no_zero|exact_length[10]');
$this->form_validation->set_rules('alt_mobile', 'Alternate Mobile', 'trim|is_natural_no_zero|exact_length[10]');
$this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
$this->form_validation->set_rules('course_name', 'Course Name', 'trim|required');
$this->form_validation->set_rules('course_fee', 'Course Fee', 'trim|required|is_natural');
$this->form_validation->set_rules('tax', 'Tax', 'trim|required|is_natural');
$this->form_validation->set_rules('course_duration', 'Course Duration', 'trim|required');
$this->form_validation->set_rules('discount', 'Course Discount', 'trim|required|is_natural');
$this->form_validation->set_rules('join_date', 'Join Date', 'trim|required');
$this->form_validation->set_rules('education_type', 'Education Type', 'trim|required');
$this->form_validation->set_rules('remark', 'Remark', 'trim');
$student_id = $this->input->post('student_id');
if ($this->form_validation->run() == FALSE)
{
$data['student_data'] = $this->Student_model->view_student($student_id);
$this->load->view('student/edit', $data );
}
else
{
$result = $this->Student_model->edit_student();
if($result == false)
{
$this->session->set_flashdata('error_msg','Student not update, Please try again');
}
else
{
$this->session->set_flashdata('success_msg','Student update successfully');
}
redirect('student/edit/'.$student_id);
}
}
else
{
$data['student_data'] = $this->Student_model->view_student($student_id);
$this->load->view('student/edit', $data );
}
}
public function view($student_id = '')
{
if($this->input->post('edit_student'))
{
//print_r($_POST); exit;
$this->form_validation->set_rules('enrollement', 'Enrollement Number', 'trim|required');
$this->form_validation->set_rules('aadhar', 'Aadhar Number', 'trim');
$this->form_validation->set_rules('sname', 'Student Name', 'trim|required');
$this->form_validation->set_rules('fname', 'Father Name', 'trim|required');
$this->form_validation->set_rules('mname', 'Mother Name', 'trim');
$this->form_validation->set_rules('caste_name', 'Student Caste', 'trim|required');
$this->form_validation->set_rules('dob', 'Date of Birth', 'trim|required');
$this->form_validation->set_rules('address', 'Address', 'trim|required');
$this->form_validation->set_rules('mobile', 'Mobile', 'trim|required|is_natural_no_zero|exact_length[10]');
$this->form_validation->set_rules('alt_mobile', 'Alternate Mobile', 'trim|is_natural_no_zero|exact_length[10]');
$this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
$this->form_validation->set_rules('course_name', 'Course Name', 'trim|required');
$this->form_validation->set_rules('course_fee', 'Course Fee', 'trim|required|is_natural');
$this->form_validation->set_rules('tax', 'Tax', 'trim|required|is_natural');
$this->form_validation->set_rules('course_duration', 'Course Duration', 'trim|required');
$this->form_validation->set_rules('discount', 'Course Discount', 'trim|required|is_natural');
$this->form_validation->set_rules('join_date', 'Join Date', 'trim|required');
$this->form_validation->set_rules('remark', 'Remark', 'trim');
$student_id = $this->input->post('student_id');
if ($this->form_validation->run() == FALSE)
{
$data['student_data'] = $this->Student_model->view_student($student_id);
$this->load->view('student/view', $data );
}
else
{
$result = $this->Student_model->edit_student();
if($result == false)
{
$this->session->set_flashdata('error_msg','Student not update, Please try again');
}
else
{
$this->session->set_flashdata('success_msg','Student update successfully');
}
redirect('student/view/'.$student_id);
}
}
else
{
$data['student_data'] = $this->Student_model->view_student($student_id);
$this->load->view('student/view', $data );
}
}
public function ajax_load()
{
$course_code = $this->input->post('course_code');
$result = $this->Student_model->ajax_load_course($course_code);
$tax = ( $result['course_fee'] * 18)/ 100;
$result['tax'] = $tax;
echo json_encode($result);
}
public function fee($enrollment='')
{
$result = $this->Student_model->view_student_by_enroll($enrollment);
$total_fee = $result['course_fee'] + $result['tax_amount'];
$discount = ($total_fee * $result['course_discount']) / 100;
$amount_to_paid= $total_fee - $discount;
$result['discount_price'] = $discount;
$result['amount_to_paid'] = $amount_to_paid;
$data['student_data']= $result;
$data['student_fee'] = $this->Student_model->student_fee($enrollment);
$data['amount_deposited'] = $this->Student_model->amount_deposited($enrollment);
if($this->input->post('submit_fee'))
{
$balance = $this->input->post('amount_pending');
$this->form_validation->set_rules('amount_add', 'Amount Received', 'trim|required|is_natural|callback_check_equal_less['.$balance.']');
$this->form_validation->set_rules('remark', 'Remark', 'trim');
$this->form_validation->set_rules('due_date', 'Due Date', 'trim|required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('student/fee', $data);
}
else
{
$result = $this->Student_model->add_fee();
if($result == false)
{
$this->session->set_flashdata('error_msg','Fee not added, Please try again');
}
else
{
$this->send_notification($this->input->post('enrollement'), $result);
$this->session->set_flashdata('success_msg','Fee added successfully');
}
redirect('student/fee/'.$enrollment);
}
}
else
{
$this->load->view('student/fee',$data);
}
}
public function editfee($enrollment, $fee_id)
{
$result = $this->Student_model->view_student_by_enroll($enrollment);
$total_fee = $result['course_fee'] + $result['tax_amount'];
$discount = ($total_fee * $result['course_discount']) / 100;
$amount_to_paid= $total_fee - $discount;
$result['discount_price'] = $discount;
$result['amount_to_paid'] = $amount_to_paid;
$data['student_data']= $result;
$data['student_fee'] = $this->Student_model->student_fee($enrollment);
$data['amount_deposited'] = $this->Student_model->amount_deposited($enrollment);
$data['receipt_data'] = $this->Student_model->fee_receipt($fee_id);
if($this->input->post('update_fee'))
{
$this->form_validation->set_rules('amount_add', 'Amount Received', 'trim|required|is_natural');
$this->form_validation->set_rules('remark', 'Remark', 'trim');
$this->form_validation->set_rules('due_date', 'Due Date', 'trim|required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('student/edit-fee', $data);
}
else
{
$result = $this->Student_model->update_fee();
if($result == false)
{
$this->session->set_flashdata('error_msg','Fee not update, Please try again');
}
else
{
$this->session->set_flashdata('success_msg','Fee update successfully');
}
redirect('student/fee/'.$enrollment);
}
}
else
{
$this->load->view('student/edit-fee',$data);
}
}
public function receipt($enrollment, $receipt_id='')
{
$result = $this->Student_model->view_student_by_enroll($enrollment);
$total_fee = $result['course_fee'] + $result['tax_amount'];
$discount = ($total_fee * $result['course_discount']) / 100;
$amount_to_paid= $total_fee - $discount;
$result['discount_price'] = $discount;
$result['amount_to_paid'] = $amount_to_paid;
$data['student_data']= $result;
$data['student_fee'] = $this->Student_model->student_fee($enrollment);
$data['amount_deposited'] = $this->Student_model->amount_deposited($enrollment);
$data['receipt_data'] = $this->Student_model->fee_receipt($receipt_id);
$this->load->library('numbertowords');
$data['amount_words'] = $this->numbertowords->convert_number($data['receipt_data']['amount']);
@unlink(FCPATH.'tes.png');
// QR code
$this->load->library('ciqrcode');
$config['cacheable'] = false;
$qr_text = $result['enrollment'].",".$result['student_name'].",".$data['receipt_data']['amount'].",tid:".$data['receipt_data']['tid'];
$params['data'] = $qr_text;
$params['size'] = 2;
$params['savename'] = FCPATH.'tes.png';
$this->ciqrcode->initialize($config);
$this->ciqrcode->generate($params);
$this->load->view('student/receipt', $data);
// End QR code
}
public function receiptView($enrollment, $receipt_id='')
{
$result = $this->Student_model->view_student_by_id($enrollment);
/* $total_fee = $result['course_fee'] + $result['tax_amount'];
$discount = ($total_fee * $result['course_discount']) / 100;
$amount_to_paid= $total_fee - $discount;
$result['discount_price'] = $discount;
$result['amount_to_paid'] = $amount_to_paid; */
$data['student_data']= $result;
$data['student_fee'] = $this->Student_model->student_fee($enrollment);
$data['amount_deposited'] = $this->Student_model->amount_deposited($enrollment);
$data['receipt_data'] = $this->Student_model->fee_receipt($receipt_id);
//$this->load->library('numbertowords');
//$data['amount_words'] = $this->numbertowords->convert_number($data['receipt_data']['amount']);
@unlink(FCPATH.'tes.png');
// QR code
$this->load->library('ciqrcode');
$config['cacheable'] = false;
$qr_text = $result['enrollment'].",".$result['student_name'].",".$data['receipt_data']['amount'].",tid:".$data['receipt_data']['tid'];
$params['data'] = $qr_text;
$params['size'] = 2;
$params['savename'] = FCPATH.'tes.png';
$this->ciqrcode->initialize($config);
$this->ciqrcode->generate($params);
$this->load->view('student/receiptView', $data);
// End QR code
}
public function test()
{
// QR code
$this->load->library('ciqrcode');
$this->load->library('ciqrcode');
$params['data'] = 'This is a text to encode become QR Code';
$params['size'] = 2;
$params['savename'] = FCPATH.'tes.png';
$this->ciqrcode->generate($params);
echo '<img src="'.base_url().'tes.png" />';
// End QR code
}
public function student_totalfee($enrollment)
{
$result = $this->Student_model->view_student_by_enroll($enrollment);
$total_fee = $result['course_fee'] + $result['tax_amount'];
$discount = ($total_fee * $result['course_discount']) / 100;
$amount_to_paid= $total_fee - $discount;
return $amount_to_paid;
}
public function send_notification($enrollment, $receipt_id='')
{
$result = $this->Student_model->view_student_by_enroll($enrollment);
$total_fee = $result['course_fee'] + $result['tax_amount'];
$discount = ($total_fee * $result['course_discount']) / 100;
$amount_to_paid= $total_fee - $discount;
$result['discount_price'] = $discount;
$student_data= $result;
$student_fee = $this->Student_model->student_fee($enrollment);
$amount_deposited = $this->Student_model->amount_deposited($enrollment);
$receipt_data = $this->Student_model->fee_receipt($receipt_id);
$balance = $amount_to_paid - $amount_deposited;
$this->load->model('Enquiry_model');
$course_name = $this->Enquiry_model->course_name($student_data['course_code']);
$due_date = date('d-M-Y', strtotime($receipt_data['due_date']));
if($balance > 0) {
$message = "Dear ".$student_data['student_name']." Thanks for depositing ".$receipt_data['amount']." INR for ".$course_name.". Your balance amount ".$balance." and due date is ". $due_date;
} else {
$message = "Dear ".$student_data['student_name']." Thanks for depositing ".$receipt_data['amount']." INR for ".$course_name;
}
$this->load->helper('sms');
send_sms($student_data['phone'], $message);
}
function check_equal_less($amount, $balance)
{
if ($amount > $balance || $amount <=0)
{
$this->form_validation->set_message('check_equal_less', 'Wrong amount paid');
return false;
} else {
return true;
}
}
}