function handle_search()
{
    if (check_valid_entries() == true) {
        $trans_ref = false;
        $sql = get_sql_for_view_transactions($_POST['filterType'], $_POST['FromTransNo'], $_POST['ToTransNo'], $trans_ref);
        if ($sql == "") {
            return;
        }
        $print_type = $_POST['filterType'];
        $print_out = $print_type == ST_SALESINVOICE || $print_type == ST_CUSTCREDIT || $print_type == ST_CUSTDELIVERY || $print_type == ST_PURCHORDER || $print_type == ST_SALESORDER || $print_type == ST_SALESQUOTE || $print_type == ST_CUSTPAYMENT || $print_type == ST_SUPPAYMENT || $print_type == ST_WORKORDER;
        $cols = array(_("#") => array('insert' => true, 'fun' => 'view_link'), _("Reference") => array('fun' => 'ref_view'), _("Date") => array('type' => 'date', 'fun' => 'date_view'), _("Print") => array('insert' => true, 'fun' => 'prt_link'), _("GL") => array('insert' => true, 'fun' => 'gl_view'));
        if (!$print_out) {
            array_remove($cols, 3);
        }
        if (!$trans_ref) {
            array_remove($cols, 1);
        }
        $table =& new_db_pager('transactions', $sql, $cols);
        $table->width = "40%";
        display_db_pager($table);
    }
}
Beispiel #2
0
function handle_void_transaction()
{
    if (check_valid_entries() == true) {
        $void_entry = get_voided_entry($_POST['filterType'], $_POST['trans_no']);
        if ($void_entry != null) {
            display_error(tr("The selected transaction has already been voided."), true);
            unset($_POST['trans_no']);
            unset($_POST['memo_']);
            unset($_POST['date_']);
            set_focus('trans_no');
            return;
        }
        $ret = void_transaction($_POST['filterType'], $_POST['trans_no'], $_POST['date_'], $_POST['memo_']);
        if ($ret) {
            display_notification_centered(tr("Selected transaction has been voided."));
            unset($_POST['trans_no']);
            unset($_POST['memo_']);
            unset($_POST['date_']);
        } else {
            display_error(tr("The entered transaction does not exist or cannot be voided."));
            set_focus('trans_no');
        }
    }
}
        set_focus('target_amount');
        return false;
    }
    if (isset($_POST['target_amount']) && input_num('target_amount') == 0) {
        display_error(_("The incomming bank amount cannot be 0."));
        set_focus('target_amount');
        return false;
    }
    if (!db_has_currency_rates(get_bank_account_currency($_POST['FromBankAccount']), $_POST['DatePaid'])) {
        return false;
    }
    if (!db_has_currency_rates(get_bank_account_currency($_POST['ToBankAccount']), $_POST['DatePaid'])) {
        return false;
    }
    return true;
}
//----------------------------------------------------------------------------------------
function handle_add_deposit()
{
    new_doc_date($_POST['DatePaid']);
    $trans_no = add_bank_transfer($_POST['FromBankAccount'], $_POST['ToBankAccount'], $_POST['DatePaid'], input_num('amount'), $_POST['ref'], $_POST['memo_'], input_num('charge'), input_num('target_amount'));
    meta_forward($_SERVER['PHP_SELF'], "AddedID={$trans_no}");
}
//----------------------------------------------------------------------------------------
if (isset($_POST['AddPayment'])) {
    if (check_valid_entries() == true) {
        handle_add_deposit();
    }
}
gl_payment_controls();
end_page();
function handle_search()
{
    global $table_style;
    if (check_valid_entries() == true) {
        $db_info = get_systype_db_info($_POST['filterType']);
        if ($db_info == null) {
            return;
        }
        $table_name = $db_info[0];
        $type_name = $db_info[1];
        $trans_no_name = $db_info[2];
        $trans_ref = $db_info[3];
        $sql = "SELECT DISTINCT {$trans_no_name} ";
        if ($trans_ref) {
            $sql .= " ,{$trans_ref} ";
        }
        $sql .= " FROM {$table_name}\n\t\t\tWHERE {$trans_no_name} >= " . $_POST['FromTransNo'] . "\n\t\t\tAND  {$trans_no_name} <= " . $_POST['ToTransNo'];
        if ($type_name != null) {
            $sql .= " AND {$type_name} = " . $_POST['filterType'];
        }
        $sql .= " ORDER BY {$trans_no_name}";
        $result = db_query($sql, "could not query transactions on {$table_name}");
        if (db_num_rows($result) == 0) {
            echo tr("There are no transactions for the given parameters.");
            return;
        }
        $print_type = $_POST['filterType'];
        $print_out = $print_type == 10 || $print_type == 11 || $print_type == systypes::cust_dispatch() || $print_type == systypes::po() || $print_type == systypes::sales_order();
        if ($print_out) {
            print_hidden_script($print_type);
            if ($trans_ref) {
                $th = array(tr("#"), tr("Reference"), tr("View"), tr("Print"), tr("GL"));
            } else {
                $th = array(tr("#"), tr("View"), tr("Print"), tr("GL"));
            }
        } else {
            if ($trans_ref) {
                $th = array(tr("#"), tr("Reference"), tr("View"), tr("GL"));
            } else {
                $th = array(tr("#"), tr("View"), tr("GL"));
            }
        }
        start_table($table_style);
        table_header($th);
        $k = 0;
        while ($line = db_fetch($result)) {
            alt_table_row_color($k);
            label_cell($line[$trans_no_name]);
            if ($trans_ref) {
                label_cell($line[$trans_ref]);
            }
            label_cell(get_trans_view_str($_POST['filterType'], $line[$trans_no_name], tr("View")));
            if ($print_out) {
                label_cell(print_document_link($line[$trans_no_name], tr("Print"), true, $print_type));
            }
            label_cell(get_gl_view_str($_POST['filterType'], $line[$trans_no_name], tr("View GL")));
            end_row();
        }
        end_table();
    }
}