auth_model->is_logged_in(); // if($ci->session->userdata('logged_in') == TRUE) // { // return true; // } // return false; } } //check admin if (!function_exists('is_superadmin')) { function is_superadmin() { // Get a reference to the controller object $ci =& get_instance(); return $ci->auth_model->is_superadmin(); } } //check admin if (!function_exists('is_admin')) { function is_admin() { // Get a reference to the controller object $ci =& get_instance(); return $ci->auth_model->is_admin(); } } //check user if (!function_exists('is_user')) { function is_user() { // Get a reference to the controller object $ci =& get_instance(); return $ci->auth_model->is_user(); } } //get logged user if (!function_exists('user')) { function user() { // Get a reference to the controller object $ci =& get_instance(); $user = $ci->auth_model->get_logged_user(); if (empty($user)) { $ci->auth_model->logout(); } else { return $user; } } } if (!function_exists('business')) { function business() { $ci =& get_instance(); $business = $ci->auth_model->get_logged_business(user()->business_id); if (empty($business)) { $ci->auth_model->logout(); } else { return $business; } } } if (!function_exists('employee')) { function employee() { // Get a reference to the controller object $ci =& get_instance(); $emp = $ci->auth_model->get_logged_employee(); if (empty($emp)) { $ci->auth_model->logout(); } else { return $emp; } } } if(!function_exists('modules')) { function modules() { $ci =& get_instance(); $module_id = $ci->auth_model->modules(); $ModuleData = []; foreach($module_id as $key => $val){ array_push($ModuleData,$val->module_id); } return $ModuleData; } } if(!function_exists('Asset_module')) { function Asset_module() { $myArray = modules(); $elementToCheck = '1'; return in_array($elementToCheck, $myArray); } } if(!function_exists('Employee_module')) { function Employee_module() { $myArray = modules(); $elementToCheck = '2'; return in_array($elementToCheck, $myArray); } } if(!function_exists('group_membership')) { function group_membership() { $ci =& get_instance(); $group_id = $ci->auth_model->group_membership(); $GroupData = []; foreach($group_id as $key => $val){ array_push($GroupData,$val->group_id,$val->module_id); } return $GroupData; } } if(!function_exists('Employee_group')) { function Employee_group() { $myArray = group_membership(); // $ci =& get_instance(); // return $Employee_group = $ci->auth_model->Employee_group($myArray); $elementToCheck = '4'; $elementToCheck = '1'; return in_array($elementToCheck, $myArray); } } if(!function_exists('HR_group')) { function HR_group() { $myArray = group_membership(); // $ci =& get_instance(); // return $Employee_group = $ci->auth_model->Employee_group($myArray); $elementToCheck = '6'; $elementToCheck = '2'; return in_array($elementToCheck, $myArray); } } if(!function_exists('')) if (!function_exists('hash_password')) { function hash_password($password) { $ci =& get_instance(); return password_hash($password, PASSWORD_BCRYPT); } } // current date time function if(!function_exists('my_date_now')){ function my_date_now(){ $dt = new DateTime('now', new DateTimezone(get_time_zone())); $date_time = $dt->format('Y-m-d H:i:s'); return $date_time; } } // show current date & time with custom format if(!function_exists('my_date_show_time')){ function my_date_show_time($date){ if($date != ''){ $date2 = date_create($date); $date_new = date_format($date2,"d M Y h:i A"); return $date_new; }else{ return ''; } } } // show current date with custom format if(!function_exists('my_date_show')){ function my_date_show($date){ if($date != ''){ $date2 = date_create($date); $date_new = date_format($date2,"d M Y"); return $date_new; }else{ return ''; } } } // show current date with custom format if(!function_exists('month_show')){ function month_show($date){ if($date != ''){ $date2 = date_create($date); $date_new = date_format($date2,"M Y"); return $date_new; }else{ return ''; } } } // show current date with custom format if(!function_exists('show_year')){ function show_year($date){ if($date != ''){ $date2 = date_create($date); $date_new = date_format($date2,"Y"); return $date_new; }else{ return ''; } } } if(!function_exists('dateFormat')) { function dateFormat($format='d-m-Y', $givenDate=null) { return date($format, strtotime($givenDate)); } } if(!function_exists('timeFormat')) { function timeFormat($format='h:i:s a', $givenTime=null) { return date($format, strtotime($givenTime)); } } //get days if (!function_exists('get_days')) { function get_days() { $days = array( '1'=>'Saturday', '2'=>'Sunday', '3'=>'Monday', '4'=>'Tuesday', '5'=>'Wednesday', '6'=>'Thursday', '7'=>'Friday' ); return $days; } } // show different between two dates if(!function_exists('day_different')){ function day_different($to){ if($to != ''){ $days = (new DateTime())->diff(new DateTime($to))->days; return $days; }else{ return ''; } } } // audit history function if(!function_exists('audit_history')){ function audit_history($postData,$table,$business_id){ if($table != ''){ $id = $postData->id; $ci =& get_instance(); $TableData = $ci->MY_Model->getData($table,$id,$business_id); $Output = array(); foreach($postData as $postDatakey=>$postDatavalue) { foreach($TableData as $TableDatakey=>$TableDatavalue) { if($postDatakey == $TableDatakey) { if($postDatavalue != $TableDatavalue) { $data['table_name'] = $table; $data['column_name'] = $postDatakey; $data['old_value'] = $TableDatavalue; $data['new_value'] = $postDatavalue; $data['created_by'] = user()->id; $data['business_id'] = $business_id; $data['primary_id'] = $id; array_push($Output,$data); } } } } return $Output; }else{ return ''; } } }