?
Current Path : /home1/savoy/www/savoyeducation.com/application/models/ |
Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 |
Current File : /home1/savoy/www/savoyeducation.com/application/models/Admin_model.php |
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Admin_model extends CI_Model { public function __construct() { parent::__construct(); $this->load->database(); } public function insert_user($data) { $this->db->insert('user_login', $data); return TRUE; } public function login($data) { $this->db->select('id,first_name,email,user_type'); $this->db->from('user_login'); $this->db->where('email', $data['email']); $this->db->where('password', md5($data['password'])); $this->db->limit(1); $query = $this->db->get(); if ($query->num_rows() == 1) { $result = $query->result_array(); $session_data = array( 'email' => $result[0]['email'], 'first_name' => $result[0]['first_name'], 'user_type' => $result[0]['user_type'], 'id' => $this->encrypt->encode($result[0]['id']), ); $this->session->set_userdata('logged_in', $session_data); return TRUE; } else { return false; } } public function fetch_users() { $this->db->select(''); $this->db->from('user_login'); $result = $this->db->get(); return $result->result_array(); } public function delete_users($user_id) { $this->db->where('id', $user_id); $this->db->where('user_type','user'); return $this->db->delete('user_login'); } public function user_permission($id, $data) { $userstatus = array('user_type' => $data); $this->db->where('id', $id); return $this->db->update('user_login', $userstatus); } public function insert_banner($data) { $this->db->insert('banners', $data); return TRUE; } public function banner_listing() { $this->db->select(''); $this->db->from('banners'); $result = $this->db->get(); return $result->result_array(); } public function edit_banner($id) { $this->db->select(''); $this->db->where('id', $id); $this->db->from('banners'); $result = $this->db->get(); return $result->result_array(); } public function update_banner_content($id, $data) { $this->db->where('id', $id); return $this->db->update('banners', $data); } public function delete_banners($id) { $this->db->where('id', $id); return $this->db->delete('banners'); } public function insert_announcement($data) { $this->db->insert('announcements', $data); return TRUE; } public function announcement_listing() { $this->db->select(''); $this->db->from('announcements'); $result = $this->db->get(); return $result->result_array(); } public function edit_announcement($id) { $this->db->select(''); $this->db->where('id', $id); $this->db->from('announcements'); $result = $this->db->get(); return $result->result_array(); } public function update_announcement_content($id, $data) { $this->db->where('id', $id); return $this->db->update('announcements', $data); } public function delete_announcement($id) { $this->db->where('id', $id); return $this->db->delete('announcements'); } public function insert_program($data) { $this->db->insert('Programs', $data); return TRUE; } public function program_listing() { $this->db->select(''); $this->db->from('Programs'); $result = $this->db->get(); return $result->result_array(); } public function edit_program($id) { $this->db->select(''); $this->db->where('id', $id); $this->db->from('Programs'); $result = $this->db->get(); return $result->result_array(); } public function update_program_content($id, $data) { $this->db->where('id', $id); return $this->db->update('Programs', $data); } public function getRows($id = '') { $this->db->select('id,file_name,created'); $this->db->from('program_gallery'); if ($id) { $this->db->where('id', $id); $query = $this->db->get(); $result = $query->row_array(); } else { $this->db->order_by('created', 'desc'); $query = $this->db->get(); $result = $query->result_array(); } return !empty($result) ? $result : false; } public function insert_programgallery($data = array()) { $insert = $this->db->insert_batch('program_gallery', $data); return $insert ? true : false; } public function gallery_list($id) { $this->db->select(''); $this->db->where('program_id', $id); $this->db->from('program_gallery'); $result = $this->db->get(); return $result->result_array(); } public function delete_gallery($id) { $this->db->where('id', $id); return $this->db->delete('program_gallery'); } public function insert_page($data) { $this->db->insert('pages', $data); return TRUE; } public function page_list() { $this->db->select(''); $this->db->from('pages'); $result = $this->db->get(); return $result->result_array(); } public function edit_page($id) { $this->db->select(''); $this->db->where('id', $id); $this->db->from('pages'); $result = $this->db->get(); return $result->result_array(); } public function update_page_content($id, $data) { $this->db->where('id', $id); return $this->db->update('pages', $data); } public function users_count() { $this->db->from('user_login'); $query = $this->db->get(); return $rowcount = $query->num_rows(); } public function announcement_count() { $this->db->from('announcements'); $query = $this->db->get(); return $rowcount = $query->num_rows(); } public function program_count() { $this->db->from('Programs'); $query = $this->db->get(); return $rowcount = $query->num_rows(); } public function forgetChangePassword($id, $data) { $userstatus = array('password' => $data); $this->db->where('email', $id); return $this->db->update('user_login', $userstatus); } public function CheckUserExist($EmailID) { $this->db->select(''); $this->db->from('user_login'); $this->db->where('email', $EmailID); $this->db->limit(1); $query = $this->db->get(); if ($query->num_rows() == 1) { return TRUE; } else { return false; } } public function update_password($username, $old_pass, $new_pass) { $this->db->select('id'); $this->db->from('user_login'); $this->db->where('email', $username); $this->db->where('password', $old_pass); $result = $this->db->get(); $user = $result->result_array(); if (!$user) { return FALSE; } else { $this->db->set('password', $new_pass); $this->db->where('id', $user[0]['id']); $this->db->update('user_login'); return TRUE; } } public function edit_contact_page(){ $this->db->select(''); $this->db->from('contactus'); $this->db->where('id',1); $result = $this->db->get(); return $result->result_array(); } public function contactus_list() { $this->db->select(''); $this->db->where('id', 1); $this->db->from('contactus'); $result = $this->db->get(); return $result->result_array(); } public function update_contact_details($id,$data){ $this->db->where('id', $id); return $this->db->update('contactus', $data); } public function insert_video($data) { $this->db->insert('videos', $data); return TRUE; } public function video_list(){ $this->db->select(''); $this->db->from('videos'); $result = $this->db->get(); return $result->result_array(); } public function edit_video($id){ $this->db->select(''); $this->db->where('id', $id); $this->db->from('videos'); $result = $this->db->get(); return $result->result_array(); } public function update_video_content($id,$data){ $this->db->where('id', $id); return $this->db->update('videos', $data); } public function delete_videos($id){ $this->db->where('id', $id); return $this->db->delete('videos'); } }