Exemplo n.º 1
0
/**
 * doJournal
 * Jurnal Transaksi Adjustment
 */
function doJournal($dataRes, $counterJurnal, $kodePt, $kodeJurnal)
{
    global $dbname;
    $queryH = insertQuery($dbname, 'keu_jurnalht', $dataRes['header']);
    if (!mysql_query($queryH)) {
        exit("DB Error: " . mysql_error());
    } else {
        foreach ($dataRes['detail'] as $det) {
            $queryD = insertQuery($dbname, 'keu_jurnaldt', $det);
            if (!mysql_query($queryD)) {
                echo "DB Error: " . mysql_error();
                rbJournal($dataRes['header']['nojurnal']);
            }
        }
    }
    // Get Journal Counter
    $whereUpd = "kodeorg='" . $kodePt . "' and kodekelompok='" . $kodeJurnal . "'";
    $data = array('nokounter' => $counterJurnal);
    $updateC = updateQuery($dbname, 'keu_5kelompokjurnal', $data, $whereUpd);
    if (!mysql_query($updateC)) {
        echo "DB Error: " . mysql_error();
        rbJournal($dataRes['header']['nojurnal']);
    }
}
            $queryH = insertQuery($dbname, 'keu_jurnalht', $dataRes['header']);
            if (!mysql_query($queryH)) {
                exit("DB Error: " . mysql_error());
            } else {
                if (!empty($dataRes['detail'])) {
                    foreach ($dataRes['detail'] as $det) {
                        $queryD = insertQuery($dbname, 'keu_jurnaldt', $det);
                        if (!mysql_query($queryD)) {
                            echo "DB Error: " . mysql_error();
                            rbJournal($dataRes['header']['nojurnal']);
                        }
                    }
                    $sUpdate = "update " . $dbname . ".keu_5kelompokjurnal set nokounter=" . intval($konter) . " where kodeorg='" . $kodePt . "' and kodekelompok='" . $kodeJurnal . "'";
                    mysql_query($sUpdate) or die(mysql_error($conn));
                } else {
                    rbJournal($dataRes['header']['nojurnal']);
                    exit("warning: Detail jurnal Kosong");
                }
            }
        }
        $tmpKonter = "";
        $dataRes['header'] = array();
        $dataRes['detail'] = array();
    }
}
/**
 * rbJournal
 * Rollback Jurnal Transaksi Adjustment
 */
function rbJournal($nojurnal)
{