?
Current Path : /home1/savoy/public_html/savoyglobal.net/eduplus2/application/models/ |
Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 |
Current File : /home1/savoy/public_html/savoyglobal.net/eduplus2/application/models/studentmodel.php |
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class Studentmodel extends CI_Model { function __construct() { // Call the Model constructor parent::__construct(); // $this->load->model('hrmodel'); } function search_student() { $data = array(); $this->db->select('*'); $this->db->from('student'); $this->db->join('master', 'master_id=student_id'); $this->db->order_by('student_id', 'desc'); $data['results'] = $this->db->get(); return $data; } function insert_student($postdata) { $data = array(); $this->db->trans_begin(); $studentid = $this->mastermodel->insertmasterdata(); $class_name_id = $postdata['class_name_id']; $dob = $this->mastermodel->convertdateformat($postdata['dob']); $reg_no = $this->mastermodel->get_student_number(); $tblValues = array( 'student_id' => $studentid, 'reg_no' => $reg_no, 'first_name' => $postdata['first_name'], 'last_name' => $postdata['last_name'], 'gender' => $postdata['gender'], 'dob' => $dob, 'admission_date' => $this->mastermodel->convertdateformat($postdata['admission_date']), 'nationality_id' => $postdata['nationality_id'], 'qatar_id' => $postdata['qatar_id'], 'blood_group' => $postdata['blood_group'], 'previous_medical_illness' => $postdata['previous_medical_illness'], 'address' => $postdata['address'], 'languages' => $postdata['languages'], 'photo' => $postdata['attach_photo'], ); $this->db->insert('student', $tblValues); $parent = $this->mastermodel->get_account_settings('student', 'finance_sub_account_settings'); if ($parent) { $chart_type_id = $this->mastermodel->get_single_field_value('finance_chart_master', 'chart_type_id', 'chart_master_id', $parent); if ($this->mastermodel->get_num_rows('finance_chart_master', 'chart_account_code', $reg_no) == 0) { $tblValues = array('chart_account_code' => $reg_no, 'chart_account_name' => $postdata['first_name'] . '-' . $postdata['last_name'], 'chart_type_id' => $chart_type_id, 'parent' => $parent, 'inactive' => 0); $this->db->insert('finance_chart_master', $tblValues); } else { $tblValues = array( 'chart_account_name' => $postdata['first_name'] . '-' . $postdata['last_name'], 'chart_type_id' => $chart_type_id, 'parent' => $parent, 'inactive' => 0); $this->db->where('chart_account_code', $reg_no); $this->db->update('finance_chart_master', $tblValues); } } if ($postdata['parentdiv'] == 0) { $parentid = $this->mastermodel->insertmasterdata(); $tblValues = array( 'parent_id' => $parentid, 'father_name' => $postdata['father_name'], 'father_qatar_id_no' => $postdata['father_qatar_id_no'], 'father_occupation' => $postdata['father_occupation'], 'father_mobile_no' => $postdata['father_mobile_no'], 'father_email' => $postdata['father_email'], 'father_ofc_no' => $postdata['father_ofc_no'], 'father_residence_no' => $postdata['father_residence_no'], 'mother_name' => $postdata['mother_name'], 'mother_qatar_id_no' => $postdata['mother_qatar_id_no'], 'mother_occupation' => $postdata['mother_occupation'], 'mother_mobile_no' => $postdata['mother_mobile_no'], 'mother_ofc_no' => $postdata['mother_ofc_no'], 'mother_residence_no' => $postdata['mother_residence_no'], 'mother_email' => $postdata['mother_email'], 'emergency_contact_no' => $postdata['emergency_contact_no'], ); $this->db->insert('parent', $tblValues); $tblValues = array( 'parent_id' => $parentid, 'student_id' => $studentid ); $this->db->insert('parent_student', $tblValues); } else if ($postdata['parentdiv'] == 1) { $tblValues = array( 'parent_id' => $postdata['parent_id'], 'student_id' => $studentid ); $this->db->insert('parent_student', $tblValues); } if ($class_name_id != 0 && $class_name_id != '') { $student_class_id = $this->mastermodel->insertmasterdata(); $tblValues = array( 'student_class_id' => $student_class_id, 'class_name_id' => $class_name_id, 'student_id' => $studentid, 'no_of_days' => $postdata['fee_term_no_of_days'], 'term_id' => $postdata['term_id'], 'class_allocation_date' => $this->mastermodel->convertdateformat($postdata['class_allocation_date']) ); $this->db->insert('student_class', $tblValues); $remarks = "Updated " . $postdata["first_name"] . "'s Class allocation details"; $tblValues = array( 'student_class_id' => $student_class_id, 'allocation_date' => $this->mastermodel->convertdateformat($postdata['class_allocation_date']), 'remarks' => $remarks ); $this->db->insert('student_class_details', $tblValues); if (isset($postdata['add_fee_particular'])) { foreach ($postdata['add_fee_particular'] as $key => $new_list) { $i = $postdata['add_fee_particular'][$key]; if ($postdata['pay_amount_' . $i] != "" && $postdata['payment_type_' . $i] != "") { $pay_amount = $postdata['pay_amount_' . $i]; $tblValues = array( 'student_class_id' => $student_class_id, 'fee_particular_id' => $postdata['particular_id_' . $i], 'payment_type' => $postdata['payment_type_' . $i], 'fee_amount' => $pay_amount ); $this->db->insert('student_class_fee', $tblValues); $student_class_fee_id = mysql_insert_id(); if ($postdata['payment_type_' . $i] == "monthly") { $j = 1; while (isset($postdata['pay_amount_' . $i . '_' . $j])) { $pay_amount = $postdata['pay_amount_' . $i . '_' . $j]; $tblValues = array( 'student_class_fee_id' => $student_class_fee_id, 'fee_wef_date' => $this->mastermodel->convertdateformat($postdata['wef_date_' . $i . '_' . $j]), 'amount' => $pay_amount ); // var_dump($tblValues); // echo "<br/>"; $j++; $this->db->insert('student_monthly_fee', $tblValues); } } } } } $k = 1; $class_term_id = $postdata['class_term_id_add']; $class_name_academic_year_id = $postdata['class_name_academic_year_id_add']; $class_session = $postdata['class_session_add']; if (isset($postdata['fee_particular_id_new_1']) && $postdata['fee_particular_id_new_1'] != '') { $feeterm_id = ""; $feeterm = $this->studentmodel->entry_added_feeterm($class_term_id, $class_name_academic_year_id, $class_session); if (count($feeterm) < 1) { $masterid_1 = $this->mastermodel->insertmasterdata(); $tbl1Values = array( 'fee_term_id' => $masterid_1, 'fee_term_term_id' => $class_term_id, 'fee_term_session' => $class_session, 'fee_term_academic_year_id' => $class_name_academic_year_id, 'refund_bond_amount' => 0, 'fee_term_due_date' => $this->mastermodel->convertdateformat($postdata['fee_term_due_date']) ); $this->db->insert('fee_term', $tbl1Values); $feeterm_id = $masterid_1; $i = 1; while (isset($postdata['fee_particular_id_new_' . $i])) { if (isset($postdata['pay_amount_new_' . $i])) $term_amount = $postdata['pay_amount_new_' . $i]; else $term_amount = 0; if ($postdata['payment_type_new_' . $i] == "monthly") { $j = 1; while (isset($postdata['pay_amount_new_' . $i . '_' . $j])) { $monthly_amount = $postdata['pay_amount_new_' . $i . '_' . $j]; } } else $monthly_amount = 0; $tbl1Values = array( 'fee_term_id' => $feeterm_id, 'fee_particular_id' => $postdata['fee_particular_id_new_' . $i], 'fee_term_amount' => $term_amount, 'fee_month_amount' => $monthly_amount, 'fee_term_no_of_days' => $postdata['fee_term_no_of_days_new_' . $i] ); $this->db->insert('fee_term_details', $tbl1Values); if (isset($postdata['month_date'])) { foreach ($postdata['month_date'] as $month_date) { $tbl1Values = array( 'fee_term_id' => $feeterm_id, 'fee_term_monthly_due_date' => $month_date ); $this->db->insert('fee_term_due_date', $tbl1Values); } } $pay_amount = $postdata['pay_amount_new_' . $i]; $tblValues = array( 'student_class_id' => $student_class_id, 'fee_particular_id' => $postdata['fee_particular_id_new_' . $i], 'payment_type' => $postdata['payment_type_new_' . $i], 'fee_amount' => $pay_amount ); $this->db->insert('student_class_fee', $tblValues); $student_class_fee_id = mysql_insert_id(); if ($postdata['payment_type_new_' . $i] == "monthly") { $j = 1; while (isset($postdata['pay_amount_new_' . $i . '_' . $j])) { $monthly_amount = $postdata['pay_amount_new_' . $i . '_' . $j]; $tblValues = array( 'student_class_fee_id' => $student_class_fee_id, 'fee_wef_date' => $this->mastermodel->convertdateformat($postdata['wef_date_' . $i . '_' . $j]), 'amount' => $monthly_amount ); $j++; $this->db->insert('student_monthly_fee', $tblValues); } } $i++; } } else { $feeterm_id = $feeterm->fee_term_id; $i = 1; while (isset($postdata['fee_particular_id_new_' . $i])) { if (isset($postdata['pay_amount_new_' . $i])) $term_amount = $postdata['pay_amount_new_' . $i]; else $term_amount = 0; if ($postdata['payment_type_new_' . $i] == "monthly") { $j = 1; while (isset($postdata['pay_amount_new_' . $i . '_' . $j])) { $monthly_amount = $postdata['pay_amount_new_' . $i . '_' . $j]; } } else $monthly_amount = 0; $tbl1Values = array( 'fee_term_id' => $feeterm_id, 'fee_particular_id' => $postdata['fee_particular_id_new_' . $i], 'fee_term_amount' => $term_amount, 'fee_month_amount' => $monthly_amount, 'fee_term_no_of_days' => $postdata['fee_term_no_of_days_new_' . $i] ); $this->db->insert('fee_term_details', $tbl1Values); if (isset($postdata['month_date'])) { foreach ($postdata['month_date'] as $month_date) { $tbl1Values = array( 'fee_term_id' => $masterid, 'fee_term_monthly_due_date' => $month_date ); $this->db->insert('fee_term_due_date', $tbl1Values); } } $pay_amount = $postdata['pay_amount_new_' . $i]; $tblValues = array( 'student_class_id' => $student_class_id, 'fee_particular_id' => $postdata['fee_particular_id_new_' . $i], 'payment_type' => $postdata['payment_type_new_' . $i], 'fee_amount' => $pay_amount ); $this->db->insert('student_class_fee', $tblValues); $student_class_fee_id = mysql_insert_id(); if ($postdata['payment_type_new_' . $i] == "monthly") { $j = 1; while (isset($postdata['pay_amount_new_' . $i . '_' . $j])) { $monthly_amount = $postdata['pay_amount_new_' . $i . '_' . $j]; $tblValues = array( 'student_class_fee_id' => $student_class_fee_id, 'fee_wef_date' => $this->mastermodel->convertdateformat($postdata['wef_date_' . $i . '_' . $j]), 'amount' => $monthly_amount ); $j++; $this->db->insert('student_monthly_fee', $tblValues); } } $i++; } } } else if (isset($postdata['fee_particular_id_new_new_1']) && $postdata['fee_particular_id_new_new_1'] != '') { $feeterm_id = ""; $feeterm = $this->studentmodel->entry_added_feeterm($class_term_id, $class_name_academic_year_id, $class_session); if (count($feeterm) < 1) { $data = array(); $this->db->trans_begin(); $masterid_2 = $this->mastermodel->insertmasterdata(); $tbl1Values = array( 'fee_term_id' => $masterid_2, 'fee_term_term_id' => $class_term_id, 'fee_term_session' => $class_session, 'fee_term_academic_year_id' => $class_name_academic_year_id, 'refund_bond_amount' => 0, 'fee_term_due_date' => $this->mastermodel->convertdateformat($postdata['fee_term_due_date_new_new']) ); $this->db->insert('fee_term', $tbl1Values); echo $this->db->last_query(); $i = 1; while (isset($postdata['fee_particular_id_new_new_' . $i])) { if ($postdata['pay_amount_term_' . $i] == '') { $pay_amount_term = 0; $pay_amount_month = $postdata['pay_amount_month_' . $i]; $tbl1Values = array( 'fee_term_id' => $masterid_2, 'fee_particular_id' => $postdata['fee_particular_id_new_new_' . $i], 'fee_term_amount' => $pay_amount_term, 'fee_month_amount' => $pay_amount_month, 'fee_term_no_of_days' => $postdata['fee_term_no_of_days_new_new_' . $i] ); $this->db->insert('fee_term_details', $tbl1Values); echo $this->db->last_query(); } if ($postdata['pay_amount_month_' . $i] == '') { $pay_amount_month = 0; $pay_amount_term = $postdata['pay_amount_term_' . $i]; $tbl1Values = array( 'fee_term_id' => $masterid_2, 'fee_particular_id' => $postdata['fee_particular_id_new_new_' . $i], 'fee_term_amount' => $pay_amount_term, 'fee_month_amount' => $pay_amount_month, 'fee_term_no_of_days' => $postdata['fee_term_no_of_days_new_new_' . $i] ); $this->db->insert('fee_term_details', $tbl1Values); echo $this->db->last_query(); } if ($postdata['pay_amount_term_' . $i] != '') { $pay_amount = $postdata['pay_amount_term_' . $i]; $tblValues = array( 'student_class_id' => $student_class_id, 'fee_particular_id' => $postdata['fee_particular_id_new_new_' . $i], 'payment_type' => $postdata['payment_type_new_new_' . $i], 'fee_amount' => $pay_amount ); $this->db->insert('student_class_fee', $tblValues); echo $this->db->last_query(); $student_class_fee_id = mysql_insert_id(); } else { $pay_amount = 0; $tblValues = array( 'student_class_id' => $student_class_id, 'fee_particular_id' => $postdata['fee_particular_id_new_new_' . $i], 'payment_type' => $postdata['payment_type_new_new_' . $i], 'fee_amount' => $pay_amount ); $this->db->insert('student_class_fee', $tblValues); echo $this->db->last_query(); $student_class_fee_id = mysql_insert_id(); } if ($postdata['payment_type_new_new_' . $i] == "monthly") { var_dump($postdata['month_date']) . "shan1"; foreach ($postdata['month_date'] as $month_date) { $monthly_amount = $postdata['pay_amount_month_' . $i]; $tblValues = array( 'student_class_fee_id' => $student_class_fee_id, 'fee_wef_date' => $month_date, 'amount' => $monthly_amount ); $this->db->insert('student_monthly_fee', $tblValues); echo $this->db->last_query(); } } $i++; } if (isset($postdata['month_date'])) { var_dump($postdata['month_date']) . "shan"; foreach ($postdata['month_date'] as $month_date) { $tbl1Values = array( 'fee_term_id' => $masterid_2, 'fee_term_monthly_due_date' => $month_date ); $this->db->insert('fee_term_due_date', $tbl1Values); echo $this->db->last_query(); } } } } } $data['resfunction'] = 'search_student'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function update_student($postdata) { $data = array(); $this->db->trans_begin(); $dob = $this->mastermodel->convertdateformat($postdata['dob']); $tblValues = array( 'first_name' => $postdata['first_name'], 'last_name' => $postdata['last_name'], 'gender' => $postdata['gender'], 'dob' => $dob, 'admission_date' => $this->mastermodel->convertdateformat($postdata['admission_date']), 'nationality_id' => $postdata['nationality_id'], 'qatar_id' => $postdata['qatar_id'], 'blood_group' => $postdata['blood_group'], 'previous_medical_illness' => $postdata['previous_medical_illness'], 'address' => $postdata['address'], 'languages' => $postdata['languages'] ); $this->db->where('student_id', $postdata['student_id']); $this->db->update('student', $tblValues); $tblValues = array( 'father_name' => $postdata['father_name'], 'father_qatar_id_no' => $postdata['father_qatar_id_no'], 'father_occupation' => $postdata['father_occupation'], 'father_mobile_no' => $postdata['father_mobile_no'], 'father_email' => $postdata['father_email'], 'father_ofc_no' => $postdata['father_ofc_no'], 'father_residence_no' => $postdata['father_residence_no'], 'mother_name' => $postdata['mother_name'], 'mother_qatar_id_no' => $postdata['mother_qatar_id_no'], 'mother_occupation' => $postdata['mother_occupation'], 'mother_mobile_no' => $postdata['mother_mobile_no'], 'mother_ofc_no' => $postdata['mother_ofc_no'], 'mother_residence_no' => $postdata['mother_residence_no'], 'mother_email' => $postdata['mother_email'], 'emergency_contact_no' => $postdata['emergency_contact_no'], ); $this->db->where('parent_id', $postdata['parent_id']); $this->db->update('parent', $tblValues); if ($postdata['attach_photo'] != '') { $tblValues = array( 'photo' => $postdata['attach_photo'], ); $this->db->where('student_id', $postdata['student_id']); $this->db->update('student', $tblValues); } if(isset($postdata['parentdiv'])) { if ($postdata['parentdiv'] == 1) { $tblValues = array( 'parent_id' => $postdata['parent_id'], ); $this->db->where('student_id', $postdata['student_id']); $this->db->update('parent_student', $tblValues); } } $data['resfunction'] = 'search_student'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Updated Successfully'; return $data; } } function insert_roll_over($postdata) { $data = array(); $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $tblValues = array( 'rollover_id' => $masterid, 'current_class_id' => $postdata['class_name_id'], 'rollover_class_id' => $postdata['class_name_rollover_id'], 'allocation_date' => $this->mastermodel->convertdateformat($postdata['allocation_date']), ); $this->db->insert('rollover', $tblValues); if (isset($postdata['add_roll_over'])) { foreach ($postdata['add_roll_over'] as $value) { $tblValues = array( 'rollover_id' => $masterid, 'student_id' => $value ); $this->db->insert('rollover_students', $tblValues); $class_name_id = $postdata['class_name_rollover_id']; $class_info = $this->mastermodel->get_data_srow('class_name', $class_name_id, 'class_name_id'); $student_id = $value; $student_info = $this->mastermodel->get_data_srow('student', $student_id, 'student_id'); $student_class = $postdata['student_class_id_' . $student_id]; $term_id = $class_info->class_term_id; if ($student_class == 0) { $student_class = $this->studentmodel->get_student_class_id($student_id, $class_name_id, $term_id); } if ($student_class == 0) { $student_class_id = $this->mastermodel->insertmasterdata(); $tblValues = array( 'student_class_id' => $student_class_id, 'class_name_id' => $class_name_id, 'student_id' => $student_id, // 'no_of_days' => $postdata['fee_term_no_of_days'], 'term_id' => $term_id, 'class_allocation_date' => $this->mastermodel->convertdateformat($postdata['allocation_date']) ); $this->db->insert('student_class', $tblValues); $remarks = "Added $student_info->first_name to $class_info->class_name_code"; } else { $student_class_id = $student_class; $tblValues = array( 'class_name_id' => $class_name_id, 'student_id' => $student_id, // 'no_of_days' => $postdata['fee_term_no_of_days'], 'class_allocation_date' => $this->mastermodel->convertdateformat($postdata['allocation_date']) ); $this->db->where('student_class_id', $student_class_id); $this->db->update('student_class', $tblValues); $remarks = "Updated $student_info->first_name's Class allocation details"; } $tblValues = array( 'student_class_id' => $student_class_id, 'allocation_date' => $this->mastermodel->convertdateformat($postdata['allocation_date']), 'remarks' => $remarks ); $this->db->insert('student_class_details', $tblValues); } } $data['resfunction'] = 'search_roll_over'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function update_roll_over() { $data = array(); $this->db->trans_begin(); $tblValues = array( 'current_class_id' => $postdata['class_name_id'], 'rollover_class_id' => $postdata['class_name_rollover_id'], 'allocation_date' => $this->mastermodel->convertdateformat($postdata['allocation_date']), ); $this->db->insert('rollover', $tblValues); if (isset($postdata['add_roll_over'])) { foreach ($postdata['add_roll_over'] as $value) { $tblValues = array( 'rollover_id' => $masterid, 'student_id' => $value ); $this->db->insert('rollover_students', $tblValues); } } $data['resfunction'] = 'search_roll_over'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function search_parents() { $data = array(); $this->db->select('*'); $this->db->from('parent'); $this->db->join('master', 'master_id=parent_id'); $this->db->order_by('parent_id', 'desc'); $data['results'] = $this->db->get(); return $data; } function insert_parent($postdata) { $data = array(); $this->db->trans_begin(); $parentid = $this->mastermodel->insertmasterdata(); $tblValues = array( 'parent_id' => $parentid, 'father_name' => $postdata['father_name'], 'father_qatar_id_no' => $postdata['father_qatar_id_no'], 'father_occupation' => $postdata['father_occupation'], 'father_mobile_no' => $postdata['father_mobile_no'], 'father_email' => $postdata['father_email'], 'father_ofc_no' => $postdata['father_ofc_no'], 'father_residence_no' => $postdata['father_residence_no'], 'mother_name' => $postdata['mother_name'], 'mother_qatar_id_no' => $postdata['mother_qatar_id_no'], 'mother_occupation' => $postdata['mother_occupation'], 'mother_mobile_no' => $postdata['mother_mobile_no'], 'mother_ofc_no' => $postdata['mother_ofc_no'], 'mother_residence_no' => $postdata['mother_residence_no'], 'mother_email' => $postdata['mother_email'], 'emergency_contact_no' => $postdata['emergency_contact_no'], ); $this->db->insert('parent', $tblValues); $i = 1; while (isset($postdata['student_id' . $i])) { $this->db->where('student_id', $postdata['student_id' . $i]); $this->db->delete('parent_student'); $tblValues = array( 'parent_id' => $parentid, 'student_id' => $postdata['student_id' . $i], ); $this->db->insert('parent_student', $tblValues); $i++; } $data['resfunction'] = 'search_parents'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function update_parent($postdata) { $data = array(); $this->db->trans_begin(); $tblValues = array( 'father_name' => $postdata['father_name'], 'father_qatar_id_no' => $postdata['father_qatar_id_no'], 'father_occupation' => $postdata['father_occupation'], 'father_mobile_no' => $postdata['father_mobile_no'], 'father_email' => $postdata['father_email'], 'father_ofc_no' => $postdata['father_ofc_no'], 'father_residence_no' => $postdata['father_residence_no'], 'mother_name' => $postdata['mother_name'], 'mother_qatar_id_no' => $postdata['mother_qatar_id_no'], 'mother_occupation' => $postdata['mother_occupation'], 'mother_mobile_no' => $postdata['mother_mobile_no'], 'mother_ofc_no' => $postdata['mother_ofc_no'], 'mother_residence_no' => $postdata['mother_residence_no'], 'mother_email' => $postdata['mother_email'], 'emergency_contact_no' => $postdata['emergency_contact_no'], ); $this->db->where('parent_id', $postdata['parent_id']); $this->db->update('parent', $tblValues); $data['resfunction'] = 'search_parents'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Updated Successfully'; return $data; } } function search_student_class($pagenum) { $data = array(); $this->db->select('*'); $this->db->from('class_name'); // $this->db->join('class_room', 'class_room.class_room_id=class_name.class_room_id'); $this->db->join('session', 'session_id=class_session'); $this->db->order_by('class_name_id', 'desc'); $data['results'] = $this->db->get(); return $data; } function update_student_fee($postdata) { $data = array(); $this->db->trans_begin(); $student_id = $postdata['student_id']; $student_info = $this->mastermodel->get_data_srow_joined('student', 'nationality', 'nationality_id', 'nationality_id', $student_id, 'student_id'); $student_class_id = $postdata['student_class_id']; $tblValues = array( 'class_allocation_date' => $this->mastermodel->convertdateformat($postdata['class_allocation_date']) ); $this->db->where('student_class_id', $student_class_id); $this->db->update('student_class', $tblValues); $remarks = "Updated $student_info->first_name's Class allocation details"; $tblValues = array( 'student_class_id' => $student_class_id, 'allocation_date' => $this->mastermodel->convertdateformat($postdata['class_allocation_date']), 'remarks' => $remarks ); $this->db->insert('student_class_details', $tblValues); $i = 1; $total_stud = $postdata['index']; while ($i <= $total_stud) { $pay_amount = 0; if ($postdata['payment_type_' . $i] == "term") { $pay_amount = $postdata['pay_amount_' . $i]; } $tblValues = array( 'student_class_id' => $student_class_id, 'fee_amount' => $pay_amount ); $this->db->where('student_class_fee_id', $postdata['fee_details_id_' . $i]); $this->db->update('student_class_fee', $tblValues); $this->db->where('student_class_fee_id', $postdata['fee_details_id_' . $i]); $this->db->delete('student_monthly_fee'); if ($postdata['payment_type_' . $i] == "monthly") { $j = 1; while (isset($postdata['pay_amount_' . $i . '_' . $j])) { $pay_amount = $postdata['pay_amount_' . $i . '_' . $j]; $tblValues = array( 'student_class_fee_id' => $postdata['fee_details_id_' . $i], 'fee_wef_date' => $this->mastermodel->convertdateformat($postdata['wef_date_' . $i . '_' . $j]), 'amount' => $pay_amount ); $j++; $this->db->insert('student_monthly_fee', $tblValues); } } $i++; } if (isset($postdata['add_new_fee_particular'])) { foreach ($postdata['add_new_fee_particular'] as $key => $new_list) { $i = $postdata['add_new_fee_particular'][$key]; if ($postdata['new_pay_amount_' . $i] != "" && $postdata['new_payment_type_' . $i] != "") { $pay_amount = $postdata['new_pay_amount_' . $i]; $tblValues = array( 'student_class_id' => $student_class_id, 'fee_particular_id' => $postdata['new_particular_id_' . $i], 'payment_type' => $postdata['new_payment_type_' . $i], 'fee_amount' => $pay_amount ); $this->db->insert('student_class_fee', $tblValues); $student_class_fee_id = mysql_insert_id(); if ($postdata['new_payment_type_' . $i] == "monthly") { $j = 1; while (isset($postdata['new_pay_amount_' . $i . '_' . $j])) { $pay_amount = $postdata['new_pay_amount_' . $i . '_' . $j]; $tblValues = array( 'student_class_fee_id' => $student_class_fee_id, 'fee_wef_date' => $this->mastermodel->convertdateformat($postdata['new_wef_date_' . $i . '_' . $j]), 'amount' => $pay_amount ); $j++; $this->db->insert('student_monthly_fee', $tblValues); } } } } } $data['resfunction'] = 'search_student_class'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Updated Successfully'; return $data; } } function insert_student_class($postdata) { $data = array(); $this->db->trans_begin(); $class_name_id = $postdata['class_name_id']; $class_info = $this->mastermodel->get_data_srow_joined('class_name', 'class_room', 'class_room_id', 'class_room_id', $class_name_id, 'class_name_id'); $student_id = $postdata['student_id']; $student_info = $this->mastermodel->get_data_srow('student', $student_id, 'student_id'); $student_class = $postdata['student_class_id']; if ($student_class == 0) { $student_class = $this->studentmodel->get_student_class_id($student_id, $class_name_id, $postdata['term_id']); } if ($student_class == 0) { $student_class_id = $this->mastermodel->insertmasterdata(); $tblValues = array( 'student_class_id' => $student_class_id, 'class_name_id' => $class_name_id, 'student_id' => $postdata['student_id'], 'no_of_days' => $postdata['fee_term_no_of_days'], 'term_id' => $postdata['term_id'], 'class_allocation_date' => $this->mastermodel->convertdateformat($postdata['class_allocation_date']) ); $this->db->insert('student_class', $tblValues); $remarks = "Added $student_info->first_name to $class_info->class_name_code"; } else { $student_class_id = $student_class; $tblValues = array( 'class_name_id' => $class_name_id, 'student_id' => $postdata['student_id'], 'no_of_days' => $postdata['fee_term_no_of_days'], 'class_allocation_date' => $this->mastermodel->convertdateformat($postdata['class_allocation_date']) ); $this->db->where('student_class_id', $student_class_id); $this->db->update('student_class', $tblValues); $remarks = "Updated $student_info->first_name's Class allocation details"; } $tblValues = array( 'student_class_id' => $student_class_id, 'allocation_date' => $this->mastermodel->convertdateformat($postdata['class_allocation_date']), 'remarks' => $remarks ); $this->db->insert('student_class_details', $tblValues); if (isset($postdata['add_fee_particular'])) { foreach ($postdata['add_fee_particular'] as $key => $new_list) { $i = $postdata['add_fee_particular'][$key]; if ($postdata['pay_amount_' . $i] != "" && $postdata['payment_type_' . $i] != "") { $pay_amount = $postdata['pay_amount_' . $i]; $tblValues = array( 'student_class_id' => $student_class_id, 'fee_particular_id' => $postdata['particular_id_' . $i], 'payment_type' => $postdata['payment_type_' . $i], 'fee_amount' => $pay_amount ); $this->db->insert('student_class_fee', $tblValues); $student_class_fee_id = mysql_insert_id(); if ($postdata['payment_type_' . $i] == "monthly") { $j = 1; while (isset($postdata['pay_amount_' . $i . '_' . $j])) { $pay_amount = $postdata['pay_amount_' . $i . '_' . $j]; $tblValues = array( 'student_class_fee_id' => $student_class_fee_id, 'fee_wef_date' => $this->mastermodel->convertdateformat($postdata['wef_date_' . $i . '_' . $j]), 'amount' => $pay_amount ); // var_dump($tblValues); // echo "<br/>"; $j++; $this->db->insert('student_monthly_fee', $tblValues); } } } } } // $i = 1; // $total_stud = $postdata['index']; // while ($i <= $total_stud) { // $pay_amount = $postdata['pay_amount_' . $i]; // $tblValues = array( // 'student_class_id' => $student_class_id, // 'fee_particular_id' => $postdata['particular_id_' . $i], // 'payment_type' => $postdata['payment_type_' . $i], // 'fee_amount' => $pay_amount // ); // $this->db->insert('student_class_fee', $tblValues); // // $student_class_fee_id = mysql_insert_id(); // if ($postdata['payment_type_' . $i] == "monthly") { // $tblValues = array( // 'student_class_fee_id' => $student_class_fee_id, // 'fee_wef_date' => $this->mastermodel->convertdateformat($postdata['wef_date_' . $i]), // 'amount' => $pay_amount // ); // $this->db->insert('student_monthly_fee', $tblValues); // } // $i++; // } // die(); $data['resfunction'] = 'search_student_class'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function update_student_class($postdata) { $data = array(); $this->db->trans_begin(); $class_name_id = $postdata['class_name_id']; $i = 1; $total_stud = $postdata['index']; while ($i <= $total_stud) { if (isset($postdata['select_student' . $i]) && $postdata['select_student' . $i] == "on") { $student_id = $postdata['student_id' . $i]; $student_class_id = $postdata['student_class_id' . $i]; $student_info = $this->mastermodel->get_data_srow('student', $student_id, 'student_id'); if (isset($postdata['class_allocation_date']) && $postdata['class_allocation_date'] != "") { $date = $this->mastermodel->convertdateformat($postdata['class_allocation_date']); } else { $date = $this->mastermodel->get_single_field_value('student_class', 'class_allocation_date', 'student_class_id', $student_class_id); } $tblValues = array( 'class_allocation_date' => $this->mastermodel->convertdateformat($date), 'fee_type_id' => $postdata['fee_type' . $i], 'registration_fee' => $postdata['register_fee' . $i] ); $this->db->where('student_class_id', $student_class_id); $this->db->update('student_class', $tblValues); $remarks = "Updated $student_info->first_name's Class allocation details"; $remarks = "Updated $student_info->first_name's class allocation details"; $tblValues = array( 'student_class_id' => $student_class_id, 'allocation_date' => $date, 'remarks' => $remarks ); $this->db->insert('student_class_details', $tblValues); } $i++; } $data['resfunction'] = 'search_student_class'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function search_attendance($pagenum) { $data = array(); $this->db->select('*'); $this->db->from('attendance'); $this->db->join('master', 'master_id=attendance_id'); $this->db->join('employee', 'employee.employee_id=attendance.teacher_id', 'left'); $this->db->join('class_name', 'class_name.class_name_id=attendance.class_id', 'left'); $this->db->order_by('attendance_id', 'desc'); $data['results'] = $this->db->get(); return $data; } function insert_attendance($postdata) { $data = array(); $this->db->trans_begin(); $attendanceid = $this->mastermodel->insertmasterdata(); $start_time = $postdata['start_time_hour'] . ":" . $postdata['start_time_minute']; $end_time = $postdata['end_time_hour'] . ":" . $postdata['end_time_minute']; $tblValues = array( 'attendance_id' => $attendanceid, // 'class_room_id' => $postdata['class_room_id'], 'class_id' => $postdata['class_name_id'], 'attendance_date' => $this->mastermodel->convertdateformat($postdata['attendance_date']), 'start_time' => $start_time, 'end_time' => $end_time, 'remarks' => $postdata['remarks'], 'teacher_id' => $postdata['teacher_id'], ); $this->db->insert('attendance', $tblValues); $j = 1; while (isset($postdata['student_id_' . $j])) { $attendan = 0; if (isset($postdata['attendance' . $j]) && $postdata['attendance' . $j] == 'on') $attendan = 1; if (isset($postdata['attendance' . $j]) && $postdata['attendance' . $j] == 'deactivate') $attendan = 2; if (isset($postdata['attendance' . $j]) && $postdata['attendance' . $j] == 'unallocated') $attendan = 3; $std_id = $postdata['student_id_' . $j]; $tblValues = array( 'attendance_id' => $attendanceid, 'student_id' => $std_id, 'attendance' => $attendan, 'start_time' => $postdata['start_time_hour' . $j] . ":" . $postdata['start_time_minute' . $j] . ":00", 'end_time' => $postdata['end_time_hour' . $j] . ":" . $postdata['end_time_minute' . $j] . ":00", 'remarks' => $postdata['remarks' . $j], ); $this->db->insert('attendance_details', $tblValues); $j++; } $data['resfunction'] = 'search_attendance'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function update_attendance($postdata) { $data = array(); $this->db->trans_begin(); $start_time = $postdata['start_time_hour'] . ":" . $postdata['start_time_minute']; $end_time = $postdata['end_time_hour'] . ":" . $postdata['end_time_minute']; $tblValues = array( 'start_time' => $start_time, 'end_time' => $end_time, 'attendance_date' => $this->mastermodel->convertdateformat($postdata['attendance_date']), 'remarks' => $postdata['remarks'], 'teacher_id' => $postdata['teacher_id'], ); $this->db->where('attendance_id', $postdata['attendance_id']); $this->db->update('attendance', $tblValues); $this->db->where('attendance_id', $postdata['attendance_id']); $this->db->delete('attendance_details'); $j = 1; while (isset($postdata['student_id_' . $j])) { // echo $postdata['attendance' . $j]; $attendan = 0; if (isset($postdata['attendance' . $j]) && $postdata['attendance' . $j] == 'on') $attendan = 1; if (isset($postdata['attendance' . $j]) && $postdata['attendance' . $j] == 'deactivate') $attendan = 2; if (isset($postdata['attendance' . $j]) && $postdata['attendance' . $j] == 'unallocated') $attendan = 3; $std_id = $postdata['student_id_' . $j]; $tblValues = array( 'attendance_id' => $postdata['attendance_id'], 'student_id' => $std_id, 'attendance' => $attendan, 'start_time' => $postdata['start_time_hour' . $j] . ":" . $postdata['start_time_minute' . $j] . ":00", 'end_time' => $postdata['end_time_hour' . $j] . ":" . $postdata['end_time_minute' . $j] . ":00", 'remarks' => $postdata['remarks' . $j], ); $this->db->insert('attendance_details', $tblValues); $j++; } $data['resfunction'] = 'search_attendance'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Updated Successfully'; return $data; } } function search_cancellation($pagenum) { $data = array(); $this->db->select('*'); $this->db->from('student_cancellation'); $this->db->join('master', 'master_id=cancellation_id'); $this->db->join('student', 'student.student_id=student_cancellation.student_id'); $this->db->join('student_class', 'student_class.student_class_id=student_cancellation.student_class_id'); $this->db->join('class_name', 'class_name.class_name_id=student_class.class_name_id'); $this->db->where('journal_id', 0); $this->db->order_by('cancellation_id', 'desc'); $data['results'] = $this->db->get(); return $data; } function search_cancellation_posted($pagenum) { $data = array(); $this->db->select('*'); $this->db->from('student_cancellation'); $this->db->join('master', 'master_id=cancellation_id'); $this->db->join('student', 'student.student_id=student_cancellation.student_id'); $this->db->join('student_class', 'student_class.student_class_id=student_cancellation.student_class_id'); $this->db->join('class_name', 'class_name.class_name_id=student_class.class_name_id'); $this->db->where('journal_id >', 0); $this->db->order_by('cancellation_id', 'desc'); $data['results'] = $this->db->get(); return $data; } function search_deactivate($pagenum) { $data = array(); $this->db->select('*,student_deactivate.start_date as start_date,student_deactivate.end_date as end_date'); $this->db->from('student_deactivate'); $this->db->join('master', 'master_id=deactivate_id'); $this->db->join('student_class', 'student_class.student_class_id=student_deactivate.student_class_id'); $this->db->join('student', 'student.student_id=student_class.student_id'); $this->db->join('class_name', 'class_name.class_name_id=student_class.class_name_id'); $this->db->order_by('deactivate_id', 'desc'); $data['results'] = $this->db->get(); return $data; } function insert_deactivate($postdata) { $data = array(); $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $tblValues = array( 'deactivate_id' => $masterid, 'student_class_id' => $postdata['student_class_id'], 'student_id' => $postdata['student_id'], 'start_date' => $this->mastermodel->convertdateformat($postdata['start_date']), 'remarks' => $postdata['remarks'], ); $this->db->insert('student_deactivate', $tblValues); $data['resfunction'] = 'search_deactivate'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function update_deactivate($postdata) { $data = array(); $this->db->trans_begin(); $tblValues = array( 'start_date' => $this->mastermodel->convertdateformat($postdata['start_date']), 'remarks' => $postdata['remarks'], ); $this->db->where('deactivate_id', $postdata['deactivate_id']); $this->db->update('student_deactivate', $tblValues); $data['resfunction'] = 'search_deactivate'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Updated Successfully'; return $data; } } function activate_student($postdata) { $data = array(); $this->db->trans_begin(); $activate_date = ''; $activate = 0; if (isset($postdata['activate'])) { $activate_date = $this->mastermodel->convertdateformat($postdata['activate_date']); $activate = 1; } $tblValues = array( 'activate_date' => $activate_date, 'activate' => $activate, ); $this->db->where('deactivate_id', $postdata['deactivate_id']); $this->db->update('student_deactivate', $tblValues); $data['resfunction'] = 'search_deactivate'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Updated Successfully'; return $data; } } function insert_cancellation($postdata) { $data = array(); $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $tblValues = array( 'cancellation_id' => $masterid, 'student_class_id' => $postdata['student_class_id'], 'student_id' => $postdata['student_id'], 'refund_amount' => $postdata['refund_amount'], 'cancellation_date' => $this->mastermodel->convertdateformat($postdata['cancellation_date']), 'remarks' => $postdata['remarks'], ); $this->db->insert('student_cancellation', $tblValues); $student_info = $this->mastermodel->get_data_srow('student', $postdata['student_id'], 'student_id'); $class_info = $this->mastermodel->get_data_srow('class_name', $postdata['class_name_id'], 'class_name_id'); $tblValues = array( 'cancelled' => 1, ); $this->db->where('student_class_id', $postdata['student_class_id']); $this->db->update('student_class', $tblValues); $tblValues = array( 'student_class_id' => $postdata['student_class_id'], 'allocation_date' => $this->mastermodel->convertdateformat($postdata['cancellation_date']), 'remarks' => "$student_info->first_name ($student_info->reg_no) is cancelled from class_name - $class_info->class_name_code " ); $this->db->insert('student_class_details', $tblValues); $data['resfunction'] = 'search_cancellation'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function update_cancellation($postdata) { $data = array(); $this->db->trans_begin(); $tblValues = array( 'refund_amount' => $postdata['refund_amount'], 'cancellation_date' => $this->mastermodel->convertdateformat($postdata['cancellation_date']), 'remarks' => $postdata['remarks'], ); $this->db->where('cancellation_id', $postdata['cancellation_id']); $this->db->update('student_cancellation', $tblValues); $data['resfunction'] = 'search_cancellation'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Updated Successfully'; return $data; } } function search_fee_posted($pagenum) { $data = array(); $this->db->select('*'); $this->db->from('fee'); $this->db->join('student_class', 'student_class.student_class_id=fee.student_class_id'); $this->db->join('class_name', 'class_name.class_name_id=student_class.class_name_id'); $this->db->join('student', 'student.student_id=student_class.student_id'); $this->db->join('nationality', 'nationality.nationality_id=student.nationality_id'); $this->db->where('posted', 1); $this->db->order_by('fee_id', 'desc'); $data['results'] = $this->db->get(); // echo $this->db->last_query(); return $data; } function get_reciept_no($date) { $date_array = explode('-', $date); $data = "SELECT MAX(fee_id) as fee_id FROM fee where fee_date like '$date_array[2]%' "; $res = $this->db->query($data); $data = "SELECT MAX(fee_receipt_no) as code FROM fee where fee_id = '" . $res->row()->fee_id . "'"; $res = $this->db->query($data); $sql = "SELECT MAX(fee_payment_id) as fee_payment_id from fee_payment where fee_payment_date like '$date_array[2]%'"; $result = $this->db->query($sql); $sql = "SELECT MAX(fee_receipt_no) as code1 from fee_payment where fee_payment_id = '" . $result->row()->fee_payment_id . "'"; $result = $this->db->query($sql); if (!empty($res->row()->code)) { $code_array = explode('/', $res->row()->code); $code = $code_array[3]; } else $code = 0; if (!empty($result->row()->code1)) { $code_array = explode('/', $result->row()->code1); $code1 = $code_array[3]; } else $code1 = 0; $rec_code = $code; if ($code1 > $rec_code) $rec_code = $code1; $num = $rec_code + 1; return 'RV/' . date("m", strtotime($date)) . '/' . date("Y", strtotime($date)) . '/' . str_pad($num, 4, '0', STR_PAD_LEFT); } function search_fee_payment($pagenum) { $data = array(); $this->db->select('*'); $this->db->from('fee_payment'); $this->db->join('student', 'student.student_id=fee_payment.fee_student_id'); $this->db->join('nationality', 'nationality.nationality_id=student.nationality_id'); $this->db->order_by('fee_payment_id', 'desc'); $data['results'] = $this->db->get(); return $data; } function allocate_fee_payment($postdata) { $data = array(); $fisc_year_id = $this->accountingmodel->getfiscalyearid(); $default_currency = $this->accountingmodel->getcurrency(); $data['resfunction'] = 'search_fee_payment'; $employee_fee_payable = $this->mastermodel->get_single_field_value('finance_sub_account_settings', 'employee_fee_payable', 'sub_account_settings_id', '1'); if ($fisc_year_id != 0 && $default_currency != 0 && $employee_fee_payable != 0) { $this->db->trans_begin(); $fee = $this->mastermodel->get_data_srow('fee_payment', $postdata['fee_payment_id'], 'fee_payment_id'); $masterid = $this->mastermodel->insertmasterdata(); $tblValues = array( 'fee_id' => $masterid, 'fee_receipt_no' => $fee->fee_receipt_no, 'fee_date' => $fee->fee_payment_date, 'payment_mode' => $fee->payment_mode, 'remarks' => $fee->fee_payment_remarks, 'student_class_id' => $postdata['class_name_id'], 'posted' => '1', ); $this->db->insert('fee', $tblValues); $toatal_amount = 0; $i = 1; while ($i < $postdata['index']) { if (isset($postdata['amount_' . $i]) && $postdata['amount_' . $i] != "" && $postdata['amount_' . $i] > 0) { $tblValues = array( 'fee_id' => $masterid, 'student_class_fee_id' => $postdata['student_class_fee_id_' . $i], 'payment_for' => $postdata['payment_for_' . $i], 'amount_paid' => $postdata['amount_' . $i], ); $this->db->insert('fee_paid_details', $tblValues); $toatal_amount+=$postdata['amount_' . $i]; } $i++; } $tblValues = array( 'total_amount' => $toatal_amount ); $this->db->where('fee_id', $masterid); $this->db->update('fee', $tblValues); if ($fee->payment_mode == 2) { $cheque = $this->mastermodel->get_data_srow('fee_payment_cheque_info', $fee->fee_payment_id, 'fee_payment_id'); $tblValues = array( 'fee_id' => $masterid, 'cheque_date' => $cheque->cheque_date, 'cheque_no ' => $cheque->cheque_no, 'cheque_info' => $cheque->cheque_info ); $this->db->insert('fee_cheque_info', $tblValues); } else if ($fee->payment_mode == 3) { $card = $this->mastermodel->get_data_srow('fee_payment_credit_card_info', $fee->fee_payment_id, 'fee_payment_id'); $tblValues = array( 'fee_id' => $masterid, 'credit_card_holder' => $card->credit_card_holder, 'credit_card_no' => $card->credit_card_no, ); $this->db->insert('fee_credit_card_info', $tblValues); } else if ($fee->payment_mode == 4) { $bank = $this->mastermodel->get_data_srow('fee_payment_bank_transfer_info', $fee->fee_payment_id, 'fee_payment_id'); $tblValues = array( 'fee_id' => $masterid, 'description' => $bank->description ); $this->db->insert('fee_payment_bank_transfer_info', $tblValues); } if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Fees allocated Successfully'; return $data; } } else { $data['res'] = 0; if ($fisc_year_id == 0) $data['msg'] = 'Fiscal Year Not Set.'; else if ($default_currency == 0) $data['msg'] = 'Default Currency Not Set.'; else $data['msg'] = 'Fiscal Year and Default Currency Not Set.'; return $data; } } function insert_fee_payment($postdata) { $data = array(); $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $reciept_no = $this->get_reciept_no($postdata['fee_date']); $tblValues = array( 'fee_payment_id' => $masterid, 'fee_student_id' => $postdata['student_id'], 'fee_receipt_no' => $reciept_no, 'fee_payment_date' => $this->mastermodel->convertdateformat($postdata['fee_date']), 'fee_payment_remarks' => $postdata['fee_remarks'], 'payment_mode' => $postdata['payment_mode'], ); $this->db->insert('fee_payment', $tblValues); if ($postdata['payment_mode'] == 2) { $tblValues = array( 'fee_payment_id' => $masterid, 'cheque_date' => $this->mastermodel->convertdateformat($postdata['cheque_date']), 'cheque_no' => $postdata['cheque_no'], 'cheque_info' => $postdata['cheque_info'], 'bank_drawn' => $postdata['bank_drawn'] ); $this->db->insert('fee_payment_cheque_info', $tblValues); } else if ($postdata['payment_mode'] == 3) { $tblValues = array( 'fee_payment_id' => $masterid, 'credit_card_holder' => $postdata['holder_name'], 'credit_card_no' => $postdata['card_no'] ); $this->db->insert('fee_payment_credit_card_info', $tblValues); } else if ($postdata['payment_mode'] == 4) { $tblValues = array( 'fee_payment_id' => $masterid, 'description' => $postdata['bank_transfer_description'] ); $this->db->insert('fee_payment_bank_transfer_info', $tblValues); } $i = 1; while (isset($postdata['fee_particular_id' . $i]) && isset($postdata['fee_term_amount' . $i])) { $tbl1Values = array( 'fee_payment_id' => $masterid, 'fee_particular_id' => $postdata['fee_particular_id' . $i], 'fee_term_amount' => $postdata['fee_term_amount' . $i] ); $this->db->insert('fee_payment_details', $tbl1Values); $i++; } $data['resfunction'] = 'search_fee_payment'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function update_fee_payment($postdata) { $data = array(); $this->db->trans_begin(); $this->mastermodel->updatemasterdata($postdata['fee_payment_id']); $tblValues = array( 'fee_payment_date' => $this->mastermodel->convertdateformat($postdata['fee_date']), 'fee_payment_remarks' => $postdata['fee_remarks'], 'payment_mode' => $postdata['payment_mode'], ); $this->db->where('fee_payment_id', $postdata['fee_payment_id']); $this->db->update('fee_payment', $tblValues); $this->db->where('fee_payment_id', $postdata['fee_payment_id']); $this->db->delete('fee_payment_cheque_info'); $this->db->where('fee_payment_id', $postdata['fee_payment_id']); $this->db->delete('fee_payment_bank_transfer_info'); $this->db->where('fee_payment_id', $postdata['fee_payment_id']); $this->db->delete('fee_payment_credit_card_info'); if ($postdata['payment_mode'] == 2) { $tblValues = array( 'fee_payment_id' => $postdata['fee_payment_id'], 'cheque_date' => $this->mastermodel->convertdateformat($postdata['cheque_date']), 'cheque_no' => $postdata['cheque_no'], 'cheque_info' => $postdata['cheque_info'], 'bank_drawn' => $postdata['bank_drawn'] ); $this->db->insert('fee_payment_cheque_info', $tblValues); } else if ($postdata['payment_mode'] == 3) { $tblValues = array( 'fee_payment_id' => $postdata['fee_payment_id'], 'credit_card_holder' => $postdata['holder_name'], 'credit_card_no' => $postdata['card_no'] ); $this->db->insert('fee_payment_credit_card_info', $tblValues); } $this->db->where('fee_payment_id', $postdata['fee_payment_id']); $this->db->delete('fee_payment_details'); $i = 1; while (isset($postdata['fee_particular_id' . $i]) && isset($postdata['fee_term_amount' . $i])) { $tbl1Values = array( 'fee_payment_id' => $postdata['fee_payment_id'], 'fee_particular_id' => $postdata['fee_particular_id' . $i], 'fee_term_amount' => $postdata['fee_term_amount' . $i] ); $this->db->insert('fee_payment_details', $tbl1Values); $i++; } $data['resfunction'] = 'search_fee_payment'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function insert_fee($postdata) { $data = array(); $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $reciept_no = $this->get_reciept_no($postdata['fee_date']); $tblValues = array( 'fee_id' => $masterid, 'fee_receipt_no' => $reciept_no, 'fee_date' => $this->mastermodel->convertdateformat($postdata['fee_date']), 'payment_mode' => $postdata['payment_mode'], 'remarks' => $postdata['remarks'], 'student_class_id' => $postdata['student_class_id'], 'posted' => '1', ); $this->db->insert('fee', $tblValues); $toatal_amount = 0; $i = 1; while ($i < $postdata['index']) { if (isset($postdata['amount_' . $i]) && $postdata['amount_' . $i] != "" && $postdata['amount_' . $i] > 0) { $tblValues = array( 'fee_id' => $masterid, 'student_class_fee_id' => $postdata['student_class_fee_id_' . $i], 'payment_for' => $postdata['payment_for_' . $i], 'amount_paid' => $postdata['amount_' . $i], ); $this->db->insert('fee_paid_details', $tblValues); $toatal_amount+=$postdata['amount_' . $i]; } $i++; } $i = 1; while (isset($postdata['fee_other_name' . $i]) != '') { $tblValues = array( 'fee_id' => $masterid, 'fee_other_name' => $postdata['fee_other_name' . $i], 'fee_other_amount' => $postdata['fee_other_amount' . $i] ); $this->db->insert('fee_paid_details_other', $tblValues); $toatal_amount+=$postdata['fee_other_amount' . $i]; $i++; } $tblValues = array( 'total_amount' => $toatal_amount ); $this->db->where('fee_id', $masterid); $this->db->update('fee', $tblValues); if ($postdata['payment_mode'] == 2) { $tblValues = array( 'fee_id' => $masterid, 'cheque_date' => $this->mastermodel->convertdateformat($postdata['cheque_date']), 'cheque_no' => $postdata['cheque_no'], 'cheque_info' => $postdata['cheque_info'], 'bank_drawn' => $postdata['bank_drawn'] ); $this->db->insert('fee_cheque_info', $tblValues); } else if ($postdata['payment_mode'] == 3) { $tblValues = array( 'fee_id' => $masterid, 'credit_card_holder' => $postdata['holder_name'], 'credit_card_no' => $postdata['card_no'] ); $this->db->insert('fee_credit_card_info', $tblValues); } else if ($postdata['payment_mode'] == 4) { $tblValues = array( 'fee_id' => $masterid, 'description' => $postdata['bank_transfer_description'] ); $this->db->insert('fee_bank_transfer_info', $tblValues); } $data['resfunction'] = 'search_fee_posted'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function update_fee($postdata) { $data = array(); $this->db->trans_begin(); $tblValues = array( 'fee_date' => $this->mastermodel->convertdateformat($postdata['fee_date']), 'payment_mode' => $postdata['payment_mode'], 'remarks' => $postdata['remarks'] ); $this->db->where('fee_id', $postdata['fee_id']); $this->db->update('fee', $tblValues); $this->db->where('fee_id', $postdata['fee_id']); $this->db->delete('fee_cheque_info'); $this->db->where('fee_id', $postdata['fee_id']); $this->db->delete('fee_bank_transfer_info'); $this->db->where('fee_id', $postdata['fee_id']); $this->db->delete('fee_credit_card_info'); $this->db->where('fee_id', $postdata['fee_id']); $this->db->delete('fee_paid_details'); $this->db->where('fee_id', $postdata['fee_id']); $this->db->delete('fee_paid_details_other'); $toatal_amount = 0; $i = 1; while ($i < $postdata['index']) { if (isset($postdata['amount_' . $i]) && $postdata['amount_' . $i] != "" && $postdata['amount_' . $i] > 0) { $tblValues = array( 'fee_id' => $postdata['fee_id'], 'student_class_fee_id' => $postdata['student_class_fee_id_' . $i], 'payment_for' => $postdata['payment_for_' . $i], 'amount_paid' => $postdata['amount_' . $i], ); $this->db->insert('fee_paid_details', $tblValues); $toatal_amount+=$postdata['amount_' . $i]; } $i++; } $i = 1; while (isset($postdata['fee_other_name' . $i]) != '') { if ($postdata['fee_other_name' . $i] != '') { $tblValues = array( 'fee_id' => $postdata['fee_id'], 'fee_other_name' => $postdata['fee_other_name' . $i], 'fee_other_amount' => $postdata['fee_other_amount' . $i] ); $this->db->insert('fee_paid_details_other', $tblValues); $toatal_amount+=$postdata['fee_other_amount' . $i]; } $i++; } $tblValues = array( 'total_amount' => $toatal_amount ); $this->db->where('fee_id', $postdata['fee_id']); $this->db->update('fee', $tblValues); if ($postdata['payment_mode'] == 2) { $tblValues = array( 'fee_id' => $postdata['fee_id'], 'cheque_date' => $this->mastermodel->convertdateformat($postdata['cheque_date']), 'cheque_no' => $postdata['cheque_no'], 'cheque_info' => $postdata['cheque_info'], 'bank_drawn' => $postdata['bank_drawn'] ); $this->db->insert('fee_cheque_info', $tblValues); } else if ($postdata['payment_mode'] == 3) { $tblValues = array( 'fee_id' => $postdata['fee_id'], 'credit_card_holder' => $postdata['holder_name'], 'credit_card_no' => $postdata['card_no'] ); $this->db->insert('fee_credit_card_info', $tblValues); } else if ($postdata['payment_mode'] == 4) { $tblValues = array( 'fee_id' => $postdata['fee_id'], 'description' => $postdata['bank_transfer_description'] ); $this->db->insert('fee_bank_transfer_info', $tblValues); } $data['resfunction'] = 'search_fee_posted'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function set_receipt_voucher_fee_settings($postdata) { $data = array(); $student = $this->mastermodel->get_data_srow('student', $postdata['student_id'], 'student_id'); $fisc_year_id = $this->accountingmodel->getfiscalyearid(); $default_currency = $this->accountingmodel->getcurrency(); $data['resfunction'] = 'search_fee_posted'; if ($fisc_year_id != 0 && $default_currency != 0) { $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $account = explode("~", $postdata['bankacc_id']); $account_to_id = $account[0]; $account_to_code = $account[1]; $account_to_name = $account[2]; $description = "Fees Payment by " . $student->first_name . ' ' . $student->last_name . " for " . $postdata['class_name_code'] . ". Payment to " . $account_to_code . "-" . $account_to_name; $transaction_id = $postdata['transaction_id']; $payment_type = $postdata['payment_type_id']; $reference = $this->accountingmodel->get_transaction_code($transaction_id, $payment_type); $tblValues = array( 'journal_id' => $masterid, 'journal_date' => $this->mastermodel->convertdateformat($postdata['journal_date']), 'description' => $description, 'reference' => $reference, 'currency_id' => $default_currency, 'payment_type_id' => $postdata['payment_type_id'], 'transaction_id' => $postdata['transaction_id'], 'posted' => '1' ); $this->db->insert('finance_journal_refs', $tblValues); if ($postdata['payment_type_id'] == 2) { $tblValues = array( 'journal_id' => $masterid, 'cheque_date' => $this->mastermodel->convertdateformat($postdata['cheque_date']), 'cheque_no ' => $postdata['cheque_no'], 'chart_account_code' => $account_to_code, 'cheque_info' => $postdata['cheque_info'] ); $this->db->insert('finance_cheque_info', $tblValues); } else if ($postdata['payment_type_id'] == 3) { $tblValues = array( 'journal_id' => $masterid, 'credit_card_holder' => $postdata['holder_name'], 'credit_card_no' => $postdata['card_no'] ); $this->db->insert('finance_credit_card_info', $tblValues); } else if ($postdata['payment_type_id'] == 4) { $tblValues = array( 'journal_id' => $masterid, 'wire_info' => $postdata['bank_transfer_description'] ); $this->db->insert('finance_wire_info', $tblValues); } $total_amount = 0; if ($postdata['payment_to_id'] != "") { $chart_account = explode("~", $postdata['payment_to_id']); $chart_account_id = $chart_account[0]; $chart_account_code = $chart_account[1]; $chart_account_name = $chart_account[2]; $total_amount = $postdata['amount']; if (empty($postdata['description'])) $description = "Fees Payment by " . $student->first_name . ' ' . $student->last_name . " for " . $postdata['class_name_code'] . ". Payment made to " . $account_to_name . "-" . $account_to_code; else $description = $postdata['description']; $tblValues = array( 'journal_id' => $masterid, 'chart_account_code' => $chart_account_code, 'debit' => 0, 'credit' => $total_amount, 'description' => $description, 'fiscal_year_id' => $fisc_year_id, ); $this->db->insert('finance_journal', $tblValues); } $description = "Fees Payment by " . $student->first_name . ' ' . $student->last_name . " for " . $postdata['class_name_code'] . ". Payment Received From " . $chart_account_name . "-" . $chart_account_code; $tblValues = array( 'journal_id' => $masterid, 'chart_account_code' => $account_to_code, 'debit' => $total_amount, 'credit' => 0, 'description' => $description, 'fiscal_year_id' => $fisc_year_id ); $this->db->insert('finance_journal', $tblValues); $tblValues = array( 'journal_id' => $masterid, 'param_id' => $postdata['fee_id'], 'refs_type' => 'Student Fee Payment', 'param_table' => 'fee' ); $this->db->insert('finance_refs', $tblValues); $tblValues = array( 'journal_id' => $masterid ); $this->db->where('fee_id', $postdata['fee_id']); $this->db->update('fee', $tblValues); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } else { $data['res'] = 0; if ($fisc_year_id == 0) $data['msg'] = 'Fiscal Year Not Set.'; else if ($default_currency == 0) $data['msg'] = 'Default Currency Not Set.'; else $data['msg'] = 'Fiscal Year and Default Currency Not Set.'; return $data; } } function post_fee_settings($id) { $data = array(); $this->db->trans_begin(); $tblValues = array( 'posted' => 1 ); $this->db->where('fee_id', $id); $this->db->update('fee', $tblValues); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Failed to post Fee Payment'; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Fee Setting Posted Successfully'; } return $data; } function reverse_fee_settings($id) { $data = array(); $this->db->trans_begin(); $tblValues = array( 'posted' => 0 ); $this->db->where('fee_id', $id); $this->db->update('fee', $tblValues); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Failed to reverse Fee Payment'; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Fee Setting Reversed Successfully'; } return $data; } function post_student_cancellation($postdata) { $data = array(); $data['resfunction'] = 'search_cancellation'; $fisc_year_id = $this->accountingmodel->getfiscalyearid(); $default_currency = $this->accountingmodel->getcurrency(); if ($fisc_year_id != 0 && $default_currency != 0) { $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $account = explode("~", $postdata['bankacc_id']); $account_to_id = $account[0]; $account_to_code = $account[1]; $account_to_name = $account[2]; $description = "Student cancellation - Refund Fee to " . $postdata['student'] . " . Payment Received From " . $account_to_name . "-" . $account_to_code; $transaction_id = $postdata['transaction_id']; $payment_type = $postdata['payment_type_id']; $reference = $this->accountingmodel->get_transaction_code($transaction_id, $payment_type); $tblValues = array( 'journal_id' => $masterid, 'journal_date' => $this->mastermodel->convertdateformat($postdata['journal_date']), 'description' => $description, 'reference' => $reference, 'currency_id' => $default_currency, 'payment_type_id' => $postdata['payment_type_id'], 'transaction_id' => $postdata['transaction_id'], 'posted' => 1 ); $this->db->insert('finance_journal_refs', $tblValues); if ($postdata['payment_type_id'] == 2) { $tblValues = array( 'journal_id' => $masterid, 'cheque_date' => $this->mastermodel->convertdateformat($postdata['cheque_date']), 'cheque_no ' => $postdata['cheque_no'], 'chart_account_code' => $account_to_code, 'cheque_info' => $postdata['cheque_info'] ); $this->db->insert('finance_cheque_info', $tblValues); } else if ($postdata['payment_type_id'] == 3) { $tblValues = array( 'journal_id' => $masterid, 'wire_info' => $postdata['wire_info'], ); $this->db->insert('finance_wire_info', $tblValues); } $total_amount = 0; if ($postdata['payment_to_id'] != "") { $chart_account = $this->mastermodel->get_data_srow('finance_chart_master', $postdata['payment_to_id'], 'chart_master_id'); $chart_account_id = $postdata['payment_to_id']; $chart_account_code = $chart_account->chart_account_code; $chart_account_name = $chart_account->chart_account_name; $total_amount = $postdata['amount']; if (empty($postdata['description'])) $description = "Student cancellation - Refund Fee to " . $postdata['student'] . " . Payment Received From " . $account_to_name . "-" . $account_to_code; else $description = $postdata['description']; $tblValues = array( 'journal_id' => $masterid, 'chart_account_code' => $chart_account_code, 'debit' => $postdata['amount'], 'credit' => 0, 'description' => $description, 'fiscal_year_id' => $fisc_year_id, ); $this->db->insert('finance_journal', $tblValues); } $tblValues = array( 'journal_id' => $masterid, 'chart_account_code' => $account_to_code, 'debit' => 0, 'credit' => $total_amount, 'description' => "Student cancellation - Refund Fee . Payment Made to $chart_account_name - $chart_account_code", 'fiscal_year_id' => $fisc_year_id ); $this->db->insert('finance_journal', $tblValues); $tblValues = array( 'journal_id' => $masterid ); $this->db->where('cancellation_id', $postdata['cancellation_id']); $this->db->update('student_cancellation', $tblValues); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } else { $data['res'] = 0; if ($fisc_year_id == 0) $data['msg'] = 'Fiscal Year Not Set.'; else if ($default_currency == 0) $data['msg'] = 'Default Currency Not Set.'; else $data['msg'] = 'Fiscal Year and Default Currency Not Set.'; return $data; } } function get_parents_details($father = '', $mother = '', $qatar = '') { $data = array(); $this->db->select('*'); $this->db->from('parent'); if ($father != '0') $this->db->where('father_name', $father); if ($mother != '0') $this->db->where('mother_name', $mother); if ($qatar != '0') $this->db->where('father_qatar_id_no', $qatar); $Q = $this->db->get(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function get_classes($id) { $data = array(); $this->db->select('class_name_code'); $this->db->from('class_name'); $this->db->join('student_class', 'student_class.class_name_id=class_name.class_name_id'); $this->db->where('student_id', $id); $this->db->order_by('student_class.class_allocation_date', 'desc'); $this->db->limit('1'); $Q = $this->db->get(); $result = $Q->row(); if ($result) { return $result->class_name_code; } else { return ""; } } /* * error * */ function getStudentsNotCancelledFromClass($class_name_id) { $data = array(); $query = (" SELECT *,student.student_id as student_id ,if(student_cancellation.class_name_id = $class_name_id , 0,1) as class FROM `student` LEFT JOIN student_cancellation ON student_cancellation.student_id= student.student_id having class = 1"); $Q = $this->db->query($query); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function get_cancelled_student($class_name_id) { $data = array(); $date = date("Y-m-d"); $this->db->select('*'); $this->db->from('student_cancellation'); $this->db->join('student_class', 'student_class.student_class_id=student_cancellation.student_class_id'); $this->db->where('class_name_id', $class_name_id); $this->db->where('cancellation_date <=', $date); $Q = $this->db->get(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row['student_id']; } } $Q->free_result(); return $data; } function get_class_student_details($class_name_id, $class_room_id) { $data = array(); $this->db->select('*,student_class.student_class_id as student_class_id ,student_class.student_id as student_id,student_class.class_name_id as class_name_id'); $this->db->from('student_class'); $this->db->join('student', 'student.student_id=student_class.student_class_id'); // $this->db->join('student_cancellation', 'student_cancellation.student_class_id=student_class.student_class_id', 'left'); // $this->db->where('class_room_id', $class_room_id); $this->db->where('class_name_id ', $class_name_id); // $this->db->where('date' <=date("Y-m-d")); // $this->db->having('cancellation_id is null'); // $this->db->order_by('date'); $Q = $this->db->get(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } /* To Get Student Class Alocation Id */ function get_student_class_id($class_name_id, $student) { $data = 0; $this->db->select('*'); $this->db->from('student_class'); $this->db->where('class_name_id', $class_name_id); $this->db->where('student_id', $student); $this->db->where('cancelled', 0); $Q = $this->db->get(); $result = $Q->row(); if ($result) { $data = $result->student_class_id; } else { $data = 0; } $Q->free_result(); return $data; } function load_student_fee_details($academic_year, $session, $no_sessions = '', $term = '') { if ($no_sessions == '') $no_sessions == 0; $data = array(); $this->db->select('*'); $this->db->from('fee_term'); $this->db->join('fee_term_details', 'fee_term_details.fee_term_id=fee_term.fee_term_id'); $this->db->join('fee_particular', 'fee_particular.fee_particular_id=fee_term_details.fee_particular_id'); $this->db->join('term', 'term.term_id=fee_term.fee_term_term_id'); $this->db->where('fee_term_academic_year_id', $academic_year); $this->db->where('fee_term_session', $session); $this->db->where('fee_term_term_id', $term); $this->db->where("( fee_term_no_of_days= '$no_sessions' OR fee_term_no_of_days='')"); $this->db->order_by('fee_term.fee_term_id'); $Q = $this->db->get(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } //echo $this->db->last_query(); $Q->free_result(); return $data; } function search_roll_over($pagenum) { $data = array(); $this->db->select('*'); $this->db->from('rollover'); $this->db->join('master', 'master_id=rollover_id'); $data['startpage'] = ''; $data['endpage'] = ''; $data['count'] = ''; $data['results'] = ''; $this->db->order_by('rollover_id', 'desc'); $data['results'] = $this->db->get(); return $data; } function check_deactivate($class_name, $student_id, $date, $deactivate = '') { $date = $this->mastermodel->convertdateformat($date); $where = "(activate_date > '$date' OR activate_date='0000-00-00')"; $this->db->from('student_deactivate'); $this->db->where('student_id', $student_id); $this->db->where('student_class_id', $class_name); $this->db->where('start_date <=', $date); $this->db->where($where); $this->db->where('activate_date !=', $date); if ($deactivate != '') $this->db->where('deactivate_id !=', $deactivate); $count = $this->db->count_all_results(); return $count; } function check_unallocated($class_name, $student_id, $date) { $date = $this->mastermodel->convertdateformat($date); $this->db->from('student_class'); $this->db->where('student_id', $student_id); $this->db->where('class_name_id', $class_name); $this->db->where('class_allocation_date >', $date); $count = $this->db->count_all_results(); return $count; } /* Functions Used */ /* */ function get_student_monthly_wef_date($student_class_id, $date) { // echo $date.'ll'; $data = array(); $this->db->select('*', false); $this->db->from('student_monthly_fee'); $this->db->join('student_class_fee', 'student_class_fee.student_class_fee_id=student_monthly_fee.student_class_fee_id'); $this->db->join('student_class', 'student_class.student_class_id=student_class_fee.student_class_id'); $this->db->where('student_class.student_class_id', $student_class_id); $this->db->where('student_class_fee.payment_type', "monthly"); if ($date != "") { $this->db->where('fee_wef_date <=', $date); } $this->db->order_by('student_class_fee.student_class_fee_id,fee_wef_date', 'desc'); // $this->db->limit('1'); $Q = $this->db->get(); // echo $this->db->last_query(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[$row['student_class_fee_id']][] = $row; } } $Q->free_result(); return $data; } /* Get student monthly fee details */ function get_student_monthly_fee_details($student_class_id, $student_class_fee_id = "") { $data = array(); $this->db->select('*'); $this->db->from('student_monthly_fee'); $this->db->join('student_class_fee', 'student_class_fee.student_class_fee_id=student_monthly_fee.student_class_fee_id'); $this->db->join('student_class', 'student_class.student_class_id=student_class_fee.student_class_id'); $this->db->where('student_class.student_class_id', $student_class_id); if ($student_class_fee_id != "") { $this->db->where('student_class_fee.student_class_fee_id', $student_class_fee_id); } $this->db->where('student_class_fee.payment_type', "monthly"); $this->db->order_by('student_class_fee.student_class_fee_id,fee_wef_date'); $Q = $this->db->get(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[$row['student_class_fee_id']][] = $row; } } $Q->free_result(); return $data; } /* Get student fee paid details */ function get_student_fee_paid_details($student_class_id) { $data = array(); $this->db->select('*,sum(amount_paid) as amount_paid'); $this->db->from('fee'); $this->db->join('fee_paid_details', 'fee_paid_details.fee_id=fee.fee_id'); if ($student_class_id > 0) { $this->db->where('student_class_id', $student_class_id); } $this->db->order_by('student_class_id,student_class_fee_id'); $this->db->group_by('student_class_id,student_class_fee_id,payment_for'); $Q = $this->db->get(); // echo $this->db->last_query(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[$row['student_class_id']][$row['student_class_fee_id']][$row['payment_for']] = $row; } } $Q->free_result(); return $data; } /* Get student fee details */ function get_student_fee_details($sudent_class_id) { $data = array(); $this->db->select('*'); $this->db->from('student_class_fee'); $this->db->join('fee_particular', 'fee_particular.fee_particular_id=student_class_fee.fee_particular_id'); $this->db->where('student_class_id', $sudent_class_id); $Q = $this->db->get(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } /* Get Class details of a student */ function get_student_class_details($student_class_id) { $this->db->select('*'); $this->db->from('student_class'); $this->db->join('student', 'student.student_id=student_class.student_id'); $this->db->join('class_name', 'class_name.class_name_id=student_class.class_name_id'); $this->db->join('term', 'term.term_id=student_class.term_id'); $this->db->where('student_class_id', $student_class_id); $Q = $this->db->get(); $row = $Q->row(); $Q->free_result(); return $row; } /* Get Class room Details */ function get_class_name_details($class_name_id) { $this->db->select('*'); $this->db->from('class_name'); $this->db->join('class_room', 'class_room.class_room_id=class_name.class_room_id'); $this->db->join('session', 'session_id=class_name.class_session'); $this->db->join('term', 'term.term_id=class_name.class_term_id'); $this->db->where('class_name_id', $class_name_id); $Q = $this->db->get(); $row = $Q->row(); $Q->free_result(); return $row; } /* To Get Details of students Under a Class */ function get_student_class_allocation_details($class_name_id, $date = '') { if ($date == '') $date = date("Y-m-d"); $data = array(); $this->db->select('*'); $this->db->from('student_class'); $this->db->join('student', 'student.student_id=student_class.student_id'); $this->db->where("student_class_id not in (select student_class_id from student_cancellation where cancellation_date <= $date)", NULL, FALSE); $this->db->where('class_name_id', $class_name_id); $this->db->order_by('class_allocation_date'); $Q = $this->db->get(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } /* To Get Detail of Classes of a student */ function get_student_classes($student_id) { $data = array(); $this->db->select('*,student_class.student_class_id as student_class_id ,student_class.student_id as student_id, student_class.class_name_id as class_id,class_name_code as class_code'); $this->db->from('student_class'); $this->db->join('class_name', 'class_name.class_name_id=student_class.class_name_id'); $this->db->join('student_cancellation', 'student_cancellation.student_class_id=student_class.student_class_id', 'left'); $this->db->where('student_class.student_id', $student_id); $this->db->having('cancellation_id is null'); $Q = $this->db->get(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function search_assessment() { $data = array(); $this->db->select('*'); $this->db->from('student_assessment'); $this->db->join('class_name', 'class_name.class_name_id=student_assessment.class_name_id'); $this->db->join('assessment_master', 'assessment_master.assessment_master_id=student_assessment.assessment_master_id'); $data['results'] = $this->db->get(); return $data; } function insert_assessment($postdata) { $data = array(); $path = './assets/uploads/assessment'; $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $tblValues = array( 'assessment_id' => $masterid, 'class_name_id' => $postdata['class_name_id'], 'assessment_master_id' => $postdata['assessment_master_id'], 'remarks' => $postdata['remarks'], 'assessment_date' => $this->mastermodel->convertdateformat($postdata['assessment_date']), ); $this->db->insert('student_assessment', $tblValues); $j = 1; while (isset($postdata['student_id_' . $j])) { $stud_id = $postdata['student_id_' . $j]; $tblValues = array( 'student_assessment_id' => $masterid, 'student_id' => $stud_id, 'remarks' => $postdata['remarks_' . $j], ); $this->db->insert('student_assessment_details', $tblValues); $assessment_detail_id = mysql_insert_id(); $fileCount = count($_FILES["myfile$stud_id"]['name']); for ($k = 0; $k < $fileCount; $k++) { $file_index = 'myfile' . $stud_id; $title = $_FILES[$file_index]["name"][$k]; $uploaded_file = pathinfo($_FILES[$file_index]["name"][$k]); $extension = $uploaded_file['extension']; $file_name = date('Y-m-d-h-i-s') . '_' . $masterid . '_' . $stud_id . '_' . $k . '.' . $extension; $_FILES[$file_index]["name"][$k] = $file_name; $tmpname = $_FILES[$file_index]["name"][$k]; if (!is_file("$path" . $_FILES[$file_index]["name"][$k])) { if (!(move_uploaded_file($_FILES[$file_index]["tmp_name"][$k], $path . "/" . $_FILES[$file_index]["name"][$k]))) { $data['msg'] = "File not uploaded.. Permission denied!"; } else { $postdata['file_location'] = $path . "/" . $_FILES[$file_index]["name"][$k]; $data['msg'] = "File Uploaded successfully!"; $tblValues = array( 'student_assessment_detail_id' => $assessment_detail_id, 'student_id' => $stud_id, 'file' => $file_name, 'title' => $title ); $this->db->insert('student_assessment_files', $tblValues); } } else { $data['msg'] = "File already exists"; } } $j++; } $data['resfunction'] = 'search_assessment'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function update_assessment($postdata) { $data = array(); $this->db->trans_begin(); $tblValues = array( 'remarks' => $postdata['remarks'], ); $this->db->where('assessment_id', $postdata['assessment_id']); $this->db->update('student_assessment', $tblValues); $this->db->where('student_assessment_id', $postdata['assessment_id']); $this->db->delete('student_assessment_details'); $path = './assets/uploads/assessment'; $j = 1; while (isset($postdata['student_id_' . $j])) { $stud_id = $postdata['student_id_' . $j]; $tblValues = array( 'student_assessment_id' => $postdata['assessment_id'], 'student_id' => $stud_id, 'remarks' => $postdata['remarks_' . $j] ); $this->db->insert('student_assessment_details', $tblValues); $assessment_detail_id = mysql_insert_id(); $m = 0; while (isset($postdata['file_old_' . $stud_id . '_' . $m])) { $file_old = $postdata['file_old_' . $stud_id . '_' . $m]; $title_old = $postdata['title_old_' . $stud_id . '_' . $m]; $tblValues = array( 'student_assessment_detail_id' => $assessment_detail_id, 'student_id' => $stud_id, 'file' => $file_old, 'title' => $title_old ); $this->db->insert('student_assessment_files', $tblValues); $m++; } $fileCount = count($_FILES["myfile$stud_id"]['name']); for ($k = 0; $k < $fileCount; $k++) { $file_index = 'myfile' . $stud_id; if (isset($_FILES[$file_index]["name"][$k]) && $_FILES[$file_index]["name"][$k] != "") { $title = $_FILES[$file_index]["name"][$k]; $uploaded_file = pathinfo($_FILES[$file_index]["name"][$k]); $extension = $uploaded_file['extension']; $file_name = date('Y-m-d-h-i-s') . '_' . $postdata['assessment_id'] . '_' . $stud_id . '_' . $k . '.' . $extension; $_FILES[$file_index]["name"][$k] = $file_name; $tmpname = $_FILES[$file_index]["name"][$k]; if (!is_file("$path" . $_FILES[$file_index]["name"][$k])) { if (!(move_uploaded_file($_FILES[$file_index]["tmp_name"][$k], $path . "/" . $_FILES[$file_index]["name"][$k]))) { $data['msg'] = "File not uploaded.. Permission denied!"; } else { $postdata['file_location'] = $path . "/" . $_FILES[$file_index]["name"][$k]; $data['msg'] = "File Uploaded successfully!"; $tblValues = array( 'student_assessment_detail_id' => $assessment_detail_id, 'student_id' => $stud_id, 'file' => $file_name, 'title' => $title ); $this->db->insert('student_assessment_files', $tblValues); } } else { $data['msg'] = "File already exists"; } } } $j++; } $data['resfunction'] = 'search_assessment'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Updated Successfully'; return $data; } } function get_fee_paid_details($id) { $data = array(); $this->db->where('fee_paid_details.fee_id', $id); $this->db->join('student_class_fee', "student_class_fee.student_class_fee_id=fee_paid_details.student_class_fee_id"); $this->db->join('fee_particular', "fee_particular.fee_particular_id=student_class_fee.fee_particular_id"); $this->db->order_by('fee_paid_details.id', 'asc'); $Q = $this->db->get('fee_paid_details'); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } // echo $this->db->last_query(); $Q->free_result(); return $data; } function search_extra($pagenum) { $data = array(); $this->db->select('*'); $this->db->from('nutrition'); $this->db->join('master', 'master_id=nutrition_id'); $this->db->join('employee', 'employee.employee_id=nutrition.nutrition_teacher_id', 'left'); $this->db->join('physical', 'physical.physical_id=nutrition.nutrition_id'); $this->db->order_by('nutrition_id', 'desc'); $data['results'] = $this->db->get(); return $data; } // function get_preview_value($postdata) // { // // $data = array(); // $this->db->trans_begin(); // $masterid = $this->mastermodel->insertmasterdata(); // $data = array( // 'nutrition_id' => $masterid, // 'nutrition_student_id' => $postdata['student_id'], // 'nutrition_date' => $this->mastermodel->convertdateformat($postdata['nutrition_date']), // 'nutrition_teacher_id' => $postdata['nutrition_teacher_id'], // 'nutrition_arrived' => $postdata['nutrition_arrived'], // 'nutrition_departed' => $postdata['nutrition_departed'], // 'nutrition_food_dislike' => $postdata['nutrition_food_dislike'], // 'nutrition_play' => $postdata['nutrition_play'], // 'nutrition_requirement' => $postdata['nutrition_requirement'], // // ); // return $data; // // } function insert_extra($postdata) { $data = array(); $this->db->trans_begin(); $essentials = ""; if (isset($postdata['physical_essentials'])) { $essentials = implode(',', $postdata['physical_essentials']); } $masterid = $this->mastermodel->insertmasterdata(); $tblValues = array( 'nutrition_id' => $masterid, 'nutrition_student_id' => $postdata['student_id'], 'nutrition_date' => $this->mastermodel->convertdateformat($postdata['nutrition_date']), 'nutrition_teacher_id' => $postdata['nutrition_teacher_id'], 'nutrition_arrived' => $postdata['nutrition_arrived_hour'] . ':' . $postdata['nutrition_arrived_minute'], 'nutrition_departed' => $postdata['nutrition_departed_hour'] . ':' . $postdata['nutrition_departed_minute'], 'nutrition_food_dislike' => $postdata['nutrition_food_dislike'], 'nutrition_play' => $postdata['nutrition_play'], 'nutrition_requirement' => $postdata['nutrition_requirement'], ); $this->db->insert('nutrition', $tblValues); $i = 1; while (isset($postdata['nutrition_sleep_from_hour' . $i])) { if ($postdata['nutrition_sleep_from_hour' . $i] != '' && $postdata['nutrition_sleep_to_hour' . $i] != '') { $tbl_values = array( 'nutrition_id' => $masterid, 'nutrition_sleep_from' => $postdata['nutrition_sleep_from_hour' . $i] . ':' . $postdata['nutrition_sleep_from_minute' . $i], 'nutrition_sleep_to' => $postdata['nutrition_sleep_to_hour' . $i] . ':' . $postdata['nutrition_sleep_to_minute' . $i], ); $this->db->insert('nutrition_sleep', $tbl_values); } $i++; } $j = 1; while (isset($postdata['nutrition_bottle_time_hour' . $j])) { if ($postdata['nutrition_bottle_time_hour' . $j] != '') { $tbl_values = array( 'nutrition_id' => $masterid, 'nutrition_bottle_time' => $postdata['nutrition_bottle_time_hour' . $j] . ':' . $postdata['nutrition_bottle_time_minute' . $j], 'nutrition_bottle_amount' => $postdata['nutrition_bottle_amount' . $j], ); $this->db->insert('nutrition_bottle', $tbl_values); } $j++; } $k = 1; while (isset($postdata['nutrition_food_time_hour' . $k])) { if ($postdata['nutrition_food_time_hour' . $k] != '' && isset($postdata['nutrition_food_status' . $k])) { $tbl_values = array( 'nutrition_id' => $masterid, 'nutrition_food_time' => $postdata['nutrition_food_time_hour' . $k] . ':' . $postdata['nutrition_food_time_minute' . $k], 'nutrition_food_status' => $postdata['nutrition_food_status' . $k], ); $this->db->insert('nutrition_food', $tbl_values); } $k++; } $l = 1; while (isset($postdata['nutrition_nappies_time_hour' . $l]) && isset($postdata['nutrition_nappies_status' . $l]) && isset($postdata['nutrition_nappies_cream' . $l])) { if ($postdata['nutrition_nappies_time_hour' . $l] != '') { $tbl_values = array( 'nutrition_id' => $masterid, 'nutrition_nappies_time' => $postdata['nutrition_nappies_time_hour' . $l] . ':' . $postdata['nutrition_nappies_time_minute' . $l], 'nutrition_nappies_status' => $postdata['nutrition_nappies_status' . $l], 'nutrition_nappies_cream' => $postdata['nutrition_nappies_cream' . $l], ); $this->db->insert('nutrition_nappies', $tbl_values); } $l++; } if (isset($postdata['physical_status'])) $physical_status = $postdata['physical_status']; else $physical_status = ''; $tblValues = array( 'physical_id' => $masterid, 'physical_student_id' => $postdata['student_id'], 'physical_date' => $this->mastermodel->convertdateformat($postdata['nutrition_date']), 'physical_status' => $physical_status, 'physical_nappies' => $postdata['physical_nappies'], 'physical_essentials' => $essentials, 'physical_essentials_other' => $postdata['physical_essentials_other'], 'physical_learning' => $postdata['physical_learning'], 'physical_meal_comments' => $postdata['physical_meal_comments'], ); $this->db->insert('physical', $tblValues); $tblValues = array( 'medical_id' => $masterid, 'medical_student_id' => $postdata['student_id'], 'medical_date' => $this->mastermodel->convertdateformat($postdata['nutrition_date']), 'medical_health_status' => $postdata['medical_health_status'], 'medical_medication' => $postdata['medical_medication'], 'medical_special_requirements' => $postdata['medical_special_requirements'], 'medical_notes' => $postdata['medical_notes'] ); $this->db->insert('medical', $tblValues); $data['resfunction'] = 'search_extra'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function update_extra($postdata) { $this->db->trans_begin(); $data = array(); $essentials = ""; if (isset($postdata['physical_essentials'])) { $essentials = implode(',', $postdata['physical_essentials']); } $tblValues = array( 'nutrition_date' => $this->mastermodel->convertdateformat($postdata['nutrition_date']), 'nutrition_teacher_id' => $postdata['nutrition_teacher_id'], 'nutrition_arrived' => $postdata['nutrition_arrived_hour'] . ':' . $postdata['nutrition_arrived_minute'], 'nutrition_departed' => $postdata['nutrition_departed_hour'] . ':' . $postdata['nutrition_departed_minute'], 'nutrition_food_dislike' => $postdata['nutrition_food_dislike'], 'nutrition_play' => $postdata['nutrition_play'], 'nutrition_requirement' => $postdata['nutrition_requirement'], ); $this->db->where('nutrition_id', $postdata['nutrition_id']); $this->db->update('nutrition', $tblValues); $this->db->where('nutrition_id', $postdata['nutrition_id']); $this->db->delete('nutrition_sleep'); $this->db->where('nutrition_id', $postdata['nutrition_id']); $this->db->delete('nutrition_bottle'); $this->db->where('nutrition_id', $postdata['nutrition_id']); $this->db->delete('nutrition_food'); $this->db->where('nutrition_id', $postdata['nutrition_id']); $this->db->delete('nutrition_nappies'); $i = 1; while (isset($postdata['nutrition_sleep_from_hour' . $i])) { if ($postdata['nutrition_sleep_from_hour' . $i] != '' && $postdata['nutrition_sleep_to_hour' . $i] != '') { $tbl_values = array( 'nutrition_id' => $postdata['nutrition_id'], 'nutrition_sleep_from' => $postdata['nutrition_sleep_from_hour' . $i] . ':' . $postdata['nutrition_sleep_from_minute' . $i], 'nutrition_sleep_to' => $postdata['nutrition_sleep_to_hour' . $i] . ':' . $postdata['nutrition_sleep_to_minute' . $i], ); $this->db->insert('nutrition_sleep', $tbl_values); } $i++; } $j = 1; while (isset($postdata['nutrition_bottle_time_hour' . $j])) { if ($postdata['nutrition_bottle_time_hour' . $j] != '') { $tbl_values = array( 'nutrition_id' => $postdata['nutrition_id'], 'nutrition_bottle_time' => $postdata['nutrition_bottle_time_hour' . $j] . ':' . $postdata['nutrition_bottle_time_minute' . $j], 'nutrition_bottle_amount' => $postdata['nutrition_bottle_amount' . $j], ); $this->db->insert('nutrition_bottle', $tbl_values); } $j++; } $k = 1; while (isset($postdata['nutrition_food_time_hour' . $k]) && isset($postdata['nutrition_food_status' . $k])) { if ($postdata['nutrition_food_time_hour' . $k] != '') { $tbl_values = array( 'nutrition_id' => $postdata['nutrition_id'], 'nutrition_food_time' => $postdata['nutrition_food_time_hour' . $k] . ':' . $postdata['nutrition_food_time_minute' . $k], 'nutrition_food_status' => $postdata['nutrition_food_status' . $k], ); $this->db->insert('nutrition_food', $tbl_values); } $k++; } $l = 1; while (isset($postdata['nutrition_nappies_time_hour' . $l]) && isset($postdata['nutrition_nappies_status' . $l]) && isset($postdata['nutrition_nappies_cream' . $l])) { if ($postdata['nutrition_nappies_time_hour' . $l] != '') { $tbl_values = array( 'nutrition_id' => $postdata['nutrition_id'], 'nutrition_nappies_time' => $postdata['nutrition_nappies_time_hour' . $l] . ':' . $postdata['nutrition_nappies_time_minute' . $l], 'nutrition_nappies_status' => $postdata['nutrition_nappies_status' . $l], 'nutrition_nappies_cream' => $postdata['nutrition_nappies_cream' . $l], ); $this->db->insert('nutrition_nappies', $tbl_values); } $l++; } if (isset($postdata['physical_status'])) $physical_status = $postdata['physical_status']; else $physical_status = ''; $tblValues = array( 'physical_status' => $physical_status, 'physical_nappies' => $postdata['physical_nappies'], 'physical_essentials' => $essentials, 'physical_essentials_other' => $postdata['physical_essentials_other'], 'physical_learning' => $postdata['physical_learning'], 'physical_meal_comments' => $postdata['physical_meal_comments'], ); $this->db->where('physical_id', $postdata['nutrition_id']); $this->db->update('physical', $tblValues); $tblValues = array( 'medical_health_status' => $postdata['medical_health_status'], 'medical_medication' => $postdata['medical_medication'], 'medical_special_requirements' => $postdata['medical_special_requirements'], 'medical_notes' => $postdata['medical_notes'], ); $this->db->where('medical_id', $postdata['nutrition_id']); $this->db->update('medical', $tblValues); $data['resfunction'] = 'search_extra'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Updated Successfully'; return $data; } } function delete_cancellation($cancellation_id, $student_class_id) { $data = array(); $this->db->trans_begin(); $this->db->delete('student_cancellation', array('cancellation_id' => $cancellation_id)); $tblValues = array( 'cancelled' => 0, ); $this->db->where('student_class_id', $student_class_id); $this->db->update('student_class', $tblValues); $this->db->trans_status(); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Unable to delete record because of associated data'; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Data Deleted Successfully'; } return $data; } function parent($id) { $data = array(); $this->db->select('*'); $this->db->from('parent_student'); $this->db->join('parent', 'parent.parent_id=parent_student.parent_id'); $this->db->where('parent_student.student_id', $id); $this->db->order_by('parent_student.student_id', 'desc'); $Q = $this->db->get(); // echo $this->db->last_query(); $row = $Q->row(); return $row; } function entry_added_feeterm($class_term_id, $class_name_academic_year_id, $class_session) { $this->db->select('*'); $this->db->from('fee_term'); $this->db->where('fee_term.fee_term_term_id', $class_term_id); $this->db->where('fee_term.fee_term_academic_year_id', $class_name_academic_year_id); $this->db->where('fee_term.fee_term_session', $class_session); $Q = $this->db->get(); $row = $Q->row(); return $row; } function days_added_for_class($class_term_id, $class_name_academic_year_id, $class_session) { $data = array(); $this->db->select('fee_term_details.fee_term_no_of_days'); $this->db->from('fee_term_details'); $this->db->join('fee_term', 'fee_term.fee_term_id=fee_term_details.fee_term_id'); $this->db->where('fee_term.fee_term_term_id', $class_term_id); $this->db->where('fee_term.fee_term_academic_year_id', $class_name_academic_year_id); $this->db->where('fee_term.fee_term_session', $class_session); $Q = $this->db->get(); // echo $this->db->last_query(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } // echo $this->db->last_query(); $Q->free_result(); return $data; } function student_pdf($id) { $this->db->select('*'); $this->db->from('student'); $this->db->join('parent_student', 'parent_student.student_id=student.student_id'); $this->db->join('parent', 'parent.parent_id=parent_student.parent_id'); $this->db->where('student.student_id', $id); $Q = $this->db->get(); // echo $this->db->last_query(); $row = $Q->row(); return $row; } function studentreceiptclassdetails($id) { $data = array(); $this->db->select('*'); $this->db->from('student'); $this->db->join('student_class', 'student_class.student_id=student.student_id'); $this->db->join('class_name', 'class_name.class_name_id=student_class.class_name_id'); $this->db->where('student.student_id', $id); $this->db->order_by('class_name.class_name_id', 'desc'); $data['results'] = $this->db->get(); return $data; } function insert_student_account_code($reg_no,$firstname,$lastname) { $parent = $this->mastermodel->get_account_settings('student', 'finance_sub_account_settings'); if ($parent) { $chart_type_id = $this->mastermodel->get_single_field_value('finance_chart_master', 'chart_type_id', 'chart_master_id', $parent); if ($this->mastermodel->get_num_rows('finance_chart_master', 'chart_account_code', $reg_no) == 0) { $tblValues = array('chart_account_code' => $reg_no, 'chart_account_name' =>$firstname . '-' . $lastname, 'chart_type_id' => $chart_type_id, 'parent' => $parent, 'inactive' => 0); $this->db->insert('finance_chart_master', $tblValues); $insert_id = $this->db->insert_id(); return $insert_id; } } } } ?>