File: /home/clientsoftwares/public_html/multirest.clientsoftwares.com/application/core/Cl_Controller.php
<?php
class Cl_Controller extends CI_Controller {
public function __construct() {
parent::__construct();
/*group by issue skip*/
$this->db->query("SET sql_mode=(SELECT REPLACE(@@sql_mode, 'ONLY_FULL_GROUP_BY', ''));");
$file_pointer = str_rot13('nffrgf/oyhrvzc/ERFG_NCV.wfba');
$file_pointer_uv = str_rot13('nffrgf/oyhrvzc/ERFG_NCV_HI.wfba');
if (file_exists($file_pointer_uv)) {
$file_content_uv = file_get_contents($file_pointer_uv);
$json_data_uv = json_decode($file_content_uv, true);
$version = $json_data_uv['version'];
$mode = APPLICATION_lcl;
if($mode=="lcl"){
$version = '1.1';
}
$this->session->set_userdata('system_version_number',$version);
}
$file_wlb = str_rot13('serdhrag_punatvat/jyo.wfba');
if (file_exists($file_wlb)) {
$file_content_wlb = file_get_contents($file_wlb);
$json_data_wlb = json_decode($file_content_wlb, true);
$this->session->set_userdata('wlb',$json_data_wlb);
}
if($this->session->userdata('company_id'))
{
$this->check_active_subscription();
}
// $this->load->database();
// // Auto logout logic
// $this->load->model('Common_model');
// date_default_timezone_set('Asia/Kolkata');
// $this->check_working_hours_logout();
}
private function check_active_subscription() {
$company_id = $this->session->userdata('company_id');
if ($company_id) {
$today = date('Y-m-d');
// Get the valid subscription for this company
$this->db->where('company_id', $company_id);
$this->db->where('start_date <=', $today);
$this->db->where('end_date >=', $today);
$this->db->order_by('id', 'DESC'); // Optional: get latest valid subscription
$query = $this->db->get('tbl_subscriptions');
if ($query->num_rows() > 0) {
$active_subscription = $query->row(); // You may loop if needed, but one active is usually enough
// Update tbl_companies
$this->db->where('id', $company_id);
$this->db->update('tbl_companies', ['subs_id' => $active_subscription->id]);
}
}
}
// protected function check_working_hours_logout() {
// $working_hours = $this->db->get('tbl_openning_clossing_time')->row();
// if (!$working_hours) return;
// $closing_time = $working_hours->closing_time; // e.g. '19:00:00'
// $current_time = date('H:i:s');
// $today = date("Y-m-d",strtotime('today'));
// if ($current_time == $current_time) {
// $user_id = $this->session->userdata('user_id');
// $daily_information= array();
// $daily_information['date'] = $today;
// $daily_information['out_time'] = date("H:i:s");
// $daily_information['user_id'] = $user_id;
// $get_daily_atte_data = $this->Common_model->getlasttimeloginuserdata($user_id,'tbl_daily_attendance');
// $this->Common_model->updatedailyattendance($daily_information, $today,$get_daily_atte_data->id, "tbl_daily_attendance");
// $this->session->unset_userdata('user_id');
// $this->session->sess_destroy();
// $this->output
// ->set_status_header(440)
// ->set_output(json_encode([
// 'status' => false,
// 'message' => 'Working hours over. You have been logged out automatically.',
// 'logout_time' => $current_time
// ]));
// exit;
// }
// }
}