?
Current Path : /home1/savoy/public_html/savoyglobal.net/application/models/ |
Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 |
Current File : /home1/savoy/public_html/savoyglobal.net/application/models/adminmodel.php |
<?php class Adminmodel extends CI_Model { function __construct() { parent::__construct(); } function authenticate($username, $password) { $passwordmd5 = md5($password); $query = $this->db->query("select * from user where username='$username' and password='$passwordmd5'"); $data['numrows'] = $query->num_rows(); if ($query->num_rows() > 0) { $result = $query->row(); $data['userid'] = $result->user_id; $data['username'] = $username; return $data; } else return 0; } function add_banner($postdata) { $this->db->trans_begin(); $tbl1Values = array( 'banner_image' => $postdata['banner_image'], 'banner_sort' => $postdata['banner_sort'] ); $this->db->insert('banner', $tbl1Values); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; return $data; } } function update_banner($postdata) { $this->db->trans_begin(); $tbl1Values = array( 'banner_sort' => $postdata['banner_sort'] ); $this->db->where('banner_id', $postdata['banner_id']); $this->db->update('banner', $tbl1Values); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; return $data; } } function add_news($postdata) { $this->db->trans_begin(); $tbl1Values = array( 'news_title' => $postdata['news_title'], 'news_content' => $postdata['news_content'], 'news_target' => $postdata['news_target'], 'news_date' => $this->mastermodel->convertdateformat($postdata['news_date']), 'news_thumbnail' => $postdata['news_thumbnail'] ); $this->db->insert('news', $tbl1Values); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; return $data; } } function update_news($postdata) { $this->db->trans_begin(); $tbl1Values = array( 'news_title' => $postdata['news_title'], 'news_content' => $postdata['news_content'], 'news_target' => $postdata['news_target'], 'news_date' => $this->mastermodel->convertdateformat($postdata['news_date']) ); $this->db->where('news_id', $postdata['news_id']); $this->db->update('news', $tbl1Values); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; return $data; } } function add_gallery($postdata) { $this->db->trans_begin(); $tbl1Values = array( 'directory_id' => $postdata['directory_id'], 'gallery_sort' => $postdata['gallery_sort'], 'gallery_image' => $postdata['image'] ); $this->db->insert('gallery', $tbl1Values); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; return $data; } } function update_gallery($postdata) { $this->db->trans_begin(); $tbl1Values = array( 'directory_id' => $postdata['directory_id'], 'gallery_sort' => $postdata['gallery_sort'], ); $this->db->where('gallery_id', $postdata['gallery_id']); $this->db->update('gallery', $tbl1Values); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; return $data; } } function add_directory($postdata) { $this->db->trans_begin(); $tbl1Values = array( 'directory_name' => $postdata['directory_name'], 'directory_image' => $postdata['image'], 'directory_sort' => $postdata['directory_sort'] ); $this->db->insert('directory', $tbl1Values); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; return $data; } } function update_directory($postdata) { $this->db->trans_begin(); $tbl1Values = array( 'directory_name' => $postdata['directory_name'], 'directory_sort' => $postdata['directory_sort'] ); $this->db->where('directory_id', $postdata['directory_id']); $this->db->update('directory', $tbl1Values); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; return $data; } } function add_client($postdata) { $this->db->trans_begin(); $tbl1Values = array( 'client_name' => $postdata['client_name'], 'client_logo' => $postdata['client_logo'], 'client_sort' => $postdata['client_sort'] ); $this->db->insert('client', $tbl1Values); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; return $data; } } function update_client($postdata) { $this->db->trans_begin(); $tbl1Values = array( 'client_name' => $postdata['client_name'], 'client_sort' => $postdata['client_sort'] ); $this->db->where('client_id', $postdata['client_id']); $this->db->update('client', $tbl1Values); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; return $data; } } function add_contact($postdata) { $this->db->trans_begin(); $tbl1Values = array( 'contact_name' => $postdata['contact_name'], 'contact_email' => $postdata['contact_email'], 'contact_phone' => $postdata['contact_phone'], 'contact_message' => $postdata['contact_message'] ); $this->db->insert('contact', $tbl1Values); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; return $data; } } function update_password($postdata) { $tbl1Values = array('password' => md5($postdata['password'])); $this->db->where('user_id', '1'); $this->db->update('user', $tbl1Values); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); return 0; } else { $this->db->trans_commit(); $data['res'] = 1; return $data; } } function get_contacts_list($singles, $doubles, $mixed) { $data = array(); $query = ''; if ($singles == 1) $query = "(select registration_singles_company_name as company_name, registration_singles_player_name as player_name, registration_singles_player_designation as designation, registration_singles_contact_no as contact_no, registration_singles_email as email_id, 'Men\'s Singles' AS event_name from registration_singles order by datetime) UNION"; if ($doubles == 1) { $query .= " (select registration_doubles_company_name as company_name, registration_doubles_player_name_1 as player_name, registration_doubles_player_designation_1 as designation, registration_doubles_contact_no_1 as contact_no, registration_doubles_email_1 as email_id, 'Men\'s Doubles' AS event_name from registration_doubles order by datetime) UNION"; $query .= " (select registration_doubles_company_name as company_name, registration_doubles_player_name_2 as player_name, registration_doubles_designation_2 as designation, registration_doubles_contact_no_2 as contact_no, registration_doubles_email_2 as email_id, 'Men\'s Doubles' AS event_name from registration_doubles order by datetime) UNION"; } if ($mixed == 1) { $query .= " (select registration_mixed_company_name as company_name, registration_mixed_player_name_1 as player_name, registration_mixed_player_designation_1 as designation, registration_mixed_contact_no_1 as contact_no, registration_mixed_email_1 as email_id, 'Mixed Doubles' AS event_name from registration_mixed order by datetime) UNION"; $query .= " (select registration_mixed_company_name as company_name, registration_mixed_player_name_2 as player_name, registration_mixed_designation_2 as designation, registration_mixed_contact_no_2 as contact_no, registration_mixed_email_2 as email_id, 'Mixed Doubles' AS event_name from registration_mixed order by datetime)"; } $query = preg_replace('/UNION$/', '', $query); $Q = $this->db->query($query); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function send_email($postdata) { foreach ($postdata['email_checkbox'] as $email) $this->mail->send($postdata['content'], $postdata['subject'], 'ajmal@savoyglobal.net', 'Mohamed Ajmal', 'mohamedajmal', 'smtp.gmail.com', 0, $email); } } ?>