Server IP : 103.191.208.50 / Your IP : 216.73.216.53 Web Server : LiteSpeed System : Linux orion.herosite.pro 4.18.0-553.53.1.lve.el8.x86_64 #1 SMP Wed May 28 17:01:02 UTC 2025 x86_64 User : celkcksm ( 1031) PHP Version : 7.4.33 Disable Function : show_source, system, shell_exec, passthru, popen, exec MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/celkcksm/ecampus.ncriptech.com/application/controllers/admin/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php defined('BASEPATH') OR exit('No direct script access allowed'); /** * */ class Hostels extends BaseAdminController { protected $inst_id=''; protected $inst_parent_id=''; protected $inst_code=''; protected $inst_type=''; protected $user_type=''; protected $hrms_access=''; protected $hostel_add_access=''; protected $hostel_edit_access=''; protected $hostel_delete_access=''; protected $hostel_fees_add_access=''; protected $hostel_fees_edit_access=''; protected $hostel_fees_delete_access=''; protected $hostel_view_access=''; protected $session_course_delete_access=''; protected $session_course_view_access=''; protected $user_permissions=''; function __construct() { parent::__construct(); $institute_data=check_institute($this->data['userdata']); //print_obj($institute_data);die; $this->user_type=$this->data['userdata']->user_type; $this->inst_id=$institute_data['institute_id']; $this->inst_parent_id=$institute_data['inst_parent_id']; $this->inst_code=$institute_data['inst_code']; $this->inst_type=$institute_data['inst_type']; $this->hostel_add_access=$institute_data['hostel_add_access']; $this->hostel_view_access=$institute_data['hostel_view_access']; $this->hostel_edit_access=$institute_data['hostel_edit_access']; $this->hostel_delete_access=$institute_data['hostel_delete_access']; $this->hostel_fees_add_access=$institute_data['hostel_fees_add_access']; $this->hostel_fees_edit_access=$institute_data['hostel_fees_edit_access']; $this->hostel_fees_delete_access=$institute_data['hostel_fees_delete_access']; // print_obj($this->hostel_fees_delete_access); // die(); //echo $this->hostel_fees_add_access;die; } function index(){ // print_obj($this->data['userdata']); // die(); if($this->data['userdata']->user_type=='student') { redirect($this->data['base_url']); } else if($this->data['userdata']->user_type=='institute' ){ if(session_userdata('isAdminLoggedin')){ $this->data['page_title']='Hostels'; if($this->hostel_view_access=='yes'){ $this->data['hostel_add_access']=$this->hostel_add_access; $this->data['students']=$this->um->get_students(array('stu_inst_id'=>$this->inst_id,'stu_user_id!='=>null),FALSE); $this->data['add_access']=$this->hostel_add_access; $this->data['edit_access'] = $this->hostel_edit_access; $view='master/vw_hostels'; }else{ $this->data['bredcrumb_data']='Hostels'; $view='master/vw_permission_denied'; } $this->theme->title($this->data['page_title'])->load('master/vw_hostels', $this->data); }else{ redirect($this->data['base_url']); } } else{ } } /*---------------------Update (07-04-2022) -----------------*/ function indexHostelFees(){ if($this->data['userdata']->user_type=='student') { redirect($this->data['base_url']); } if(session_userdata('isAdminLoggedin')){ $this->data['add_access']=$this->hostel_view_access; $this->data['edit_access'] = $this->hostel_add_access; /* print($this->hostel_fees_edit_access); die();*/ $this->data['page_title']='Hostel Fees'; $sessions=$this->sessm->get_session(array('session_inst_id'=>$this->inst_id),FALSE); $courses=$this->cm->get_course(array('course_inst_id'=>$this->inst_id),FALSE); $session_courses=$this->sessm->get_session_courses(array('session_inst_id'=>$this->inst_id),FALSE); $this->data['sessions']=$sessions; $this->data['courses']=$courses; $this->data['session_courses']=$session_courses; $this->data['hostels']=$this->hm->get_hostel(array('hostel_inst_id'=>$this->inst_id),FALSE); $this->theme->title($this->data['page_title'])->load('master/vw_hostels_fees', $this->data); }else{ redirect($this->data['base_url']); } } function indexHostelFeesAdmission(){ if($this->data['userdata']->user_type=='student') { redirect($this->data['base_url']); } if(session_userdata('isAdminLoggedin')){ $this->data['page_title']='Hostel Admission Fees'; $sessions=$this->sessm->get_session(array('session_inst_id'=>$this->inst_id),FALSE); $this->data['hostels']=$this->hm->get_hostel(array('hostel_inst_id'=>$this->inst_id),FALSE); $courses=$this->cm->get_course(array('course_inst_id'=>$this->inst_id),FALSE); $session_courses=$this->sessm->get_session_courses(array('session_inst_id'=>$this->inst_id),FALSE); //print_obj($session_courses);die; $this->data['add_access']=$this->hostel_fees_add_access; $this->data['edit_access']=$this->hostel_fees_edit_access; $this->data['page_title']='Admission'; $this->data['sessions']=$sessions; $this->data['courses']=$courses; $this->data['session_courses']=$session_courses; $this->theme->title($this->data['page_title'])->load('master/vw_hostels_admission_fees', $this->data); }else{ redirect($this->data['base_url']); } } public function onAddEditHostels(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $hostel_name=post_data('hostel_name'); $hostel_address=post_data('hostel_address'); $hostel_type=post_data('hostel_type'); $hostel_id=post_data('_hostel'); //echo $course_id;die; $this->form_validation->set_rules('hostel_name', 'Hostel Name required', 'trim|required'); $this->form_validation->set_rules('hostel_address', 'Hostel Address required', 'trim|required'); if ($this->form_validation->run() == true){ $section_data=$this->hm->get_hostel(array('hostel_inst_id'=>$this->inst_id,'hostel_name'=>$hostel_name,'hostel_address'=>$hostel_address)); if(empty($hostel_id)){ //get laast id $added=$this->hm->store_hostel(array('hostel_inst_id'=>$this->inst_id,'hostel_name'=>$hostel_name,'hostel_address'=>$hostel_address,'hostel_type'=>$hostel_type)); }else if(!empty($hostel_id)){ $hostel_id=decode_data($hostel_id); $added=$this->hm->update_hostel(array('hostel_inst_id'=>$this->inst_id,'hostel_name'=>$hostel_name,'hostel_address'=>$hostel_address,'hostel_type'=>$hostel_type),array('hostel_id'=>$hostel_id)); } if($added){ $return['success']=(!empty($hostel_id))?'Hostel updated successfully':'Hostel added successfully'; }else{ $return['error']=(!empty($hostel_id))?'Hostel not updated':'Hostel not added'; } }else{ $return['error']='Error occurred'; } json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onSearchHostelsList(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $param['column_order'] = array( null, 'hostel_name', 'hostel_address' ); $param['column_search'] = array('hostel_name','hostel_address'); $param['order'] = array('hostel_id' => 'ASC'); $posts=$this->input->post(); $param['inst_id']=$this->inst_id; $list = $this->hm->_get_hostels($posts,$param,FALSE,FALSE); $data = array(); $no = isset($posts['start'])?$posts['start']:0; $action=''; foreach ($list as $hostels){ $no++; $row = array(); $row[] = $no; $row[] = ucwords($hostels->hostel_type); $row[] = $hostels->hostel_name.'<br>'.$hostels->hostel_address; if($this->hostel_fees_add_access=='yes' && $this->hostel_delete_access=='yes' && $this->hostel_edit_access=='yes' ){ $row[]=' <a href="'.$this->data['base_url'].'/hostels/fees"><button type="button" class="btn btn-xs btn-info waves-effect waves-light" data-hostel_id="'.encode_data($hostels->hostel_id).'" data-hostel_name="'.$hostels->hostel_name.'">Add Hostel Fees</button></a> <button type="button" class="btn btn-xs btn-info btn_edit_hostel" data-hostel="'.encode_data($hostels->hostel_id).'" data-hostel_name="'.$hostels->hostel_name.'" data-hostel_address="'.$hostels->hostel_address.'" data-hostel_type="'.$hostels->hostel_type.'"><i class="fa fa-edit"></i></button> <button type="button" class="btn btn-xs btn-danger btn_delete_hostel" data-hostel="'.encode_data($hostels->hostel_id).'"><i class="fa fa-trash"></i></button> '; } elseif($this->hostel_fees_add_access=='yes' && $this->hostel_edit_access=='yes'){ $row[]='<a href="'.$this->data['base_url'].'/hostels/fees"><button type="button" class="btn btn-xs btn-info waves-effect waves-light" data-hostel_id="'.encode_data($hostels->hostel_id).'" data-hostel_name="'.$hostels->hostel_name.'">Add Hostel Fees</button></a> <button type="button" class="btn btn-xs btn-info btn_edit_hostel" data-hostel="'.encode_data($hostels->hostel_id).'" data-hostel_name="'.$hostels->hostel_name.'" data-hostel_address="'.$hostels->hostel_address.'" data-hostel_type="'.$hostels->hostel_type.'"><i class="fa fa-edit"></i></button> '; } elseif($this->hostel_fees_add_access=='yes' && $this->hostel_delete_access=='yes'){ $row[]='<a href="'.$this->data['base_url'].'/hostels/fees"><button type="button" class="btn btn-xs btn-info waves-effect waves-light" data-hostel_id="'.encode_data($hostels->hostel_id).'" data-hostel_name="'.$hostels->hostel_name.'">Add Hostel Fees</button></a> <button type="button" class="btn btn-xs btn-danger btn_delete_hostel" data-hostel="'.encode_data($hostels->hostel_id).'"><i class="fa fa-trash"></i></button> '; } elseif($this->hostel_edit_access=='yes' && $this->hostel_delete_access=='yes'){ $row[]=' <button type="button" class="btn btn-xs btn-info btn_edit_hostel" data-hostel="'.encode_data($hostels->hostel_id).'" data-hostel_name="'.$hostels->hostel_name.'" data-hostel_address="'.$hostels->hostel_address.'" data-hostel_type="'.$hostels->hostel_type.'"><i class="fa fa-edit"></i></button> <button type="button" class="btn btn-xs btn-danger btn_delete_hostel" data-hostel="'.encode_data($hostels->hostel_id).'"><i class="fa fa-trash"></i></button> '; } else if($this->hostel_fees_add_access=='yes'){ $row[]=' <a href="'.$this->data['base_url'].'/hostels/fees"><button type="button" class="btn btn-xs btn-info waves-effect waves-light" data-hostel_id="'.encode_data($hostels->hostel_id).'" data-hostel_name="'.$hostels->hostel_name.'">Add Hostel Fees</button></a> '; } else if($this->hostel_delete_access=='yes'){ $row[]=' <button type="button" class="btn btn-xs btn-danger btn_delete_hostel" data-hostel="'.encode_data($hostels->hostel_id).'"><i class="fa fa-trash"></i></button> '; } else if($this->hostel_edit_access=='yes'){ $row[]=' <button type="button" class="btn btn-xs btn-info btn_edit_hostel" data-hostel="'.encode_data($hostels->hostel_id).'" data-hostel_name="'.$hostels->hostel_name.'" data-hostel_address="'.$hostels->hostel_address.'" data-hostel_type="'.$hostels->hostel_type.'"><i class="fa fa-edit"></i></button> '; } else{ $row[]='<span class="badge badge-danger">Not Permitted</span>'; } $data[] = $row; } $output = array( "draw" => isset($posts['draw'])?$posts['draw']:'', "recordsTotal" => $this->hm->_get_hostels($posts,$param,TRUE), "recordsFiltered" => $this->hm->_get_hostels($posts,$param,TRUE), "data" => $data, ); echo json_encode($output); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onDeleteHostels(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $hostel=post_data('hostel'); $hostel_id=decode_data($hostel); $hostel_data=$this->hm->get_hostel(array('hostel_id'=>$hostel_id)); if(!empty($hostel_data)){ $assigned_data=$this->hm->get_hostel_admission_fees_assign_data(array('assign_hostel_id'=>$hostel_id)); $assigned_students=$this->fm->get_hostel_fees_payment(array('payment_hostel_id'=>$hostel_id)); if(empty($assigned_data) && empty($assigned_students)){ $deleted=$this->hm->delete_hostel(array('hostel_id'=>$hostel_id)); if($deleted){ $return['success']='Hostel deleted successfully.'; }else{ $return['error']='Hostel not deleteed.'; } }else{ $return['error']='Hostel data is associated with other data.Hostel can not be deleted now.'; } }else{ $return['error']='Hostel not found'; } json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } /*----------------- Hostel Fees ------------------*/ public function onSearchHostelsFeesList(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $param['column_order'] = array( null, 'fees_hostel_id', 'fees_session_id', 'fees_course_id', 'fees_value' ); $param['column_search'] = array('fees_hostel_id','fees_session_id','fees_course_id','fees_value'); $param['order'] = array('fees_id' => 'ASC'); $posts=$this->input->post(); $param['inst_id']=$this->inst_id; $list = $this->hm->_get_hostel_fees($posts,$param,FALSE,FALSE); //print_obj($list);die; $data = array(); $no = isset($posts['start'])?$posts['start']:0; $action=''; foreach ($list as $hostelsFees){ $no++; $row = array(); $course_data=''; $session_year=$hostelsFees->session_start_year ."-". $hostelsFees->session_end_year; $row[] = $no; $row[] = $hostelsFees->hostel_name.'<br>'; $row[] = $hostelsFees->course_code.'<br>'.$session_year; $row[] = number_format($hostelsFees->fees_value,2).'<br>Due '.ordinal($hostelsFees->fees_due_date).' <br>of each month'; $row[] = number_format($hostelsFees->fees_late_value,2); $data[] = $row; } $output = array( "draw" => isset($posts['draw'])?$posts['draw']:'', "recordsTotal" => $this->hm->_get_hostel_fees($posts,$param,TRUE), "recordsFiltered" => $this->hm->_get_hostel_fees($posts,$param,TRUE), "data" => $data, ); echo json_encode($output); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onSearchHostelsAdmissionFeesList(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $param['column_order'] = array( null, 'hostel_name', 'course_name', 'session_start_year', 'year_value' ); $param['column_search'] = array('admission_fees_value','year_value','hostel_name','course_name'); $param['order'] = array('admission_fees_id' => 'ASC'); $posts=$this->input->post(); $param['inst_id']=$this->inst_id; $list = $this->hm->_get_hostel_admission_fees($posts,$param,FALSE,FALSE); //print_obj($list);die; $data = array(); $no = isset($posts['start'])?$posts['start']:0; $action=''; foreach ($list as $hostelsFees){ $no++; $row = array(); $session_year=$hostelsFees->session_start_year ."-". $hostelsFees->session_end_year; $row[] = $no; $row[] = $hostelsFees->hostel_name; $row[] = $hostelsFees->course_code.'<br>'.$session_year.'<br>Year:'.$hostelsFees->year_value; $row[] = number_format($hostelsFees->admission_fees_value,2); $row[] = number_format($hostelsFees->admission_caution_fees_value,2); if($this->hostel_fees_edit_access=='yes' && $this->hostel_fees_delete_access=='yes'){ $row[] = '<button type="button" class="btn btn-xs btn-info btn_edit_hostel_admission_fees" data-fees_id="'.encode_data($hostelsFees->admission_fees_id).'" data-hostel="'.$hostelsFees->admission_hostel_id.'" data-admission_fees="'.$hostelsFees->admission_fees_value.'" data-course_id="'.$hostelsFees->course_id.'" data-caution_fees="'.$hostelsFees->admission_caution_fees_value.'" data-session_id="'.$hostelsFees->session_id.'" data-session_year="'.$hostelsFees->year_id.'"><i class="fa fa-edit"></i></button> <button type="button" class="btn btn-xs btn-danger btn_delete_hostel_admission_fees" data-fees_id="'.encode_data($hostelsFees->admission_fees_id).'"><i class="fa fa-trash"></i></button>';} elseif($this->hostel_fees_edit_access=='yes'){ $row[] = '<button type="button" class="btn btn-xs btn-info btn_edit_hostel_admission_fees" data-fees_id="'.encode_data($hostelsFees->admission_fees_id).'" data-hostel="'.$hostelsFees->admission_hostel_id.'" data-admission_fees="'.$hostelsFees->admission_fees_value.'" data-course_id="'.$hostelsFees->course_id.'" data-caution_fees="'.$hostelsFees->admission_caution_fees_value.'" data-session_id="'.$hostelsFees->session_id.'" data-session_year="'.$hostelsFees->year_id.'"><i class="fa fa-edit"></i></button> '; } elseif($this->hostel_fees_delete_access=='yes'){ $row[] = ' <button type="button" class="btn btn-xs btn-danger btn_delete_hostel_admission_fees" data-fees_id="'.encode_data($hostelsFees->admission_fees_id).'"><i class="fa fa-trash"></i></button>';} else{ $row[] = 'Not permitted'; } $data[] = $row; } $output = array( "draw" => isset($posts['draw'])?$posts['draw']:'', "recordsTotal" => $this->hm->_get_hostel_admission_fees($posts,$param,TRUE), "recordsFiltered" => $this->hm->_get_hostel_admission_fees($posts,$param,TRUE), "data" => $data, ); echo json_encode($output); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onAddEditHostelFees(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $hostel_session=post_data('hostel_session'); $hostel_course=post_data('hostel_course'); $hostel_id=post_data('hostel_id'); $hostel_fees=post_data('hostel_fees'); $hostel_late_fees=post_data('hostel_late_fees'); $hostel_due_date=post_data('hostel_due_date'); $fees_id=post_data('_fees'); //echo $course_id;die; $this->form_validation->set_rules('hostel_session', 'Academic Session is required', 'trim|required'); $this->form_validation->set_rules('hostel_course', 'Course is required', 'trim|required'); $this->form_validation->set_rules('hostel_id', 'Hostel Name is required', 'trim|required'); $this->form_validation->set_rules('hostel_fees', 'Fees is required', 'trim|required'); if ($this->form_validation->run() == true){ $section_data=$this->hm->get_hostel_fees(array('fees_inst_id'=>$this->inst_id,'fees_hostel_id'=>$hostel_id,'fees_session_id'=>$hostel_session,'fees_course_id'=>$hostel_course,'fees_value'=>$hostel_fees)); if(empty($fees_id)){ //get laast id $added=$this->hm->store_hostel_fees(array('fees_inst_id'=>$this->inst_id,'fees_hostel_id'=>$hostel_id,'fees_session_id'=>$hostel_session,'fees_course_id'=>$hostel_course,'fees_value'=>$hostel_fees,'fees_late_value'=>$hostel_late_fees,'fees_due_date'=>$hostel_due_date)); }else if(!empty($fees_id)){ $fees_id=decode_data($fees_id); $added=$this->hm->update_hostel_fees(array('fees_inst_id'=>$this->inst_id,'fees_hostel_id'=>$hostel_id,'fees_session_id'=>$hostel_session,'fees_course_id'=>$hostel_course,'fees_value'=>$hostel_fees,'fees_late_value'=>$hostel_late_fees,'fees_due_date'=>$hostel_due_date),array('fees_id'=>$fees_id)); } if($added){ $return['success']=(!empty($fees_id))?'Hostel Fees updated successfully':'Hostel Fees added successfully'; }else{ $return['error']=(!empty($fees_id))?'Hostel Fess not updated':'Hostel Fes not added'; } }else{ $return['error']='Error occurred'; } json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onAddEditHostelAdmissionFees(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $hostel_session=post_data('hostel_session'); $hostel_course=post_data('hostel_course'); $hostel_id=post_data('hostel_id'); $hostel_fees=post_data('hostel_fees'); $hostel_caution_fees=post_data('hostel_caution_fees'); $hostel_academic_year=post_data('hostel_academic_year'); $fees_id=post_data('_fees'); //echo $course_id;die; $this->form_validation->set_rules('hostel_session', 'Academic Session is required', 'trim|required'); $this->form_validation->set_rules('hostel_course', 'Course is required', 'trim|required'); $this->form_validation->set_rules('hostel_id', 'Hostel Name is required', 'trim|required'); $this->form_validation->set_rules('hostel_fees', 'Fees is required', 'trim|required'); $this->form_validation->set_rules('hostel_caution_fees', 'Caution Fees is required', 'trim|required'); if ($this->form_validation->run() == true){ $fees_data=$this->hm->get_hostel_admission_fees(array('admission_inst_id'=>$this->inst_id,'admission_hostel_id'=>$hostel_id,'admission_sess_id'=>$hostel_session,' admission_course_id'=>$hostel_course,'admission_fees_value'=>$hostel_fees,'admission_academic_year_id'=>$hostel_academic_year)); if(empty($fees_id)){ //get laast id $added=$this->hm->store_hostel_admission_fees(array('admission_inst_id'=>$this->inst_id,'admission_hostel_id'=>$hostel_id,'admission_sess_id'=>$hostel_session,' admission_course_id'=>$hostel_course,'admission_fees_value'=>$hostel_fees,'admission_caution_fees_value'=>$hostel_caution_fees,'admission_academic_year_id'=>$hostel_academic_year,'created_by'=>$this->data['userdata']->user_id,'created_at'=>date('Y-m-d'))); }else if(!empty($fees_id)){ $fees_id=decode_data($fees_id); $added=$this->hm->update_hostel_admission_fees(array('admission_inst_id'=>$this->inst_id,'admission_hostel_id'=>$hostel_id,'admission_sess_id'=>$hostel_session,'admission_course_id'=>$hostel_course,'admission_fees_value'=>$hostel_fees,'admission_caution_fees_value'=>$hostel_caution_fees,'admission_academic_year_id'=>$hostel_academic_year,'updated_by'=>$this->data['userdata']->user_id,'updated_at'=>date('Y-m-d')),array('admission_fees_id'=>$fees_id)); } if($added){ $return['success']=(!empty($fees_id))?'Hostel Admission Fees updated successfully':'Hostel Admission Fees added successfully'; }else{ $return['error']=(!empty($fees_id))?'Hostel Admission Fess not updated':'Hostel Admission Fees not added'; } }else{ $return['error']='Error occurred'; } json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onDeleteHostelAdmissionFees(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $fees_id=post_data('fees_id'); if($fees_id!=''){ $fees_id=decode_data($fees_id); $fes_details=$this->hm->get_hostel_admission_fees(array('admission_fees_id'=>$fees_id)); if(!empty($fes_details)){ $assigned_data=$this->hm->get_hostel_admission_fees_assign_data(array('assign_hostel_admission_fees_id'=>$fees_id)); if(empty($assigned_data)){ $deleted=-$this->hm->delete_hostel_admission_fees(array('admission_fees_id'=>$fees_id)); if($deleted){ $return['success']='Data has been deleted from the system.'; }else{ $return['error']='Data not deleted from the system.'; } }else{ $return['error']='There are students already assigned.Data can not be deleted now.'; } }else{ $return['error']='Fees details not found in the system.'; } }else{ $return['error']='Data tamper not allowed'; } json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onDeleteHostelsFees(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $fees=post_data('fees'); $fees_id=decode_data($fees); $hostel_fees_data=$this->hm->get_hostel_fees(array('fees_id'=>$fees_id)); if(!empty($hostel_fees_data)){ $assigned_students=$this->fm->get_hostel_fees_payment(array('payment_hostel_id'=>$hostel_fees_data->fees_hostel_id,'payment_hostel_sess_id'=>$hostel_fees_data->fees_session_id,'payment_hostel_course_id'=>$hostel_fees_data->fees_course_id)); if(empty($assigned_students)){ $deleted=$this->hm->delete_hostel_fees(array('fees_id'=>$fees_id)); if($deleted){ $return['success']='Hostel Fees deleted successfully.'; }else{ $return['error']='Hostel Fess not deleteed.'; } }else{ $return['error']='Fees already assigned to the students.Data can not be deleted now.'; } }else{ $return['error']='Hostel fees data not found'; } json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onAssignStudents(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $hostel_id=post_data('hostel_id'); $course_id=post_data('course_id'); $session_id=post_data('session_id'); if(!empty($hostel_id)){ $hostel_id=decode_data($hostel_id); $session_id=decode_data($session_id); $course_id=decode_data($course_id); $institute_data=check_institute($this->data['userdata']); $inst_id=$this->inst_id; $students_to_assign=$this->input->post('students_to_assign'); //print_obj($students_to_assign);die; $months=array('january'=>'01','february'=>'02','march'=>'03','april'=>'04','may'=>'05','june'=>'06','july'=>'07','august'=>'08','september'=>'09','october'=>'10','november'=>'11','december'=>'12'); $session_data=$this->sessm->get_session(array('session_id'=>$session_id)); $get_hostel_fees=$this->hm->get_hostel_fees(array('fees_hostel_id'=>$hostel_id,'fees_session_id'=>$session_id)); if(!empty($students_to_assign)){ foreach ($students_to_assign as $key => $value) { $student_ids[]=(isset($value['students_id']))?$value['students_id']:null; } if(!empty($student_ids)){ foreach ($students_to_assign as $key => $value) { $student_id=$value['students_id']; $rent_value=$value['hostel_fees']; $schedule_date=$value['rent_schedule']; $schedule_start_year=$value['start_year']; $shedule_start_month=$value['start_month']; if(!empty($student_id) && $student_id>0){ $this->hm->delete_hostel_assign_data(array('assigned_hostel_id'=>$hostel_id, 'assigned_stu_id'=>$student_id, 'assigned_inst_id'=>$inst_id, 'assigned_sess_id'=>$session_id, 'assigned_course_id'=>$course_id)); $hostel_assigned_data[]=array( 'assigned_hostel_id'=>$hostel_id, 'assigned_stu_id'=>$student_id, 'assigned_inst_id'=>$inst_id, 'assigned_sess_id'=>$session_id, 'assigned_course_id'=>$course_id, 'assigned_fees'=>$rent_value, 'assigned_billing_cycle'=>$schedule_date , 'assigned_billing_start_year'=>$schedule_start_year, 'assigned_billing_start_month'=>$shedule_start_month ); } } //print_obj if(isset($hostel_assigned_data) && !empty($hostel_assigned_data)){ $hostel_assigned=$this->hm->store_hostel_assign_data($hostel_assigned_data,true); if($hostel_assigned){ $session_data=$this->sessm->get_session(array('session_id'=>$session_id)); foreach ($students_to_assign as $key => $value) { $this->um->update_students(array('stu_avail_hostel'=>'yes','stu_avail_hostel_id'=>$hostel_id,'updated_by'=>$this->data['userdata']->user_id,'updated_at'=>date('Y-m-d')),array('stu_user_id'=>$value['students_id'])); } //foreach ($months as $mkey => $mvalue) { for ($smonth=$shedule_start_month; $smonth<=12; $smonth++) { $month_val=strtolower(get_month_from_number($smonth)); //echo $month_val; foreach ($students_to_assign as $key => $value) { $student_id=$value['students_id']; $rent_value=$value['hostel_fees']; $schedule_date=$value['rent_schedule']; $schedule_start_year=$value['start_year']; $shedule_start_month=$value['start_month']; if(!empty($student_id) && $student_id>0){ for ($i=$schedule_start_year; $i <=$session_data->session_end_year ; $i++) { if($schedule_date>9){ $due_at=$i.'-'.$smonth.'-'.$schedule_date; }else{ $due_at=$i.'-'.$smonth.'-0'.$schedule_date; } $payment_unique_code=generate_string(4); $payment_hostel=array( 'payment_hostel_id'=>$hostel_id, 'payment_hostel_inst_id'=>$inst_id, 'payment_hostel_sess_id'=>$session_id, 'payment_hostel_course_id'=>$course_id, 'payment_hostel_stu_id'=>$student_id, 'payment_unique_code'=>$payment_unique_code, 'payment_year'=>$i, 'payment_month'=>$month_val, 'payment_value'=>$rent_value, 'payment_late_value'=>$get_hostel_fees->fees_late_value, 'payment_status'=>'not paid', 'due_at'=>$due_at, 'created_at'=>date('Y-m-d') ); //print_obj($payment_hostel); $get_hostel_fees_payment=$this->fm->delete_hostel_fees_payment(array('payment_hostel_id'=>$hostel_id, 'payment_hostel_inst_id'=>$inst_id, 'payment_hostel_sess_id'=>$session_id, 'payment_hostel_course_id'=>$course_id, 'payment_hostel_stu_id'=>$student_id, 'payment_year'=>$i, 'payment_month'=>$month_val)); $this->fm->store_hostel_fees_payment($payment_hostel); } } } } //die; //} $return['success']='Hostel rents assigned'; }else{ $return['error']='Hostel not assigned'; } }else{ $return['error']='Hostel not assigned'; } }else{ $return['error']='Please select student.'; } }else{ $return['error']='Error occurred'; } }else{ $return['error']='Hostel not found'; } json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onAssignStudents_backup(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $inst_id=$this->data['userdata']->user_id; $hostel_id=post_data('hostel_id'); $course_id=post_data('course_id'); $session_id=post_data('session_id'); $student_id=post_data('student_id'); $year_value=$this->input->post('year_value'); $year_date_value=$this->input->post('year_date_value'); if(!empty($hostel_id) && !empty($course_id) && !empty($session_id)){ $hostel_id=decode_data($hostel_id); $session_id=decode_data($session_id); $course_id=decode_data($course_id); $students=$this->input->post('students_to_assign'); if(!empty($students)){ $session_data=$this->sessm->get_session(array('session_id'=>$session_id)); if(!empty($session_data)){ $get_hostel_fees=$this->hm->get_hostel_fees(array('fees_hostel_id'=>$hostel_id,'fees_session_id'=>$session_id)); $hostel_admission_fees=$this->hm->get_hostel_admission_fees(array('admission_hostel_id'=>$hostel_id)); if(!empty($get_hostel_fees)){ if(!empty($hostel_admission_fees)){ $session_start_year=$session_data->session_start_year; $session_end_year=$session_data->session_end_year; foreach ($year_value as $yk => $yv) { foreach ($students as $key => $value) { $unique_order_id=generate_string(4); if(!empty($yv) && isset($year_date_value[$yv]['start_date'])){ $year_date=$year_date_value[$yv]['start_date']; $start_year=date('Y',strtotime($year_date)); $start_month=date('m',strtotime($year_date)); echo 'start_year:'.$start_year.'/start_month:'.$start_month.'<br>'; } $admission_fees_data[]=array( 'assign_hostel_admission_fees_id'=>$hostel_admission_fees->admission_fees_id, 'assign_stu_id'=>$value, 'assign_hostel_id'=>$hostel_id, 'assign_hostel_inst_id'=>$inst_id, 'assign_course_id'=>$course_id, 'assign_sess_id'=>$session_id, 'assign_fees_paid'=>'no', 'assign_unique_payid'=>$unique_order_id ); if(!empty($admission_fees_data)){ $admission_fees_added=$this->hm->store_hostel_admission_fees_assign_data($admission_fees_data,TRUE); if($admission_fees_added){ $this->um->update_students(array('stu_avail_hostel'=>'yes','stu_avail_hostel_id'=>$hostel_id),array('stu_user_id'=>$student_id)); }else{ $return['error']='Hostel rental fees can not be set now.Please try later.'; } }else{ $return['error']='Hostel rental fees can not be set now.Please try later.'; } } } }else{ $return['error']='Hostel admission fees settings not found in the system.Please set that first.'; } }else{ $return['error']='Hostel resntal fees settings not found in the system.Please set that settings first.'; } }else{ $return['error']='Session data not found in the system.'; } }else{ $return['error']='Select students'; } }else{ $return['error']='Data manipulation is not allowed'; } json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onAssignStudents_old(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $hostel_id=post_data('hostel_id'); $student_ids=$this->input->post('students_to_assign'); $session=post_data('session_id'); $year_values=$this->input->post('year_value'); $session_id=decode_data($session); //$hostel_fees=$this->input->post('hostel_fees'); //$hostel_fees_session_id=$this->input->post('hostel_fees_session'); //$hostel_fees_course_id=$this->input->post('hostel_fees_course'); //$include_fees=$this->input->post('include_fees'); //print_obj($hostel_fees);die; $months=array('january'=>'01','february'=>'02','march'=>'03','april'=>'04','may'=>'05','june'=>'06','july'=>'07','august'=>'08','september'=>'09','october'=>'10','november'=>'11','december'=>'12'); $session_data=$this->sessm->get_session(array('session_id'=>$session_id)); $hostel_id=decode_data($hostel_id); $hostel_data=$this->hm->get_hostel(array('hostel_inst_id'=>$this->data['userdata']->user_id,'hostel_id'=>$hostel_id)); // print_obj($fees_data);die; if(!empty($hostel_data)){ if(!empty($year_values)){ $get_hostel_fees=$this->hm->get_hostel_fees(array('fees_hostel_id'=>$hostel_id,'fees_session_id'=>$session_id)); if(!empty($student_ids)){ foreach ($student_ids as $key => $value) { $this->um->update_students(array('stu_avail_hostel'=>'yes','stu_avail_hostel_id'=>$hostel_id),array('stu_user_id'=>$value)); foreach ($year_values as $ykey => $yvalue) { $session_year=$yvalue; $hostel_assigned_data=array( 'assigned_hostel_id'=>$hostel_id, 'assigned_stu_id'=>$value, 'assigned_inst_id'=>$hostel_data->hostel_inst_id, 'assigned_sess_id'=>$session_id, 'assigned_sess_year'=>$session_year, ); $get_hostel_assign_data=$this->hm->get_hostel_assign_data($hostel_assigned_data); if(!empty($get_hostel_assign_data)){ $this->hm->update_hostel_assign_data($hostel_assigned_data,$hostel_assigned_data); }else{ $this->hm->store_hostel_assign_data($hostel_assigned_data); } $get_hostel_fees_payment=$this->fm->get_hostel_fees_payment(array('payment_hostel_id'=>$hostel_id, 'payment_hostel_inst_id'=>$hostel_data->hostel_inst_id, 'payment_hostel_sess_id'=>$session_id, 'payment_hostel_stu_id'=>$value, 'payment_year'=>$session_year)); if(empty($get_hostel_fees_payment)){ foreach ($months as $mkey => $mvalue) { if($get_hostel_fees->fees_due_date>9){ $due_at=$session_year.'-'.$mvalue.'-'.$get_hostel_fees->fees_due_date; }else{ $due_at=$session_year.'-'.$mvalue.'-0'.$get_hostel_fees->fees_due_date; } $payment_hostel[]=array( 'payment_hostel_id'=>$hostel_id, 'payment_hostel_inst_id'=>$hostel_data->hostel_inst_id, 'payment_hostel_sess_id'=>$session_id, 'payment_hostel_course_id'=>null, 'payment_hostel_stu_id'=>$value, 'payment_year'=>$session_year, 'payment_month'=>$mkey, 'payment_value'=>$get_hostel_fees->fees_value, 'payment_late_value'=>$get_hostel_fees->fees_late_value, 'payment_status'=>'not paid', 'due_at'=>$due_at, 'created_at'=>date('Y-m-d') ); } $this->fm->store_hostel_fees_payment($payment_hostel,TRUE); } } // $hostel_admission_fees=array( // 'assign_hostel_admission_fees_id'=>, // 'assign_stu_id'=>, // 'assign_hostel_id'=>, // 'assign_hostel_inst_id'=>, // 'assign_course_id'=>, // 'assign_sess_id'=>, // 'assign_fees_paid' // ); // $fees_data=array( // 'payment_hostel_id'=>$hostel_id, // 'payment_hostel_inst_id'=>$hostel_data->hostel_inst_id, // 'payment_hostel_sess_id'=>$session, // 'payment_hostel_course_id'=>$hostel_fees_course_id, // 'payment_hostel_stu_id'=>$value, // 'payment_year'=>$session_year, // 'payment_month'=>null, // 'payment_value'=>$_v['fees_value'], // 'payment_late_value'=>$_v['fees_late_value'], // 'due_at'=>date('Y-m-d',strtotime($_v['fees_due_at'])), // 'created_at'=>date('Y-m-d'), // 'payment_status'=>'not paid', // 'payment_penalty'=>NULL // ); // $institute_hostel_admission_fees_assigned=array( // 'assign_hostel_admission_fees_id'=>'', // 'assign_stu_id'=>$value, // 'assign_hostel_id'=>$hostel_id, // 'assign_hostel_inst_id'=>$this->data['userdata']->user_id, // 'assign_course_id'=>'', // '' // ); // $data_toupdate=array( // 'admission_avail_hostel'=>'yes', // 'admission_hostel_id'=>$hostel_id // ); // $assigned=$this->adm->update_admission_data($data_toupdate,array('admission_stu_id'=>$value)); // if($include_fees=='1'){ // $param=array('payment_hostel_id'=>$hostel_id, // 'payment_hostel_stu_id'=>$value); // $found=$this->fm->get_hostel_fees_payment($param); // if(!empty($found)){ // $this->fm->delete_hostel_fees_payment($param); // } // foreach ($hostel_fees as $k => $v) { // foreach ($v as $_k => $_v) { // $fees_data=array( // 'payment_hostel_id'=>$hostel_id, // 'payment_hostel_inst_id'=>$hostel_data->hostel_inst_id, // 'payment_hostel_sess_id'=>$hostel_fees_session_id, // 'payment_hostel_course_id'=>$hostel_fees_course_id, // 'payment_hostel_stu_id'=>$value, // 'payment_year'=>$k, // 'payment_month'=>strtolower($_k), // 'payment_value'=>$_v['fees_value'], // 'payment_late_value'=>$_v['fees_late_value'], // 'due_at'=>date('Y-m-d',strtotime($_v['fees_due_at'])), // 'created_at'=>date('Y-m-d'), // 'payment_status'=>'not paid', // 'payment_penalty'=>NULL // ); // $this->fm->store_hostel_fees_payment($fees_data); // } // } // } } // die; $return['success']='Students assigned to '.$hostel_data->hostel_name; }else{ $return['error']='No students selected to assign'; } }else{ $return['error']='Select Academic Year'; } }else{ $return['error']='Hostel data not found'; } json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onGetAssignedStudents(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $hostel_id=post_data('hostel_id'); $session_id=post_data('session_id'); $course_id=post_data('course_id'); $months=array('january'=>'01','february'=>'02','march'=>'03','april'=>'04','may'=>'05','june'=>'06','july'=>'07','august'=>'08','september'=>'09','october'=>'10','november'=>'11','december'=>'12'); $this->data['months']=$months; if(!empty($hostel_id) && !empty($course_id) && !empty($session_id)){ $hostel_id=decode_data($hostel_id); $course_id=decode_data($course_id); $session_id=decode_data($session_id); $this->data['session_data']=$this->sessm->get_session(array('session_id'=>$session_id)); $this->data['hostel_id']=$hostel_id; $this->data['course_id']=$course_id; $this->data['session_id']=$session_id; $hostel_rents_data=$this->hm->get_hostel_fees(array('fees_hostel_id'=>$hostel_id,'fees_session_id'=>$session_id,'fees_course_id'=>$course_id)); if(!empty($hostel_rents_data)){ $hostel_rents=$hostel_rents_data->fees_value; }else{ $hostel_rents=0; } $_students=$this->adm->get_admission_data(array('stu_inst_id'=>$this->data['userdata']->user_id,'admission_course_id'=>$course_id,'admission_sess_id'=>$session_id),FALSE); $students=array(); for ($i=1; $i <=28 ; $i++) { $months_schedule[$i]=ordinal($i).' of each month'; } $this->data['months_schedule']=$months_schedule; if(!empty($_students)){ foreach ($_students as $key => $value) { $get_hostel_fees_payment_data=$this->fm->get_hostel_fees_payment(array('payment_hostel_id'=>$hostel_id,'payment_hostel_inst_id'=>$value->admission_inst_id,'payment_hostel_sess_id'=>$session_id,'payment_hostel_course_id'=>$course_id,'payment_hostel_stu_id'=>$value->admission_stu_id,'payment_status'=>'paid')); $assigned_fees_data=$this->hm->get_hostel_assign_data(array('assigned_hostel_id'=>$hostel_id,'assigned_stu_id'=>$value->admission_stu_id,'assigned_inst_id'=>$value->admission_inst_id,'assigned_sess_id'=>$value->admission_sess_id,'assigned_course_id'=>$value->admission_course_id)); $param=array('payment_hostel_id'=>$hostel_id, 'payment_hostel_inst_id'=>$value->admission_inst_id, 'payment_hostel_sess_id'=>$value->admission_sess_id, 'payment_hostel_course_id'=>$value->admission_course_id, 'payment_hostel_stu_id'=>$value->stu_user_id); //print_obj($param);die; $student_hostel_data=$this->fm->get_hostel_fees_payment($param); $students[]=array( 'student_id'=>$value->admission_stu_id, 'student_name'=>$value->stu_first_name.' '.$value->stu_mid_name.' '.$value->stu_last_name, 'selected'=>($value->stu_avail_hostel=='yes' && $value->stu_avail_hostel_id==$hostel_id)?'checked':'', 'student_hostel_rents'=>(!empty($assigned_fees_data))?$assigned_fees_data->assigned_fees:$hostel_rents, 'student_billing_cycle'=>(!empty($assigned_fees_data))?$assigned_fees_data->assigned_billing_cycle:null, 'student_already_paid'=>(!empty($get_hostel_fees_payment_data))?'yes':'no' ); } //print_obj($students);die; $this->data['students']=$students; $return['html']=$this->theme->view('_pages/master/vw_hostels_fees_assigned', $this->data,true); }else{ $return['error']='No students found in the system.'; } }else{ $return['error']='Sudents can not be assigned'; } json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onGetAssignedStudents_backup(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $hostel_id=post_data('hostel_id'); $this->data['year_value_start']=post_data('year_value_start'); $this->data['year_value_end']=post_data('year_value_end'); $course_id=post_data('course_id'); $session_id=post_data('session_id'); $fees_id=post_data('fees_id'); $months=get_months(); //print_obj($months);die; if(!empty($hostel_id)){ $hostel_id=decode_data($hostel_id); $course_id=decode_data($course_id); $session_id=decode_data($session_id); $fees_id=decode_data($fees_id); $selected_year=(!empty($year))?$year:date('Y'); $this->data['hostel_fees_data']=$this->hm->get_hostel_fees(array('fees_id'=>$fees_id,'fees_hostel_id'=>$hostel_id)); // $hostel_fees=$this->hm->__get_hostel_fees(array('fees_hostel_id'=>$hostel_id)); // $this->data['hostel_fees']=$hostel_fees; // //print_obj($hostel_fees);die; // if(!empty($hostel_fees)){ // $fees_value=$hostel_fees->fees_value; // $fees_late_value=$hostel_fees->fees_late_value; // }else{ // $fees_value=0; // $fees_late_value=0; // } // $session_start=$hostel_fees->session_start_year; // $session_end=$hostel_fees->session_end_year; // for ($i=$session_start; $i <=$session_end; $i++) { // $years[]=$i; // } // $this->data['years']=$years; // foreach ($years as $yk => $yv) { // foreach ($months as $key => $value) { // $_days=days_in_month($key,$yv); // $fees_payment_data=$this->fm->get_hostel_fees_payment(array('payment_hostel_id'=>$hostel_id,'payment_hostel_inst_id'=>$hostel_fees->fees_inst_id,'payment_hostel_sess_id'=>$hostel_fees->fees_session_id,'payment_hostel_course_id'=>$hostel_fees->fees_course_id,'payment_year'=>$yv,'payment_month'=>$value),TRUE,'payment_year,payment_month'); // //print_obj($fees_payment_data); // for ($i=1; $i <=$_days ; $i++) { // if($i>9){ // $iday=$i; // }else{ // $iday='0'.$i; // } // if($key>9){ // $kmonth=$key; // }else{ // $kmonth='0'.$key; // } // $days_months=$iday.'-'.$kmonth.'-'.$yv; // $days[$key][$yk][]=array( // 'days'=>$days_months, // 'selected'=>(!empty($fees_payment_data) && (date('d-m-Y',strtotime($fees_payment_data->due_at))==$days_months))?'selected':'' // ); // } // //print_obj($days[$key][$yk]); // if(!empty($fees_payment_data)){ // $fees_value=$fees_payment_data->payment_value; // $fees_late_value=$fees_payment_data->payment_late_value; // }else{ // $fees_value=$fees_value; // $fees_late_value=$fees_late_value; // } // $months_array[$yv][$value]=array('fees_value'=>$fees_value,'fees_late_value'=>$fees_late_value,'days'=>$days[$key][$yk]); // } // } //die; //print_obj($months_array);die; //$this->data['hostel_fees_data']=$months_array; //$_students=$this->um->get_students(array('stu_inst_id'=>$this->data['userdata']->user_id,'stu_user_id!='=>null,''),FALSE); $_students=$this->adm->get_admission_data(array('stu_inst_id'=>$this->data['userdata']->user_id,'admission_course_id'=>$course_id,'admission_sess_id'=>$session_id),FALSE); //print_obj($_students);die; $students=array(); if(!empty($_students)){ foreach ($_students as $key => $value) { $param=array('payment_hostel_id'=>$hostel_id, 'payment_hostel_inst_id'=>$value->admission_inst_id, 'payment_hostel_sess_id'=>$value->admission_sess_id, 'payment_hostel_course_id'=>$value->admission_course_id, 'payment_hostel_stu_id'=>$value->stu_user_id); //print_obj($param);die; $student_hostel_data=$this->fm->get_hostel_fees_payment($param); $students[]=array( 'student_id'=>$value->admission_stu_id, 'student_name'=>$value->stu_first_name.' '.$value->stu_mid_name.' '.$value->stu_last_name, 'selected'=>($value->stu_avail_hostel=='yes' && $value->stu_avail_hostel_id==$hostel_id)?'checked':'' ); } $this->data['students']=$students; $return['html']=$this->theme->view('_pages/master/vw_hostels_fees_assigned', $this->data,true); }else{ $return['error']='No students found in the system.'; } json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onAssignStudentsToAdmission(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $check_institute=check_institute($this->data['userdata']); $inst_id=$check_institute['institute_id']; $hostel_id=post_data('hostel_id'); $course_id=post_data('course_id'); $session_id=post_data('session_id'); $student_id=post_data('student_id'); $rent_start_month='03';//post_data('rent_start_month'); $months=array('january'=>'01','february'=>'02','march'=>'03','april'=>'04','may'=>'05','june'=>'06','july'=>'07','august'=>'08','september'=>'09','october'=>'10','november'=>'11','december'=>'12'); $session_data=$this->sessm->get_session(array('session_id'=>$session_id)); if(!empty($student_id)){ $student_ids=explode(',', $student_id); $get_hostel_fees=$this->hm->get_hostel_fees(array('fees_hostel_id'=>$hostel_id,'fees_session_id'=>$session_id)); $hostel_admission_fees=$this->hm->get_hostel_admission_fees(array('admission_hostel_id'=>$hostel_id)); if(!empty($hostel_admission_fees)){ $session_start_year=$session_data->session_start_year; $session_end_year=$session_data->session_end_year; foreach ($student_ids as $key => $value) { $unique_order_id=generate_string(4); $admission_fees_data=array( 'assign_hostel_admission_fees_id'=>$hostel_admission_fees->admission_fees_id, 'assign_stu_id'=>$value, 'assign_hostel_id'=>$hostel_id, 'assign_hostel_inst_id'=>$inst_id, 'assign_course_id'=>$course_id, 'assign_sess_id'=>$session_id, 'assign_fees_paid'=>'no', 'assign_unique_payid'=>$unique_order_id ); $admission_fees_added=$this->hm->store_hostel_admission_fees_assign_data($admission_fees_data); if($admission_fees_added){ $this->um->update_students(array('stu_avail_hostel'=>'yes','stu_avail_hostel_id'=>$hostel_id),array('stu_user_id'=>$value)); $year_starts=0; for ($i=$session_start_year; $i <=$session_end_year ; $i++) { $hostel_assigned_data=array( 'assigned_hostel_id'=>$hostel_id, 'assigned_stu_id'=>$value, 'assigned_inst_id'=>$inst_id, 'assigned_sess_id'=>$session_id, 'assigned_course_id'=>$course_id, 'assigned_sess_year'=>$i ); $get_hostel_assign_data=$this->hm->get_hostel_assign_data(array('assigned_hostel_id'=>$hostel_id,'assigned_stu_id'=>$value,'assigned_inst_id'=>$inst_id,'assigned_sess_id'=>$session_id)); if(!empty($get_hostel_assign_data)){ $this->hm->update_hostel_assign_data($hostel_assigned_data,array('assigned_hostel_id'=>$hostel_id,'assigned_stu_id'=>$value,'assigned_inst_id'=>$inst_id,'assigned_sess_id'=>$session_id)); }else{ $this->hm->store_hostel_assign_data($hostel_assigned_data); } $get_hostel_fees_payment=$this->fm->get_hostel_fees_payment(array('payment_hostel_id'=>$hostel_id,'payment_hostel_inst_id'=>$inst_id,'payment_hostel_sess_id'=>$session_id,'payment_hostel_stu_id'=>$student_id,'payment_year'=>$i)); foreach ($months as $mkey => $mvalue) { if($get_hostel_fees->fees_due_date>9){ $due_at=$i.'-'.$mvalue.'-'.$get_hostel_fees->fees_due_date; }else{ $due_at=$i.'-'.$mvalue.'-0'.$get_hostel_fees->fees_due_date; } $payment_unique_code=generate_string(4); if($year_starts==0){ if((int)$mvalue<=$rent_start_month){ $payment_status='to_be_deleted'; }else{ $payment_status='not paid'; } }else{ $payment_status='not paid'; } $payment_hostel=array( 'payment_hostel_id'=>$hostel_id, 'payment_hostel_inst_id'=>$inst_id, 'payment_hostel_sess_id'=>$session_id, 'payment_hostel_course_id'=>$course_id, 'payment_hostel_stu_id'=>$student_id, 'payment_unique_code'=>$payment_unique_code, 'payment_year'=>$i, 'payment_month'=>$mkey, 'payment_value'=>$get_hostel_fees->fees_value, 'payment_late_value'=>$get_hostel_fees->fees_late_value, 'payment_status'=>$payment_status, 'due_at'=>$due_at, 'created_at'=>date('Y-m-d') ); $get_hostel_fees_payment=$this->fm->get_hostel_fees_payment(array('payment_hostel_id'=>$hostel_id, 'payment_hostel_inst_id'=>$inst_id, 'payment_hostel_sess_id'=>$session_id, 'payment_hostel_course_id'=>$course_id, 'payment_hostel_stu_id'=>$student_id, 'payment_year'=>$i, 'payment_month'=>$mkey)); if(empty($get_hostel_fees_payment)){ $this->fm->store_hostel_fees_payment($payment_hostel); } } $year_starts++; } } } $return['success']='Student hostel admission data added'; }else{ $return['error']='Hostel admission fees data not found in the system.Please add them first.'; } }else{ $return['error']='Please select student.'; } json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onGetAssigneeStudents(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $inst_id=$this->inst_id; $hostel_id=post_data('hostel_id'); $course_id=post_data('course_id'); $session_id=post_data('session_id'); $_students=$this->adm->get_admission_data(array('stu_inst_id'=>$inst_id,'admission_course_id'=>$course_id,'admission_sess_id'=>$session_id),FALSE); $students=array(); if(!empty($_students)){ foreach ($_students as $key => $value) { $param=array('payment_hostel_id'=>$hostel_id,'payment_hostel_inst_id'=>$value->admission_inst_id,'payment_hostel_sess_id'=>$value->admission_sess_id,'payment_hostel_course_id'=>$value->admission_course_id,'payment_hostel_stu_id'=>$value->stu_user_id); //print_obj($param);die; $student_hostel_data=$this->fm->get_hostel_fees_payment($param); $students[]=array( 'student_id'=>$value->admission_stu_id, 'student_name'=>$value->stu_first_name.' '.$value->stu_mid_name.' '.$value->stu_last_name, 'selected'=>($value->stu_avail_hostel=='yes' && $value->stu_avail_hostel_id==$hostel_id)?'checked':'' ); } $this->data['students']=$students; }else{ $this->data['students']=$students; } $return['html']=$this->theme->view('_pages/master/vw_hostels_fees_assignee', $this->data,true); json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onGetHostelFees(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $hostel_id=post_data('hostel_id'); $student_id=post_data('student_id'); $session_id=post_data('session_id'); $course_id=post_data('course_id'); $year=post_data('session_year'); $session_id=decode_data($session_id); $course_id=decode_data($course_id); $hostel_id=decode_data($hostel_id); $student_id=decode_data($student_id); $months=get_months(); $hostel_fees=$this->hm->__get_hostel_fees(array('fees_hostel_id'=>$hostel_id,'fees_session_id'=>$session_id,'fees_course_id'=>$course_id)); $this->data['hostel_fees']=$hostel_fees; $months_array=array(); //print_obj($hostel_fees);die; if(!empty($hostel_fees)){ $fees_value=$hostel_fees->fees_value; $fees_late_value=$hostel_fees->fees_late_value; }else{ $fees_value=0; $fees_late_value=0; } foreach ($months as $key => $value) { $_days=days_in_month($key,$year); $fees_payment_data=$this->fm->get_hostel_fees_payment(array('payment_hostel_id'=>$hostel_id,'payment_hostel_inst_id'=>$hostel_fees->fees_inst_id,'payment_hostel_sess_id'=>$hostel_fees->fees_session_id,'payment_hostel_course_id'=>$hostel_fees->fees_course_id,'payment_year'=>$year,'payment_month'=>$value),TRUE,'payment_year,payment_month'); //print_obj($fees_payment_data); for ($i=1; $i <=$_days ; $i++) { if($i>9){ $iday=$i; }else{ $iday='0'.$i; } if($key>9){ $kmonth=$key; }else{ $kmonth='0'.$key; } $days_months=$iday.'-'.$kmonth.'-'.$year; $days[$key][]=array( 'days'=>$days_months, 'selected'=>(!empty($fees_payment_data) && (date('d-m-Y',strtotime($fees_payment_data->due_at))==$days_months))?'selected':'' ); } //print_obj($days[$key][$yk]); if(!empty($fees_payment_data)){ $fees_value=$fees_payment_data->payment_value; $fees_late_value=$fees_payment_data->payment_late_value; }else{ $fees_value=$fees_value; $fees_late_value=$fees_late_value; } $months_array[$year][$value]=array('fees_value'=>$fees_value,'fees_late_value'=>$fees_late_value,'days'=>$days[$key]); } $this->data['hostel_fees_data']=$months_array; $return['html']=$this->theme->view('_pages/master/vw_hostels_fees_set', $this->data,true); return json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onUpdateStudentHostelFees(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $hostel_fees=$this->input->post('hostel_fees'); $hostel_id=post_data('hostel_id'); $session_id=post_data('session_id'); $course_id=post_data('course_id'); $student_id=post_data('student_id'); $year=post_data('session_year'); if(!empty($hostel_fees)){ foreach ($hostel_fees as $key => $value) { $fees_data=array( 'payment_hostel_id'=>$hostel_id, 'payment_hostel_inst_id'=>$hostel_data->hostel_inst_id, 'payment_hostel_sess_id'=>$session_id, 'payment_hostel_course_id'=>$course_id, 'payment_hostel_stu_id'=>$student_id, 'payment_year'=>$k, 'payment_month'=>strtolower($_k), 'payment_value'=>$_v['fees_value'], 'payment_late_value'=>$_v['fees_late_value'], 'due_at'=>date('Y-m-d',strtotime($_v['fees_due_at'])), 'created_at'=>date('Y-m-d'), 'payment_status'=>'not paid', 'payment_penalty'=>NULL ); $this->fm->store_hostel_fees_payment($fees_data); } }else{ $return['error']=''; } return json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onGetCashpayment(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $userdata=$this->data['userdata']; $payment_id=post_data('payment_id'); if(!empty($payment_id)){ $payment_id=decode_data($payment_id); $hostel_fees=$this->fm->get_hostel_fees_payment(array('payment_id'=>$payment_id)); if(!empty($hostel_fees)){ $txn_id='TXN'.date('Ymd').$payment_id; $order_id='ORDHT'.date('Ymd').'_'.$hostel_fees->payment_year.'_'.$hostel_fees->payment_month.'_'.gen_code(2).'_'.$hostel_fees->payment_id; $date_now = new DateTime(); $due_date = new DateTime($hostel_fees->due_at); if($date_now>$due_date){ $penalty_applied='applied'; $total_due=$hostel_fees->payment_value+$hostel_fees->payment_late_value; }else if($date_now==$due_date){ $penalty_applied='not applied'; $total_due=$hostel_fees->payment_value; }else{ $penalty_applied='not applied'; $total_due=$hostel_fees->payment_value; } $updated=$this->fm->update_hostel_fees_payment(array('recieved_at'=>date('Y-m-d'),'payment_status'=>'paid','payment_penalty'=>$penalty_applied),array('payment_id'=>$hostel_fees->payment_id)); if($userdata->user_type=='institute_branch'){ $branch_data=$this->get_user(array('user_id'=>$userdata->user_id),'institute_branch'); $parent_inst_id=$branch_data->branch_parent_inst_id; }else{ $parent_inst_id=$userdata->user_id; } $payment_details=array( 'details_payment_platform'=>'cash', 'details_type'=>'hostel_fees_payment', 'details_payment_type'=>'hostel_fees', 'details_type_id'=>$hostel_fees->payment_hostel_id, 'details_inst_id'=>$hostel_fees->payment_hostel_inst_id, 'details_parent_inst_id'=>$parent_inst_id, 'details_sess_id'=>$hostel_fees->payment_hostel_sess_id, 'details_course_id'=>$hostel_fees->payment_hostel_course_id, 'details_sess_year'=>$hostel_fees->payment_year, 'details_installment_id'=>$hostel_fees->payment_id, 'details_txn_id'=>$txn_id, 'details_order_id'=>$order_id, 'details_amount'=>$total_due, 'details_discount_amount'=>'0', 'details_accounting_type'=>'income', 'details_created_by_type'=>$userdata->user_type, 'details_created_by'=>$userdata->user_id, 'details_created_at'=>date('Y-m-d') ); $saved=$this->fm->store_payment_details($payment_details); if($saved){ $return['success']='Payment has been recieved'; }else{ $return['error']='Payment can not be recieved now'; } }else{ $return['error']='Data not found'; } }else{ $return['error']='Data error'; } json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } //Hostel Admission public function indexHostelAdmission(){ if($this->data['userdata']->user_type=='student' || $this->data['userdata']->user_type=='agent' ){ redirect($this->data['base_url']); } if(session_userdata('isAdminLoggedin')){ $this->data['page_title']='Hostel Admission'; $this->data['hostels']=$this->hm->get_hostel(array('hostel_inst_id'=>$this->inst_id),FALSE); $this->data['active_sessions']=$this->sessm->get_session(array('session_inst_id'=>$this->inst_id,'session_status'=>'active'),FALSE); $this->data['students']=$this->um->get_students(array('stu_inst_id'=>$this->inst_id,'stu_user_id!='=>null),FALSE); $sessions=$this->sessm->get_session(array('session_inst_id'=>$this->inst_id),FALSE); $courses=$this->cm->get_course(array('course_inst_id'=>$this->inst_id),FALSE); $session_courses=$this->sessm->get_session_courses(array('session_inst_id'=>$this->inst_id),FALSE); $this->data['sessions']=$sessions; $this->data['courses']=$courses; $this->data['session_courses']=$session_courses; $this->theme->title($this->data['page_title'])->load('master/vw_hostels_admission', $this->data); }else{ redirect($this->data['base_url']); } } public function onSearchHostelAdmissions(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $param['column_order'] = array( null, 'hostel_name' ); $param['column_search'] = array('admission_fees_value','stu_first_name','stu-mid_name','stu-last_name','hostel_name','course_name','subject_name'); $param['order'] = array('assigned_id' => 'ASC'); $posts=$this->input->post(); $param['inst_id']=$this->data['userdata']->user_id; $list = $this->hm->_get_hostel_admission_fees_assign_data($posts,$param,FALSE,FALSE); //print_obj($list);die; $data = array(); $no = isset($posts['start'])?$posts['start']:0; $action=''; foreach ($list as $fees_data){ $no++; $row = array(); if($fees_data->stu_mid_name!=''){ $student_name=$fees_data->stu_first_name.' '.$fees_data->stu_mid_name.' '.$fees_data->stu_last_name; }else{ $student_name=$fees_data->stu_first_name.' '.$fees_data->stu_last_name; } $row[] = $no; $row[] = $fees_data->hostel_name; $row[] = $student_name; $row[] = $fees_data->stu_user_code; $row[] = number_format($fees_data->admission_fees_value,2); //$row[] = $hostelsFees->session_start_year ."-". $hostelsFees->session_end_year; //$row[] = $hostelsFees->year_value; $row[] = number_format($fees_data->admission_caution_fees_value,2); $row[] ='<button class="btn btn-xs btn-danger" type="button" data-admission_data_id=""><i class="fa fa-trash"></i></button>'; $data[] = $row; } $output = array( "draw" => isset($posts['draw'])?$posts['draw']:'', "recordsTotal" => $this->hm->_get_hostel_admission_fees_assign_data($posts,$param,TRUE), "recordsFiltered" => $this->hm->_get_hostel_admission_fees_assign_data($posts,$param,TRUE), "data" => $data, ); echo json_encode($output); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } }