bbone/application/helpers/custom_helper.php
2022-12-16 00:23:18 +05:30

162 lines
4.0 KiB
PHP

<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
/*
* ASM
*
* @author Venba Developers & Contributors
* @copyright Copyright (c) 2012 - 2017 InvoicePlane.com
* @license https://venbainfotech.com/license.txt
* @link https://venbainfotech.com.com
*/
//check auth
if (!function_exists('check_auth'))
{
function check_auth()
{
// Get a reference to the controller object
$ci =& get_instance();
//return $ci->auth_model->is_logged_in();
if($ci->session->userdata('logged_in') == TRUE)
{
return true;
}
return false;
}
}
//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('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 '';
}
}
}
//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;
}
}