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

123 lines
3.0 KiB
PHP
Raw Permalink 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('nandini@ezydemo.com', 'Erisn Classroom - Bustracking');
$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 generate_driver_id()
{
$ci =& get_instance();
$ci->load->database();
$ci->db->select_max('id');
$query = $ci->db->get('bt_drivers');
$res = $query->row_array();
$pid = $res['id'] + 1;
if (strlen($pid) == 1)
$pid = "000" . $pid;
else if (strlen($pid) == 2)
$pid = "00" . $pid;
else if (strlen($pid) == 3)
$pid = "0" . $pid;
$applicationid = "BTD" . date('Y') . $pid;
return $applicationid;
}
function getDayList_E()
{
$status = array();
$status['monday'] = 'Monday';
$status['tuesday'] = 'Tuesday';
$status['wednesday'] = 'Wednesday';
$status['thursday'] = 'Thursday';
$status['friday'] = 'Friday';
$status['saturday'] = 'Saturday';
$status['sunday'] = 'Sunday';
return $status;
}
function getDayList_N()
{
$status = array();
$status['monday'] = 'sombaar';
$status['tuesday'] = 'mangalbaar';
$status['wednesday'] = 'budhabaar';
$status['thursday'] = 'bihibaar';
$status['friday'] = 'shukrabaar';
$status['saturday'] = 'shanibaar';
$status['sunday'] = 'aitabaar';
return $status;
}
// For batch display format by shivu
function batchdateFormat($date1,$date2){
return date('M-Y', strtotime($date1)) . '/' . date('M-Y', strtotime($date2));
}
function batchdateFormatTo($date1,$date2){
return date('M-Y', strtotime($date1)) . ' to ' . date('M-Y', strtotime($date2));
}
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');
}
?>