BBnepal-Accounts/application/controllers/Admin.php

13571 lines
508 KiB
PHP
Raw Normal View History

2024-07-10 12:43:19 +00:00
<?php
defined('BASEPATH') or exit('No direct script access allowed');
use Nilambar\NepaliDate\NepaliDate;
require_once 'vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\IOFactory;
// use Nilambar\NepaliDate\NepaliDate;
require_once APPPATH . '/third_party/fpdf/fpdf.php';
// use PhpOffice\PhpSpreadsheet\IOFactory;
// require('vendor/autoload.php');
class Admin extends CI_Controller
{
private $nepaliDateObject;
private $nepali_current_date;
public function __construct()
{
parent::__construct();
$this->load->model('Admin_model');
$this->load->helper('url');
$this->load->library('email');
$this->load->helper('file');
$this->load->helper('common_helper');
$this->load->library('Ciqrcode');
date_default_timezone_set('Asia/Kathmandu');
$this->nepaliDateObject = new NepaliDate();
$this->nepali_current_date = cuurentNepaliDate($this->nepaliDateObject);
}
public function index()
{
if (!isset($_SESSION['admin_id'])) {
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$this->load->view('admin/header', $data);
$this->load->view('admin/login');
$this->load->view('admin/footer');
} else {
redirect(base_url() . 'Admin/dashboard');
}
}
public function admin_login()
{
$uname = $this->input->post('email');
$pwd = $this->input->post('password');
if ($this->Admin_model->login($uname, $pwd)) {
if (isset($_POST['remember_me']) && $_POST['remember_me'] == 'on') {
//set 0 instead of time to remove the cookie once the browser is closed
setcookie("username", $_POST["email"], time() + (20 * 365 * 24 * 60 * 60)); //86400 seconds in a day
setcookie("password", $_POST["password"], time() + (20 * 365 * 24 * 60 * 60));
setcookie("rem_me", 'On', time() + (20 * 365 * 24 * 60 * 60));
} else {
if (isset($_COOKIE['username'])) {
unset($_COOKIE['username']);
setcookie('username', '');
}
if (isset($_COOKIE['password'])) {
unset($_COOKIE['password']);
setcookie('password', '');
}
if (isset($_COOKIE['rem_me'])) {
unset($_COOKIE['rem_me']);
setcookie('rem_me', '');
}
}
$admin_info = $this->Admin_model->login($uname, $pwd);
//getting values from database
$admin_id = $admin_info->id;
$admin_role = $admin_info->role;
$admin_rights = $admin_info->rights;
$admin_email = $admin_info->email;
$admin_role_ids = $admin_info->admin_role_ids;
$admin_name = $admin_info->admin_name;
//create required sessions
$this->session->set_userdata('admin_id', $admin_id);
$this->session->set_userdata('admin_role', $admin_role);
$this->session->set_userdata('admin_rights', $admin_rights);
$this->session->set_userdata('admin_email', $admin_email);
$this->session->set_userdata('admin_role_ids', $admin_role_ids);
$this->session->set_userdata('admin_name', $admin_name);
echo '1';
} else {
echo '0';
}
}
public function admin_logout()
{
$this->session->sess_destroy();
redirect(base_url() . 'Admin', 'refresh');
}
public function dashboard()
{
if (isset($_SESSION['admin_id'])) {
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['subject_count'] = $this->db->count_all('subject');
$data['course_count'] = $this->db->count_all('course');
$data['classroom_count'] = $this->db->count_all('classroom');
$data['teacher_count'] = $this->db->count_all('teacher');
$data['student_count'] = $this->db->count_all('students');
$data['exam_count'] = 0;
$data['session_count'] = 0;
$data['application_count'] = $this->db->count_all('applications');
$data['notification_count'] = $this->db->count_all('notifications');
// report start by shivakumar
// $sqlQuery1 = "SELECT feetype_name,icon FROM fee_types WHERE is_active='yes'";
// $data['feestype_data'] = $this->Admin_model->get_query_result($sqlQuery1);
// $fee_type_data = array();
// $start_date = date('Y-m-01', strtotime($this->nepali_current_date));
// $current_date = date('Y-m-t', strtotime($this->nepali_current_date));
// $sqlQuery1 = "SELECT id as feetype_id,feetype_name,icon FROM fee_types WHERE is_active='yes'";
// $feetypelist = $this->Admin_model->get_query_result($sqlQuery1);
// if (isset($feetypelist) && !empty($feetypelist)) {
// foreach ($feetypelist as $ftype) {
// if ($ftype['feetype_id'] == 1) {
// $appication_totalamt = $this->Admin_model-> ($start_date, $current_date, $ftype['feetype_name'], 'student_fee_online_transactions');
// $fee_type_data[] = array(
// 'feetype_id' => $ftype['feetype_id'],
// 'feetype_name' => $ftype['feetype_name'],
// 'feetype_icon' => $ftype['icon'],
// 'feetype_total' => 0,
// 'feetype_due_amt' => 0,
// 'feetype_paid_amount' => (isset($appication_totalamt) && !empty($appication_totalamt)) ? $appication_totalamt : 0
// );
// } else {
// $result = $this->Admin_model->currentMonth_fee($start_date, $current_date, $ftype['feetype_id']);
// $fee_type_data[] = array(
// 'feetype_id' => $ftype['feetype_id'],
// 'feetype_name' => $ftype['feetype_name'],
// 'feetype_icon' => $ftype['icon'],
// 'feetype_total' => (isset($result['total_course_fee']) && !empty($result['total_course_fee'])) ? $result['total_course_fee'] : 0,
// 'feetype_due_amt' => (isset($result['pending_fee']) && !empty($result['pending_fee'])) ? $result['pending_fee'] : 0,
// 'feetype_paid_amount' => (isset($result['paid_amount']) && !empty($result['paid_amount'])) ? $result['paid_amount'] : 0
// );
// }
// }
// }
// $data['current_report_data'] = $fee_type_data;
$course_query = "SELECT * FROM course WHERE is_active='yes'";
$data['courses'] = $this->Admin_model->get_query_result($course_query);
// report end by shivakumar
$data['menulist'] = $this->Admin_model->get_adminMenu();
// dd($data['menulist']);
$this->load->view('admin/header', $data);
$this->load->view('admin/dashboard');
$this->load->view('admin/footer');
}
}
//subject start
public function subject()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$sqlquery = "SELECT * FROM subject ORDER BY id DESC";
$data['subjects'] = $this->Admin_model->get_query_result($sqlquery);
$this->load->view('admin/header', $data);
$this->load->view('admin/subject');
$this->load->view('admin/footer');
}
public function add_edit_subject($subjectId)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/ae_subject.php'))
show_404();
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['id'] = $subjectId;
if (count($_POST) > 0) {
$res = $this->Admin_model->add_edit_subject($subjectId, $_POST);
$this->session->set_flashdata('successsubject', str_replace('%s', 'new subject', THE_ADD_SUCCESS_MSG));
if ($subjectId > 0)
$this->session->set_flashdata('successsubject', str_replace('%s', 'subject', THE_UPDATE_SUCCESS_MSG));
redirect(base_url() . 'admin/subject');
}
$data['title'] = 'Add New Subject';
if ($subjectId > 0) {
$data['title'] = 'Update Subject';
$whereqry = array('id' => $subjectId);
$data['subject'] = $this->Admin_model->get_subject_details($whereqry);
}
$this->load->view('admin/header', $data);
$this->load->view('admin/ae_subject');
$this->load->view('admin/footer');
}
public function addupdate_subject($s_id = '')
{
if (isset($_POST['update_subject'])) {
$s_id = ($_POST['sid'] != 0) ? $_POST['sid'] : 0;
$s_name = $_POST['sname'];
$s_icon = $_POST['subicon'];
$subject_code = $_POST['subcode'];
$this->form_validation->set_rules('sname', 'Subject Name', 'required');
$this->form_validation->set_rules('subicon', 'Subject Icon', 'required');
if ($this->form_validation->run() == FALSE) {
redirect(base_url() . 'admin/add-edit-subject/' . $s_id, 'refresh');
} else {
if ($s_id == 0) {
$insertdata = $this->Admin_model->add_subject($s_name, $s_icon, $subject_code);
if ($insertdata == 1) {
$this->session->set_flashdata('successsubject', str_replace('%s', 'new subject', THE_ADD_SUCCESS_MSG));
} else {
$this->session->set_flashdata('errorsubject', str_replace('%s', 'subject', THE_INSERT_FAILED_MSG));
}
} else {
$is_active = $_POST['is_active'];
$updatedata = $this->Admin_model->update_subject($s_id, $s_name, $s_icon, $subject_code, $is_active);
if ($updatedata == 1) {
$this->session->set_flashdata('successsubject', str_replace('%s', 'subject', THE_UPDATE_SUCCESS_MSG));
} else {
$this->session->set_flashdata('errorsubject', str_replace('%s', 'subject', THE_UPDATE_FAILED_MSG));
}
}
redirect(base_url() . 'admin/subject/' . $s_id, 'refresh');
}
}
}
public function subject_deleted()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$sid = '';
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['subjects'] = $this->Admin_model->get_delsubjects();
$this->load->view('admin/header', $data);
$this->load->view('admin/subject-deleted');
$this->load->view('admin/footer');
}
public function course_deleted()
{
if (isset($_SESSION['admin_id'])) {
$sid = '';
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['course'] = $this->Admin_model->get_delcourse();
$this->load->view('admin/header', $data);
$this->load->view('admin/course-deleted');
$this->load->view('admin/footer');
}
}
public function installment_deleted()
{
if (isset($_SESSION['admin_id'])) {
$sid = '';
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['installment'] = $this->Admin_model->get_delinstall();
// print_r($data['installment']);
$this->load->view('admin/header', $data);
$this->load->view('admin/installment_delete');
$this->load->view('admin/footer');
}
}
public function delete_data()
{
$id = $_POST['id'];
$table = $_POST['table'];
$data = $this->Admin_model->delete_data($id, $table);
print_r($data);
}
public function delete_batch($batchId)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$batchId = ($batchId != '') ? $batchId : 0;
if ($batchId != 0) {
$result = $this->Admin_model->delete_batch($batchId);
if ($result == 'exists') {
$this->session->set_flashdata('danger', str_replace('%s', 'Batch', ALREADY_ASSIGNED_MSG));
} else if ($result == 'success') {
$this->session->set_flashdata('success', str_replace('%s', 'Batch', THE_DELETE_SUCCESS_MSG));
} else if ($result == 'failed') {
$this->session->set_flashdata('danger', str_replace('%s', 'Batch', THE_DELETE_ERROR_MSG));
}
} else {
$this->session->set_flashdata('danger', str_replace('%s', 'Batch', THE_DELETE_ERROR_MSG));
}
redirect(base_url() . 'admin/batches');
}
public function delete_classroom($del_id)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$clsroomId = (isset($del_id) && !empty($del_id)) ? $del_id : 0;
if ($clsroomId != 0) {
$result = $this->Admin_model->delete_classroom($clsroomId);
if ($result == 'exists')
$this->session->set_flashdata('error_msg', 'The Deleting classroom associated with
Online session or Students');
else
$this->session->set_flashdata('success_msg', str_replace('%s', 'classroom', THE_DELETE_SUCCESS_MSG));
} else {
$this->session->set_flashdata('error_msg', 'Classroom Not Found');
}
redirect(base_url() . "admin/classroom");
}
public function delete_data_permanent()
{
$id = $_POST['id'];
$table = $_POST['table'];
$data = $this->Admin_model->delete_data_permanent($id, $table);
print_r($data);
}
public function delete_classroom_permanent()
{
$id = $_POST['id'];
$table = $_POST['table'];
$data = $this->Admin_model->delete_classroom_permanent($id, $table);
print_r($data);
}
public function restore_data()
{
$id = $_POST['id'];
$table = $_POST['table'];
$data = $this->Admin_model->restore_data($id, $table);
print_r($data);
}
//subject end
//course start
public function addedit_course()
{
$c_id = $_POST['cid'];
$c_name = $_POST['cname'];
$c_sub = $_POST['csubject'];
$c_fee = $_POST['cfee'];
$a_fee = $_POST['afee'];
$csub = implode(',', $c_sub);
$data_array = array(
'subject_id' => $csub,
'course_name' => $c_name,
'course_fee' => $c_fee,
'application_fee' => $a_fee
);
$data = $this->Admin_model->addedit_course($c_id, $data_array);
print_r($data);
}
//course end
/**************************************** START of Batches - Nandini Hulsurkar ************************************/
public function cron_create_db_backup()
{
$res = $this->database_backup_common();
if (isset($res['successCnt']) && $res['successCnt'] == 4)
echo "The database backup has been created successfully.";
else
echo 'Oops.. Something went wrong in creatingt the database backup.';
exit;
}
public function database_backup_common()
{
$this->load->helper('file');
$nepaliDandT = $this->nepali_current_date;
$nepaliDandT = str_replace(' ', '_', $nepaliDandT);
$nepaliDandT = str_replace(':', '-', $nepaliDandT);
//$this->the_path = $_SERVER["DOCUMENT_ROOT"].'/black-board/';
$this->the_path = $_SERVER["DOCUMENT_ROOT"] . '/';
$theDBBDir = $this->the_path . 'database_backups';
if (!file_exists($theDBBDir)) {
mkdir($theDBBDir, 0777, true);
}
$dbArray = array();
$mainDBName = $this->db->database . '.sql';
array_push($dbArray, $mainDBName);
$libraryDBObj = $this->load->database('erisnClassroom_lms', TRUE);
$libraryDBName = $libraryDBObj->database . '.sql';
array_push($dbArray, $libraryDBName);
$hostelDBObj = $this->load->database('hms', TRUE);
$hostelDBName = $hostelDBObj->database . '.sql';
array_push($dbArray, $hostelDBName);
$busTrackingDBObj = $this->load->database('erisnClassroom_bts', TRUE);
$busTrackingDBName = $busTrackingDBObj->database . '.sql';
array_push($dbArray, $busTrackingDBName);
$successCnt = 0;
$errArray = array();
foreach ($dbArray as $key => $value) {
$this->load->dbutil();
$prefs = array(
'format' => 'zip',
'filename' => $value
);
$backup = $this->dbutil->backup($prefs);
$backupThisDB = $nepaliDandT . '.zip';
$save = $theDBBDir . '/' . $backupThisDB;
$res = write_file($save, $backup);
if ($res)
$successCnt++;
else
array_push($errArray, $value);
}
//echo $successCnt;
//echo '<pre>';print_r($errArray);
//echo '<pre>';print_r($dbArray);exit;
$theReturn['successCnt'] = $successCnt;
$theReturn['errArray'] = $errArray;
return $theReturn;
}
public function create_database_backup()
{
$res = $this->database_backup_common();
if (isset($res['successCnt']) && $res['successCnt'] == 4)
$this->session->set_flashdata('success', 'The database backup has been created successfully.');
else
$this->session->set_flashdata('danger', 'Oops.. Something went wrong in creatingt the database backup.');
redirect(base_url() . 'admin/db-backups');
}
public function delete_database_backup($fileName)
{
$theDBBDir = 'database_backups/' . $fileName;
if (file_exists($theDBBDir)) {
if (unlink($theDBBDir))
$this->session->set_flashdata('success', 'The database backup has been deleted successfully.');
else
$this->session->set_flashdata('danger', 'Oops.. Something went wrong in deleting the database backup.');
} else
$this->session->set_flashdata('danger', 'Oops.. The database backup file which you are trying to delete doesnot exist.');
redirect(base_url() . 'admin/db-backups');
}
public function database_backups()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'Admin');
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$dbBackupFiles = array();
$theDBBDir = 'database_backups';
if (file_exists($theDBBDir)) {
$dbBackupFiles = array_diff(scandir($theDBBDir, 1), array('..', '.'));
//echo '<pre>'; print_r($dbBackupFiles);exit;
}
$data['dbBackupFiles'] = $dbBackupFiles;
$this->load->view('admin/header', $data);
$this->load->view('admin/database-backups', $data);
$this->load->view('admin/footer');
}
public function batches()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'Admin');
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['batch'] = $this->Admin_model->get_batches();
$this->load->view('admin/header', $data);
$this->load->view('admin/batch');
$this->load->view('admin/footer');
}
public function ajaxCheckIsBatchNameAlreadyExists()
{
$result = 'Insufficient Data';
if (isset($_POST['batch_name']) && $_POST['batch_name'] != '' && isset($_POST['id']) && $_POST['id'] != '') {
$result = $this->Admin_model->check_batch_name_already_exists($_POST['id'], $_POST['batch_name']);
}
echo $result;
exit;
}
public function add_edit_batch($batchId)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'Admin');
$sql = "SELECT * FROM batch WHERE id = $batchId";
$batchDetails = $this->Admin_model->get_batches('', $sql);;
if (empty($batchDetails) && $batchId != 0)
redirect('admin/batches');
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['bid'] = $batchId;
$data['title'] = 'Add New Batch';
if ($batchId > 0) {
$data['title'] = 'Update Batch';
$data['batchDetails'] = $batchDetails;
}
if (count($_POST) > 0) {
//echo '<pre>'; print_r($_POST);exit;
$res = $this->Admin_model->add_edit_batch($batchId, $_POST);
$this->session->set_flashdata('success', str_replace('%s', 'new batch', THE_ADD_SUCCESS_MSG));
if ($batchId > 0)
$this->session->set_flashdata('success', str_replace('%s', 'batch', THE_UPDATE_SUCCESS_MSG));
redirect(base_url() . 'admin/batches');
}
$this->load->view('admin/header', $data);
$this->load->view('admin/add-edit-batch');
$this->load->view('admin/footer');
}
/**************************************** END of Batches - Nandini Madam************************************/
//classroom start
public function classroom()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/classroom.php'))
show_404();
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$query = "SELECT cl.*,c.course_name,s.section_name FROM classroom cl LEFT JOIN course c ON cl.course_id =c.id LEFT JOIN section s ON cl.section_id=s.id ORDER BY cl.id ASC";
$data['classroomlist'] = $this->Admin_model->get_query_result($query);
$data['title'] = "Classroom List";
$this->load->view('admin/header', $data);
$this->load->view('admin/classroom');
$this->load->view('admin/footer');
}
public function add_edit_classroom($classroomId)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/ae_classroom.php'))
show_404();
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['courselist'] = $this->Admin_model->get_general_result_details('course', 'DESC', array('is_active' => 'yes'));
$data['id'] = $classroomId;
if ($classroomId > 0) {
$data['title'] = "Update Classroom ";
$data['classroom'] = $this->Admin_model->get_general_row_details('classroom', 'ASC', array('id' => $classroomId));
$sqlQuery = "SELECT cl.*,cs.subject_id as course_subject_ids,cts.teacher_id, cts.is_class_teacher FROM classroom cl JOIN course_subjects cs ON cl.course_id=cs.course_id LEFT JOIN classroom_teacher_subject cts ON cs.subject_id=cts.subject_id AND cl.id=cts.classroom_id WHERE cl.id='$classroomId'";
// $sqlQuery = "SELECT cl.*,cs.subject_id as course_subject_ids FROM classroom cl JOIN
// course_subjects cs ON cl.course_id=cs.course_id WHERE cl.id='$classroomId' AND cs.subject_id NOT IN (Select subject_id as subid from classroom_teacher_subject WHERE classroom_id = $classroomId)";
$data['course_subjects'] = $this->Admin_model->get_query_result($sqlQuery);
// dd($data['course_subjects']);
$data['subjects_teacher'] = $this->Admin_model->get_general_result_details('classroom_teacher_subject', 'ASC', array('classroom_id' => $classroomId));
// $sqlQuery = "SELECT cs.subject_id,cts.teacher_id FROM `classroom` cl LEFT JOIN classroom_teacher_subject cts on cts.classroom_id=cl.id LEFT JOIN course_subjects cs ON cl.course_id=cs.id WHERE cts.classroom_id=$classroomId";
// $data['subjects_teacher'] = $this->Admin_model->get_query_result($sqlQuery);
// echo "<pre>";
// print_r($data['course_subjects']);
// die();
$section_query = "SELECT cl.id ,cs.section_id as sectionId,s.section_name FROM classroom cl LEFT JOIN course_sections cs ON cs.course_id=cl.course_id LEFT JOIN section s ON s.id = cs.section_id WHERE s.is_active='yes' AND cl.id=$classroomId";
$data['sectionlist'] = $this->Admin_model->get_query_result($section_query);
} else {
$data['title'] = " Add Classroom ";
}
if (count($_POST) > 0) {
// echo "<pre>";
// print_r($_POST);
// exit;
if ($classroomId == 0) {
$check_exists = $this->Admin_model->get_general_result_details('classroom', 'ASC', array('course_id' => $_POST['course_id'], 'section_id' => $_POST['section_id']));
if (count($check_exists) > 0) {
$this->session->set_flashdata('error_msg', str_replace('%s', 'Course and Section', THE_EXISTS_ERROR_MSG));
redirect(base_url() . 'Admin/classroom');
} else {
$rst = $this->Admin_model->add_update_classroom($classroomId, $_POST);
if ($rst === 1)
$this->session->set_flashdata('success_msg', str_replace('%s', 'new classroom', THE_ADD_SUCCESS_MSG));
else if ($rst === 2)
$this->session->set_flashdata('success_msg', str_replace('%s', 'classroom', THE_UPDATE_SUCCESS_MSG));
else
$this->session->set_flashdata('error_msg', str_replace('%s', 'new classroom', THE_ADD_ERROR_MSG));
redirect(base_url() . 'Admin/classroom');
}
} else {
$rst = $this->Admin_model->add_update_classroom($classroomId, $_POST);
if ($rst === 1)
$this->session->set_flashdata('success_msg', str_replace('%s', 'new classroom', THE_ADD_SUCCESS_MSG));
else if ($rst === 2)
$this->session->set_flashdata('success_msg', str_replace('%s', 'classroom', THE_UPDATE_SUCCESS_MSG));
else if ($rst === 3)
$this->session->set_flashdata('error_msg', str_replace('%s', 'classroom', THE_UPDATE_NO_CHANGES_MSG));
else
$this->session->set_flashdata('error_msg', str_replace('%s', 'new classroom', THE_ADD_ERROR_MSG));
redirect(base_url() . 'Admin/classroom');
}
}
$this->load->view('admin/header', $data);
$this->load->view('admin/ae_classroom');
$this->load->view('admin/footer');
}
public function get_courseSubject()
{
$cid = $_POST['cur_id'];
$tid = '';
$data['subname'] = $this->Admin_model->get_coursesubject($cid);
$data['teacher'] = $this->Admin_model->get_teacher($tid);
echo json_encode($data);
}
public function addedit_classroom()
{
$cr_id = $_POST['crid'];
$cr_name = $_POST['crname'];
$cr_batch_from = $_POST['crbatch_from'];
$cr_batch_to = $_POST['crbatch_to'];
$cr_course = $_POST['crcourse'];
$cr_subject = $_POST['crsubject'];
$cr_teacher = $_POST['crteacher'];
$data = $this->Admin_model->addedit_classroom($cr_id, $cr_name, $cr_batch_from, $cr_batch_to, $cr_course, $cr_subject, $cr_teacher);
print_r($data);
}
public function classroom_deleted()
{
if (isset($_SESSION['admin_id'])) {
$crid = '';
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['classroom'] = $this->Admin_model->get_delclassroom($crid);
$classroom = $data['classroom'];
$prev = "";
$cur = "";
$subject = '';
$classroom_details = array();
$k = 0;
for ($i = 0; $i < count($classroom); $i++) {
if ($prev == '' && $cur == '') {
$prev = $classroom[$i]['classroom_name'];
$cur = $classroom[$i]['classroom_name'];
$final_details[$k]['classroom_name'] = $classroom[$i]['classroom_name'];
$data_teacher = $this->Admin_model->get_teacher($classroom[$i]['teacher_id']);
$data_course = $this->Admin_model->get_course($classroom[$i]['course_id']);
$final_details[$k]['course_id'] = $classroom[$i]['course_id'];
$final_details[$k]['id'] = $classroom[$i]['id'];
$final_details[$k]['course_name'] = $data_course['course_name'];
$subject = '';
$teacher = '';
$k++;
} else {
$cur = $classroom[$i]['classroom_name'];
}
if ($cur != $prev) {
//echo $payment_installment;
$lastk = $k - 1;
if ($i == count($classroom) - 1) {
//$installment_details[$lastk]['payment'] = $payment;
$data_subject = $this->Admin_model->get_subjects($classroom[$i]['subject_id']);
$data_teacher = $this->Admin_model->get_teacher($classroom[$i]['teacher_id']);
if ($data_subject['subject_name'] != '' && $data_teacher['teacher_name'] != '') {
$final_details[$k]['subject'] = $data_subject['subject_name'];
$final_details[$k]['teacher'] = $data_teacher['subject_name'];
}
} else {
$final_details[$lastk]['subject'] = $subject;
$final_details[$lastk]['teacher'] = $teacher;
}
$final_details[$lastk]['subject'] = $subject;
$final_details[$lastk]['teacher'] = $teacher;
$final_details[$k]['classroom_name'] = $cur;
$final_details[$k]['course_id'] = $classroom[$i]['course_id'];
$final_details[$k]['id'] = $classroom[$i]['id'];
$data_subject = $this->Admin_model->get_subjects($classroom[$i]['subject_id']);
$data_course = $this->Admin_model->get_course($classroom[$i]['course_id']);
$data_teacher = $this->Admin_model->get_teacher($classroom[$i]['teacher_id']);
$final_details[$k]['course_name'] = $data_course['course_name'];
if (isset($data_subject['subject_name']) && isset($data_teacher['teacher_name'])) {
$subject = $data_subject['subject_name'];
$teacher = $data_teacher['teacher_name'];
}
$k++;
} else {
if ($i == count($classroom) - 1) {
$lastk = $k - 1;
$data_subject = $this->Admin_model->get_subjects($classroom[$i]['subject_id']);
$data_teacher = $this->Admin_model->get_teacher($classroom[$i]['teacher_id']);
if ($data_subject['subject_name'] != '' && $data_teacher['teacher_name'] != '') {
$subject .= '<br>' . $data_subject['subject_name'];
$teacher .= '<br>' . $data_teacher['teacher_name'];
}
$final_details[$lastk]['subject'] = $subject;
$final_details[$lastk]['teacher'] = $teacher;
} else {
$cur = $classroom[$i]['classroom_name'];
// $payment .= '<br>'.$installment[$i]['payment_installment'].'-'.$installment[$i]['payable_amount'];
$data_subject = $this->Admin_model->get_subjects($classroom[$i]['subject_id']);
$data_teacher = $this->Admin_model->get_teacher($classroom[$i]['teacher_id']);
if (isset($data_subject['subject_name']) && isset($data_teacher['teacher_name'])) {
$subject .= '<br>' . $data_subject['subject_name'];
$teacher .= '<br>' . $data_teacher['teacher_name'];
}
}
}
$prev = $cur;
}
/*
echo "<pre>";
print_r($final_details);
*/
$data['final_details'] = $final_details;
$this->load->view('admin/header', $data);
$this->load->view('admin/classroom-deleted');
$this->load->view('admin/footer');
}
}
//classroom end
//teacher start
public function teacher($id = '')
{
if (isset($_SESSION['admin_id'])) {
if ($id == 1) {
$this->session->set_flashdata('success_msg', str_replace('%s', 'Teacher', THE_DELETE_SUCCESS_MSG));
}
$tid = '';
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$teachers = $this->Admin_model->get_teacher($tid);
foreach ($teachers as $key => $value) {
$filePath = 'assets_admin/images/teacher-profile/' . $value['photo'];
if (file_exists($filePath)) {
$teachers[$key]['profile_pic'] = base_url() . 'assets_admin/images/teacher-profile/' . $value['photo'];
} else {
$teachers[$key]['profile_pic'] = base_url() . 'common_assets/No-Image.jpg';
}
}
$data['teacher'] = $teachers;
$hr_db = $this->load->database('hr', TRUE);
$hr_roles = $hr_db->query("SELECT * from staff_roles where is_active = 'yes'")->result_array();
$hr_designation = $hr_db->query("SELECT * from hr_designation where is_active = 'yes'")->result_array();
$data['hr_designation'] = $hr_designation;
$data['hr_roles'] = $hr_roles;
$this->load->view('admin/header', $data);
$this->load->view('admin/teacher');
$this->load->view('admin/footer');
}
}
public function add_edit_teacher($tid = NULL)
{
if (isset($_SESSION['admin_id'])) {
$data['tid'] = $tid;
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
//shankar code start here /
$data['subject_list'] = $this->Admin_model->get_subjects();
$data['assign_subjects'] = array('0');
//shankar code end here
if ($tid > 0) {
$data['detail'] = $this->Admin_model->get_teacher($tid);
//shankar code start here
$data['subjects'] = $this->Admin_model->get_teacher($tid, 1);
$dat = array();
foreach ($data['subjects'] as $key => $val) {
array_push($dat, $val['id']);
}
$data['assign_subjects'] = $dat;
//shankar code end here
}
$hr_db = $this->load->database('hr', TRUE);
$hr_roles = $hr_db->query("SELECT * from staff_roles where is_active = 'yes'")->result_array();
$hr_designation = $hr_db->query("SELECT * from hr_designation where is_active = 'yes'")->result_array();
$data['hr_designation'] = $hr_designation;
$data['hr_roles'] = $hr_roles;
// dd($hr_designation);
$this->load->view('admin/header', $data);
$this->load->view('admin/add-edit-teacher');
$this->load->view('admin/footer');
}
}
public function teacher_deleted()
{
if (isset($_SESSION['admin_id'])) {
$sid = '';
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['teacher'] = $this->Admin_model->get_delteacher();
$this->load->view('admin/header', $data);
$this->load->view('admin/teacher-deleted');
$this->load->view('admin/footer');
}
}
public function addedit_teacher()
{
$t_id = $_POST['tid'];
// $u_name = $_POST['uname'];
$t_name = $_POST['tname'];
$t_email = $_POST['temail'];
$t_mobile = $_POST['tmobile'];
$t_address = $_POST['taddress'];
$t_password = $_POST['tpassword'];
$t_role = $_POST['role'];
$t_designation = $_POST['designation'];
// dd($_POST);
//shankar code start here
$c_sub = $_POST['csubject'];
//shankar code end here
$profile_image = "";
if (!empty($_FILES['file']['name'])) {
$config['upload_path'] = 'assets_admin/images/teacher-profile/';
$config['allowed_types'] = 'gif|jpg|jpeg|png|jiff|jfif';
$this->load->library('upload', $config);
$this->upload->initialize($config);
$this->load->library('upload', $config);
$teacher_pic_prev = $this->db->get_where('teacher', array('id' => $t_id))->row()->photo;
if ($this->upload->do_upload('file')) {
unlink('assets_admin/images/teacher-profile/' . $teacher_pic_prev);
$data['upload_data'] = $this->upload->data('file_name');
$profile_image = $data['upload_data'];
} else {
$profile_image = '';
}
}
$data_array = array(
// 'username' => $u_name,
'teacher_name' => $t_name,
'email' => $t_email,
'mobile' => $t_mobile,
'address' => $t_address,
'role' => $t_role,
'designation' => $t_designation
);
$data = $this->Admin_model->addedit_teacher($t_id, $t_password, $profile_image, $data_array, $c_sub);
// var_dump($data);
if ((int) $data == 1) {
$this->session->set_flashdata('success_msg', str_replace('%s', 'New Teacher', THE_ADD_SUCCESS_MSG));
} else if ((int) $data == 2) {
$this->session->set_flashdata('success_msg', str_replace('%s', 'Teacher', THE_UPDATE_SUCCESS_MSG));
} else {
$this->session->set_flashdata('error_msg', str_replace('%s', '! Teacher Alredy Exist ', THE_ADD_ERROR_MSG));
}
redirect(base_url() . 'Admin/teacher');
} //teacher end
public function get_application()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/application.php'))
show_404();
$cfid = '';
$cid = '';
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$query = "SELECT * FROM course WHERE is_active='yes'";
$data['courses'] = $this->Admin_model->get_query_result($query);
if (isset($_POST['filterSubmit']) && $_POST['filterSubmit'] == 'Filter') {
$course_id = $this->input->post('course');
$e_date = $this->input->post('end');
$s_date = $this->input->post('start');
$s_date = $s_date ? $s_date : '';
$e_date = $e_date ? $e_date : '';
$course_id = $course_id ? $course_id : '';
$data['new'] = $this->Admin_model->get_application($s_date, $e_date, $course_id);
$data['approved'] = $this->Admin_model->get_approved_application($s_date, $e_date, $course_id);
$data['rejected'] = $this->Admin_model->get_rejected_application($s_date, $e_date, $course_id);
} else {
$data['new'] = $this->Admin_model->get_application($start = '', $end = '', $course = '');
$data['approved'] = $this->Admin_model->get_approved_application($start = '', $end = '', $course = '');
$data['rejected'] = $this->Admin_model->get_rejected_application($start = '', $end = '', $course = '');
}
$this->load->view('admin/header', $data);
$this->load->view('admin/application', $data);
$this->load->view('admin/footer');
}
public function process_application()
{
// $baseurl=base_url();
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
// $id = $this->uri->segment(3);
// $res = $this->uri->segment(4);
$id = $_POST['id'];
$res = $_POST['val'];
$result = $this->Admin_model->get_student_details('applications', array('id' => $id));
// $this->load->config('email');
// $from = $this->config->item('smtp_user');
// $this->email->from($from);
// $this->email->set_newline("\r\n");
// dd($_POST);
if ($res == 0) {
$stats = 'Rejected';
$reject_data = array(
"studname" => $result['name'],
"baseurl" => base_url()
);
$reject_data['school_info'] = $this->Admin_model->get_logo_from_setting();
$msg = $this->load->view('email-reject', $reject_data, TRUE);
$data = array(
'status' => 'rejected'
);
// $this->email->to($result['email']);
// $this->email->subject('Application');
// $this->email->message($msg);
// echo "Mailer Error: " . $this->email->print_debugger();
// $this->email->send();
// if (sendMail($result['email'], 'Application', $msg)) {
$rst = $this->Admin_model->process_application($id, $data);
if ($rst == 1) {
$this->session->set_flashdata('success', 'Application has been Rejected.');
echo 1;
} else {
$this->session->set_flashdata('error', 'Application has Not been Rejected.');
echo 0;
}
// } else {
// $this->session->set_flashdata('error', 'The mail is Not Sent');
// echo -1;
// // echo "Mailer Error: " . $this->email->print_debugger();
// }
} else {
$stats = 'Approved';
// $approve_data = array(
// "studname" => $result['name'],
// "make_payment" => base_url() . "student/admission_payment/" . $id,
// "baseurl" => base_url()
// );
// $approve_data['school_info'] = $this->Admin_model->get_logo_from_setting();
// $msg = $this->load->view('email-approve', $approve_data, TRUE);
$data = array(
'status' => 'approved'
);
// // $this->email->to($result['email']);
// // $this->email->subject('Application');
// // $this->email->message($msg);
// // if (sendMail($result['email'], 'Application', $msg)) {
$rst = $this->Admin_model->process_application($id, $data);
if ($rst == 1) {
$application_info = $this->db->query("SELECT * FROM applications WHERE id = $id")->row_array();
$res = $this->db->query("SELECT count(id) as student_count FROM students ")->row_array();
$exist_data = (isset($res['student_count']) && ($res['student_count'] != 0)) ? $res['student_count'] : 0;
$this->db->select_max('id');
$query = $this->db->get('students');
$resid = $query->row_array();
$resid = (isset($resid['id']) && !empty($resid['id'])) ? $resid['id'] : 0;
$studentMaxId = $resid + 1;
$pid = date('Y', strtotime($this->nepali_current_date)) . '0' . $studentMaxId;
$school_info = $this->Admin_model->get_logo_from_setting();
$school_prefix = (!empty($school_info['school_prefix_id'])) ? $school_info['school_prefix_id'] : 'BB';
$studentid = $school_prefix . STUDENT_PREFIX . $pid;
$parent_id = $school_prefix . STUDENT_PARENT_PREFIX . $pid;
$qr_path = $this->generate_qrcode($studentid);
$td = array(
'name' => $application_info['name'],
'course' => $application_info['course'],
'batch_id' => $application_info['batch_id'],
'email' => $application_info['email'],
'studentId' => $studentid,
'password' => $application_info['password'],
'mobile' => $application_info['mobile'],
'gender' => $application_info['gender'],
'dob' => $application_info['dob'],
'father_name' => $application_info['father_name'],
'mother_name' => $application_info['mother_name'],
'emergency_contact_name' => $application_info['emergency_contact_name'],
'emergency_contact_number' => $application_info['emergency_contact_number'],
'parent_username' => $application_info['name'],
'parent_password' => $application_info['name'],
'country' => $application_info['country'],
'state' => $application_info['state'],
'address1' => $application_info['address1'],
'photo' => $application_info['photo'],
'school_certificate' => $application_info['school_certificate'],
'exam_result' => $application_info['exam_result'],
'medical_cerificate' => $application_info['medical_cerificate'],
'registered_on' => $this->nepali_current_date,
'qr_code' => $qr_path,
'parent_username' => $parent_id,
'parent_password' => md5($parent_id),
'parent_pan' => '',
);
$insert = $this->db->insert('students', $td);
$this->session->set_flashdata('success', 'Application has been approved.');
echo 1;
} else {
$this->session->set_flashdata('error', 'Application has Not been approved.');
echo 0;
}
// dd($id);
// } else {
// $this->session->set_flashdata('error', 'The mail is Not Sent');
// echo -1;
// // echo "Mailer Error: " . $this->email->print_debugger();
// }
}
redirect('/admin/get_application');
}
public function application_request($id, $res)
{
if (isset($_SESSION['admin_id'])) {
$result = $this->Admin_model->get_student_details('applications', array('id' => $id));
if ($res == 0) {
$stats = 'Rejected';
$reject_data = array(
"studname" => $result['name'],
"baseurl" => base_url()
);
$reject_data['school_info'] = $this->Admin_model->get_logo_from_setting();
$msg = $this->load->view('email-reject', $reject_data, TRUE);
$data = array(
'status' => 'rejected'
);
} else {
$stats = 'Approved';
$approve_data = array(
"studname" => $result['name'],
"make_payment" => base_url() . "student/admission_payment/" . $id,
"baseurl" => base_url()
);
$approve_data['school_info'] = $this->Admin_model->get_logo_from_setting();
$msg = $this->load->view('email-approve', $approve_data, TRUE);
$data = array(
'status' => 'approved'
);
}
// $this->load->config('email');
// $from = $this->config->item('smtp_user');
// $this->email->from($from);
// $this->email->set_newline("\r\n");
// $this->email->to($result['email']);
// $this->email->subject('Application');
// $this->email->message($msg);
// echo $resu= $this->email->send();
// echo $this->email->print_debugger(array('headers'));
if (sendMail($result['email'], 'Application', $msg)) {
$resultt = $this->Admin_model->process_application($id, $data);
if ($resultt) {
$this->session->set_flashdata('success', 'Application has been ' . $data['status'] . '.');
echo 1;
} else {
$this->session->set_flashdata('error', 'Application has Not been ' . $data['status'] . '.');
echo 0;
}
} else {
// echo "Mailer Error: " . $this->email->print_debugger();
$this->session->set_flashdata('error', 'The mail is Not Sent');
echo -1;
}
redirect(base_url() . "admin/get_application");
}
}
public function view_applicant()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$id = $this->uri->segment(3);
$data['applicant'] = $this->Admin_model->view_applicant($id);
$this->load->view('admin/header', $data);
$this->load->view('admin/view_applicant', $data);
$this->load->view('admin/footer');
}
public function documents_reupload()
{
$id = $this->input->post('student_id');
$this->load->helper('url');
$this->load->helper(array('form', 'url'));
$config['upload_path'] = 'assets_student/application/';
$config['allowed_types'] = 'gif|jpg|png|jpeg|jfif|jiff';
$config['file_name'] = uniqid('img', false);
foreach ($_FILES as $key => $value) {
if ($value['error'] == 4) {
unset($_FILES[$key]);
array_values($_FILES);
}
}
if (count($_FILES) == 0) {
redirect('/admin/view_student/' . $id);
}
$this->load->library('upload', $config);
$this->upload->initialize($config);
$data['currentURL'] = current_url();
$data['id'] = $id;
if ($_FILES['photo']['size'] != 0) {
if (!$this->upload->do_upload('photo')) {
$data['photo'] = "";
} else {
$photo = array('upload_data' => $this->upload->data());
$data['photo'] = $photo['upload_data']['file_name'];
}
}
if ($_FILES['school']['size'] != 0) {
if (!$this->upload->do_upload('school')) {
$data['school_certificate'] = "";
} else {
$school = array('upload_data' => $this->upload->data());
$data['school_certificate'] = $school['upload_data']['file_name'];
}
}
if ($_FILES['exam']['size'] != 0) {
if (!$this->upload->do_upload('exam')) {
$data['exam_result'] = "";
} else {
$exam = array('upload_data' => $this->upload->data());
$data['exam_result'] = $exam['upload_data']['file_name'];
}
}
if ($_FILES['medical']['size'] != 0) {
if (!$this->upload->do_upload('medical')) {
$data['medical_cerificate'] = "";
} else {
$medical = array('upload_data' => $this->upload->data());
$data['medical_cerificate'] = $medical['upload_data']['file_name'];
}
}
$app_new_id = $this->Admin_model->update_studentsdoc($data);
redirect('/admin/view_student/' . $data['id']);
}
public function student()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$cid = '';
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['batchId'] = isset($data['school_info']['batch_id']) ? $data['school_info']['batch_id'] : 0;
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
if ($this->input->post('filterSubmit') == "Filter") {
// $this->form_validation->set_rules('filter-Sdate', 'Start Date', 'required');
$this->form_validation->set_rules('filter-course', 'Course', 'required');
// $this->form_validation->set_rules('filter-Edate', 'End Date', 'required');
$course_id = $_POST['filter-course'] ? $_POST['filter-course'] : 0;
$batch_id = $_POST['filter-batch'] ? $_POST['filter-batch'] : $data['school_info']['batch_id'];
// $e_date = isset($_POST['filter-Edate']) ? $_POST['filter-Edate'] : '';
// $s_date = isset($_POST['filter-Sdate']) ? $_POST['filter-Sdate'] : '';
$data['courseId'] = $course_id;
$data['batchId'] = $batch_id;
// $data['sdate'] = $s_date;
// $data['edate'] = $e_date;
if (!$this->form_validation->run() == FALSE) {
$std_query = "SELECT sb.student_id,sb.batch_id as student_batch,sb.classroom_id,sb.roll_no,sb.registration_no,sb.symbol_no, cl.course_id, cl.section_id, s.*, b.b_name FROM student_batch sb
JOIN classroom cl ON cl.id = sb.classroom_id
JOIN students s ON s.id = sb.student_id
JOIN batch b ON b.id = $batch_id
WHERE sb.batch_id = $batch_id AND cl.course_id = $course_id AND s.is_active='yes'";
$students = $this->db->query($std_query)->result_array();
$data['students'] = $students;
// dd($students);
} else {
$std_query = "SELECT sb.student_id,sb.batch_id as student_batch,sb.classroom_id,sb.roll_no,sb.registration_no,sb.symbol_no, cl.course_id, cl.section_id, s.*, b.b_name FROM student_batch sb
JOIN classroom cl ON cl.id = sb.classroom_id
JOIN students s ON s.id = sb.student_id
JOIN batch b ON b.id = $batch_id
WHERE sb.batch_id = $batch_id AND s.is_active='yes'";
$students = $this->db->query($std_query)->result_array();
$data['students'] = $students;
}
} else {
// $data['students'] = $this->Admin_model->get_students();
$data['students'] = array();
}
foreach ($data['students'] as $key => $value) {
$batch_id = $value['batch_id'];
$batch_name = '-';
$batch_name_row = $this->db->get_where('batch', array('id' => $batch_id))->row();
if (count((array)$batch_name_row) > 0) {
$batch_name = $batch_name_row->b_name;
}
$data['students'][$key]['batch_name'] = $batch_name;
}
$data['course'] = $this->db->query("select * from course WHERE is_active='yes'")->result_array();
$data['batch'] = $this->Admin_model->get_batch();
$this->load->view('admin/header', $data);
$this->load->view('admin/student-list', $data);
$this->load->view('admin/footer');
}
//course start
public function classroom_student()
{
if (isset($_SESSION['admin_id'])) {
$clsid = $this->uri->segment(3);
$cid = $this->uri->segment(4);
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['course_id'] = $cid;
$data['class_id'] = $clsid;
$data['students'] = $this->Admin_model->get_classstudents($clsid);
$this->load->view('admin/header', $data);
$this->load->view('admin/classroom-students');
$this->load->view('admin/footer');
}
}
//course start
public function students_notassign()
{
if (isset($_SESSION['admin_id'])) {
$clsid = $this->uri->segment(3);
$cid = $this->uri->segment(4);
$data['course_id'] = $cid;
$data['class_id'] = $clsid;
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['students'] = $this->Admin_model->get_coursestudents($cid);
$this->load->view('admin/header', $data);
$this->load->view('admin/students-notassigned');
$this->load->view('admin/footer');
}
}
//course start
public function student_class_assignment()
{
if (isset($_SESSION['admin_id'])) {
$cid = $this->uri->segment(3);
$data['course_id'] = $cid;
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['students'] = $this->Admin_model->get_coursestudents($cid);
$this->load->view('admin/header', $data);
$this->load->view('admin/students-assign');
$this->load->view('admin/footer');
}
}
// public function assign_classroom()
// {
// if(isset($_SESSION['admin_id'])){
// $classid = $this->uri->segment(3);
// $sid = $this->uri->segment(4);
// $data['currentURL'] = current_url();
// //get logo
// $data['logo'] = $this->Admin_model->get_logo();
// $data['school_info'] = $this->Admin_model->get_logo_from_setting();
// //get menu list
// $data['menulist'] = $this->Admin_model->get_adminMenu();
// $data['students'] = $this->Admin_model->assign_clssroom($classid,$sid);
// $course = $this->Admin_model->get_studentcourse($sid);
// $course_id = $course['course'];
// redirect(base_url().'Admin/students_notassign/'.$classid.'/'.$course_id);
// }
// }
public function view_classstudent()
{
if (isset($_SESSION['admin_id'])) {
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$id = $this->uri->segment(3);
$data['student'] = $this->Admin_model->view_student($id);
$this->load->view('admin/header', $data);
$this->load->view('admin/view_classstudent', $data);
$this->load->view('admin/footer');
}
}
public function remove_student()
{
if (isset($_SESSION['admin_id'])) {
$data['currentURL'] = current_url();
$id = $_POST['id'];
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$this->Admin_model->get_removestudent($id);
}
}
// public function testexam(){
// if(isset($_SESSION['admin_id'])){
// $data['currentURL'] = current_url();
// //get logo
// $data['logo'] = $this->Admin_model->get_logo();
// $data['school_info'] = $this->Admin_model->get_logo_from_setting();
// //get menu list
// $data['menulist'] = $this->Admin_model->get_adminMenu();
// $this->load->view('admin/header',$data);
// $this->load->view('admin/exam-add-edit',$data);
// $this->load->view('admin/footer');
// }
// }
// public function listtestexam(){
// if(isset($_SESSION['admin_id'])){
// $data['currentURL'] = current_url();
// //get logo
// $data['logo'] = $this->Admin_model->get_logo();
// $data['school_info'] = $this->Admin_model->get_logo_from_setting();
// //get menu list
// $data['menulist'] = $this->Admin_model->get_adminMenu();
// $this->load->view('admin/header',$data);
// $this->load->view('admin/examlist',$data);
// $this->load->view('admin/footer');
// }
// }
// public function addexam(){
// print_r($_POST);
// die();
// }
// Section Controllers - Afras - 10/08/2021
public function section()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['result'] = $this->Admin_model->get_table_info('section');
$this->load->view('admin/header', $data);
$this->load->view('admin/section');
$this->load->view('admin/footer');
}
public function deleteSection($secId)
{
$confirm = $this->Admin_model->checkSectioninCourse($secId);
if ($confirm == 'failed') {
$sql = $this->Admin_model->deleteSection($secId);
if ($sql) {
$this->session->set_flashdata('success', 'Section has been successfully deleted');
redirect(base_url() . 'admin/sections');
} else {
$this->session->set_flashdata('failed', 'Section could not been deleted, Please try again!');
redirect(base_url() . 'admin/sections');
}
} else {
if ($confirm == 'Course Error') {
$session_msg = 'Section is linked with Course, But No Courses Found';
$this->session->set_flashdata('failed', $session_msg);
redirect(base_url() . 'admin/sections');
}
foreach ($confirm as $key => $value) {
if ($key == 0) {
$roomNames = $value;
} else {
$roomNames = ', ' . $value;
}
}
$session_msg = "Delete Failed! <br> Section connected to " . $roomNames . " Course";
$this->session->set_flashdata('failed', $session_msg);
redirect(base_url() . 'admin/sections');
}
}
public function validateSectionName()
{
$sectionName = strtolower($this->input->post('value'));
$id = $this->input->post('id');
$query = $this->Admin_model->check_value_exists('section', array('LOWER(section_name)' => $sectionName), $id);
if ($query)
echo 'success';
else
echo 'failed';
}
public function add_edit_section($sectionId)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/ae_section.php'))
show_404();
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['id'] = $sectionId;
$whereClause = array('id' => $sectionId);
$checkSectionExists = $this->Admin_model->get_section_details($whereClause);
if (empty($checkSectionExists) && $sectionId != 0) {
$this->session->set_flashdata('failed', 'There is no section with selected id');
redirect(base_url() . 'Admin/section');
}
if (count($_POST) > 0) {
$_POST['section_name'] = $this->convertToCapCase($_POST['section_name']);
if ($sectionId > 0) {
$_POST['modified'] = $this->nepali_current_date;
} else {
$_POST['created'] = $this->nepali_current_date;
}
$sql = $this->Admin_model->add_edit_section($sectionId, $_POST);
if (($sql) && $sectionId > 0) {
$this->session->set_flashdata('success', 'Section has been updated successfully');
redirect(base_url() . 'Admin/section');
} else if ($sql) {
$this->session->set_flashdata('success', 'Section has been addedd successfully');
redirect(base_url() . 'Admin/section');
} else {
$this->session->set_flashdata('failed', 'Section updation failed as it is linked with course or classroom');
redirect(base_url() . 'Admin/section');
}
}
$data['title'] = 'Add New Section';
if ($sectionId > 0) {
$data['title'] = 'Edit Section';
$data['result'] = $checkSectionExists;
}
$this->load->view('admin/header', $data);
$this->load->view('admin/ae_section');
$this->load->view('admin/footer');
}
function convertToCapCase($str)
{
$str = strtolower($str);
return ucwords($str);
}
// Section Controllers - Afras - 10/08/2021
// assign syllabus start by shivu
function assign_syllabus($id)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/assign-syllabus.php'))
show_404();
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['title'] = "Assigning Syllabus - ";
$data['subject'] = $this->Admin_model->get_general_details('subject', 'ASC', array('id' => $id));
$query = "SELECT c.id as course_id,c.course_name,s.id FROM course_subjects cs LEFT JOIN course c ON cs.course_id=c.id LEFT JOIN subject s ON cs.subject_id=s.id WHERE c.is_active='yes' AND cs.subject_id=$id";
$data['courses'] = $this->Admin_model->get_query_result($query);
$qry1 = "SELECT s.id,s.syllabus,c.course_name FROM `subject_syllabus` s JOIN course c ON c.id=s.course_id WHERE s.subject_id=$id";
$data['syllabuslist'] = $this->Admin_model->get_query_result($qry1);
$data['action_url'] = base_url() . "admin/ae_assign_syllabus";
$this->load->view('admin/header', $data);
$this->load->view('admin/assign-syllabus');
$this->load->view('admin/footer');
}
public function ae_assign_syllabus($id)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$config['upload_path'] = 'assets_admin/images/syllabus/' . $_POST['course_id'] . '-' . $_POST['subject_id'] . '/';
if (!is_dir($config['upload_path'])) mkdir($config['upload_path'], 0777, TRUE);
$config['allowed_types'] = 'pdf|jpeg|jpg|png';
$config['max_size'] = '5120';
$this->load->library('upload', $config);
// dd($_FILES);
$this->upload->initialize($config);
if ($this->upload->do_upload('syllabus')) {
$upload_data = 'assets_admin/images/syllabus/' . $_POST['course_id'] . '-' . $_POST['subject_id'] . '/' . $this->upload->data('file_name');
if (count($_POST) > 0) {
$result = $this->Admin_model->insert_update_data($_POST, $upload_data);
if ($result == 1)
$this->session->set_flashdata('successsubject', 'Syllabus has been updated successfully');
else if ($result == 2)
$this->session->set_flashdata('successsubject', 'Syllabus has been insert successfully');
else
$this->session->set_flashdata('errorsubject', 'Syllabus Insertion Failed');
} else {
$this->session->set_flashdata('errorsubject', 'Please Upload valid File');
}
} else {
$error = array('error' => $this->upload->display_errors());
$this->session->set_flashdata('errorsubject', $error['error']);
}
redirect(base_url() . 'admin/subject');
}
public function checkname()
{
$namevalue = $_POST['value'];
$table = $_POST['tablename'];
$dbcolumn = $_POST['column'];
$result = $this->Admin_model->get_general_details($table, 'ASC', array($dbcolumn => $namevalue));
if (count($result) > 0)
echo 1;
else
echo 0;
}
public function checksyllabus()
{
$subject_id = (isset($_POST['subject_id'])) ? $_POST['subject_id'] : 0;
$course_id = (isset($_POST['course_id'])) ? $_POST['course_id'] : 0;
$result = $this->Admin_model->get_general_details('subject_syllabus', 'ASC', array('subject_id' => $subject_id, 'course_id' => $course_id));
if (count($result) > 0)
echo $result['syllabus'];
else
echo 0;
} // assign syllabus end here
// Course Controllers - 12-10-2021 Afras Khan
public function course()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (isset($_SESSION['admin_id'])) {
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
// $data['course'] = $this->Admin_model->get_course_details();
$sql = "SELECT c.id, c.course_name, se.section_name, s.subject_name, c.created from course c inner join course_sections ce on c.id = ce.course_id inner join course_subjects cs on c.id = cs.course_id inner join section se on ce.section_id = se.id inner join subject s on s.id = cs.subject_id GROUP BY c.id, se.section_name, s.subject_name ORDER BY c.id ";
$data['result'] = $this->Admin_model->get_course_subject_section($sql);
$getCourseNames = "Select c.id,c.course_name, cf.amount from course c left join course_fees cf on c.id = cf.course_id AND cf.fees_type = 2 GROUP BY c.course_name, c.id, cf.amount ORDER BY c.id ASC";
$data['course_names'] = $this->Admin_model->get_table_info('course', '', $getCourseNames);
// dd($data['course_names']);
$this->load->view('admin/header', $data);
$this->load->view('admin/course');
$this->load->view('admin/footer');
}
}
public function add_edit_course($cid = NULL)
{
if (isset($_SESSION['admin_id'])) {
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/ae_section.php'))
show_404();
$whereClause = array('id' => $cid);
$checkCourseExists = $this->Admin_model->get_course_details($whereClause);
if (empty($checkCourseExists) && $cid != 0) {
$this->session->set_flashdata('failed', 'There is no course with selected id');
redirect(base_url() . 'Admin/course');
}
$sid = '';
$data['id'] = $cid;
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['subject_list'] = $this->Admin_model->get_table_info('subject', array('is_active' => 'yes'));
$data['section_list'] = $this->Admin_model->get_table_info('section', array('is_active' => 'yes'));
if (count($_POST) > 0) {
$course_name = ucwords(strtolower($this->input->post('course_name')));
$status = $this->input->post('is_active');
$subject_section_ids['subject'] = $this->input->post('csubject');
$subject_section_ids['section'] = $this->input->post('csection');
if ($cid == 0) {
$insertArr = array(
'course_name' => $course_name,
'is_active' => $status,
'created' => $this->nepali_current_date
);
$course_query = $this->Admin_model->add_edit_course($cid, $insertArr, $subject_section_ids);
if ($course_query) {
$this->session->set_flashdata('success', 'Course has been added successfully ');
redirect(base_url() . 'Admin/course');
} else {
$this->session->set_flashdata('failed', 'Course could not be added, Please try again!');
redirect(base_url() . 'Admin/course');
}
} else if ($cid > 0) {
$insertArr = array(
'course_name' => $course_name,
'is_active' => $status,
'modified' => $this->nepali_current_date
);
// $check_course_in_classroom = $this->Admin_model->get_table_info_row('classroom', array('course_id' => $cid));
$check_course_in_classroom = $this->db->query("SELECT * FROM classroom WHERE course_id=$cid")->result_array();
if (!empty($check_course_in_classroom)) {
// echo "<pre>";
// print_r($check_course_in_classroom);
foreach ($check_course_in_classroom as $each_cl_value) {
$arr1 = explode(' - ', $each_cl_value['classroom_name']);
$arr1[0] = $course_name;
$class_name = implode(' - ', $arr1);
// print_r($class_name);
$this->db->set('classroom_name', $class_name)
->where('id', $each_cl_value['id'])
->update('classroom');
}
// exit;
// $arr = explode(' - ', $check_course_in_classroom['classroom_name']);
// $arr[0] = $course_name;
// $class_name = implode(' - ', $arr);
// $this->db->set('classroom_name', $class_name)
// ->where('course_id', $cid)
// ->update('classroom');
}
// Updating Course table with name and date
$course_query = $this->Admin_model->add_edit_course($cid, $insertArr, $subject_section_ids);
// Updating Course-Sections with updated section Id's
$pre_course_sec = $this->Admin_model->get_course_sections($cid);
$preSelectedSections = array_column($pre_course_sec, 'section_id');
// dd($pre_course_sec);
$section_flag = ($preSelectedSections == $subject_section_ids['section']);
if (!$section_flag) {
foreach ($subject_section_ids['section'] as $key => $value) {
foreach ($preSelectedSections as $pre_key => $pre_val) {
if ($value == $pre_val) {
array_splice($preSelectedSections, $pre_key, 1);
}
}
}
$update_course_section = $this->Admin_model->update_course_section($subject_section_ids['section'], $preSelectedSections, $cid);
if ($update_course_section['status'] == 'failed') {
$sectionNameMsg = 'Cannot unselect ' . $update_course_section['section-names'];
$sectionNameMsg .= '<br>As They are connected with : ';
$sectionNameMsg .= $update_course_section['class-name'] . ' class';
$this->session->set_flashdata('failed', $sectionNameMsg);
redirect(base_url() . 'admin/add_edit_course/' . $cid);
} else if (!$update_course_section) {
$sectionNameMsg = 'Course could not be updated. Please try again later';
$this->session->set_flashdata('failed', $sectionNameMsg);
redirect(base_url() . 'admin/add_edit_course/' . $cid);
}
}
// Updating Course-Subjects with updated section Id's
$update_course_subject = $this->Admin_model->update_course_subject($subject_section_ids['subject'], $cid);
// Yogesh
$offlineExams = $this->Admin_model->get_course_offfline_exam($cid);
// echo '<pre>';
$update_course_offline_exam =
$this->Admin_model->update_course_offline_exam($subject_section_ids['subject'], $offlineExams, $cid);
// echo '<pre>';
// print_r($update_course_offline_exam);
if ($update_course_subject['status'] == 'failed') {
$subjectNameMsg = 'Cannot unselect ' . $update_course_subject['subject-names'];
$subjectNameMsg .= '<br>As They are connected with : ';
$subjectNameMsg .= $update_course_subject['sub-class-name'] . ' class';
$this->session->set_flashdata('failed', $subjectNameMsg);
redirect(base_url() . 'admin/add_edit_course/' . $cid);
} else if (!$update_course_subject) {
$subjectNameMsg = 'Course could not be updated. Please try again later';
$this->session->set_flashdata('failed', $subjectNameMsg);
redirect(base_url() . 'admin/add_edit_course/' . $cid);
}
$this->session->set_flashdata('success', 'Course has been updated successfully');
redirect(base_url() . 'admin/course/');
exit();
}
} // POST IF CONDITION ENDS
$data['title'] = 'Add New Course';
if ($cid > 0) {
$data['title'] = 'Edit Course 1';
$whereClause = array('id =' => $cid);
$data['course_info'] = $this->Admin_model->get_course_details($whereClause);
$data['course_section_info'] = $this->Admin_model->get_course_sections($cid);
$data['course_subject_info'] = $this->Admin_model->get_course_subjects($cid);
// dd($data['course_subject_info']);
$selectedSec = array();
$selectedSub = array();
if (!empty($data['course_section_info'])) {
foreach ($data['course_section_info'] as $key => $value) {
array_push($selectedSec, array(
'id !=' => $value['section_id']
));
}
}
if (!empty($data['course_subject_info'])) {
foreach ($data['course_subject_info'] as $key => $value) {
array_push($selectedSub, array(
'id !=' => $value['subject_id']
));
}
}
$data['difference_section'] = $this->Admin_model->unselected_subject_section($selectedSec, 'section');
$data['difference_subject'] = $this->Admin_model->unselected_subject_section($selectedSub, 'subject');
}
$this->load->view('admin/header', $data);
$this->load->view('admin/ae_course');
$this->load->view('admin/footer');
}
}
public function ajax_validate_course_name()
{
$courseName = strtolower($this->input->post('value'));
$id = $this->input->post('id');
$query = $this->Admin_model->check_value_exists('course', array('LOWER(course_name)' => $courseName), $id);
if ($query)
echo 'success';
else
echo 'failed';
}
public function delete_course($cid)
{
$confirm = $this->Admin_model->check_course_in_classroom($cid);
if ($confirm == 'failed') {
$sql = $this->Admin_model->deleteCourse($cid);
if ($sql) {
$this->session->set_flashdata('success', 'Course has been successfully deleted');
redirect(base_url() . 'admin/course');
} else {
$this->session->set_flashdata('failed', 'Course could not been deleted, Please try again!');
redirect(base_url() . 'admin/course');
}
} else {
if ($confirm == 'Classroom Error') {
$session_msg = 'Course is linked with Classrooms, But No Classrooms Found';
$this->session->set_flashdata('failed', $session_msg);
redirect(base_url() . 'admin/course');
}
foreach ($confirm as $key => $value) {
if ($key == 0) {
$roomNames = $value;
} else {
$roomNames .= ', ' . $value;
}
}
$session_msg = "Delete Failed! <br> Course connected to " . $roomNames . " Classrooms";
$this->session->set_flashdata('failed', $session_msg);
redirect(base_url() . 'admin/course');
}
}
// Course Controllers Ends - 12-10-2021 Afras Khan
// Notification Controllers Starts - 13-10-2021 - Afras Khan
public function notifications()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (isset($_SESSION['admin_id'])) {
$data['filterArray'] = $this->Admin_model->getDistinctNotifications();
if (isset($_POST['filterSubmit'])) {
$filterName = $this->input->post('filter-name');
$filterClass = $this->input->post('filter-classroom');
$filterTeacher = $this->input->post('filter-teacher');
$filterDate = $this->input->post('filter-date');
$sql = $this->Admin_model->getFilterNotifications($filterName, $filterClass, $filterTeacher, $filterDate);
if ($sql != 'failed') {
$data['notificationInfo'] = $sql;
$_SESSION['isFilterActve'] = true;
} else {
$data['notificationInfo'] = $this->Admin_model->get_notification_details();
}
} else {
$data['notificationInfo'] = $this->Admin_model->get_notification_details();
}
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$this->load->view('admin/header', $data);
$this->load->view('admin/notifications', $data);
$this->load->view('admin/footer');
}
}
public function notification_form()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$queryData = array();
$student = isset($_POST['student_classroom']) ? $this->input->post('student_classroom') : NULL;
$teacher = isset($_POST['teacher_name']) ? $this->input->post('teacher_name') : NULL;
date_default_timezone_set('Asia/Kolkata');
$queryData = array(
'notification_title' => $this->input->post('notification_title'),
'notification_to' => $this->input->post('notification_to'),
'student_classroom' => $student,
'teacher_id' => $teacher,
'description' => $this->input->post('description'),
'created_at' => $this->nepali_current_date
);
$query = $this->Admin_model->insertNotificationData($queryData);
if ($query) {
if (isset($_SESSION['admin_id'])) {
$this->session->set_flashdata('success', str_replace('%s', 'Notification', THE_ADD_SUCCESS_MSG));
redirect(base_url() . 'Admin/notifications');
} else {
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$this->load->view('admin/header', $data);
$this->load->view('admin/login');
$this->load->view('admin/footer');
}
} else { // Query Else Condition
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$this->load->view('admin/header', $data);
$this->load->view('admin/send-notifications', $data);
$this->load->view('admin/footer');
}
}
public function ajax_fetch_notifications_data()
{
$selectedValue = $this->input->post('value');
if ($selectedValue == 'teacher') { // Fetch Teachers name if value is teachers
$id = '';
$teachers = $this->Admin_model->get_teacherUnique($id);
$jsonVar = json_encode($teachers);
echo $jsonVar;
} else if ($selectedValue == 'student') {
$id = '';
$student = $this->Admin_model->get_classroomUnique($id);
$jsonVar = json_encode($student);
echo $jsonVar;
} else if ($selectedValue == 'both') {
$id = '';
$data['student'] = $this->Admin_model->get_classroomUnique($id);
$data['teachers'] = $this->Admin_model->get_teacherUnique($id);
$jsonVar = json_encode($data);
echo $jsonVar;
}
}
public function send_notifications()
{
if (isset($_SESSION['admin_id'])) {
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$this->load->view('admin/header', $data);
// $this->load->view('admin/send-notifications', $data);
$this->load->view('admin/footer');
}
}
public function delete_notification()
{
$id = $this->input->get('id');
$sql = $this->Admin_model->deleteNotification($id);
if ($sql) {
$this->session->set_flashdata('success', str_replace('%s', 'Notification', THE_DELETE_SUCCESS_MSG));
redirect(base_url() . 'Admin/notifications');
} else {
$this->session->set_flashdata('failed', str_replace('%s', 'Notification', THE_DELETE_ERROR_MSG));
redirect(base_url() . 'Admin/notifications');
}
}
public function view_notification($id)
{
$sql = $this->Admin_model->getSingleNotification($id);
if ($sql !== 'failed') {
if (isset($_SESSION['admin_id'])) {
$data['result'] = $sql;
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$this->load->view('admin/header', $data);
$this->load->view('admin/notif-details', $data);
$this->load->view('admin/footer');
}
} else {
$this->session->set_flashdata('failed', 'Row could not been viewed, Please try again in sometime!');
redirect(base_url() . 'Admin/notifications');
}
}
public function ajax_validate_notification_name()
{
$notification_title = strtolower($this->input->post('value'));
$id = 0;
$query = $this->Admin_model->check_value_exists('notifications', array('LOWER(notification_title)' => $notification_title), $id);
if ($query)
echo 'success';
else
echo 'failed';
}
// Notification Controllers Ends - 13-10-2021 - Afras Khan
// shankar code Start for exam secton 13-10-21
public function add_exam_view()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['result'] = $this->Admin_model->get_exam_details();
$this->load->view('admin/header', $data);
$this->load->view('admin/exams');
$this->load->view('admin/footer');
}
public function delete_added_Exam($examId)
{
$sql = $this->Admin_model->deleteExam($examId);
if ($sql) {
$this->session->set_flashdata('success', 'Exam has been successfully deleted');
redirect(base_url() . 'admin/exam-view');
} else {
$this->session->set_flashdata('failed', 'Sorry ! Exam already assign to Question Paper');
redirect(base_url() . 'admin/exam-view');
}
}
public function validateAddedExamName()
{
$sql = $this->Admin_model->get_exam_details();
$AllNames = array();
foreach ($sql as $key => $value) {
array_push($AllNames, array(
'name' => $value['e_name'],
'id' => $value['id']
));
}
echo json_encode($AllNames);
}
public function add_edit_exam($examId)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['id'] = $examId;
$whereClause = array('id' => $examId);
$checkSectionExists = $this->Admin_model->get_exam_details($whereClause);
if (empty($checkSectionExists) && $examId != 0) {
$this->session->set_flashdata('failed', 'There is no exam with selected id');
redirect(base_url() . 'admin/ae_exam');
}
if (count($_POST) > 0) {
$_POST['e_name'] = $this->convertToCapCase($_POST['e_name']);
if ($examId > 0) {
$_POST['modified'] = $this->nepali_current_date;
} else {
$_POST['created'] = $this->nepali_current_date;
$_POST['modified'] = $this->nepali_current_date;
}
$sql = $this->Admin_model->add_edit_exam($examId, $_POST);
if (($sql) && $examId > 0) {
$this->session->set_flashdata('success', str_replace('%s', 'Exam', THE_UPDATE_SUCCESS_MSG));
// $this->session->set_flashdata('success', 'Section has been updated successfully');
redirect(base_url() . 'admin/exam-view');
} else if ($sql) {
$this->session->set_flashdata('success', str_replace('%s', 'new exam', THE_ADD_SUCCESS_MSG));
// $this->session->set_flashdata('success', 'Section has been addedd successfully');
redirect(base_url() . 'admin/exam-view');
} else {
$this->session->set_flashdata('danger', str_replace('%s', 'Exam', THE_ADD_ERROR_MSG));
// $this->session->set_flashdata('failed', 'Section updation failed');
redirect(base_url() . 'admin/exam-view');
}
}
$data['title'] = 'Add New Exam';
if ($examId > 0) {
$data['title'] = 'Edit Exam';
$data['result'] = $checkSectionExists;
}
// echo"<pre>";print_r($data);exit();
$this->load->view('admin/header', $data);
$this->load->view('admin/ae_exam');
$this->load->view('admin/footer');
}
// shankar code end for exam secton 13-10-21
// Admin Role Controller - 16-10-21 Afras Khan
public function roles()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$sql = "Select a.*, ar.menu_ids from admin_roles a LEFT JOIN admin_role_permissions ar on a.id = ar.admin_role_ids;";
$data['result'] = $this->Admin_model->get_table_info('admin_roles', '', $sql);
$this->load->view('admin/header', $data);
$this->load->view('admin/roles');
$this->load->view('admin/footer');
}
public function add_edit_roles($arId)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/ae_role.php'))
show_404();
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['id'] = $arId;
$whereClause = array('id' => $arId);
$checkRoleExists = $this->Admin_model->get_role_details($whereClause);
if (empty($checkRoleExists) && $arId != 0) {
$this->session->set_flashdata('failed', 'There is no admin role with selected id');
redirect(base_url() . 'admin/roles/list');
}
if (count($_POST) > 0) {
$_POST['role_name'] = ucwords(strtolower($_POST['role_name']));
$rolePermId = $this->input->post('rolesid');
unset($_POST['rolesid']);
if (!empty($rolePermId)) {
$rolePermId = implode(',', $rolePermId);
}
if ($arId > 0) {
$_POST['modified'] = date('Y-m-d H:i:s', strtotime($this->nepali_current_date));
$permids = array(
'menu_ids' => $rolePermId
);
}
$sql = $this->Admin_model->add_edit_role($arId, $_POST);
if ($arId == 0) {
$permids = array(
'admin_role_ids' => $sql,
'menu_ids' => $rolePermId
);
}
if (!empty($rolePermId)) {
$rolePermQuery = $this->Admin_model->add_edit_role_permissions($arId, $permids);
}
if (($sql) && ($permids) && $arId > 0) {
$this->session->set_flashdata('success', str_replace('%s', 'Role', THE_UPDATE_SUCCESS_MSG));
redirect(base_url() . 'admin/roles/list');
} else if (($sql) && ($permids)) {
$this->session->set_flashdata('success', str_replace('%s', 'Role', THE_ADD_SUCCESS_MSG));
redirect(base_url() . 'admin/roles/list');
} else {
$this->session->set_flashdata('failed', str_replace('%s', 'Role', THE_UPDATE_ERROR_MSG));
redirect(base_url() . 'admin/roles/list');
}
}
$data['title'] = 'Add New Role';
if ($arId > 0) {
$data['title'] = 'Edit Role';
$data['result'] = $checkRoleExists;
$where_permissions = array('admin_role_ids' => $arId);
$permissions_info = $this->Admin_model->get_table_info('admin_role_permissions', $where_permissions);
$id_string = array_column($permissions_info, 'menu_ids');
$id_string = array_shift($id_string);
$data['pre_selected_ids'] = explode(',', $id_string);
}
$this->load->view('admin/header', $data);
$this->load->view('admin/ae_role');
$this->load->view('admin/footer');
}
public function ajax_validate_role_name()
{
$valName = strtolower($this->input->post('value'));
$id = $this->input->post('id');
$query = $this->Admin_model->check_value_exists('admin_roles', array('LOWER(role_name)' => $valName), $id);
if ($query)
echo 'success';
else
echo 'failed';
}
public function delete_role($roleId)
{
$checkRoleExists = $this->Admin_model->get_table_info('admin', array('admin_role_ids' => $roleId));
if (empty($checkRoleExists)) {
$sql = $this->Admin_model->delete_role($roleId);
if ($sql) {
$this->session->set_flashdata('success', str_replace('%s', 'Role', THE_DELETE_SUCCESS_MSG));
redirect(base_url() . 'admin/roles/list');
} else {
$this->session->set_flashdata('failed', str_replace('%s', 'Role', THE_DELETE_ERROR_MSG));
redirect(base_url() . 'admin/roles/list');
}
} else {
$session_msg = "Delete Failed! <br> Role has been assigned to an User";
$this->session->set_flashdata('failed', $session_msg);
redirect(base_url() . 'admin/roles/list');
}
}
// Admin Role Controller Ends - 16-10-21 Afras Khan
// User Role Controller - 18-10-21 Afras Khan
public function users()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$sql = "Select a.*, ar.role_name from admin a LEFT JOIN admin_roles ar on a.admin_role_ids = ar.id";
$data['result'] = $this->Admin_model->get_table_info('admin', '', $sql);
$this->load->view('admin/header', $data);
$this->load->view('admin/users');
$this->load->view('admin/footer');
}
public function add_edit_users($uId)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/ae_user.php'))
show_404();
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
//get admin roles
$data['roles'] = $this->Admin_model->get_table_info("admin_roles", array('status' => 'Active'));
$data['id'] = $uId;
$sql = "Select a.*, ar.role_name from admin a LEFT JOIN admin_roles ar on a.admin_role_ids = ar.id WHERE a.id = '$uId'";
$adminData = $this->Admin_model->get_table_info('admin', '', $sql);
if (empty($adminData) && $uId != 0) {
$this->session->set_flashdata('failed', 'There is no user with selected id');
redirect(base_url() . 'Admin/users/list');
}
if (count($_POST) > 0) {
unset($_POST['confirm_password']);
$_POST['password'] = md5($this->input->post('password'));
$_POST['admin_name'] = ucwords(strtolower($this->input->post('admin_name')));
if ($uId > 0) {
$_POST['modified'] = date('Y-m-d H:i:s', strtotime($this->nepali_current_date));
if ($_POST['replace_password'] != '') {
$_POST['password'] = md5($this->input->post('replace_password'));
unset($_POST['replace_password']);
} else {
unset($_POST['replace_password']);
}
} else
$_POST['created'] = date('Y-m-d H:i:s', strtotime($this->nepali_current_date));
$insert_user_query = $this->Admin_model->add_edit_users($uId, $_POST);
if (!empty($insert_user_query) && $uId > 0) {
$this->session->set_flashdata('success', str_replace('%s', 'User', THE_UPDATE_SUCCESS_MSG));
redirect(base_url() . 'admin/users/list');
} else if (!empty($insert_user_query)) {
$this->session->set_flashdata('success', str_replace('%s', 'User', THE_ADD_SUCCESS_MSG));
redirect(base_url() . 'admin/users/list');
} else {
if ($id > 0) {
$this->session->set_flashdata('failed', str_replace('%s', 'User', THE_UPDATE_ERROR_MSG));
redirect(base_url() . 'admin/users/list');
} else {
$this->session->set_flashdata('failed', str_replace('%s', 'User', THE_ADD_ERROR_MSG));
redirect(base_url() . 'admin/users/list');
}
}
}
$data['title'] = 'Add New User';
if ($uId > 0) {
$data['title'] = 'Edit User';
$data['result'] = $adminData;
$admin_role_id = $data['result'][0]['admin_role_ids'];
$roleQuery = "Select id, role_name from admin_roles where id != '$admin_role_id'";
$data['pre_selected_roles'] = $this->Admin_model->get_table_info('admin_roles', '', $roleQuery);
}
$this->load->view('admin/header', $data);
$this->load->view('admin/ae_user');
$this->load->view('admin/footer');
}
public function ajax_validate_user_email()
{
$valName = strtolower($this->input->post('value'));
$id = $this->input->post('id');
$query = $this->Admin_model->check_value_exists('admin', array('LOWER(email)' => $valName), $id);
if ($query)
echo 'success';
else
echo 'failed';
}
public function delete_user($uId)
{
if ($uId == $_SESSION['admin_id']) {
$session_msg = 'The User you are trying to delete is currently been logged in';
$this->session->set_flashdata('failed', $session_msg);
redirect(base_url() . 'admin/users/list');
}
$sql = $this->Admin_model->delete_user($uId);
if ($sql) {
$this->session->set_flashdata('success', str_replace('%s', 'User', THE_DELETE_SUCCESS_MSG));
redirect(base_url() . 'admin/users/list');
} else {
$this->session->set_flashdata('failed', str_replace('%s', 'User', THE_DELETE_ERROR_MSG));
redirect(base_url() . 'admin/users/list');
}
}
// User Role Controller ends - 18-10-21 Afras Khan
// function assign_students()
// {
// if (!isset($_SESSION['admin_id']))
// redirect(base_url() . 'admin');
// if (!file_exists(APPPATH . 'views/admin/assign_students.php'))
// show_404();
// $data['currentURL'] = current_url();
// //get logo
// $data['logo'] = $this->Admin_model->get_logo();
//$data['school_info'] = $this->Admin_model->get_logo_from_setting();
// $data['title'] = " Assign Students";
// //get menu list
// $data['menulist'] = $this->Admin_model->get_adminMenu();
// $data['student_list'] = $this->Admin_model->get_general_result_details('students', 'DESC');
// $this->load->view('admin/header', $data);
// $this->load->view('admin/assign_students');
// $this->load->view('admin/footer');
// }
// SHANKAR code of Exam Questions creation Start from here 20-10-21
public function list_test_exam()
{
if (isset($_SESSION['admin_id'])) {
$crid = '';
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['course'] = $this->Admin_model->get_allcourse($crid);
if (isset($_POST['filterSubmit'])) {
// $filterName = $this->input->post('filter-name');
// $filterClass = $this->input->post('filter-classroom');
$course_id = $this->input->post('filter-course');
$e_date = $this->input->post('filter-Edate');
$s_date = $this->input->post('filter-Sdate');
$data['exam_data'] = $this->Admin_model->get_all_questions($s_date, $e_date, $course_id);
} else {
$data['exam_data'] = $this->Admin_model->get_all_questions();
}
$data['subject'] = $this->Admin_model->get_subjects($crid);
$data['teacher'] = $this->Admin_model->get_teacher($crid);
$data['current_nepali_date'] = date('Y-m-d', strtotime('+2 day', strtotime($this->nepali_current_date)));
$this->load->view('admin/header', $data);
$this->load->view('admin/examlist', $data);
$this->load->view('admin/footer');
}
}
public function get_sections_from_classroom($c_id)
{
$result = $this->Admin_model->get_sections_from_classroom($c_id);
// echo json_encode($result);
echo json_encode($result);
}
public function get_subject_teachers($s_id)
{
// $result = $this->Admin_model->get_s
$teacher_query = "SELECT ts.teacher_id ,ts.subject_id, ts.is_active FROM teacher_subjects ts WHERE ts.is_active='yes' AND ts.subject_id=$s_id";
$query2 = "SELECT ts.teacher_id ,ts.subject_id, ts.is_active, t.teacher_name FROM teacher_subjects ts LEFT JOIN teacher t ON t.id=ts.teacher_id WHERE ts.is_active='yes' AND ts.subject_id=$s_id";
$teacherList = $this->Admin_model->get_query_result($query2);
echo json_encode($teacherList);
}
public function get_subjects_from_course($course_id)
{
$result = $this->Admin_model->get_subjects_from_course($course_id);
// echo json_encode($result);
echo json_encode($result);
}
public function get_teacher_from_subject()
{
// var_dump($_POST);
$section_id = json_decode($this->input->post('section_id'));
$course_id = json_decode($this->input->post('course_id'));
$subject_id = json_decode($this->input->post('subject_id'));
// echo $course_id."<br>".$subject_id."<br>";
// print_r($section_id);
// echo "<br>";
// echo count($section_id);
$list_teachers = array();
for ($i = 0; $i < count($section_id); $i++) {
$teachers_name = $this->Admin_model->get_teacher_from_subject($course_id, $section_id[$i], $subject_id);
for ($j = 1; $j <= count($teachers_name); $j++) {
array_push($list_teachers, array(
'id' => $teachers_name[$j - 1]['id'],
'teacher_name' => $teachers_name[$j - 1]['teacher_name']
));
}
}
echo json_encode($list_teachers);
}
public function check_teacher_exam_exist()
{
// var_dump($_POST);
$section_id = json_decode($this->input->post('section_id'));
$course_id = json_decode($this->input->post('course_id'));
$subject_id = json_decode($this->input->post('subject_id'));
$teacher_id = json_decode($this->input->post('teacher_id'));
$exam_id = json_decode($this->input->post('exam_id'));
$result = $this->db->query('select section_id from questions where exam_id=' . $exam_id . ' and course_id = ' . $course_id . ' and subject_id = ' . $subject_id . ' and YEAR(exam_date) = YEAR(CURDATE()) ')->row_array();
$status = 'no';
if ($result) {
for ($i = 0; $i < count($section_id); $i++) {
if (in_array($section_id[$i], explode(',', $result['section_id'])))
$status = 'yes';
}
}
echo json_encode($status);
}
public function add_edit_exam_question()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$que_id = $this->uri->segment(3);
$view = $this->uri->segment(4);
$crid = '';
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['exam'] = $this->Admin_model->get_exam_name();
$data['course'] = $this->Admin_model->get_course($crid);
$data['nepali_curr_date'] = $this->nepali_current_date;
if (count($_POST) > 0) {
$start_time = $_POST['exam_date'] . ' ' . $_POST['start_time'];
$start_time = date('Y-m-d H:i:s', strtotime($start_time));
$end_time = $_POST['exam_date'] . ' ' . $_POST['end_time'];
$end_time = date('Y-m-d H:i:s', strtotime($end_time));
if ($que_id > 0) {
$data = array(
'exam_id' => $_POST['exam_name'],
'course_id' => $_POST['course_name'],
'section_id' => implode(",", $_POST['section']),
'subject_id' => $_POST['subject_id'],
'teacher_id' => $_POST['teacher'],
'exam_date' => date('Y-m-d', strtotime($_POST['exam_date'])),
'exam_starttime' => $start_time,
'exam_endtime' => $end_time,
'exam_duration' => $_POST['exam_duration'],
'exam_question_format' => $_POST['mrks_array'],
'total_marks' => $_POST['total_marks'],
'passing_marks' => $_POST['passing_marks'],
'published' => 'yes',
'modified' => $this->nepali_current_date
);
} else {
$data = array(
'exam_id' => $_POST['exam_name'],
'course_id' => $_POST['course_name'],
'section_id' => implode(",", $_POST['section']),
'subject_id' => $_POST['subject_id'],
'teacher_id' => $_POST['teacher'],
'exam_date' => date('Y-m-d', strtotime($_POST['exam_date'])),
'exam_starttime' => $start_time,
'exam_endtime' => $end_time,
'exam_duration' => $_POST['exam_duration'],
'exam_question_format' => $_POST['mrks_array'],
'total_marks' => $_POST['total_marks'],
'passing_marks' => $_POST['passing_marks'],
'published' => 'yes',
'created' => $this->nepali_current_date
);
}
$sql = $this->Admin_model->add_exam_exam_paper($que_id, $data);
if (($sql) && $que_id > 0) {
$this->session->set_flashdata('success', str_replace('%s', 'Exam', THE_UPDATE_SUCCESS_MSG));
// $this->session->set_flashdata('success', 'Section has been updated successfully');
redirect(base_url() . 'admin/test-exam-list');
} else if ($sql) {
$this->session->set_flashdata('success', str_replace('%s', 'new exam', THE_ADD_SUCCESS_MSG));
// $this->session->set_flashdata('success', 'Section has been addedd successfully');
redirect(base_url() . 'admin/test-exam-list');
} else {
$this->session->set_flashdata('danger', str_replace('%s', 'Exam', THE_ADD_ERROR_MSG));
// $this->session->set_flashdata('failed', 'Section updation failed');
redirect(base_url() . 'admin/test-exam-list');
}
}
$data['title'] = 'Add New Question Paper';
$data['result'] = '';
if ($que_id > 0) {
$data['title'] = 'Edit Question Paper';
$data['result'] = $this->Admin_model->get_all_questions($s_date = '', $e_date = '', $crid = '', $que_id);
$sections = explode(",", $data['result']['section_id']);
$getSection = array();
for ($i = 0; $i < count($sections); $i++) {
$whereClause = array('id' => $sections[$i]);
$sec = $this->Admin_model->get_section_details($whereClause);
array_push($getSection, $sec);
}
$data['section_data'] = $getSection;
}
$data['e_id'] = $que_id;
$data['view'] = $view;
if ($view == 1) {
$data['title'] = 'View Exam Questions';
}
// echo"<pre>";
// print_r($data['section_data']);
// print_r($data['result']);
// exit();
$this->load->view('admin/header', $data);
$this->load->view('admin/exam-add-edit', $data);
$this->load->view('admin/footer');
}
// SHANKAR code of Exam Questions creation End here 20-10-21
// Admin Forgot Password Controller - 23-10-2021 Afras Khan
public function ajax_send_password_email()
{
$email = strtolower($this->input->post('email'));
$query = $this->Admin_model->get_table_info('admin', array('email =' => $email));
if (empty($query)) {
echo 'failed';
} else {
$this->load->helper('common_helper');
$Encoded_email = urlsafe_b64encode($email);
$data = array(
"admin_name" => $query[0]['admin_name'],
"reset_link" => base_url() . "admin/reset-password/" . $Encoded_email,
"baseurl" => base_url()
);
$msg = $this->load->view('admin/forgot-password-template', $data, TRUE);
$this->load->config('email');
$from = $this->config->item('smtp_user');
$this->email->from($from);
$this->email->set_newline("\r\n");
$this->email->to($email);
$this->email->subject('Reset Password');
$this->email->message($msg);
if ($this->email->send()) {
echo 'success';
} else {
echo 'mailErr';
}
}
}
public function reset_admin_password($email)
{
$this->load->helper('common_helper');
$decodedEmailId = urlsafe_b64decode($email);
if (!file_exists(APPPATH . 'views/admin/forgot-password.php'))
show_404();
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['id'] = $this->db->get_where('admin', array('email' => $decodedEmailId))->row()->id;
$data['encodedKey'] = $email;
if (count($_POST) > 0) {
$admin_id = $this->input->post('id');
$pwd = md5($this->input->post('password'));
$data = array('password' => $pwd);
$query = $this->Admin_model->update_admin_password($admin_id, $data);
if ($query) {
$this->session->set_flashdata('success', str_replace('%s', 'Password', THE_UPDATE_SUCCESS_MSG));
redirect(base_url() . 'admin/');
} else {
$this->session->set_flashdata('failed', str_replace('%s', 'Password', THE_UPDATE_FAILED_MSG));
redirect(base_url() . 'admin/reset-password/' . $email);
}
exit();
}
$this->load->view('admin/header', $data);
$this->load->view('admin/reset-password');
$this->load->view('admin/footer');
}
public function forgot_password()
{
if (!file_exists(APPPATH . 'views/admin/forgot-password.php'))
show_404();
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$this->load->view('admin/header', $data);
$this->load->view('admin/forgot-password');
$this->load->view('admin/footer');
}
// Admin Forgot Password Controller Ends - 23-10-2021 Afras Khan
function assign_students($classroomId)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/assign_students.php'))
show_404();
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$classroom_name = $this->db->get_where('classroom', array('id' => $classroomId))->row()->classroom_name;
$data['title'] = "Student List of " . $classroom_name;
$data['classroomid'] = $classroomId;
$data['back_url'] = urlsafe_b64encode($classroomId . '-qqcksbvlwierhwjerw');
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
// $query = "SELECT sb.id as stud_batch_id, sb.roll_no, sb.batch_id,sb.classroom_id,s.* FROM student_batch sb JOIN students s ON sb.student_id=s.id AND sb.batch_id = s.batch_id WHERE sb.classroom_id=$classroomId";
// $query = "SELECT sb.id as stud_batch_id, sb.roll_no, sb.batch_id,sb.classroom_id,s.* FROM student_batch sb JOIN students s ON sb.student_id=s.id AND sb.batch_id = s.batch_id JOIN classroom cl ON cl.id=sb.classroom_id WHERE cl.course_id=s.course AND sb.classroom_id=$classroomId";
$query = "SELECT sb.id as stud_batch_id, sb.roll_no, sb.batch_id as student_batch, sb.classroom_id, s.* FROM student_batch sb LEFT JOIN students s ON sb.student_id=s.id WHERE sb.batch_id = " . $data['school_info']['batch_id'] . " AND sb.classroom_id=$classroomId ORDER BY sb.roll_no";
// exit;
$data['student_list'] = $this->Admin_model->get_query_result($query);
$this->load->view('admin/header', $data);
$this->load->view('admin/assign_students');
$this->load->view('admin/footer');
}
function assign_classroom($classroomId)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/assign_classroom.php'))
show_404();
$classroom_id = (int)str_replace("-qqcksbvlwierhwjerw", '', urlsafe_b64decode($classroomId));
$check_classroom_id = $this->db->query('select * from classroom where id =' . $classroom_id)->row_array();
if (empty($check_classroom_id))
redirect(base_url() . 'admin');
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['title'] = "Assign Students";
$data['course_id'] = $check_classroom_id['course_id'];
$data['back_url'] = urlsafe_b64encode($check_classroom_id['id'] . '-qqcksbvlwierhwjerw');
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['batch_list'] = $this->Admin_model->get_general_result_details('batch', 'DESC', array('is_active' => 'yes'));
$data['course_list'] = $this->Admin_model->get_general_result_details('course', 'DESC', array('is_active' => 'yes', 'id' => $data['course_id']));
$data['student_list'] = $this->Admin_model->get_general_result_details('students', 'DESC', array('assign_status' => 'no', 'is_active' => 'yes', 'course' => $data['course_id']));
$data['section_list'] = $this->Admin_model->get_general_result_details('section', 'DESC', array('is_active' => 'yes'));
$this->load->view('admin/header', $data);
$this->load->view('admin/assign_classroom');
$this->load->view('admin/footer');
}
public function getsectionsbyCourse()
{
$result2 = array();
$courseId = $_REQUEST['courseid'];
$query = "SELECT section_id FROM course_sections WHERE course_id=$courseId";
// SELECT s.section_name,s.id as section_id FROM course_sections cs LEFT JOIN section s ON s.id=cs.section_id WHERE cs.course_id =$courseId ORDER BY s.id DESC
$result = $this->Admin_model->get_query_result($query);
if (count($result) > 0) {
foreach ($result as $value) {
$sectionId = (!empty($value['section_id'])) ? $value['section_id'] : 0;
$query2 = "SELECT s.section_name,cl.section_id as section_id FROM classroom cl LEFT JOIN section s ON s.id=cl.section_id WHERE cl.course_id =$courseId AND cl.section_id=$sectionId ORDER BY s.id DESC";
$rst = $this->Admin_model->get_query_row($query2);
if ($rst != '') {
$result2[] = $rst;
}
}
if (count($result2) > 0) {
echo json_encode($result2);
} else {
$result2[] = array('section_id' => null, 'section_name' => 'No sections Found');
echo json_encode($result2);
}
} else {
$result[] = array('section_id' => null, 'section_name' => 'No sections Found');
echo json_encode($result);
}
}
public function ajaxstudentfilters()
{
extract($_POST);
// Array ( [batch_filter] => 2 [course_filter] => 1 [section_filter] => )
$where = array();
if (isset($_POST['batch_filter']) && ($_POST['batch_filter'] != '')) {
$where['batch_id'] = $batch_filter;
}
if (isset($_POST['course_filter']) && ($_POST['course_filter'] != '')) {
$where['course'] = $course_filter;
}
$where['assign_status'] = 'no';
$data['student_list'] = $this->Admin_model->get_general_result_details('students', 'DESC', $where);
// echo $this->db->last_query();
$unassigned_list = $this->load->view('admin/view-unassigned-students', $data, TRUE);
echo $unassigned_list;
}
public function assignedtoclassroom()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/assign_classroom.php'))
show_404();
// print_r($this->input->post());
if ($this->input->post('assignto') == 'assigntoclassroom') {
$this->form_validation->set_rules('course_filter', 'Course', 'required');
$this->form_validation->set_rules('section_filter', 'Section', 'required');
$this->form_validation->set_rules('batch_filter', 'Batch', 'required');
$this->form_validation->set_rules('student_list[]', 'Student List', 'required');
// $this->form_validation->set_message('check', 'Please Select Students ');
$check_classroom_id = $this->db->query('select * from classroom where course_id =' . $this->input->post('course_filter'))->row_array();
$back_url = urlsafe_b64encode($check_classroom_id['id'] . '-qqcksbvlwierhwjerw');
if ($this->form_validation->run() == FALSE) {
$this->assign_classroom($back_url);
} else {
$failed = array();
$get_class_id = '';
if (count($this->input->post()) > 0) {
$studentids = $this->input->post('student_list');
$batchId = $this->input->post('batch_filter');
$courseId = $this->input->post('course_filter');
$sectionId = $this->input->post('section_filter');
$courseName = $this->db->get_where('course', array('id' => $courseId))->row()->course_name;
$sectionName = $this->db->get_where('section', array('id' => $sectionId))->row()->section_name;
$classrom = $this->Admin_model->get_general_row_details('classroom', 'DESC', array('course_id' => $courseId, 'section_id' => $sectionId, 'is_active' => 'yes'));
if ($classrom != '') {
$get_class_id = $classrom['id'];
foreach ($studentids as $stud_id) {
$insertData = array(
'student_id' => $stud_id,
'batch_id' => $batchId,
'classroom_id' => $classrom['id']
);
$results = $this->Admin_model->get_general_row_details('student_batch', 'DESC', array('student_id' => $stud_id, 'batch_id' => $batchId, 'classroom_id' => $classrom['id']));
if ($results != '') {
$studName = $this->db->get_where('students', array('id' => $results['student_id']))->row()->name;
$failed[] = $studName;
} else {
$roll_no = $this->db->query('select roll_no from student_batch where batch_id=' . $batchId . ' and classroom_id =' . $classrom['id'] . ' and is_active ="yes" order by roll_no DESC')->row_array();
if (!empty($roll_no)) {
$insertData['roll_no'] = $roll_no['roll_no'] + 1;
} else {
$insertData['roll_no'] = 1;
}
$last_id = $this->Admin_model->insert_assign_classroom($insertData);
if ($last_id > 0) {
$this->db->where(array('id' => $stud_id, 'is_active' => 'yes', 'assign_status' => 'no'));
$this->db->update('students', array('assign_status' => 'yes', 'modified' => $this->nepali_current_date));
}
$this->session->set_flashdata('success_msg', "The Students are Successfully Assigned to Classroom");
}
}
$faillist = implode(',', $failed);
if (!empty($faillist)) {
$this->session->set_flashdata('error_msg', str_replace('%s', $faillist, CLASSROOM_ALREADY_ASSIGNED_MSG));
}
} else {
$this->session->set_flashdata('error_msg', str_replace('%s', $courseName . ' and ' . $sectionName, CLASSROOM_NOTEXISTS_MSG));
}
}
if (empty($get_class_id))
redirect('admin/dashboard');
else
redirect('admin/assign-students/' . $get_class_id);
}
}
}
public function remove_classroom_student($studId, $batchId, $classroomID)
{
$condition = array(
'student_id' => $studId,
'batch_id' => $batchId,
'classroom_id' => $classroomID
);
$result = $this->Admin_model->delete_row('student_batch', $condition);
if ($result) {
$this->db->set('assign_status', 'no');
$this->db->where(array('id' => $studId, 'batch_id' => $batchId, 'assign_status' => 'yes'));
$rst = $this->db->update('students');
if ($rst)
$this->session->set_flashdata('success_msg', str_replace('%s', 'Student', THE_DELETE_SUCCESS_MSG));
else
$this->session->set_flashdata('error_msg', str_replace('%s', 'Student', THE_DELETE_ERROR_MSG));
} else {
$this->session->set_flashdata('error_msg', str_replace('%s', 'Student', THE_DELETE_ERROR_MSG));
}
redirect('admin/assign-students/' . $classroomID);
}
public function getSubjectsByCourse()
{
$courseID = $_REQUEST['course_id'];
$subject_query = "SELECT s.subject_name,s.id FROM course_subjects cs LEFT JOIN subject s ON s.id=cs.subject_id WHERE cs.course_id=$courseID";
$result['subjects'] = $this->Admin_model->get_query_result($subject_query);
echo json_encode($result);
}
public function getTeacherbysubjects()
{
$subjectId = $_REQUEST['subject_id'];
$teaher_query = "SELECT t.id as teach_id,t.teacher_name FROM teacher_subjects ts LEFT JOIN teacher t ON t.id=ts.teacher_id WHERE ts.subject_id=$subjectId";
$data['teachers'] = $this->Admin_model->get_query_result($teaher_query);
echo json_encode($data);
}
//shankar code for teacher view 27-10-2021
public function view_teacher($tid)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['teacher_info'] = $this->Admin_model->get_teacher($tid);
$data['teacher_onlinesession'] = array();
$counter = 0;
(!empty($data['monday']) && isset($data['monday'])) ? ($counter > count($data['monday'])) ? '' : $counter = count($data['monday']) : '';
(!empty($data['tuesday']) && isset($data['tuesday'])) ? ($counter > count($data['tuesday'])) ? '' : $counter = count($data['tuesday']) : '';
(!empty($data['wednesday']) && isset($data['wednesday'])) ? ($counter > count($data['wednesday'])) ? '' : $counter = count($data['wednesday']) : '';
(!empty($data['thursday']) && isset($data['thursday'])) ? ($counter > count($data['thursday'])) ? '' : $counter = count($data['thursday']) : '';
(!empty($data['friday']) && isset($data['friday'])) ? ($counter > count($data['friday'])) ? '' : $counter = count($data['friday']) : '';
(!empty($data['saturday']) && isset($data['saturday'])) ? ($counter > count($data['saturday'])) ? '' : $counter = count($data['saturday']) : '';
(!empty($data['sunday']) && isset($data['sunday'])) ? ($counter > count($data['sunday'])) ? '' : $counter = count($data['sunday']) : '';
$data['count'] = $counter;
$data['course_subject'] = $this->Admin_model->get_course_subjects_teacher($tid, 1);
foreach ($data['course_subject'] as $key) {
$data['all_co_sub'] = $this->Admin_model->get_course_subjects_teacher($tid, $key['classroom_id']);
}
$this->load->view('admin/header', $data);
$this->load->view('admin/view-teacher');
$this->load->view('admin/footer');
}
//shankar code for teacher view 27-10-2021
// Fee Course - 10-11-2021 Afras Khan
public function fee_course()
{
// dd($_POST);
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/fee-course.php'))
show_404();
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['current_batch'] = $data['school_info']['batch_id'];
$data['selected_batch'] = $data['current_batch'];
if ($this->input->post('filterSubmit') == "Filter") {
$this->form_validation->set_rules('filter-batch', 'Batch', 'required');
$this->form_validation->set_rules('filter-course', 'Course', 'required');
// $this->form_validation->set_rules('filter-feeType', 'Fees Name', 'required');
$course_id = (isset($_POST['filter-course']) && !empty($_POST['filter-course'])) ? $_POST['filter-course'] : 0;
$batch = (isset($_POST['filter-batch']) && !empty($_POST['filter-batch'])) ? $_POST['filter-batch'] : 0;
$feeType = (isset($_POST['filter-feeType']) && !empty($_POST['filter-feeType'])) ? $_POST['filter-feeType'] : 0;
$feeName = (isset($_POST['filter-feesName']) && !empty($_POST['filter-feesName'])) ? $_POST['filter-feesName'] : '';
$data['courseId'] = $course_id;
$data['bacth_id'] = $batch;
$data['feeType_id'] = $feeType;
$data['feeName'] = $feeName;
$data['selected_batch'] = $data['bacth_id'];
if (!$this->form_validation->run() == FALSE) {
$where = '';
if ($feeType > 0)
$where .= " AND ft.id = $feeType";
if (strlen($feeName) > 0)
$where .= " AND cf.fee_values like '%$feeName%'";
$sql = "SELECT b.b_name as batch, c.course_name as course, ft.feetype_name as feetype, cf.* FROM course_fees cf inner join batch b on cf.batch_id = b.id INNER JOIN course c on cf.course_id = c.id INNER JOIN fee_types ft on cf.fees_type = ft.id WHERE b.id = $batch AND c.id = $course_id $where ORDER BY cf.id ASC";
$data['course_fees'] = $this->Admin_model->get_table_info('course_fees', '', $sql);
}
}
if (!empty($data['course_fees']) && isset($data['course_fees'])) {
foreach ($data['course_fees'] as $key => $value) {
$data['course_fees'][$key]['due_date'] = date('Y-m-d', strtotime($value['due_date']));
}
}
$data['course'] = $this->db->query("select * from course WHERE is_active='yes'")->result_array();
$data['batch'] = $this->Admin_model->get_batch();
$data['fee_types'] = $this->db->query("select * from fee_types WHERE is_active='yes'")->result_array();
$this->load->view('admin/header', $data);
$this->load->view('admin/fee-course.php');
$this->load->view('admin/footer');
}
public function fee_types()
{
// dd($_POST);
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/fee-types.php'))
show_404();
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['current_batch'] = $data['school_info']['batch_id'];
$data['selected_batch'] = $data['current_batch'];
$data['title'] = 'Fee Types';
$data['fee_types'] = $this->db->query("select * from fee_types")->result_array();
if (ACCOUNTING) :
foreach ($data['fee_types'] as $feeKey => &$fee) {
$fee['default_account'] = $this->accounting->fetchMappedAccount('fee_types', $fee['id']) ?? "Not Set"; //HERE FETCH DEFAULT ACCOUNT FROM MAPPING TABLE
}
endif;
if ($_POST > 0) {
if (isset($_POST['addFeeType']) && ($_POST['addFeeType'] == 'Add')) {
$feeTitle = $_POST['title'];
$isUnique = $this->Admin_model->get_unique_name_main_db('feetype_name', $feeTitle, 'fee_types');
if ($isUnique) {
$in_data['feetype_name'] = $feeTitle;
$in_data['is_active'] = 'yes';
$in_data['created'] = $this->nepali_current_date;
$in_data['modified'] = $this->nepali_current_date;
$this->db->insert('fee_types', $in_data);
$feetype_id = $this->db->insert_id();
if (ACCOUNTING) :
$mappedAccountID = $_POST['account_id'];
$this->accounting->updateFeeTypeAccountMapping($feetype_id, $mappedAccountID);
endif;
$this->session->set_flashdata('success', str_replace('%s', 'Fee Type', 'New fee type has been added.'));
} else {
$this->session->set_flashdata('danger', str_replace('%s', 'Fee Type', 'Fee name already exist.'));
}
redirect(base_url() . 'admin/fee-types');
} else if (isset($_POST['updateFeeType']) && ($_POST['updateFeeType'] == 'Update')) {
// dd($_POST);
$feeId = $_POST['feeId'];
$feeTitle = $_POST['title'];
$isUnique = $this->Admin_model->update_unique_name_main_db('feetype_name', $feeTitle, 'fee_types', $feeId);
if ($isUnique) {
$up_data['feetype_name'] = $feeTitle;
$up_data['is_active'] = $_POST['is_active'];
$up_data['modified'] = $this->nepali_current_date;
$this->db->where('id', $feeId);
$this->db->update('fee_types', $up_data);
$feetype_id = $feeId;
if (ACCOUNTING) :
$mappedAccountID = $_POST['account_id'];
$this->accounting->updateFeeTypeAccountMapping($feetype_id, $mappedAccountID);
endif;
$this->session->set_flashdata('success', str_replace('%s', 'Fee Type', 'Fee details has been updated successfully.'));
} else {
$this->session->set_flashdata('danger', str_replace('%s', 'Fee Type', 'Fee name already exist.'));
}
redirect(base_url() . 'admin/fee-types');
}
}
$this->load->view('admin/header', $data);
$this->load->view('admin/fee-types.php');
$this->load->view('admin/footer');
}
public function expense_types()
{
// dd($_POST);
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/expense-types.php'))
show_404();
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['current_batch'] = $data['school_info']['batch_id'];
$data['selected_batch'] = $data['current_batch'];
$data['title'] = 'Expense Types';
$data['expense_types'] = $this->db->query("select * from expense_types")->result_array();
if (ACCOUNTING) :
foreach ($data['expense_types'] as $feeKey => &$fee) {
$fee['default_account'] = $this->accounting->fetchMappedAccount('expense_types', $fee['id']) ?? "Not Set"; //HERE FETCH DEFAULT ACCOUNT FROM MAPPING TABLE
}
endif;
if ($_POST > 0) {
if (isset($_POST['addExpenseType']) && ($_POST['addExpenseType'] == 'Add')) {
$feeTitle = $_POST['title'];
$isUnique = $this->Admin_model->get_unique_name_main_db('name', $feeTitle, 'expense_types');
if ($isUnique) {
$in_data['name'] = $feeTitle;
$in_data['status'] = 'yes';
$in_data['created_on'] = $this->nepali_current_date;
$in_data['modified_on'] = $this->nepali_current_date;
$this->db->insert('expense_types', $in_data);
$feetype_id = $this->db->insert_id();
if (ACCOUNTING) :
$mappedAccountID = $_POST['account_id'];
$this->accounting->updateExpenseTypeAccountMapping($feetype_id, $mappedAccountID);
endif;
$this->session->set_flashdata('success', str_replace('%s', 'Expense Type', 'New expense type has been added.'));
} else {
$this->session->set_flashdata('danger', str_replace('%s', 'Expense Type', 'Expense name already exist.'));
}
redirect(base_url() . 'admin/expense-types');
} else if (isset($_POST['updateExpenseType']) && ($_POST['updateExpenseType'] == 'Update')) {
// dd($_POST);
$expenseId = $_POST['expenseId'];
$feeTitle = $_POST['title'];
$isUnique = $this->Admin_model->update_unique_name_main_db('name', $feeTitle, 'expense_types', $expenseId);
if ($isUnique) {
$up_data['name'] = $feeTitle;
$up_data['status'] = $_POST['is_active'];
$up_data['modified_on'] = $this->nepali_current_date;
$this->db->where('id', $expenseId);
$this->db->update('expense_types', $up_data);
$expensetype_id = $expenseId;
if (ACCOUNTING) :
$mappedAccountID = $_POST['account_id'];
$this->accounting->updateExpenseTypeAccountMapping($expensetype_id, $mappedAccountID);
endif;
$this->session->set_flashdata('success', str_replace('%s', 'Expense Type', 'Expense details has been updated successfully.'));
} else {
$this->session->set_flashdata('danger', str_replace('%s', 'Expense Type', 'Expense name already exist.'));
}
redirect(base_url() . 'admin/expense-types');
}
}
$this->load->view('admin/header', $data);
$this->load->view('admin/expense-types.php');
$this->load->view('admin/footer');
}
// public function add_edit_fee_course($feesId)
// {
// // dd($_POST);
// if (!isset($_SESSION['admin_id']))
// redirect(base_url() . 'admin');
// if (!file_exists(APPPATH . 'views/admin/ae_fee_course.php'))
// show_404();
// $checkIfExists = $this->Admin_model->get_table_info('course_fees', array('id' => $feesId));
// if (empty($checkIfExists) && $feesId != 0) {
// $this->session->set_flashdata('failed', 'There is no fees with selected id');
// redirect(base_url() . 'admin/fee-course');
// }
// $data['fees_id'] = $feesId;
// $data['school_info'] = $this->Admin_model->get_logo_from_setting();
// $batches = $this->Admin_model->get_table_info('batch', array('is_active' => 'yes'));
// $data['batches'] = $batches;
// $data['current_batch'] = $data['school_info']['batch_id'];
// // dd($data['current_batch']);
// $data['payment_types'] = $this->Admin_model->get_table_info('payment_types', '', '', 'ASC');
// $courses = $this->Admin_model->get_table_info('course', '', '', 'ASC');
// $data['courses'] = $courses;
// $data['feeTypes'] = $this->Admin_model->get_table_info('fee_types', array('is_active' => 'yes'), '', 'ASC');
// if (count($_POST) > 0) {
// // dd($_POST);
// $grouped = isset($_POST['grouped']) ? 'yes' : 'no';
// foreach ($_POST as $key => $value) {
// if ($key == 'englishdate' || $key == 'nepalidate') {
// foreach ($value as $key2 => $value2) {
// if ($value2 == '') {
// unset($_POST[$key][$key2]);
// }
// }
// }
// if (!$_POST[$key]) {
// unset($_POST[$key]);
// }
// }
// // dd($_POST);
// $batch_id = $this->input->post('batch_id');
// $course_id = $this->input->post('course_id');
// $hostel_plan = NULL;
// if (isset($_POST['hostel_plan_id'])) {
// $hostel_plan = $this->input->post('hostel_plan_id');
// }
// $route_id = NULL;
// if (isset($_POST['new_route_id'])) {
// $route_id = $this->input->post('new_route_id');
// }
// if (array_key_exists('common_bs_due_date', $_POST)) {
// $due_date = $this->input->post('common_bs_due_date');
// } else if (array_key_exists('common_ad_due_date', $_POST)) {
// $due_date = $this->input->post('common_ad_due_date');
// } else {
// if (array_key_exists('bsdate', $_POST)) {
// $due_date = $_POST['bsdate'][0];
// }
// if (array_key_exists('englishdate', $_POST)) {
// $due_date = $_POST['englishdate'][0];
// }
// }
// $due_date = date('Y-m-d H:i:s', strtotime($due_date));
// $fees_type = $this->input->post('feetype');
// $fees_name = array();
// for ($i = 0; $i < count($_POST['feename']); $i++) {
// $fees_name[$i]['name'] = $_POST['feename'][$i];
// $fees_name[$i]['amount'] = $_POST['feeamount'][$i];
// }
// $fee_values = implode(',', $_POST['feename']);
// $fees_name = json_encode($fees_name);
// $amount = 0;
// foreach ($_POST['feeamount'] as $key => $value) {
// $amount += $value;
// }
// $nowDate = $this->nepali_current_date;
// // Adding Data Inside POST
// if ($feesId == 0) {
// $insertFlag = false;
// foreach ($course_id as $key => $value) {
// $allData = array();
// if ($fees_type == 8) { // For Monthly Fee
// foreach ($_POST['feename'] as $n => $e) {
// $fees_name_inside = array();
// $fees_name_inside[0]['name'] = $e;
// $fees_name_inside[0]['amount'] = $_POST['feeamount'][$n];
// $fees_name_inside = json_encode($fees_name_inside);
// $allData[] = array(
// 'batch_id' => $batch_id,
// 'course_id' => $value,
// 'fees_type' => $fees_type,
// 'fees_name' => $fees_name_inside,
// 'amount' => $_POST['feeamount'][$n],
// 'due_date' => date('Y-m-d H:i:s', strtotime($_POST['bsdate'][$n])),
// 'grouped' => $grouped,
// 'fee_values' => $_POST['feename'][$n],
// 'hostel_plan_id' => $hostel_plan,
// 'route_id' => $route_id,
// 'created' => $nowDate
// );
// }
// } else if ($fees_type == 4) { // For Transport Fee
// foreach ($_POST['feename'] as $n => $e) {
// $fees_name_route_inside = array();
// $fees_name_route_inside[0]['name'] = $e;
// $fees_name_route_inside[0]['amount'] = $_POST['feeamount'][$n];
// $fees_name_route_inside = json_encode($fees_name_route_inside);
// $allData[] = array(
// 'batch_id' => $batch_id,
// 'course_id' => $value,
// 'fees_type' => $fees_type,
// 'fees_name' => $fees_name_route_inside,
// 'amount' => $_POST['feeamount'][$n],
// 'due_date' => date('Y-m-d H:i:s', strtotime($_POST['bsdate'][$n])),
// 'grouped' => $grouped,
// 'fee_values' => $_POST['feename'][$n],
// 'hostel_plan_id' => $hostel_plan,
// 'route_id' => $route_id,
// 'created' => $nowDate
// );
// // original code End HERE
// }
// } else {
// $allData[] = array(
// 'batch_id' => $batch_id,
// 'course_id' => $value,
// 'fees_type' => $fees_type,
// 'fees_name' => $fees_name,
// 'amount' => $amount,
// 'due_date' => $due_date,
// 'grouped' => $grouped,
// 'fee_values' => $fee_values,
// 'hostel_plan_id' => $hostel_plan,
// 'route_id' => $route_id,
// 'created' => $nowDate
// );
// }
// $insertQuery = $this->db->insert_batch('course_fees', $allData);
// if ($insertQuery) {
// $insertFlag = true;
// } else {
// $insertFlag = false;
// }
// }
// if ($insertFlag) {
// $this->session->set_flashdata('success', str_replace('%s', 'Fees', THE_ADD_SUCCESS_MSG));
// redirect(base_url() . 'admin/fee-course');
// } else {
// $this->session->set_flashdata('failed', str_replace('%s', 'Fees', THE_ADD_ERROR_MSG));
// redirect(base_url() . 'admin/fee-course');
// }
// }
// if ($feesId > 0) { // Updating Data Inside POST
// $pay['course_fee_id'] = $feesId;
// $check_payment = $this->db->get_where('students_online_payments', $pay)->row();
// if (!empty($check_payment)) {
// $this->session->set_flashdata('failed', 'Fees cannot be modified as a payment has already been made');
// redirect(base_url() . 'admin/fee-course');
// }
// $allData = array(
// 'batch_id' => $batch_id,
// 'course_id' => $course_id,
// 'fees_type' => $fees_type,
// 'fees_name' => $fees_name,
// 'amount' => $amount,
// 'due_date' => $due_date,
// 'grouped' => $grouped,
// 'fee_values' => $fee_values,
// 'hostel_plan_id' => $hostel_plan,
// 'route_id' => $route_id,
// 'modified' => $nowDate
// );
// // dd($allData);
// $checkIfFeeRelated = $this->Admin_model->get_table_info('students_online_payments', array('course_fee_id' => $feesId));
// if (empty($checkIfFeeRelated)) {
// $updateQuery = $this->Admin_model->add_edit_fee_course($feesId, $allData);
// if ($updateQuery) {
// $this->session->set_flashdata('success', str_replace('%s', 'Fees', THE_UPDATE_SUCCESS_MSG));
// redirect(base_url() . 'admin/fee-course');
// } else {
// $this->session->set_flashdata('failed', str_replace('%s', 'Fees', THE_UPDATE_ERROR_MSG));
// redirect(base_url() . 'admin/ae-fee-course/' . $feesId);
// }
// } else {
// $this->session->set_flashdata('failed', 'This Fee cannot be edited as installments have already been created');
// redirect(base_url() . 'admin/fee-course');
// }
// }
// }
// if ($feesId > 0) { // Display to AE_EDIT PAGE
// $Feesql = "SELECT b.b_name as batch, c.course_name as course,ft.id as fee_id, ft.feetype_name as feetype, cf.* FROM course_fees cf inner join batch b on cf.batch_id = b.id INNER JOIN course c on cf.course_id = c.id INNER JOIN fee_types ft on cf.fees_type = ft.id WHERE cf.id = '$feesId' ORDER BY cf.id DESC";
// $checkCourseFee = $this->Admin_model->get_table_info('course_fees', '', $Feesql);
// if (empty($checkCourseFee) && $feesId != 0) {
// $this->session->set_flashdata('failed', 'There is no course fee with selected id');
// redirect(base_url() . 'admin/fee-course');
// }
// // start from here by shivuuu
// if ($checkCourseFee[0]['fees_type'] == 4) {
// $transport_db = $this->load->database('erisnClassroom_bts', TRUE);
// $batch_routes = $transport_db->query('SELECT * from bt_batch_routes where batch_id = ' . $checkCourseFee[0]['batch_id'])->row_array();
// if (!empty($batch_routes)) {
// $route_ids = explode(',', $batch_routes['route_ids']);
// $whereClause = '';
// foreach ($route_ids as $bkey => $bvalue) {
// if ($bkey == 0) {
// $whereClause .= "id = '$bvalue'";
// } else {
// $whereClause .= " or id = '$bvalue'";
// }
// }
// $data['edit_route_list'] = $transport_db->query('SELECT * from bt_routes where ' . $whereClause)->result_array();
// }
// }
// // end Here by shivakumar
// $data['course_fees'] = $checkCourseFee;
// // dd($data['course_fees']);
// foreach ($data['course_fees'] as $key => $value) {
// $data['course_fees'][$key]['due_date'] = date('Y-m-d', strtotime($value['due_date']));
// }
// }
// // dd($data['course_fees']);
// $data['currentURL'] = current_url();
// $data['nepali_months'] = $this->db->query("SELECT * FROM nepali_months")->result_array();
// $data['logo'] = $this->Admin_model->get_logo();
// $data['school_info'] = $this->Admin_model->get_logo_from_setting();
// $data['menulist'] = $this->Admin_model->get_adminMenu();
// $data['check_fees_type'] = (!empty($coursebyfees)) ? $coursebyfees : '';
// // dd($data);
// $this->load->view('admin/header', $data);
// $this->load->view('admin/ae_fee_course.php');
// $this->load->view('admin/footer');
// }
public function add_edit_fee_course($feesId)
{
// dd($_POST);
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/ae_fee_course.php'))
show_404();
$checkIfExists = $this->Admin_model->get_table_info('course_fees', array('id' => $feesId));
if (
empty($checkIfExists) && $feesId != 0
) {
$this->session->set_flashdata('failed', 'There is no fees with selected id');
redirect(base_url() . 'admin/fee-course');
}
$data['fees_id'] = $feesId;
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$batches = $this->Admin_model->get_table_info('batch', array('is_active' => 'yes'));
$data['batches'] = $batches;
$data['current_batch'] = $data['school_info']['batch_id'];
// dd($data['current_batch']);
$data['payment_types'] = $this->Admin_model->get_table_info('payment_types', '', '', 'ASC');
$courses = $this->Admin_model->get_table_info('course', '', '', 'ASC');
$data['courses'] = $courses;
$data['feeTypes'] = $this->Admin_model->get_table_info('fee_types', array('is_active' => 'yes'), '', 'ASC');
if (count($_POST) > 0) {
// dd($_POST);
$grouped = isset($_POST['grouped']) ? 'yes' : 'no';
foreach ($_POST as $key => $value) {
if (
$key == 'englishdate' || $key == 'nepalidate'
) {
foreach ($value as $key2 => $value2) {
if ($value2 == '') {
unset($_POST[$key][$key2]);
}
}
}
if (!$_POST[$key]) {
unset($_POST[$key]);
}
}
// dd($_POST);
$batch_id = $this->input->post('batch_id');
$course_id = $this->input->post('course_id');
$hostel_plan = NULL;
if (isset($_POST['hostel_plan_id'])) {
$hostel_plan = $this->input->post('hostel_plan_id');
}
$route_id = NULL;
if (isset($_POST['new_route_id'])) {
$route_id = $this->input->post('new_route_id');
}
// if (array_key_exists('common_bs_due_date', $_POST)) {
// $due_date = $this->input->post('common_bs_due_date');
// } else if (array_key_exists('common_ad_due_date', $_POST)) {
// $due_date = $this->input->post('common_ad_due_date');
// } else {
// if (array_key_exists('bsdate', $_POST)) {
// $due_date = $_POST['bsdate'][0];
// }
// if (array_key_exists('englishdate', $_POST)) {
// $due_date = $_POST['englishdate'][0];
// }
// }
if (isset($_POST['bsdate'][0])) {
$due_date = date('Y-m-d H:i:s', strtotime($_POST['bsdate'][0]));
} else {
$due_date = '';
}
$fees_type = $this->input->post('feetype');
$batch_detail = $this->db->query("SELECT * FROM batch WHERE id = " . $_POST['batch_id'])->row_array();
$fees_name = array();
// dd($_POST);
if (isset($_POST['feename']) && !empty($_POST['feename'][0])) {
for ($i = 0; $i < count($_POST['feename']); $i++) {
$fees_name[$i]['name'] = $_POST['feename'][$i];
$fees_name[$i]['amount'] = $_POST['feeamount'][$i];
}
$fee_values = implode(',', $_POST['feename']);
$fees_name = json_encode($fees_name);
} else {
if (($fees_type == 8) || ($fees_type == 4)) {
$months = $this->db->query("SELECT * FROM nepali_months")->result_array();
$feename = array();
foreach ($months as $key => $month) {
$fees_name[$key]['name'] = $month['month_name'];
$fees_name[$key]['amount'] = $_POST['feeamount'][0];
array_push($feename, $month['month_name']);
}
$fee_values = implode(',', $feename);
$fees_name = json_encode($fees_name);
}
}
$amount = 0;
foreach ($_POST['feeamount'] as $key => $value) {
$amount += $value;
}
$nowDate = $this->nepali_current_date;
// Adding Data Inside POST
if ($feesId == 0) {
$insertFlag = false;
foreach ($course_id as $key => $value) {
$allData = array();
if ($fees_type == 8) { // For Monthly Fee
$month_fees = json_decode($fees_name);
foreach ($month_fees as $n => $e) {
$fees_name_inside = array();
$fees_name_inside[0]['name'] = $e->name;
$fees_name_inside[0]['amount'] = $e->amount;
// print_r($batch_detail);
$batch_year = explode('-', $batch_detail['b_from'])[0];
$fees_name_inside = json_encode($fees_name_inside);
$dueDate = $batch_year . '-' . sprintf("%02d", ($n + 1)) . '-' . '25';
echo ($batch_year . '-' . sprintf("%02d", ($n + 1)) . '-' . '25' . '<br>');
$allData[] = array(
'batch_id' => $batch_id,
'course_id' => $value,
'fees_type' => $fees_type,
'fees_name' => $fees_name_inside,
'amount' => $e->amount,
'due_date' => date('Y-m-d H:i:s', strtotime($dueDate)),
'grouped' => $grouped,
'fee_values' => $e->name,
'hostel_plan_id' => $hostel_plan,
'route_id' => $route_id,
'created' => $nowDate
);
}
// dd($allData);
// End of monthly fee
} else if ($fees_type == 4) { // For Transport Fee
$month_fees = json_decode($fees_name);
foreach ($month_fees as $n => $e) {
$fees_name_inside = array();
$fees_name_inside[0]['name'] = $e->name;
$fees_name_inside[0]['amount'] = $e->amount;
// print_r($batch_detail);
$batch_year = explode('-', $batch_detail['b_from'])[0];
$fees_name_inside = json_encode($fees_name_inside);
$dueDate = $batch_year . '-' . sprintf("%02d", ($n + 1)) . '-' . '25';
// echo ($batch_year . '-' . sprintf("%02d", ($n + 1)) . '-' . '25' . '<br>');
$allData[] = array(
'batch_id' => $batch_id,
'course_id' => $value,
'fees_type' => $fees_type,
'fees_name' => $fees_name_inside,
'amount' => $e->amount,
'due_date' => date('Y-m-d H:i:s', strtotime($dueDate)),
'grouped' => $grouped,
'fee_values' => $e->name,
'hostel_plan_id' => $hostel_plan,
'route_id' => $route_id,
'created' => $nowDate
);
}
// dd($allData);
// End of transport Fee
} else {
$allData[] = array(
'batch_id' => $batch_id,
'course_id' => $value,
'fees_type' => $fees_type,
'fees_name' => $fees_name,
'amount' => $amount,
'due_date' => $due_date,
'grouped' => $grouped,
'fee_values' => $fee_values,
'hostel_plan_id' => $hostel_plan,
'route_id' => $route_id,
'created' => $nowDate
);
// dd($allData);
}
$insertQuery = $this->db->insert_batch('course_fees', $allData);
if ($insertQuery) {
$insertFlag = true;
} else {
$insertFlag = false;
}
}
if ($insertFlag) {
$this->session->set_flashdata('success', str_replace('%s', 'Fees', THE_ADD_SUCCESS_MSG));
redirect(base_url() . 'admin/fee-course');
} else {
$this->session->set_flashdata('failed', str_replace('%s', 'Fees', THE_ADD_ERROR_MSG));
redirect(base_url() . 'admin/fee-course');
}
}
if ($feesId > 0) { // Updating Data Inside POST
$pay['course_fee_id'] = $feesId;
$check_payment = $this->db->get_where('students_online_payments', $pay)->row();
if (!empty($check_payment)) {
$this->session->set_flashdata('failed', 'Fees cannot be modified as a payment has already been made');
redirect(base_url() . 'admin/fee-course');
}
$allData = array(
'batch_id' => $batch_id,
'course_id' => $course_id,
'fees_type' => $fees_type,
'fees_name' => $fees_name,
'amount' => $amount,
'due_date' => $due_date,
'grouped' => $grouped,
'fee_values' => $fee_values,
'hostel_plan_id' => $hostel_plan,
'route_id' => $route_id,
'modified' => $nowDate
);
// dd($allData);
$checkIfFeeRelated = $this->Admin_model->get_table_info('students_online_payments', array('course_fee_id' => $feesId));
if (empty($checkIfFeeRelated)) {
$updateQuery = $this->Admin_model->add_edit_fee_course($feesId, $allData);
if ($updateQuery) {
$this->session->set_flashdata('success', str_replace('%s', 'Fees', THE_UPDATE_SUCCESS_MSG));
redirect(base_url() . 'admin/fee-course');
} else {
$this->session->set_flashdata('failed', str_replace('%s', 'Fees', THE_UPDATE_ERROR_MSG));
redirect(base_url() . 'admin/ae-fee-course/' . $feesId);
}
} else {
$this->session->set_flashdata('failed', 'This Fee cannot be edited as installments have already been created');
redirect(base_url() . 'admin/fee-course');
}
}
}
if ($feesId > 0) { // Display to AE_EDIT PAGE
$Feesql = "SELECT b.b_name as batch, c.course_name as course,ft.id as fee_id, ft.feetype_name as feetype, cf.* FROM course_fees cf inner join batch b on cf.batch_id = b.id INNER JOIN course c on cf.course_id = c.id INNER JOIN fee_types ft on cf.fees_type = ft.id WHERE cf.id = '$feesId' ORDER BY cf.id DESC";
$checkCourseFee = $this->Admin_model->get_table_info('course_fees', '', $Feesql);
if (empty($checkCourseFee) && $feesId != 0) {
$this->session->set_flashdata('failed', 'There is no course fee with selected id');
redirect(base_url() . 'admin/fee-course');
}
// start from here by shivuuu
if ($checkCourseFee[0]['fees_type'] == 4) {
$transport_db = $this->load->database('erisnClassroom_bts', TRUE);
$batch_routes = $transport_db->query('SELECT * from bt_batch_routes where batch_id = ' . $checkCourseFee[0]['batch_id'])->row_array();
if (!empty($batch_routes)) {
$route_ids = explode(',', $batch_routes['route_ids']);
$whereClause = '';
foreach ($route_ids as $bkey => $bvalue) {
if ($bkey == 0) {
$whereClause .= "id = '$bvalue'";
} else {
$whereClause .= " or id = '$bvalue'";
}
}
$data['edit_route_list'] = $transport_db->query('SELECT * from bt_routes where ' . $whereClause)->result_array();
}
}
// end Here by shivakumar
$data['course_fees'] = $checkCourseFee;
// dd($data['course_fees']);
foreach ($data['course_fees'] as $key => $value) {
$data['course_fees'][$key]['due_date'] = date('Y-m-d', strtotime($value['due_date']));
}
}
// dd($data['course_fees']);
$data['currentURL'] = current_url();
$data['nepali_months'] = $this->db->query("SELECT * FROM nepali_months")->result_array();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['check_fees_type'] = (!empty($coursebyfees)) ? $coursebyfees : '';
// dd($data);
$this->load->view('admin/header', $data);
$this->load->view('admin/ae_fee_course.php');
$this->load->view('admin/footer');
}
public function add_edit_fee_course_old($feesId)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/ae_fee_course.php'))
show_404();
$checkIfExists = $this->Admin_model->get_table_info('course_fees', array('id' => $feesId));
if (empty($checkIfExists) && $feesId != 0) {
$this->session->set_flashdata('failed', 'There is no fees with selected id');
redirect(base_url() . 'admin/fee-course');
}
$data['fees_id'] = $feesId;
$batches = $this->Admin_model->get_table_info('batch', array('is_active' => 'yes'));
$data['batches'] = $batches;
$data['payment_types'] = $this->Admin_model->get_table_info('payment_types', '', '', 'ASC');
$courses = $this->Admin_model->get_table_info('course', '', '', 'ASC');
$data['courses'] = $courses;
$data['feeTypes'] = $this->Admin_model->get_table_info('fee_types', array('is_active' => 'yes'), '', 'ASC');
// dd($data['feeTypes']);
if (count($_POST) > 0) {
$grouped = isset($_POST['grouped']) ? 'yes' : 'no';
foreach ($_POST as $key => $value) {
if ($key == 'englishdate' || $key == 'nepalidate') {
foreach ($value as $key2 => $value2) {
if ($value2 == '') {
unset($_POST[$key][$key2]);
}
}
}
if (!$_POST[$key]) {
unset($_POST[$key]);
}
}
$batch_id = $this->input->post('batch_id');
$course_id = $this->input->post('course_id');
$hostel_plan = NULL;
if (isset($_POST['hostel_plan_id'])) {
$hostel_plan = $this->input->post('hostel_plan_id');
}
$route_id = NULL;
if (isset($_POST['route_id'])) {
$route_id = $this->input->post('route_id');
}
if (array_key_exists('common_bs_due_date', $_POST)) {
$due_date = $this->input->post('common_bs_due_date');
} else if (array_key_exists('common_ad_due_date', $_POST)) {
$due_date = $this->input->post('common_ad_due_date');
} else {
if (array_key_exists('bsdate', $_POST)) {
$due_date = $_POST['bsdate'][0];
}
if (array_key_exists('englishdate', $_POST)) {
$due_date = $_POST['englishdate'][0];
}
}
$due_date = date('Y-m-d H:i:s', strtotime($due_date));
$fees_type = $this->input->post('feetype');
$fees_name = array();
for ($i = 0; $i < count($_POST['feename']); $i++) {
$fees_name[$i]['name'] = $_POST['feename'][$i];
$fees_name[$i]['amount'] = $_POST['feeamount'][$i];
}
$fee_values = implode(',', $_POST['feename']);
$fees_name = json_encode($fees_name);
$amount = 0;
foreach ($_POST['feeamount'] as $key => $value) {
$amount += $value;
}
$nowDate = $this->nepali_current_date;
// Adding Data Inside POST
if ($feesId == 0) {
$insertFlag = false;
foreach ($course_id as $key => $value) {
$allData = array(
'batch_id' => $batch_id,
'course_id' => $value,
'fees_type' => $fees_type,
'fees_name' => $fees_name,
'amount' => $amount,
'due_date' => $due_date,
'grouped' => $grouped,
'fee_values' => $fee_values,
'hostel_plan_id' => $hostel_plan,
'route_id' => $route_id,
'created' => $nowDate
);
$insertQuery = $this->Admin_model->add_edit_fee_course($feesId, $allData);
if ($insertQuery) {
$insertFlag = true;
} else {
$insertFlag = false;
return;
}
}
if ($insertFlag) {
$this->session->set_flashdata('success', str_replace('%s', 'Fees', THE_ADD_SUCCESS_MSG));
redirect(base_url() . 'admin/fee-course');
} else {
$this->session->set_flashdata('failed', str_replace('%s', 'Fees', THE_ADD_ERROR_MSG));
redirect(base_url() . 'admin/fee-course');
}
}
if ($feesId > 0) { // Updating Data Inside POST
$pay['course_fee_id'] = $feesId;
$check_payment = $this->db->get_where('students_online_payments', $pay)->row();
if (!empty($check_payment)) {
$this->session->set_flashdata('failed', 'Fees cannot be modified as a payment has already been made');
redirect(base_url() . 'admin/fee-course');
}
$allData = array(
'batch_id' => $batch_id,
'course_id' => $course_id,
'fees_type' => $fees_type,
'fees_name' => $fees_name,
'amount' => $amount,
'due_date' => $due_date,
'grouped' => $grouped,
'fee_values' => $fee_values,
'hostel_plan_id' => $hostel_plan,
'route_id' => $route_id,
'modified' => $nowDate
);
$checkIfFeeRelated = $this->Admin_model->get_table_info('students_online_payments', array('course_fee_id' => $feesId));
if (empty($checkIfFeeRelated)) {
$updateQuery = $this->Admin_model->add_edit_fee_course($feesId, $allData);
if ($updateQuery) {
$this->session->set_flashdata('success', str_replace('%s', 'Fees', THE_UPDATE_SUCCESS_MSG));
redirect(base_url() . 'admin/fee-course');
} else {
$this->session->set_flashdata('failed', str_replace('%s', 'Fees', THE_UPDATE_ERROR_MSG));
redirect(base_url() . 'admin/ae-fee-course/' . $feesId);
}
} else {
$this->session->set_flashdata('failed', 'This Fee cannot be edited as installments have already been created');
redirect(base_url() . 'admin/fee-course');
}
}
}
if ($feesId > 0) { // Display to AE_EDIT PAGE
$Feesql = "SELECT b.b_name as batch, c.course_name as course, ft.feetype_name as feetype, cf.* FROM course_fees cf inner join batch b on cf.batch_id = b.id INNER JOIN course c on cf.course_id = c.id INNER JOIN fee_types ft on cf.fees_type = ft.id WHERE cf.id = '$feesId' ORDER BY cf.id DESC";
$checkCourseFee = $this->Admin_model->get_table_info('course_fees', '', $Feesql);
if (empty($checkCourseFee) && $feesId != 0) {
$this->session->set_flashdata('failed', 'There is no course fee with selected id');
redirect(base_url() . 'admin/fee-course');
}
$data['course_fees'] = $checkCourseFee;
foreach ($data['course_fees'] as $key => $value) {
$data['course_fees'][$key]['due_date'] = date('Y-m-d', strtotime($value['due_date']));
}
}
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$this->load->view('admin/header', $data);
$this->load->view('admin/ae_fee_course.php');
$this->load->view('admin/footer');
}
public function ajax_get_hostel_plans()
{
$select_plan = '';
if (isset($_POST['selected_plan'])) {
$select_plan = $this->input->post('selected_plan');
}
$plans = $this->Admin_model->get_table_info('hostel_plans', '', '', 'ASC');
$html = '<select name="feename[0]" onchange="set_plan_id(this)" class="form-control feeNameClass">';
$id = '';
$name = '';
foreach ($plans as $key => $value) {
if ($key == 0) {
$html .= '<option value="">Select A Plan</option>';
}
if ($select_plan != '' && $select_plan == $value['plan_name']) {
$id = $value['id'];
$name = $value['plan_name'];
$html .= '<option selected data-id="' . $value['id'] . '" value="' . $value['plan_name'] . '">' . $value['plan_name'] . '</option>';
} else {
$html .= '<option data-id=' . $value['id'] . ' value="' . $value['plan_name'] . '">' . $value['plan_name'] . '</option>';
}
}
$html .= '</select>';
if ($select_plan != '' && $select_plan == $name) {
$html .= '<input type="hidden" name="hostel_plan_id" value="' . $id . '" id="hostel_plan_id">';
} else {
$html .= '<input type="hidden" name="hostel_plan_id" id="hostel_plan_id">';
}
echo $html;
}
public function delete_course_fees($fid)
{
$checkIfFeeRelated = $this->Admin_model->get_table_info('students_online_payments', array('course_fee_id' => $fid));
if (empty($checkIfFeeRelated)) {
$deleteQuery = $this->Admin_model->delete_course_fees($fid);
$deleteInst = $this->Admin_model->delete_row('installment', array('course_fee_id' => $fid));
// dd($deleteQuery);
if ($deleteQuery) {
$this->session->set_flashdata('success', str_replace('%s', 'Fees', THE_DELETE_SUCCESS_MSG));
redirect(base_url() . 'admin/fee-course');
} else {
$this->session->set_flashdata('failed', str_replace('%s', 'Fees', THE_DELETE_ERROR_MSG));
redirect(base_url() . 'admin/fee-course');
}
} else {
$this->session->set_flashdata('failed', 'This Fee cannot be deleted as students have already made payment');
redirect(base_url() . 'admin/fee-course');
}
}
public function ajax_validate_fee_type()
{
$data = json_decode($this->input->post('info'));
$id = $data->id;
$whereClause = '';
if (is_array($data->course_id)) {
foreach ($data->course_id as $key => $value) {
if ($key == 0) {
$whereClause .= "course_id = '$value'";
} else {
$whereClause .= " or course_id = '$value'";
}
}
} else {
$whereClause .= "course_id = '$data->course_id'";
}
$sql = 'Select * from course_fees WHERE (batch_id = ' . $data->batch_id . '
AND fees_type =' . $data->fee_type . ')
AND id != ' . $id . '
AND (' . $whereClause . ')';
// $dataArr = array(
// 'batch_id' => $data->batch_id,
// 'course_id' => $data->course_id,
// 'fees_type' => $data->fee_type
// );
// $query = $this->Admin_model->check_value_exists('course_fees', $dataArr, $id);
$query = $this->Admin_model->get_table_info('course_fees', '', $sql);
if (empty($query)) {
echo 'success';
} else {
echo 'failed';
}
}
public function ajax_check_fee_names()
{
$data = json_decode($this->input->post('info'));
// dd($data);
$id = $data->id;
$whereClause = '';
$q = '';
if (is_array($data->course_id)) {
foreach ($data->course_id as $key => $value) {
if ($key == 0) {
$whereClause .= "course_id = '$value'";
} else {
$whereClause .= " or course_id = '$value'";
}
}
} else {
$whereClause .= "course_id = '$data->course_id'";
}
if ($data->route_id != '')
$q .= " AND route_id = '$data->route_id'";
echo $sql = 'Select * from course_fees WHERE (batch_id = ' . $data->batch_id . '
AND fees_type =' . $data->fee_type . ')
AND id != ' . $id . $q . '
AND (' . $whereClause . ')';
$fee_names = $data->fee_names;
// dd($fee_names);
$query = $this->Admin_model->get_table_info('course_fees', '', $sql);
if (empty($query)) {
exit(true);
}
$flag = false;
foreach ($query as $key => $value) {
$fee_values = explode(',', strtolower($value['fee_values']));
sort($fee_names);
sort($fee_values);
if ($fee_names == $fee_values) {
$fee_values . "-<br>";
$flag = true;
break;
}
}
if ($flag) {
echo false; // Dublicate names found
} else {
echo true;
}
}
// Fee Course End - 10-11-2021 Afras Khan
// Fee course validation
public function ajax_check_fee_names_new()
{
$data = json_decode($this->input->post('info'));
// dd($data);
$coursebyfees = array();
$id = $data->id;
$whereClause = '';
$course_arr = implode(',', $data->course_id);
$fee_names = implode("','", $data->fee_names);
// dd($fee_names);
if (count($data->fee_names) > 0)
$whereClause .= " AND cf.fee_values IN ('" . $fee_names . "')";
if ($data->route_id != '')
$whereClause .= " AND cf.route_id = '$data->route_id'";
if (count($data->course_id) > 0)
$whereClause .= ' AND cf.course_id IN (' . $course_arr . ')';
$feesname_exists = $this->db->query("Select cf.*,c.course_name FROM course_fees cf JOIN course c ON cf.course_id=c.id WHERE cf.batch_id=" . $data->batch_id . " AND cf.fees_type =" . $data->fee_type . " AND cf.id != " . $id . $whereClause)->result_array();
// $query1="Select cf.*,c.course_name FROM course_fees cf JOIN course c ON cf.course_id=c.id WHERE cf.batch_id=".$data->batch_id." AND cf.fees_type =".$data->fee_type." AND cf.id != ".$id.$whereClause;
if (isset($feesname_exists) && !empty($feesname_exists)) {
foreach ($feesname_exists as $k => $vl) {
$coursebyfees[$vl['fee_values']][] = $vl['course_name'];
}
echo json_encode($coursebyfees);
} else {
echo 0;
}
}
// End here - by shivakumar
// To get section name for classroom - shivakumar start
public function getSectionsforClassroomByCourse()
{
$courseId = (isset($_REQUEST['course_id'])) ? $_REQUEST['course_id'] : 0;
$query = "SELECT s.section_name,s.id FROM course_sections cs LEFT JOIN section s ON s.id=cs.section_id WHERE s.is_active='yes' AND cs.course_id=$courseId";
$result = $this->Admin_model->get_query_result($query);
if (count($result) > 0) {
echo json_encode($result);
} else {
$result = array('id' => '', 'section_name' => 'No sections Found');
echo json_encode($result);
}
}
// To get section name for classroom - shivakumar end
public function delete_subject($subject_id)
{
$subject_id = ($subject_id != '') ? $subject_id : 0;
if ($subject_id != 0) {
$result = $this->Admin_model->delete_subject($subject_id);
if ($result == 'exists') {
$this->session->set_flashdata('errorsubject', str_replace('%s', 'Subject', ALREADY_ASSIGNED_MSG));
} else if ($result == 'success') {
$this->session->set_flashdata('successsubject', str_replace('%s', 'Subject', THE_DELETE_SUCCESS_MSG));
} else if ($result == 'failed') {
$this->session->set_flashdata('errorsubject', str_replace('%s', 'Subject', THE_DELETE_ERROR_MSG));
}
} else {
$this->session->set_flashdata('errorsubject', str_replace('%s', 'Subject', THE_DELETE_ERROR_MSG));
}
redirect(base_url() . 'admin/subject');
}
// Student's Info - 14-11-2021 Afras Khan
public function view_student($studentid)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/view-student.php'))
show_404();
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['student'] = $this->Admin_model->view_student($studentid);
$data['student_id'] = $studentid;
$data['section_name'] = $this->db->query('select sc.section_name from section sc , student_batch sb, classroom c, students s where s.id =' . $studentid . ' AND sb.student_id = s.id AND sb.batch_id = s.batch_id and c.id = sb.classroom_id and c.section_id = sc.id order by sb.id DESC')->row_array();
// dd($data['student']);
$this->load->view('admin/header', $data);
$this->load->view('admin/view-student', $data);
$this->load->view('admin/footer');
}
public function ajax_update_student_files()
{
extract($_POST['dataArr']);
// Below is the data extracted
// $file = image name
// $path = image path
// $studId = student Id
// $inputName = input name
$updateData[$inputName] = $file;
$file_name = uniqid($file, false);
$config['upload_path'] = 'assets_student/application/';
$config['allowed_types'] = 'gif|jpg|png';
$config['file_name'] = $file_name;
$this->load->library('upload', $config);
$this->upload->initialize($config);
if (!$this->upload->do_upload('photo')) {
echo 'failed in upper';
echo $this->upload->display_errors();
return false;
} else {
$data = array('upload_data' => $this->upload->data());
$sql = $this->Admin_model->update_student_files($updateData[$inputName], $studId);
if ($sql) {
echo 'success';
} else {
echo 'failed in lower';
}
}
}
public function editInfo_Student($studentid = '')
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/view-student.php'))
show_404();
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['student'] = $this->Admin_model->view_student($studentid);
foreach ($data['student'] as $key => $value) {
$names = explode(' ', $value['name'], 2);
if (count($names) > 1) {
$data['student'][$key]['first_name'] = $names[0];
$data['student'][$key]['last_name'] = $names[1];
} else {
$data['student'][$key]['first_name'] = $names[0];
$data['student'][$key]['last_name'] = '';
}
}
$data['student_id'] = $studentid;
// dd($data['student']);
if (isset($_POST['submit_info'])) {
$first_name = ucfirst(strtolower($_POST['first_name']));
$last_name = ucfirst(strtolower($_POST['last_name']));
$complete_name = $first_name . ' ' . $last_name;
$update_data = array(
'name' => $complete_name,
'iemis' => $_POST['iemis'],
'father_name' => $_POST['fname'],
'mother_name' => $_POST['mname'],
'email' => $_POST['email'],
'mobile' => $_POST['contact'],
'dob' => $_POST['dob'],
'gender' => $_POST['gender'],
'address1' => $_POST['address1'],
'address2' => $_POST['address2'],
'country' => $_POST['country'],
'state' => $_POST['state'],
'zipcode' => $_POST['zipcode'],
'parent_pan' => $_POST['pan'],
'emergency_contact_name' => $_POST['pname'],
'emergency_contact_number' => $_POST['pcontact']
);
$this->db->where('id', $_POST['student_Id']);
$update = $this->db->update("students", $update_data);
if ($update) {
$this->session->set_flashdata('success', str_replace('%s', 'Student', THE_UPDATE_SUCCESS_MSG));
redirect(base_url() . 'admin/view_student/' . $_POST['student_Id']);
} else {
$this->session->set_flashdata('success', str_replace('%s', 'Student', THE_ADD_ERROR_MSG));
redirect(base_url() . 'admin/view_student/' . $_POST['student_Id']);
}
}
// dd($data['student']);
$this->load->view('admin/header', $data);
$this->load->view('admin/edit-student-info', $data);
$this->load->view('admin/footer');
}
public function view_student_payments($student_id)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/view-student-payments.php'))
show_404();
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['nepali_curr_date'] = $this->nepali_current_date;
$data['student_id'] = $student_id;
$this->load->model("Student_model");
$selectedBatchId = isset($_POST['f_batch']) ? $_POST['f_batch'] : $data['school_info']['batch_id'];
$student_info_array = "Select s.id as student_id,c.course_id, c.section_id, s.name,s.email,s.studentId, s.photo, s.gender,s.emergency_contact_number, c.classroom_name,b.id as batch_id, b.b_name from students s
INNER JOIN student_batch sb on s.id = sb.student_id AND $selectedBatchId = sb.batch_id
INNER JOIN classroom c on c.id = sb.classroom_id
INNER JOIN batch b on b.id = sb.batch_id
WHERE s.id = $student_id
ORDER BY sb.id DESC;
";
//Student Info
$data['student_info_array'] = $this->Admin_model->get_table_info_row('students', '', $student_info_array);
// Paid Fees
$sql = "Select sop.*, pt.payment_type_name, cf.amount, f.feetype_name, cf.fee_values from students_online_payments sop inner join payment_types pt on pt.id = sop.installment_type_id inner join course_fees cf on cf.id = sop.course_fee_id inner join fee_types f on cf.fees_type = f.id WHERE sop.student_id = '$student_id' ORDER BY sop.id";
$data['payments'] = $this->Admin_model->get_table_info('students_online_payments', '', $sql);
// $data['not_paid_fees'] = $not_paid_installments;
$fee_transactions = array();
// Paid Transactions
$query = "Select sf.id, sf.studentId, sf.payment_for, sf.txn_id, sf.invoice_no, sf.deduction_type, sf.status, sf.payment_date, sf.payment_recived_id,
sf.created, sf.modified, sf.payment_method, sf.bank_transaction_id, sf.course_fee_id, sf.install_sno, sf.bill_print_count, cf.batch_id,
GROUP_CONCAT(sf.id SEPARATOR ',') AS online_transaction_id ,
GROUP_CONCAT(sf.payment_amt SEPARATOR ',') AS payment_amt ,
GROUP_CONCAT(sf.deduction_amount SEPARATOR ',') AS deduction_amount ,
GROUP_CONCAT(sf.fine_amount SEPARATOR ',') AS fine_amount ,
GROUP_CONCAT(sf.payment_for SEPARATOR ',') AS payment_for ,
GROUP_CONCAT(cf.fee_values SEPARATOR ', ') AS fee_values from student_fee_online_transactions sf
inner join students s on sf.studentId = s.studentId
INNER JOIN course_fees cf on cf.id = sf.course_fee_id
WHERE s.id = $student_id GROUP BY sf.invoice_no ORDER BY sf.payment_date ASC";
$fee_transactions = $this->Admin_model->get_table_info('student_fee_online_transactions', '', $query);
$final_fee_transactions = array();
foreach ($fee_transactions as $ft_key => $transaction) {
$payment_date_time_array = explode(' ', $transaction['payment_date']);
$payment_date = explode('-', $payment_date_time_array[0]);
$payment_year = $payment_date[0];
$current_date_time_array = explode(' ', $this->nepali_current_date);
$current_date = explode('-', $current_date_time_array[0]);
$current_year = $current_date[0];
// echo $payment_year .' => '. $current_year .'<br>';
if (($payment_year == $current_year) || ($selectedBatchId == $transaction['batch_id'])) {
array_push($final_fee_transactions, $transaction);
}
}
// dd($final_fee_transactions);
$fee_transactions = $final_fee_transactions;
$data['transactions'] = $fee_transactions;
// dd($data['transactions']);
// Table unpaid fees
$table_fees = [];
// Afras kahan working script start HERE
$table_unpaid_query = "Select cf.id as course_fee_id,cf.fee_values as fee_name, cf.batch_id, b.b_name as batch_name,
1 as install_s_no,cf.amount as fee_amount,ft.feetype_name as fee_type,ft.id as fee_type_id, fas.is_half_fee,
DATE(cf.due_date) as due_date,
IF(ss.id is null,0,ss.id) as scholarship_id,
IF(ss.scholarship_amount is null,0,ss.scholarship_amount) as scholarship_amount,
IF(ss.scholarship_discount is null,0,ss.scholarship_discount) as scholarship_discount,
IF(ss.scholarship_type is null,0,ss.scholarship_type) as scholarship_type,
IF(ss.is_active is null,null,ss.is_active) as hasScholarship,
IF(sop.id is null,0,sop.id) as sop_id,
IF(sop.pending_amount is null,cf.amount,sop.pending_amount) as pending_amount,
IF(sop.fine_amount is null,0,sop.fine_amount) as fine_amount,
IF(sop.fee_completed is null,'no',sop.fee_completed) as fee_completed from course_fees cf
INNER JOIN fee_assigned_students fas on fas.course_fee_id = cf.id AND student_id = $student_id
INNER JOIN fee_types ft on ft.id = cf.fees_type
LEFT JOIN students_online_payments sop on cf.id = sop.course_fee_id AND sop.student_id = $student_id
LEFT JOIN batch b ON b.id = cf.batch_id
LEFT JOIN student_scholarship ss on cf.id = ss.course_fee_id AND ss.student_id = $student_id";
// Afras Khan working script End Here
$tableUnpaid = $this->Admin_model->get_table_info('students', '', $table_unpaid_query);
// echo '<pre>';
// var_dump($tableUnpaid);
// dd($tableUnpaid);
$unpaid_fees_list = array();
$due_fees_list = array();
foreach ($tableUnpaid as $u_key => $unpaid_fee) {
if ($selectedBatchId == $unpaid_fee['batch_id']) {
array_push($unpaid_fees_list, $unpaid_fee);
} else {
array_push($due_fees_list, $unpaid_fee);
}
}
// echo '<pre>';
// print_r($unpaid_fees_list);
// dd($due_fees_list);invoice
$data['table_unpaid_fees'] = $unpaid_fees_list;
$data['table_due_fees'] = $due_fees_list;
// rsort($data['table_unpaid_fees']);
$data['scholarship_types'] = $this->Admin_model->get_query_result("SELECT id, scholarshiptype_name FROM scholarship_types");
$data['batches'] = $this->db->query('SELECT * FROM batch WHERE is_active = "yes"')->result_array();
$data['selectedBatch'] = $selectedBatchId;
$this->load->view('admin/header', $data);
$this->load->view('admin/view-student-payments');
$this->load->view('admin/footer');
}
public function ajax_fetch_each_transac_details()
{
$sop_id = $this->input->post('sopId');
$sop_info = $this->Admin_model->get_table_info_row('students_online_payments', array('id' => $sop_id));
$data_to_return = '';
// dd($sop_info);
if (!empty($sop_info)) {
$course_fee_id = $sop_info['course_fee_id'];
$installments = json_decode($sop_info['payment_details']);
// dd($installments);
foreach ($installments as $key => $value) {
$data_txn['course_fee_id'] = $course_fee_id;
$data_txn['install_sno'] = $value->install_sno;
$txn = $this->db->get_where('student_fee_online_transactions', $data_txn)->row_array();
$stuID = (isset($txn['studentId']) && !empty($txn['studentId'])) ? $txn['studentId'] : 0;
$transaction_id = (isset($txn['txn_id']) && !empty($txn['txn_id'])) ? $txn['txn_id'] : 0;
$invoice_link = base_url() . 'admin/invoice/' . urlsafe_b64encode($stuID) . '/' . urlsafe_b64encode($transaction_id) . '/' . urlsafe_b64encode(0);
$data_to_return .= '<tr>';
$data_to_return .= '<td>' . $value->install_sno . '</td>';
$data_to_return .= '<td>' . $value->paid_amount . '</td>';
$data_to_return .= '<td>' . $value->pending_amount . '</td>';
$data_to_return .= '<td>' . $value->deduction_type . '</td>';
$data_to_return .= '<td>' . $value->deduction_amount . '</td>';
$data_to_return .= '<td>' . $value->fine_amount . '</td>';
$data_to_return .= '<td>' . $value->payment_via . '</td>';
$data_to_return .= '<td>' . $value->updated_by . '</td>';
$data_to_return .= '<td class="eft-action"><i onclick="revertEft(this,' . $sop_info['id'] . ',' . $value->install_sno . ')" data-toggle="tooltip" data-placement="top" title="Revert this payment" class="fa fa-times" style="color:red" ></i><a target="blank" href="' . $invoice_link . '"><i style="color:#032da1" class="fa fa-file" aria-hidden="true"></i></a></td>';
$data_to_return .= '</tr>';
}
}
$json = json_encode($data_to_return);
echo $json;
}
public function ajax_erase_fee_installment()
{
$sop_id = $this->input->post('sopId');
$install_sno = $this->input->post('install_sno');
$sop_data = $this->Admin_model->get_table_info('students_online_payments', array('id' => $sop_id));
$undelete = [];
$update_data = [];
$course_fee_id = '';
if (!empty($sop_data)) {
foreach ($sop_data as $key => $value) {
$course_fee_id = $value['course_fee_id'];
$installments = json_decode($value['payment_details'], true);
//echo '<pre>'; print_r($installments);
$thePayDetailsNow = array();
foreach ($installments as $index => $ele) {
// echo $index."=> ". $ele;
if ($ele['install_sno'] == $install_sno) {
$update_data['pending_amount'] = $value['pending_amount'] + $ele['payable_amount'];
$update_data['paid_amount'] = $value['paid_amount'] - $ele['paid_amount'];
$update_data['fine_amount'] = $value['fine_amount'] - $ele['fine_amount'];
$update_data['deducted_amount'] = $value['deducted_amount'] - $ele['deduction_amount'];
$update_data['fee_completed'] = 'no';
unset($installments[$index]);
} else
$undelete[] = $installments[$index];
}
$update_data['payment_details'] = json_encode($undelete);
}
$update_sop = $this->db->update('students_online_payments', $update_data, array('id' => $sop_id));
if ($update_sop) {
$student_id = (isset($sop_data[0]['student_id']) && !empty($sop_data[0]['student_id'])) ? $sop_data[0]['student_id'] : 0;
$rst = $this->db->query('SELECT studentId FROM students WHERE id=' . $student_id)->row_array();
$studentId = (isset($rst['studentId']) && !empty($rst['studentId'])) ? $rst['studentId'] : 0;
$revertThisData = $this->db->query("SELECT * FROM student_fee_online_transactions WHERE studentId='$studentId' AND course_fee_id = $course_fee_id AND install_sno = $install_sno")->result_array();
if (isset($revertThisData[0])) {
$revertThisData[0]['done_by'] = $_SESSION['admin_id'] . ' - ' . $_SESSION['admin_name'] . ' - ' . $_SESSION['admin_email'];
$revertThisData[0]['c_date'] = date('Y-m-d H:i:s', strtotime($this->nepali_current_date));
$revertBackuped = $this->db->insert('student_fee_reverts', $revertThisData[0]);
if ($revertBackuped) {
$transac_del = $this->db->query("DELETE FROM student_fee_online_transactions WHERE studentId='$studentId' AND course_fee_id = $course_fee_id AND install_sno = $install_sno");
if ($transac_del)
echo 'success';
else
echo 'trans-failed';
} else
echo 'revert-backup-failed';
} else
echo 'sfot-record-missing';
/*$transac_del = $this->db->query("DELETE FROM student_fee_online_transactions WHERE studentId='$studentId' AND course_fee_id = $course_fee_id AND install_sno = $install_sno");
if($transac_del) {
echo 'success';
} else {
echo 'trans-failed';
}*/
} else {
echo 'failed';
}
} else {
echo 'failed';
}
}
// Student's Info End - 14-11-2021 Afras Khan
// Fee Installment - Afras Khan - 16-11-2021
public function fee_installment()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/fee-installment.php'))
show_404();
if (isset($_SESSION['admin_id'])) {
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$sql = "Select c.course_name,cf.amount,ft.feetype_name as fees_name,i.* from course_fees cf inner join installment i on cf.id = i.course_fee_id inner join course c on c.id = cf.course_id inner join fee_types ft on ft.id = cf.fees_type ORDER BY i.id DESC";
$data['installments'] = $this->Admin_model->get_table_info('installment', '', $sql);
$this->load->view('admin/header', $data);
$this->load->view('admin/fee-installment', $data);
$this->load->view('admin/footer');
}
}
public function delete_installment()
{
$id = $_POST['id'];
$table = $_POST['table'];
$data = $this->Admin_model->delete_installment($id, $table);
print_r($data);
}
public function restore_installment()
{
$id = $_POST['id'];
$table = $_POST['table'];
$data = $this->Admin_model->restore_installment($id, $table);
print_r($data);
}
public function addedit_installment()
{
//print_r($_POST);
$cid = $_POST['ficourse'];
$pay_method = $_POST['payment_method'];
$amount = $_POST['amount'];
$duedate = $_POST['duedate'];
$data_array = array(
'course_id' => $cid,
'pay_method' => $pay_method,
'amount' => $amount,
'duedate' => $duedate
);
$data = $this->Admin_model->addedit_installment($data_array);
//print_r($data);
// redirect(base_url().'Admin', 'fee-installment');
}
public function add_edit_fee_installment($feesId)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/add-edit-fee-installment.php'))
show_404();
$checkIfExists = $this->Admin_model->get_table_info('installment', array('id' => $feesId));
if (empty($checkIfExists) && $feesId != 0) {
$this->session->set_flashdata('failed', 'There is no installment with selected id');
redirect(base_url() . 'admin/fee-installment');
}
if (isset($_SESSION['admin_id'])) {
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['fees_id'] = $feesId;
$data['menulist'] = $this->Admin_model->get_adminMenu();
if ($feesId > 0) {
$installment = $checkIfExists;
$cf_id = $installment[0]['course_fee_id'];
$data['cf_id'] = $cf_id;
$query = "Select course_id, batch_id,fees_type, due_date, amount, hostel_plan_id from course_fees where id = '$cf_id'";
$course_batch_ids = $this->Admin_model->get_table_info('course_fees', '', $query);
$whereClause = "";
foreach ($course_batch_ids as $key => $value) {
$whereClause .= 'cf.course_id = ' . $value["course_id"] . ' AND cf.batch_id =' . $value["batch_id"];
$data['batch_id'] = $value["batch_id"];
$data['course_id'] = $value["course_id"];
$data['feetype_id'] = $value['fees_type'];
$data['due_date'] = date('d-M-Y', strtotime($value["due_date"]));
$data['due_amount_total'] = $value['amount'];
$data['hostel_plan_id'] = $value['hostel_plan_id'];
}
$data['batch'] = $this->Admin_model->get_install_batch();
$data['course'] = $this->Admin_model->get_install_course();
$sql = "Select ft.id, ft.feetype_name from fee_types ft inner join course_fees cf on ft.id = cf.fees_type WHERE " . $whereClause . " GROUP BY ft.id";
$data['fee_types'] = $this->Admin_model->get_table_info('course_fees', '', $sql);
$data['installment'] = $installment;
$data['payment_types'] = $this->Admin_model->get_table_info('payment_types', '', '', 'ASC');
$data['due_info'] = json_decode($installment[0]['due_amount_date']);
$data['pt_keys'] = (array_keys((array)$data['due_info']));
// dd($data['due_info']);
} else {
$data['batch'] = $this->Admin_model->get_install_batch();
$data['payment_types'] = $this->Admin_model->get_table_info('payment_types', '', '', 'ASC');
}
$this->load->view('admin/header', $data);
$this->load->view('admin/add-edit-fee-installment');
$this->load->view('admin/footer');
}
}
public function get_coursefee()
{
$course = $_POST['course'];
$installment = $_POST['inst'];
$start = $_POST['start'];
$data = $this->Admin_model->get_coursefee($course, $installment, $start);
print_r($data);
}
public function get_duedates()
{
$course_fee = $_POST['course_fee'];
$installment = $_POST['inst'];
$start = $_POST['start'];
// echo $start;exit;
$data = $this->Admin_model->get_duedates($course_fee, $installment, $start);
$json = json_encode($data);
echo $json;
}
public function convert()
{
echo $returnURL = base_url() . 'api/Student_api/pay_unpaid_fees/';
}
public function ajax_get_installment_course_batch()
{
$batch_id = $this->input->post('batch');
$sql = "select c.id as course_id, c.course_name, cf.amount, ft.feetype_name from course_fees cf inner join course c on cf.course_id = c.id inner join fee_types ft on cf.fees_type = ft.id WHERE cf.batch_id = '$batch_id' GROUP BY c.course_name";
$data = $this->Admin_model->get_table_info('course_fees', '', $sql);
$html = '<option selected value="">Please select a course</option>';
foreach ($data as $value) {
$html .= '<option value="' . $value['course_id'] . '">' . $value['course_name'] . '</option>';
}
echo $html;
}
public function ajax_get_installment_course_feetype()
{
$course_id = $this->input->post('course');
$batch_id = $this->input->post('batch');
$sql = "Select ft.id, ft.feetype_name as ft_name from course_fees cf inner join fee_types ft on cf.fees_type = ft.id WHERE cf.batch_id = '$batch_id' AND cf.course_id = '$course_id' GROUP BY ft.id";
$data = $this->Admin_model->get_table_info('course_fees', '', $sql);
$html = '<option selected value="">Please select a fee type</option>';
foreach ($data as $value) {
$html .= '<option value="' . $value['id'] . '">' . $value['ft_name'] . '</option>';
}
echo $html;
}
public function ajax_get_installment_course_fee_date_id()
{
$course_id = $this->input->post('course');
$batch_id = $this->input->post('batch');
$feeid = $this->input->post('fee_id');
if (isset($_POST['plan_id'])) {
$plan = $this->input->post('plan_id');
$where = array(
'batch_id' => $batch_id,
'course_id' => $course_id,
'fees_type' => $feeid,
'hostel_plan_id' => $plan
);
} else {
$where = array(
'batch_id' => $batch_id,
'course_id' => $course_id,
'fees_type' => $feeid
);
}
$data = $this->Admin_model->get_table_info('course_fees', $where);
$json = json_encode($data);
echo $json;
}
public function ajax_get_complete_course_fee_id()
{
$course_fee = $this->input->post('id');
$where['id'] = $course_fee;
$data = $this->Admin_model->get_table_info('course_fees', $where);
$json = json_encode($data);
echo $json;
}
public function ajax_get_course_fee_hostel_plan()
{
$course_id = $this->input->post('course');
$batch_id = $this->input->post('batch');
$feeid = $this->input->post('fee_id');
$where = array(
'batch_id' => $batch_id,
'course_id' => $course_id,
'fees_type' => $feeid
);
$sql = "select hp.id, hp.plan_name from hostel_plans hp inner join course_fees cf on cf.hostel_plan_id = hp.id WHERE cf.batch_id = '$batch_id'
AND cf.course_id = '$course_id'
AND cf.fees_type = '$feeid' ORDER BY hp.id ASC";
$data = $this->Admin_model->get_table_info('course_fees', '', $sql);
$html = '<option selected value="">Please select a Hostel Plan</option>';
foreach ($data as $value) {
$html .= '<option value="' . $value['id'] . '">' . $value['plan_name'] . '</option>';
}
echo $html;
}
public function ajax_get_course_fee_values()
{
$course_id = $this->input->post('course');
$batch_id = $this->input->post('batch');
$feeid = $this->input->post('fee_id');
$where = array(
'batch_id' => $batch_id,
'course_id' => $course_id,
'fees_type' => $feeid
);
$data = $this->Admin_model->get_table_info('course_fees', $where);
$html = '<option selected value="">Please select Fee Names of the above combination</option>';
foreach ($data as $value) {
$html .= '<option value="' . $value['id'] . '">' . $value['fee_values'] . '</option>';
}
echo $html;
}
public function ajax_get_course_fee_values_count_data()
{
$course_id = $this->input->post('course');
$batch_id = $this->input->post('batch');
$feeid = $this->input->post('fee_id');
$where = array(
'batch_id' => $batch_id,
'course_id' => $course_id,
'fees_type' => $feeid
);
$data = $this->Admin_model->get_table_info('course_fees', $where);
$html = '<option selected value="">Please select Fee Names of the above combination</option>';
foreach ($data as $value) {
$html .= '<option value="' . $value['id'] . '">' . $value['fee_values'] . '</option>';
}
$response['count'] = count($data);
$response['data'] = $html;
$json = json_encode($response);
echo $json;
}
public function ajax_validate_course_installment()
{
$course_fee_id = $this->input->post('value');
$id = $this->input->post('id');
$query = $this->Admin_model->check_value_exists('installment', array('course_fee_id' => $course_fee_id), $id);
if ($query)
echo 'success';
else
echo 'failed';
}
public function insert_update_feeinstallment($feeId)
{
$remove = ['paymentoption', 'fibatch_from', 'course_fee', 'batch_id', 'ficourse', 'ft_id'];
$_POST = array_diff_key($_POST, array_flip($remove));
$course_fee_id = $this->input->post('course-fee_id');
$payment_method = $this->input->post('payment_method');
$amount = $this->input->post('amount');
$duedate = $this->input->post('duedate');
$active = $this->input->post('is_active');
$due_amount_date = array();
$temp_arr = array();
$count = 0;
foreach ($amount as $key => $value) {
if (!is_array($value)) {
$temp_arr[$payment_method[$count]][] = array(
'due_date' => $duedate[$key],
'amount' => $value
);
} else {
foreach ($value as $index => $ele) {
$temp_arr[$payment_method[$count]][] = array(
'due_date' => $duedate[$key][$index],
'amount' => $ele
);
}
}
$count++;
}
$store_json = json_encode($temp_arr);
$due_amount_date = $store_json;
$data_to_db = array(
'course_fee_id' => $course_fee_id,
'due_amount_date' => $due_amount_date,
'is_active' => $active
);
if ($feeId == 0) {
$insertQuery = $this->Admin_model->add_edit_table('installment', $feeId, $data_to_db);
if ($insertQuery) {
$this->session->set_flashdata('success', str_replace('%s', 'Fees installment', THE_ADD_SUCCESS_MSG));
redirect(base_url() . 'admin/fee-installment');
} else {
$this->session->set_flashdata('failed', str_replace('%s', 'Fees installment', THE_ADD_ERROR_MSG));
redirect(base_url() . 'admin/fee-installment');
}
}
if ($feeId > 0) {
$pay['course_fee_id'] = $course_fee_id;
$check_payment = $this->db->get_where('students_online_payments', $pay)->row();
if (!empty($check_payment)) {
$this->session->set_flashdata('failed', 'Installment cannot be edited as a payment has already been made');
redirect(base_url() . 'admin/fee-installment');
}
$updateQuery = $this->Admin_model->add_edit_table('installment', $feeId, $data_to_db);
if ($updateQuery) {
$this->session->set_flashdata('success', str_replace('%s', 'Fees installment', THE_UPDATE_SUCCESS_MSG));
redirect(base_url() . 'admin/fee-installment');
} else {
$this->session->set_flashdata('failed', str_replace('%s', 'Fees installment', THE_UPDATE_ERROR_MSG));
redirect(base_url() . 'admin/fee-installment');
}
}
}
public function delete_course_installment($installment_id)
{
$course_fee_id = $this->db->get_where('installment', array('id' => $installment_id))->row()->course_fee_id;
$pay['course_fee_id'] = $course_fee_id;
$check_payment = $this->db->get_where('students_online_payments', $pay)->row();
if (!empty($check_payment)) {
$this->session->set_flashdata('failed', 'Installment cannot be deleted as a payment has already been made');
redirect(base_url() . 'admin/fee-installment');
}
$deleteInst = $this->Admin_model->delete_row('installment', array('id' => $installment_id));
if ($deleteInst) {
$this->session->set_flashdata('success', str_replace('%s', 'Fees installment', THE_DELETE_SUCCESS_MSG));
redirect(base_url() . 'admin/fee-installment');
} else {
$this->session->set_flashdata('failed', str_replace('%s', 'Fees installment', THE_DELETE_ERROR_MSG));
redirect(base_url() . 'admin/fee-installment');
}
}
// Fee installment end - 16-11-2021
// Online session delete by shivakumar start
public function delete_online_session($sessionId)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$sessionId = ($sessionId != '') ? $sessionId : 0;
if ($sessionId != 0) {
$result = $this->Admin_model->delete_onlinesession($sessionId);
if ($result == 'exists') {
$this->session->set_flashdata('danger', str_replace('%s', 'Online Session', ALREADY_ASSIGNED_TIMETABLE_MSG));
} else if ($result == 'success') {
$this->session->set_flashdata('success', str_replace('%s', 'Online Session', THE_DELETE_SUCCESS_MSG));
} else if ($result == 'failed') {
$this->session->set_flashdata('danger', str_replace('%s', 'Online Session', THE_DELETE_ERROR_MSG));
}
} else {
$this->session->set_flashdata('danger', str_replace('%s', 'Online Session', THE_DELETE_ERROR_MSG));
}
redirect(base_url() . 'admin/online_session_list');
}
// Online session delete by shivakumar end
public function reports()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/report.php'))
show_404();
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$fee_type_data = array();
$studentInfo = array();
$start_date = date('Y-m-01', strtotime($this->nepali_current_date));
$current_date = date('Y-m-t', strtotime($this->nepali_current_date));
$sqlQuery1 = "SELECT id as feetype_id,feetype_name,icon FROM fee_types WHERE is_active='yes'";
$feetypelist = $this->Admin_model->get_query_result($sqlQuery1);
if (isset($feetypelist) && !empty($feetypelist)) {
foreach ($feetypelist as $ftype) {
if ($ftype['feetype_id'] == 1) {
$appication_totalamt = $this->Admin_model->get_currentmonthfee($start_date, $current_date, $ftype['feetype_name'], 'student_fee_online_transactions');
$fee_type_data[] = array(
'feetype_id' => $ftype['feetype_id'],
'feetype_name' => $ftype['feetype_name'],
'feetype_icon' => $ftype['icon'],
'feetype_total' => 0,
'feetype_due_amt' => 0,
'feetype_paid_amount' => (isset($appication_totalamt) && !empty($appication_totalamt)) ? $appication_totalamt : 0
);
} else {
$result = $this->Admin_model->currentMonth_fee($start_date, $current_date, $ftype['feetype_id']);
$fee_type_data[] = array(
'feetype_id' => $ftype['feetype_id'],
'feetype_name' => $ftype['feetype_name'],
'feetype_icon' => $ftype['icon'],
'feetype_total' => (isset($result['total_course_fee']) && !empty($result['total_course_fee'])) ? $result['total_course_fee'] : 0,
'feetype_due_amt' => (isset($result['pending_fee']) && !empty($result['pending_fee'])) ? $result['pending_fee'] : 0,
'feetype_paid_amount' => (isset($result['paid_amount']) && !empty($result['paid_amount'])) ? $result['paid_amount'] : 0
);
}
}
}
if ($this->input->post('filtersubmit') == "filter") {
$feestype = (isset($_POST['by_feetype']) && !empty($_POST['by_feetype'])) ? $_POST['by_feetype'] : '';
$courseId = (isset($_POST['by_course_id']) && !empty($_POST['by_course_id'])) ? $_POST['by_course_id'] : 0;
$startDate = (isset($_POST['by_start_paid_date']) && !empty($_POST['by_start_paid_date'])) ? $_POST['by_start_paid_date'] : date('Y-m-01', strtotime($this->nepali_current_date));
$endDate = (isset($_POST['by_end_paid_date']) && !empty($_POST['by_end_paid_date'])) ? $_POST['by_end_paid_date'] : date('Y-m-t', strtotime($this->nepali_current_date));
$where = '';
if ($feestype != '')
$where = "WHERE payment_for LIKE '%$feestype%'";
// else if ($startDate != '')
// $where = "WHERE date(payment_date) = '$startDate'";
// else if ($endDate != '')
// $where = "WHERE date(payment_date) = '$endDate'";
else if ($startDate != '' && $endDate != '')
$where = "WHERE date(payment_date) BETWEEN '$startDate' AND '$endDate'";
else if ($feestype != '' && $startDate != '')
$where = "WHERE payment_for LIKE '%$feestype%' AND date(payment_date) = '$startDate'";
else if ($feestype != '' && $startDate != '' && $endDate != '')
$where = "WHERE payment_for LIKE '%$feestype%' AND Date(payment_date) BETWEEN '$startDate' AND '$endDate'";
$Sqlquery = "SELECT * FROM `student_fee_online_transactions` $where ORDER BY id DESC";
$fees_transactins = $this->Admin_model->get_query_result($Sqlquery);
foreach ($fees_transactins as $ft_value) {
$studentId = (isset($ft_value['studentId']) && !empty($ft_value['studentId'])) ? $ft_value['studentId'] : 0;
if ($courseId != 0) {
$student_where = array('applicationid' => $studentId, 'course' => $courseId);
} else {
$student_where = array('applicationid' => $studentId);
}
$student = $this->db->get_where('applications', $student_where)->row_array();
$studentDetails = (isset($student) && !empty($student)) ? $student : 0;
if ($studentDetails == 0) {
if ($courseId != 0) {
$Studentwhere = array('studentId' => trim($studentId), 'course' => $courseId);
} else {
$Studentwhere = array('studentId' => $studentId);
}
$studentDetails = $this->db->get_where('students', $Studentwhere)->row_array();
}
if ($studentDetails != '') {
$student_data = array(
'studentId' => $studentId,
'stud_id' => $studentId,
'name' => $studentDetails['name'],
'course' => $studentDetails['course'],
'payment_for' => $ft_value['payment_for'],
'payment_amt' => $ft_value['payment_amt'],
'txn_id' => $ft_value['txn_id'],
'invoice_no' => $ft_value['invoice_no'],
'payment_date' => $ft_value['payment_date'],
'status' => $ft_value['status'],
'course_fee_id' => (isset($ft_value['course_fee_id']) && ($ft_value['course_fee_id'] != 0)) ? $ft_value['course_fee_id'] : 0
);
$studentInfo[] = $student_data;
}
}
$data['search_course_id'] = $courseId;
$data['search_feetype'] = $feestype;
$data['search_start_paid_date'] = $startDate;
$data['search_end_paid_date'] = $endDate;
} else {
$Sqlquery = "SELECT * FROM `student_fee_online_transactions` ORDER BY id DESC LIMIT 100";
$fees_transactins = $this->Admin_model->get_query_result($Sqlquery);
foreach ($fees_transactins as $ft_value) {
$studentId = $ft_value['studentId'];
$student = $this->db->get_where('applications', array('applicationid' => $studentId))->row_array();
$studentDetails = (isset($student) && !empty($student)) ? $student : 0;
if ($studentDetails == 0) {
$studentDetails = $this->db->get_where('students', array('studentId' => $studentId))->row_array();
}
if ($studentDetails != '') {
$student_data = array(
'studentId' => $studentId,
'stud_id' => $studentDetails['id'],
'name' => $studentDetails['name'],
'course' => $studentDetails['course'],
'payment_for' => $ft_value['payment_for'],
'payment_amt' => $ft_value['payment_amt'],
'txn_id' => $ft_value['txn_id'],
'invoice_no' => $ft_value['invoice_no'],
'payment_date' => $ft_value['payment_date'],
'status' => $ft_value['status'],
'course_fee_id' => (isset($ft_value['course_fee_id']) && ($ft_value['course_fee_id'] != 0)) ? $ft_value['course_fee_id'] : 0
);
$studentInfo[] = $student_data;
}
}
}
$data['student_fees'] = $studentInfo;
$data['current_report_data'] = $fee_type_data;
$data['course_list'] = $this->db->query("select * from course WHERE is_active='yes'")->result_array();
$data['feetype_list'] = $this->db->query("select * from fee_types WHERE is_active='yes'")->result_array();
$this->load->view('admin/header', $data);
$this->load->view('admin/report', $data);
$this->load->view('admin/footer');
}
public function payment_overview($fees_type_id)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/payment_overview.php'))
show_404();
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
if ($this->input->post('search_filter') == "Filter") {
$this->form_validation->set_rules('by_feetype', 'Fees Type', 'required');
$feesTypeID = (isset($_POST['by_feetype']) && !empty($_POST['by_feetype'])) ? $_POST['by_feetype'] : '';
$feeTypeName = $this->db->get_where('fee_types', array('id' => $feesTypeID))->row()->feetype_name;
$courseId = (isset($search['course_id']) && !empty($search['course_id'])) ? $search['course_id'] : 0;
$start_date = (isset($search['start_date']) && !empty($search['start_date'])) ? $search['start_date'] : date('y-m-01');
$end_date = (isset($search['end_date']) && !empty($search['end_date'])) ? $search['end_date'] : date('y-m-t');
$by_payment_status = (isset($search['by_payment_status']) && !empty($search['by_payment_status'])) ? $search['by_payment_status'] : '';
if ($feesTypeID == 1) {
$data['payment_data'] = $this->Admin_model->get_payment_by_filter($_POST, $feeTypeName);
} else {
$data['payment_data'] = $this->Admin_model->get_payment_by_filter_student($_POST, $feeTypeName);
}
$data['search_feetype'] = $feesTypeID;
if ($courseId != 0)
$data['course_id'] = $courseId;
if ($by_payment_status != '')
$data['by_payment_status'] = $by_payment_status;
} else {
if ($fees_type_id > 0) {
$feeTypeName = $this->db->get_where('fee_types', array('id' => $fees_type_id))->row()->feetype_name;
if ($fees_type_id == 1) {
$data['payment_data'] = $this->Admin_model->get_application_fee($feeTypeName);
} else {
$data['payment_data'] = $this->Admin_model->get_student_fee($feeTypeName);
}
$data['search_feetype'] = $fees_type_id;
}
}
$data['course_list'] = $this->db->query("select * from course WHERE is_active='yes'")->result_array();
$data['feetype_list'] = $this->db->query("select * from fee_types WHERE is_active='yes'")->result_array();
$this->load->view('admin/header', $data);
$this->load->view('admin/payment_overview', $data);
$this->load->view('admin/footer');
}
public function downloadSingleId($studentId)
{
$studentinfo = $this->Admin_model->getstudentRow($studentId);
$data['studentinfo'] = $studentinfo;
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
// dd($data);
// $this->load->view('admin/singlecard', $data);
$this->load->library('m_pdf');
$html = $this->load->view('admin/singlecard', $data, true); //load the pdf.php by passing our data and get all data in $html varriable.
$pdfFilePath = $studentinfo['studentId'] . '-' . date('Y-m-d H:i:s', strtotime($this->nepali_current_date)) . ".pdf";
$pdf = $this->m_pdf->loadforStudentIdCard();
// $stylesheet = '<style>' . file_get_contents('assets_student/css/bootstrap.css') . '</style>';
// $pdf->WriteHTML($stylesheet, 1);
$pdf->WriteHTML($html, 2);
$pdf->Output($pdfFilePath, "D");
}
public function downloadAll()
{
$studnet_arr = $this->input->post('student_id_list');
$this->load->library('m_pdf');
$studentData = array();
foreach ($studnet_arr as $studValue) {
$studentData[] = $this->Admin_model->getstudentRow($studValue);
}
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['studentlist'] = $studentData;
// $this->load->view('admin/multipulecards', $data);
$html = $this->load->view('admin/multipulecards', $data, true);
$pdfFilePath = 'StudentCards' . '-' . date('YmdHis') . ".pdf";
$pdf = $this->m_pdf->loadforStudentIdCard();
$pdf->WriteHTML($html, 2);
$pdf->Output($pdfFilePath, "D");
}
public function invoice($studID, $txn_ID, $count, $invoiceList)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/invoice.php'))
show_404();
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$studentID = urlsafe_b64decode($studID);
$txnID = urlsafe_b64decode($txn_ID);
$counter = urlsafe_b64decode($count);
$invoiceList = urlsafe_b64decode($invoiceList);
if ($counter > 1)
$data['back_url'] = 'admin/student_fee_course/' . $counter;
else
$data['back_url'] = 'admin/reports';
// $i_list = [];
if ($studentID != '' && $txnID != '') {
$students = $this->db->get_where('students', array('studentId' => $studentID))->row_array();
// $students = $this->db->query("SELECT name as FROM students WHERE studentId = $studentID")->row_array();
$invoiceData = $students;
$i_list = explode(',', $invoiceList);
$i_list_data = [];
foreach ($i_list as $i_value) {
$sql1 = "SELECT course_fees.fee_values,s.course as courseID,s.name,s.studentId,b.b_from,b.b_name as batch_name,b.b_end,sb.batch_id,cl.course_id,cl.section_id,s.parent_pan,sfot.remarks
FROM student_fee_online_transactions sfot LEFT JOIN students s ON sfot.studentId=s.studentId LEFT JOIN student_batch sb ON s.id=sb.student_id AND s.batch_id = sb.batch_id LEFT JOIN classroom cl ON cl.id=sb.classroom_id LEFT JOIN batch b ON sb.batch_id=b.id
INNER JOIN course_fees ON sfot.course_fee_id = course_fees.id
WHERE sfot.studentId='$studentID' AND sfot.txn_id='$txnID' order by sb.id desc";
// $invoice = $this->db->query("select sf.* from student_fee_online_transactions sf WHERE sf.id = $i_value")->result_array();
$invoice = $this->db->get_where('student_fee_online_transactions', array('id' => $i_value))->row_array();
$courseFee =
$this->db->query("select id as course_fee_id, amount as fee_amount, fee_values as fee_name, batch_id from course_fees where id = " . $invoice['course_fee_id'])->row_array();
$invoice['course_fee'] = $courseFee;
// print_r($invoice);
$i_list_data[$i_value] = $invoice;
// print_r($i_list_data[$i_value]->payment_for);
}
$selectedBatch = $invoice['course_fee']['batch_id'];
// dd($invoice['course_fee'] );
// $student_ID = $this->db->get_where('students', array('studentId' => $studentID))->row();
// if ($student_ID != '') {
$sql1 = "SELECT course_fees.fee_values,s.course as courseID,s.name,s.studentId,b.b_from,b.b_name as batch_name,b.b_end,sb.batch_id,cl.course_id,cl.section_id,s.parent_pan
FROM student_fee_online_transactions sfot
LEFT JOIN students s ON sfot.studentId=s.studentId
LEFT JOIN student_batch sb ON s.id=sb.student_id AND sb.batch_id = $selectedBatch
LEFT JOIN classroom cl ON cl.id=sb.classroom_id
LEFT JOIN batch b ON sb.batch_id=b.id
INNER JOIN course_fees ON sfot.course_fee_id = course_fees.id
WHERE sfot.studentId='$studentID' AND sfot.txn_id='$txnID' order by sb.id desc";
$payment_data = $this->Admin_model->get_query_row($sql1);
// print_r($payment_data);
$student_data = array(
'studentId' => $payment_data['studentId'],
'studentname' => $payment_data['name'],
'batch_name' => $payment_data['batch_name'],
'batch_from' => $payment_data['b_from'],
'batch_end' => $payment_data['b_end'],
'course_id' => (isset($payment_data['course_id']) && !empty($payment_data['course_id'])) ? $payment_data['course_id'] : $payment_data['courseID'],
'tdt' => date('Y-m-d H:i:s', strtotime($this->nepali_current_date)),
'section_id' => $payment_data['section_id'],
'parent_pan' => (isset($payment_data['parent_pan']) && !empty($payment_data['parent_pan'])) ? $payment_data['parent_pan'] : '',
// 'invoice_no' => (isset($payment_data['invoice_no']) && !empty($payment_data['invoice_no'])) ? $payment_data['invoice_no'] : ''
);
$student_data['invoices'] = $i_list_data;
$data['invoice_data'] = $student_data;
// $data['invoice_data'] = $student_data;
// } else {
// $sql2 = "SELECT soft.*,course_fees.fee_values,a.name,a.course,b.b_name as batch_name,b.b_from,b.b_end FROM student_fee_online_transactions soft LEFT JOIN applications a ON a.applicationid=soft.studentId LEFT JOIN batch b ON b.id=a.batch_id LEFT JOIN course_fees ON soft.course_fee_id = course_fees.id WHERE soft.studentId='$studentID' AND soft.txn_id='$txnID' order by soft.id desc";
// $paymentdata = $this->Admin_model->get_query_row($sql2);
// // dd($sql2);
// if (count($paymentdata) > 0) {
// $application_data = array(
// 'student_fee_online_transactions_id' => $paymentdata['id'],
// 'studentId' => $paymentdata['studentId'],
// 'payment_for' => $paymentdata['fee_values'] . '(' . $paymentdata['payment_for'] . ')',
// 'txn_id' => $paymentdata['txn_id'],
// 'payment_amt' => $paymentdata['payment_amt'],
// 'paid_date' => $paymentdata['payment_date'],
// 'studentname' => $paymentdata['name'],
// 'batch_name' => $paymentdata['batch_name'],
// 'batch_from' => $paymentdata['b_from'],
// 'batch_end' => $paymentdata['b_end'],
// 'course_id' => $paymentdata['course'],
// 'received_by' => $paymentdata['payment_recived_id'],
// 'payment_method' => $paymentdata['payment_method'],
// 'fine_amount' => $paymentdata['fine_amount'],
// 'tdt' => date('Y-m-d H:i:s', strtotime($this->nepali_current_date)),
// 'deduction_type' => $paymentdata['deduction_type'],
// 'deduction_amount' => $paymentdata['deduction_amount'],
// 'section_id' => 0,
// 'bill_print_count' => $paymentdata['bill_print_count'],
// 'course_fee_id' => $paymentdata['course_fee_id'],
// 'install_sno' => $paymentdata['install_sno'],
// 'parent_pan' => '',
// 'invoice_no' => (isset($paymentdata['invoice_no']) && !empty($paymentdata['invoice_no'])) ? $paymentdata['invoice_no'] : ''
// );
// $data['invoice_data'] = $application_data;
// }
// }
}
$this->load->view('admin/header', $data);
$this->load->view('admin/invoice', $data);
$this->load->view('admin/footer');
}
public function invoicedownload($studID, $txn_ID)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/invoicepdf.php'))
show_404();
$this->load->library('m_pdf');
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$studentID = urlsafe_b64decode($studID);
$txnID = urlsafe_b64decode($txn_ID);
if ($studentID != '' && $txnID != '') {
$student_ID = $this->db->get_where('students', array('studentId' => $studentID))->row();
if ($student_ID != '') {
$this->db->where('studentId', $studentID);
$this->db->where('txn_id', $txnID);
$this->db->set('bill_print_count', 'bill_print_count+1', FALSE);
$update = $this->db->update('student_fee_online_transactions');
$sql1 = "SELECT sfot.*,course_fees.fee_values,s.course as courseID,s.name,s.studentId,b.b_name as batch_name,b.b_from,b.b_end,sb.batch_id,cl.course_id,cl.section_id,s.parent_pan FROM student_fee_online_transactions sfot LEFT JOIN students s ON sfot.studentId=s.studentId LEFT JOIN student_batch sb ON s.id=sb.student_id AND sb.batch_id = s.batch_id LEFT JOIN classroom cl ON cl.id=sb.classroom_id LEFT JOIN batch b ON sb.batch_id=b.id
INNER JOIN course_fees ON sfot.course_fee_id = course_fees.id
WHERE sfot.studentId='$studentID' AND sfot.txn_id='$txnID' order by sb.id desc";
$payment_data = $this->Admin_model->get_query_row($sql1);
$student_data = array(
'student_fee_online_transactions_id' => $payment_data['id'],
'studentId' => $payment_data['studentId'],
'payment_for' => $payment_data['fee_values'] . '(' . $payment_data['payment_for'] . ')',
'txn_id' => $payment_data['txn_id'],
'payment_amt' => $payment_data['payment_amt'],
'paid_date' => $payment_data['payment_date'],
'studentname' => $payment_data['name'],
'batch_name' => $payment_data['batch_name'],
'batch_from' => $payment_data['b_from'],
'batch_end' => $payment_data['b_end'],
'received_by' => $payment_data['payment_recived_id'],
'payment_method' => $payment_data['payment_method'],
'course_id' => (isset($payment_data['course_id']) && !empty($payment_data['course_id'])) ? $payment_data['course_id'] : $payment_data['courseID'],
'tdt' => date('Y-m-d H:i:s', strtotime($this->nepali_current_date)),
'section_id' => $payment_data['section_id'],
'payment_method' => $payment_data['payment_method'],
'fine_amount' => $payment_data['fine_amount'],
'deduction_type' => $payment_data['deduction_type'],
'deduction_amount' => $payment_data['deduction_amount'],
'bill_print_count' => $payment_data['bill_print_count'],
'course_fee_id' => $payment_data['course_fee_id'],
'install_sno' => $payment_data['install_sno'],
'parent_pan' => (isset($payment_data['parent_pan']) && !empty($payment_data['parent_pan'])) ? $payment_data['parent_pan'] : '',
'invoice_no' => (isset($payment_data['invoice_no']) && !empty($payment_data['invoice_no'])) ? $payment_data['invoice_no'] : ''
);
$data['invoice_data'] = $student_data;
} else {
$this->db->where('studentId', $studentID);
$this->db->where('txn_id', $txnID);
$this->db->set('bill_print_count', 'bill_print_count+1', FALSE);
$update = $this->db->update('student_fee_online_transactions');
$sql2 = "SELECT soft.*,course_fees.fee_values,a.name,a.course,b.b_name as batch_name,b.b_from,b.b_end FROM student_fee_online_transactions soft LEFT JOIN applications a ON a.applicationid=soft.studentId LEFT JOIN batch b ON b.id=a.batch_id INNER JOIN course_fees ON soft.course_fee_id = course_fees.id WHERE soft.studentId='$studentID' AND soft.txn_id='$txnID' order by soft.id desc";
$paymentdata = $this->Admin_model->get_query_row($sql2);
if (count($paymentdata) > 0) {
$application_data = array(
'student_fee_online_transactions_id' => $paymentdata['id'],
'studentId' => $paymentdata['studentId'],
'payment_for' => $paymentdata['fee_values'] . '(' . $paymentdata['payment_for'] . ')',
'txn_id' => $paymentdata['txn_id'],
'payment_amt' => $paymentdata['payment_amt'],
'paid_date' => $paymentdata['payment_date'],
'studentname' => $paymentdata['name'],
'batch_name' => $paymentdata['batch_name'],
'batch_from' => $paymentdata['b_from'],
'batch_end' => $paymentdata['b_end'],
'received_by' => $paymentdata['payment_recived_id'],
'payment_method' => $paymentdata['payment_method'],
'course_id' => $paymentdata['course'],
'tdt' => date('Y-m-d H:i:s', strtotime($this->nepali_current_date)),
'section_id' => 0,
'payment_method' => $paymentdata['payment_method'],
'fine_amount' => $paymentdata['fine_amount'],
'deduction_type' => $paymentdata['deduction_type'],
'deduction_amount' => $paymentdata['deduction_amount'],
'bill_print_count' => $paymentdata['bill_print_count'],
'course_fee_id' => $paymentdata['course_fee_id'],
'install_sno' => $paymentdata['install_sno'],
'parent_pan' => '',
'invoice_no' => (isset($paymentdata['invoice_no']) && !empty($paymentdata['invoice_no'])) ? $paymentdata['invoice_no'] : ''
);
$data['invoice_data'] = $application_data;
}
}
}
// $this->load->view('admin/invoicepdf', $data);
$html = $this->load->view('admin/invoicepdf', $data, true);
$pdfFilePath = $studentID . '-' . date('Y-m-dHis') . ".pdf";
$pdf = $this->m_pdf->loadforinvoice();
// $stylesheet = file_get_contents(base_url().'assets_admin/css/invoice.css'); // external css
// $pdf->WriteHTML($stylesheet,1);
$pdf->WriteHTML($html, 2);
$pdf->Output($pdfFilePath, "D");
}
public function delete_test_exam_question($id)
{
$sql = $this->Admin_model->delete_test_exam_question($id);
if ($sql) {
$this->session->set_flashdata('success', 'Exam Questions has been successfully deleted');
redirect(base_url() . 'admin/test-exam-list');
} else {
$this->session->set_flashdata('danger', 'Exam Questions could not been deleted, Please try again!');
redirect(base_url() . 'admin/test-exam-list');
}
}
// batch date by shivakumar start
public function getbatchDates()
{
$batchID = (isset($_POST['batch_id']) && !empty($_POST['batch_id'])) ? $_POST['batch_id'] : 0;
if ($batchID > 0) {
$sql = "SELECT * from batch WHERE id='$batchID'";
$result = $this->Admin_model->get_query_row($sql);
if (!empty($result)) {
echo json_encode($result);
} else
echo 0;
} else
echo 0;
}
public function fee_collection($appID)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/feecollection.php'))
show_404();
$cfid = '';
$cid = '';
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$student_id = '';
if ($appID) {
$applicationID = (isset($appID) && !empty($appID)) ? urlsafe_b64decode($appID) : 0;
$Sql = "SELECT * FROM applications WHERE applicationid='$applicationID'";
$result = $this->Admin_model->get_query_row($Sql);
if ($result != '') {
$course_fees = $this->Admin_model->applications_get($result, 2);
$data['feetypeName'] = $this->db->get_where('fee_types', array('id' => 2))->row()->feetype_name;
$course_fee_id = ($course_fees != '') ? $course_fees['id'] : 0;
$sqlQuery1 = "SELECT * FROM installment WHERE course_fee_id=$course_fee_id AND is_active='yes'";
$data['installment'] = $this->Admin_model->get_query_row($sqlQuery1);
$data['course_fees'] = $course_fees;
$data['studentinfo'] = $result;
$data['student_info_array']['name'] = $result['name'];
$data['student_info_array']['email'] = $result['email'];
$data['student_info_array']['applicationid'] = $result['applicationid'];
}
}
//Student Info
$this->load->view('admin/header', $data);
$this->load->view('admin/feecollection', $data);
$this->load->view('admin/footer');
}
function get_installdetails()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
//paypal return transaction details array
$install_type = $this->input->post('install_type');
$installment_id = $this->input->post('installment_id');
$applicationId = $this->input->post('application_id');
$install = $this->Admin_model->install_get($installment_id);
$array_install = json_decode($install['due_amount_date']);
$html = '';
foreach ($array_install as $key => $installvalue) {
if ($key == $install_type) {
foreach ($installvalue as $inskey => $val) {
$due_date = ($inskey == 0) ? "<span> Instant Payment </span>" : "<span>" . $val->due_date . "</span>";
$checkbox = ($inskey == 0) ? "style='color:green'" : "style='color:red'";
$firstPayment = ($inskey == 0) ? $val->amount : 0;
$html .= '<div class="row"><div class="instalment-row"><i class="far fa-check-circle" ' . $checkbox . '></i>
<input readonly type = "text" value = ' . $val->amount . ' id = "feeamount" data-amt="' . $firstPayment . '" />
<label> - ' . $due_date . '</label>
</div></div>';
// <input type = "text" value = ' . $n["payable_amount"] . ' id = "feeamount" />
// <div> <p>Due dates : </p>' . str_replace(',', '<br>', $n["duedates"]) . '
// </div>
}
}
}
echo $html;
}
public function feecollectionFromStudent()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$application_id = $_POST['application_id'];
$course_fee_id = $_POST['course_fee_id'];
$payment_method = $_POST['payment_method'];
$installType = $_POST['payment_options'];
$description = $_POST['description'];
$totalAmount = $_POST['totalAmount'];
$fees_type = $_POST['fees_type'];
$school_info = $this->Admin_model->get_logo_from_setting();
$reimbursement_type = $_POST['deduction_type'] ? $_POST['deduction_type'] : '';
$reimbursement_amount = $_POST['deduction_amount'] ? $_POST['deduction_amount'] : 0;
$studfees = array();
$stid = $this->Admin_model->applicationinfo_movingto_students($application_id);
if ($stid == -1) {
$this->session->set_flashdata('danger', 'Payment Failed');
redirect(base_url() . 'admin/get_application');
} else {
$studentappId = $this->db->get_where('students', array('id' => $stid))->row()->studentId;
$coursefees = $this->Admin_model->get_query_row("SELECT id,due_amount_date FROM installment WHERE course_fee_id=$course_fee_id");
$coursefeesarr = json_decode($coursefees['due_amount_date']);
$firstpay = true;
foreach ($coursefeesarr as $k => $cf_value) {
if ($installType == $k) {
foreach ($cf_value as $index => $val1) {
if ($firstpay) {
$studfees[] = array(
'install_sno' => $index + 1,
'due_date' => $val1->due_date,
'feeamount' => $val1->amount,
'deduction_type' => $reimbursement_type,
'deduction_amount' => $reimbursement_amount,
'paid_amount' => $totalAmount - $reimbursement_amount,
'payment_status' => 'yes',
'paid_date' => date('Y-m-d H:i:s', strtotime($this->nepali_current_date))
);
$firstpay = false;
} else {
$studfees[] = array(
'install_sno' => $index + 1,
'due_date' => $val1->due_date,
'feeamount' => $val1->amount,
'deduction_type' => '',
'deduction_amount' => 0,
'paid_amount' => 0,
'payment_status' => 'no',
'paid_date' => date('Y-m-d H:i:s', strtotime($this->nepali_current_date))
);
}
}
}
}
$stdentfee = array(
'student_id' => $stid,
'course_fee_id' => $course_fee_id,
'installment_type_id' => $installType,
'payment_details' => json_encode($studfees),
'payment_method' => $payment_method,
'created' => date('Y-m-d H:i:s', strtotime($this->nepali_current_date)),
'modified' => date('Y-m-d H:i:s', strtotime($this->nepali_current_date))
);
$result = $this->db->insert('students_online_payments', $stdentfee);
if (!empty($result)) {
$a = mt_rand(100000, 999999);
$transData['studentId'] = (!empty($studentappId)) ? $studentappId : $stid;
$transData['payment_for'] = $fees_type;
$transData['txn_id'] = $a . $studentappId;
$transData['payment_amt'] = $totalAmount;
$transData['currency_code'] = $school_info['currency'];
$transData['status'] = 'Completed';
$transData['payment_date'] = date('Y-m-d H:i:s', strtotime($this->nepali_current_date));
$transData['payment_recived_id'] = $this->session->userdata('admin_name');
$transData['payment_method'] = $payment_method;
$transData['bank_transaction_id'] = (isset($description) && !empty($description)) ? $description : NULL;
$transData['course_fee_id'] = $course_fee_id;
$rst = $this->Admin_model->storefeeTransaction($transData);
if ($rst)
$this->session->set_flashdata('success', 'Fees Added successfully');
else
$this->session->set_flashdata('error', 'Fees Insertion failed Transactions ');
} else {
$this->session->set_flashdata('error', 'Fees collection failed. Please Try once');
}
redirect(base_url() . 'admin/get_application');
}
}
//school Setting by Shankar
public function SchoolSetting()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/setting.php'))
show_404();
$data['title'] = 'School Settings';
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['courses'] = $this->Admin_model->get_courses();
$data['batch'] = $this->Admin_model->get_batch();
$data['result'] = $this->db->query('select * from school_settings where id= 1')->row_array();
// $rst=$this->db->query("SELECT invoice_no FROM `student_fee_online_transactions` ORDER BY id DESC")->row_array();
// if(!empty($rst)){
// $data['new_invoice_no']=(isset($rst['invoice_no']) && !empty($rst['invoice_no'])) ? $rst['invoice_no'] :"0000";
// }
$data['currency'] = currency_data();
$this->load->view('admin/header', $data);
$this->load->view('admin/setting');
$this->load->view('admin/footer');
}
public function AddEditSchoolSetting()
{
// echo "<pre>";print_r($_FILES);
$get_school_data = $this->db->get('school_settings')->row_array();
// dd($get_school_data);
if ($get_school_data) {
$signiture = 'common_assets/' . $get_school_data['authorized_signature'];
$white_logo = 'common_assets/' . $get_school_data['logo'];
$color_logo = 'common_assets/' . $get_school_data['color_logo'];
$markscard_header = ($get_school_data['markscard_header'] != '' && !empty($get_school_data['markscard_header'])) ? 'common_assets/' . $get_school_data['markscard_header'] : '';
} else {
$signiture = '';
$white_logo = '';
$color_logo = '';
$markscard_header = '';
}
$data_array = array();
// test_view_array($_FILES);
if (isset($_FILES["ssigniture"]["name"]) && !empty($_FILES["ssigniture"]["name"])) {
if (file_exists($signiture)) {
unlink($signiture);
}
// $_FILES["ssigniture"]["name"] = 'signature-scan.png';
$filename = $_FILES["ssigniture"]["name"];
$location = 'common_assets/' . $filename;
$imageFileType = pathinfo($location, PATHINFO_EXTENSION);
$imageFileType = strtolower($imageFileType);
/* Valid extensions */
$valid_extensions = array("png");
$response = 0;
/* Check file extension */
if (in_array(strtolower($imageFileType), $valid_extensions)) {
/* Upload file */
if (move_uploaded_file($_FILES['ssigniture']['tmp_name'], $location)) {
$data_array['authorized_signature'] = str_replace("common_assets/", "", $location);
}
}
}
if (isset($_FILES["swhiteLogo"]["name"]) && !empty($_FILES["swhiteLogo"]["name"])) {
if (file_exists($white_logo)) {
unlink($white_logo);
}
// $_FILES["swhiteLogo"]["name"] = 'white_logo.png';
$filename = $_FILES["swhiteLogo"]["name"];
$location = 'common_assets/' . $filename;
$imageFileType = pathinfo($location, PATHINFO_EXTENSION);
$imageFileType = strtolower($imageFileType);
/* Valid extensions */
$valid_extensions = array("png");
$response = 0;
/* Check file extension */
if (in_array(strtolower($imageFileType), $valid_extensions)) {
/* Upload file */
if (move_uploaded_file($_FILES['swhiteLogo']['tmp_name'], $location)) {
$data_array['logo'] = str_replace("common_assets/", "", $location);
}
}
}
if (isset($_FILES["scolorLogo"]["name"]) && !empty($_FILES["scolorLogo"]["name"])) {
if (file_exists($color_logo)) {
unlink($color_logo);
}
// $_FILES["scolorLogo"]["name"] = 'color_logo.png';
$filename = $_FILES["scolorLogo"]["name"];
$location = 'common_assets/' . $filename;
$imageFileType = pathinfo($location, PATHINFO_EXTENSION);
$imageFileType = strtolower($imageFileType);
/* Valid extensions */
$valid_extensions = array("png");
$response = 0;
/* Check file extension */
if (in_array(strtolower($imageFileType), $valid_extensions)) {
/* Upload file */
if (move_uploaded_file($_FILES['scolorLogo']['tmp_name'], $location)) {
$data_array['color_logo'] = str_replace("common_assets/", "", $location);
}
}
}
if (isset($_FILES["markscard_header"]["name"]) && !empty($_FILES["markscard_header"]["name"])) {
if ($markscard_header != '') {
if (file_exists($markscard_header)) {
unlink($markscard_header);
}
}
$filename = $_FILES["markscard_header"]["name"];
$location = 'common_assets/' . $filename;
$imageFileType = pathinfo($location, PATHINFO_EXTENSION);
$imageFileType = strtolower($imageFileType);
// echo $imageFileType; exit;
$valid_extensions = array("png", "jpg", "jpeg");
$response = 0;
/* Check file extension */
if (in_array($imageFileType, $valid_extensions)) {
// echo $imageFileType; exit;
/* Upload file */
if (move_uploaded_file($_FILES['markscard_header']['tmp_name'], $location)) {
$data_array['markscard_header'] = str_replace("common_assets/", "", $location);
}
}
}
// dd($data_array);
$data_array['school_name'] = $_POST['sname'];
$data_array['school_code'] = $_POST['scode'];
$data_array['email'] = $_POST['semail'];
$data_array['phone'] = $_POST['scontact'];
$data_array['address'] = $_POST['saddress'];
$data_array['website_link'] = $_POST['swebsite'];
$data_array['twitter'] = $_POST['stwitter'];
$data_array['instagram'] = $_POST['sinstagram'];
$data_array['facebook'] = $_POST['sfacebook'];
$data_array['date_format'] = $_POST['sdateformat'];
$data_array['batch_id'] = $_POST['sbatch'];
$cur_sym = explode('-', $_POST['scurrency']);
$data_array['currency'] = $cur_sym[0];
$data_array['currency_symbol'] = $cur_sym[1];
$data_array['modified'] = date('Y-m-d H:i:s', strtotime($this->nepali_current_date));
$data_array['pan'] = strtoupper($_POST['span']);
$data_array['school_prefix_id'] = strtoupper($_POST['school_prefix_id']);
$data_array['invoice_prefix'] = strtoupper($_POST['invoice_prefix']);
$data_array['invoice_sno'] = trim($_POST['invoice_sno']);
$data_array['invoice_prefix_status'] = $_POST['invoice_prefix_status'];
// $data_array['markscard_header'] = (isset($data_array['markscard_header']) && !empty($data_array['markscard_header'])) ? base_url('common_assets/'.$data_array['markscard_header']) :'';
// dd($data_array);
$this->db->where('id', 1);
$this->db->update('school_settings', $data_array);
$updated_status = $this->db->affected_rows();
if ($updated_status) {
$CI = &get_instance();
$logoSetting = $CI->load->database('schoolSetting', TRUE);
$check_school = $this->db->query('select school_main_id, auth_key from school_settings')->row_array();
if (isset($data_array['color_logo']) && !empty($data_array['color_logo'])) {
$content['logo'] = base_url('common_assets/' . $data_array['color_logo']);
$logoSetting->where('id', $check_school['school_main_id']);
$logoSetting->where('auth_key', $check_school['auth_key']);
$logoSetting->update('school_data', $content);
$updated_school_data = $logoSetting->affected_rows();
}
$check_image = $logoSetting->query('select logo from school_data where id=' . $check_school['school_main_id'] . ' AND auth_key = "' . $check_school['auth_key'] . '"')->row_array();
if (empty($check_image['logo'])) {
$content['logo'] = base_url('common_assets/black_logo.png');
$logoSetting->where('id', $check_school['school_main_id']);
$logoSetting->where('auth_key', $check_school['auth_key']);
$logoSetting->update('school_data', $content);
$updated_school_data = $logoSetting->affected_rows();
}
$this->session->set_flashdata('success', str_replace('%s', 'School Setting', THE_UPDATE_SUCCESS_MSG));
redirect(base_url() . 'admin/SchoolSetting');
} else {
$this->session->set_flashdata('danger', str_replace('%s', 'School Setting', THE_UPDATE_FAILED_MSG));
redirect(base_url() . 'admin/SchoolSetting');
}
}
//shiv kumar code for offline fee collection
public function student_fee_course()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
// if (!file_exists(APPPATH . 'views/admin/student-fee-list.php'))
// show_404();
$course_fee_id = $this->uri->segment(3);
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['fees_details'] = $this->db->query("select cf.id as course_fee_id,cf.batch_id, cf.course_id, ft.feetype_name, c.course_name, cf.amount from course c, course_fees cf, fee_types ft where cf.id = '$course_fee_id' and c.id = cf.course_id")->row_array();
$data['title'] = $data['fees_details']['feetype_name'];
$student_coure_fee = array();
if (!empty($data['fees_details'])) {
$student_list = $this->db->query('select s.id as student_id ,s.name, s.studentId from students s where s.course =' . $data['fees_details']['course_id'] . ' and s.batch_id =' . $data['fees_details']['batch_id'] . '')->result_array();
foreach ($student_list as $key => $value) {
$paid_list = $this->db->query('select sop.payment_details, sop.installment_type_id, sop.id as student_online_payment_id from students_online_payments sop where student_id =' . $value['student_id'] . ' and sop.course_fee_id =' . $data['fees_details']['course_fee_id'] . '')->row_array();
$get_txn_id = $this->db->query('select sfot.txn_id from student_fee_online_transactions sfot where sfot.course_fee_id = ' . $data['fees_details']['course_fee_id'] . ' and sfot.studentId ="' . $value['studentId'] . '" order by sfot.id DESC')->row_array();
if (!empty($paid_list))
array_push($student_coure_fee, array(
'status' => 1,
'student_id' => $value['student_id'],
'student_name' => $value['name'],
'student_number' => $value['studentId'],
'payment_details' => $paid_list['payment_details'],
'installment_type_id' => $paid_list['installment_type_id'],
'student_online_payment_id' => $paid_list['student_online_payment_id'],
'txn_id' => $get_txn_id['txn_id'] ? $get_txn_id['txn_id'] : 0
));
else
array_push($student_coure_fee, array(
'status' => 0,
'student_id' => $value['student_id'],
'student_name' => $value['name'],
'student_number' => $value['studentId']
));
}
}
$data['course_fee_student'] = $student_coure_fee;
$this->load->view('admin/header', $data);
$this->load->view('admin/student-fee-list', $data);
$this->load->view('admin/footer');
}
public function studentfeelistFromStudent()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$this->load->model('Student_model');
$application_id = $_POST['student_id']; //ECA007362
$course_fee_id = $_POST['fees_type_id']; // 13
$payment_method = $_POST['payment_method']; //cash or bank
$installType = $_POST['installment_type_id']; // 1,2,3,4
$description = $_POST['transaction_id']; // transaction id
$totalAmount = $_POST['amount']; // 5000
$fees_type = $_POST['fees_type']; // course fee , application
$school_info = $this->Admin_model->get_logo_from_setting();
$check_id_record_exist = $this->db->get_where('students_online_payments', array('student_id' => $application_id, 'course_fee_id' => $course_fee_id))->row();
$studentappId = $this->db->get_where('students', array('id' => $application_id))->row()->studentId;
if ($check_id_record_exist) {
$payment_installments = $check_id_record_exist->payment_details;
$payment_row_id = $check_id_record_exist->id;
$flag = true;
$installment_data = (array)json_decode($payment_installments);
foreach ($installment_data as $key => $value) {
if ($value->payment_status == 'no' && $flag) {
$installment_data[$key]->paid_amount = $totalAmount;
$installment_data[$key]->payment_status = 'yes';
$installment_data[$key]->paid_date = date('Y-m-d H:i:s', strtotime($this->nepali_current_date));
$flag = false;
}
}
$update_data['payment_details'] = json_encode($installment_data);
$update_data['modified'] = date('Y-m-d H:i:s', strtotime($this->nepali_current_date));
$result_success = $this->Student_model->add_edit_table('students_online_payments', $payment_row_id, $update_data);
} else {
$studfees = array();
$coursefees = $this->Admin_model->get_query_row("SELECT id,due_amount_date FROM installment WHERE course_fee_id=$course_fee_id");
if (empty($coursefees)) {
$this->session->set_flashdata('failed', 'Please Create Installment First');
redirect(base_url() . 'admin/student_fee_course/' . $course_fee_id);
}
$coursefeesarr = json_decode($coursefees['due_amount_date']);
$firstpay = true;
foreach ($coursefeesarr as $k => $cf_value) {
if ($installType == $k) {
foreach ($cf_value as $index => $val1) {
if ($firstpay) {
$studfees[] = array(
'install_sno' => $index + 1,
'due_date' => $val1->due_date,
'feeamount' => $val1->amount,
'paid_amount' => $totalAmount,
'payment_status' => 'yes',
'paid_date' => date('Y-m-d H:i:s')
);
$firstpay = false;
} else {
$studfees[] = array(
'install_sno' => $index + 1,
'due_date' => $val1->due_date,
'feeamount' => $val1->amount,
'paid_amount' => 0,
'payment_status' => 'no',
'paid_date' => date('Y-m-d H:i:s')
);
}
}
}
}
$stdentfee = array(
'student_id' => $application_id,
'course_fee_id' => $course_fee_id,
'installment_type_id' => $installType,
'payment_details' => json_encode($studfees),
'payment_method' => $payment_method,
'created' => date('Y-m-d H:i:s', strtotime($this->nepali_current_date)),
'modified' => date('Y-m-d H:i:s', strtotime($this->nepali_current_date))
);
$result_success = $this->db->insert('students_online_payments', $stdentfee);
}
if ($result_success) {
$transData['studentId'] = (!empty($studentappId)) ? $studentappId : $application_id;
$transData['payment_for'] = $fees_type;
$transData['txn_id'] = date('Ymd', strtotime($this->nepali_current_date)) . $studentappId;
$transData['payment_amt'] = $totalAmount;
$transData['currency_code'] = $school_info['currency'];
$transData['status'] = 'Completed';
$transData['payment_date'] = date('Y-m-d H:i:s', strtotime($this->nepali_current_date));
$transData['payment_recived_id'] = $this->session->userdata('admin_name');
$transData['payment_method'] = $payment_method;
$transData['bank_transaction_id'] = (isset($description) && !empty($description)) ? $description : NULL;
$transData['course_fee_id'] = $course_fee_id;
$rst = $this->Admin_model->storefeeTransaction($transData);
if ($rst)
$this->session->set_flashdata('success', 'Fees Added successfully');
else
$this->session->set_flashdata('failed', 'Fees Insertion failed Transactions ');
} else {
$this->session->set_flashdata('failed', 'Fees collection failed. Please Try once');
}
redirect(base_url() . 'admin/student_fee_course/' . $course_fee_id);
}
public function studentOfflineFees()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$this->load->model('Student_model');
$application_id = $_POST['student_id']; //ECA007362
$course_fee_id = $_POST['fees_type_id']; // 13
$payment_method = $_POST['payment_method']; //cash or bank
$installType = $_POST['installment_type_id']; // 1,2,3,4
$description = $_POST['transaction_id']; // transaction id
$totalAmount = $_POST['amount']; // 5000
$fees_type = $_POST['fees_type']; // course fee , application
$school_info = $this->Admin_model->get_logo_from_setting();
$check_id_record_exist = $this->db->get_where('students_online_payments', array('student_id' => $application_id, 'course_fee_id' => $course_fee_id))->row();
$studentappId = $this->db->get_where('students', array('id' => $application_id))->row()->studentId;
if ($check_id_record_exist) {
$payment_installments = $check_id_record_exist->payment_details;
$payment_row_id = $check_id_record_exist->id;
$flag = true;
$installment_data = (array)json_decode($payment_installments);
foreach ($installment_data as $key => $value) {
if ($value->payment_status == 'no' && $flag) {
$installment_data[$key]->paid_amount = $totalAmount;
$installment_data[$key]->payment_status = 'yes';
$installment_data[$key]->paid_date = date('Y-m-d H:i:s', strtotime($this->nepali_current_date));
$flag = false;
}
}
$update_data['payment_details'] = json_encode($installment_data);
$update_data['modified'] = date('Y-m-d H:i:s', strtotime($this->nepali_current_date));
$result_success = $this->Student_model->add_edit_table('students_online_payments', $payment_row_id, $update_data);
} else {
$studfees = array();
$coursefees = $this->Admin_model->get_query_row("SELECT id,due_amount_date FROM installment WHERE course_fee_id=$course_fee_id");
if (empty($coursefees)) {
$this->session->set_flashdata('failed', 'Please Create Installment First');
redirect(base_url() . 'admin/student_fee_course/' . $course_fee_id);
}
$coursefeesarr = json_decode($coursefees['due_amount_date']);
$firstpay = true;
foreach ($coursefeesarr as $k => $cf_value) {
if ($installType == $k) {
foreach ($cf_value as $index => $val1) {
if ($firstpay) {
$studfees[] = array(
'install_sno' => $index + 1,
'due_date' => $val1->due_date,
'feeamount' => $val1->amount,
'paid_amount' => $totalAmount,
'payment_status' => 'yes',
'paid_date' => date('Y-m-d H:i:s', strtotime($this->nepali_current_date))
);
$firstpay = false;
} else {
$studfees[] = array(
'install_sno' => $index + 1,
'due_date' => $val1->due_date,
'feeamount' => $val1->amount,
'paid_amount' => 0,
'payment_status' => 'no',
'paid_date' => date('Y-m-d H:i:s', strtotime($this->nepali_current_date))
);
}
}
}
}
$stdentfee = array(
'student_id' => $application_id,
'course_fee_id' => $course_fee_id,
'installment_type_id' => $installType,
'payment_details' => json_encode($studfees),
'payment_method' => $payment_method,
'created' => date('Y-m-d H:i:s', strtotime($this->nepali_current_date)),
'modified' => date('Y-m-d H:i:s', strtotime($this->nepali_current_date))
);
$result_success = $this->db->insert('students_online_payments', $stdentfee);
}
if ($result_success) {
$transData['studentId'] = (!empty($studentappId)) ? $studentappId : $application_id;
$transData['payment_for'] = $fees_type;
$transData['txn_id'] = date('Ymd') . $studentappId;
$transData['payment_amt'] = $totalAmount;
$transData['currency_code'] = $school_info['currency'];
$transData['status'] = 'Completed';
$transData['payment_date'] = date('Y-m-d H:i:s', strtotime($this->nepali_current_date));
$transData['payment_recived_id'] = $this->session->userdata('admin_name');
$transData['payment_method'] = $payment_method;
$transData['bank_transaction_id'] = (isset($description) && !empty($description)) ? $description : NULL;
$transData['course_fee_id'] = $course_fee_id;
$rst = $this->Admin_model->storefeeTransaction($transData);
if ($rst)
$this->session->set_flashdata('success', 'Fees Added successfully');
else
$this->session->set_flashdata('failed', 'Fees Insertion failed Transactions ');
} else {
$this->session->set_flashdata('failed', 'Fees collection failed. Please Try once');
}
redirect(base_url() . 'admin/view-student-payments/' . $application_id);
}
public function viewStudentImportFile()
{
if (isset($_SESSION['admin_id'])) {
if (isset($_SESSION['promote_table']))
$data['view_data'] = $_SESSION['promote_table'];
else
$data['view_data'] = null;
$cid = '';
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['course'] = $this->db->query("select * from course WHERE is_active='yes'")->result_array();
$data['batch'] = $this->Admin_model->get_batch();
$this->load->view('admin/header', $data);
$this->load->view('admin/importMemberList', $data);
$this->load->view('admin/footer');
}
}
public function importStudents()
{
$school_info = $this->Admin_model->get_logo_from_setting();
if (empty($_FILES['file']['name'])) {
$this->session->set_flashdata('failed', 'Please Upload CSV file... ');
redirect(base_url() . 'admin/student');
}
$fileAr = explode('.', $_FILES['file']['name']);
if ($fileAr[1] !== 'csv') {
$this->session->set_flashdata('failed', 'Please Upload CSV file... ');
redirect(base_url() . 'admin/viewStudentImportFile');
}
$this->load->library('CSVReader');
$result = $this->csvreader->parse_file($_FILES['file']['tmp_name']);
// dd();
$table_view = array();
$course_id = $_POST['course'];
$batch_id = $_POST['batch'];
$section_id = $_POST['section'];
if (count($result) > 500) {
$this->session->set_flashdata('failed', 'Data Should not be more than 500 ');
redirect(base_url() . 'admin/viewStudentImportFile');
}
foreach ($result as $key => $value) {
if (empty($value['name']) || empty($value['email']) || empty($value['mobile']) || empty($value['gender']) || empty($value['dob']) || empty($value['country']) || empty($value['state']) || empty($value['address1']) || empty($value['zipcode']) || empty($value['hostel']) || empty($value['registered_on']) || empty($value['payment_status']) || empty($value['assign_status']) || empty($value['emergency_contact_name']) || empty($value['emergency_contact_number']) || ((strtolower($value['payment_status']) != 'yes') && (strtolower($value['payment_status']) != 'no')) || ((strtolower($value['assign_status']) != 'yes') && (strtolower($value['assign_status']) != 'no')) || ((strtolower($value['hostel']) != 'yes') && (strtolower($value['hostel']) != 'no'))) {
array_push($table_view, array(
'name' => $value['name'],
'studentId' => '',
'batch_id' => $batch_id,
'email' => $value['email'],
'mobile' => $value['mobile'],
'gender' => $value['gender'],
'dob' => $value['dob'],
'registered_on' => $value['registered_on'],
'status' => 'madatory fields not filled'
));
continue;
}
// dd($table_view);
$check_query = $this->db->query("SELECT count(id) as count FROM students WHERE email = '" . $value['email'] . "'")->row_array();
if ($check_query['count'] > 0) {
array_push($table_view, array(
'name' => $value['name'],
'studentId' => '',
'batch_id' => $batch_id,
'email' => $value['email'],
'mobile' => $value['mobile'],
'gender' => $value['gender'],
'dob' => $value['dob'],
'registered_on' => date('Y-m-d', strtotime($value['registered_on'])),
'status' => 'duplicate'
));
continue;
}
// dd($table_view);
$this->db->select_max('id');
$query = $this->db->get('students');
$resid = $query->row_array();
$resid = (isset($resid['id']) && !empty($resid['id'])) ? $resid['id'] : 0;
$studentMaxId = $resid + 1;
// if (strlen($studentMaxId) == 1)
// $pid = "00000" . $studentMaxId;
// else if (strlen($studentMaxId) == 2)
// $pid = "0000" . $studentMaxId;
// else if (strlen($studentMaxId) == 3)
// $pid = "000" . $studentMaxId;
// else if (strlen($studentMaxId) == 4)
// $pid = "00" . $studentMaxId;
// else if (strlen($studentMaxId) == 5)
// $pid = "00" . $studentMaxId;
// $studentid = STUDENT_PREFIX . date('Y', strtotime($this->nepali_current_date)) . $pid;
// $parent_id = STUDENT_PARENT_PREFIX . date('Y', strtotime($this->nepali_current_date)) . $pid;
$pid = date('Y', strtotime($this->nepali_current_date)) . '0' . $studentMaxId;
$school_info = $this->Admin_model->get_logo_from_setting();
$school_prefix = (!empty($school_info['school_prefix_id'])) ? $school_info['school_prefix_id'] : 'BB';
$studentid = $school_prefix . STUDENT_PREFIX . $pid;
$parent_id = $school_prefix . STUDENT_PARENT_PREFIX . $pid;
$qr_path = $this->generate_qrcode($studentid);
$data_insert = array(
'name' => $value['name'],
'studentId' => $studentid,
'password' => md5($studentid),
'batch_id' => $batch_id,
'email' => $value['email'],
'mobile' => $value['mobile'],
'gender' => ucfirst($value['gender']),
'dob' => date('Y-m-d', strtotime($value['dob'])),
'course' => $course_id,
'emergency_contact_name' => $value['emergency_contact_name'],
'emergency_contact_number' => $value['emergency_contact_number'],
'country' => $value['country'],
'state' => $value['state'],
'address1' => $value['address1'],
'address2' => $value['address2'],
'zipcode' => $value['zipcode'],
'photo' => "No-Image.jpg",
'school_certificate' => "No-Image.jpg",
'exam_result' => "No-Image.jpg",
'medical_cerificate' => "No-Image.jpg",
'registered_on' => date('Y-m-d', strtotime($value['registered_on'])),
'qr_code' => $qr_path,
'parent_username' => $parent_id,
'parent_password' => md5($parent_id),
'payment_status' => strtolower($value['payment_status']),
'assign_status' => 'yes',
'hostel' => strtolower($value['hostel']),
'modified' => $this->nepali_current_date
);
$insert = $this->db->insert('students', $data_insert);
$newId = $this->db->insert_id();
if ($newId) {
$data_insert['status'] = 'success';
array_push($table_view, $data_insert);
$clas_query = $this->db->query("select * from classroom where course_id = $course_id and section_id = $section_id")->row_array();
if ($clas_query) {
$roll_no = $this->db->query('select roll_no from student_batch where batch_id=' . $batch_id . ' and classroom_id =' . $clas_query['id'] . ' and is_active ="yes" order by roll_no DESC')->row_array();
if (!empty($roll_no)) {
$in_data['roll_no'] = $roll_no['roll_no'] + 1;
} else {
$in_data['roll_no'] = 1;
}
$in_data['student_id'] = $newId;
$in_data['batch_id'] = $batch_id;
$in_data['classroom_id'] = $clas_query['id'];
$in_data['is_active'] = 'yes';
$in_data['created'] = $this->nepali_current_date;
$batch_student = $this->db->insert('student_batch', $in_data);
$batch_student_id = $this->db->insert_id();
$studentId = $this->db->get_where('students', array('id' => $newId))->row()->studentId;
// $course_fee_id=(isset($value['course_fee_id']) && !empty($value['course_fee_id'])) ? $value['course_fee_id'] : 0;
$course_fee_id = (isset($result[$key]['course_fee_id']) && !empty($result[$key]['course_fee_id'])) ? $result[$key]['course_fee_id'] : 0;
$paidAmt = (isset($result[$key]['paid_amount']) && !empty($result[$key]['paid_amount'])) ? $result[$key]['paid_amount'] : 0;
$paidDate = (isset($result[$key]['paid_date']) && !empty($result[$key]['paid_date'])) ? date('Y-m-d H:i:s', strtotime($result[$key]['paid_date'])) : date('Y-m-d H:i:s', strtotime($this->nepali_current_date));
$payment_method = (isset($result[$key]['payment_method']) && !empty($result[$key]['payment_method'])) ? strtolower($result[$key]['payment_method']) : 'cash';
if ($course_fee_id > 0) {
$coursefee = $this->db->get_where('course_fees', array('id' => $course_fee_id))->row_array();
if (count($coursefee) > 0) {
$fee_type_name = $this->db->get_where('fee_types', array('id' => $coursefee['fees_type']))->row()->feetype_name;
if ($coursefee['amount'] > 0 && $coursefee['amount'] >= $paidAmt) {
$pending_amount = ((int)$coursefee['amount'] - (int)$paidAmt);
$install_sno = 1;
$installmentData[] = array(
"install_sno" => $install_sno,
"payment_status" => "yes",
"payable_amount" => $paidAmt,
"paid_amount" => $paidAmt,
"paid_date" => $paidDate,
"total_amount" => $coursefee['amount'],
"pending_amount" => $pending_amount,
"due_date" => $coursefee['due_date'],
"deduction_type" => "",
"deduction_amount" => 0,
"fine_amount" => 0,
"payment_via" => $payment_method,
"updated_by" => $_SESSION['admin_id'] . ' - ' . $_SESSION['admin_name'] . ' - ' . $_SESSION['admin_email']
);
$students_online_payments = array(
'student_id' => $newId,
'installment_type_id' => $coursefee['fees_type'],
'course_fee_id' => $course_fee_id,
'paid_amount' => $paidAmt,
'pending_amount' => $pending_amount,
'payment_details' => json_encode($installmentData),
'payment_method' => $payment_method
);
// echo "<pre>";
// print_r($students_online_payments);
$this->db->insert('students_online_payments', $students_online_payments);
$fee_assigned_students = array('student_id' => $newId, 'course_fee_id' => $course_fee_id, 'created_at' => date('Y-m-d H:i:s', strtotime($this->nepali_current_date)), 'modified' => date('Y-m-d H:i:s', strtotime($this->nepali_current_date)));
$a = mt_rand(100000, 999999);
$transData['studentId'] = $studentId;
$transData['payment_for'] = $fee_type_name;
$transData['txn_id'] = $a . $studentId;
$transData['payment_amt'] = $paidAmt;
$transData['currency_code'] = $school_info['currency'];
$transData['status'] = 'Completed';
$transData['deduction_type'] = NULL;
$transData['deduction_amount'] = 0;
$transData['payment_date'] = $paidDate;
$transData['payment_recived_id'] = $this->session->userdata('admin_name');
$transData['payment_method'] = $payment_method;
$transData['bank_transaction_id'] = '';
$transData['course_fee_id'] = $course_fee_id;
$transData['install_sno'] = $install_sno;
$this->db->insert('fee_assigned_students', $fee_assigned_students);
$this->db->insert('student_fee_online_transactions', $transData);
$installmentData = [];
// $transData=[];
} else {
$this->session->set_flashdata('failed', 'Paid Amount should be less than Fees Amount');
}
}
}
}
}
}
// exit;
$_SESSION['promote_table'] = $table_view;
$this->session->set_flashdata('success', 'Data inserted Successfully......');
redirect(base_url() . 'admin/viewStudentImportFile');
}
public function generate_qrcode($studentID)
{
$hex_data = date('YmdHis') . '-' . $studentID;
$save_name = $hex_data . '.png';
$dir = 'assets_student/studentqrcode/';
if (!file_exists($dir)) {
mkdir($dir, 0775, true);
}
/* QR Configuration */
$config['cacheable'] = true;
$config['imagedir'] = $dir;
$config['quality'] = true;
$config['size'] = '1024';
$config['black'] = array(255, 255, 255);
$config['white'] = array(255, 255, 255);
$this->ciqrcode->initialize($config);
/* QR Data */
$params['data'] = $studentID;
$params['level'] = 'L';
$params['size'] = 10;
$params['savename'] = $config['imagedir'] . $save_name;
$result = $this->ciqrcode->generate($params);
return $result;
}
public function download_Csv_File()
{
$this->load->helper('download');
//file path
$file = 'common_assets/demo.csv';
//download file from directory
force_download($file, NULL);
redirect(base_url() . 'admin/student');
}
public function get_student_list($batch, $course, $section)
{
$result = $this->db->query("
select s.id, s.name, s.studentId, course_name, section_name
from students s, course co, section sc, student_batch sb, classroom c
where s.course = $course
and s.batch_id = $batch
and sb.student_id = s.id
and sb.batch_id = s.batch_id
and sb.classroom_id = c.id
and c.id = sb.classroom_id
and c.course_id = $course
and c.section_id = $section
and sc.id = c.section_id
and co.id = c.course_id")->result_array();
echo json_encode($result);
}
public function get_count_of_girl_and_boy()
{
$course_id = $this->uri->segment(3);
$section_id = $this->uri->segment(4);
if ($section_id == 0) {
$male_count = $this->db->query('SELECT count(s.id) as male_count FROM students s, classroom c , student_batch sb WHERE s.course = ' . $course_id . ' AND s.course = c.course_id AND sb.batch_id = s.batch_id AND sb.classroom_id = c.id AND sb.student_id = s.id AND s.gender = "Male" GROUP by s.gender ORDER by s.id')->row_array();
$female_count = $this->db->query('SELECT count(s.id) as female_count FROM students s, classroom c , student_batch sb WHERE s.course = ' . $course_id . ' AND s.course = c.course_id AND sb.batch_id = s.batch_id AND sb.classroom_id = c.id AND sb.student_id = s.id AND s.gender = "Female" GROUP by s.gender ORDER by s.id')->row_array();
} else {
$male_count = $this->db->query('SELECT count(s.id) as male_count FROM students s, classroom c , student_batch sb WHERE s.course = ' . $course_id . ' AND c.section_id = ' . $section_id . ' AND s.course = c.course_id AND sb.batch_id = s.batch_id AND sb.classroom_id = c.id AND sb.student_id = s.id AND s.gender = "Male" GROUP by s.gender ORDER by s.id')->row_array();
$female_count = $this->db->query('SELECT count(s.id) as female_count FROM students s, classroom c , student_batch sb WHERE s.course = ' . $course_id . ' AND c.section_id = ' . $section_id . ' AND s.course = c.course_id AND sb.batch_id = s.batch_id AND sb.classroom_id = c.id AND sb.student_id = s.id AND s.gender = "Female" GROUP by s.gender ORDER by s.id')->row_array();
}
if (empty($male_count))
$male = 0;
else
$male = $male_count['male_count'];
if (empty($female_count))
$female = 0;
else
$female = $female_count['female_count'];
$Total_count = array('male' => $male, 'female' => $female);
// $Total_count = array('male'=> 60, 'female'=> 40 );
echo json_encode($Total_count);
}
// Change Password
public function change_admin_password()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['title'] = 'Change Password';
if (count($_POST) > 0) {
$pwd = md5($this->input->post('password'));
$data = array('password' => $pwd);
$query = $this->Admin_model->update_admin_password($_SESSION['admin_id'], $data);
if ($query) {
$this->session->set_flashdata('success', str_replace('%s', 'Password', THE_UPDATE_SUCCESS_MSG));
redirect(base_url() . 'admin/admin-change-password');
} else {
$this->session->set_flashdata('failed', str_replace('%s', 'Password', THE_UPDATE_FAILED_MSG));
redirect(base_url() . 'admin/admin-change-password');
}
exit();
}
$this->load->view('admin/header', $data);
$this->load->view('admin/change-password');
$this->load->view('admin/footer');
}
public function getStudentsByClassroom()
{
$classroomId = $_REQUEST['classroomid'];
$batchId = $_REQUEST['batchid'];
$sql = "SELECT s.id,s.studentId,s.name FROM students s JOIN student_batch sb ON s.id=sb.student_id AND s.batch_id = sb.batch_id WHERE s.is_active='yes' AND sb.batch_id=$batchId AND sb.classroom_id=$classroomId";
$data = $this->Admin_model->get_query_result($sql);
echo json_encode($data);
}
// Attendance section End from here
public function calender_Notification()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['title'] = 'Calender';
$this->load->view('admin/header', $data);
$this->load->view('admin/calender', $data);
}
// Paying Student offline fees - Afraskhan
public function pay_offline_student_fees()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
// dd($_POST);
$student_transaction_id = $this->input->post('sot_id');
$installment_key = $this->input->post('install_key');
$deduction_type = isset($_POST['deduction_type']) && $_POST['deduction_type'] != 'none' ? $this->input->post('deduction_type') : NULL;
$deduction_amount = isset($_POST['deducted_amount']) ? $this->input->post('deducted_amount') : NULL;
$payment_type_received = $this->input->post('payment_type');
$bank_transaction_id = isset($_POST['bank_transaction_id']) ? $this->input->post('bank_transaction_id') : NULL;
$school_info = $this->Admin_model->get_logo_from_setting();
$student_transac = null;
$course_fee_id = $_POST['course_fee_id'] ? $this->input->post('course_fee_id') : NULL;
$payment_info = isset($_POST['payment_info']) ? $this->input->post('payment_info') : NULL;
$student_id = $this->input->post('studentId');
$update_query = null;
$total_amount = null;
if ($student_transaction_id == 'new_payment') {
// dd($_POST);
$firstpay = true;
$payment_info = json_decode($payment_info);
$installment_type_id = count((array)$payment_info);
$array_to_insert = [];
// dd($payment_info);
foreach ($payment_info as $key => $ele) {
foreach ($ele as $index => $val1) {
$total_amount = intval($val1->amount);
if ($firstpay) {
$array_to_insert[] = (object)array(
'install_sno' => $index + 1,
'due_date' => $val1->due_date,
'feeamount' => $val1->amount,
'deduction_type' => $deduction_type,
'deduction_amount' => $deduction_amount,
'paid_amount' => $total_amount - $deduction_amount,
'payment_status' => 'yes',
'paid_date' => date('Y-m-d H:i:s', strtotime($this->nepali_current_date))
);
$firstpay = false;
} else {
$array_to_insert[] = (object) array(
'install_sno' => $index + 1,
'due_date' => $val1->due_date,
'feeamount' => $val1->amount,
'deduction_type' => '',
'deduction_amount' => 0,
'paid_amount' => 0,
'payment_status' => 'no',
'paid_date' => date('Y-m-d H:i:s', strtotime($this->nepali_current_date))
);
}
}
}
$student_transac = array(
'student_id' => $student_id,
'course_fee_id' => $course_fee_id,
'installment_type_id' => $installment_key,
'payment_details' => json_encode($array_to_insert),
'payment_method' => $payment_type_received,
'created' => date('Y-m-d H:i:s', strtotime($this->nepali_current_date)),
'modified' => date('Y-m-d H:i:s', strtotime($this->nepali_current_date))
);
$student_transaction_id = $update_query = $this->Admin_model->insert_data('students_online_payments', $student_transac);
} else {
$student_transac = $this->Admin_model->get_table_info_row('students_online_payments', array('id' => $student_transaction_id));
$installments = json_decode($student_transac['payment_details']);
foreach ($installments as $index => $ele) {
if ($ele->install_sno == $installment_key) {
$installments[$index]->deduction_type = $deduction_type;
$installments[$index]->deduction_amount = $deduction_amount;
$total_amount = intval($ele->feeamount);
$ele->paid_amount = intval($ele->feeamount) - intval($deduction_amount);
$ele->payment_status = 'yes';
$ele->paid_date = date('d-m-Y H:i:s', strtotime($this->nepali_current_date));
} else {
$installments[$index]->deduction_type = NULL;
$installments[$index]->deduction_amount = NULL;
}
}
$student_transac['payment_details'] = json_encode($installments);
$student_transac['payment_method'] = $payment_type_received;
$student_transac['modified'] = date('d-m-Y H:i:s', strtotime($this->nepali_current_date));
$update_query = $this->Admin_model->update_table($student_transaction_id, $student_transac, 'students_online_payments');
}
// dd($student_transac);
if ($update_query) {
$studentappId = $this->db->get_where('students', array('id' => $student_transac['student_id']))->row()->studentId;
$course_fee_id_student = $student_transac['course_fee_id'];
$feeType_where = 'select ft.feetype_name from fee_types ft inner join course_fees cf on cf.fees_type = ft.id WHERE cf.id = ' . $course_fee_id_student;
$fees_type = $this->Admin_model->get_table_info_row('course_fees', '', $feeType_where);
$a = mt_rand(100000, 999999);
$transData['studentId'] = (!empty($studentappId)) ? $studentappId : $application_id;
$transData['payment_for'] = $fees_type['feetype_name'];
$transData['txn_id'] = $a . $studentappId;
$transData['payment_amt'] = $total_amount;
$transData['currency_code'] = $school_info['currency'];
$transData['status'] = 'Completed';
$transData['payment_date'] = date('Y-m-d H:i:s', strtotime($this->nepali_current_date));
$transData['payment_recived_id'] = $this->session->userdata('admin_name');
$transData['payment_method'] = $student_transac['payment_method'];
$transData['bank_transaction_id'] = $bank_transaction_id;
$transData['course_fee_id'] = $course_fee_id_student;
// dd($transData);
$rst = $this->Admin_model->storefeeTransaction($transData);
$this->session->set_flashdata('success', 'Fees has been paid successfully');
redirect(base_url() . 'admin/view-student-payments/' . $student_transac['student_id']);
} else {
$this->session->set_flashdata('failed', 'Oops! Fees could not be paid successfully. Please try again');
redirect(base_url() . 'admin/view-student-payments/' . $student_transac['student_id']);
}
}
public function ajax_get_fee_installments()
{
$course_fee_id = $this->input->post('course_fee_id');
$installment_key = $this->input->post('installment_type');
$student_id = $this->input->post('student_id');
$this->load->model('Student_model');
$sql_item_name = "Select f.feetype_name from fee_types f inner join course_fees cf on cf.fees_type = f.id WHERE cf.id = $course_fee_id";
$fee_type_col = $this->Student_model->get_general_row_details('fee_types', '', $sql_item_name);
$fee_type_name = $fee_type_col['feetype_name'];
$whereClause = "Select cf.id,cf.amount, i.id as installment_id, i.due_amount_date from course_fees cf inner join installment i on cf.id = i.course_fee_id WHERE cf.id = '$course_fee_id'";
$selected_installment = $query = $this->Student_model->get_general_row_details('course_fees', '', $whereClause);
if (!empty($query)) {
// decoding due_amount_date from installments
$selected_installment['due_amount_date'] = (array)json_decode($query['due_amount_date']);
$first_due_amount = '';
$s_no_new = '';
$signal = true;
// filtering the array with user selected option with $installment_key
foreach ($selected_installment['due_amount_date'] as $key => $value) {
if ($key != $installment_key) {
unset($selected_installment['due_amount_date'][$key]);
} else {
foreach ($value as $index => $ele) {
$due_date = date('Y-m-d', strtotime($ele->due_date));
$current_date = date('Y-m-d', strtotime($this->nepali_current_date));
$selected_installment['due_amount_date'][$key][$index]->payment_status = 'no';
}
}
}
// test_view_array($decoded);
$data['installment'] = $selected_installment;
// Re arranging keys of $data['installment']['due_amount_date'] below
$data['installment']['due_amount_date'] = array_values($data['installment']['due_amount_date']);
$jsonString = json_encode($data['installment']['due_amount_date']);
$jsonString = str_replace('"', "'", $jsonString);
$html = '<div class="user-info-one-fees mb-5">
<p>Payment Dates:</p>
<ul class="mt-3 sele-sub-opt-two" style="list-style-type: none;">';
// test_view_array($data['installment']['due_amount_date']);
foreach ($data['installment']['due_amount_date'] as $index => $val) {
$flag = true;
foreach ($val as $key2 => $ele) {
$due_date = date('Y-m-d', strtotime($ele->due_date));
$current_date = date('Y-m-d', strtotime($this->nepali_current_date));
$payClass = $due_date > $current_date ? '' : 'red-pay';
$html .= '<li><div class="outter-pay-wrap" style="display: flex;">';
if ($due_date > $current_date) {
$html .= '<div class="outter-check"><i class="fa fa-check"></i></div>';
} else {
$html .= '<div class="outter-check red-pay"><i class="fas fa-times"></i></div>';
}
$html .= '<p class="paid-para">' . $ele->amount . '</p></div>';
$html .= '<div class="paid-space"> Due on : ' . date('d-m-Y', strtotime($ele->due_date));
if ($flag) {
$html .= '<span><a href="javascript:void(0)" class="btn pay-btn ml-2 blue-bg btn-sm" onclick="createDynamicForm(' . $student_id . ',this,' . $installment_key . ',\'new_payment\',' . $ele->amount . ',' . $course_fee_id . ',' . $jsonString . ')">Pay Now</a></span></div>';
$flag = false;
}
$html .= '</li>';
}
$html .= '</ul></div>';
}
echo $html;
} else {
echo 'failed';
}
}
public function ajax_pay_table_fees()
{
if (count($_POST) == 0) {
echo false;
$this->session->set_flashdata('failed', 'Oops! Fees could not be paid successfully. Please try again');
exit;
}
$table_data = $this->input->post('feeData');
$school_info = $this->Admin_model->get_logo_from_setting();
$table_data = json_decode($table_data);
// Yet to be set
$payment_type = isset($_POST['payment_type']) ? $this->input->post('payment_type') : 'cash';
$bank_transaction_id = isset($_POST['bank_transaction_id']) ? $this->input->post('bank_transaction_id') : NULL;
$student_id = $this->input->post('student_id');
$student_app_id = '';
$student_details = $this->db->get_where('students', array('id' => $student_id))->row_array();
if (!empty($student_details)) {
$student_app_id = $student_details['studentId'] ? $student_details['studentId'] : '';
}
// Yet to be set
$transactions_to_be_inserted = [];
$sop_to_be_inserted = [];
$sop_to_be_updated = [];
$check_data = '';
$trans_invoice_no = (!empty($school_info['invoice_sno']) && $school_info['invoice_sno'] > 0) ? $school_info['invoice_sno'] : '1000';
// $invoice_result=$this->db->query("SELECT invoice_no FROM student_fee_online_transactions ORDER BY id DESC LIMIT 1")->row_array();
// if($invoice_result['invoice_no'] != '' && $invoice_result['invoice_no'] != NULL){
// $trans_invoice_no=$invoice_result['invoice_no'] +1;
// }
// else {
// $trans_invoice_no=+1;
// }
$total_paid_amount = 0;
// Table Data Loop Starts
foreach ($table_data as $key => $value) {
$courseFeeId = isset($value->courseFeeId) ? $value->courseFeeId : $value->courseFeeId;
// dd($value);
$feeType_query = "Select ft.feetype_name,cf.due_date from fee_types ft INNER JOIN course_fees cf on cf.fees_type = ft.id WHERE cf.id = $courseFeeId";
$fee_details = $this->Admin_model->get_table_info_row('course_fees', '', $feeType_query);
$total_amount = (int)$value->fee_total_amount > 0 ? (int)$value->fee_total_amount : 0;
$payable_amount = isset($value->payable_amount) ? ((int)$value->payable_amount > 0 ? (int)$value->payable_amount : 0) : ((int)$value->feePayableAmt > 0 ? (int)$value->feePayableAmt : 0);
$deduction_amount = (int)$value->deduction_amount > 0 ? (int)$value->deduction_amount : 0;
$fine_amount = (int)$value->fine_amount > 0 ? (int)$value->fine_amount : 0;
$paid_amount = ($payable_amount + $fine_amount) - $deduction_amount;
$deduction_type = $value->deduction_type ? $value->deduction_type : '';
$check_query = "Select * from students_online_payments WHERE ( student_id = $student_id AND course_fee_id = $courseFeeId ) AND fee_completed = 'no'";
$check_data = $this->Admin_model->get_table_info('students_online_payments', '', $check_query);
$install_sno = '';
// dd($check_data);
if (empty($check_data)) {
$i_pending_amount = $total_amount - $payable_amount;
$details = array();
$insert_data['student_id'] = $student_id;
$insert_data['course_fee_id'] = $courseFeeId;
$insert_data['payment_method'] = $payment_type;
$insert_data['fine_amount'] = $fine_amount;
$insert_data['deducted_amount'] = $deduction_amount;
$insert_data['pending_amount'] = $i_pending_amount;
$insert_data['paid_amount'] = $paid_amount;
$insert_data['created'] = $this->nepali_current_date;
$insert_data['modified'] = $this->nepali_current_date;
$insert_data['fee_completed'] = $i_pending_amount == 0 || $i_pending_amount < 0 ? 'yes' : 'no';
$install_sno = 1;
$details[] = (object)array(
'install_sno' => 1,
'payment_status' => 'yes',
'payable_amount' => $payable_amount,
'paid_amount' => $paid_amount,
'paid_date' => date('d-m-Y', strtotime($this->nepali_current_date)),
'total_amount' => $total_amount,
'pending_amount' => $total_amount - $payable_amount,
'due_date' => $fee_details['due_date'],
'deduction_type' => $value->deduction_type,
'deduction_amount' => $value->deduction_amount,
'fine_amount' => $fine_amount,
'payment_via' => $payment_type,
'updated_by' => $_SESSION['admin_id'] . ' - ' . $_SESSION['admin_name'] . ' - ' . $_SESSION['admin_email']
);
$insert_data['payment_details'] = json_encode($details);
$sop_to_be_inserted[] = $insert_data;
} else {
// dd($check_data);
foreach ($check_data as $index => $ele) {
$installments = json_decode($ele['payment_details']);
$key_count = count((array)$installments);
$install_sno = $key_count + 1;
$installments[] = (object)array(
'install_sno' => $key_count + 1,
'payment_status' => 'yes',
'payable_amount' => $payable_amount,
'paid_amount' => $paid_amount,
'paid_date' => date('d-m-Y', strtotime($this->nepali_current_date)),
'total_amount' => $total_amount,
'due_date' => $fee_details['due_date'],
'pending_amount' => $ele['pending_amount'] - $payable_amount,
'deduction_type' => $value->deduction_type,
'deduction_amount' => $value->deduction_amount,
'fine_amount' => $fine_amount,
'payment_via' => $payment_type,
'updated_by' => $_SESSION['admin_id'] . ' - ' . $_SESSION['admin_name'] . ' - ' . $_SESSION['admin_email']
);
$u_pending_amount = (int)$ele['pending_amount'] - $payable_amount;
$sop_to_be_updated[] = array(
'id' => $ele['id'],
'payment_details' => json_encode($installments),
'paid_amount' => (int)$ele['paid_amount'] + $paid_amount,
'deducted_amount' => (int)$ele['deducted_amount'] + $deduction_amount,
'pending_amount' => $u_pending_amount,
'fine_amount' => (int)$ele['fine_amount'] + $fine_amount,
'fee_completed' => $u_pending_amount == 0 || $u_pending_amount < 0 ? 'yes' : 'no',
'modified' => $this->nepali_current_date
);
}
}
if ($fee_details['feetype_name'] == 'Transport Fee') {
$BTSdb = $this->load->database('erisnClassroom_bts', TRUE);
$query = $BTSdb->query("UPDATE bt_students_bus_route_details SET is_active='YES' WHERE student_id= '" . $student_app_id . "' order by id DESC limit 1");
}
$a = mt_rand(100000, 999999);
$transData['studentId'] = $student_app_id;
$transData['payment_for'] = $fee_details['feetype_name'];
$transData['txn_id'] = $a . $student_app_id;
$transData['invoice_no'] = $trans_invoice_no;
$transData['payment_amt'] = isset($value->payable_amount) ? $value->payable_amount : $value->feePayableAmt;
$transData['currency_code'] = $school_info['currency'];
$transData['status'] = 'Completed';
$transData['deduction_type'] = $deduction_type;
$transData['deduction_amount'] = $value->deduction_amount;
$transData['payment_date'] = $this->nepali_current_date;
$transData['payment_recived_id'] = $this->session->userdata('admin_name');
$transData['payment_method'] = $payment_type;
$transData['fine_amount'] = $fine_amount;
$transData['bank_transaction_id'] = $bank_transaction_id;
$transData['course_fee_id'] = $courseFeeId;
$transData['install_sno'] = $install_sno;
$transData['created'] = $this->nepali_current_date;
$transData['modified'] = $this->nepali_current_date;
$transactions_to_be_inserted[] = $transData;
$total_paid_amount = $total_paid_amount + $transData['payment_amt'];
} // Table Data Loop Ends
if (!empty($sop_to_be_inserted)) {
$insert_transactions = $this->db->insert_batch('students_online_payments', $sop_to_be_inserted);
}
if (!empty($sop_to_be_updated)) {
$update_transactions = $this->db->update_batch('students_online_payments', $sop_to_be_updated, 'id');
}
if (!empty($transactions_to_be_inserted)) {
$cf = $this->Admin_model->get_query_row("SELECT cf.*, ft.feetype_name FROM course_fees cf JOIN fee_types ft ON ft.id = cf.fees_type WHERE cf.id = $courseFeeId");
$scholarship = $this->Admin_model->get_query_row("SELECT ss.*, st.scholarshiptype_name FROM student_scholarship ss JOIN scholarship_types st ON st.id = ss.scholarship_type WHERE ss.student_id = $student_id AND ss.course_fee_id = $courseFeeId");
// dd($scholarship);
$insert_transactions = $this->db->insert_batch('student_fee_online_transactions', $transactions_to_be_inserted);
if ($insert_transactions) {
$this->db->where(array('id' => $school_info['id']));
$this->db->update('school_settings', array('invoice_sno' => (int)$trans_invoice_no + 1));
$this->accounting->receiptVoucherEntry($student_id, $student_app_id, $cf['batch_id'], $cf['course_id'], $total_paid_amount);
$this->session->set_flashdata('success', 'Fees has been paid successfully');
} else {
$this->session->set_flashdata('failed', 'Fees could not be paid successfully, Please try again');
}
}
}
// Paying Student offline fees end - Afraskhan
//shankar code start here
public function studentChangePassword()
{
if ($_POST) {
$data = array(
'password' => md5($_POST['password']),
'modified' => $this->nepali_current_date
);
$this->db->where('id', $_POST['student_id']);
$this->db->update('students', $data);
$this->db->trans_complete();
if ($this->db->trans_status() === FALSE) {
$this->session->set_flashdata('danger', str_replace('%s', 'Password', THE_ADD_ERROR_MSG));
} else {
$this->session->set_flashdata('success', str_replace('%s', 'Password', THE_UPDATE_SUCCESS_MSG));
}
redirect(base_url() . 'admin/view_student/' . $_POST['student_id']);
}
}
public function suspend_Student()
{
if ($_POST) {
$this->db->where('id', $_POST['student_id']);
if ($_POST['status']) {
$this->db->update('students', array('is_active' => 'no', 'suspend_reason' => $_POST['reason'], 'modified' => date('Y-m-d H:i:s')));
} else {
$this->db->update('students', array('is_active' => 'yes', 'modified' => date('Y-m-d H:i:s')));
}
$updated_status = $this->db->affected_rows();
if ($updated_status) {
if ($_POST['status']) {
$this->session->set_flashdata('success_msg', 'Student Disabled Successfully');
} else {
$this->session->set_flashdata('success_msg', 'Student Enabled Successfully');
redirect(base_url() . 'admin/enable-student');
}
} else {
$this->session->set_flashdata('error_msg', 'Something Went Wrong ..... !!');
}
redirect(base_url() . 'admin/student');
}
}
public function student_suspend_list()
{
if (isset($_SESSION['admin_id'])) {
$cid = '';
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
if ($this->input->post('filterSubmit') == "Filter") {
$this->form_validation->set_rules('filter-Sdate', 'Start Date', 'required');
$this->form_validation->set_rules('filter-course', 'Course', 'required');
$this->form_validation->set_rules('filter-Edate', 'End Date', 'required');
$course_id = $_POST['filter-course'] ? $_POST['filter-course'] : 0;
$e_date = $_POST['filter-Edate'] ? $_POST['filter-Edate'] : 0;
$s_date = $_POST['filter-Sdate'] ? $_POST['filter-Sdate'] : 0;
$data['courseId'] = $course_id;
$data['sdate'] = $s_date;
$data['edate'] = $e_date;
if (!$this->form_validation->run() == FALSE) {
$data['students'] = $this->Admin_model->get_students_suspend($s_date, $e_date, $course_id);
} else {
$data['students'] = $this->Admin_model->get_students_suspend();
}
} else {
$data['students'] = $this->Admin_model->get_students_suspend();
}
$data['course'] = $this->db->query("select * from course WHERE is_active='yes'")->result_array();
$data['batch'] = $this->Admin_model->get_batch();
$this->load->view('admin/header', $data);
$this->load->view('admin/supended-student-list', $data);
$this->load->view('admin/footer');
}
}
//application reupload images by shankar
public function application_documents_reupload()
{
$id = $this->input->post('appid');
$this->load->helper('url');
$this->load->helper(array('form', 'url'));
$config['upload_path'] = 'assets_student/application/';
$config['allowed_types'] = 'gif|jpg|png';
$config['file_name'] = uniqid('img', false);
$this->load->library('upload', $config);
$this->upload->initialize($config);
$data['currentURL'] = current_url();
$data['id'] = $id;
if ($_FILES['photo']['size'] != 0) {
if (!$this->upload->do_upload('photo')) {
$data['photo'] = "";
} else {
$photo = array('upload_data' => $this->upload->data());
$data['photo'] = $photo['upload_data']['file_name'];
}
}
if ($_FILES['school']['size'] != 0) {
if (!$this->upload->do_upload('school')) {
$data['school_certificate'] = "";
} else {
$school = array('upload_data' => $this->upload->data());
$data['school_certificate'] = $school['upload_data']['file_name'];
}
}
if ($_FILES['exam']['size'] != 0) {
if (!$this->upload->do_upload('exam')) {
$data['exam_result'] = "";
} else {
$exam = array('upload_data' => $this->upload->data());
$data['exam_result'] = $exam['upload_data']['file_name'];
}
}
if ($_FILES['medical']['size'] != 0) {
if (!$this->upload->do_upload('medical')) {
$data['medical_cerificate'] = "";
} else {
$medical = array('upload_data' => $this->upload->data());
$data['medical_cerificate'] = $medical['upload_data']['file_name'];
}
}
$app_new_id = $this->Admin_model->application_update_studentsdoc($data);
if ($app_new_id)
$this->session->set_flashdata('success', 'Image Updated Successfully.....!!');
else
$this->session->set_flashdata('danger', 'Something Went Wrong .....');
redirect('/admin/view_applicant/' . $data['id']);
}
public function get_sectionbycourse()
{
$courseId = $_REQUEST['course_id'];
$batchId = $_REQUEST['batch_id'];
$sql = "SELECT s.id as section_id,s.section_name FROM course_sections cs JOIN section s ON s.id=cs.section_id WHERE cs.course_id='$courseId' ORDER BY s.id DESC";
// $sections=$this->Admin_model->get_query_result($sql);
// echo json_encode($sections);
$section_list = $this->Admin_model->get_query_result($sql);
$sectionsData = array();
foreach ($section_list as $sec_value) {
$sectionIDD = $sec_value['section_id'];
$sec_sql = "SELECT sec.id as section_id,sec.section_name FROM classroom cl JOIN section sec ON sec.id=cl.section_id WHERE cl.section_id=$sectionIDD AND cl.course_id='$courseId'";
$result = $this->Admin_model->get_query_row($sec_sql);
if (!empty($result))
$sectionsData[] = $result;
}
$data['sections'] = $sectionsData;
$today = date('Y-m-d', strtotime($this->nepali_current_date));
$feesType = 1; // application Fee
$sql1 = "SELECT * FROM `course_fees` WHERE batch_id=$batchId AND course_id=$courseId AND fees_type=$feesType ";
// $sql1 = "SELECT * FROM `course_fees` WHERE batch_id=$batchId AND course_id=$courseId AND fees_type=$feesType AND DATE(due_date) >= DATE('$today')";
$result = $this->Admin_model->get_query_row($sql1);
$data['application_fee'] = ($result != '') ? json_encode($result) : 0;
echo json_encode($data);
}
public function get_section_by_course()
{
$courseId = $_REQUEST['course_id'];
$sql = "SELECT s.id as section_id,s.section_name FROM course_sections cs JOIN section s ON s.id=cs.section_id WHERE cs.course_id='$courseId' ORDER BY s.id DESC";
$section_list = $this->Admin_model->get_query_result($sql);
$data['sections'] = $section_list;
echo json_encode($data);
}
public function checknamewithId()
{
$id = $_POST['id'];
$namevalue = $_POST['value'];
$table = $_POST['tablename'];
$dbcolumn = $_POST['column'];
$result = $this->Admin_model->check_value_exists($table, array($dbcolumn => $namevalue), $id);
if ($result)
echo 'success';
else
echo 'failed';
}
// to get application fee by shivakumar start
public function get_batch_course()
{
$batchId = $_REQUEST['batch_id'];
$today_datetime = DATE('Y-m-d', strtotime($this->nepali_current_date));
$feesType = 1;
$sql = "SELECT DISTINCT cf.course_id,c.course_name,c.id FROM course_fees cf JOIN course c ON c.id=cf.course_id WHERE cf.batch_id=$batchId AND cf.fees_type=$feesType";
// $sql = "SELECT * FROM `course_fees` WHERE batch_id=$batchId AND AND due_date >= DATE('$today_datetime')";
$result = $this->Admin_model->get_query_result($sql);
echo $rst = ($result != '') ? json_encode($result) : 0;
}
// to get application fee by shivakumar End
public function ajax_check_if_exists()
{
$table = $this->input->post('table');
$column = $this->input->post('column');
$value = $this->input->post('value');
$required = isset($_POST['required']) ? $this->input->post('required') : null;
$where[$column] = $value;
$get_result = $this->Admin_model->get_table_info_row($table, $where);
if (empty($get_result)) {
echo 'failed';
} else {
if ($required) {
echo $get_result[$required];
} else {
echo 'success';
}
}
}
public function downloadAllInvoice()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/invoiceallpdf.php'))
show_404();
if (count($_REQUEST['inoviceids']) > 0) {
$invoiceids = $_REQUEST['inoviceids'];
$student_id = $_REQUEST['student_id'];
// print_r(count());
$invoiceData = array();
$all_invoice_ids = [];
$invoiceData = [];
foreach ($invoiceids as $i_k => $i_val) {
// print_r($i_value);
$i_array = explode(',', $i_val);
foreach ($i_array as $i_key => $i_value) {
// print_r($i_value);
array_push($all_invoice_ids, (int)$i_value);
}
}
sort($all_invoice_ids);
foreach ($all_invoice_ids as $ai_key => $ai_value) {
// foreach ($invoiceArray as $i_key => $i_value) {
// }
$i_data = $this->db->query("SELECT student_fee_online_transactions.*, course_fees.fee_values,course_fees.batch_id FROM student_fee_online_transactions, course_fees WHERE student_fee_online_transactions.id='$ai_value' and student_fee_online_transactions.course_fee_id = course_fees.id ")->row_array();
$this->db->query('update student_fee_online_transactions set bill_print_count = bill_print_count + 1 where id =' . $ai_value);
array_push($invoiceData, $i_data);
}
// foreach ($invoiceids as $i_value) {
// $this->db->where('id', $i_value);
// $this->db->set('bill_print_count', 'bill_print_count+1', FALSE);
// $update = $this->db->update('student_fee_online_transactions');
// if ($update) {
// $i_data = $this->db->query("SELECT student_fee_online_transactions.*, course_fees.fee_values FROM student_fee_online_transactions, course_fees WHERE student_fee_online_transactions.id='$i_value' and student_fee_online_transactions.course_fee_id = course_fees.id ")->row_array();
// array_push($invoiceData, $i_data);
// }
// }
// dd($invoiceData);
$feeBatchId = $invoiceData[0]['batch_id'];
$data['invoicelist'] = $invoiceData;
if ($student_id != 0) {
$studentdata = $this->db->query("SELECT s.name as studentname,b.b_name as batch_name, s.email, s.studentId,s.id,cl.course_id,cl.section_id,s.parent_pan, cl.classroom_name, cl.id as classroom_id
FROM students s
JOIN student_batch sb ON sb.student_id = s.id AND sb.batch_id = $feeBatchId
JOIN classroom cl ON cl.id=sb.classroom_id
JOIN batch b ON b.id=$feeBatchId WHERE s.id=$student_id order by sb.id desc")->row_array();
// dd($studentdata);
if (count($studentdata) > 0)
$data['studentinfo'] = $studentdata;
else
$data['studentinfo'] = 0;
} else {
$data['studentinfo'] = 0;
}
$data['invoiceids'] = $invoiceids;
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['schoolinfo']['tdt'] = date('Y-m-d H:i:s', strtotime($this->nepali_current_date));
$data['nDate'] = date('Y-m-d H:i:s', strtotime($this->nepali_current_date));
$this->load->view('admin/invoiceallpdf', $data);
}
}
public function ajax_get_transport_routes()
{
$batch_id = $this->input->post('batch_id');
$transport_db = $this->load->database('erisnClassroom_bts', TRUE);
$batch_routes = $transport_db->query('SELECT * from bt_batch_routes where batch_id = ' . $batch_id)->row_array();
if (empty($batch_routes)) {
echo false;
exit;
} else {
$route_ids = explode(',', $batch_routes['route_ids']);
$whereClause = '';
foreach ($route_ids as $key => $value) {
if ($key == 0) {
$whereClause .= "id = '$value'";
} else {
$whereClause .= " or id = '$value'";
}
}
$routes = $transport_db->query('SELECT * from bt_routes where ' . $whereClause)->result_array();
$select_plan = '';
if (isset($_POST['selected_plan'])) {
$select_plan = $this->input->post('selected_plan');
}
$html = '<select name="feename[0]" onchange="set_transport_route_id(this)" class="form-control feeNameClass">';
$id = '';
$name = '';
foreach ($routes as $key => $value) {
if ($key == 0) {
$html .= '<option value="">Select A Route</option>';
}
if ($select_plan != '' && $select_plan == $value['route_name']) {
$id = $value['id'];
$name = $value['route_name'];
$html .= '<option selected data-id="' . $value['id'] . '" value="' . $value['route_name'] . '">' . $value['route_name'] . '</option>';
} else {
$html .= '<option data-id=' . $value['id'] . ' value="' . $value['route_name'] . '">' . $value['route_name'] . '</option>';
}
}
$html .= '</select>';
if ($select_plan != '' && $select_plan == $name) {
$html .= '<input type="hidden" name="route_id" value="' . $id . '" id="route_id">';
} else {
$html .= '<input type="hidden" name="route_id" id="route_id">';
}
echo $html;
}
}
public function ajax_get_transport_routes_new()
{
$batch_id = $this->input->post('batch_id');
$transport_db = $this->load->database('erisnClassroom_bts', TRUE);
$batch_routes = $transport_db->query('SELECT * from bt_batch_routes where batch_id = ' . $batch_id)->row_array();
if (empty($batch_routes)) {
echo false;
exit;
} else {
$route_ids = explode(',', $batch_routes['route_ids']);
$whereClause = '';
foreach ($route_ids as $key => $value) {
if ($key == 0) {
$whereClause .= "id = '$value'";
} else {
$whereClause .= " or id = '$value'";
}
}
$routes = $transport_db->query('SELECT * from bt_routes where ' . $whereClause)->result_array();
$select_plan = '';
if (isset($_POST['selected_plan'])) {
$select_plan = $this->input->post('selected_plan');
}
$html = '<label for="">Routes Name<span class="text-danger font-weight-bold">*</span></label><select name="new_route_id" id="new_route_id" onchange="CheckRouteFee(this)" class="form-control feeNameClass123">';
$id = '';
$name = '';
foreach ($routes as $key => $value) {
if ($key == 0) {
$html .= '<option value="" >Select A Route</option>';
}
if ($select_plan != '' && $select_plan == $value['route_name']) {
$id = $value['id'];
$name = $value['route_name'];
$html .= '<option selected data-id="' . $value['id'] . '" value="' . $value['id'] . '">' . $value['route_name'] . '</option>';
} else {
$html .= '<option data-id=' . $value['id'] . ' value="' . $value['id'] . '">' . $value['route_name'] . '</option>';
}
}
$html .= '</select> <br> <div class="row"><div class="col-md-12" id="errorDiv"></div></div>';
if ($select_plan != '' && $select_plan == $name) {
$html .= '<input type="hidden" name="route_id" value="' . $id . '" id="route_id">';
} else {
$html .= '<input type="hidden" name="route_id" id="route_id">';
}
echo $html;
}
}
public function manage_installments_add($cf_id)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/manage_installments_add.php'))
show_404();
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$sql = "Select cf.id,cf.amount,b.b_name,c.course_name,cf.due_date,cf.batch_id,cf.course_id,ft.feetype_name,cf.hostel_plan_id,cf.route_id,ft.id as feetype_id from course_fees cf INNER JOIN batch b on b.id = cf.batch_id
INNER JOIN course c ON c.id = cf.course_id
INNER JOIN fee_types ft on ft.id = cf.fees_type WHERE cf.id = $cf_id ";
$data['course_fee'] = $course_fee = $this->Admin_model->get_table_info_row('course_fees', '', $sql);
$data['cf_id'] = $cf_id;
if (empty($course_fee)) {
$this->session->set_flashdata('failed', 'There is no fees with selected id');
redirect(base_url() . 'admin/fee-course');
}
$condition = '';
if ($course_fee['feetype_id'] == '3') {
$condition = " AND s.hostel_plan_id = $course_fee[hostel_plan_id]";
}
if ($course_fee['feetype_id'] == '4') {
$condition = " AND s.bus_routeid = $course_fee[route_id]";
}
// Unassigned Installments Table
$students_sql = "select s.id,s.studentId, s.name, s.email, s.mobile, se.section_name,
IF((SELECT COUNT(*) from fee_assigned_students WHERE course_fee_id = $cf_id AND student_id = s.id) > 0, 'YES', 'NO') as assigned
from students s
INNER JOIN student_batch sb on s.id = sb.student_id AND s.batch_id = sb.batch_id
INNER JOIN classroom c ON c.id = sb.classroom_id
INNER JOIN section se ON c.section_id = se.id
WHERE s.batch_id = $course_fee[batch_id]
AND s.course = $course_fee[course_id]
AND s.id NOT IN (SELECT student_id from students_online_payments WHERE student_id = s.id AND course_fee_id = $course_fee[id])
$condition
AND sb.created = (SELECT MAX(created) from student_batch sb2 where sb.student_id = sb2.student_id)
ORDER BY s.id DESC";
// exit;
$data['unassigned_students'] = $student_info = $this->Admin_model->get_table_info('students', '', $students_sql);
// dd($data['unassigned_students']);
$data['payment_types'] = $this->Admin_model->get_table_info('payment_types', '', '', 'ASC');
// dd($student_info);
$this->load->view('admin/header', $data);
$this->load->view('admin/manage_installments_add');
$this->load->view('admin/footer');
}
public function add_new_installments_revised_old_afras()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$_POST['table_rows'] = json_decode($_POST['table_rows']);
$cf_id = $this->input->post('course_fee_id');
// dd($_POST);
if (empty($_POST['table_rows'])) {
// $delQryHere=$this->db->query("DELETE FROM fee_assigned_students WHERE course_fee_id=$cf_id AND student_id NOT IN(SELECT SOP.student_id FROM students_online_payments SOP INNER JOIN fee_assigned_students F ON F.student_id = SOP.student_id AND SOP.course_fee_id=$cf_id)");
$del['course_fee_id'] = $cf_id;
$delete_db_list = $this->Admin_model->delete_row('fee_assigned_students', $del);
$this->session->set_flashdata('success', 'Students have been removed from fees successfully');
redirect(base_url() . 'admin/fee-course');
}
// Step 1 : Getting Students List
$where = '';
foreach ($_POST['table_rows'] as $key => $value) {
if ($key == 0) {
$where .= "studentId = '$value'";
} else {
$where .= " or studentId = '$value'";
}
}
$db_sql = "Select student_id,course_fee_id from fee_assigned_students WHERE course_fee_id = $cf_id";
$db_list = $this->Admin_model->get_table_info('fee_assigned_students', '', $db_sql);
if (!empty($db_list)) {
$del['course_fee_id'] = $cf_id;
$delete_db_list = $this->Admin_model->delete_row('fee_assigned_students', $del);
}
$view_sql = "Select id as student_id,$cf_id as course_fee_id from students where $where";
$view_list = $this->Admin_model->get_table_info('students', '', $view_sql);
$insert_query = $this->db->insert_batch('fee_assigned_students', $view_list);
if ($insert_query) {
$this->session->set_flashdata('success', 'Fee has been assigned to student successfully');
redirect(base_url() . 'admin/fee-course');
} else {
$this->session->set_flashdata('failed', 'Fee could not be assigned to students! Please try again later.');
redirect(base_url() . 'admin/fee-course');
}
}
// fees assigned by shivu start from here
public function add_new_installments_revised()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$assigned_arr = array();
$unassigned_arr = array();
$check_already = array();
$insert_data = array();
$cf_id = $this->input->post('course_fee_id');
$student_list = $_POST['students_input'];
if (!empty($_POST['students_input'])) {
foreach ($student_list as $k => $svalue) {
if ($svalue == 1) {
$sql = "SELECT cf.fee_values,fas.id as fee_assigned_id FROM fee_assigned_students fas JOIN course_fees cf ON cf.id=fas.course_fee_id WHERE fas.student_id=$k ANd fas.course_fee_id= $cf_id ";
$check_assigned = $this->Admin_model->get_query_row($sql);
if ($check_assigned != '') {
$check_already[] = $k;
} else {
$insert_data = array('student_id' => $k, 'course_fee_id' => $cf_id);
$insert_rst = $this->db->insert('fee_assigned_students', $insert_data);
if ($insert_rst == TRUE)
array_push($assigned_arr, $k);
}
} else if ($svalue == 0) {
$coondition_data = array(
'student_id' => $k,
'course_fee_id' => $cf_id
);
$this->db->where($coondition_data);
$unselected_data = $this->db->delete('fee_assigned_students');
if ($unselected_data == TRUE)
array_push($unassigned_arr, $k);
}
}
if (count($assigned_arr) > 0 && count($unassigned_arr) > 0) {
$this->session->set_flashdata('success', 'Fees has bee updated successfully');
}
if (count($assigned_arr) > 0)
$this->session->set_flashdata('success', 'Fees has been assigned successfully');
if (count($unassigned_arr) > 0)
$this->session->set_flashdata('success', 'Fees has been assigned successfully');
} else {
$this->session->set_flashdata('failed', 'No Changes');
}
redirect(base_url() . 'admin/manage-installments/' . $cf_id);
}
// fees assigned by shivu end here
// Transport module start from here
// By: shivu
public function assign_routes_students()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/asign-routes.php'))
show_404();
$BTSdb = $this->load->database('erisnClassroom_bts', TRUE);
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['title'] = "Assign Routes";
$result = array();
$classroomId = '';
if ((isset($_POST['filterSubmit']) && !empty($_POST['filterSubmit'])) == 'Filter') {
$this->form_validation->set_rules('search_batch', 'Batch', 'required');
$batchId = (!empty($_POST['search_batch'])) ? $_POST['search_batch'] : '';
$classroomId = (!empty($_POST['search_classroom'])) ? $_POST['search_classroom'] : '';
if (!$this->form_validation->run() == FALSE) {
$where = '';
$where .= "WHERE s.is_active='yes'";
if ($batchId != '')
$where .= ' AND sb.batch_id=' . $batchId;
// if($classroomId != '')
// $where .= ' AND sb.classroom_id='.$classroomId;
if ($classroomId != '') {
$arr = implode(',', $classroomId);
$where .= ' AND cl.course_id=s.course AND sb.classroom_id IN (' . $arr . ')';
}
$sql = "SELECT sb.batch_id,b.b_name as batch_name,sb.classroom_id,cl.classroom_name,s.* FROM students s JOIN student_batch sb ON s.id=sb.student_id JOIN classroom cl ON cl.id=sb.classroom_id JOIN batch b ON b.id=sb.batch_id $where ORDER BY s.bus_facility ASC";
$result = $this->db->query("SELECT sb.batch_id,b.b_name as batch_name,sb.classroom_id,cl.classroom_name,s.* FROM students s JOIN student_batch sb ON s.id=sb.student_id JOIN classroom cl ON cl.id=sb.classroom_id JOIN batch b ON b.id=sb.batch_id $where ORDER BY s.bus_facility ASC")->result_array();
foreach ($result as $stdKey => $student) {
$studentRouteAssign = $BTSdb->query('SELECT sbrd.id,sbrd.batch_id,sbrd.route_id,sbrd.pick_up_id,sbrd.drop_id,sbrd.one_way,sbrd.is_active,r.route_name, rd.place_name as pick_up_location
FROM bt_students_bus_route_details sbrd
JOIN bt_routes r ON r.id = sbrd.route_id
JOIN bt_routes_details rd ON rd.id = sbrd.pick_up_id
WHERE sbrd.batch_id=' . $batchId . ' AND sbrd.student_id = ' . $student['id'])->row_array();
$result[$stdKey]['assign_route'] = $studentRouteAssign;
}
// dd($result);
}
}
$data['search_batch_id'] = (isset($batchId) && $batchId != '') ? $batchId : '';
$data['search_classroom_id'] = (isset($classroomId) && $classroomId != '') ? $classroomId : '';
$data['studentlist'] = (count($result) > 0) ? $result : 0;
// dd($data['studentlist']);
$data['classrooms'] = $this->db->query("select * from classroom WHERE is_active='yes'")->result_array();
$data['batchs'] = $this->Admin_model->get_batch();
$this->load->view('admin/header', $data);
$this->load->view('admin/asign-routes.php', $data);
$this->load->view('admin/footer');
}
function getrouteDetails()
{
$batchid = $_REQUEST['batch_id'];
$student_id = $_REQUEST['student_id'];
$student = $this->db->get_where('students', array('id' => $student_id))->row_array();
// dd($student);
$course_id = (isset($student['course']) && !empty($student['course'])) ? $student['course'] : 0;
$student_route_id = (isset($student['bus_routeid']) && !empty($student['bus_routeid'])) ? $student['bus_routeid'] : 0;
$fees_type = 4; // Fee types table (Transport Fee)
if ($student_route_id != 0 && $course_id != 0)
$studentCourseFeeId = $this->db->query("SELECT id as route_course_fee_id,amount FROM course_fees WHERE batch_id=$batchid AND course_id=$course_id AND fees_type=$fees_type AND route_id=$student_route_id")->row()->route_course_fee_id;
else
$studentCourseFeeId = 0;
$BTSdb = $this->load->database('erisnClassroom_bts', TRUE);
$data = array();
$routelist = array();
$stoplist = array();
if ($batchid != '') {
$routes = $BTSdb->query('SELECT id,batch_id,route_ids FROM bt_batch_routes WHERE batch_id=' . $batchid)->row_array();
$studentAssignedRoute = $BTSdb->query('SELECT * FROM bt_students_bus_route_details WHERE batch_id=' . $batchid . ' AND student_id=' . $student_id)->row_array();
if ($routes != '') {
$myArray = explode(',', $routes['route_ids']);
foreach ($myArray as $route_id) {
$routedata = $BTSdb->query("SELECT * FROM `bt_routes` WHERE id=" . $route_id)->row_array();
$stopdata = $BTSdb->query("SELECT id as stops_id, place_name FROM `bt_routes_details` WHERE route_id=" . $route_id . " order by route_order ASC")->result_array();
$routeprice = $this->db->query("SELECT id as route_course_fee_id,amount FROM course_fees WHERE batch_id=$batchid AND course_id=$course_id AND fees_type=$fees_type AND route_id=$route_id")->row_array();
$route_price = (isset($routeprice['amount']) && !empty($routeprice['amount'])) ? $routeprice['amount'] : 0;
$routelist[] = array(
'route_id' => $routedata['id'],
'route_name' => $routedata['route_name'],
'route_fee' => ($route_price != 0) ? $route_price : 0
);
$stoplist[$routedata['id']] = $stopdata;
}
// dd($routeprice);
}
}
// dd($stoplist);
// payment paid or not checking here
$route_course_fee_id = (isset($routeprice['route_course_fee_id']) && !empty($routeprice['route_course_fee_id'])) ? $routeprice['route_course_fee_id'] : 0;
$paymentStatus = false;
if ($studentCourseFeeId != 0) {
$student_installment = $this->db->get_where('students_online_payments', array('student_id' => $student_id, 'course_fee_id' => $studentCourseFeeId))->row_array();
if (!empty($student_installment)) {
$installmentArray = json_decode($student_installment['payment_details'], true);
// dd($installmentArray);
foreach ($installmentArray as $payment_data) {
if ($payment_data['payment_status'] == 'yes') {
$paymentStatus = true;
break;
}
}
}
}
$data['payment_status'] = $paymentStatus;
$data['route_course_fee_id'] = $studentCourseFeeId;
$data['student_info'] = $student;
$data['route_data'] = $routelist;
$data['batch_name'] = $this->db->get_where('batch', array('id' => $batchid))->row()->b_name;
$data['student_route_id'] = $student_route_id;
$data['student_assigned_route'] = $studentAssignedRoute;
$data['stop_list'] = $stoplist;
$page = $this->load->view('admin/routedata', $data, TRUE);
echo $page;
}
public function routeAssignToStudent()
{
$BTSdb = $this->load->database('erisnClassroom_bts', TRUE);
$studentId = $_REQUEST['student_id'];
$routeId = $_REQUEST['route_id'];
$pick_id = $_REQUEST['stop_id'];
$batch_id = $_REQUEST['batch_id'];
$is_one_way = $_REQUEST['is_one_way'];
// var_dump($is_one_way);
// $oneway = $is_one_way ? 'yes' : 'no';
$result = $this->db->query("UPDATE students SET bus_routeid=$routeId,bus_facility='yes',route_stop_id=$pick_id WHERE id=$studentId");
// bus tracking
$query1 = $BTSdb->query('SELECT * from bt_students_bus_route_details WHERE student_id=' . $studentId . ' and batch_id =' . $batch_id . ' order by id DESC')->row_array();
$data = array('student_id' => $studentId, 'route_id' => $routeId, 'pick_up_id' => $pick_id, 'drop_id' => $pick_id, 'is_active' => 'No', 'batch_id' => $batch_id, 'one_way' => $is_one_way);
if (!empty($query1)) {
$upQuery = $BTSdb->query("UPDATE bt_students_bus_route_details SET is_active='yes', one_way='" . $is_one_way . "' , route_id='" . $routeId . "' , pick_up_id='" . $pick_id . "' , drop_id='" . $pick_id . "' WHERE student_id=" . $query1['student_id']);
// if ($query1['route_id'] == $routeId) {
// // if ($query1['pick_up_id'] == $pick_id) {
// // } else {
// // $upQuery = $BTSdb->query("UPDATE bt_students_bus_route_details SET is_active='No' WHERE student_id=" . $query1['student_id']);
// // if ($upQuery) {
// // $upQuery1 = $BTSdb->query("UPDATE bt_students_bus_route_details SET pick_up_id = " . $pick_id . " , drop_id =" . $pick_id . " WHERE student_id=" . $query1['student_id'] . " and batch_id =" . $batch_id);
// // }
// // }
// echo ("<script>console.log('PHP: UPDATE bt_students_bus_route_details SET route_id = " . $routeId . " , pick_up_id = " . $pick_id . " , one_way = " . $oneway . " , drop_id = 0 WHERE student_id=" . $studentId . " and batch_id =" . $batch_id . "');</script>");
// // debug_to_console("UPDATE bt_students_bus_route_details SET route_id = " . $routeId . " , pick_up_id = " . $pick_id . " , one_way = " . $oneway . " , drop_id = 0 WHERE student_id=" . $studentId . " and batch_id =" . $batch_id);
// $upQuery1 = $BTSdb->query("UPDATE bt_students_bus_route_details SET route_id = " . $routeId . " , pick_up_id = " . $pick_id . " , one_way = " . $oneway . " , drop_id = 0 WHERE student_id=" . $studentId . " and batch_id =" . $batch_id);
// }
// // if ($query1['route_id'] == $routeId) {
// // if ($query1['pick_up_id'] == $pick_id) {
// // echo "<script>console.log('Same pick up.');</script>";
// // } else {
// // echo "<script>console.log('diffferent pick up.');</script>";
// // $upQuery = $BTSdb->query("UPDATE bt_students_bus_route_details SET is_active='No' WHERE student_id=" . $query1['student_id']);
// // echo "<script>console.log(UPDATE bt_students_bus_route_details SET is_active='No', one_way='" . $oneway . "' WHERE student_id=" . $query1['student_id'] . "</script>";
// // if ($upQuery) {
// // $upQuery1 = $BTSdb->query("UPDATE bt_students_bus_route_details SET pick_up_id = " . $pick_id . " , drop_id =" . $pick_id . " WHERE student_id=" . $query1['student_id'] . " and batch_id =" . $batch_id);
// // }
// // }
// // }
} else {
$insertQuery = $BTSdb->insert('bt_students_bus_route_details', $data);
}
echo ($result) ? 1 : 0;
}
public function routeUnAssignToStudent()
{
$BTSdb = $this->load->database('erisnClassroom_bts', TRUE);
$studentId = $_REQUEST['student_id'];
$routeId = $_REQUEST['route_id'];
$pick_id = $_REQUEST['stop_id'];
$batch_id = $_REQUEST['batch_id'];
$is_one_way = $_REQUEST['is_one_way'];
$course_id = $_REQUEST['s_course'];
// print_r($_REQUEST);
$std_routes = $BTSdb->query("SELECT * FROM bt_students_bus_route_details WHERE student_id = $studentId")->result_array();
// $oneway = $is_one_way ? 'yes' : 'no';
$query = "SELECT cf.id as course_fee_id,cf.fee_values as fee_name ,
IF(ss.id is null,0,ss.id) as scholarship_id,
IF(sop.id is null,0,sop.id) as sop_id,
IF(fas.id is null,0,fas.id) as fas_id
FROM course_fees cf
LEFT JOIN students_online_payments sop on cf.id = sop.course_fee_id AND sop.student_id = $studentId
LEFT JOIN student_scholarship ss on cf.id = ss.course_fee_id AND ss.student_id = $studentId
LEFT JOIN fee_assigned_students fas on fas.course_fee_id = cf.id AND fas.student_id = $studentId
WHERE cf.route_id = $routeId AND cf.batch_id = $batch_id AND cf.course_id = $course_id";
$std_transport_fees = $this->db->query($query)->result_array();
foreach ($std_transport_fees as $f_key => $transport_fee) {
if ($transport_fee['sop_id'] == 0) {
if ($transport_fee['scholarship_id'] > 0) {
$this->db->where('id', $transport_fee['scholarship_id']);
$this->db->delete('student_scholarship');
}
if ($transport_fee['fas_id'] > 0) {
$this->db->where('id', $transport_fee['fas_id']);
$this->db->delete('fee_assigned_students');
}
}
}
foreach ($std_routes as $r_key => $std_route) {
$BTSdb->where('id', $std_route['id']);
$BTSdb->delete('bt_students_bus_route_details');
}
$up_data['bus_facility'] = 'no';
$up_data['bus_routeid'] = 0;
$up_data['route_stop_id'] = 0;
$this->db->where('id', $studentId);
$result = $this->db->update('students', $up_data);
echo ($result) ? 1 : 0;
}
// Transport module End here
// By: shivu
// Hostel facility module start from here
// By: shivu
public function students_assign_to_hostel()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/asign-to-hostel.php'))
show_404();
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['title'] = "Hostel Facility";
$result = array();
if ((isset($_POST['filterSubmit']) && !empty($_POST['filterSubmit'])) == 'Filter') {
$this->form_validation->set_rules('search_batch', 'Batch', 'required');
$batchId = (!empty($_POST['search_batch'])) ? $_POST['search_batch'] : '';
$classroomId = (!empty($_POST['search_classroom'])) ? $_POST['search_classroom'] : '';
if (!$this->form_validation->run() == FALSE) {
$where = '';
$where .= "WHERE s.is_active='yes'";
if ($batchId != '')
$where .= ' AND s.batch_id=' . $batchId;
if ($classroomId != '')
$where .= ' AND sb.classroom_id=' . $classroomId;
$result = $this->db->query("SELECT sb.batch_id,b.b_name as batch_name,sb.classroom_id,cl.classroom_name,s.* FROM students s JOIN student_batch sb ON s.id=sb.student_id JOIN classroom cl ON cl.id=sb.classroom_id JOIN batch b ON b.id=sb.batch_id $where")->result_array();
}
}
$data['search_batch_id'] = (isset($batchId) && $batchId != '') ? $batchId : '';
$data['search_classroom_id'] = (isset($classroomId) && $classroomId != '') ? $classroomId : '';
$data['studentlist'] = (count($result) > 0) ? $result : 0;
// dd($data['studentlist']);
$data['classrooms'] = $this->db->query("select * from classroom WHERE is_active='yes'")->result_array();
$data['batchs'] = $this->Admin_model->get_batch();
$this->load->view('admin/header', $data);
$this->load->view('admin/asign-to-hostel.php', $data);
$this->load->view('admin/footer');
}
function gethostelDetails()
{
$batchid = $_REQUEST['batch_id'];
$student_id = $_REQUEST['student_id'];
$student = $this->db->get_where('students', array('id' => $student_id))->row_array();
$course_id = (isset($student['course']) && !empty($student['course'])) ? $student['course'] : 0;
$student_hostelplan_id = (isset($student['hostel_plan_id']) && !empty($student['hostel_plan_id'])) ? $student['hostel_plan_id'] : 0;
$fees_type_id = 3; // Fee types table (Hostel Fee)
if ($student_hostelplan_id != 0 && $course_id != 0)
$studentCourseFeeId = $this->db->query("SELECT id as route_course_fee_id,amount FROM course_fees WHERE batch_id=$batchid AND course_id=$course_id AND fees_type=$fees_type_id AND hostel_plan_id=$student_hostelplan_id")->row()->route_course_fee_id;
else
$studentCourseFeeId = 0;
// $hostelplanprice=array();
$data = array();
$hostelplanlist = array();
if ($batchid != '') {
$hostel_plans = $this->db->query('SELECT id,plan_name FROM hostel_plans')->result_array();
if ($hostel_plans != '') {
foreach ($hostel_plans as $plan) {
$hostelPlanId = $plan['id'];
$hostelplanprice = $this->db->query("SELECT id as hostel_course_fee_id, amount FROM course_fees WHERE batch_id=$batchid AND course_id=$course_id AND fees_type=$fees_type_id AND hostel_plan_id=$hostelPlanId")->row_array();
$plan_price = (isset($hostelplanprice['amount']) && !empty($hostelplanprice['amount'])) ? $hostelplanprice['amount'] : 0;
$hostelplanlist[] = array(
'hostel_plan_id' => $plan['id'],
'hostel_plan_name' => $plan['plan_name'],
'hostel_fee' => ($plan_price != 0) ? $plan_price : 0
);
}
}
}
// $hostel_course_fee_id=(isset($hostelplanprice['hostel_course_fee_id']) && !empty($hostelplanprice['hostel_course_fee_id'])) ? $hostelplanprice['hostel_course_fee_id'] :0;
$paymentStatus = false;
if ($studentCourseFeeId != 0) {
$student_installment = $this->db->get_where('students_online_payments', array('student_id' => $student_id, 'course_fee_id' => $studentCourseFeeId))->row_array();
if (!empty($student_installment)) {
$installmentArray = json_decode($student_installment['payment_details'], true);
foreach ($installmentArray as $payment_data) {
if ($payment_data['payment_status'] == 'yes') {
$paymentStatus = true;
break;
}
}
}
}
$data['payment_status'] = $paymentStatus;
$data['hostel_course_fee_id'] = $studentCourseFeeId;
$data['student_info'] = $student;
$data['hostelplan_data'] = $hostelplanlist;
$data['batch_name'] = $this->db->get_where('batch', array('id' => $batchid))->row()->b_name;
$data['student_hostel_plan_id'] = (isset($student['hostel_plan_id']) && !empty($student['hostel_plan_id'])) ? $student['hostel_plan_id'] : 0;
$page = $this->load->view('admin/hosteldata_modal', $data, TRUE);
echo $page;
}
public function hostelAssignToStudent()
{
$studentId = $_REQUEST['student_id'];
$hostelId = $_REQUEST['hostel_plan_id'];
$result = $this->db->query("UPDATE students SET hostel_plan_id=$hostelId,hostel='yes' WHERE id=$studentId");
echo ($result) ? 1 : 0;
}
// Hostel facility module End here
// By: shivu
// shankar code for promote student 12-04-22
public function promote_student()
{
if ((isset($_POST['student_id_list']) && !empty($student_id_list)) || (isset($_POST['select-batch']) && !empty($_POST['select-batch'])) || (isset($_POST['select-course']) && isset($_POST['select-course'])) || (isset($_POST['select-section']) && isset($_POST['select-section']))) {
$save_array = [];
foreach ($_POST['student_id_list'] as $key => $value) {
//adding student id into student batch
$get_classroom_id = $this->db->query('select id from classroom where course_id =' . $_POST['select-course'] . ' AND section_id =' . $_POST['select-section'])->row_array();
$roll_no = $this->db->query('select roll_no from student_batch where batch_id=' . $_POST['select-batch'] . ' and classroom_id =' . $get_classroom_id['id'] . ' and is_active ="yes" order by roll_no DESC')->row_array();
$save = array(
'student_id' => $value,
'batch_id' => $_POST['select-batch'],
'classroom_id' => $get_classroom_id['id'],
'roll_no' => (!empty($roll_no)) ? $roll_no['roll_no'] + 1 : 1,
'created' => $this->nepali_current_date
);
$this->db->insert('student_batch', $save);
$insert_id = $this->db->insert_id();
if ($insert_id) {
$upDate_student = array(
'batch_id' => $_POST['select-batch'],
'course' => $_POST['select-course'],
'modified' => $this->nepali_current_date
);
// $this->db->where('id', $value);
$this->db->update('students', $upDate_student, "id =$value");
if ($this->db->trans_status() === FALSE) {
} else {
$save_array[] = $insert_id;
}
}
}
if (!empty($save_array)) {
$data = urlsafe_b64encode(json_encode($save_array));
// dd($data);
redirect(base_url() . 'admin/promosion-view-show/' . $data);
} else {
$this->session->set_flashdata('failed', 'Something Went Wrong !! Data not Added');
redirect(base_url() . 'admin/studentPromosionView');
}
} else {
$this->session->set_flashdata('failed', 'Data not Added');
redirect(base_url() . 'admin/studentPromosionView');
}
}
public function promosion_view_show($content)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['courseId'] = '';
$data['sectionId'] = '';
$data['course'] = $this->db->query("select * from course WHERE is_active='yes'")->result_array();
$data['batch'] = $this->Admin_model->get_batch();
$student_data = array();
$sb_id = json_decode(urlsafe_b64decode($content));
foreach ($sb_id as $key => $value) {
$students = $this->db->query('select s.name as student_name, s.studentId , b.b_from, b.b_end, sc.section_name, co.course_name from student_batch sb, students s, classroom c, batch b, section sc , course co where sb.id =' . $value . ' AND s.id = sb.student_id AND sb.batch_id = b.id AND c.id = sb.classroom_id AND c.course_id = co.id AND c.section_id = sc.id')->row_array();
if (!empty($students)) {
array_push($student_data, array(
'student_name' => $students['student_name'],
'student_id' => $students['studentId'],
'course_name' => $students['course_name'],
'section_name' => $students['section_name'],
'batch_name' => batchdateFormatTo($students['b_from'], $students['b_end']),
'sb_id' => $value
));
}
}
$data['promoted_students'] = $student_data;
if (empty($student_data)) {
$this->session->set_flashdata('failed', 'Something Went Wrong... No Data Found');
redirect(base_url() . 'admin/studentPromosionView');
}
$this->load->view('admin/header', $data);
$this->load->view('admin/promosion-view');
$this->load->view('admin/footer');
}
public function deltePromotedStudentByBatch()
{
$id = $_POST['id'];
$student_id = $this->db->query('select student_id from student_batch where id =' . $id)->row_array();
if (!empty($student_id)) {
$delete = $this->db->delete('student_batch', array('id' => $id));
if ($delete) {
//get last data of student batch using student id
$get_data = $this->db->query('select sb.batch_id, co.id as course_id from student_batch sb,classroom c, course co where student_id=' . $student_id['student_id'] . ' AND c.id = sb.classroom_id AND c.course_id = co.id order by sb.id DESC')->row_array();
if (!empty($get_data)) {
$upDate_student = array(
'batch_id' => $get_data['batch_id'],
'course' => $get_data['course_id']
);
// $this->db->where('id', $value);
$this->db->update('students', $upDate_student, array('id' => $student_id['student_id']));
if ($this->db->trans_status() === FALSE) {
echo 'failed';
} else {
echo 'success';
}
} else {
echo 'failed';
}
}
} else {
echo 'failed';
}
}
public function get_sections_from_course_id($c_id)
{
$result = $this->Admin_model->get_sections_from_course_id($c_id);
// echo json_encode($result);
echo json_encode($result);
}
public function getTeacherByClassroomSubject()
{
$subjectid = $_REQUEST['subjectid'];
$classroomid = $_REQUEST['classroomid'];
$rst = $this->db->query("SELECT * FROM classroom_teacher_subject WHERE classroom_id=$classroomid AND subject_id=$subjectid")->row_array();
if (!empty($rst))
echo json_encode($rst);
else
echo 0;
}
public function printcount_increment()
{
$invoiceIds = $_REQUEST['inoviceids'];
// $invoiceArray = json_decode($invoiceIds);
// foreach ($invoiceArray as $i_key => $i_value) {
// $this->db->query('update student_fee_online_transactions set bill_print_count = bill_print_count + 1 where id =' . $i_value);
// }
$this->db->query('update student_fee_online_transactions set bill_print_count = bill_print_count + 1 where id =' . $invoiceIds);
return true;
}
public function addExpeses($checker)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$data['currentURL'] = current_url();
//get logo
$data['expenses_types'] = $this->db->query('select id as expenseId, name as expenseTitle from expense_types')->result_array();
$data['expenses_data'] = '';
if ($checker > 0) {
$data['title'] = 'Update Expenses';
$data['checker'] = $checker;
$data['expenses_data'] = $this->db->query('select * from expenses where id=' . $checker)->row_array();
} else {
$data['checker'] = 0;
$data['title'] = 'Add Expenses';
}
if (count($_POST) > 0) {
if ($_POST['expenses_id'] == 0) {
if (!empty($_FILES['file_expenses']['name'])) {
$filename = $_FILES['file_expenses']['name'];
if (!is_dir('expenses_images')) {
mkdir('./expenses_images', 0777, true);
}
$location = "expenses_images/" . $filename;
$imageFileType = pathinfo($location, PATHINFO_EXTENSION);
$imageFileType = strtolower($imageFileType);
/* Valid extensions */
$valid_extensions = array("jpg", "jpeg", "png");
$response = 0;
/* Check file extension */
if (in_array(strtolower($imageFileType), $valid_extensions)) {
/* Upload file */
if (move_uploaded_file($_FILES['file_expenses']['tmp_name'], $location)) {
$response = $location;
}
}
}
$profile_image = '';
$expense_s_type = '';
$expense_s_type_computer = '';
$expense_s_type_vehicle = '';
if (isset($_FILES['file_expenses']['name'])) {
$profile_image = $response;
}
if (isset($_POST['expense_sub_type_computer'])) {
$expense_s_type_computer = $_POST['expense_sub_type_computer'];
}
if (isset($_POST['expense_sub_type_vehicle'])) {
$expense_s_type_vehicle = $_POST['expense_sub_type_vehicle'];
}
if ($expense_s_type_computer != '') {
$expense_s_type = $expense_s_type_computer;
} else if ($expense_s_type_vehicle != '') {
$expense_s_type = $expense_s_type_vehicle;
}
// var_dump($_POST);
$data_array = array(
'title' => $_POST['formTitle'],
'expense_type' => $_POST['expense_type'],
'expense_s_type' => $expense_s_type,
'quantity' => $_POST['formQuantity'],
'amount' => $_POST['formAmount'],
'total_amount' => $_POST['totalAmountPaid'],
'paid_date' => $_POST['formPaidDate'],
'file_path' => $profile_image,
'description' => $_POST['description'],
'created' => $this->nepali_current_date
);
// print_r($data_array);
$this->db->insert('expenses', $data_array);
$result_id = $this->db->insert_id();
if ($result_id) {
$this->session->set_flashdata('success', str_replace('%s', 'New Expenses', THE_ADD_SUCCESS_MSG));
redirect(base_url() . 'admin/addExpeses/0');
} else {
$this->session->set_flashdata('failed', 'Something Went Wrong ... Try again in sometime ....!!');
redirect(base_url() . 'admin/addExpeses/0');
}
} else {
if (!empty($_FILES['file_expenses']['name'])) {
$filename = $_FILES['file_expenses']['name'];
if (!is_dir('expenses_images')) {
mkdir('./expenses_images', 0777, true);
}
$location = "expenses_images/" . $filename;
$imageFileType = pathinfo($location, PATHINFO_EXTENSION);
$imageFileType = strtolower($imageFileType);
/* Valid extensions */
$valid_extensions = array("jpg", "jpeg", "png");
$response = 0;
/* Check file extension */
$expenses_pic_prev = $this->db->get_where('expenses', array('id' => $_POST['expenses_id']))->row()->file_path;
if (in_array(strtolower($imageFileType), $valid_extensions)) {
/* Upload file */
if (move_uploaded_file($_FILES['file_expenses']['tmp_name'], $location)) {
unlink($expenses_pic_prev);
$response = $location;
}
}
}
$profile_image = '';
$data_array = array(
'title' => $_POST['formTitle'],
'quantity' => $_POST['formQuantity'],
'amount' => $_POST['formAmount'],
'total_amount' => $_POST['totalAmountPaid'],
'paid_date' => $_POST['formPaidDate'],
'description' => $_POST['description'],
'created' => $this->nepali_current_date
);
if (isset($_FILES['file_expenses']['name']) && !empty($_FILES['file_expenses']['name'])) {
$data_array['file_path'] = $response;
}
$this->db->where('id', $_POST['expenses_id']);
$this->db->update('expenses', $data_array);
$updated_status = $this->db->affected_rows();
if ($updated_status) {
$this->session->set_flashdata('success', str_replace('%s', 'Expenses', THE_UPDATE_SUCCESS_MSG));
redirect(base_url() . 'admin/addExpeses/' . $_POST['expenses_id']);
} else {
$this->session->set_flashdata('failed', str_replace('%s', 'Expenses', THE_UPDATE_FAILED_MSG));
redirect(base_url() . 'admin/addExpeses/' . $_POST['expenses_id']);
}
}
}
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$this->load->view('admin/header', $data);
$this->load->view('admin/add-expenses');
$this->load->view('admin/footer');
}
public function listExpeses()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$data['currentURL'] = current_url();
if ($this->input->post('filterSubmit') == "Filter") {
// $this->form_validation->set_rules('filter-course', 'Course', 'required');
$s_expense_type = $_POST['filter-expense-type'];
$s_date = (isset($_POST['filter-Sdate']) && !empty($_POST['filter-Sdate'])) ? $_POST['filter-Sdate'] : '';
if (empty($s_date)) {
// echo 'Empty';
$e_date = (isset($_POST['filter-Edate']) && !empty($_POST['filter-Edate'])) ? $_POST['filter-Edate'] : '';
} else {
// echo 'Npt Empty';
$e_date = (isset($_POST['filter-Edate']) && !empty($_POST['filter-Edate'])) ? $_POST['filter-Edate'] : date('Y-m-d', strtotime($this->nepali_current_date));
}
// var_dump($e_date);
// dd($s_date);
// $s_date = (isset($_POST['by_start_paid_date']) && !empty($_POST['by_start_paid_date'])) ? $_POST['by_start_paid_date'] : date('Y-m-01', strtotime($this->nepali_current_date));
// $e_date = (isset($_POST['by_end_paid_date']) && !empty($_POST['by_end_paid_date'])) ? $_POST['by_end_paid_date'] : date('Y-m-t', strtotime($this->nepali_current_date));
$data['sdate'] = $s_date;
$data['edate'] = $e_date;
$where = '';
if ($s_date != '' && $s_date != '')
$where = "WHERE date(paid_date) BETWEEN '$s_date' AND '$e_date'";
else {
if ($s_date != '') {
$where = "WHERE date(paid_date) BETWEEN '$s_date'";
} else if ($e_date != '')
$where = "WHERE date(paid_date) <= '$e_date'";
}
if (trim($s_expense_type) != '') {
if (trim($where) != '') {
$where = "$where AND expense_type = $s_expense_type";
} else {
$where = "WHERE expense_type = $s_expense_type";
}
}
$Sqlquery = "SELECT * FROM `expenses` $where ORDER BY paid_date DESC";
$data['expenses_data'] = $this->Admin_model->get_query_result($Sqlquery);
} else {
// $data['students'] = $this->Admin_model->get_students();
$data['expenses_data'] = $this->db->query('select * from expenses order BY paid_date DESC')->result_array();
}
$data['expenses_types'] = $this->db->query('select id as expenseId, name as expenseTitle from expense_types')->result_array();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$this->load->view('admin/header', $data);
$this->load->view('admin/list-expenses');
$this->load->view('admin/footer');
}
public function delete_expenses($id)
{
$sql = $this->Admin_model->delete_expenses($id);
if ($sql) {
$this->session->set_flashdata('success', 'Expenses has been successfully deleted');
redirect(base_url() . 'admin/listExpeses');
} else {
$this->session->set_flashdata('danger', 'Expenses could not been deleted, Please try again!');
redirect(base_url() . 'admin/listExpeses');
}
}
public function rollNumberChange($classroomId)
{
$data['encrepted_clas'] = $classroomId;
$classroom_id = (int)str_replace("-qqcksbvlwierhwjerw", '', urlsafe_b64decode($classroomId));
$check_classroom_id = $this->db->query('select * from classroom where id =' . $classroom_id)->row_array();
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['title'] = "Student List of " . $check_classroom_id['classroom_name'];
$data['classroomid'] = $check_classroom_id['id'];
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$cls_id = $check_classroom_id['id'];
// $query = "SELECT sb.id as stud_batch_id, sb.roll_no, sb.batch_id,sb.classroom_id,s.* FROM student_batch sb LEFT JOIN students s ON sb.student_id=s.id AND sb.batch_id = " . $data['school_info']['batch_id'] . " WHERE sb.classroom_id=$cls_id";
$query = "SELECT sb.id as stud_batch_id, sb.roll_no, sb.batch_id as student_batch, sb.classroom_id, s.* FROM student_batch sb LEFT JOIN students s ON sb.student_id=s.id WHERE sb.batch_id = " . $data['school_info']['batch_id'] . " AND sb.classroom_id=$cls_id ORDER BY sb.roll_no";
$data['student_list'] = $this->Admin_model->get_query_result($query);
// echo $query;
// dd($data['student_list']);
if ($_POST) {
$checker = 0;
$roll_numbers = explode(",", $_POST['roll_numbers']);
$batch_ids = explode(",", $_POST['batch_ids']);
// dd($_POST);
foreach ($roll_numbers as $key => $value) {
$this->db->set('roll_no', $value);
$this->db->where('id', $batch_ids[$key]);
$update = $this->db->update('student_batch');
if ($update) {
$checker = 1;
}
}
if ($checker > 0)
$this->session->set_flashdata('success_msg', 'Roll Number Updated Successfully');
else
$this->session->set_flashdata('error_msg', 'Something Went Wrong...Plese try again...!!');
redirect(base_url() . 'admin/roll-change/' . $classroomId);
}
$this->load->view('admin/header', $data);
$this->load->view('admin/assign_rollNumber');
$this->load->view('admin/footer');
}
// New Inovice
public function newinvoice($studID, $txn_ID, $count, $invoiceList)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/invoice.php'))
show_404();
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$studentID = urlsafe_b64decode($studID);
$txnID = urlsafe_b64decode($txn_ID);
$counter = urlsafe_b64decode($count);
$invoiceList = urlsafe_b64decode($invoiceList);
if ($counter > 1)
$data['back_url'] = 'admin/student_fee_course/' . $counter;
else
$data['back_url'] = 'admin/reports';
if ($studentID != '' && $txnID != '') {
$student_ID = $this->db->get_where('students', array('studentId' => $studentID))->row();
if ($student_ID != '') {
$sql1 = "SELECT sfot.*,course_fees.fee_values,s.course as courseID,s.name,s.studentId,b.b_from,b.b_name as batch_name,b.b_end,sb.batch_id,cl.course_id,cl.section_id,s.parent_pan FROM student_fee_online_transactions sfot LEFT JOIN students s ON sfot.studentId=s.studentId LEFT JOIN student_batch sb ON s.id=sb.student_id AND s.batch_id = sb.batch_id LEFT JOIN classroom cl ON cl.id=sb.classroom_id LEFT JOIN batch b ON sb.batch_id=b.id
INNER JOIN course_fees ON sfot.course_fee_id = course_fees.id
WHERE sfot.studentId='$studentID' AND sfot.invoice_no='$txnID' order by sb.id desc";
$payment_datalist = $this->Admin_model->get_query_result($sql1);
foreach ($payment_datalist as $payment_data) {
$student_data[] = array(
'student_fee_online_transactions_id' => $payment_data['id'],
// 'studentId' => $payment_data['studentId'],
'payment_for' => $payment_data['fee_values'] . '(' . $payment_data['payment_for'] . ')',
'txn_id' => $payment_data['txn_id'],
'payment_amt' => $payment_data['payment_amt'],
'paid_date' => $payment_data['payment_date'],
// 'studentname' => $payment_data['name'],
// 'batch_name' => $payment_data['batch_name'],
// 'batch_from' => $payment_data['b_from'],
// 'batch_end' => $payment_data['b_end'],
// 'course_id' => (isset($payment_data['course_id']) && !empty($payment_data['course_id'])) ? $payment_data['course_id'] : $payment_data['courseID'],
'received_by' => $payment_data['payment_recived_id'],
'payment_method' => $payment_data['payment_method'],
'fine_amount' => $payment_data['fine_amount'],
'tdt' => date('Y-m-d H:i:s', strtotime($this->nepali_current_date)),
'deduction_type' => $payment_data['deduction_type'],
'deduction_amount' => $payment_data['deduction_amount'],
// 'section_id' => $payment_data['section_id'],
'bill_print_count' => $payment_data['bill_print_count'],
'course_fee_id' => $payment_data['course_fee_id'],
'install_sno' => $payment_data['install_sno'],
'parent_pan' => (isset($payment_data['parent_pan']) && !empty($payment_data['parent_pan'])) ? $payment_data['parent_pan'] : '',
'invoice_no' => (isset($payment_data['invoice_no']) && !empty($payment_data['invoice_no'])) ? $payment_data['invoice_no'] : ''
);
}
$data['invoice_data'] = $student_data;
dd($data['invoice_data']);
} else {
$sql2 = "SELECT soft.*,course_fees.fee_values,a.name,a.course,b.b_name as batch_name,b.b_from,b.b_end FROM student_fee_online_transactions soft LEFT JOIN applications a ON a.applicationid=soft.studentId LEFT JOIN batch b ON b.id=a.batch_id LEFT JOIN course_fees ON soft.course_fee_id = course_fees.id WHERE soft.studentId='$studentID' AND soft.invoice_no='$txnID' order by soft.id desc";
$paymentdata = $this->Admin_model->get_query_result($sql2);
// dd($sql2);
if (count($paymentdata) > 0) {
$application_data = array(
'student_fee_online_transactions_id' => $paymentdata['id'],
'studentId' => $paymentdata['studentId'],
'payment_for' => $paymentdata['fee_values'] . '(' . $paymentdata['payment_for'] . ')',
'txn_id' => $paymentdata['txn_id'],
'payment_amt' => $paymentdata['payment_amt'],
'paid_date' => $paymentdata['payment_date'],
'studentname' => $paymentdata['name'],
'batch_name' => $paymentdata['batch_name'],
'batch_from' => $paymentdata['b_from'],
'batch_end' => $paymentdata['b_end'],
'course_id' => $paymentdata['course'],
'received_by' => $paymentdata['payment_recived_id'],
'payment_method' => $paymentdata['payment_method'],
'fine_amount' => $paymentdata['fine_amount'],
'tdt' => date('Y-m-d H:i:s', strtotime($this->nepali_current_date)),
'deduction_type' => $paymentdata['deduction_type'],
'deduction_amount' => $paymentdata['deduction_amount'],
'section_id' => 0,
'bill_print_count' => $paymentdata['bill_print_count'],
'course_fee_id' => $paymentdata['course_fee_id'],
'install_sno' => $paymentdata['install_sno'],
'parent_pan' => '',
'invoice_no' => (isset($paymentdata['invoice_no']) && !empty($paymentdata['invoice_no'])) ? $paymentdata['invoice_no'] : ''
);
$data['invoice_data'] = $application_data;
}
}
}
// dd($data['invoice_data']);
$this->load->view('admin/header', $data);
$this->load->view('admin/invoice', $data);
$this->load->view('admin/footer');
}
/*START : Coding done by assign_all_fees_atonce -----------------------------------------*/
function assign_all_fees_atonce()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/assign-all-fees-atonce.php'))
show_404();
$theStudents = array();
$theFees = array();
$theBatchId = '';
$feestype = array();
$studntinfo = [];
$studntinfo1 = [];
$studntRouteInfo = [];
$studntRouteInfo1 = [];
$sectionId = '';
$courseId = '';
$filterRouteId = '';
$dateFrom = '';
$feestypes = [];
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['title'] = "Assign Fees";
$data['courses'] = $this->Admin_model->get_courses();
//echo '<pre>'; print_r($data['courses']);exit;
$school_info = $this->Admin_model->get_logo_from_setting();
$data['school_info'] = $school_info;
if (isset($school_info['batch_id']))
$theBatchId = (!empty($school_info['batch_id'])) ? $school_info['batch_id'] : 0;
if ($this->input->post('filterSubmit') == "Filter") {
$condtion = '';
// $this->form_validation->set_rules('filter-course', 'Course', 'required');
$courseId = (isset($_POST['filter-course']) && !empty($_POST['filter-course'])) ? $_POST['filter-course'] : '';
$sectionId = (isset($_POST['filter-section']) && !empty($_POST['filter-section'])) ? $_POST['filter-section'] : '';
$feestypes = (isset($_POST['filter-fees_type']) && !empty($_POST['filter-fees_type'])) ? $_POST['filter-fees_type'] : '';
$dateFrom = (isset($_POST['date_from']) && !empty($_POST['date_from'])) ? $_POST['date_from'] : '';
$filterRouteId = (isset($_POST['filter-route-id']) && !empty($_POST['filter-route-id'])) ? $_POST['filter-route-id'] : '';
// dd($feestypes);
if ($courseId != '')
$condtion .= " AND cf.course_id='$courseId'";
if ($feestypes != '') {
$arr = implode(',', $feestypes);
$condtion .= " AND cf.fees_type in ($arr)";
}
if ($filterRouteId != '')
$condtion .= " AND cf.route_id = '$filterRouteId'";
if ($dateFrom != '')
$condtion .= " AND cf.created >= '$dateFrom'";
if ($theBatchId != 0) {
$sql = "SELECT cf.id as course_fee_id,cf.batch_id,cf.course_id,ft.id,ft.feetype_name,cf.fees_name,cf.amount,cf.due_date,cf.grouped,cf.fee_values FROM course_fees cf JOIN fee_types ft ON cf.fees_type=ft.id WHERE cf.batch_id='$theBatchId' $condtion ";
$result = $this->Admin_model->get_query_result($sql);
$q = '';
if ($courseId != '')
$q .= " AND s.course=$courseId";
if ($sectionId != '')
$q .= " AND cl.section_id=$sectionId";
if ($filterRouteId != '')
$q .= " AND s.bus_routeid=$filterRouteId";
// if($date_from != '')
// $q.=" AND DATE(cf.created) <= $dateFrom";
//$sql2="SELECT s.id as student_id,s.studentId,s.name,s.course,s.batch_id,cl.section_id,se.section_name FROM students s
// JOIN student_batch sb ON sb.student_id=s.id AND sb.batch_id=s.batch_id
// JOIN classroom cl ON cl.id = sb.classroom_id JOIN section se ON se.id=cl.section_id WHERE sb.batch_id='$theBatchId' $q";
$sql2 = "SELECT s.id as student_id,s.studentId,s.name,s.course,s.batch_id,cl.section_id,se.section_name, sb.roll_no FROM students s JOIN student_batch sb ON s.id=sb.student_id AND sb.batch_id = $theBatchId JOIN classroom cl ON cl.id = sb.classroom_id AND s.course=cl.course_id JOIN section se ON cl.section_id=se.id WHERE sb.batch_id= $theBatchId $q ORDER BY sb.roll_no";
// exit;
$result2 = $this->Admin_model->get_query_result($sql2);
if (count($result) > 0) {
foreach ($result as $value) {
$feestype[] = array(
'feecourse_id' => $value['course_fee_id'],
'fee_name' => $value['fee_values'],
'course_fee_id' => $value['course_fee_id'],
'fee_amount' => $value['amount']
);
}
if (count($result2) > 0) {
// dd($result2);
$BTSdb = $this->load->database('erisnClassroom_bts', TRUE);
// $studentId = $_REQUEST['student_id'];
// $routeId = $_REQUEST['route_id'];
// $pick_id = $_REQUEST['stop_id'];
// $batch_id = $_REQUEST['batch_id'];
// $is_one_way = $_REQUEST['is_one_way'];
// var_dump($is_one_way);
// $oneway = $is_one_way ? 'yes' : 'no';
// $result = $this->db->query("UPDATE students SET bus_routeid=$routeId,bus_facility='yes',route_stop_id=$pick_id WHERE id=$studentId");
// $query1 = $BTSdb->query('SELECT * from bt_students_bus_route_details WHERE student_id=' . $studentId . ' and batch_id =' . $theBatchId . ' order by id DESC')->row_array();
foreach ($result2 as $key1 => $std_value) {
// $std_id = $std_value['student_id'];
foreach ($result as $key2 => $value) {
$rst = $this->db->get_where('fee_assigned_students', array('student_id' => $std_value['student_id'], 'course_fee_id' => $value['course_fee_id']))->row_array();
$feetypevalue = ($rst != '') ? 1 : 0;
$studntinfo1[$key2] = array('course_fee_id' => $value['course_fee_id'], 'status' => $feetypevalue);
}
$studntinfo[$key1] = array(
'student_id' => $result2[$key1]['student_id'],
'student_name' => $result2[$key1]['name'],
'studentId' => $result2[$key1]['studentId'],
'roll_no' => $result2[$key1]['roll_no'],
'fees_data' => $studntinfo1
);
if ($filterRouteId != '') {
$query1 = $BTSdb->query('SELECT * from bt_students_bus_route_details WHERE student_id=' . $result2[$key1]['student_id'] . ' and batch_id =' . $theBatchId . ' and route_id =' . $filterRouteId . ' order by id DESC')->row_array();
// $studntRouteInfo[$key];
$studntinfo[$key1]['route_details'] = isset($query1) && count($query1) != 0 ? $query1 : null;
}
// array_push();
}
}
$theStudents['student_info'] = $studntinfo;
// echo '<pre>';
// var_dump($studntinfo);
$theStudents['student_route_details'] = $studntinfo;
// $data['fees_type_names']=$feestype;
}
}
}
// dd($data['fees_type_names']);
$feestypelist = $this->Admin_model->get_fees_type();
if ($filterRouteId != '') {
$data['routes'] = $this->Admin_model->get_currentbatch_routes();
$data['filter_route_id'] = $filterRouteId;
}
$data['section'] = $sectionId;
$data['feestypes'] = $feestypes;
$data['course'] = $courseId;
$data['start_date'] = (!empty($dateFrom)) ? $dateFrom : '';
$data['fees_type'] = $feestypelist;
$data['fees_type_names'] = $feestype;
$data['theFees'] = $theFees;
$data['theBatchId'] = $theBatchId;
$data['theStudents'] = $theStudents;
$this->load->view('admin/header', $data);
$this->load->view('admin/assign-all-fees-atonce', $data);
$this->load->view('admin/footer');
}
function assigntostudents()
{
// dd($_POST);
$fees_typelist = $this->input->post('feestype');
$modified_students = $this->input->post('students');
if (!empty($modified_students)) {
$student_fees = $this->input->post('row');
$oneWay = $this->input->post('one_way');
$modified = array();
$assigned_arr = array();
$unassigned_arr = array();
$check_already = array();
// echo '<pre>';
// print_r($student_fees);
// print_r($oneWay);
foreach ($student_fees as $key => $std_value) {
if (in_array($key, $modified_students)) {
// echo '<h2> Is Half Fee ' . $oneWay[$key] . ' </h2> <span> Fee Data = ' . $std_value . ' Student Id = ' . $key . ' </span> <br>';
$modified[] = array(
'student_id' => $key,
'fees_data' => $std_value,
'is_half_fee' => $oneWay[$key]
);
}
}
if (count($modified) > 0) {
foreach ($modified as $feekey => $value) {
$studentId = $value['student_id'];
// echo '<pre>';
// var_dump($value);
foreach ($value['fees_data'] as $course_fee_id => $fe_value) {
$cf = $this->Admin_model->get_query_row("SELECT cf.*, ft.feetype_name FROM course_fees cf JOIN fee_types ft ON ft.id = cf.fees_type WHERE cf.id = $course_fee_id");
if ($fe_value == 'on') {
$insert_data = array(
'student_id' => $studentId,
'course_fee_id' => $course_fee_id,
'is_half_fee' => $value['is_half_fee'][$course_fee_id]
);
// checking start HERE
$sql = "SELECT cf.fee_values,fas.id as fee_assigned_id FROM fee_assigned_students fas JOIN course_fees cf ON cf.id=fas.course_fee_id WHERE fas.student_id=$studentId ANd fas.course_fee_id=$course_fee_id ";
$check_assigned = $this->Admin_model->get_query_row($sql);
if ($check_assigned != '') {
$check_already[] = $check_assigned['fee_values'];
} else {
$std = $this->Admin_model->get_query_row("SELECT * FROM students WHERE id = $studentId");
$scholarship = $this->Admin_model->get_query_row("SELECT ss.*, st.scholarshiptype_name FROM student_scholarship ss JOIN scholarship_types st ON st.id = ss.scholarship_type WHERE ss.student_id = $studentId AND ss.course_fee_id = $course_fee_id");
// dd($scholarship);
$this->accounting->voucherEntry($studentId, $std['studentId'], $cf, $scholarship, 'Journal');
// dd($insert_data);
$result = $this->db->insert('fee_assigned_students', $insert_data);
if ($result == TRUE)
array_push($assigned_arr, $course_fee_id);
}
// Checking End Here
} else if ($fe_value == 'off') {
$coondition_data = array(
'student_id' => $studentId,
'course_fee_id' => $course_fee_id,
'is_half_fee' => $value['is_half_fee'][$course_fee_id]
);
$this->db->where($coondition_data);
$unselected_data = $this->db->delete('fee_assigned_students');
if ($unselected_data == TRUE) {
$this->accounting->reversalVoucherEntry($studentId, $cf);
array_push($unassigned_arr, $course_fee_id);
}
}
}
}
if (count($assigned_arr) > 0 && count($unassigned_arr) > 0) {
$this->session->set_flashdata('success', "Fees has been assigned to Students Successfully");
} else if (count($assigned_arr) > 0 && count($unassigned_arr) == 0) {
$this->session->set_flashdata('success', "Fees has been assigned Successfully");
} else if (count($assigned_arr) == 0 && count($unassigned_arr) > 0) {
$this->session->set_flashdata('success', "Fees has been unassigned Successfully");
}
} else {
$this->session->set_flashdata('error', "No Changes");
}
} else {
$this->session->set_flashdata('error', "No Changes");
}
redirect(base_url() . 'admin/assign-all-fees');
}
/*END Of : Coding done by Shivakumar -----------------------------------------*/
// New Student module - start from Here
// Developer: Shivakumar
// Date: 03-06-2022
public function newstudentview()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/addnewstudent.php'))
show_404();
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['title'] = "Student Admission";
$data['courses'] = $this->Admin_model->get_courses();
$data['batch'] = $this->Admin_model->get_batch();
$CI = &get_instance();
$mainList = $CI->load->database('schoolSetting', TRUE);
$data['provinces'] = $mainList->query("SELECT * FROM provinces")->result_array();
$this->load->view('admin/header', $data);
$this->load->view('admin/addnewstudent', $data);
$this->load->view('admin/footer');
}
public function addnewstudent()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (count($_POST) > 0) {
$config['upload_path'] = 'assets_student/application/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$this->load->library('upload', $config);
$this->upload->initialize($config);
$data['currentURL'] = current_url();
$data['sinfo'] = $_POST;
$school_info = $this->Admin_model->get_logo_from_setting();
$photo = array('upload_data' => $this->upload->data());
if (!$this->upload->do_upload('photo')) {
$data['photo'] = "No-Image.jpg";
} else {
$photo = array('upload_data' => $this->upload->data());
$data['photo'] = $photo['upload_data']['file_name'];
}
if (!$this->upload->do_upload('school')) {
$data['school'] = "No-Image.jpg";
} else {
$school = array('upload_data' => $this->upload->data());
$data['school'] = $school['upload_data']['file_name'];
}
if (!$this->upload->do_upload('exam')) {
$data['exam'] = "No-Image.jpg";
} else {
$exam = array('upload_data' => $this->upload->data());
$data['exam'] = $exam['upload_data']['file_name'];
}
if (!$this->upload->do_upload('medical')) {
$data['medical'] = "No-Image.jpg";
} else {
$medical = array('upload_data' => $this->upload->data());
$data['medical'] = $medical['upload_data']['file_name'];
}
$data['sameAsPermanentAddress'] = $_POST['same_as_per_add'];
// if(isset($_POST['sibling']) && $_POST['sibling'] == 'yes') {
// $parentId = $_POST['sibling_parent_id'];
// $inserted_student=$this->Admin_model->addNewStudent($data,$parentId);
// if($inserted_student > 0){
// $this->session->set_flashdata('success', str_replace('%s', 'Student', THE_ADD_SUCCESS_MSG));
// }
// else {
// $this->session->set_flashdata('error', str_replace('%s', 'Student', THE_INSERT_FAILED_MSG));
// }
// } else {
$inserted_student = $this->Admin_model->addNewStudent($data);
if ($inserted_student === -1) {
$this->session->set_flashdata('error', "Student Email or Mobile number Already Exists");
} else if ($inserted_student > 0) {
$this->session->set_flashdata('success', str_replace('%s', 'Student', THE_ADD_SUCCESS_MSG));
} else {
$this->session->set_flashdata('error', str_replace('%s', 'Student', THE_INSERT_FAILED_MSG));
}
// }
redirect(base_url() . 'admin/add-student');
// $this->Admin_model->add_applicationinfo($data);
}
}
// New Student module - End Here
public function get_routes_by_batch_course()
{
$BTSdb = $this->load->database('erisnClassroom_bts', TRUE);
$school_info = $this->Admin_model->get_logo_from_setting();
$batch_id = (isset($school_info['batch_id']) && !empty($school_info['batch_id'])) ? $school_info['batch_id'] : 0;
$route_data = array();
// $fee_type_id=($_POST['fee_type_id'] !='') ? $_POST['fee_type_id'] : 0;
$result = $BTSdb->query('select * FROM bt_batch_routes WHERE batch_id=' . $batch_id)->row_array();
if ($result != '') {
$route_ids = explode(',', $result['route_ids']);
if (count($route_ids) > 0) {
foreach ($route_ids as $value) {
$value = (!empty($value)) ? $value : 0;
$rst = $BTSdb->query('SELECT * FROM `bt_routes` WHERE id=' . $value)->row_array();
$route_data[] = array(
'id' => $rst['id'],
'route_name' => $rst['route_name']
);
}
$data['routes'] = $route_data;
} else {
$data['routes'] = '';
}
} else
$data['routes'] = '';
echo json_encode($data);
}
function check_route_fees()
{
$batch_id = (isset($_POST['batch_id']) && !empty($_POST['batch_id'])) ? $_POST['batch_id'] : 0;
$feetype_id = (isset($_POST['feetype_id']) && !empty($_POST['feetype_id'])) ? $_POST['feetype_id'] : 0;
$course_ids = (isset($_POST['course_ids']) && !empty($_POST['course_ids'])) ? $_POST['course_ids'] : 0;
$route_id = (isset($_POST['route_id']) && !empty($_POST['route_id'])) ? $_POST['route_id'] : 0;
$course_arr = implode(',', $course_ids);
// $condtion.=" AND cf.fees_type in ($arr)";
// echo 'SELECT * FROM `course_fees` WHERE batch_id='.$batch_id.' AND fees_type='.$feetype_id.' AND course_id IN ('.$course_arr.') AND route_id='.$route_id;
$exitsfee = $this->db->query('SELECT cf.*,c.course_name FROM course_fees cf JOIN course c ON c.id=cf.course_id WHERE cf.batch_id=' . $batch_id . ' AND cf.fees_type=' . $feetype_id . ' AND cf.course_id IN (' . $course_arr . ') AND cf.route_id=' . $route_id)->result_array();
echo (count($exitsfee) > 0) ? json_encode($exitsfee) : 0;
}
function report_recent_transactions()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/report_recent_transactions.php'))
show_404();
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$studentInfo = array();
if ($this->input->post('filtersubmit') == "filter") {
$feestype = (isset($_POST['by_feetype']) && !empty($_POST['by_feetype'])) ? $_POST['by_feetype'] : '';
$courseId = (isset($_POST['by_course_id']) && !empty($_POST['by_course_id'])) ? $_POST['by_course_id'] : 0;
$startDate = (isset($_POST['by_start_paid_date']) && !empty($_POST['by_start_paid_date'])) ? $_POST['by_start_paid_date'] : date('Y-m-01', strtotime($this->nepali_current_date));
$endDate = (isset($_POST['by_end_paid_date']) && !empty($_POST['by_end_paid_date'])) ? $_POST['by_end_paid_date'] : date('Y-m-t', strtotime($this->nepali_current_date));
$where = '';
if ($feestype != '')
$where = "WHERE payment_for LIKE '%$feestype%'";
// else if ($startDate != '')
// $where = "WHERE date(payment_date) = '$startDate'";
// else if ($endDate != '')
// $where = "WHERE date(payment_date) = '$endDate'";
else if ($startDate != '' && $endDate != '')
$where = "WHERE date(payment_date) BETWEEN '$startDate' AND '$endDate'";
else if ($feestype != '' && $startDate != '')
$where = "WHERE payment_for LIKE '%$feestype%' AND date(payment_date) = '$startDate'";
else if ($feestype != '' && $startDate != '' && $endDate != '')
$where = "WHERE payment_for LIKE '%$feestype%' AND Date(payment_date) BETWEEN '$startDate' AND '$endDate'";
$Sqlquery = "SELECT * FROM `student_fee_online_transactions` $where ORDER BY id DESC";
$fees_transactins = $this->Admin_model->get_query_result($Sqlquery);
foreach ($fees_transactins as $ft_value) {
$studentId = (isset($ft_value['studentId']) && !empty($ft_value['studentId'])) ? $ft_value['studentId'] : 0;
if ($courseId != 0) {
$student_where = array('applicationid' => $studentId, 'course' => $courseId);
} else {
$student_where = array('applicationid' => $studentId);
}
$student = $this->db->get_where('applications', $student_where)->row_array();
$studentDetails = (isset($student) && !empty($student)) ? $student : 0;
if ($studentDetails == 0) {
if ($courseId != 0) {
$Studentwhere = array('studentId' => trim($studentId), 'course' => $courseId);
} else {
$Studentwhere = array('studentId' => $studentId);
}
$studentDetails = $this->db->get_where('students', $Studentwhere)->row_array();
}
if ($studentDetails != '') {
$student_data = array(
'studentId' => $studentId,
'stud_id' => $studentId,
'name' => $studentDetails['name'],
'course' => $studentDetails['course'],
'payment_for' => $ft_value['payment_for'],
'payment_amt' => $ft_value['payment_amt'],
'txn_id' => $ft_value['txn_id'],
'invoice_no' => $ft_value['invoice_no'],
'payment_date' => $ft_value['payment_date'],
'status' => $ft_value['status'],
'deduction_type' => $ft_value['deduction_type'],
'deduction_amount' => $ft_value['deduction_amount'],
'fine_amount' => $ft_value['fine_amount'],
'course_fee_id' => (isset($ft_value['course_fee_id']) && ($ft_value['course_fee_id'] != 0)) ? $ft_value['course_fee_id'] : 0
);
$studentInfo[] = $student_data;
}
}
$data['search_course_id'] = $courseId;
$data['search_feetype'] = $feestype;
$data['search_start_paid_date'] = $startDate;
$data['search_end_paid_date'] = $endDate;
} else {
$Sqlquery = "SELECT * FROM `student_fee_online_transactions` ORDER BY id DESC LIMIT 100";
$fees_transactins = $this->Admin_model->get_query_result($Sqlquery);
foreach ($fees_transactins as $ft_value) {
$studentId = $ft_value['studentId'];
$student = $this->db->get_where('applications', array('applicationid' => $studentId))->row_array();
$studentDetails = (isset($student) && !empty($student)) ? $student : 0;
if ($studentDetails == 0) {
$studentDetails = $this->db->get_where('students', array('studentId' => $studentId))->row_array();
}
if ($studentDetails != '') {
$student_data = array(
'studentId' => $studentId,
'stud_id' => $studentDetails['id'],
'name' => $studentDetails['name'],
'course' => $studentDetails['course'],
'payment_for' => $ft_value['payment_for'],
'payment_amt' => $ft_value['payment_amt'],
'txn_id' => $ft_value['txn_id'],
'invoice_no' => $ft_value['invoice_no'],
'payment_date' => $ft_value['payment_date'],
'status' => $ft_value['status'],
'deduction_type' => $ft_value['deduction_type'],
'deduction_amount' => $ft_value['deduction_amount'],
'fine_amount' => $ft_value['fine_amount'],
'course_fee_id' => (isset($ft_value['course_fee_id']) && ($ft_value['course_fee_id'] != 0)) ? $ft_value['course_fee_id'] : 0
);
$studentInfo[] = $student_data;
}
}
}
$data['student_fees'] = $studentInfo;
// $data['current_report_data'] = $fee_type_data;
$data['course_list'] = $this->db->query("select * from course WHERE is_active='yes'")->result_array();
$data['feetype_list'] = $this->db->query("select * from fee_types WHERE is_active='yes'")->result_array();
$this->load->view('admin/header', $data);
$this->load->view('admin/report_recent_transactions', $data);
$this->load->view('admin/footer');
}
function report_overview()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/report_overview.php'))
show_404();
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$fee_type_data = array();
$start_date = date('Y-m-01', strtotime($this->nepali_current_date));
$current_date = date('Y-m-t', strtotime($this->nepali_current_date));
$sqlQuery1 = "SELECT id as feetype_id,feetype_name,icon FROM fee_types WHERE is_active='yes'";
$feetypelist = $this->Admin_model->get_query_result($sqlQuery1);
if (isset($feetypelist) && !empty($feetypelist)) {
foreach ($feetypelist as $ftype) {
if ($ftype['feetype_id'] == 1) {
$appication_totalamt = $this->Admin_model->get_currentmonthfee($start_date, $current_date, $ftype['feetype_name'], 'student_fee_online_transactions');
$fee_type_data[] = array(
'feetype_id' => $ftype['feetype_id'],
'feetype_name' => $ftype['feetype_name'],
'feetype_icon' => $ftype['icon'],
'feetype_total' => 0,
'feetype_due_amt' => 0,
'feetype_paid_amount' => (isset($appication_totalamt) && !empty($appication_totalamt)) ? $appication_totalamt : 0
);
} else {
$result = $this->Admin_model->currentMonth_fee($start_date, $current_date, $ftype['feetype_id']);
$fee_type_data[] = array(
'feetype_id' => $ftype['feetype_id'],
'feetype_name' => $ftype['feetype_name'],
'feetype_icon' => $ftype['icon'],
'feetype_total' => (isset($result['total_course_fee']) && !empty($result['total_course_fee'])) ? $result['total_course_fee'] : 0,
'feetype_due_amt' => (isset($result['pending_fee']) && !empty($result['pending_fee'])) ? $result['pending_fee'] : 0,
'feetype_paid_amount' => (isset($result['paid_amount']) && !empty($result['paid_amount'])) ? $result['paid_amount'] : 0
);
}
}
}
$data['current_report_data'] = $fee_type_data;
// $data['course_list'] = $this->db->query("select * from course WHERE is_active='yes'")->result_array();
// $data['feetype_list'] = $this->db->query("select * from fee_types WHERE is_active='yes'")->result_array();
$this->load->view('admin/header', $data);
$this->load->view('admin/report_overview', $data);
$this->load->view('admin/footer');
}
// get report by by date
public function getreportBydate()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/annual_report.php'))
show_404();
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$batches = $this->Admin_model->get_table_info('batch', array('is_active' => 'yes'));
$data['batches'] = $batches;
$courses = $this->Admin_model->get_table_info('course', '', '', 'ASC');
$data['course'] = $courses;
$fees_types_list = $this->Admin_model->get_fees_type();
$feeTypeWhere = " WHERE id > 0 ";
if (isset($_POST['filtersubmit']) && ($_POST['filtersubmit'] == 'Filter')) {
$f_batch = (isset($_POST['f_batch']) && !empty($_POST['f_batch'])) ? $_POST['f_batch'] : '';
$f_feetype = (isset($_POST['f_feetype']) && !empty($_POST['f_feetype'])) ? $_POST['f_feetype'] : '';
$f_course = (isset($_POST['f_course']) && !empty($_POST['f_course'])) ? $_POST['f_course'] : '';
$f_section = (isset($_POST['f_section']) && !empty($_POST['f_section'])) ? $_POST['f_section'] : '';
$startDate = (isset($_POST['f_start_paid_date']) && !empty($_POST['f_start_paid_date'])) ? $_POST['f_start_paid_date'] : ''; //date('Y-m-01', strtotime($this->nepali_current_date))
$endDate = (isset($_POST['f_end_paid_date']) && !empty($_POST['f_end_paid_date'])) ? $_POST['f_end_paid_date'] : ''; //date('Y-m-t', strtotime($this->nepali_current_date))
$condtion = '';
$q = '';
$result = array();
$arr_sections = '';
$arr_feetype = '';
$studentlist = array();
if ($f_course != '') {
$sql = "SELECT s.id as section_id,s.section_name FROM course_sections cs JOIN section s ON s.id=cs.section_id WHERE cs.course_id='$f_course' ORDER BY s.id DESC";
$section_list = $this->Admin_model->get_query_result($sql);
$data['sections'] = $section_list;
$condtion .= " AND cf.course_id='$f_course'";
$q .= " AND s.course=$f_course";
}
if ($f_section != '') {
$arr_sections = implode(',', $f_section);
$q .= " AND cl.section_id in ($arr_sections)";
}
if ($f_feetype != '') {
$arr_feetype = implode(',', $f_feetype);
$condtion .= " AND cf.fees_type in ($arr_feetype)";
$feeTypeWhere .= " AND id IN (" . $arr_feetype . ")";
}
$feeTypeQuery = "SELECT id,feetype_name FROM fee_types " . $feeTypeWhere . " AND is_active = 'yes' ORDER BY feetype_name";
$selectedFeeTypeList = $this->Admin_model->get_query_result($feeTypeQuery);
// dd($selectedFeeTypeList);
$reqFTarr = array();
$theReqFTidsHere = $this->Admin_model->get_query_row("SELECT GROUP_CONCAT(id SEPARATOR ',') AS r_f_t_ids FROM fee_types WHERE is_active = 'yes'");
if ($arr_feetype != '')
$theReqFTidsHere = $this->Admin_model->get_query_row("SELECT GROUP_CONCAT(id SEPARATOR ',') AS r_f_t_ids FROM fee_types WHERE id IN (" . $arr_feetype . ") AND is_active = 'yes'");
// dd($theReqFTidsHere);
if ($theReqFTidsHere['r_f_t_ids'] != '')
$reqFTarr = explode(',', $theReqFTidsHere['r_f_t_ids']);
// echo '<pre>'; print_r($reqFTarr)."top";
// dd($reqFTarr);
if ($f_batch != '') {
$sql2 = "SELECT s.id as student_id,s.studentId,s.name,s.course,s.batch_id,cl.section_id,sb.roll_no,c.course_name,se.section_name,
GROUP_CONCAT(fas.course_fee_id SEPARATOR ',') AS c_f_ids
FROM students s
JOIN student_batch sb ON sb.student_id=s.id AND sb.batch_id=$f_batch
JOIN classroom cl ON cl.id = sb.classroom_id AND s.course=cl.course_id
JOIN section se ON cl.section_id=se.id
JOIN course c ON c.id=cl.course_id
JOIN fee_assigned_students fas ON fas.student_id=s.id
JOIN course_fees cf ON cf.id=fas.course_fee_id
WHERE sb.batch_id= $f_batch AND cf.batch_id=$f_batch $q GROUP By s.id ORDER BY sb.roll_no ASC";
$studentlist = $this->Admin_model->get_query_result($sql2);
// echo $sql2;
$sopq = '';
if ($startDate != '' && $endDate != '')
$sopq .= " AND DATE(sop.modified) BETWEEN '$startDate' AND '$endDate'";
else if ($startDate != '')
$sopq .= " AND DATE(sop.modified) >= '$startDate' ";
else if ($endDate != '')
$sopq .= " AND DATE(sop.modified) <= '$endDate' ";
// print_r($sopq);
if (!empty($studentlist)) {
$theSno = 0;
foreach ($studentlist as $std_key => $std_val) {
$paidAmountArray = array();
$pendingAmountArray = array();
$deductedAmountArray = array();
$fineAmountArray = array();
$feeAmountArray = array();
$feeTypeArray = array();
$assignedFeesArray = explode(',', $std_val['c_f_ids']);
foreach ($assignedFeesArray as $assignedFee_key => $assignedFeesVal) {
$sopQuery = "SELECT sop.id, sop.student_id, sop.course_fee_id,sop.fee_completed, sop.paid_amount, sop.pending_amount, sop.deducted_amount, sop.fine_amount
FROM students_online_payments sop WHERE sop.student_id =" . $std_val['student_id'] . " AND sop.course_fee_id = $assignedFeesVal $sopq";
$assignedFeeDetails = $this->Admin_model->get_query_row($sopQuery);
$cfDetQuery = "SELECT cf.id AS cfid, cf.fees_type, ft.id, ft.feetype_name,cf.amount,cf.fee_values FROM course_fees AS cf, fee_types AS ft WHERE cf.id=" . $assignedFeesVal;
// echo '<pre>';
// print_r($sopQuery);
$courseFee = $this->Admin_model->get_query_row($cfDetQuery);
// echo '================================> ' . $assignedFeesVal;
// print_r($courseFee);
// if ($std_key == 21) {
// echo '<pre>';
// print_r($assignedFeeDetails);
// }
if (!empty($courseFee)) {
if (empty($assignedFeeDetails)) {
$scholarshipDetailQuery = "SELECT * from student_scholarship WHERE student_id = " . $std_val['student_id'] . " AND course_fee_id = $assignedFeesVal";
$scholarshipDetail = $this->Admin_model->get_query_row($scholarshipDetailQuery);
// print_r($assignedFeeDetails);
if (!empty($scholarshipDetail)) {
// array_push($paidAmountArray, 0);
array_push($pendingAmountArray, $courseFee['amount'] - $scholarshipDetail['scholarship_amount']);
array_push($feeAmountArray, $courseFee['amount'] - $scholarshipDetail['scholarship_amount']);
} else {
array_push($feeAmountArray, $courseFee['amount']);
array_push($pendingAmountArray, $courseFee['amount']);
}
array_push($paidAmountArray, 0);
array_push($deductedAmountArray, 0);
array_push($fineAmountArray, 0);
} else {
if ($assignedFeeDetails['fee_completed'] == 'yes') {
array_push($feeAmountArray, $assignedFeeDetails['paid_amount']);
} else {
array_push($feeAmountArray, $assignedFeeDetails['paid_amount'] + $assignedFeeDetails['pending_amount']);
}
// array_push($feeAmountArray, $courseFee['amount']);
array_push($paidAmountArray, $assignedFeeDetails['paid_amount']);
array_push($pendingAmountArray, $assignedFeeDetails['pending_amount']);
array_push($deductedAmountArray, $assignedFeeDetails['deducted_amount']);
array_push($fineAmountArray, $assignedFeeDetails['fine_amount']);
//
}
array_push($feeTypeArray, $courseFee['fees_type']);
} else {
array_push($feeAmountArray, 0);
array_push($paidAmountArray, 0);
array_push($pendingAmountArray, 0);
array_push($deductedAmountArray, 0);
array_push($fineAmountArray, 0);
array_push($feeTypeArray, 0);
}
}
// echo '<pre>';
// print_r($feeTypeArray);
$studentlist[$std_key]['fee_amt'] = implode(',', $feeAmountArray);
$studentlist[$std_key]['paid_amt'] = implode(',', $paidAmountArray);
$studentlist[$std_key]['pending_amt'] = implode(',', $pendingAmountArray);
$studentlist[$std_key]['deducted_amt'] = implode(',', $deductedAmountArray);
$studentlist[$std_key]['fine_amt'] = implode(',', $fineAmountArray);
$studentlist[$std_key]['fee_type'] = implode(',', $feeTypeArray);
$studentlist[$std_key]['c_fee_amt'] = count($feeAmountArray);
$studentlist[$std_key]['c_paid_amt'] = count($paidAmountArray);
$studentlist[$std_key]['c_pending_amt'] = count($pendingAmountArray);
$studentlist[$std_key]['c_deducted_amt'] = count($deductedAmountArray);
$studentlist[$std_key]['c_fine_amt'] = count($fineAmountArray);
$studentlist[$std_key]['c_fee_type'] = count($feeTypeArray);
$studentlist[$std_key]['reqFTarr'] = $theReqFTidsHere['r_f_t_ids'];
}
foreach ($studentlist as $s_key => $s_val) {
$studentlist[$s_key]['sno'] = ++$theSno;
$sub_arr = array();
$c_f_ids_arr = explode(',', $s_val['c_f_ids']);
$paid_amt_arr = explode(',', $s_val['paid_amt']);
$pending_amt_arr = explode(',', $s_val['pending_amt']);
$diduction_amt_arr = explode(',', $s_val['deducted_amt']);
$fine_amt_arr = explode(',', $s_val['fine_amt']);
$fee_amt_arr = explode(',', $s_val['fee_amt']);
$fee_type_arr = explode(',', $s_val['fee_type']);
foreach ($selectedFeeTypeList as $ftkey => $ftval) {
if (in_array($ftval['id'], $fee_type_arr)) {
$total_fee_amount = 0;
$total_paid_amt = 0;
$total_pending_amt = 0;
$total_diduction_amt = 0;
$total_fine_amt = 0;
$total_amt_array = array();
foreach ($fee_type_arr as $ft_key => $ft_value) {
if ($ft_value == $ftval['id']) {
$total_fee_amount = $total_fee_amount + $fee_amt_arr[$ft_key];
array_push($total_amt_array, $fee_amt_arr[$ft_key]);
$total_paid_amt = $total_paid_amt + $paid_amt_arr[$ft_key];
$total_pending_amt = $total_pending_amt + $pending_amt_arr[$ft_key];
$total_diduction_amt = $total_diduction_amt + $diduction_amt_arr[$ft_key];
$total_fine_amt = $total_fine_amt + $fine_amt_arr[$ft_key];
}
}
$studentlist[$s_key][$ftval['feetype_name']]['total_amt'] = $total_fee_amount;
$studentlist[$s_key][$ftval['feetype_name']]['total_amt_array'] = $total_amt_array;
$studentlist[$s_key][$ftval['feetype_name']]['paid_amt'] = $total_paid_amt;
$studentlist[$s_key][$ftval['feetype_name']]['pending_amt'] = $total_pending_amt;
$studentlist[$s_key][$ftval['feetype_name']]['diduction_amt'] = $total_diduction_amt;
$studentlist[$s_key][$ftval['feetype_name']]['fine_amt'] = $total_fine_amt;
} else {
$studentlist[$s_key][$ftval['feetype_name']]['total_amt'] = 0;
$studentlist[$s_key][$ftval['feetype_name']]['paid_amt'] = 0;
$studentlist[$s_key][$ftval['feetype_name']]['pending_amt'] = 0;
$studentlist[$s_key][$ftval['feetype_name']]['diduction_amt'] = 0;
$studentlist[$s_key][$ftval['feetype_name']]['fine_amt'] = 0;
}
}
}
}
// dd($studentlist);
}
$data['search_batch'] = $f_batch;
$data['search_course_id'] = $f_course;
$data['search_section'] = $f_section;
$data['search_feetype'] = $f_feetype;
$data['selected_fee_types'] = $selectedFeeTypeList;
$data['search_start_paid_date'] = $startDate;
$data['search_end_paid_date'] = $endDate;
$data['studentlist'] = $studentlist;
}
$data['fees_types'] = $fees_types_list;
$data['today_date'] = $this->nepali_current_date;
$this->load->view('admin/header', $data);
$this->load->view('admin/annual_report', $data);
$this->load->view('admin/footer');
}
public function getAnnualReportDetails()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/annual_report_details.php'))
show_404();
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$batches = $this->Admin_model->get_table_info('batch', array('is_active' => 'yes'));
$data['batches'] = $batches;
$courses = $this->Admin_model->get_table_info('course', '', '', 'ASC');
$data['course'] = $courses;
$fees_types_list = $this->Admin_model->get_fees_type();
$feeTypeWhere = " WHERE id > 0 ";
if (isset($_POST['filtersubmit']) && ($_POST['filtersubmit'] == 'Filter')) {
$f_batch = (isset($_POST['f_batch']) && !empty($_POST['f_batch'])) ? $_POST['f_batch'] : '';
$f_feetype = (isset($_POST['f_feetype']) && !empty($_POST['f_feetype'])) ? $_POST['f_feetype'] : '';
$f_course = (isset($_POST['f_course']) && !empty($_POST['f_course'])) ? $_POST['f_course'] : '';
$f_section = (isset($_POST['f_section']) && !empty($_POST['f_section'])) ? $_POST['f_section'] : '';
$startDate = (isset($_POST['f_start_paid_date']) && !empty($_POST['f_start_paid_date'])) ? $_POST['f_start_paid_date'] : ''; //date('Y-m-01', strtotime($this->nepali_current_date))
$endDate = (isset($_POST['f_end_paid_date']) && !empty($_POST['f_end_paid_date'])) ? $_POST['f_end_paid_date'] : ''; //date('Y-m-t', strtotime($this->nepali_current_date))
$condtion = '';
$q = '';
$result = array();
$arr_sections = '';
$arr_feetype = '';
$studentlist = array();
if ($f_course != '') {
$sql = "SELECT s.id as section_id,s.section_name FROM course_sections cs JOIN section s ON s.id=cs.section_id WHERE cs.course_id='$f_course' ORDER BY s.id DESC";
$section_list = $this->Admin_model->get_query_result($sql);
$data['sections'] = $section_list;
$condtion .= " AND cf.course_id='$f_course'";
$q .= " AND s.course=$f_course";
}
if ($f_section != '') {
$arr_sections = implode(',', $f_section);
$q .= " AND cl.section_id in ($arr_sections)";
}
$sopq = '';
if ($startDate != '' && $endDate != '')
$sopq .= " AND DATE(sop.modified) BETWEEN '$startDate' AND '$endDate'";
else if ($startDate != '')
$sopq .= " AND DATE(sop.modified) >= '$startDate' ";
else if ($endDate != '')
$sopq .= " AND DATE(sop.modified) <= '$endDate' ";
// if ($f_feetype != '') {
// // $arr_feetype = implode(',', $f_feetype);
// $condtion .= " AND cf.fees_type = $f_feetype";
// $feeTypeWhere .= " AND id = $f_feetype";
// }
if ($f_feetype != '') {
$arr_feetype = implode(',', $f_feetype);
$condtion .= " AND cf.fees_type in ($arr_feetype)";
$feeTypeWhere .= " AND id IN (" . $arr_feetype . ")";
}
$feeTypeQuery = "SELECT id,feetype_name FROM fee_types" . $feeTypeWhere;
$selectedFeeTypeList = $this->Admin_model->get_query_result($feeTypeQuery);
$reqFTarr = array();
$theReqFTidsHere = $this->Admin_model->get_query_row("SELECT GROUP_CONCAT(id SEPARATOR ',') AS r_f_t_ids FROM fee_types ");
if ($arr_feetype != '')
$theReqFTidsHere = $this->Admin_model->get_query_row("SELECT GROUP_CONCAT(id SEPARATOR ',') AS r_f_t_ids FROM fee_types WHERE id IN (" . $arr_feetype . ")");
if ($theReqFTidsHere['r_f_t_ids'] != '')
$reqFTarr = explode(',', $theReqFTidsHere['r_f_t_ids']);
if ($f_batch != '') {
$feeListsQuery = "SELECT id, batch_id, course_id, fees_type, fee_values, amount, fees_name, created FROM course_fees WHERE batch_id = $f_batch AND course_id = $f_course AND fees_type IN (" . $arr_feetype . ")";
$selectedFeeList = $this->Admin_model->get_query_result($feeListsQuery);
$sql2 = "SELECT s.id as student_id,s.studentId,s.name,s.course,s.batch_id,cl.section_id,sb.roll_no,c.course_name,se.section_name,
GROUP_CONCAT(fas.course_fee_id SEPARATOR ',') AS c_f_ids
FROM students s
JOIN student_batch sb ON sb.student_id=s.id AND s.batch_id=sb.batch_id
JOIN classroom cl ON cl.id = sb.classroom_id AND s.course=cl.course_id
JOIN section se ON cl.section_id=se.id
JOIN course c ON c.id=cl.course_id
JOIN fee_assigned_students fas ON fas.student_id=s.id
WHERE s.batch_id= $f_batch $q GROUP By s.id ORDER BY se.section_name, sb.roll_no ASC";
// $sql2 = "SELECT s.id as student_id,s.studentId,s.name,s.course,s.batch_id,cl.section_id,sb.roll_no,c.course_name,se.section_name ,
// GROUP_CONCAT(sop.course_fee_id SEPARATOR ',') AS c_f_ids,
// GROUP_CONCAT(sop.paid_amount SEPARATOR ',') AS paid_amt ,
// GROUP_CONCAT(sop.pending_amount SEPARATOR ',') AS pending_amt,
// GROUP_CONCAT(sop.deducted_amount SEPARATOR ',') AS deducted_amt,
// GROUP_CONCAT(sop.fine_amount SEPARATOR ',') AS fine_amt
// FROM students s
// JOIN student_batch sb ON sb.student_id=s.id AND s.batch_id=sb.batch_id
// JOIN classroom cl ON cl.id = sb.classroom_id AND s.course=cl.course_id
// JOIN section se ON cl.section_id=se.id
// JOIN course c ON c.id=cl.course_id
// JOIN students_online_payments sop ON sop.student_id=s.id
// WHERE s.batch_id= $f_batch $q GROUP By s.id ORDER BY student_id ASC";
$studentlist = $this->Admin_model->get_query_result($sql2);
if (!empty($studentlist)) {
$theSno = 0;
foreach ($studentlist as $std_key => $std_val) {
$paidAmountArray = array();
$pendingAmountArray = array();
$deductedAmountArray = array();
$fineAmountArray = array();
$feeAmountArray = array();
$feeTypeArray = array();
$assignedFeesArray = explode(',', $std_val['c_f_ids']);
foreach ($assignedFeesArray as $assignedFee_key => $assignedFeesVal) {
$sopQuery = "SELECT sop.id, sop.student_id, sop.course_fee_id,sop.fee_completed, sop.paid_amount, sop.pending_amount, sop.deducted_amount, sop.fine_amount
FROM students_online_payments sop WHERE sop.student_id =" . $std_val['student_id'] . " AND sop.course_fee_id = $assignedFeesVal $sopq";
$assignedFeeDetails = $this->Admin_model->get_query_row($sopQuery);
$cfDetQuery = "SELECT cf.id AS cfid, cf.fees_type, ft.id, ft.feetype_name,cf.amount,cf.fee_values FROM course_fees AS cf, fee_types AS ft WHERE cf.id=" . $assignedFeesVal;
// echo '<pre>';
// print_r($sopQuery);
$courseFee = $this->Admin_model->get_query_row($cfDetQuery);
// if ($std_key == 21) {
// echo '<pre>';
// print_r($assignedFeeDetails);
// }
if (!empty($courseFee)) {
if (empty($assignedFeeDetails)) {
$scholarshipDetailQuery = "SELECT * from student_scholarship WHERE student_id = " . $std_val['student_id'] . " AND course_fee_id = $assignedFeesVal";
$scholarshipDetail = $this->Admin_model->get_query_row($scholarshipDetailQuery);
// print_r($assignedFeeDetails);
if (!empty($scholarshipDetail)) {
// array_push($paidAmountArray, 0);
array_push($pendingAmountArray, $courseFee['amount'] - $scholarshipDetail['scholarship_amount']);
array_push($feeAmountArray, $courseFee['amount'] - $scholarshipDetail['scholarship_amount']);
} else {
array_push($feeAmountArray, $courseFee['amount']);
array_push($pendingAmountArray, $courseFee['amount']);
}
array_push($paidAmountArray, 0);
array_push($deductedAmountArray, 0);
array_push($fineAmountArray, 0);
} else {
if ($assignedFeeDetails['fee_completed'] == 'yes') {
array_push($feeAmountArray, $assignedFeeDetails['paid_amount']);
} else {
array_push($feeAmountArray, $assignedFeeDetails['paid_amount'] + $assignedFeeDetails['pending_amount']);
}
// array_push($feeAmountArray, $courseFee['amount']);
array_push($paidAmountArray, $assignedFeeDetails['paid_amount']);
array_push($pendingAmountArray, $assignedFeeDetails['pending_amount']);
array_push($deductedAmountArray, $assignedFeeDetails['deducted_amount']);
array_push($fineAmountArray, $assignedFeeDetails['fine_amount']);
//
}
array_push($feeTypeArray, $courseFee['fees_type']);
} else {
array_push($feeAmountArray, 0);
array_push($paidAmountArray, 0);
array_push($pendingAmountArray, 0);
array_push($deductedAmountArray, 0);
array_push($fineAmountArray, 0);
array_push($feeTypeArray, 0);
}
}
// echo '<pre>';
// print_r($feeTypeArray);
$studentlist[$std_key]['fee_amt'] = implode(',', $feeAmountArray);
$studentlist[$std_key]['paid_amt'] = implode(',', $paidAmountArray);
$studentlist[$std_key]['pending_amt'] = implode(',', $pendingAmountArray);
$studentlist[$std_key]['deducted_amt'] = implode(',', $deductedAmountArray);
$studentlist[$std_key]['fine_amt'] = implode(',', $fineAmountArray);
$studentlist[$std_key]['fee_type'] = implode(',', $feeTypeArray);
$studentlist[$std_key]['c_fee_amt'] = count($feeAmountArray);
$studentlist[$std_key]['c_paid_amt'] = count($paidAmountArray);
$studentlist[$std_key]['c_pending_amt'] = count($pendingAmountArray);
$studentlist[$std_key]['c_deducted_amt'] = count($deductedAmountArray);
$studentlist[$std_key]['c_fine_amt'] = count($fineAmountArray);
$studentlist[$std_key]['c_fee_type'] = count($feeTypeArray);
$studentlist[$std_key]['reqFTarr'] = $theReqFTidsHere['r_f_t_ids'];
foreach ($selectedFeeList as $sf_key => $sf_val) {
$feeDetailQuery = "SELECT sop.id, sop.student_id, sop.course_fee_id, sop.paid_amount, sop.fine_amount, sop.deducted_amount, sop.pending_amount, sop.fee_completed, cf.amount, cf.fee_values, cf.amount
FROM students_online_payments sop JOIN course_fees cf ON sop.course_fee_id=cf.id WHERE sop.student_id=" . $std_val['student_id'] . " AND sop.course_fee_id =" . $sf_val['id'];
$feeDetail = $this->db->query($feeDetailQuery)->row_array();
if (!empty($feeDetail)) {
$studentlist[$std_key]['fees'][$sf_val['id']] = $feeDetail;
$scholarshipDetailQuery = "SELECT * from student_scholarship WHERE student_id = " . $std_val['student_id'] . " AND course_fee_id = " . $feeDetail['course_fee_id'];
$scholarshipDetail = $this->Admin_model->get_query_row($scholarshipDetailQuery);
// if ($std_key == 16) {
// print_r($scholarshipDetail);
// }
if (!empty($scholarshipDetail)) {
$studentlist[$std_key]['fees'][$sf_val['id']]['amount'] = $studentlist[$std_key]['fees'][$sf_val['id']]['amount'] - $scholarshipDetail['scholarship_amount'];
}
} else {
$stdAssignedFeelQuery = "SELECT fas.id, fas.course_fee_id
FROM fee_assigned_students fas WHERE fas.student_id=" . $std_val['student_id'] . " AND fas.course_fee_id =" . $sf_val['id'];
$stdAssignedFee =
$this->db->query($stdAssignedFeelQuery)->row_array();
// var_dump($stdAssignedFee);
if (!empty($stdAssignedFee)) {
$cfDetQuery = "SELECT cf.id AS cfid, cf.fees_type, ft.id, ft.feetype_name,cf.amount,cf.fee_values
FROM course_fees AS cf, fee_types AS ft WHERE cf.id=" . $stdAssignedFee['course_fee_id'];
$courseFee = $this->Admin_model->get_query_row($cfDetQuery);
// echo $courseFee['cfid'];
$scholarshipDetailQuery = "SELECT * from student_scholarship WHERE student_id = " . $std_val['student_id'] . " AND course_fee_id = " . $courseFee['cfid'];
$scholarshipDetail = $this->Admin_model->get_query_row($scholarshipDetailQuery);
// if ($std_key == 16) {
// echo '<pre> ----------------------------------------------------------->';
// print_r($scholarshipDetailQuery);
// }
$feeAmount = $courseFee['amount'];
$pendingAmount = $courseFee['amount'];
if (!empty($scholarshipDetail)) {
$feeAmount = $courseFee['amount'] - $scholarshipDetail['scholarship_amount'];
$pendingAmount = $courseFee['amount'] - $scholarshipDetail['scholarship_amount'];
}
$studentlist[$std_key]['fees'][$sf_val['id']]['id'] = 0;
$studentlist[$std_key]['fees'][$sf_val['id']]['student_id'] = $std_val['student_id'];
$studentlist[$std_key]['fees'][$sf_val['id']]['course_fee_id'] = $stdAssignedFee['course_fee_id'];
$studentlist[$std_key]['fees'][$sf_val['id']]['paid_amount'] = 0;
$studentlist[$std_key]['fees'][$sf_val['id']]['fine_amount'] = 0;
$studentlist[$std_key]['fees'][$sf_val['id']]['deducted_amount'] = 0;
$studentlist[$std_key]['fees'][$sf_val['id']]['pending_amount'] = $pendingAmount;
$studentlist[$std_key]['fees'][$sf_val['id']]['amount'] = $feeAmount;
$studentlist[$std_key]['fees'][$sf_val['id']]['fee_completed'] = 'no';
$studentlist[$std_key]['fees'][$sf_val['id']]['fee_values'] = $courseFee['fee_values'];
} else {
$studentlist[$std_key]['fees'][$sf_val['id']] = null;
}
}
}
}
}
}
// dd($studentlist);
$data['search_batch'] = $f_batch;
$data['search_course_id'] = $f_course;
$data['search_section'] = $f_section;
$data['search_feetype'] = $f_feetype;
$data['selected_fee_types'] = $selectedFeeTypeList;
$data['search_start_paid_date'] = $startDate;
$data['search_end_paid_date'] = $endDate;
$data['selected_fee_list'] = $selectedFeeList;
$data['studentlist'] = $studentlist;
}
$data['report_date'] = date('Y-m-d', strtotime($this->nepali_current_date));
$data['fees_types'] = $fees_types_list;
$data['today_date'] = $this->nepali_current_date;
$this->load->view('admin/header', $data);
$this->load->view('admin/annual_report_details', $data);
$this->load->view('admin/footer');
}
public function invoice_reports()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/invoice-reports.php'))
show_404();
$theResults = array();
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$feeTypeWhere = " WHERE id > 0 ";
$theMainWhere = " WHERE cr.course_id = s.course ";
if (count($_POST) > 0) {
//echo '<pre>'; print_r($_POST);
if (isset($_POST['filter_fee_types']) && !empty($_POST['filter_fee_types']))
$feeTypeWhere .= " AND id IN(" . implode(",", $_POST['filter_fee_types']) . ")";
if (isset($_POST['select_particular']) && $_POST['select_particular'] == 'today')
$theMainWhere .= " AND DATE(sfop.payment_date) ='" . date('Y-m-d', strtotime($this->nepali_current_date)) . "'";
else if (isset($_POST['select_particular']) && $_POST['select_particular'] == 'select_date_range') {
if (isset($_POST['filter_from_date']) && $_POST['filter_from_date'] != '')
$theMainWhere .= " AND DATE(sfop.payment_date) >='" . $_POST['filter_from_date'] . "'";
if (isset($_POST['filter_to_date']) && $_POST['filter_to_date'] != '')
$theMainWhere .= " AND DATE(sfop.payment_date) <='" . $_POST['filter_to_date'] . "'";
}
}
$feeTypeQuery = "SELECT id,feetype_name FROM fee_types" . $feeTypeWhere . " AND is_active = 'yes' ORDER BY feetype_name ASC";
$selectedFeeTypeList = $this->Admin_model->get_query_result($feeTypeQuery);
$reqFTarr = array();
$theReqFTidsHere = $this->Admin_model->get_query_row("SELECT GROUP_CONCAT(id SEPARATOR ',') AS r_f_t_ids FROM fee_types" . $feeTypeWhere);
if ($theReqFTidsHere['r_f_t_ids'] != '')
$reqFTarr = explode(',', $theReqFTidsHere['r_f_t_ids']);
$theMainSql = "SELECT sfop.id, sfop.studentId, sfop.invoice_no, sfop.payment_date, sfop.deduction_amount,
GROUP_CONCAT(sfop.course_fee_id SEPARATOR ',') AS c_f_ids,
GROUP_CONCAT(sfop.payment_amt SEPARATOR ',') AS pay_amt,
GROUP_CONCAT(sfop.deduction_amount SEPARATOR ',') AS deduction_amt,
GROUP_CONCAT(sfop.fine_amount SEPARATOR ',') AS fine_amt,
s.id AS std_id, s.name AS std_name, s.course AS std_course, s.batch_id AS std_batch_id,
sb.roll_no, sb.classroom_id,
cr.course_id AS cr_course_id, cr.section_id AS cr_sec_id, cr.classroom_name
FROM student_fee_online_transactions AS sfop
LEFT JOIN students AS s ON s.studentId = sfop.studentId
LEFT JOIN student_batch AS sb ON s.id = sb.student_id AND s.batch_id=sb.batch_id
LEFT JOIN classroom as cr ON sb.classroom_id = cr.id AND s.course=cr.course_id
$theMainWhere
GROUP By sfop.invoice_no
ORDER BY sfop.id ASC";
//echo $theMainWhere.'<br/>'.$theMainSql;exit;
if (!empty($selectedFeeTypeList) && count($_POST) > 0)
$theResults = $this->Admin_model->get_query_result($theMainSql);
if (!empty($theResults)) {
$theSno = 0;
foreach ($theResults as $key => $value) {
$theResults[$key]['sno'] = ++$theSno;
$xxx = array();
$cfAmtArr = explode(',', $value['pay_amt']);
$cfidsArr = explode(',', $value['c_f_ids']);
if (!empty($cfidsArr)) {
foreach ($cfidsArr as $tk => $tv) {
$cfDetQuery = "SELECT cf.id AS cfid, cf.fees_type, ft.id, ft.feetype_name FROM course_fees AS cf, fee_types AS ft WHERE cf.id=" . $tv . " AND cf.fees_type=ft.id";
$cfDetails = $this->Admin_model->get_query_result($cfDetQuery);
if (isset($cfDetails[0]['feetype_name']) && $cfDetails[0]['feetype_name'] != '' && in_array($cfDetails[0]['id'], $reqFTarr)) {
if (!isset($xxx[$key][$cfDetails[0]['feetype_name']]))
$xxx[$key][$cfDetails[0]['feetype_name']] = $cfAmtArr[$tk];
else
$xxx[$key][$cfDetails[0]['feetype_name']] = ($xxx[$key][$cfDetails[0]['feetype_name']] + $cfAmtArr[$tk]);
}
}
}
foreach ($selectedFeeTypeList as $ftkey => $ftval) {
if (!isset($xxx[$key][$ftval['feetype_name']]))
$theResults[$key][$ftval['feetype_name']] = 0;
else
$theResults[$key][$ftval['feetype_name']] = $xxx[$key][$ftval['feetype_name']];
}
}
}
//echo '<pre>';print_r($feeTypeList);
//echo '<pre>';print_r($theResults);
//exit;
//$data['fee_types_list'] = $feeTypeList;
$data['all_fee_types'] = $this->Admin_model->get_query_result("SELECT id,feetype_name FROM fee_types");
$data['selected_fee_types'] = $selectedFeeTypeList;
$data['the_results'] = $theResults;
$this->load->view('admin/header', $data);
$this->load->view('admin/invoice-reports', $data);
$this->load->view('admin/footer');
}
public function invoice_fee_reports()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/invoice-fee-reports.php'))
show_404();
$theResults = array();
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$feeTypeWhere = " WHERE id > 0 ";
$theMainWhere = " WHERE cr.course_id = s.course";
// $theMainWhere = "";
if (count($_POST) > 0) {
//echo '<pre>'; print_r($_POST);
if (isset($_POST['filter_fee_types']) && !empty($_POST['filter_fee_types']))
$feeTypeWhere .= " AND id IN(" . implode(",", $_POST['filter_fee_types']) . ")";
if (isset($_POST['select_particular']) && $_POST['select_particular'] == 'today')
$theMainWhere .= " AND DATE(sfop.payment_date) ='" . date('Y-m-d', strtotime($this->nepali_current_date)) . "'";
else if (isset($_POST['select_particular']) && $_POST['select_particular'] == 'select_date_range') {
if (isset($_POST['filter_from_date']) && $_POST['filter_from_date'] != '')
$theMainWhere .= " AND DATE(sfop.payment_date) >='" . $_POST['filter_from_date'] . "'";
if (isset($_POST['filter_to_date']) && $_POST['filter_to_date'] != '')
$theMainWhere .= " AND DATE(sfop.payment_date) <='" . $_POST['filter_to_date'] . "'";
}
}
$feeTypeQuery = "SELECT id,feetype_name FROM fee_types" . $feeTypeWhere . " AND is_active = 'yes' ORDER BY feetype_name ASC";
$selectedFeeTypeList = $this->Admin_model->get_query_result($feeTypeQuery);
$reqFTarr = array();
$theReqFTidsHere = $this->Admin_model->get_query_row("SELECT GROUP_CONCAT(id SEPARATOR ',') AS r_f_t_ids FROM fee_types" . $feeTypeWhere);
if ($theReqFTidsHere['r_f_t_ids'] != '')
$reqFTarr = explode(',', $theReqFTidsHere['r_f_t_ids']);
$theMainSql = "SELECT sfop.id, sfop.studentId, sfop.invoice_no, sfop.payment_date, sfop.deduction_amount,
GROUP_CONCAT(sfop.course_fee_id SEPARATOR ',') AS c_f_ids,
GROUP_CONCAT(sfop.payment_amt SEPARATOR ',') AS pay_amt,
GROUP_CONCAT(sfop.deduction_amount SEPARATOR ',') AS deduction_amt,
GROUP_CONCAT(sfop.fine_amount SEPARATOR ',') AS fine_amt,
s.id AS std_id, s.name AS std_name, s.course AS std_course, s.batch_id AS std_batch_id,
sb.roll_no, sb.classroom_id,
cr.course_id AS cr_course_id, cr.section_id AS cr_sec_id, cr.classroom_name
FROM student_fee_online_transactions AS sfop
LEFT JOIN students AS s ON s.studentId = sfop.studentId
LEFT JOIN student_batch AS sb ON s.id = sb.student_id AND s.batch_id=sb.batch_id
LEFT JOIN classroom as cr ON sb.classroom_id = cr.id AND s.course=cr.course_id
$theMainWhere
GROUP By sfop.invoice_no
ORDER BY sfop.id ASC";
if (!empty($selectedFeeTypeList) && count($_POST) > 0)
$theResults = $this->Admin_model->get_query_result($theMainSql);
// dd($theResults);
$finalResult = array();
if (!empty($theResults)) {
$theSno = 0;
foreach ($theResults as $key => $value) {
$theResults[$key]['sno'] = ++$theSno;
$selectedFee = array();
$cfAmtArr = explode(',', $value['pay_amt']);
$cfidsArr = explode(',', $value['c_f_ids']);
if (!empty($cfidsArr)) {
foreach ($cfidsArr as $tk => $tv) {
$cfDetQuery = "SELECT cf.id AS cfid, cf.fees_type, ft.id, ft.feetype_name FROM course_fees AS cf, fee_types AS ft WHERE cf.id=" . $tv . " AND cf.fees_type=ft.id";
$cfDetails = $this->Admin_model->get_query_result($cfDetQuery);
if (isset($cfDetails[0]['feetype_name']) && $cfDetails[0]['feetype_name'] != '' && in_array($cfDetails[0]['id'], $reqFTarr)) {
if (!isset($selectedFee[$key][$cfDetails[0]['feetype_name']]))
$selectedFee[$key][$cfDetails[0]['feetype_name']] = $cfAmtArr[$tk];
else
$selectedFee[$key][$cfDetails[0]['feetype_name']] = ($selectedFee[$key][$cfDetails[0]['feetype_name']] + $cfAmtArr[$tk]);
}
}
}
foreach ($selectedFeeTypeList as $ftkey => $ftval) {
if (!isset($selectedFee[$key][$ftval['feetype_name']])) {
$theResults[$key][$ftval['feetype_name']] = 0;
// array_push($finalResult, $theResults[$key]);
} else {
$theResults[$key][$ftval['feetype_name']] = $selectedFee[$key][$ftval['feetype_name']];
// echo $selectedFee[$key][$ftval['feetype_name']] .'=================>'.$ftval['feetype_name'] .'<br>';
// echo '<pre>';
// if(isset)
array_push($finalResult, $theResults[$key]);
// print_r($theResults[$key]);
}
}
}
}
// dd(($theResults));
//echo '<pre>';print_r($feeTypeList);
//echo '<pre>';print_r($theResults);
//exit;
//$data['fee_types_list'] = $feeTypeList;
$data['all_fee_types'] = $this->Admin_model->get_query_result("SELECT id,feetype_name FROM fee_types");
$data['selected_fee_types'] = $selectedFeeTypeList;
$data['the_results'] = $finalResult;
$this->load->view('admin/header', $data);
$this->load->view('admin/invoice-fee-reports', $data);
$this->load->view('admin/footer');
}
public function fee_revert_reports()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/fee-revert-reports.php'))
show_404();
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//echo '<pre>'; print_r($data['school_info']);exit;
$data['menulist'] = $this->Admin_model->get_adminMenu();
$theResults = array();
$feeTypeWhere = " WHERE id > 0 ";
$theMainWhere = " WHERE fr.id > 0 ";
$courseSelected = '';
if (count($_POST) > 0) {
//echo '<pre>'; print_r($_POST);exit;
if (isset($_POST['filter_fee_types']) && !empty($_POST['filter_fee_types']))
$feeTypeWhere .= " AND id IN(" . implode(",", $_POST['filter_fee_types']) . ")";
if (isset($_POST['filter_course']) && !empty($_POST['filter_course']))
$courseSelected .= " AND s.course IN(" . implode(",", $_POST['filter_course']) . ")";
if (isset($_POST['select_particular']) && $_POST['select_particular'] == 'today')
$theMainWhere .= " AND DATE(fr.c_date) ='" . date('Y-m-d', strtotime($this->nepali_current_date)) . "'";
else if (isset($_POST['select_particular']) && $_POST['select_particular'] == 'select_date_range') {
if (isset($_POST['filter_from_date']) && $_POST['filter_from_date'] != '')
$theMainWhere .= " AND DATE(fr.c_date) >='" . $_POST['filter_from_date'] . "'";
if (isset($_POST['filter_to_date']) && $_POST['filter_to_date'] != '')
$theMainWhere .= " AND DATE(fr.c_date) <='" . $_POST['filter_to_date'] . "'";
}
}
$theReqFTidsHere = $this->Admin_model->get_query_row("SELECT GROUP_CONCAT(id SEPARATOR ',') AS r_f_t_ids FROM fee_types" . $feeTypeWhere);
if ($theReqFTidsHere['r_f_t_ids'] != '')
$selectedFeeTypes = $theReqFTidsHere['r_f_t_ids'];
$theMainSql = "SELECT fr.id, fr.studentId, fr.invoice_no, fr.payment_amt, fr.c_date, fr.done_by, fr.course_fee_id,
cf.id AS cf_id, cf.fee_values AS fee_name, cf.fees_type, feet.feetype_name,
s.id AS std_id, s.name AS std_name, s.course AS std_course_id, c.course_name
FROM student_fee_reverts AS fr
JOIN course_fees AS cf ON fr.course_fee_id = cf.id AND cf.fees_type IN($selectedFeeTypes)
JOIN fee_types AS feet on cf.fees_type=feet.id
JOIN students AS s ON fr.studentId=s.studentId $courseSelected
JOIN course AS c ON s.course=c.id
$theMainWhere
ORDER BY fr.c_date DESC";
if (count($_POST) > 0)
$theResults = $this->Admin_model->get_query_result($theMainSql);
$data['course_list'] = $this->db->query("select id,course_name from course WHERE is_active='yes'")->result_array();
$data['all_fee_types'] = $this->Admin_model->get_query_result("SELECT id,feetype_name FROM fee_types");
$data['the_results'] = $theResults;
$this->load->view('admin/header', $data);
$this->load->view('admin/fee-revert-reports', $data);
$this->load->view('admin/footer');
}
public function due_fee_reports()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/due_fee_report.php'))
show_404();
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$startDate = '';
$endDate = '';
$condition = '';
$studentlist = array();
$selectedFeeTypes = array();
$batches = $this->Admin_model->get_table_info('batch', array('is_active' => 'yes'));
$data['batches'] = $batches;
$courses = $this->Admin_model->get_table_info('course', '', '', 'ASC');
$data['course'] = $courses;
$fees_types_list = $this->Admin_model->get_fees_type();
// dd($fees_types_list);
$data['fees_types'] = $fees_types_list;
$ft_where = " ";
if (count($_POST)) {
$se_batch = (isset($_POST['f_batch']) && !empty($_POST['f_batch'])) ? $_POST['f_batch'] : '';
$se_course = (isset($_POST['f_course']) && !empty($_POST['f_course'])) ? $_POST['f_course'] : '';
$se_section = (isset($_POST['f_section']) && !empty($_POST['f_section'])) ? $_POST['f_section'] : '';
$se_payment_status = (isset($_POST['payment_status']) && !empty($_POST['payment_status'])) ? $_POST['payment_status'] : '';
$search_feetypes = (isset($_POST['f_feetype']) && !empty($_POST['f_feetype'])) ? $_POST['f_feetype'] : '';
if ($search_feetypes != '') {
$ft_where = " AND id IN (" . implode(',', $search_feetypes) . ")";
}
$selectedFeeTypes = $this->db->query("SELECT * FROM fee_types WHERE id > 0" . $ft_where)->result_array();
if ($se_course != '')
$condition .= " AND cl.course_id=$se_course";
if ($se_section != '')
$condition .= " AND cl.section_id IN (" . implode(',', $se_section) . ")";
$startDate = (isset($_POST['f_start_paid_date']) && !empty($_POST['f_start_paid_date'])) ? $_POST['f_start_paid_date'] : '';
$endDate = (isset($_POST['f_end_paid_date']) && !empty($_POST['f_end_paid_date'])) ? $_POST['f_end_paid_date'] : '';
$studentlist = $this->db->query("SELECT s.*,c.course_name,se.section_name,sb.roll_no FROM students s JOIN student_batch sb ON s.id=sb.student_id JOIN classroom cl ON cl.id=sb.classroom_id JOIN course c ON c.id=cl.course_id JOIN section se ON se.id=cl.section_id WHERE sb.batch_id=$se_batch $condition")->result_array();
$batch_course_fees = $this->db->query("SELECT GROUP_CONCAT(id) as cf_ids FROM course_fees WHERE batch_id=$se_batch AND course_id=$se_course")->row_array();
if ($batch_course_fees != '')
$condition .= " AND cf.id IN (" . $batch_course_fees['cf_ids'] . ")";
$selected_ft_ids = $this->db->query("SELECT GROUP_CONCAT(id) as selected_ft_ids FROM fee_types WHERE id > 0 " . $ft_where)->row_array();
if ($selected_ft_ids != '')
$condition1 = " AND cf.fees_type IN (" . $selected_ft_ids['selected_ft_ids'] . ")";
// $studentlist=$this->db->query("SELECT s.*,c.course_name,se.section_name, GROUP_CONCAT(cf.id) AS assigned_cf_ids FROM students s JOIN student_batch sb ON s.id=sb.student_id JOIN classroom cl ON cl.id=sb.classroom_id JOIN course c ON c.id=cl.course_id JOIN section se ON se.id=cl.section_id LEFT JOIN fee_assigned_students fas ON fas.student_id=s.id
// JOIN course_fees cf ON cf.id=fas.course_fee_id WHERE sb.batch_id=$se_batch $condition GROUP By s.id")->result_array();
if (count($studentlist) > 0) {
$theSno = 0;
foreach ($studentlist as $skey => $student) {
$studentlist[$skey]['sno'] = ++$theSno;
$sub_arr = array();
$payDetail = $this->Admin_model->getFeesBy_status_feetypes($se_batch, $se_course, $student['id'], $se_payment_status, $selected_ft_ids, $startDate, $endDate);
// echo "<pre>";
// print_r($payDetail);
$selected_ft_ids_arr_values = explode(',', $selected_ft_ids['selected_ft_ids']);
$selected_ft_ids_arr = $this->db->query("SELECT id as ft_id,feetype_name FROM fee_types WHERE id > 0 " . $ft_where)->result_array();
// echo "<pre>";
// print_r($selected_ft_ids_arr_values);
foreach ($payDetail as $pdkey => $fe_value) {
if (in_array($fe_value['fees_type'], $selected_ft_ids_arr_values)) {
if (isset($sub_arr[$skey][$fe_value['fees_type']])) {
$sub_arr[$skey][$fe_value['fees_type']]['total_assigned_amount'] += (int)$fe_value['cf_total_amount'];
$sub_arr[$skey][$fe_value['fees_type']]['total_paid_amount'] += (int)$fe_value['total_paid_amount'];
$sub_arr[$skey][$fe_value['fees_type']]['total_fine_amount'] += (int)$fe_value['total_fine_amount'];
$sub_arr[$skey][$fe_value['fees_type']]['total_diduction_amount'] += (int)$fe_value['total_deduction_amount'];
$sub_arr[$skey][$fe_value['fees_type']]['total_pending_amount'] += (int)$fe_value['total_pending_amount'];
} else {
$sub_arr[$skey][$fe_value['fees_type']]['total_assigned_amount'] = (int)$fe_value['cf_total_amount'];
$sub_arr[$skey][$fe_value['fees_type']]['total_paid_amount'] = (int)$fe_value['total_paid_amount'];
$sub_arr[$skey][$fe_value['fees_type']]['total_fine_amount'] = (int)$fe_value['total_fine_amount'];
$sub_arr[$skey][$fe_value['fees_type']]['total_diduction_amount'] = (int)$fe_value['total_deduction_amount'];
$sub_arr[$skey][$fe_value['fees_type']]['total_pending_amount'] = (int)$fe_value['total_pending_amount'];
}
}
}
foreach ($selected_ft_ids_arr as $ftkey => $ftval) {
if (!isset($sub_arr[$skey][$ftval['ft_id']])) {
$studentlist[$skey][$ftval['ft_id']]['total_assigned_amount'] = 0;
$studentlist[$skey][$ftval['ft_id']]['total_paid_amount'] = 0;
$studentlist[$skey][$ftval['ft_id']]['total_fine_amount'] = 0;
$studentlist[$skey][$ftval['ft_id']]['total_diduction_amount'] = 0;
$studentlist[$skey][$ftval['ft_id']]['total_pending_amount'] = 0;
} else {
$studentlist[$skey][$ftval['ft_id']]['total_assigned_amount'] = $sub_arr[$skey][$ftval['ft_id']]['total_assigned_amount'];
$studentlist[$skey][$ftval['ft_id']]['total_paid_amount'] = $sub_arr[$skey][$ftval['ft_id']]['total_paid_amount'];
$studentlist[$skey][$ftval['ft_id']]['total_fine_amount'] = $sub_arr[$skey][$ftval['ft_id']]['total_fine_amount'];
$studentlist[$skey][$ftval['ft_id']]['total_diduction_amount'] = $sub_arr[$skey][$ftval['ft_id']]['total_diduction_amount'];
$studentlist[$skey][$ftval['ft_id']]['total_pending_amount'] = $sub_arr[$skey][$ftval['ft_id']]['total_pending_amount'];
}
}
}
// dd($studentlist);
// exit;
}
}
$data['selected_feetype'] = $selectedFeeTypes;
$data['search_start_paid_date'] = $startDate;
$data['search_end_paid_date'] = $endDate;
$data['students'] = $studentlist;
$this->load->view('admin/header', $data);
$this->load->view('admin/due_fee_report', $data);
$this->load->view('admin/footer');
}
function total_due_report()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/total_due_report.php'))
show_404();
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$batches = $this->Admin_model->get_table_info('batch', array('is_active' => 'yes'));
$data['batches'] = $batches;
$courses = $this->Admin_model->get_table_info('course', '', '', 'ASC');
$data['course'] = $courses;
$condition = '';
$student_fee = array();
if (isset($_POST['send_alert']) && ($_POST['send_alert'] == 'Send Alert')) {
print_r($_POST);
} else {
if (count($_POST)) {
$se_batch = (isset($_POST['f_batch']) && !empty($_POST['f_batch'])) ? $_POST['f_batch'] : '';
$se_course = (isset($_POST['f_course']) && !empty($_POST['f_course'])) ? $_POST['f_course'] : '';
$se_section = (isset($_POST['f_section']) && !empty($_POST['f_section'])) ? $_POST['f_section'] : '';
if ($se_course != '')
$condition .= " AND cl.course_id=$se_course";
if ($se_section != '')
$condition .= " AND cl.section_id IN (" . implode(',', $se_section) . ")";
$studentlist = $this->db->query("SELECT s.id as student_id,s.name,s.course,s.batch_id,s.email,s.studentId,s.mobile,s.emergency_contact_name,s.emergency_contact_number,c.course_name,se.section_name,sb.roll_no FROM students s JOIN student_batch sb ON s.id=sb.student_id JOIN classroom cl ON cl.id=sb.classroom_id JOIN course c ON c.id=cl.course_id JOIN section se ON se.id=cl.section_id WHERE sb.batch_id=$se_batch $condition ORDER BY se.section_name, sb.roll_no")->result_array();
if (count($studentlist) > 0) {
foreach ($studentlist as $s_key => $student) {
$total_amount = 0;
$total_paid_amount = 0;
$total_pending_amount = 0;
$stud_id = $student['student_id'];
$fee_query = "SELECT cf.id as coursefee_id,cf.fees_type,cf.amount as cf_total_amount,fas.id,ft.feetype_name,ft.id,
IF(sop.id is null,0,sop.id) as sop_id,
IF(sop.paid_amount is null,0,sop.paid_amount) as paid_amount,
IF(sop.fine_amount is null,0,sop.fine_amount) as fine_amount,
IF(sop.deducted_amount is null,0,sop.deducted_amount) as deducted_amount,
IF(sop.pending_amount is null,cf.amount,sop.pending_amount) as pending_amount
FROM course_fees cf
JOIN fee_assigned_students fas ON fas.course_fee_id=cf.id AND fas.student_id=$stud_id
JOIN fee_types ft on ft.id = cf.fees_type
LEFT JOIN students_online_payments sop on cf.id = sop.course_fee_id AND sop.student_id = " . $stud_id . " WHERE batch_id = $se_batch ";
$fees_rst = $this->db->query($fee_query)->result_array();
foreach ($fees_rst as $f_val) {
$scholarshipDetailQuery = "SELECT * from student_scholarship WHERE student_id = " . $student['student_id'] . " AND course_fee_id = " . $f_val['coursefee_id'] . "";
$scholarshipDetail = $this->Admin_model->get_query_row($scholarshipDetailQuery);
$feeAmount = $f_val['cf_total_amount'];
$paidAmount = $f_val['paid_amount'];
$pendingAmount = $f_val['pending_amount'];
if (!empty($scholarshipDetail)) {
$feeAmount = $feeAmount - $scholarshipDetail['scholarship_amount'];
$pendingAmount = $feeAmount - $scholarshipDetail['scholarship_amount'];
} else {
}
$total_amount += $feeAmount;
$total_paid_amount += $paidAmount;
$total_pending_amount += $pendingAmount;
}
$student_fee[] = array(
'student_id' => $student['student_id'],
'student_name' => $student['name'],
'roll_no' => $student['roll_no'],
'studentId' => $student['studentId'],
'course_name' => $student['course_name'],
'section_name' => $student['section_name'],
'emergency_contact_name' => $student['emergency_contact_name'],
'emergency_contact_number' => $student['emergency_contact_number'],
'total_assigned_amount' => $total_amount,
'total_paid_amount' => $total_paid_amount,
'total_pending_amount' => $total_amount - $total_paid_amount
);
}
}
}
$data['student_fees'] = $student_fee;
$data['today_date'] = $this->nepali_current_date;
$this->load->view('admin/header', $data);
$this->load->view('admin/total_due_report', $data);
$this->load->view('admin/footer');
}
}
// Developer: Shivakumar
// Date: 03-06-2022
public function assign_additional_subjects_to_students()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/assign-addi-sub-to-students.php'))
show_404();
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$currentBatch = 0;
if (isset($data['school_info']['batch_id']) && $data['school_info']['batch_id'] != '')
$currentBatch = $data['school_info']['batch_id'];
$theResults = array();
$theOptSubs = array();
if (count($_POST) > 0) {
if ($_POST['clicked_on'] == 'UpdateData') {
if (isset($_POST['student']) && !empty($_POST['student'])) { //echo '<pre>'; print_r($_POST['student']);
foreach ($_POST['student'] as $sid => $sosArr) {
//echo '<pre>'; print_r($sosArr);
$theUpdateData = '';
foreach ($sosArr as $osId => $flag) {
if ($flag == 'yes') {
if ($theUpdateData == '')
$theUpdateData = $osId;
else
$theUpdateData .= ',' . $osId;
}
}
//echo $sid.' == '.$theUpdateData.'<br/>';
$this->db->query("DELETE FROM student_additional_subjects WHERE student_id=" . $sid . " AND course_id=" . $_POST['filter_by_course'] . " AND batch_id=" . $_POST['filter_by_batch']);
if ($theUpdateData != '') {
$udata['batch_id'] = $_POST['filter_by_batch'];
$udata['course_id'] = $_POST['filter_by_course'];
$udata['student_id'] = $sid;
$udata['subjects_list'] = $theUpdateData;
$udata['created_on'] = date('Y-m-d H:i:s', strtotime($this->nepali_current_date));
$udata['created_by'] = $_SESSION['admin_name'];
$this->db->insert('student_additional_subjects', $udata);
}
/*$getPrevRecds = $this->db->query("SELECT id FROM student_additional_subjects WHERE student_id=".$sid." AND course_id=".$_POST['filter_by_course']." AND batch_id=".$_POST['filter_by_batch'])->result_array();
if(!empty($getPrevRecds))
{
if($theUpdateData==''){
$this->db->query("DELETE FROM student_additional_subjects WHERE id=".$getPrevRecds[0]['id']);
}
else
{
$udata['subjects_list'] = $theUpdateData;
$udata['modified_on'] = date('Y-m-d H:i:s',strtotime($this->nepali_current_date));
$udata['modified_by'] = $_SESSION['admin_name'];
$this->db->where(array('id'=>$getPrevRecds[0]['id']));
$this->db->update('student_additional_subjects', $udata);
}
}
else
{
if($theUpdateData!='')
{
$udata['batch_id'] = $_POST['filter_by_batch'];
$udata['course_id'] = $_POST['filter_by_course'];
$udata['student_id'] = $sid;
$udata['subjects_list'] = $theUpdateData;
$udata['created_on'] = date('Y-m-d H:i:s',strtotime($this->nepali_current_date));
$udata['created_by'] = $_SESSION['admin_name'];
$this->db->insert('student_additional_subjects', $udata);
}
}*/
}
//exit;
$this->session->set_flashdata('success', "The details have been updated successfully.");
}
}
$whereCond = " WHERE S.id > 0 AND SB.batch_id=" . $_POST['filter_by_batch'] . " AND CR.course_id=" . $_POST['filter_by_course'];
$orderBy = " ORDER BY S.name ASC ";
if ($currentBatch == $_POST['filter_by_batch'] && isset($_POST['filter_by_section']) && !empty($_POST['filter_by_section']))
$whereCond .= " AND CR.section_id IN(" . implode(",", $_POST['filter_by_section']) . ")";
$theSql = "SELECT S.id,S.name,S.studentId,
SB.roll_no,SB.classroom_id,
CR.course_id,CR.section_id
FROM students AS S
JOIN student_batch AS SB on SB.student_id = S.id
JOIN classroom AS CR ON SB.classroom_id = CR.id " . $whereCond . $orderBy;
$theResults = $this->Admin_model->get_query_result($theSql);
if (!empty($theResults)) {
foreach ($theResults as $key => $sutd) {
$stdOptSubjects = $this->db->query("SELECT subjects_list FROM student_additional_subjects WHERE student_id=" . $sutd['id'] . " AND course_id=" . $_POST['filter_by_course'] . " AND batch_id=" . $_POST['filter_by_batch'])->result_array();
if (!empty($stdOptSubjects)) {
$theResults[$key]['the_add_subjects'] = $stdOptSubjects[0]['subjects_list'];
$getOSdets = $this->db->query("SELECT GROUP_CONCAT(subject_name) AS sub_names_here FROM subject WHERE id IN(" . $stdOptSubjects[0]['subjects_list'] . ")")->result_array();
$theResults[$key]['the_add_subject_details'] = '';
if (isset($getOSdets[0]['sub_names_here']))
$theResults[$key]['the_add_subject_details'] = $theResults[$key]['the_add_subject_details'];
} else {
$theResults[$key]['the_add_subjects'] = '';
$theResults[$key]['the_add_subject_details'] = '';
}
}
}
$courseSubjects = $this->db->query("SELECT GROUP_CONCAT(subject_id) AS c_s_ids FROM course_subjects WHERE course_id=" . $_POST['filter_by_course'])->result_array();
if (isset($courseSubjects[0]['c_s_ids']) && $courseSubjects[0]['c_s_ids'] != '') {
$csIdsArr = explode(',', $courseSubjects[0]['c_s_ids']);
$s = 0;
foreach ($csIdsArr as $key => $subId) {
$subDetails = $this->db->query("SELECT id,subject_name FROM subject WHERE id=$subId AND is_additional='Yes' AND is_active='yes'")->result_array();
if (!empty($subDetails)) {
$theOptSubs[$s]['id'] = $subDetails[0]['id'];
$theOptSubs[$s]['sub_name'] = $subDetails[0]['subject_name'];
$s++;
}
}
}
}
$data['course'] = $this->db->query("select * from course WHERE is_active='yes'")->result_array();
$data['batch'] = $this->Admin_model->get_batches();
$data['currentBatch'] = $currentBatch;
$data['theResults'] = $theResults;
$data['theOptSubs'] = $theOptSubs;
$this->load->view('admin/header', $data);
$this->load->view('admin/assign-addi-sub-to-students', $data);
$this->load->view('admin/footer');
}
public function assign_optional_subjects_to_students()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/assign-opt-sub-to-students.php'))
show_404();
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$currentBatch = 0;
if (isset($data['school_info']['batch_id']) && $data['school_info']['batch_id'] != '')
$currentBatch = $data['school_info']['batch_id'];
$theResults = array();
$theOptSubs = array();
if (count($_POST) > 0) {
if ($_POST['clicked_on'] == 'UpdateData') {
//echo '<pre>'; print_r($_POST);
if (isset($_POST['student']) && !empty($_POST['student'])) {
foreach ($_POST['student'] as $sid => $sosArr) {
$theUpdateData = '';
foreach ($sosArr as $osId => $flag) {
if ($flag == 'yes') {
if ($theUpdateData == '')
$theUpdateData = $osId;
else
$theUpdateData .= ',' . $osId;
}
}
//echo $sid.' == '.$theUpdateData.'<br/>';
$this->db->query("DELETE FROM student_optional_subjects WHERE student_id=" . $sid . " AND course_id=" . $_POST['filter_by_course'] . " AND batch_id=" . $_POST['filter_by_batch']);
if ($theUpdateData != '') {
$udata['batch_id'] = $_POST['filter_by_batch'];
$udata['course_id'] = $_POST['filter_by_course'];
$udata['student_id'] = $sid;
$udata['subjects_list'] = $theUpdateData;
$udata['created_on'] = date('Y-m-d H:i:s', strtotime($this->nepali_current_date));
$udata['created_by'] = $_SESSION['admin_name'];
$this->db->insert('student_optional_subjects', $udata);
}
/*$getPrevRecds = $this->db->query("SELECT id FROM student_optional_subjects WHERE student_id=".$sid." AND course_id=".$_POST['filter_by_course']." AND batch_id=".$_POST['filter_by_batch'])->result_array();
if(!empty($getPrevRecds))
{
if($theUpdateData=='')
$this->db->query("DELETE FROM student_optional_subjects WHERE id=".$getPrevRecds[0]['id']);
else
{
$udata['subjects_list'] = $theUpdateData;
$udata['modified_on'] = date('Y-m-d H:i:s',strtotime($this->nepali_current_date));
$udata['modified_by'] = $_SESSION['admin_name'];
$this->db->where(array('id'=>$getPrevRecds[0]['id']));
$this->db->update('student_optional_subjects', $udata);
}
}
else
{
if($theUpdateData!='')
{
$udata['batch_id'] = $_POST['filter_by_batch'];
$udata['course_id'] = $_POST['filter_by_course'];
$udata['student_id'] = $sid;
$udata['subjects_list'] = $theUpdateData;
$udata['created_on'] = date('Y-m-d H:i:s',strtotime($this->nepali_current_date));
$udata['created_by'] = $_SESSION['admin_name'];
$this->db->insert('student_optional_subjects', $udata);
}
}*/
}
$this->session->set_flashdata('success', "The details have been updated successfully.");
}
}
$whereCond = " WHERE S.id > 0 AND SB.batch_id=" . $_POST['filter_by_batch'] . " AND CR.course_id=" . $_POST['filter_by_course'];
$orderBy = " ORDER BY S.name ASC ";
if ($currentBatch == $_POST['filter_by_batch'] && isset($_POST['filter_by_section']) && !empty($_POST['filter_by_section']))
$whereCond .= " AND CR.section_id IN(" . implode(",", $_POST['filter_by_section']) . ")";
$theSql = "SELECT S.id,S.name,S.studentId,
SB.roll_no,SB.classroom_id,
CR.course_id,CR.section_id
FROM students AS S
JOIN student_batch AS SB on SB.student_id = S.id
JOIN classroom AS CR ON SB.classroom_id = CR.id " . $whereCond . $orderBy;
$theResults = $this->Admin_model->get_query_result($theSql);
if (!empty($theResults)) {
foreach ($theResults as $key => $sutd) {
$stdOptSubjects = $this->db->query("SELECT subjects_list FROM student_optional_subjects WHERE student_id=" . $sutd['id'] . " AND course_id=" . $_POST['filter_by_course'] . " AND batch_id=" . $_POST['filter_by_batch'])->result_array();
if (!empty($stdOptSubjects)) {
$theResults[$key]['the_opt_subjects'] = $stdOptSubjects[0]['subjects_list'];
$getOSdets = $this->db->query("SELECT GROUP_CONCAT(subject_name) AS sub_names_here FROM subject WHERE id IN(" . $stdOptSubjects[0]['subjects_list'] . ")")->result_array();
$theResults[$key]['the_opt_subject_details'] = '';
if (isset($getOSdets[0]['sub_names_here']))
$theResults[$key]['the_opt_subject_details'] = $theResults[$key]['the_opt_subject_details'];
} else {
$theResults[$key]['the_opt_subjects'] = '';
$theResults[$key]['the_opt_subject_details'] = '';
}
}
}
//$getCSql = "SELECT GROUP_CONCAT(subject_id) AS c_s_ids FROM course_subjects WHERE course_id=".$_POST['filter_by_course'];
$courseSubjects = $this->db->query("SELECT GROUP_CONCAT(subject_id) AS c_s_ids FROM course_subjects WHERE course_id=" . $_POST['filter_by_course'])->result_array();
if (isset($courseSubjects[0]['c_s_ids']) && $courseSubjects[0]['c_s_ids'] != '') {
$csIdsArr = explode(',', $courseSubjects[0]['c_s_ids']);
$s = 0;
foreach ($csIdsArr as $key => $subId) {
$subDetails = $this->db->query("SELECT id,subject_name FROM subject WHERE id=$subId AND is_optional='Yes' AND is_active='yes'")->result_array();
if (!empty($subDetails)) {
$theOptSubs[$s]['id'] = $subDetails[0]['id'];
$theOptSubs[$s]['sub_name'] = $subDetails[0]['subject_name'];
$s++;
}
}
}
}
//echo '<pre>'; print_r($theResults);exit;
$data['course'] = $this->db->query("select * from course WHERE is_active='yes'")->result_array();
$data['batch'] = $this->Admin_model->get_batches();
$data['currentBatch'] = $currentBatch;
$data['theResults'] = $theResults;
$data['theOptSubs'] = $theOptSubs;
$this->load->view('admin/header', $data);
$this->load->view('admin/assign-opt-sub-to-students', $data);
$this->load->view('admin/footer');
}
function checktime()
{
echo date('l jS \of F Y h:i:s A', strtotime($this->nepali_current_date)) . "<br>";
echo date('l jS \of F Y h:i:s A') . "<br>";
echo $today = date('Y-m-d', strtotime('today 00:00:00'));
}
function assign_due_fees()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/assign_due_fees.php'))
show_404();
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$batches = $this->Admin_model->get_table_info('batch', array('is_active' => 'yes'));
$data['batches'] = $batches;
$courses = $this->Admin_model->get_table_info('course', '', '', 'ASC');
$data['course'] = $courses;
$condition = '';
$student_fee = array();
if (isset($_POST['save']) && $_POST['save'] == 'Save') {
// print_r($_POST);
$amount_arr = $_POST['opening_balance'];
$batch_arr = $_POST['student_batch'];
$course_arr = $_POST['student_course'];
$section_arr = $_POST['student_section'];
$cfIds_arr = $_POST['course_fee'];
foreach ($amount_arr as $key => $value) {
$amount = $amount_arr[$key];
$batchId = $batch_arr[$key];
$courseId = $course_arr[$key];
$sectionId = $section_arr[$key];
$courseFeeId = $cfIds_arr[$key];
$grouped = 'no';
$hostel_plan = NULL;
$route_id = NULL;
$nowDate = $this->nepali_current_date;
// $cfId =
// print_r($_POST);
if ($value != 0) {
if ($courseFeeId != '') {
// Creating new fee of due balance.
$data_to_update = array(
'amount' => $amount,
'modified' => $nowDate,
);
$insertQuery = $this->Admin_model->add_edit_table('course_fees', $courseFeeId, $data_to_update);
} else {
// Creating new fee of due balance.
$data_to_db = array(
'batch_id' => $batchId,
'course_id' => $courseId,
'fees_type' => 99,
'fees_name' => 'Due Balance',
'amount' => $amount,
'due_date' => $this->nepali_current_date,
'grouped' => $grouped,
'fee_values' => 'Due Balance',
'hostel_plan_id' => $hostel_plan,
'route_id' => $route_id,
'created' => $nowDate,
);
$insertQuery = $this->Admin_model->add_edit_table('course_fees', 0, $data_to_db);
// Assigning Fee to student/
$lastInsertedId = $this->db->insert_id();
$data_to_fas_db = array(
'student_id' => $key,
'course_fee_id' => $lastInsertedId,
'created_at' => $nowDate,
);
$feeAssignedQuery = $this->Admin_model->add_edit_table('fee_assigned_students', 0, $data_to_fas_db);
}
}
}
if ($insertQuery || $feeAssignedQuery) {
$this->session->set_flashdata('success_msg', str_replace('%s', 'Student opening balance', THE_ADD_SUCCESS_MSG));
// redirect(base_url() . 'admin/assign-due-fees');
} else {
$this->session->set_flashdata('error_msg', str_replace('%s', 'Student opening balance', THE_ADD_ERROR_MSG));
// redirect(base_url() . 'admin/assign-due-fees');
}
} else {
if (count($_POST)) {
$se_batch = (isset($_POST['f_batch']) && !empty($_POST['f_batch'])) ? $_POST['f_batch'] : '';
$se_course = (isset($_POST['f_course']) && !empty($_POST['f_course'])) ? $_POST['f_course'] : '';
$se_section = (isset($_POST['f_section']) && !empty($_POST['f_section'])) ? $_POST['f_section'] : '';
if ($se_course != '')
$condition .= " AND cl.course_id=$se_course";
if ($se_section != '')
$condition .= " AND cl.section_id IN (" . implode(',', $se_section) . ")";
$studentlist = $this->db->query("SELECT s.id as student_id,s.name as student_name,s.course as course_id ,s.batch_id,s.email,s.studentId,s.mobile,s.emergency_contact_name,s.emergency_contact_number,c.course_name,se.id as section_id, se.section_name,sb.roll_no FROM students s JOIN student_batch sb ON s.id=sb.student_id JOIN classroom cl ON cl.id=sb.classroom_id JOIN course c ON c.id=cl.course_id JOIN section se ON se.id=cl.section_id WHERE sb.batch_id=$se_batch AND s.is_active ='yes' $condition")->result_array();
$data['student_fees'] = $studentlist;
$studentOpeningBalanceFees = $this->db->query("SELECT fas.student_id ,fas.course_fee_id, cf.id as course_fee_id, cf.course_id,cf.batch_id,cf.fees_name,cf.amount,cf.fee_values
FROM fee_assigned_students fas JOIN course_fees cf ON cf.id=fas.course_fee_id
WHERE cf.batch_id=$se_batch AND cf.fees_type=99")->result_array();
$data['student_opening_balance'] = $studentOpeningBalanceFees;
// var_dump($studentOpeningBalanceFees);
}
}
$this->load->view('admin/header', $data);
$this->load->view('admin/assign_due_fees', $data);
$this->load->view('admin/footer');
}
public function scholarship()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/scholarship.php'))
show_404();
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$startDate = '';
$endDate = '';
$condition = '';
$studentlist = array();
$selectedFeeTypes = array();
$batches = $this->Admin_model->get_table_info('batch', array('is_active' => 'yes'));
$data['batches'] = $batches;
$courses = $this->Admin_model->get_table_info('course', '', '', 'ASC');
$data['course'] = $courses;
$fees_types_list = $this->Admin_model->get_fees_type();
// dd($fees_types_list);
$data['fees_types'] = $fees_types_list;
$ft_where = " ";
if (count($_POST)) {
// if (isset($_POST['filtersubmit']) && $_POST['filtersubmit'] == 'Filter') {
$se_batch = (isset($_POST['f_batch']) && !empty($_POST['f_batch'])) ? $_POST['f_batch'] : '';
$se_course = (isset($_POST['f_course']) && !empty($_POST['f_course'])) ? $_POST['f_course'] : '';
$se_section = (isset($_POST['f_section']) && !empty($_POST['f_section'])) ? $_POST['f_section'] : '';
$f_feetype = (isset($_POST['filter_fee_types']) && !empty($_POST['filter_fee_types'])) ? $_POST['filter_fee_types'] : '';
// echo '<pre>';
// var_dump($_POST['filter_fee_types']);
if ($se_course != '')
$condition .= " AND cl.course_id=$se_course";
if ($se_section != '')
$condition .= " AND cl.section_id IN (" . implode(',', $se_section) . ")";
$studentlist = $this->db->query("SELECT s.id as student_id,s.name as student_name,s.course as course_id ,s.batch_id,s.email,s.studentId,s.mobile,s.emergency_contact_name,s.emergency_contact_number,c.course_name,se.id as section_id, se.section_name,sb.id as student_batch_id, sb.roll_no FROM students s
JOIN student_batch sb ON s.id=sb.student_id
JOIN classroom cl ON cl.id=sb.classroom_id
JOIN course c ON c.id=cl.course_id
JOIN section se ON se.id=cl.section_id
WHERE sb.batch_id=$se_batch AND s.is_active ='yes' $condition")->result_array();
// echo '<pre>';
// print_r($studentlist2);
$arr_feetype = implode(',', $f_feetype);
$selectedCourseFeeType = $this->db->query(
"SELECT cf.id as course_fee_id,cf.fees_name,cf.amount,cf.fee_values,cf.is_active,cf.fees_type,cf.course_id,cf.batch_id,cf.modified
FROM course_fees cf WHERE cf.course_id = $se_course AND cf.batch_id=$se_batch AND cf.is_active ='yes' AND cf.fees_type in ($arr_feetype)"
)->result_array();
$data['selected_fee_types'] = $selectedCourseFeeType;
// echo '<pre>';
// var_dump($selectedCourseFeeType);
foreach ($studentlist as $key => $theStd) {
$studentScholarship = $this->db->query("SELECT ss.id, ss.student_id, ss.course_fee_id, ss.created, ss.modified, ss.scholarship_amount, ss.scholarship_type, ss.scholarship_discount,
IF(sop.id is null,0,sop.id) as isPaymentMade
FROM student_scholarship ss
LEFT JOIN students_online_payments sop on ss.course_fee_id = sop.course_fee_id AND sop.student_id = ss.student_id
WHERE ss.student_id =" . $theStd['student_id'] . " AND ss.batch_id = " . $theStd['batch_id'] . " AND ss.fee_type in ($arr_feetype)")->result_array();
$studentlist[$key]['scholarship'] = count($studentScholarship) > 0 ? $studentScholarship : null;
}
if (isset($_POST['save']) && $_POST['save'] == 'Save') {
// echo '<pre>';
// var_dump($_POST);
$scholarshipPercentage = (isset($_POST['scholarshipPercentage']) && !empty($_POST['scholarshipPercentage'])) ? $_POST['scholarshipPercentage'] : [];
$scholarshipAmount = (isset($_POST['scholarshipAmount']) && !empty($_POST['scholarshipAmount'])) ? $_POST['scholarshipAmount'] : [];
$s_type = (isset($_POST['s_type']) && !empty($_POST['s_type'])) ? $_POST['s_type'] : [];
$courseFees = (isset($_POST['courseFeeId']) && !empty($_POST['courseFeeId'])) ? $_POST['courseFeeId'] : [];
$studentBatches = (isset($_POST['studentBatchId']) && !empty($_POST['studentBatchId'])) ? $_POST['studentBatchId'] : [];
$selectedCourseFee = (isset($_POST['f_selected_course_fee']) && !empty($_POST['f_selected_course_fee'])) ? $_POST['f_selected_course_fee'] : [];
$updateStatusArr = [];
$scholarship_course_fees = [];
// echo '<pre>';
// Loop for selected fee type
foreach ($scholarshipAmount as $feeTypeKey => $s_amountValue) {
foreach ($s_amountValue as $sa_key => $sa_value) {
// dd($studentBatches[$sa_key]);
if ($sa_value != '0' || $sa_value != '') {
// var_dump($sa_value);
if ($sa_value == 0) {
// echo 'value = 0';
if ($feeTypeKey == 4 || $feeTypeKey == 8 || $feeTypeKey == 5) {
if (isset($selectedCourseFee[$sa_key])) {
foreach ($selectedCourseFee[$sa_key] as $scf_value) {
$ss_scholarship = $this->db->query("SELECT * FROM student_scholarship WHERE student_id =" . $sa_key . " AND course_fee_id = " . $scf_value . " AND batch_id = " . $se_batch)->result_array();
// echo '<pre>';
// print_r($ss_scholarship[0]['id']);
$this->db->where('id', $ss_scholarship[0]['id']);
$del = $this->db->delete('student_scholarship');
// print_r($del);
}
}
} else {
$assignedScholarshipId = (isset($_POST['assignedScholarshipId']) && !empty($_POST['assignedScholarshipId'])) ? $_POST['assignedScholarshipId'] : [];
$courseFeeId = $courseFees[$feeTypeKey][$sa_key];
$scholarshipId =
$assignedScholarshipId[$feeTypeKey][$sa_key];
$data_to_update = [];
if ($scholarshipId != 0) {
$this->db->where('id', $scholarshipId);
$del = $this->db->delete('student_scholarship');
// print_r($del);
}
// var_dump($data_to_update);
}
} else if ($sa_value == '') {
// echo 'value = empty';
} else {
$s_Amount = $sa_value;
$s_Percentage = $scholarshipPercentage[$feeTypeKey][$sa_key];
$scholarshipType = $s_type[$sa_key];
// ************************************************** Single Fee Logic **************************************************
if ($feeTypeKey == 4 || $feeTypeKey == 8 || $feeTypeKey == 5) {
// echo '<pre>';
if (isset($selectedCourseFee[$sa_key])) {
foreach ($selectedCourseFee[$sa_key] as $scf_value) {
$ss_scholarship = $this->db->query("SELECT * FROM student_scholarship WHERE student_id =" . $sa_key . " AND course_fee_id = " . $scf_value . " AND batch_id = " . $se_batch)->result_array();
// print_r($ss_scholarship);
// Checking if the student is in student scholarship table
if (count($ss_scholarship) > 0) {
// var_dump($ss_scholarship[0]['id']);
$data_to_update = array(
'student_id' => $sa_key,
'course_fee_id' => $scf_value,
'is_active' => 'yes',
'scholarship_amount' => $s_Amount,
'scholarship_type' => $scholarshipType,
'scholarship_discount' => $s_Percentage,
'modified' => $this->nepali_current_date,
);
$updateQuery = $this->Admin_model->add_edit_table('student_scholarship', $ss_scholarship[0]['id'], $data_to_update);
if ($updateQuery == true) {
array_push($updateStatusArr, true);
} else {
array_push($updateStatusArr, false);
}
} else {
$data_to_update = array(
'student_id' => $sa_key,
'course_fee_id' => $scf_value,
'fee_type' => $feeTypeKey,
'batch_id' => $se_batch,
'is_active' => 'yes',
'scholarship_amount' => $s_Amount,
'scholarship_type' => $scholarshipType,
'scholarship_discount' => $s_Percentage,
'created' => $this->nepali_current_date,
'modified' => $this->nepali_current_date,
);
// print_r($data_to_update);
$updateQuery = $this->Admin_model->add_edit_table('student_scholarship', 0, $data_to_update);
if ($updateQuery == true) {
array_push($updateStatusArr, true);
} else {
array_push($updateStatusArr, false);
}
}
}
}
} else {
// foreach ($s_amountValue as $sa_key => $sa_value) {
$assignedScholarshipId = (isset($_POST['assignedScholarshipId']) && !empty($_POST['assignedScholarshipId'])) ? $_POST['assignedScholarshipId'] : [];
$courseFeeId = $courseFees[$feeTypeKey][$sa_key];
$scholarshipId =
$assignedScholarshipId[$feeTypeKey][$sa_key];
$data_to_update = [];
if ($scholarshipId != 0) {
$data_to_update = array(
'student_id' => $sa_key,
'course_fee_id' => $courseFeeId,
'is_active' => 'yes',
'scholarship_amount' => $s_Amount,
'scholarship_type' => $scholarshipType,
'scholarship_discount' => $s_Percentage,
'modified' => $this->nepali_current_date,
);
$insertQuery = $this->Admin_model->add_edit_table('student_scholarship', $scholarshipId, $data_to_update);
if ($insertQuery == true) {
array_push($updateStatusArr, true);
} else {
array_push($updateStatusArr, false);
}
} else {
$data_to_update = array(
'student_id' => $sa_key,
'course_fee_id' => $courseFeeId,
'fee_type' => $feeTypeKey,
'batch_id' => $se_batch,
'is_active' => 'yes',
'scholarship_amount' => $s_Amount,
'scholarship_type' => $scholarshipType,
'scholarship_discount' => $s_Percentage,
'created' => $this->nepali_current_date,
'modified' => $this->nepali_current_date,
);
$insertQuery = $this->Admin_model->add_edit_table('student_scholarship', 0, $data_to_update);
if ($insertQuery == true) {
array_push($updateStatusArr, true);
} else {
array_push($updateStatusArr, false);
}
}
//
}
}
}
}
}
if (in_array(false, $updateStatusArr)) {
$this->session->set_flashdata('error_msg', str_replace('%s', 'Scholarship', 'Something went wrong. Plese try again after sometime.'));
} else {
$this->session->set_flashdata('success_msg', str_replace('%s', 'Scholarship', 'Scholarship has been assigned successfully.'));
redirect(base_url() . 'admin/scholarship');
}
// // $scholarship_course_fees = $scholarship_course_fees + ', ' + strval($feeTypeKey);
// ************************************************** Single Fee Logic **************************************************
}
}
$data['all_fee_types'] = $this->Admin_model->get_query_result("SELECT id,feetype_name FROM fee_types");
$data['all_scholarship_types'] = $this->Admin_model->get_query_result("SELECT id, scholarshiptype_name FROM scholarship_types WHERE is_active = 'yes'");
$data['selected_feetype'] = $selectedFeeTypes;
$data['search_start_paid_date'] = $startDate;
$data['search_end_paid_date'] = $endDate;
$data['students'] = $studentlist;
$this->load->view('admin/header', $data);
$this->load->view('admin/scholarship', $data);
$this->load->view('admin/footer');
}
public function scholarship_list()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/scholarship-list.php'))
show_404();
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$startDate = '';
$endDate = '';
$condition = '';
$studentlist = array();
$selectedFeeTypes = array();
$batches = $this->Admin_model->get_table_info('batch', array('is_active' => 'yes'));
$data['batches'] = $batches;
$courses = $this->Admin_model->get_table_info('course', '', '', 'ASC');
$data['course'] = $courses;
$fees_types_list = $this->Admin_model->get_fees_type();
// dd($fees_types_list);
$data['fees_types'] = $fees_types_list;
$ft_where = " ";
if (count($_POST)) {
// if (isset($_POST['filtersubmit']) && $_POST['filtersubmit'] == 'Filter') {
$se_batch = (isset($_POST['f_batch']) && !empty($_POST['f_batch'])) ? $_POST['f_batch'] : '';
$data['search_batch_id'] = $se_batch;
$query = "SELECT ss.id, ss.student_id,
s.studentId AS studentId, s.name AS student_name, s.course AS student_course, s.batch_id AS student_batch_id,
sb.roll_no, cr.classroom_name, crs.course_name, sec.section_name
FROM student_scholarship ss
LEFT JOIN students AS s ON s.id = ss.student_id
LEFT JOIN student_batch AS sb ON s.id = sb.student_id AND s.batch_id=sb.batch_id
LEFT JOIN classroom as cr ON sb.classroom_id = cr.id AND s.course=cr.course_id
LEFT JOIN course as crs ON cr.course_id = crs.id AND s.course=crs.id
LEFT JOIN section as sec ON cr.section_id = sec.id
WHERE ss.batch_id = $se_batch
GROUP BY ss.student_id";
$scholarshipList = [];
$scholarshipList = $this->db->query($query)->result_array();
foreach ($scholarshipList as $stdKey => $stdValue) {
$scholarship = $this->db->query("SELECT ss.id as scholarship_id,ss.student_id, ss.course_fee_id, ss.batch_id, ss.is_active, ss.scholarship_type,ss.scholarship_amount,ss.scholarship_discount,
cf.fee_values as fee_name, cf.amount as fee_amount, ft.feetype_name as fee_type, IF(sop.id is null,0,sop.id) as isPaymentMade
FROM student_scholarship ss
LEFT JOIN course_fees AS cf ON ss.course_fee_id = cf.id
LEFT JOIN fee_types AS ft ON cf.fees_type = ft.id
LEFT JOIN students_online_payments sop on ss.course_fee_id = sop.course_fee_id AND sop.student_id = ss.student_id
WHERE ss.batch_id=$se_batch AND ss.student_id=" . $stdValue['student_id'])->result_array();
$scholarshipList[$stdKey]['scholarship'] = $scholarship;
}
$data['scholarStudents'] = $scholarshipList;
// echo '<pre>';
// print_r($scholarshipList);
}
$data['all_fee_types'] = $this->Admin_model->get_query_result("SELECT id,feetype_name FROM fee_types");
$data['all_scholarship_types'] = $this->Admin_model->get_query_result("SELECT id, scholarshiptype_name FROM scholarship_types WHERE is_active = 'yes'");
$data['selected_feetype'] = $selectedFeeTypes;
$data['search_start_paid_date'] = $startDate;
$data['search_end_paid_date'] = $endDate;
$this->load->view('admin/header', $data);
$this->load->view('admin/scholarship-list', $data);
$this->load->view('admin/footer');
}
function getscholarshipDetails()
{
$batchid = $_REQUEST['batch_id'];
$student_id = $_REQUEST['studentId'];
$scholarships = $this->db->query("SELECT ss.id as scholarship_id,ss.student_id, ss.course_fee_id, ss.batch_id, ss.is_active, ss.scholarship_type,ss.scholarship_amount,ss.scholarship_discount,
cf.fee_values as fee_name, cf.amount as fee_amount, ft.feetype_name as fee_type, IF(sop.id is null,0,sop.id) as isPaymentMade
FROM student_scholarship ss
LEFT JOIN course_fees AS cf ON ss.course_fee_id = cf.id
LEFT JOIN fee_types AS ft ON cf.fees_type = ft.id
LEFT JOIN students_online_payments sop on ss.course_fee_id = sop.course_fee_id AND sop.student_id = ss.student_id
WHERE ss.batch_id=$batchid AND ss.student_id=" . $student_id)->result_array();
$studentInfo = $this->db->query("SELECT * FROM students
WHERE id=$student_id")->result_array();
// $studentDetail = [];
foreach ($studentInfo as $sKey => $sValue) {
$data['student_info'] = $sValue;
}
$data['batchid'] = $batchid;
$data['all_scholarship_types'] = $this->Admin_model->get_query_result("SELECT id, scholarshiptype_name FROM scholarship_types WHERE is_active = 'yes'");
$data['student_id'] = $student_id;
$data['scholarship_data'] = $scholarships;
// $data['route_data'] = $routelist;
// $data['batch_name'] = $this->db->get_where('batch', array('id' => $batchid))->row()->b_name;
// $data['student_route_id'] = $student_route_id;
// $data['student_assigned_route'] = $studentAssignedRoute;
// $data['stop_list'] = $stoplist;
$page = $this->load->view('admin/scholarshipdata', $data, TRUE);
echo $page;
}
public function updateScholarship()
{
$studentId = $_REQUEST['student_id'];
$routeId = $_REQUEST['route_id'];
$pick_id = $_REQUEST['stop_id'];
$batch_id = $_REQUEST['batch_id'];
$is_one_way = $_REQUEST['is_one_way'];
var_dump($_REQUEST);
}
public function send_message()
{
print_r($_POST);
echo '
<script type="text/javascript">
window.onload = function () { alert("' . $_POST['contact_number'] . '"); }
</script>';
}
public function sendNotification($message)
{
$options = array(
'cluster' => 'ap2',
'encrypted' => true
);
$pusher = new Pusher\Pusher(
'6df1a6c2a507560f5547', // app key
'0d22f8afc8c3bfc10442', // app secret
'1532423', // app id
$options
);
$data['message'] = $message;
$pusher->trigger('my-channel', 'my-event', $data);
}
public function scholarship_types()
{
// sendNotification('Pusher Check');
$options = array(
'cluster' => 'ap2',
'encrypted' => true
);
$pusher = new Pusher\Pusher(
'6df1a6c2a507560f5547', // app key
'0d22f8afc8c3bfc10442', // app secret
'1532423', // app id
$options
);
$data['message'] = '$message';
$pusher->trigger('my-channel', 'my-event', $data);
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['result'] = $this->Admin_model->get_table_info('scholarship_types');
$this->load->view('admin/header', $data);
$this->load->view('admin/scholarship_types');
$this->load->view('admin/footer');
}
public function add_edit_scholarship_type($scholarshipId)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/ae_scholarship_type.php'))
show_404();
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['id'] = $scholarshipId;
$whereClause = array('id' => $scholarshipId);
$checkSectionExists = $this->Admin_model->get_scholarship_type($whereClause);
if (empty($checkSectionExists) && $scholarshipId != 0) {
$this->session->set_flashdata('failed', 'There is no section with selected id');
redirect(base_url() . 'Admin/section');
}
if (count($_POST) > 0) {
$_POST['scholarshiptype_name'] = $this->convertToCapCase($_POST['scholarshiptype_name']);
var_dump($_POST);
if ($scholarshipId > 0) {
$_POST['modified'] = $this->nepali_current_date;
} else {
$_POST['created'] = $this->nepali_current_date;
}
$sql = $this->Admin_model->add_edit_scholarship($scholarshipId, $_POST);
if (($sql) && $scholarshipId > 0) {
$this->session->set_flashdata('success', 'Scholarship has been updated successfully');
redirect(base_url() . 'admin/scholarship-types');
} else if ($sql) {
$this->session->set_flashdata('success', 'Scholarship has been addedd successfully');
redirect(base_url() . 'admin/scholarship-types');
} else {
$this->session->set_flashdata('failed', 'Scholarship updation failed.');
redirect(base_url() . 'admin/scholarship-types');
}
}
$data['title'] = 'Add New Scholarship';
if ($scholarshipId > 0) {
$data['title'] = 'Edit Scholarship';
$data['result'] = $checkSectionExists;
}
$this->load->view('admin/header', $data);
$this->load->view('admin/ae_scholarship_type');
$this->load->view('admin/footer');
}
public function debug_to_console($data)
{
$output = $data;
if (is_array($output))
$output = implode(',', $output);
echo "<script>console.log('Debug Objects: " . $output . "' );</script>";
}
public function transport_report()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/transport-report.php'))
show_404();
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$startDate = '';
$endDate = '';
$condition = '';
$studentlist = array();
$selectedFeeTypes = array();
$batches = $this->Admin_model->get_table_info('batch', array('is_active' => 'yes'));
$data['batches'] = $batches;
$courses = $this->Admin_model->get_table_info('course', '', '', 'ASC');
$data['course'] = $courses;
$fees_types_list = $this->Admin_model->get_fees_type();
// dd($fees_types_list);
$data['fees_types'] = $fees_types_list;
$ft_where = " ";
if (count($_POST)) {
// if (isset($_POST['filtersubmit']) && $_POST['filtersubmit'] == 'Filter') {
$se_batch = (isset($_POST['f_batch']) && !empty($_POST['f_batch'])) ? $_POST['f_batch'] : '';
$data['search_batch_id'] = $se_batch;
$transport_db = $this->load->database('erisnClassroom_bts', TRUE);
$batch_routes = $transport_db->query('SELECT * from bt_batch_routes where batch_id = ' . $se_batch)->row_array();
$transportListQuery = "SELECT btRD.student_id, btRD.route_id, btRD.pick_up_id, btRD.batch_id, btRD.one_way, btRD.is_active, btRD.drop_id
FROM bt_students_bus_route_details btRD";
// $transportList = $this->$transport_db->query($transportListQuery);
$transport_db = $this->load->database('erisnClassroom_bts', TRUE);
$transportList = $transport_db->query(
'SELECT btRD.student_id, btRD.route_id, btRD.pick_up_id, btRD.batch_id, btRD.one_way, btRD.is_active, btRD.drop_id,
bRD.place_name, bRD.route_id, bRD.route_order, br.id, br.route_name
FROM bt_students_bus_route_details btRD
LEFT JOIN bt_routes_details AS bRD ON bRD.id = btRD.pick_up_id AND btRD.route_id=bRD.route_id
LEFT JOIN bt_routes AS br ON br.id=btRD.route_id
Where btRD.batch_id = ' . $se_batch
)->result_array();
// $studentList
foreach ($transportList as $tl_key => $tl_value) {
$studentQuery = "SELECT s.id, s.name AS student_name,s.studentId, s.course AS student_course, s.batch_id AS student_batch_id,
sb.roll_no, cr.classroom_name, crs.course_name, sec.section_name
FROM students AS s
LEFT JOIN student_batch AS sb ON s.id = sb.student_id AND s.batch_id=sb.batch_id
LEFT JOIN classroom as cr ON sb.classroom_id = cr.id AND s.course=cr.course_id
LEFT JOIN course as crs ON cr.course_id = crs.id AND s.course=crs.id
LEFT JOIN section as sec ON cr.section_id = sec.id
WHERE s.batch_id = $se_batch AND s.id = " . $tl_value['student_id'] . "
GROUP BY s.id";
// $transportFee = "SELECT cf.feeAmount, cf.fee_values AS fee_name
// FROM course_fees AS cf
// WHERE cf.batch_id = $se_batch AND cf.course_id = " . $tl_value['student_id'] . "
// GROUP BY s.id";
$studentDetail = $this->db->query($studentQuery)->result_array();
$transportList[$tl_key]['student'] = $studentDetail;
}
$data['transportList'] = $transportList;
}
$this->load->view('admin/header', $data);
$this->load->view('admin/transport-report', $data);
$this->load->view('admin/footer');
}
// public function assign_class_teacher()
// {
// }
public function assign_class_teacher($classroomId)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/assign-class-teacher.php'))
show_404();
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['courselist'] = $this->Admin_model->get_general_result_details('course', 'DESC', array('is_active' => 'yes'));
$data['title'] = "Assign Class Teacher ";
$data['id'] = $classroomId;
$teacherIds = [];
if ($classroomId > 0) {
$data['classroom'] = $this->Admin_model->get_general_row_details('classroom', 'ASC', array('id' => $classroomId));
$sqlQuery = "SELECT cl.*,cs.subject_id as course_subject_ids FROM classroom cl JOIN
course_subjects cs ON cl.course_id=cs.course_id WHERE cl.id='$classroomId' AND cs.subject_id NOT IN (Select subject_id as subid from classroom_teacher_subject WHERE classroom_id = $classroomId)";
$data['course_subjects'] = $this->Admin_model->get_query_result($sqlQuery);
$classroomSubjects = $this->Admin_model->get_general_result_details('classroom_teacher_subject', 'ASC', array('classroom_id' => $classroomId));
$sqlQuery =
"SELECT cts.id,cts.classroom_id,cts.subject_id,cts.teacher_id,cts.is_class_teacher,sub.subject_name FROM classroom_teacher_subject cts
LEFT JOIN subject sub on cts.subject_id=sub.id WHERE cts.classroom_id=$classroomId";
$data['classroom_subjects'] =
$this->Admin_model->get_query_result($sqlQuery);
if (count($_POST)) {
if (isset($_POST['update']) && ($_POST['update'] == 'Update')) {
$classroomSubjects = $data['classroom_subjects'];
$subjectId = $_POST['subject_id'];
var_dump($classroomSubjects);
$updateStatus = [];
foreach ($classroomSubjects as $cs_key => $cs_value) {
$isClassTeacher = '';
if ($cs_value['subject_id'] == $subjectId) {
$isClassTeacher = 'yes';
} else {
$isClassTeacher = 'no';
}
$data_array = array(
'is_class_teacher' => $isClassTeacher,
'modified' => $this->nepali_current_date
);
$this->db->where('id', $cs_value['id']);
$update = $this->db->update('classroom_teacher_subject', $data_array);
if ($update) {
array_push($updateStatus, true);
} else {
array_push($updateStatus, false);
}
}
if (!in_array(false, $updateStatus)) {
$this->session->set_flashdata('success', 'Classteacher has been updated successfully');
redirect(base_url() . 'admin/ae-classroom/' . $classroomId);
} else {
$this->session->set_flashdata('error', 'Something went wrong.');
}
}
}
} else {
show_404();
}
$this->load->view('admin/header', $data);
$this->load->view('admin/assign-class-teacher');
$this->load->view('admin/footer');
}
public function symbolNumberUpdate($classroomId)
{
$data['encrepted_clas'] = $classroomId;
$classroom_id = (int)str_replace("-qqcksbvlwierhwjerw", '', urlsafe_b64decode($classroomId));
$check_classroom_id = $this->db->query('select * from classroom where id =' . $classroom_id)->row_array();
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['title'] = "Symbol Number of " . $check_classroom_id['classroom_name'];
$data['classroomid'] = $check_classroom_id['id'];
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$cls_id = $check_classroom_id['id'];
// $query = "SELECT sb.id as stud_batch_id, sb.roll_no, sb.symbol_no, sb.registration_no, sb.batch_id,sb.classroom_id,s.* FROM student_batch sb LEFT JOIN students s ON sb.student_id=s.id AND sb.batch_id = " . $school_info['batch_id'] . " WHERE sb.classroom_id=$cls_id";
$query = "SELECT sb.id as stud_batch_id, sb.roll_no, sb.symbol_no, sb.batch_id as student_batch, sb.classroom_id, s.* FROM student_batch sb LEFT JOIN students s ON sb.student_id=s.id WHERE sb.batch_id = " . $data['school_info']['batch_id'] . " AND sb.classroom_id=$cls_id ORDER BY sb.roll_no";
$data['student_list'] = $this->Admin_model->get_query_result($query);
if ($_POST) {
$checker = 0;
$symbol_numbers = explode(",", $_POST['symbol_numbers']);
$batch_ids = explode(",", $_POST['batch_ids']);
// dd($_POST);
foreach ($symbol_numbers as $key => $value) {
$this->db->set('symbol_no', $value);
$this->db->where('id', $batch_ids[$key]);
$update = $this->db->update('student_batch');
if ($update) {
$checker = 1;
}
}
if ($checker > 0)
$this->session->set_flashdata('success_msg', 'Symbol Number Updated Successfully');
else
$this->session->set_flashdata('error_msg', 'Something Went Wrong...Plese try again...!!');
redirect(base_url() . 'admin/symbol-number/' . $classroomId);
}
$this->load->view('admin/header', $data);
$this->load->view('admin/assign_symbol_number');
$this->load->view('admin/footer');
}
public function registrationNumberUpdate($classroomId)
{
$data['encrepted_clas'] = $classroomId;
$classroom_id = (int)str_replace("-qqcksbvlwierhwjerw", '', urlsafe_b64decode($classroomId));
$check_classroom_id = $this->db->query('select * from classroom where id =' . $classroom_id)->row_array();
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['title'] = "Registration Number of " . $check_classroom_id['classroom_name'];
$data['classroomid'] = $check_classroom_id['id'];
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$cls_id = $check_classroom_id['id'];
$query = "SELECT sb.id as stud_batch_id, sb.roll_no, sb.symbol_no, sb.registration_no, sb.batch_id as student_batch, sb.classroom_id, s.* FROM student_batch sb LEFT JOIN students s ON sb.student_id=s.id WHERE sb.batch_id = " . $data['school_info']['batch_id'] . " AND sb.classroom_id=$cls_id ORDER BY sb.roll_no";
// $query = "SELECT sb.id as stud_batch_id, sb.roll_no, sb.symbol_no, sb.registration_no, sb.batch_id,sb.classroom_id,s.* FROM student_batch sb LEFT JOIN students s ON sb.student_id=s.id AND sb.batch_id = s.batch_id WHERE sb.classroom_id=$cls_id";
$data['student_list'] = $this->Admin_model->get_query_result($query);
if ($_POST) {
$checker = 0;
$registration_numbers = explode(",", $_POST['registration_numbers']);
$batch_ids = explode(",", $_POST['batch_ids']);
// dd($_POST);
foreach ($registration_numbers as $key => $value) {
$this->db->set('registration_no', $value);
$this->db->where('id', $batch_ids[$key]);
$update = $this->db->update('student_batch');
if ($update) {
$checker = 1;
}
}
if ($checker > 0)
$this->session->set_flashdata('success_msg', 'Registration Number Updated Successfully');
else
$this->session->set_flashdata('error_msg', 'Something Went Wrong...Plese try again...!!');
redirect(base_url() . 'admin/registration-number/' . $classroomId);
}
$this->load->view('admin/header', $data);
$this->load->view('admin/assign_registration_number');
$this->load->view('admin/footer');
}
public function multiple_edit()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/multiple-student-edit.php'))
show_404();
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$theStudents = array();
$theSubjects = array();
$data['selected_batch'] = $data['school_info']['batch_id'];
if (count($_POST) > 0) {
$se_course =
$_POST['course_id'];
$se_batch
= $_POST['batch_id'];
// $se_offline_exam_id =
// $_POST['offline_exam_id'];
$se_section = (isset($_POST['section_id']) && !empty($_POST['section_id'])) ? $_POST['section_id'] : '';
$data['selected_batch'] =
$_POST['batch_id'];
$condition = '';
if (isset($_POST['clicked_button']) && ($_POST['clicked_button'] == 'Save' || $_POST['clicked_button'] == 'Save All')) {
$this->load->helper('url');
$this->load->helper(array('form', 'url'));
$std_names = $_POST['name'];
$std_email = $_POST['email'];
$std_dob = $_POST['sdob'];
$std_mobile = $_POST['mobile'];
$std_fathername = $_POST['fathername'];
$std_mothername = $_POST['mother_name'];
$std_emergency_contact_number = $_POST['emergency_contact_number'];
$std_address = $_POST['address'];
$std_state = $_POST['state'];
$std_country = $_POST['country'];
$std_iemis = $_POST['iemis'];
$user_photos = $_POST['user_photo'];
$studentId = $_POST['studentId'];
$update_status = array();
$std_photos = array();
$config['upload_path'] = 'assets_student/application/';
$config['allowed_types'] = 'gif|jpg|png|jpeg|jfif|jiff';
$imageCount = $_FILES['photo']['name'];
print_r(count($imageCount));
// for ($i = 0; $i < $imageCount; $i++) {
// $_FILES['file']['name'] = $_FILES['photo']['name'][$i];
// $_FILES['file']['type'] = $_FILES['photo']['type'][$i];
// $_FILES['file']['tmp_name'] = $_FILES['photo']['tmp_name'][$i];
// $_FILES['file']['error'] = $_FILES['photo']['error'][$i];
// $_FILES['file']['size'] = $_FILES['photo']['size'][$i];
// }
foreach ($imageCount as $i_key => $i_value) {
$config['file_name'] = $studentId[$i_key];
$config['encrypt_name'] = FALSE;
$this->load->library('upload', $config);
$this->upload->initialize($config);
$_FILES['file']['name'] = $_FILES['photo']['name'][$i_key];
$_FILES['file']['type'] = $_FILES['photo']['type'][$i_key];
$_FILES['file']['tmp_name'] = $_FILES['photo']['tmp_name'][$i_key];
$_FILES['file']['error'] = $_FILES['photo']['error'][$i_key];
$_FILES['file']['size'] = $_FILES['photo']['size'][$i_key];
// echo '<pre>';
// print_r($_FILES['file']['tmp_name']);
if ($_FILES['file']['size'] != 0) {
if (!$this->upload->do_upload('file')) {
$std_photos[$i_key] = "";
} else {
$photo = array('upload_data' => $this->upload->data());
$std_photos[$i_key] = $photo['upload_data']['file_name'];
$file = $config['upload_path'] . '' . $user_photos[$i_key];
// dd($file);
if (file_exists($file)) {
unlink($file);
}
}
}
}
foreach ($std_names as $std_key => $std_value) {
echo '<pre>';
$userPhoto = (isset($std_photos[$std_key]) && !empty($std_photos[$std_key])) ? $std_photos[$std_key] : $user_photos[$std_key];
$update_data = array(
'name' => $std_names[$std_key],
'email' => $std_email[$std_key],
'dob' => $std_dob[$std_key],
'mobile' => $std_mobile[$std_key],
'father_name' => $std_fathername[$std_key],
'mother_name' => $std_mothername[$std_key],
'emergency_contact_number' => $std_emergency_contact_number[$std_key],
'address1' => $std_address[$std_key],
'state' => $std_state[$std_key],
'country' => $std_country[$std_key],
'iemis' => $std_iemis[$std_key],
'photo' => $userPhoto
);
// var_dump($update_data);
$this->db->where('id', $std_key);
$update = $this->db->update("students", $update_data);
if ($update) {
array_push($update_status, true);
} else {
array_push($update_status, false);
}
}
// dd($update_status);
// dd($std_photos);
if (in_array(false, $update_status)) {
$this->session->set_flashdata('error_msg', str_replace('%s', 'Records Update', 'Something went wrong. Plese try again after sometime.'));
} else {
$this->session->set_flashdata('success_msg', str_replace('%s', 'Records Update', 'Student records has been updated successfully.'));
redirect(base_url() . 'admin/multiple-edit');
}
}
//START -- of getting the subjects for selected batch,course & exam combination
if (isset($_SESSION['admin_role_ids']) && $_SESSION['admin_role_ids'] == 1) {
// $theSubSql = "SELECT OEM.subject_id,OEM.th_total_marks,OEM.th_pass_marks,OEM.is_practical,OEM.pr_total_marks,OEM.pr_pass_marks,OEM.subject_order,S.subject_name,S.is_optional,S.is_additional FROM offline_exam_marks AS OEM, subject AS S WHERE OEM.batch_id=" . $_POST['batch_id'] . " AND OEM.course_id=" . $_POST['course_id'] . " AND OEM.offline_exam_id=" . $_POST['offline_exam_id'] . " AND OEM.subject_id=S.id AND S.is_additional='No' AND OEM.is_active='yes' ORDER BY OEM.subject_order ASC";
// $theSubjects = $this->db->query($theSubSql)->result_array();
// echo '<pre>';
// print_r($theSubjects);
if ($se_course != '')
$condition .= " AND cl.course_id=$se_course";
if ($se_section != '')
$condition .= " AND cl.section_id IN (" . implode(',', $se_section) . ")";
$theStudents = $this->db->query("SELECT s.*,c.course_name,se.section_name,sb.roll_no FROM students s JOIN student_batch sb ON s.id=sb.student_id JOIN classroom cl ON cl.id=sb.classroom_id JOIN course c ON c.id=cl.course_id JOIN section se ON se.id=cl.section_id WHERE sb.batch_id=$se_batch $condition")->result_array();
// dd($theStudents);
}
}
$data['batch'] = $this->db->query("select id,b_name from batch WHERE is_active='yes'")->result_array();
$data['course'] = $this->db->query("select * from course WHERE is_active='yes'")->result_array();
$data['exams'] = $this->db->query("select * from offline_exams WHERE is_active='yes'")->result_array();
$data['theStudents'] = $theStudents;
// $data['theSubjects'] = $theSubjects;
$this->load->view('admin/header', $data);
$this->load->view('admin/multiple-student-edit', $data);
$this->load->view('admin/footer');
}
public function school_calendar()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/school-calendar.php'))
show_404();
$data['title'] = 'School Calendar';
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$adminInfo = $this->db->query("SELECT * FROM admin WHERE id =" . $_SESSION['admin_id'])->row_array();
$data['courses'] = $this->Admin_model->get_courses();
$data['batch'] = $this->Admin_model->get_batch();
$data['result'] = $this->db->query('select * from school_settings where id= 1')->row_array();
// $rst=$this->db->query("SELECT invoice_no FROM `student_fee_online_transactions` ORDER BY id DESC")->row_array();
// if(!empty($rst)){
// $data['new_invoice_no']=(isset($rst['invoice_no']) && !empty($rst['invoice_no'])) ? $rst['invoice_no'] :"0000";
// }
if ($_POST > 0) {
if (isset($_POST['addEvent']) && ($_POST['addEvent'] == 'Add')) {
$start_date_array = explode('-', $_POST['event_date']);
$td['title'] = $_POST['title'];
$td['year'] = $start_date_array[0];
$td['month'] = $start_date_array[1];
$td['day'] = $start_date_array[2];
$td['date'] = $_POST['event_date'];
$td['end_date'] = $_POST['event_end_date'];
$td['event_type'] = $_POST['event_type'];
$td['remarks'] = $_POST['description'];
$td['created_on'] = $this->nepali_current_date;
$td['created_by'] = $adminInfo['admin_name'];
$td['modified_on'] = $this->nepali_current_date;
$td['modified_by'] = $adminInfo['admin_name'];
$this->db->insert('school_calendar', $td);
$this->session->set_flashdata('success', str_replace('%s', 'Event Type', 'New event has been added.'));
redirect(base_url() . 'admin/school-calendar');
// dd($td);
} else if (isset($_POST['updateEvent']) && ($_POST['updateEvent'] == 'Update')) {
$start_date_array = explode('-', $_POST['event_date']);
$ud['title'] = $_POST['title'];
$ud['year'] = $start_date_array[0];
$ud['month'] = $start_date_array[1];
$ud['day'] = $start_date_array[2];
$ud['date'] = $_POST['up_event_date'];
$ud['end_date'] = $_POST['up_event_end_date'];
$ud['event_type'] = $_POST['event_type'];
$ud['remarks'] = $_POST['description'];
$ud['modified_on'] = $this->nepali_current_date;
$ud['modified_by'] = $adminInfo['admin_name'];
$this->db->where('id', $_POST['eventId']);
$update = $this->db->update('school_calendar', $ud);
if ($update) {
$this->session->set_flashdata('success', str_replace('%s', 'Event', 'Event record updated successfully.'));
} else {
$this->session->set_flashdata('danger', str_replace('%s', 'Event', 'Something went wrong. Please try again.'));
}
redirect(base_url() . 'admin/school-calendar');
// dd($_POST);
} else if (isset($_POST['deleteEvent']) && ($_POST['deleteEvent'] == 'Delete')) {
$eventId = $_POST['eventId'];
$this->db->where('id', $eventId);
$delete = $this->db->delete('school_calendar');
$this->session->set_flashdata('success', str_replace('%s', 'Event', 'Event deleted successfully.'));
redirect(base_url() . 'admin/school-calendar');
}
}
$data['event_lists'] = $this->db->query('select * from school_calendar')->result_array();
$data['event_types'] = $this->db->query("select * from school_event_types WHERE is_active='yes'")->result_array();
$dateTimeArray = explode(' ', $this->nepali_current_date);
$data['today_date'] = $dateTimeArray[0];
$data['currency'] = currency_data();
$this->load->view('admin/header', $data);
$this->load->view('admin/school-calendar');
$this->load->view('admin/footer');
}
public function school_event_type()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/school-event-type.php'))
show_404();
$data['title'] = 'Event Types';
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['courses'] = $this->Admin_model->get_courses();
$data['batch'] = $this->Admin_model->get_batch();
$data['result'] = $this->db->query('select * from school_settings where id= 1')->row_array();
if ($_POST > 0) {
if (isset($_POST['addEventType']) && ($_POST['addEventType'] == 'Add')) {
// dd($_POST);
$eventTitle = $_POST['title'];
$isUnique = $this->Admin_model->get_unique_name_main_db('title', $eventTitle, 'school_event_types');
if ($isUnique) {
$in_data['title'] = $eventTitle;
$in_data['is_active'] = 'yes';
$in_data['created_on'] = $this->nepali_current_date;
$in_data['modified_on'] = $this->nepali_current_date;
$this->db->insert('school_event_types', $in_data);
$this->session->set_flashdata('success', str_replace('%s', 'Event Type', 'New event type has been added.'));
} else {
$this->session->set_flashdata('danger', str_replace('%s', 'Event Type', 'Event name already exist.'));
}
redirect(base_url() . 'admin/event-types');
} else if (isset($_POST['updateEventType']) && ($_POST['updateEventType'] == 'Update')) {
$eventId = $_POST['eventId'];
$eventTitle = $_POST['title'];
// dd($_POST);
$isUnique = $this->Admin_model->update_unique_name_main_db('title', $eventTitle, 'school_event_types', $eventId);
if ($isUnique) {
$up_data['title'] = $eventTitle;
$up_data['is_active'] = $_POST['is_active'];
$up_data['modified_on'] = $this->nepali_current_date;
$this->db->where('id', $eventId);
$this->db->update('school_event_types', $up_data);
$this->session->set_flashdata('success', str_replace('%s', 'Event Type', 'Event details has been updated successfully.'));
} else {
$this->session->set_flashdata('danger', str_replace('%s', 'Event Type', 'Event name already exist.'));
}
redirect(base_url() . 'admin/event-types');
} else if (isset($_POST['deleteEventType']) && ($_POST['deleteEventType'] == 'Delete')) {
$eventId = $_POST['eventId'];
$events = $this->db->query("SELECT * FROM school_calendar WHERE event_type=$eventId")->result_array();
if (empty($events)) {
$this->db->where('id', $eventId);
$delete = $this->db->delete('school_event_types');
if ($delete) {
$this->session->set_flashdata('success', str_replace('%s', 'Event Type', 'Event type deleted successfully.'));
}
} else {
$this->session->set_flashdata('danger', str_replace('%s', 'Event Type', 'Event existed with this event type. Please delete events link with it.'));
}
redirect(base_url() . 'admin/event-types');
}
}
$data['event_type_list'] = $this->db->query('select * from school_event_types')->result_array();
$dateTimeArray = explode(' ', $this->nepali_current_date);
$data['today_date'] = $dateTimeArray[0];
$data['currency'] = currency_data();
$this->load->view('admin/header', $data);
$this->load->view('admin/school-event-type');
$this->load->view('admin/footer');
}
public function designation()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$data['currentURL'] = current_url();
$data['title'] = 'Designations';
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$hr_db = $this->load->database('hr', TRUE);
if (isset($_POST['addDesignation']) && $_POST['addDesignation'] == 'Add') {
$designationTitle = $_POST['title'];
$isUnique = $this->Admin_model->get_unique_name('title', $designationTitle, 'hr_designation');
if ($isUnique) {
$in_data['title'] = $designationTitle;
$in_data['is_active'] = 'yes';
$in_data['created_on'] = $this->nepali_current_date;
$in_data['modified_on'] = $this->nepali_current_date;
$hr_db->insert('hr_designation', $in_data);
$this->session->set_flashdata('success', str_replace('%s', 'Designation', 'New designation has been added.'));
} else {
$this->session->set_flashdata('danger', str_replace('%s', 'Designation', 'Designation title already exist.'));
}
redirect(base_url() . 'admin/designation');
} else if (isset($_POST['updateDesignation']) && $_POST['updateDesignation'] == 'Update') {
$designationTitle = $_POST['title'];
$designationId = $_POST['designationId'];
$update_data = array(
'title' => $designationTitle,
'is_active' => $_POST['is_active'],
'modified_on' => $this->nepali_current_date,
);
$hr_db->where('id', $designationId);
$update = $hr_db->update("hr_designation", $update_data);
if ($update) {
$this->session->set_flashdata('success', str_replace('%s', 'Designation', 'Designation has been updated successfully.'));
} else {
$this->session->set_flashdata('danger', str_replace('%s', 'Designation', 'THE_ADD_ERROR_MSG'));
}
redirect(base_url() . 'admin/designation');
}
$query = $hr_db->query('select * from hr_designation');
$data['designation_list'] = $query->result_array();
// $this->load->view('bustracking-admin/common/left-menu', $data);
// $this->load->view('bustracking-admin/common/header', $data);
// $this->load->view('bustracking-admin/designation', $data);
$this->load->view('admin/header', $data);
$this->load->view('admin/designation', $data);
$this->load->view('admin/footer');
}
public function department()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$data['currentURL'] = current_url();
$data['title'] = 'Departments';
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$hr_db = $this->load->database('hr', TRUE);
if (isset($_POST['addDepartment']) && $_POST['addDepartment'] == 'Add') {
$departmentTitle = $_POST['title'];
$isUnique = $this->Admin_model->get_unique_name('title', $departmentTitle, 'hr_department');
// echo '<pre>';
// print_r($isUnique);
if ($isUnique) {
$in_data['title'] = $departmentTitle;
$in_data['is_active'] = 'yes';
$in_data['created_on'] = $this->nepali_current_date;
$in_data['modified_on'] = $this->nepali_current_date;
$hr_db->insert('hr_department', $in_data);
$this->session->set_flashdata('success', str_replace('%s', 'Department', 'New department has been added.'));
} else {
$this->session->set_flashdata('danger', str_replace('%s', 'Department', 'Department title already exist.'));
}
redirect(base_url() . 'admin/department');
} else if (isset($_POST['updateDepartment']) && $_POST['updateDepartment'] == 'Update') {
$departmentTitle = $_POST['title'];
$departmentId = $_POST['departmentId'];
$update_data = array(
'title' => $departmentTitle,
'is_active' => $_POST['is_active'],
'modified_on' => $this->nepali_current_date,
);
$hr_db->where('id', $departmentId);
$update = $hr_db->update("hr_department", $update_data);
if ($update) {
$this->session->set_flashdata('success', str_replace('%s', 'Department', 'Department has been updated successfully.'));
} else {
$this->session->set_flashdata('danger', str_replace('%s', 'Department', 'THE_ADD_ERROR_MSG'));
}
redirect(base_url() . 'admin/department');
}
$query = $hr_db->query('select * from hr_department');
$data['department_list'] = $query->result_array();
$this->load->view('admin/header', $data);
$this->load->view('admin/department', $data);
$this->load->view('admin/footer');
}
public function staff_roles()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
$data['currentURL'] = current_url();
$data['title'] = 'Staff Roles';
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['logo'] = $this->Admin_model->get_logo();
$hr_db = $this->load->database('hr', TRUE);
if (isset($_POST['addStaffRole']) && $_POST['addStaffRole'] == 'Add') {
$staffRoleTitle = $_POST['title'];
$isUnique = $this->Admin_model->get_unique_name('title', $staffRoleTitle, 'staff_roles');
// echo '<pre>';
// print_r($isUnique);
if ($isUnique) {
$in_data['title'] = $staffRoleTitle;
$in_data['is_active'] = 'yes';
$in_data['created_on'] = $this->nepali_current_date;
$in_data['modified_on'] = $this->nepali_current_date;
$hr_db->insert('staff_roles', $in_data);
$this->session->set_flashdata('success', str_replace('%s', 'Role', 'New has been added.'));
} else {
$this->session->set_flashdata('danger', str_replace('%s', 'Role', 'Role already exist.'));
}
redirect(base_url() . 'admin/staff-roles');
} else if (isset($_POST['updateStaffRole']) && $_POST['updateStaffRole'] == 'Update') {
// var_dump($_POST);
// exit();
$staffRoleTitle = $_POST['title'];
$staffRoleId = $_POST['roleId'];
$update_data = array(
'title' => $staffRoleTitle,
'is_active' => $_POST['is_active'],
'modified_on' => $this->nepali_current_date,
);
$hr_db->where('id', $staffRoleId);
$update = $hr_db->update("staff_roles", $update_data);
if ($update) {
$this->session->set_flashdata('success', str_replace('%s', 'Roles', 'Role has been updated successfully.'));
} else {
$this->session->set_flashdata('danger', str_replace('%s', 'Roles', 'THE_ADD_ERROR_MSG'));
}
redirect(base_url() . 'admin/staff-roles');
}
$query = $hr_db->query('select * from staff_roles');
$data['staffRole_list'] = $query->result_array();
$this->load->view('admin/header', $data);
$this->load->view('admin/staff-roles', $data);
$this->load->view('admin/footer');
}
public function school_administration()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/school-administration.php'))
show_404();
$data['title'] = 'School Administration';
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['courses'] = $this->Admin_model->get_courses();
$data['batch'] = $this->Admin_model->get_batch();
$data['result'] = $this->db->query('select * from school_settings where id= 1')->row_array();
// $rst=$this->db->query("SELECT invoice_no FROM `student_fee_online_transactions` ORDER BY id DESC")->row_array();
// if(!empty($rst)){
// $data['new_invoice_no']=(isset($rst['invoice_no']) && !empty($rst['invoice_no'])) ? $rst['invoice_no'] :"0000";
// }
$data['currency'] = currency_data();
$this->load->view('admin/header', $data);
$this->load->view('admin/school-administration');
$this->load->view('admin/footer');
}
public function school_staffs()
{
if (isset($_SESSION['admin_id'])) {
$tid = '';
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
$staffs = $this->Admin_model->get_staff($tid);
foreach ($staffs as $key => $value) {
$filePath = 'assets_admin/images/teacher-profile/' . $value['photo'];
if (file_exists($filePath)) {
$staffs[$key]['profile_pic'] = base_url() . 'assets_admin/images/teacher-profile/' . $value['photo'];
} else {
$staffs[$key]['profile_pic'] = base_url() . 'common_assets/No-Image.jpg';
}
}
$data['staffs'] = $staffs;
$hr_db = $this->load->database('hr', TRUE);
$hr_roles = $hr_db->query("SELECT * from staff_roles where is_active = 'yes'")->result_array();
$hr_designation = $hr_db->query("SELECT * from hr_designation where is_active = 'yes'")->result_array();
$data['hr_designation'] = $hr_designation;
$data['hr_roles'] = $hr_roles;
$this->load->view('admin/header', $data);
$this->load->view('admin/staffs');
$this->load->view('admin/footer');
}
}
public function add_edit_staff($tid = NULL)
{
if (isset($_SESSION['admin_id'])) {
$data['tid'] = $tid;
$data['currentURL'] = current_url();
//get logo
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
//get menu list
$data['menulist'] = $this->Admin_model->get_adminMenu();
//shankar code start here /
$data['subject_list'] = $this->Admin_model->get_subjects();
$data['assign_subjects'] = array('0');
//shankar code end here
if ($tid > 0) {
$data['detail'] = $this->Admin_model->get_teacher($tid);
//shankar code start here
$data['subjects'] = $this->Admin_model->get_teacher($tid, 1);
$dat = array();
foreach ($data['subjects'] as $key => $val) {
array_push($dat, $val['id']);
}
$data['assign_subjects'] = $dat;
//shankar code end here
}
$hr_db = $this->load->database('hr', TRUE);
$hr_roles = $hr_db->query("SELECT * from staff_roles where is_active = 'yes'")->result_array();
$hr_designation = $hr_db->query("SELECT * from hr_designation where is_active = 'yes'")->result_array();
$data['hr_designation'] = $hr_designation;
$data['hr_roles'] = $hr_roles;
// dd($hr_designation);
$this->load->view('admin/header', $data);
$this->load->view('admin/add-edit-staff');
$this->load->view('admin/footer');
}
}
public function dowmloadApplictionForm()
{
$this->load->library('m_pdf');
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['issue_date'] = $this->nepali_current_date;
$data['courses'] = $this->db->query("SELECT * FROM course WHERE is_active = 'yes'")->result_array();
// dd($data['school_info']);
$html = $this->load->view('admin/admission_form', $data, true);
$pdfFilePath = 'Admission Form' . '-' . date('YmdHis') . ".pdf";
$pdf = $this->m_pdf->loadforAdmissionForm();
// $stylesheet = file_get_contents('assets_admin/css/bootstrap.min.css');
// $pdf->WriteHTML($stylesheet, 1);
$pdf->WriteHTML($html, 2);
$pdf->Output($pdfFilePath, "D");
}
public function dowmloadApplicantApplictionForm()
{
$this->load->library('m_pdf');
// dd($_POST);
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['issue_date'] = $this->nepali_current_date;
$data['courses'] = $this->db->query("SELECT * FROM course WHERE is_active = 'yes'")->result_array();
// dd($data['school_info']);
$data['applicant'] = $this->db->query("SELECT * FROM applications WHERE id = " . $_POST['applicant_id'])->row_array();
$html = $this->load->view('admin/applicant_admission_form', $data, true);
$pdfFilePath = 'Admission Form' . '-' . date('YmdHis') . ".pdf";
$pdf = $this->m_pdf->loadforAdmissionForm();
// $stylesheet = file_get_contents('assets_admin/css/bootstrap.min.css');
// $pdf->WriteHTML($stylesheet, 1);
$pdf->WriteHTML($html, 2);
$pdf->Output($pdfFilePath, "D");
}
function classroom_schedule()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/classroom_schedule.php'))
show_404();
$theCourseSubjects = array();
$theBatchId = '';
$studntinfo = [];
$sectionId = '';
$courseId = '';
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['title'] = "Assign Fees";
$data['courses'] = $this->Admin_model->get_courses();
//echo '<pre>'; print_r($data['courses']);exit;
$school_info = $this->Admin_model->get_logo_from_setting();
$data['school_info'] = $school_info;
$data['nepali_months'] = $this->db->query("Select * from nepali_months")->result_array();
$adminInfo = $this->db->query("SELECT * FROM admin WHERE id =" . $_SESSION['admin_id'])->row_array();
$theResult = array();
$weekDays = $this->db->query("Select * from week_days")->result_array();
if (isset($school_info['batch_id']))
$theBatchId = (!empty($school_info['batch_id'])) ? $school_info['batch_id'] : 0;
if ($this->input->post('filterSubmit') == "Filter") {
$obj = new NepaliDate();
$condtion = '';
$theBatchId = (isset($_POST['f_batch']) && !empty($_POST['f_batch'])) ? $_POST['f_batch'] : $school_info['batch_id'];
$courseId = (isset($_POST['filter-course']) && !empty($_POST['filter-course'])) ? $_POST['filter-course'] : '';
$sectionId = (isset($_POST['filter-section']) && !empty($_POST['filter-section'])) ? $_POST['filter-section'] : '';
$theCourseSubjects = $this->db->query("Select cs.*, s.subject_name, s.id as subject_id from course_subjects cs JOIN subject s ON s.id = cs.subject_id WHERE cs.course_id = $courseId")->result_array();
$class_schedule_query = "SELECT id,
GROUP_CONCAT(DISTINCT start_time) AS class_start_time,
GROUP_CONCAT(DISTINCT end_time) as class_end_time
FROM classroom_schedule
WHERE batch=$theBatchId AND course=$courseId AND section=$sectionId";
$theResult = $this->db->query($class_schedule_query)->row_array();
if (!empty($theResult['class_start_time'])) {
$class_start_time_array = explode(',', $theResult['class_start_time']);
$class_end_time_array = explode(',', $theResult['class_end_time']);
// dd($theResult);
foreach ($class_start_time_array as $cst_key => $cst_value) {
// echo $cst_value . ' =====> ' . $class_end_time_array[$cst_key] . '<br>';
$theResult['class_schedule'][$cst_key]['batch_id'] = $theBatchId;
$theResult['class_schedule'][$cst_key]['course_id'] = $courseId;
$theResult['class_schedule'][$cst_key]['section_id'] = $sectionId;
$theResult['class_schedule'][$cst_key]['start_time'] = $cst_value;
$theResult['class_schedule'][$cst_key]['end_time'] = $class_end_time_array[$cst_key];
foreach ($weekDays as $wd_key => $wd_value) {
$theResult['class_schedule'][$cst_key]['days'][$wd_key] = $wd_value;
$class_subject_schedule = "SELECT cs.subject, s.subject_name FROM classroom_schedule cs JOIN subject s ON s.id=cs.subject
WHERE cs.start_time = '$cst_value' AND cs.end_time='" . $class_end_time_array[$cst_key] . "' AND cs.day=" . $wd_value['id'] . " AND batch=$theBatchId AND course=$courseId AND section=$sectionId";
$class_subject = $this->db->query($class_subject_schedule)->row_array();
$theResult['class_schedule'][$cst_key]['days'][$wd_key]['subject'] = $class_subject;
}
}
}
// dd($theResult);
}
if ((isset($_POST['addClassSchedule'])) && ($_POST['addClassSchedule'] == 'Save')) {
$theBatchId = (isset($_POST['selectedBatchId']) && !empty($_POST['selectedBatchId'])) ? $_POST['selectedBatchId'] : $school_info['batch_id'];
$courseId = (isset($_POST['selectedCourseId']) && !empty($_POST['selectedCourseId'])) ? $_POST['selectedCourseId'] : '';
$sectionId = (isset($_POST['selectedSectionId']) && !empty($_POST['selectedSectionId'])) ? $_POST['selectedSectionId'] : '';
$days = $_POST['days'];
$startTime = $_POST['class_start_time'];
$endTime = $_POST['class_end_time'];
$subject = $_POST['subject'];
$classroom = $this->db->query("SELECT * FROM classroom WHERE course_id=$courseId AND section_id=$sectionId")->row_array();
$insert_array = array();
foreach ($days as $key => $day) {
$td['day'] = $day;
$td['start_time'] = $startTime;
$td['end_time'] = $endTime;
$td['subject'] = $subject;
$td['course'] = $courseId;
$td['section'] = $sectionId;
$td['batch'] = $theBatchId;
$td['classroom'] = $classroom['id'];
$td['created_on'] = $this->nepali_current_date;
$td['created_by'] = $adminInfo['admin_name'];
$td['modified_on'] = $this->nepali_current_date;
$td['modified_by'] = $adminInfo['admin_name'];
// echo '<pre>';
// print_r($td);
$insert = $this->db->insert('classroom_schedule', $td);
if ($insert) {
array_push($insert_array, true);
} else {
array_push($insert_array, true);
}
}
if (!in_array(false, $insert_array)) {
$this->session->set_flashdata('success', 'Record has been inserted Successfully.');
} else {
$this->session->set_flashdata('error', 'Something Went Wrong. Please try again later');
}
// redirect('admin/classroom-schedule');
// dd($insert_array);
$class_schedule_query = "SELECT id,
GROUP_CONCAT(DISTINCT start_time) AS class_start_time,
GROUP_CONCAT(DISTINCT end_time) as class_end_time
FROM classroom_schedule
WHERE batch=$theBatchId AND course=$courseId AND section=$sectionId";
$theResult = $this->db->query($class_schedule_query)->row_array();
$class_start_time_array = explode(',', $theResult['class_start_time']);
$class_end_time_array = explode(',', $theResult['class_end_time']);
foreach ($class_start_time_array as $cst_key => $cst_value) {
// echo $cst_value . ' =====> ' . $class_end_time_array[$cst_key] . '<br>';
$theResult['class_schedule'][$cst_key]['start_time'] = $cst_value;
$theResult['class_schedule'][$cst_key]['end_time'] = $class_end_time_array[$cst_key];
foreach ($weekDays as $wd_key => $wd_value) {
$theResult['class_schedule'][$cst_key]['days'][$wd_key] = $wd_value;
$class_subject_schedule = "SELECT cs.subject, s.subject_name FROM classroom_schedule cs JOIN subject s ON s.id=cs.subject
WHERE cs.start_time = '$cst_value' AND cs.end_time='" . $class_end_time_array[$cst_key] . "' AND cs.day=" . $wd_value['id'] . " AND batch=$theBatchId AND course=$courseId AND section=$sectionId";
$class_subject = $this->db->query($class_subject_schedule)->row_array();
$theResult['class_schedule'][$cst_key]['batch_id'] = $theBatchId;
$theResult['class_schedule'][$cst_key]['course_id'] = $courseId;
$theResult['class_schedule'][$cst_key]['section_id'] = $sectionId;
$theResult['class_schedule'][$cst_key]['days'][$wd_key]['subject'] = $class_subject;
}
}
$theCourseSubjects = $this->db->query("Select cs.*, s.subject_name, s.id as subject_id from course_subjects cs JOIN subject s ON s.id = cs.subject_id WHERE cs.course_id = $courseId")->result_array();
}
if ((isset($_POST['d_action'])) && ($_POST['d_action'] == 'deleteSchedule')) {
$theBatchId = $_POST['batch_id'];
$courseId = $_POST['course_id'];
$sectionId = $_POST['section_id'];
$startTime = $_POST['start_time'];
$endTime = $_POST['end_time'];
$current_class = $this->db->query("SELECT id FROM classroom_schedule WHERE start_time='$startTime' AND end_time='$endTime' AND batch=$theBatchId AND course=$courseId AND section=$sectionId")->result_array();
$delete_array = array();
foreach ($current_class as $c_key => $cc) {
$this->db->where('id', $cc['id']);
$delete = $this->db->delete('classroom_schedule');
// print_r($cc);
if ($delete) {
array_push($delete_array, true);
} else {
array_push($delete_array, false);
}
}
if (!(in_array(false, $delete_array))) {
$this->session->set_flashdata('success', 'Record has been deleted Successfully.');
} else {
$this->session->set_flashdata('error', 'Something Went Wrong. Please try again later');
}
$class_schedule_query = "SELECT id,
GROUP_CONCAT(DISTINCT start_time) AS class_start_time,
GROUP_CONCAT(DISTINCT end_time) as class_end_time
FROM classroom_schedule
WHERE batch=$theBatchId AND course=$courseId AND section=$sectionId";
$theResult = $this->db->query($class_schedule_query)->row_array();
if (empty($theResult['id'])) {
$theResult = [];
$class_start_time_array = [];
$class_end_time_array = [];
} else {
$class_start_time_array = explode(',', $theResult['class_start_time']);
$class_end_time_array = explode(',', $theResult['class_end_time']);
}
// dd($theResult);
foreach ($class_start_time_array as $cst_key => $cst_value) {
// echo $cst_value . ' =====> ' . $class_end_time_array[$cst_key] . '<br>';
if (!empty($theResult['id'])) {
$theResult['class_schedule'][$cst_key]['start_time'] = $cst_value;
$theResult['class_schedule'][$cst_key]['end_time'] = $class_end_time_array[$cst_key];
foreach ($weekDays as $wd_key => $wd_value) {
$theResult['class_schedule'][$cst_key]['days'][$wd_key] = $wd_value;
$class_subject_schedule = "SELECT cs.subject, s.subject_name FROM classroom_schedule cs JOIN subject s ON s.id=cs.subject
WHERE cs.start_time = '$cst_value' AND cs.end_time='" . $class_end_time_array[$cst_key] . "' AND cs.day=" . $wd_value['id'] . " AND batch=$theBatchId AND course=$courseId AND section=$sectionId";
$class_subject = $this->db->query($class_subject_schedule)->row_array();
$theResult['class_schedule'][$cst_key]['batch_id'] = $theBatchId;
$theResult['class_schedule'][$cst_key]['course_id'] = $courseId;
$theResult['class_schedule'][$cst_key]['section_id'] = $sectionId;
$theResult['class_schedule'][$cst_key]['days'][$wd_key]['subject'] = $class_subject;
}
}
}
$theCourseSubjects = $this->db->query("Select cs.*, s.subject_name, s.id as subject_id from course_subjects cs JOIN subject s ON s.id = cs.subject_id WHERE cs.course_id = $courseId")->result_array();
}
// dd($theResult);
$data['course_subjects'] = $theCourseSubjects;
$data['week_days'] = $weekDays;
$data['section'] = $sectionId;
$data['course'] = $courseId;
$data['class_schedule'] = $theResult;
// dd($theResult);
$data['theBatchId'] = $theBatchId;
$batches = $this->Admin_model->get_table_info('batch', array('is_active' => 'yes'));
$data['batches'] = $batches;
$this->load->view('admin/header', $data);
$this->load->view('admin/classroom_schedule', $data);
$this->load->view('admin/footer');
}
function classroom_schedule_update($url_params)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/classroom_schedule.php'))
show_404();
$theCourseSubjects = array();
$theBatchId = '';
$studntinfo = [];
$sectionId = '';
$courseId = '';
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['courses'] = $this->Admin_model->get_courses();
//echo '<pre>'; print_r($data['courses']);exit;
$school_info = $this->Admin_model->get_logo_from_setting();
$data['school_info'] = $school_info;
$data['nepali_months'] = $this->db->query("Select * from nepali_months")->result_array();
$adminInfo = $this->db->query("SELECT * FROM admin WHERE id =" . $_SESSION['admin_id'])->row_array();
$theResult = array();
$weekDays = $this->db->query("Select * from week_days")->result_array();
//
$param_arr = unserialize(urldecode($url_params));
$theBatchId = $param_arr['batch_id'];
$sectionId = $param_arr['section_id'];
$courseId = $param_arr['course_id'];
$start_time = $param_arr['start_time'];
$end_time = $param_arr['end_time'];
if ($_POST > 0) {
if (isset($_POST['schedule_update']) && ($_POST['schedule_update'] == 'Save')) {
// $isUnique = $this->Admin_model->get_unique_name_main_db('classroom_schedule', $_POST['class_start_time'], 'start_time');
// if($isUnique){}
$class_start_time = date('h:i:s', strtotime($_POST['class_start_time']));
// strtotime($_POST['class_start_time']);
$class_end_time = date('h:i:s', strtotime($_POST['class_end_time']));
$theBatchId = $_POST['batch_id'];
$courseId = $_POST['course_id'];
$sectionId = $_POST['section_id'];
$class_schedule_query = "SELECT id,
GROUP_CONCAT(DISTINCT start_time) AS class_start_time,
GROUP_CONCAT(DISTINCT end_time) as class_end_time
FROM classroom_schedule
WHERE batch=$theBatchId AND course=$courseId AND section=$sectionId";
$schedules = $this->db->query($class_schedule_query)->row_array();
$previos_class_start_times = explode(',', $schedules['class_start_time']);
$previos_class_end_times = explode(',', $schedules['class_end_time']);
foreach ($previos_class_start_times as $p_key => $pc_value) {
// echo ($pc_value . ' => ' . $class_start_time . '<br>');
$pc_startTime = date('h:i:s', strtotime($pc_value));
$pcEndTime = date('h:i:s', strtotime($previos_class_end_times[$p_key]));
$subjects = $_POST['subject'];
foreach ($subjects as $s_key => $subject) {
$current_class = $this->db->query("SELECT id FROM classroom_schedule WHERE start_time='$pc_startTime' AND end_time='$pcEndTime' AND day=" . $s_key . " AND batch=$theBatchId AND course=$courseId AND section=$sectionId")->row_array();
if (!empty($current_class)) {
// echo $subject . ' => ' . $current_class['id'] . '<br>';
$ud['start_time'] = $_POST['class_start_time'];
$ud['end_time'] = $_POST['class_end_time'];
$ud['subject'] = $subject;
$ud['modified_on'] = $this->nepali_current_date;
$ud['modified_by'] = $adminInfo['admin_name'];
$ud['id'] = $current_class['id'];
// echo '<pre>';
// print_r($ud);
$this->db->where('id', $current_class['id']);
$update = $this->db->update('classroom_schedule', $ud);
} else {
$classroom = $this->db->query("SELECT * FROM classroom WHERE course_id=$courseId AND section_id=$sectionId")->row_array();
$td['day'] = $s_key;
$td['start_time'] = $_POST['class_start_time'];
$td['end_time'] = $_POST['class_end_time'];
$td['subject'] = $subject;
$td['course'] = $courseId;
$td['section'] = $sectionId;
$td['batch'] = $theBatchId;
$td['classroom'] = $classroom['id'];
$td['created_on'] = $this->nepali_current_date;
$td['created_by'] = $adminInfo['admin_name'];
$td['modified_on'] = $this->nepali_current_date;
$td['modified_by'] = $adminInfo['admin_name'];
// echo '<pre>';
// print_r($td);
$insert = $this->db->insert('classroom_schedule', $td);
if ($insert) {
array_push($insert_array, true);
} else {
array_push($insert_array, true);
}
}
}
// }
// }
// dd($_POST);
$url_params = array(
'batch_id' => $_POST['batch_id'],
'course_id' => $_POST['course_id'],
'section_id' => $_POST['section_id'],
'start_time' => $_POST['class_start_time'],
'end_time' => $_POST['class_end_time']
);
$this->session->set_flashdata('success', 'The schedule updated successfully.');
redirect('admin/classroom-schedule-update/' . urlencode(serialize($url_params)));
}
}
}
$classroom_schedule = $this->db->query("SELECT * FROM classroom_schedule WHERE start_time='$start_time' AND end_time='$end_time' AND course=$courseId AND section=$sectionId AND batch=$theBatchId")->result_array();
$classroom = $this->db->query("SELECT * FROM classroom WHERE course_id=$courseId AND section_id=$sectionId")->row_array();
$theCourseSubjects = $this->db->query("Select cs.*, s.subject_name, s.id as subject_id from course_subjects cs JOIN subject s ON s.id = cs.subject_id WHERE cs.course_id = $courseId")->result_array();
$data['course_subjects'] = $theCourseSubjects;
$data['week_days'] = $weekDays;
$data['section'] = $sectionId;
$data['course'] = $courseId;
$data['classroom'] = $classroom;
$data['url_params'] = $url_params;
$data['start_time'] = $start_time;
$data['end_time'] = $end_time;
$data['class_schedule'] = $classroom_schedule;
$data['theBatchId'] = $theBatchId;
$batches = $this->Admin_model->get_table_info('batch', array('is_active' => 'yes'));
$data['batches'] = $batches;
$this->load->view('admin/header', $data);
$this->load->view('admin/classroom_schedule_update', $data);
$this->load->view('admin/footer');
}
function assign_student_fees($url_params)
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/assign-all-fees-student.php'))
show_404();
$theStudents = array();
$theFees = array();
$theBatchId = '';
$feestype = array();
$studntinfo = [];
$studntinfo1 = [];
$studntRouteInfo = [];
$studntRouteInfo1 = [];
$sectionId = '';
$courseId = '';
$filterRouteId = '';
$dateFrom = '';
$feestypes = [];
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$data['title'] = "Assign Fees";
$data['courses'] = $this->Admin_model->get_courses();
//echo '<pre>'; print_r($data['courses']);exit;
$school_info = $this->Admin_model->get_logo_from_setting();
$data['school_info'] = $school_info;
if (isset($school_info['batch_id']))
$theBatchId = (!empty($school_info['batch_id'])) ? $school_info['batch_id'] : 0;
$param_arr = unserialize(urldecode($url_params));
$theBatchId = $param_arr['batch_id'];
$theCourseId = $param_arr['course_id'];
$theSectionId = $param_arr['section_id'];
$theStudentd = $param_arr['student_id'];
$student_info_query = "SELECT s.id as student_id, s.name, s.email, s.studentId, s.photo, s.bus_routeid, s.hostel_plan_id, s.gender, s.emergency_contact_number, s.dob, cl.classroom_name,b.id as batch_id, cl.course_id, b.b_name, sb.roll_no FROM students s
JOIN student_batch sb ON sb.student_id = $theStudentd AND sb.batch_id = $theBatchId
JOIN batch b ON b.id = $theBatchId
JOIN classroom cl ON cl.id = sb.classroom_id WHERE s.id =$theStudentd ORDER BY sb.id DESC";
$student_info = $this->db->query($student_info_query)->row_array();
// echo $student_info_query;
$course_fees_types_query = "SELECT DISTINCT cf.fees_type FROM course_fees cf WHERE cf.course_id = $theCourseId AND cf.batch_id = $theBatchId";
$course_fee_types = $this->db->query($course_fees_types_query)->result_array();
foreach ($course_fee_types as $cft_key => $cf_type) {
$fee_type = $this->db->query("SELECT * FROM fee_types WHERE id = " . $cf_type['fees_type'])->row_array();
$course_fees_query = "";
// For transport fee
// if($student_info['bus_routeid'] > 0){
// }
if (($cf_type['fees_type'] == 4)) {
if ($student_info['bus_routeid'] > 0) {
$course_fees_query = "SELECT cf.* FROM course_fees cf WHERE cf.course_id = $theCourseId AND cf.batch_id = $theBatchId AND cf.fees_type = " . $cf_type['fees_type'] . " AND route_id = " . $student_info['bus_routeid'];
$course_fees = $this->db->query($course_fees_query)->result_array();
$student_info['course_fees'][$cf_type['fees_type']]['fee_title'] = $fee_type['feetype_name'];
$student_info['course_fees'][$cf_type['fees_type']]['fees'] = $course_fees;
foreach ($course_fees as $cf_key => $cf_value) {
$fee_assign_query = "SELECT * FROM fee_assigned_students WHERE student_id = $theStudentd AND course_fee_id = " . $cf_value['id'];
$assigned_fee = $this->db->query($fee_assign_query)->row_array();
// Looking if the fee is assigned or not
if (!empty($assigned_fee)) {
$student_info['course_fees'][$cf_type['fees_type']]['fees'][$cf_key]['assigned'] = 'yes';
$student_info['course_fees'][$cf_type['fees_type']]['fees'][$cf_key]['fee_assigned_id'] = $assigned_fee['id'];
} else {
$student_info['course_fees'][$cf_type['fees_type']]['fees'][$cf_key]['assigned'] = 'no';
$student_info['course_fees'][$cf_type['fees_type']]['fees'][$cf_key]['fee_assigned_id'] = 0;
}
// Checking if the payment has been made or not.
$fee_online_payment_query = "SELECT * FROM students_online_payments WHERE student_id = $theStudentd AND course_fee_id = " . $cf_value['id'];
$student_online_payment = $this->db->query($fee_online_payment_query)->row_array();
if (!empty($assigned_fee)) {
$student_info['course_fees'][$cf_type['fees_type']]['fees'][$cf_key]['payment'] = 'yes';
$student_info['course_fees'][$cf_type['fees_type']]['fees'][$cf_key]['sop_id'] = isset($student_online_payment) ? $student_online_payment['id'] : 0;
} else {
$student_info['course_fees'][$cf_type['fees_type']]['fees'][$cf_key]['payment'] = 'no';
$student_info['course_fees'][$cf_type['fees_type']]['fees'][$cf_key]['sop_id'] = 0;
}
// print_r($assigned_fee);
}
}
} else {
$course_fees_query = "SELECT cf.* FROM course_fees cf WHERE cf.course_id = $theCourseId AND cf.batch_id = $theBatchId AND cf.fees_type = " . $cf_type['fees_type'];
$course_fees = $this->db->query($course_fees_query)->result_array();
$student_info['course_fees'][$cf_type['fees_type']]['fee_title'] = $fee_type['feetype_name'];
$student_info['course_fees'][$cf_type['fees_type']]['fees'] = $course_fees;
foreach ($course_fees as $cf_key => $cf_value) {
$fee_assign_query = "SELECT * FROM fee_assigned_students WHERE student_id = $theStudentd AND course_fee_id = " . $cf_value['id'];
$assigned_fee = $this->db->query($fee_assign_query)->row_array();
// Looking if the fee is assigned or not
if (!empty($assigned_fee)) {
$student_info['course_fees'][$cf_type['fees_type']]['fees'][$cf_key]['assigned'] = 'yes';
$student_info['course_fees'][$cf_type['fees_type']]['fees'][$cf_key]['fee_assigned_id'] = $assigned_fee['id'];
} else {
$student_info['course_fees'][$cf_type['fees_type']]['fees'][$cf_key]['assigned'] = 'no';
$student_info['course_fees'][$cf_type['fees_type']]['fees'][$cf_key]['fee_assigned_id'] = 0;
}
// Checking if the payment has been made or not.
$fee_online_payment_query = "SELECT * FROM students_online_payments WHERE student_id = $theStudentd AND course_fee_id = " . $cf_value['id'];
$student_online_payment = $this->db->query($fee_online_payment_query)->row_array();
if (!empty($student_online_payment)) {
$student_info['course_fees'][$cf_type['fees_type']]['fees'][$cf_key]['payment'] = 'yes';
$student_info['course_fees'][$cf_type['fees_type']]['fees'][$cf_key]['sop_id'] = isset($student_online_payment) ? $student_online_payment['id'] : 0;
} else {
$student_info['course_fees'][$cf_type['fees_type']]['fees'][$cf_key]['payment'] = 'no';
$student_info['course_fees'][$cf_type['fees_type']]['fees'][$cf_key]['sop_id'] = 0;
}
// print_r($assigned_fee);
}
}
}
if ($_POST > 0) {
if (isset($_POST['assigntostudents']) && $_POST['assigntostudents'] == 'Update') {
//
$course_fees = isset($_POST['course_fees_id']) ? $_POST['course_fees_id'] : [];
$fees_assigned = isset($_POST['course_fees_assigned_id']) ? $_POST['course_fees_assigned_id'] : [];
$fees_payment_status = isset($_POST['course_fees_payment_status']) ? $_POST['course_fees_payment_status'] : [];
$assigned_fees = isset($_POST['fees']) ? $_POST['fees'] : [];
$update_array = array();
foreach ($course_fees as $cf_key => $cf_value) {
// echo $cf_value . ' => ' . $fees_assigned[$cf_value] . ' => ' . $fees_payment_status[$cf_value];
// Deleting previous assigned fees
if ($fees_payment_status[$cf_value] == 'no') {
if ($fees_assigned[$cf_value] > 0) {
// echo '<br>' . 'Delete id ' . $fees_assigned[$cf_value] . '<br>';
$this->db->where('id', $fees_assigned[$cf_value]);
$this->db->delete('fee_assigned_students');
}
}
// End of Deleting previous assigned fees
if (isset($assigned_fees[$cf_value])) {
// echo ' => ' . $assigned_fees[$cf_value] . '<br>';
$td['student_id'] = $_POST['student_id'];
$td['course_fee_id'] = $cf_value;
$td['created_at'] = $this->nepali_current_date;
$insert = $this->db->insert('fee_assigned_students', $td);
if ($insert) {
array_push($update_array, true);
} else {
array_push($update_array, false);
}
}
// echo ' =============================================== <br>';
}
if (in_array(true, $update_array)) {
$this->session->set_flashdata('success', 'Student fees updated successfully.');
} else {
$this->session->set_flashdata('danger', 'Fee update unsuccessful.');
}
redirect('admin/student-fees/' . $url_params);
// dd($_POST);
}
}
// dd($student_info);
$data['url_params'] = $url_params;
$data['theBatchId'] = $theBatchId;
$data['theStudentInfo'] = $student_info;
$this->load->view('admin/header', $data);
$this->load->view('admin/assign-all-fees-student', $data);
$this->load->view('admin/footer');
}
public function accounting_ledgers()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/accounting-ledgers.php'))
show_404();
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$condition = '';
$studentlist = array();
$batches = $this->Admin_model->get_table_info('batch', array('is_active' => 'yes'));
$data['batches'] = $batches;
$courses = $this->Admin_model->get_table_info('course', '', '', 'ASC');
$data['course'] = $courses;
$fees_types_list = $this->Admin_model->get_fees_type();
$data['fees_types'] = $fees_types_list;
$user_type = 'student';
if (count($_POST)) {
$user_type = $_POST['f_user_type'];
if ($_POST['f_user_type'] == 'student') {
$se_batch = (isset($_POST['f_batch']) && !empty($_POST['f_batch'])) ? $_POST['f_batch'] : '';
$se_course = (isset($_POST['f_course']) && !empty($_POST['f_course'])) ? $_POST['f_course'] : '';
$se_section = (isset($_POST['f_section']) && !empty($_POST['f_section'])) ? $_POST['f_section'] : '';
$f_feetype = (isset($_POST['filter_fee_types']) && !empty($_POST['filter_fee_types'])) ? $_POST['filter_fee_types'] : '';
if ($se_course != '')
$condition .= " AND cl.course_id=$se_course";
if ($se_section != '')
$condition .= " AND cl.section_id IN (" . implode(',', $se_section) . ")";
$studentlist = $this->db->query("SELECT s.id as student_id,s.name as student_name,s.course as course_id ,s.batch_id,s.email,s.studentId,s.mobile,s.emergency_contact_name as guardian_name,s.emergency_contact_number as guardian_contact_number,c.course_name,se.id as section_id, se.section_name,sb.id as student_batch_id, sb.roll_no FROM students s
JOIN student_batch sb ON s.id=sb.student_id
JOIN classroom cl ON cl.id=sb.classroom_id
JOIN course c ON c.id=cl.course_id
JOIN section se ON se.id=cl.section_id
WHERE sb.batch_id=$se_batch AND s.is_active ='yes' $condition ORDER BY cl.course_id, cl.section_id, sb.roll_no ")->result_array();
foreach ($studentlist as $key => $std) {
$studentlist[$key]['ledger_account'] = $this->accounting->fetchAccountInfo($std['studentId']);
}
// dd($studentlist);
$data['students'] = $studentlist;
} else {
$tid = '';
$teachers = $this->Admin_model->get_teacher($tid);
foreach ($teachers as $key => $value) {
$filePath = 'assets_admin/images/teacher-profile/' . $value['photo'];
if (file_exists($filePath)) {
$teachers[$key]['profile_pic'] = base_url() . 'assets_admin/images/teacher-profile/' . $value['photo'];
} else {
$teachers[$key]['profile_pic'] = base_url() . 'common_assets/No-Image.jpg';
}
$teachers[$key]['ledger_account'] = $this->accounting->fetchAccountInfo($value['teacherId']);
}
// dd($studentlist);
$data['teacher'] = $teachers;
$hr_db = $this->load->database('hr', TRUE);
$hr_roles = $hr_db->query("SELECT * from staff_roles where is_active = 'yes'")->result_array();
$hr_designation = $hr_db->query("SELECT * from hr_designation where is_active = 'yes'")->result_array();
$data['hr_designation'] = $hr_designation;
$data['hr_roles'] = $hr_roles;
$data['teachers'] = $teachers;
}
// dd($data);
}
$data['user_type'] = $user_type;
$this->load->view('admin/header', $data);
$this->load->view('admin/accounting-ledgers', $data);
$this->load->view('admin/footer');
}
public function createLedgerAccount()
{
// dd($_POST);
$adminInfo = $this->db->query("SELECT * FROM admin WHERE id =" . $_SESSION['admin_id'])->row_array();
$userIds = $this->input->post('contact_list');
$user_type = $this->input->post('user_t');
$course_id = $this->input->post('course_id');
$course_id = !empty($course_id) ? $course_id : 0;
$dobArr = explode('-', date("Y-m-d"));
$dateBS = $this->nepaliDateObject->convertAdToBs($dobArr[0], $dobArr[1], $dobArr[2]);
$t_date = $dateBS['year'] . '-' . sprintf("%02d", $dateBS['month']) . '-' . sprintf("%02d", $dateBS['day']);
$status = array();
foreach ($userIds as $c_key => $userId) {
$username = '';
if ($user_type == 'student') {
$std_info = $this->db->query("SELECT * FROM students WHERE studentId = '$userId'")->row_array();
$username = $std_info['name'];
} else {
$teacher_info = $this->db->query("SELECT * FROM teacher WHERE teacherId = '$userId'")->row_array();
$username = $teacher_info['teacher_name'];
}
$acc_create = $this->accounting->userCreateAcc($userId, $user_type, $username, $t_date);
array_push($status, $acc_create);
}
if (in_array('success', $status)) {
$this->session->set_flashdata('success_msg', str_replace('%s', 'Ledger Account', 'Ledger accounts has been created successfully.'));
} else {
$this->session->set_flashdata('error_msg', str_replace('%s', 'Ledger Account', 'Something went wrong. Please try again later.'));
}
redirect(base_url() . 'admin/accounting-ledgers');
}
public function journal_vouchers()
{
if (!isset($_SESSION['admin_id']))
redirect(base_url() . 'admin');
if (!file_exists(APPPATH . 'views/admin/journal-vouchers.php'))
show_404();
$data['currentURL'] = current_url();
$data['logo'] = $this->Admin_model->get_logo();
$data['school_info'] = $this->Admin_model->get_logo_from_setting();
$data['menulist'] = $this->Admin_model->get_adminMenu();
$condition = '';
$studentlist = array();
$batches = $this->Admin_model->get_table_info('batch', array('is_active' => 'yes'));
$data['batches'] = $batches;
$courses = $this->Admin_model->get_table_info('course', '', '', 'ASC');
$data['course'] = $courses;
$fees_types_list = $this->Admin_model->get_fees_type();
$data['fees_types'] = $fees_types_list;
$user_type = 'student';
if (count($_POST)) {
$user_type = $_POST['f_user_type'];
if ($_POST['f_user_type'] == 'student') {
$se_batch = (isset($_POST['f_batch']) && !empty($_POST['f_batch'])) ? $_POST['f_batch'] : '';
$se_course = (isset($_POST['f_course']) && !empty($_POST['f_course'])) ? $_POST['f_course'] : '';
$se_section = (isset($_POST['f_section']) && !empty($_POST['f_section'])) ? $_POST['f_section'] : '';
$f_feetype = (isset($_POST['filter_fee_types']) && !empty($_POST['filter_fee_types'])) ? $_POST['filter_fee_types'] : '';
if ($se_course != '')
$condition .= " AND cl.course_id=$se_course";
if ($se_section != '')
$condition .= " AND cl.section_id IN (" . implode(',', $se_section) . ")";
$studentlist = $this->db->query("SELECT s.id as student_id,s.name as student_name,s.course as course_id ,s.batch_id,s.email,s.studentId,s.mobile,s.emergency_contact_name as guardian_name,s.emergency_contact_number as guardian_contact_number,c.course_name,se.id as section_id, se.section_name,sb.id as student_batch_id, sb.roll_no FROM students s
JOIN student_batch sb ON s.id=sb.student_id
JOIN classroom cl ON cl.id=sb.classroom_id
JOIN course c ON c.id=cl.course_id
JOIN section se ON se.id=cl.section_id
WHERE sb.batch_id=$se_batch AND s.is_active ='yes' $condition ORDER BY cl.course_id, cl.section_id, sb.roll_no ")->result_array();
foreach ($studentlist as $key => $std) {
$studentlist[$key]['ledger_account'] = $this->accounting->fetchVoucherInfo($std['student_id']);
}
// dd($studentlist);
$data['students'] = $studentlist;
} else {
$tid = '';
$teachers = $this->Admin_model->get_teacher($tid);
foreach ($teachers as $key => $value) {
$filePath = 'assets_admin/images/teacher-profile/' . $value['photo'];
if (file_exists($filePath)) {
$teachers[$key]['profile_pic'] = base_url() . 'assets_admin/images/teacher-profile/' . $value['photo'];
} else {
$teachers[$key]['profile_pic'] = base_url() . 'common_assets/No-Image.jpg';
}
$teachers[$key]['ledger_account'] = $this->accounting->fetchAccountInfo($value['teacherId']);
}
// dd($studentlist);
$data['teacher'] = $teachers;
$hr_db = $this->load->database('hr', TRUE);
$hr_roles = $hr_db->query("SELECT * from staff_roles where is_active = 'yes'")->result_array();
$hr_designation = $hr_db->query("SELECT * from hr_designation where is_active = 'yes'")->result_array();
$data['hr_designation'] = $hr_designation;
$data['hr_roles'] = $hr_roles;
$data['teachers'] = $teachers;
}
// dd($data);
}
$data['all_fee_types'] = $this->Admin_model->get_query_result("SELECT id,feetype_name FROM fee_types WHERE is_active = 'yes'");
$data['user_type'] = $user_type;
$this->load->view('admin/header', $data);
$this->load->view('admin/journal-vouchers', $data);
$this->load->view('admin/footer');
}
public function createVoucher()
{
// dd($_POST);
$adminInfo = $this->db->query("SELECT * FROM admin WHERE id =" . $_SESSION['admin_id'])->row_array();
$userIds = $this->input->post('contact_list');
$user_type = $this->input->post('user_t');
$course_id = $this->input->post('course_id');
$course_id = !empty($course_id) ? $course_id : 0;
$dobArr = explode('-', date("Y-m-d"));
$dateBS = $this->nepaliDateObject->convertAdToBs($dobArr[0], $dobArr[1], $dobArr[2]);
$t_date = $dateBS['year'] . '-' . sprintf("%02d", $dateBS['month']) . '-' . sprintf("%02d", $dateBS['day']);
$status = array();
foreach ($userIds as $c_key => $userId) {
$username = '';
if ($user_type == 'student') {
$std_info = $this->db->query("SELECT * FROM students WHERE studentId = '$userId'")->row_array();
$student = $this->db->query("SELECT s.id as student_id FROM students s WHERE s.studentId='$userId' AND s.is_active ='yes' ")->row_array();
$userId = $student['student_id'];
} else {
$teacher_info = $this->db->query("SELECT * FROM teacher WHERE teacherId = '$userId'")->row_array();
$userId = $teacher_info['id'];
}
$acc_create = $this->accounting->createVoucher($userId, $user_type);
array_push($status, $acc_create);
}
// dd($status);
if (in_array('success', $status)) {
$this->session->set_flashdata('success_msg', str_replace('%s', 'Ledger Account', 'Ledger accounts has been created successfully.'));
} else {
$this->session->set_flashdata('error_msg', str_replace('%s', 'Ledger Account', 'Something went wrong. Please try again later.'));
}
redirect(base_url() . 'admin/journal-vouchers');
}
}