<?php

/*
 * *************************************************
 * Copyright (C) 2021 Earworks.                    *
 * Codeigniter Project Template Modification       *
 * Please contact our email for more information : *
 * contact@earworks.co.id                          *
 * *************************************************
 */

defined('BASEPATH') OR exit('No direct script access allowed');
if (!function_exists('month_list')) {

    function month_list($selected = null) {
        $dropdown_bulan = [
            1 => 'Januari',
            2 => 'Februari',
            3 => 'Maret',
            4 => 'April',
            5 => 'Mei',
            6 => 'Juni',
            7 => 'Juli',
            8 => 'Agustus',
            9 => 'September',
            10 => 'Oktober',
            11 => 'November',
            12 => 'Desember'
        ];
        return $selected && isset($dropdown_bulan[$selected]) ? $dropdown_bulan[$selected] : $dropdown_bulan;
    }

}
if (!function_exists('date_id')) {

    function date_id($format = 'd-f-Y', $db_datetime = null) {
        if ($db_datetime == null) {
            $db_datetime = date('Y-m-d H:i:s');
        }
        $dropdown_bulan = month_list();
        $stamp = strtotime($db_datetime);
        return strtr($format, [
            'd' => date('d', $stamp),
            'f' => $dropdown_bulan[intval(date('m', $stamp))],
            'm' => date('m', $stamp),
            'y' => date('y', $stamp),
            'Y' => date('Y', $stamp)
        ]);
    }

}