<?php

function display_dashboard_sales_filtering_parameters() {
    dashboard_set_from_to_months('from_month_id', 'to_month_id');
    
    start_table(TABLESTYLE, "width=25%");
        $dash_sales_array = get_dashboard_sales_types_array();
        custom_values_list_row("Type:", 'group_code', $dash_sales_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);
        value_list_row('Entry Type:', 'entry_type_id', 'UTILITY_BILL_ENTRY_TYPES', null, '');
    end_table(1);
    
    start_table(TABLESTYLE);
        start_row();
            submit_center_first('DashboardSales', "Display", '', 'process', ICON_OK);
        end_row();
    end_table(2);
}

function get_dashboard_sales_types_array() {
    $dash_sales_array = array();
    
        $dash_sales_array['SALES_P&L'] = "Sales P&L";
        
        return $dash_sales_array;
}

function display_dashboard_sales_view($entry_type_id=0) {
    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('sales_views');
        div_start('sales_views');

            start_table();

                switch ($_POST['group_code']) {
                    case 'SALES_P&L':
                        include_once("$path_to_root/dashboard/includes/ui/dashboard_sales_pnl_ui.inc");
                        include_once($path_to_root . "/dashboard/includes/db/dashboard_sales_pnl_db.inc"); 
                        
                        dashboard_sales_pnl($from_month['display_order'], $to_month['display_order'], $entry_type_id);
                        break;
                        
                    default:        
                        break;
                }

            end_table();
            
        div_end();
}

?>