$transaction['trans_amount'] = get_numeric_form_value("trans_amount", '');
$transaction['trans_date'] = get_form_value("trans_date", '');
$transaction['trans_desc'] = get_form_value("trans_desc", '');
$transaction['id_adh'] = get_numeric_form_value("id_adh", '');
// flagging required fields
$required = array('trans_amount' => 1, 'trans_date' => 1, 'trans_desc' => 1, 'id_adh' => 1);
$disabled = array();
if (isset($_GET['detach'])) {
    if (!Contribution::unsetTransactionPart($trans_id, $_GET['detach'])) {
        $error_detected[] = _T("Unable to detach contribution from transaction");
    } else {
        $success_detected[] = _T("Contribution has been successfully detached from current transaction");
    }
}
if (isset($_GET['cid']) && $_GET['cid'] != null) {
    if (!Contribution::setTransactionPart($trans_id, $_GET['cid'])) {
        $error_detected[] = _T("Unable to attach contribution to transaction");
    } else {
        $success_detected[] = _T("Contribution has been successfully attached to current transaction");
    }
}
if ($trans_id != '') {
    // initialize transactions structure with database values
    $trans->load($trans_id);
    if ($trans->id == '') {
        //not possible to load transaction, exit
        header('location: index.php');
        die;
    }
}
// Validation