function cc_TranTypeAcc($dtaccid, $ctaccid)
 {
     $dtacc = getAcc($dtaccid);
     $ctacc = getAcc($ctaccid);
     if ($dtacc['acctype'] == 'I' && $ctacc['acctype'] == 'I') {
         return false;
     }
     if ($dtacc['acctype'] == 'E' && $ctacc['acctype'] == 'E') {
         return false;
     }
     if ($dtacc['acctype'] == 'B' && $ctacc['acctype'] == 'B') {
         return false;
     }
     if ($dtacc['acctype'] == 'E' && $ctacc['acctype'] == 'I') {
         return "dtct";
     }
     if ($dtacc['acctype'] == 'E' && $ctacc['acctype'] == 'B') {
         return "ct";
     }
     if ($dtacc['acctype'] == 'I' && $ctacc['acctype'] == 'E') {
         return "dtct";
     }
     if ($dtacc['acctype'] == 'I' && $ctacc['acctype'] == 'B') {
         return "ct";
     }
     if ($dtacc['acctype'] == 'B' && ($ctacc['acctype'] == 'I' || $ctacc['acctype'] == 'E')) {
         return "dt";
     }
 }
/**
 * @ignore
 */
function writetransdivy($dtacc, $ctacc, $date, $refnum, $amount, $details, $div)
{
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($ctacc, "num", 1, 50, "Invalid Account to be Credited.");
    $v->isOk($dtacc, "num", 1, 50, "Invalid Account to be Debited.");
    $v->isOk($date, "date", 1, 14, "Invalid date.");
    $v->isOk($refnum, "num", 1, 50, "Invalid reference number.");
    $v->isOk($amount, "float", 1, 50, "Invalid Amount {$amount}.");
    $v->isOk($details, "string", 0, 2048, "Invalid Details. ({$details})");
    if ($v->isError()) {
        $write = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $write .= "<li class=err>" . $e["msg"];
        }
        $write .= "<p><input type=button onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        $OUTPUT = $write;
        require "template.php";
    }
    if (floatval($amount) == floatval(0)) {
        return;
    }
    # date format
    $date = explode("-", $date);
    $date = $date[2] . "-" . $date[1] . "-" . $date[0];
    /*
    # Insert the records into the transect table
    db_conn(PRD_DB);
    $sql = "INSERT INTO transect(debit, credit, date, refnum, amount, author, details, div) VALUES('$dtacc', '$ctacc', '$date', '$refnum', '$amount', '".USER_NAME."', '$details', '$div')";
    $transRslt = db_exec($sql) or errDie("Unable to insert Transaction  details to database",SELF);
    */
    # Get account information
    if ($dtacc != 0) {
        $dacc = getAcc($dtacc);
    } else {
        $dacc['accname'] = 0;
        $dacc['topacc'] = 0;
        $dacc['accnum'] = 0;
    }
    if ($ctacc != 0) {
        $cacc = getAcc($ctacc);
    } else {
        $cacc['accname'] = 0;
        $cacc['topacc'] = 0;
        $cacc['accnum'] = 0;
    }
    # Insert the records into the transect table
    global $PRDMON;
    db_conn($PRDMON[1]);
    $sql = "INSERT INTO transect(debit, daccname, dtopacc, daccnum , credit,\n\t\t\t\tcaccname, ctopacc, caccnum, date, refnum, amount, author, details, div)\n\t\t\tVALUES('{$dtacc}', '{$dacc['accname']}','{$dacc['topacc']}','{$dacc['accnum']}',\n\t\t\t\t'{$ctacc}', '{$cacc['accname']}','{$cacc['topacc']}','{$cacc['accnum']}',\n\t\t\t\t'{$date}', '{$refnum}', '{$amount}', '" . USER_NAME . "', '{$details}', '{$div}')";
    $transRslt = db_exec($sql) or errDie("Unable to insert Transaction  details to database", SELF);
    # Update the balances by adding appropriate values to the trial_bal Table
    core_connect();
    # begin sql transaction
    # pglib_transaction ("BEGIN") or errDie("Unable to start a database transaction.",SELF);
    $ctbal = "UPDATE trial_bal SET credit = (credit + '{$amount}') WHERE accid = '{$ctacc}'";
    $dtbal = "UPDATE trial_bal SET debit = (debit + '{$amount}') WHERE accid  = '{$dtacc}'";
    $ctbalRslt = db_exec($ctbal) or errDie("Unable to update credit balance for credited account.", SELF);
    $dtbalRslt = db_exec($dtbal) or errDie("Unable to update debit balance for debited account.", SELF);
    # commit sql transaction
    # pglib_transaction ("COMMIT") or errDie("Unable to finish a database transaction.",SELF);
}