<?php

function dashboard_view_employee_petty_cash_outstanding($employee_code, $from_date, $to_date) {
    
    display_heading('Employee Petty Cash Outstanding');    
    br();
    
    $employee_name = get_group_company_employee_formatted_long_name("UKE", $employee_code);
    display_heading("Employee : ".$employee_name);    
    
    br();
    
    $from_date_ = sql2date($from_date);
    $to_date_ = sql2date($to_date);
    
    display_employee_petty_cash_outstanding("UKE", $employee_code, 0, $from_date_, $to_date_);
    
}

function dashboard_view_employee_petty_cash_outstanding1111($expense_type_id, $from_date, $to_date) {
    
    global $expense_categories;
    

        
        
        start_table(TABLESTYLE, "width=80%");

            $th = array("Date", "Batch No", "Expense Category", "Expense Item", "Expense Type", "Invoice No", "Description", "Amount"); 
            
                table_header($th);
                
                    $k = $total_amount = $count = 0;
                    $result = view_dashboard_petty_cash_expenses_details($expense_type_id, $from_date, $to_date);
                        while($row = db_fetch($result)) {
                            alt_table_row_color($k);
                                label_cell(sql2date($row['expence_date']),"align=center");
                                $link = get_petty_cash_trans_view_str(ST_I_OWE_YOU_BATCH, $row['iou_batch_no']);
                                label_cell($link, "align=center");
                                label_cell($expense_categories[$row["expense_category_id"]]);
                                
                                $expense_item_name = '';
                                switch ($row['expense_category_id']) {
                                    case EC_PETTY_CASH_EXPENSE:
                                        $expense_item_name = '';
                                        break;
                                    case EC_STOCK_ITEM_RECEIPT:
                                        $receipts_res = get_petty_cash_item_receive_items_by_source_type(ST_I_OWE_YOU_BATCH, $row["id"]);
                                        $receipts = db_fetch($receipts_res);
                                        $receipt_tran_no = 0;
                                        if(is_array($receipts)){
                                            $receipt_tran_no = $receipts['trans_no'];
                                        }
                                        $link = get_inventory_trans_view_str(ST_PETTY_CASH_ITEM_RECEIPT, $receipt_tran_no, "Received items");
                    //                    $link = get_petty_cash_item_receive_str(ST_PETTY_CASH_ITEM_RECEIPT, $batch_no, $myrow["id"], "Receive items");
                                        $expense_item_name = $link;
                                        break;
                                    case EC_VEHICLE_MAINTENANCE:
                                        $expense_item_name = get_vehicle_formatted_name($myrow["expense_item_id"]);
                                        break;
                                    case EC_UTILITY_ITEM:
                                        $utility_item = get_listvalue_by_id($myrow["expense_item_id"]);
                                        $expense_item_name = $utility_item['value_name'];
                                        break;
                                    case EC_ASSET_MAINTENANCE:
                                        $expense_item_name = get_asset_formatted_name($myrow["expense_item_id"]);
                                        break;

                                    default:
                                        break;
                                }
            
                                label_cell($expense_item_name);  
                                label_cell($row['expense_type_name']);
                                label_cell($row['bill_no']);
                                label_cell($row['expence_description']);
                                
                                $total = $row['approved_amount'];
                                amount_cell($total);
                                
                                

                            end_row();

                            $total_amount += $total;
                            $count++;
                        }
                        
                        start_row();
                            label_cell(text_bold("Total"),"align=right colspan=7");
                            label_cell(text_bold(number_format($total_amount, 2)),"align=right"); 
                        end_row();
                
        end_table(2);
}


?>