<?php

function display_petty_cash_float_iquiry_selecting_parameters() {
//    start_table(TABLESTYLE_INQUIRY_PARAMETERES);
    start_table(TABLESTYLE);
        start_row();
            petty_cash_floats_list_cells("Float:", "float_id", null, "", true);
            date_cells(_("from:"), 'from_date', '', null, -7);
            date_cells(_("to:"), 'to_date', '', null, +7);
        end_row();
        
        start_row();
        global $petty_cash_float_transaction_types;
            asort($petty_cash_float_transaction_types);
            custom_values_list_cells("Type:", 'filter_type', $petty_cash_float_transaction_types, null, '', true);
            ref_cells(_("Trans. No:"), 'filering_trans_no', '',null, '');

            submit_cells('SearchOrders', _("Search"),'',_('Search'), 'default');
        end_row();
    end_table(2);
}

function display_petty_cash_float_iquiry($from_date, $to_date, $float_id, $filter_type, $filering_trans_no) {
    global $systypes_array, $Ajax;
    
    $Ajax->activate('details');
    div_start('details');
    start_table(TABLESTYLE, "width=90%");
    
        $th = array(_("Id"), _("Type"), _("Tran No"), _("Float Name"), _("Date"), _("Amount"), _("Balance"));
        table_header($th);

        start_row();
            label_cell(text_bold("Balance before $from_date"), 'colspan=5 align=right');
            $befor_cash = get_petty_cash_float_before_totals($float_id, sql2date(INFINITE_START_DATE), $from_date);
            label_cell('');
            amount_cell($befor_cash, true);
            
        end_row();
        
        
        $j = 1;
        $k = $total = $balance = 0;
            $result = get_petty_cash_float_inquiry($from_date,$to_date, $filter_type, $filering_trans_no, $float_id, $to_float_id=0);
                while ($row = db_fetch($result)){
                    alt_table_row_color($k);

                        label_cell($row["id"], 'align=center');
                        $link = get_trans_view_str($row['tran_type'], $row['type_no']);
                        if (array_key_exists($row["tran_type"], $systypes_array)) {
                            label_cell($systypes_array[$row["tran_type"]]);
                        } else {
                            label_cell('', 'align=center');
                        }
                        label_cell($link, 'align=center');
                        label_cell($row["name"]);
                        label_cell(sql2date($row["tran_date"]));

                        qty_cell($row["amount"], false, 2);
                        
                        $balance = $befor_cash += $row["amount"];
                        qty_cell($balance, false, 2); 
                        
                    end_row();
                    
                    $j++;
                    If ($j == 20) {
                        $j = 1;
                        table_header($th);
                    }
                    
                        $total += $row["amount"];
                }
                
                start_row();
                    label_cell(text_bold("Period Transactions Total"), 'colspan=5 align=right');
                    amount_cell($total, true);
                    label_cell('');
                end_row();
                
                if(!($filter_type > 0 || $filering_trans_no > 0)){
                    start_row();
                        label_cell(text_bold("Balance on $to_date"), 'colspan=5 align=right');
                        label_cell('');
                        amount_cell($balance, true);
                    end_row();
                }

    end_table(2);
    div_end();
    
}

?>