示例#1
0
    if (isset($_POST['settled_amount']) && in_array(get_post('PayType'), array(PT_SUPPLIER, PT_CUSTOMER)) && input_num('settled_amount') <= 0) {
        display_error(_("Settled amount have to be positive number."));
        set_focus('person_id');
        $input_error = 1;
    }
    return $input_error;
}
if (isset($_POST['Process']) && !check_trans()) {
    begin_transaction();
    $_SESSION['pay_items'] =& $_SESSION['pay_items'];
    $new = $_SESSION['pay_items']->order_id == 0;
    add_new_exchange_rate(get_bank_account_currency(get_post('bank_account')), get_post('date_'), input_num('_ex_rate'));
    $trans = write_bank_transaction($_SESSION['pay_items']->trans_type, $_SESSION['pay_items']->order_id, $_POST['bank_account'], $_SESSION['pay_items'], $_POST['date_'], $_POST['PayType'], $_POST['person_id'], get_post('PersonDetailID'), $_POST['ref'], $_POST['memo_'], true, input_num('settled_amount', null));
    $trans_type = $trans[0];
    $trans_no = $trans[1];
    write_trans($_SESSION['pay_items']->trans_type, $trans_no, $_POST['cv_no'], $_POST['address'], $_POST['check_num']);
    //moodlearning
    new_doc_date($_POST['date_']);
    $_SESSION['pay_items']->clear_items();
    unset($_SESSION['pay_items']);
    commit_transaction();
    if ($new) {
        meta_forward($_SERVER['PHP_SELF'], $trans_type == ST_BANKPAYMENT ? "AddedID={$trans_no}" : "AddedDep={$trans_no}");
    } else {
        meta_forward($_SERVER['PHP_SELF'], $trans_type == ST_BANKPAYMENT ? "UpdatedID={$trans_no}" : "UpdatedDep={$trans_no}");
    }
}
//-----------------------------------------------------------------------------------------------
function check_item_data()
{
    if (!check_num('amount', 0)) {
     if ($dim2_ref != '' && $dim2 == null) {
         display_error("Error: Could not find dimension with reference '{$dim2_ref}' (line {$line} in import file '{$_FILES['imp']['name']}')");
         $error = true;
     }
     if ($type == ST_BANKDEPOSIT) {
         $amt = -$amt;
     }
     // Add to the journal entry / deposit / payment
     if (!$error) {
         $entry->add_gl_item($code, $dim1, $dim2, $amt, $memo);
     }
 }
 // Process final entries in the file
 if (!$error) {
     if ($curEntryId != null) {
         write_trans($type, $entry, $curEntryId, $bank_account);
         $entryCount++;
     }
 } else {
     $errCnt++;
 }
 @fclose($fp);
 // Commit import to database
 if (!$errCnt) {
     commit_transaction();
 }
 if ($type == ST_JOURNAL) {
     $typeString = "journal entries";
 } elseif ($type == ST_BANKDEPOSIT) {
     $typeString = "deposits";
 } elseif ($type == ST_BANKPAYMENT) {