BBnepal-Accounts/library/application/helpers/common_helper.php

80 lines
2.0 KiB
PHP
Raw Normal View History

2024-07-10 12:43:19 +00:00
<?php
function urlsafe_b64encode($string)
{
$data = base64_encode($string);
$data = str_replace(array('+','/','='),array('-','_',''),$data);
return $data;
}
function urlsafe_b64decode($string) {
$data = str_replace(array('-','_'),array('+','/'),$string);
$mod4 = strlen($data) % 4;
if ($mod4) {
$data .= substr('====', $mod4);
}
return base64_decode($data);
}
/*function loggedin_admin_user_permissions()
{
$CI = &get_instance();
$CI->load->model('AdminRule_Model');
$adminRules = $CI->AdminRule_Model->get_admin_rule_details('', "SELECT menu_id FROM admin_rule WHERE role_id=".$CI->session->userdata('role_id'));
return $adminRules;
}*/
function ciSendEmail($data=array())
{
$CI = &get_instance();
$CI->load->library('email');
//$CI->email->clear();
//$config['mailtype'] = 'html';
//$CI->email->initialize($config);
$CI->email->from('bb.blackboardnepal@gmail.com', 'Black - Library');
$CI->email->to($data['to']);
//if(isset($data['cc_to']) && $data['cc_to']!='')
//$CI->email->cc($data['cc_to']);
$CI->email->subject($data['subject']);
$CI->email->message($data['message']);
$CI->email->set_mailtype('html');
$res = $CI->email->send();
//echo $res;exit;
return $res;
}
function cuurentNepaliDate($dateObj)
{
$date_arr = explode('-', date('Y-m-d'));
list($y, $m, $d) = $date_arr;
// Convert BS to AD.
$datearr = $dateObj->convertAdToBs($y, $m, $d);
extract($datearr);
$string = $year.'-'.$month.'-'.$day;
$date = date_create_from_format('Y-m-d', $string);
return $php_date = date_format($date, 'Y-m-d H:i:s');
}
function convert_ADdate_to_BSdate($dateObj,$date,$character='-')
{
$date_arr = explode('-', $date);
list($y, $m, $d) = $date_arr;
$datearr = $dateObj->convertAdToBs($y, $m, $d);
extract($datearr);
$string = $year.'-'.$month.'-'.$day;
$date = date_create_from_format('Y-m-d', $string);
return $php_date = date_format($date, 'Y-m-d');
}
?>