<?php

function dashboard_view_petty_cash_data_entry($user_id, $trans_type, $from_date, $to_date) {
    
    global $systypes_array;
    
    display_heading('User Petty Cash Data Entry');    
    br();
    
    $user = get_user($user_id);
    display_heading("User : ".$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_petty_cash_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_petty_cash_user_data_entry_period_details($from_date, $to_date, $user_id, $trans_type) {
    
    switch ($trans_type) {
        case ST_PETTY_CASH:
            $sql = dashboard_get_sql_for_petty_cash_data_entry_petty_cash_expenses($from_date, $to_date, $user_id);
            break;
        case ST_I_OWE_YOU:
            $sql = dashboard_get_sql_for_petty_cash_data_entry_ious($from_date, $to_date, $user_id);
            break;
        case ST_I_OWE_YOU_BATCH:
            $sql = dashboard_get_sql_for_petty_cash_data_entry_iou_batches($from_date, $to_date, $user_id);
            break;
        case ST_I_OWE_YOU_PAYMENT:
            $sql = dashboard_get_sql_for_petty_cash_data_entry_iou_payments($from_date, $to_date, $user_id);
            break;
        case ST_PETTY_CASH_PAYMENT:
            $sql = dashboard_get_sql_for_petty_cash_data_entry_petty_cash_payments($from_date, $to_date, $user_id);
            break;
        case ST_IOU_BANKPAYMENT:
            $sql = dashboard_get_sql_for_petty_cash_data_entry_iou_bank_payments($from_date, $to_date, $user_id);
            break;
        case ST_IOU_BANKPAYMENT:
            $sql = dashboard_get_sql_for_petty_cash_data_entry_iou_bank_returns($from_date, $to_date, $user_id);
            break;

        default:
            $sql = "";
            break;
    }


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