<?php

function display_dashboard_petty_cash_filtering_parameters() {
    start_table(TABLESTYLE, "width=25%");
        $dash_purchs_array = get_dashboard_petty_cash_types_array();
        custom_values_list_row("Type:", 'group_code', $dash_purchs_array, null, false, true);
        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_petty_cash_types_array() {
    $dash_purchs_array = array();
    
        $dash_purchs_array['DELIVERY_LEAD_TIME'] = "Delivery Lead Time";
        $dash_purchs_array['PRICE_VARIANCE'] = "Price Variance";
        $dash_purchs_array['NEW_SUPPLIERS'] = "New Suppliers";
        $dash_purchs_array['TOP_SUPPLIERS'] = "Purchases (GRNs)";
        $dash_purchs_array['TOP_ITEMS'] = "Purchases (Items)";
        $dash_purchs_array['PURCHASE_ORDERS'] = "Purchase Orders";
        $dash_purchs_array['PURCHASE_REQUISITIONS'] = "Purchase Requisitions";
        
        return $dash_purchs_array;
}

function display_dashboard_petty_cash_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 'DELIVERY_LEAD_TIME':
                        include_once("$path_to_root/dashboard/includes/ui/dashboard_supplier_delivery_lead_time_ui.inc");
                        include_once($path_to_root . "/dashboard/includes/db/dashboard_supplier_delivery_lead_time_db.inc"); 
                        dashboard_supplier_delivery_lead_time($from_month['display_order'], $to_month['display_order']);
                        break;                        
                        
                    case 'PRICE_VARIANCE':
                        include_once("$path_to_root/dashboard/includes/ui/dashboard_purchase_price_variance_ui.inc");
                        include_once($path_to_root . "/dashboard/includes/db/dashboard_purchase_price_variance_db.inc"); 
                        dashboard_purchase_price_variance($from_month['display_order'], $to_month['display_order']);
                        break;
                        
                    case 'NEW_SUPPLIERS':
                        include_once("$path_to_root/dashboard/includes/ui/dashboard_new_suppliers_ui.inc");
                        include_once($path_to_root . "/dashboard/includes/db/dashboard_new_suppliers_db.inc"); 
                        dashboard_new_suppliers($from_month['display_order'], $to_month['display_order']);
                        break;
                        
                    case 'TOP_SUPPLIERS':
                        include_once("$path_to_root/dashboard/includes/ui/dashboard_top_suppliers_ui.inc");
                        include_once($path_to_root . "/dashboard/includes/db/dashboard_top_suppliers_db.inc"); 
                        dashboard_top_suppliers($from_month['display_order'], $to_month['display_order']);
                        break;
                        
                    case 'TOP_ITEMS':
                        include_once("$path_to_root/dashboard/includes/ui/dashboard_purchase_top_items_ui.inc");
                        include_once($path_to_root . "/dashboard/includes/db/dashboard_purchase_top_items_db.inc"); 
                        dashboard_purchase_top_items($from_month['display_order'], $to_month['display_order']);
                        break;
                        
                    case 'PURCHASE_ORDERS': 
                        include_once("$path_to_root/dashboard/includes/ui/dashboard_purchase_orders_ui.inc");
                        include_once($path_to_root . "/dashboard/includes/db/dashboard_purchase_orders_db.inc"); 
                        dashboard_display_purchase_orders($from_month['display_order'], $to_month['display_order']);
                        break;
                    
                    case 'PURCHASE_REQUISITIONS': 
                        include_once("$path_to_root/dashboard/includes/ui/dashboard_purchase_requisitions_ui.inc");
                        include_once($path_to_root . "/dashboard/includes/db/dashboard_purchase_requisitions_db.inc"); 
                        dashboard_display_purchase_requisitions($from_month['display_order'], $to_month['display_order']);
                        break;
                        
                    default:        
                        break;
                }

            end_table(2);
        div_end();
}

?>