function edit_link($row)
{
    global $editors;
    $ok = true;
    if ($row['type'] == ST_SALESINVOICE) {
        $myrow = get_customer_trans($row["type_no"], $row["type"]);
        if ($myrow['alloc'] != 0 || get_voided_entry(ST_SALESINVOICE, $row["type_no"]) !== false) {
            $ok = false;
        }
    }
    return isset($editors[$row["type"]]) && !is_closed_trans($row["type"], $row["type_no"]) && $ok ? pager_link(_("Edit"), sprintf($editors[$row["type"]], $row["type_no"], $row["type"]), ICON_EDIT) : '';
}
function edit_link($row)
{
    if (@$_GET['popup'] || get_voided_entry($row['type'], $row["trans_no"]) || is_closed_trans($row['type'], $row["trans_no"])) {
        return '';
    }
    $str = '';
    switch ($row['type']) {
        case ST_SALESINVOICE:
            $str = "/sales/customer_invoice.php?ModifyInvoice=" . $row['trans_no'];
            break;
        case ST_CUSTCREDIT:
            if ($row['order_'] == 0) {
                // free-hand credit note
                $str = "/sales/credit_note_entry.php?ModifyCredit=" . $row['trans_no'];
            } else {
                // credit invoice
                $str = "/sales/customer_credit_invoice.php?ModifyCredit=" . $row['trans_no'];
            }
            break;
        case ST_CUSTDELIVERY:
            $str = "/sales/customer_delivery.php?ModifyDelivery=" . $row['trans_no'];
            break;
        case ST_CUSTPAYMENT:
            $str = "/sales/customer_payments.php?trans_no=" . $row['trans_no'];
            break;
    }
    return $str ? pager_link(_('Edit'), $str, ICON_EDIT) : '';
}
function check_valid_entries()
{
    if (is_closed_trans($_POST['filterType'], $_POST['trans_no'])) {
        display_error(_("The selected transaction was closed for edition and cannot be voided."));
        set_focus('trans_no');
        return;
    }
    if (!is_date($_POST['date_'])) {
        display_error(_("The entered date is invalid."));
        set_focus('date_');
        return false;
    }
    if (!is_date_in_fiscalyear($_POST['date_'])) {
        display_error(_("The entered date is not in fiscal year."));
        set_focus('date_');
        return false;
    }
    if (!is_numeric($_POST['trans_no']) or $_POST['trans_no'] <= 0) {
        display_error(_("The transaction number is expected to be numeric and greater than zero."));
        set_focus('trans_no');
        return false;
    }
    return true;
}
function edit_link($row)
{
    $str = '';
    if (@$_GET['popup']) {
        return '';
    }
    switch ($row['type']) {
        case ST_SALESINVOICE:
            if (get_voided_entry(ST_SALESINVOICE, $row["trans_no"]) === false && $row['Allocated'] == 0) {
                $str = "/sales/customer_invoice.php?ModifyInvoice=" . $row['trans_no'];
            }
            break;
        case ST_CUSTCREDIT:
            if (get_voided_entry(ST_CUSTCREDIT, $row["trans_no"]) === false && $row['Allocated'] == 0) {
                if ($row['order_'] == 0) {
                    // free-hand credit note
                    $str = "/sales/credit_note_entry.php?ModifyCredit=" . $row['trans_no'];
                } else {
                    // credit invoice
                    $str = "/sales/customer_credit_invoice.php?ModifyCredit=" . $row['trans_no'];
                }
            }
            break;
        case ST_CUSTDELIVERY:
            if (get_voided_entry(ST_CUSTDELIVERY, $row["trans_no"]) === false) {
                $str = "/sales/customer_delivery.php?ModifyDelivery=" . $row['trans_no'];
            }
            break;
        case ST_CUSTPAYMENT:
            if (get_voided_entry(ST_CUSTPAYMENT, $row["trans_no"]) === false) {
                $str = "/sales/customer_payments.php?trans_no=" . $row['trans_no'];
            }
            break;
    }
    if ($str != "" && !is_closed_trans($row['type'], $row["trans_no"])) {
        return pager_link(_('Edit'), $str, ICON_EDIT);
    }
    return '';
}