<?php

function dashboard_view_purchasing_data_entry($user_id, $trans_type, $from_date, $to_date) {
    
    global $systypes_array;
    
    display_heading('User Purchasing Data Entry');    
    br();
    
    $user = get_user($user_id);
    display_heading($user['real_name']);    
    
    br();
    
        start_table(TABLESTYLE, "width=60%");

            $th = array("Type", "Tran. No", "Reference", "Tran. Date", "Created On", "Delay"); 
            table_header($th);

            $k = 9;
            $result = dashboard_get_purchasing_user_data_entry_period_details($from_date, $to_date, $user_id, $trans_type);
                while($row = db_fetch($result)) {
                    alt_table_row_color($k);

                        label_cell($systypes_array[$trans_type]);

                        $link = get_trans_view_str($trans_type, $row['tran_no']);
                        label_cell($link, "align=center");
                        label_cell($row['reference']);

                        label_cell(($row['tran_date']),"align=center");
                        label_cell(($row['created_on']),"align=center");
                        label_cell(($row['days']),"align=center");

                    end_row();
                }

        end_table();
}

function dashboard_get_purchasing_user_data_entry_period_details($from_date, $to_date, $user_id, $trans_type) {
    
    switch ($trans_type) {
        case ST_PURCHORDER:
            $sql = dashboard_get_sql_for_purchasing_data_entry_purchase_orders($from_date, $to_date, $user_id);
            break;
        case ST_PURCH_REQ:
            $sql = dashboard_get_sql_for_purchasing_data_purchase_requisitions($from_date, $to_date, $user_id);
            break;
        case ST_CUSTDELIVERY:
            $sql = dashboard_get_sql_for_purchasing_data_entry_grn_batches($from_date, $to_date, $user_id);
            break;

        default:
            $sql = "";
            break;
    }

    return db_query($sql, "dashboard_get_purchasing_user_data_entry_period_details");  
}


?>