<?php

function display_dashboard_asset_filtering_parameters() {
    
    dashboard_set_from_to_months('from_month_id', 'to_month_id');
    
    start_table(TABLESTYLE, "width=25%");
        $dash_purchs_array = get_dashboard_asset_types_array();
        custom_values_list_row("Type:", 'group_code', $dash_purchs_array, null, false, true);
        switch ($_POST['group_code']) {
            case 'INVENTORY_CONSUMPTION':
                label_row('Stock Item:', stock_items_list('stock_id', null, 'All items', true));
                break;
            case 'PETTY_CASH_EXPENSES':
                value_list_row("Expense Type:", "expense_type_id", "PETTY_CASH_EXPENSE_TYPES", null, 'All expense types');
                break;
            case 'UTILITY_EXPENSES':
                utility_expense_types_list_row("Expense Type:", 'expense_type_id', null, 'All Expense Types', true);
                break;
            case 'VEHICLE_ALL_COSTS':
                vehicles_list_row("Vehicle:", 'vehicle_id', null, 'Select a vehicle', true);
                break;

            default:
                break;
        }
        months_list_row("From Month:", 'from_month_id', null, false, true);   
        months_list_row("To Month:", 'to_month_id', null, false, true);  

        set_global_dashboard_from_month($_POST['from_month_id']);
        set_global_dashboard_to_month($_POST['to_month_id']);
    end_table(1);

    start_table(TABLESTYLE);
        start_row();
            submit_center_first('DashboardPurch', "Display", '', 'process', ICON_OK);
        end_row();
    end_table(2);
}

function get_dashboard_asset_types_array() {
    $dash_purchs_array = array();
    
        $dash_purchs_array['-1'] = "Select type";
//        $dash_purchs_array['PETTY_CASH_EXPENSES'] = "Petty Cash Expenses";
        $dash_purchs_array['INVENTORY_CONSUMPTION'] = "Item Consumption";
        $dash_purchs_array['UTILITY_EXPENSES'] = "Utility Expenses";
//        $dash_purchs_array['ASSET_ALL_COSTS'] = "Asset All Costs";
//        $dash_purchs_array['DATA_ENTRY'] = "Data Entry";
        
        return $dash_purchs_array;
}

function display_dashboard_asset_view() {
    global $path_to_root, $Ajax;

    $from_month = get_month(get_global_dashboard_from_month());
    $to_month = get_month(get_global_dashboard_to_month());

    $Ajax->activate('uda_ddg');
        div_start('uda_ddg');

            start_table();

                switch ($_POST['group_code']) {
                    case 'INVENTORY_CONSUMPTION':
                        include_once($path_to_root . "/dashboard/includes/ui/dashboard_asset_item_consumption_ui.inc");
                        include_once($path_to_root . "/dashboard/includes/db/dashboard_asset_item_consumption_db.inc"); 
                        include_once($path_to_root . "/dashboard/includes/db/dashboard_inventory_item_consumption_db.inc");  
                        include_once($path_to_root . "/assets/includes/db/assets_db.inc"); 
                        include_once($path_to_root . "/includes/db/group_companies_db.inc"); 
                        dashboard_asset_item_consumption($from_month['display_order'], $to_month['display_order'], $_POST['stock_id']);
                        break;
                    
                    case 'PETTY_CASH_EXPENSES':
                        include_once("$path_to_root/dashboard/includes/ui/dashboard_asset_petty_cash_expenses_ui.inc");
                        include_once($path_to_root . "/dashboard/includes/db/dashboard_asset_petty_cash_expenses_db.inc"); 
                        include_once($path_to_root . "/transport/includes/db/vehicles_db.inc"); 
                        dashboard_asset_petty_cash_expenses($from_month['display_order'], $to_month['display_order'], $_POST['expense_type_id']);
                        break;
                    
                    case 'UTILITY_EXPENSES':
                        include_once("$path_to_root/dashboard/includes/ui/dashboard_asset_utility_expenses_ui.inc");
                        include_once($path_to_root . "/dashboard/includes/db/dashboard_asset_utility_expenses_db.inc"); 
                        include_once($path_to_root . "/dashboard/includes/db/dashboard_utility_expenses_db.inc");  
                        include_once($path_to_root . "/assets/includes/db/assets_db.inc"); 
                        dashboard_asset_utility_expenses($from_month['display_order'], $to_month['display_order'], $_POST['expense_type_id']);
                        break;
                    
                    case 'ASSET_ALL_COSTS':
                        include_once("$path_to_root/dashboard/includes/ui/dashboard_asset_vehicle_all_costs_ui.inc");
                        include_once($path_to_root . "/dashboard/includes/db/dashboard_utility_expenses_db.inc"); 
                        include_once($path_to_root . "/dashboard/includes/db/dashboard_petty_cash_expenses_db.inc"); 
                        include_once($path_to_root . "/dashboard/includes/db/dashboard_asset_vehicle_all_costs_db.inc");  
                        include_once($path_to_root . "/dashboard/includes/db/dashboard_inventory_item_consumption_db.inc");  
                        include_once($path_to_root . "/transport/includes/db/vehicles_db.inc"); 
                        dashboard_asset_vehicle_all_costs($from_month['display_order'], $to_month['display_order'], $_POST['vehicle_id']);
                        break;

                    default:        
                        break;
                }

            end_table(2);
        div_end();
}

?>