session->has_userdata('admin_id')) {
return true;
} else {
$ci->session->set_flashdata($error_for, $error_message);
redirect($link_redirect);
}
} else {
if ($ci->session->has_userdata('admin_id')) {
return true;
} else {
redirect('home');
}
}
}
function is_admin($error_for, $error_message, $link_redirect)
{
$ci = &get_instance();
if ($error_for && $error_message && $link_redirect) {
if ($ci->session->has_userdata('admin_id') and $ci->session->userdata('role') == 1) {
return true;
} else {
$ci->session->set_flashdata($error_for, $error_message);
redirect($link_redirect);
}
} else {
if ($ci->session->has_userdata('admin_id') and $ci->session->userdata('role') == 1) {
return true;
} else {
redirect('home');
}
}
}
//fungsi acak string
function _randString($length)
{
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789^";
$str = '';
$size = strlen($chars);
for ($i = 0; $i < $length; $i++) {
$str .= $chars[rand(3, $size - 5)];
}
return $str;
}
function _notif($message)
{
$notif = $_GET['notif'];
$notif_cut = substr($notif, 0, 5);
if ($message) {
if ($notif_cut == 'suces') { ?>
'Januari',
2 => 'Februari',
3 => 'Maret',
4 => 'April',
5 => 'Mei',
6 => 'Juni',
7 => 'Juli',
8 => 'Agustus',
9 => 'September',
10 => 'Oktober',
11 => 'November',
12 => 'Desember'
);
$tgl_bln_thn = explode('-', $tanggal);
$jam_min_dtk = explode(':', $tanggal);
return substr($tgl_bln_thn[2], 0, 4) . ' ' . $bulan[(int) $tgl_bln_thn[1]] . ' ' . $tgl_bln_thn[0] . ' / ' . substr($jam_min_dtk[0], 11, 13) . ':' . $jam_min_dtk[1] . ':' . $jam_min_dtk[2];
}
function _tglIndo($tanggal)
{
if (!empty($tanggal)) {
$bulan = array(
1 => 'Januari',
2 => 'Februari',
3 => 'Maret',
4 => 'April',
5 => 'Mei',
6 => 'Juni',
7 => 'Juli',
8 => 'Agustus',
9 => 'September',
10 => 'Oktober',
11 => 'November',
12 => 'Desember'
);
$tgl_bln_thn = explode('-', $tanggal);
return substr($tgl_bln_thn[2], 0, 4) . ' ' . $bulan[(int) $tgl_bln_thn[1]] . ' ' . $tgl_bln_thn[0];
}
}
//echo hariIndo(date('D'));
function _hariIndo($date)
{
$tanggal = $date;
$day = date('D', strtotime($tanggal));
$dayList = array(
'Sun' => 'Minggu',
'Mon' => 'Senin',
'Tue' => 'Selasa',
'Wed' => 'Rabu',
'Thu' => 'Kamis',
'Fri' => 'Jumat',
'Sat' => 'Sabtu'
);
//echo "Tanggal {$tanggal} adalah hari : " . $dayList[$day];
$result = $dayList[$day];
return ($result);
}
function _rupiah($nilai)
{
return 'Rp. ' . number_format($nilai, 0, ",", ".");
}
function _cekAccess($role_id, $menu_id)
{
$ci = &get_instance();
$where = array('accessRole_roleId' => $role_id, 'accessRole_menu' => $menu_id);
$accessrole = $ci->general_m->get_where('accessrole', $where);
if ($accessrole->num_rows() > 0) {
return 'checked';
} else {
return '';
}
}
function _cekAccessSubMenu($role_id, $menu_id, $submenu_id)
{
$ci = &get_instance();
$where = array('accessRole_roleId' => $role_id, 'accessRole_menu' => $menu_id, 'accessRole_subMenu' => $submenu_id);
$accessrole = $ci->general_m->get_where('accessrole', $where);
if ($accessrole->num_rows() > 0) {
return 'checked';
} else {
return '';
}
}
function _getCompany($field)
{
$ci = &get_instance();
$result = $ci->db->get('company')->row_array();
return $result[$field];
}
?>