Exemplo n.º 1
0
function update_gateway_fee2($vars)
{
    $invoice = mysql_fetch_row(mysql_query("SELECT `userid` FROM `tblinvoices` WHERE `id`='" . $vars[invoiceid] . "'"));
    $user = mysql_fetch_row(mysql_query("SELECT `currency` FROM `tblclients` WHERE `id`='" . $invoice[0] . "'"));
    $currency = mysql_fetch_row(mysql_query("SELECT `code` FROM `tblcurrencies` WHERE `id`='" . $user[0] . "'"));
    $paymentmethod = $vars['paymentmethod'];
    delete_query("tblinvoiceitems", "invoiceid='" . $vars[invoiceid] . "' and notes='gateway_fees'");
    $result = select_query("tbladdonmodules", "setting,value", "setting='fee_2_" . $vars['paymentmethod'] . '_' . $currency[0] . "' or setting='fee_1_" . $vars[paymentmethod] . '_' . $currency[0] . "'");
    while ($data = mysql_fetch_array($result)) {
        $params[$data['setting']] = $data['value'];
    }
    $fee1 = $params['fee_1_' . $paymentmethod . '_' . $currency[0]];
    $fee2 = $params['fee_2_' . $paymentmethod . '_' . $currency[0]];
    $total = InvoiceTotal($vars['invoiceid']);
    if ($total > 0) {
        $amountdue = $fee1 + $total * $fee2 / 100;
        if ($fee1 > 0 & $fee2 > 0) {
            $d = $fee1 . '+' . $fee2 . "%";
        } elseif ($fee2 > 0) {
            $d = $fee2 . "%";
        } elseif ($fee1 > 0) {
            $d = $fee1;
        }
    }
    if ($d) {
        insert_query("tblinvoiceitems", array("userid" => $_SESSION['uid'], "invoiceid" => $vars[invoiceid], "type" => "Fee", "notes" => "gateway_fees", "description" => getGatewayName2($vars['paymentmethod']) . " комиссия ({$d}) в " . $currency[0], "amount" => $amountdue, "taxed" => "0", "duedate" => "now()", "paymentmethod" => $vars[paymentmethod]));
    }
    updateInvoiceTotal($vars[invoiceid]);
}
Exemplo n.º 2
0
function update_gateway_fee2($vars)
{
    $paymentmethod = $vars['paymentmethod'];
    delete_query("tblinvoiceitems", "invoiceid='" . $vars[invoiceid] . "' and notes='gateway_fees'");
    $result = select_query("tbladdonmodules", "setting,value", "setting='fee_2_" . $vars['paymentmethod'] . "' or setting='fee_1_" . $vars[paymentmethod] . "'");
    while ($data = mysql_fetch_array($result)) {
        $params[$data[0]] = $data[1];
    }
    $fee1 = $params['fee_1_' . $paymentmethod];
    $fee2 = $params['fee_2_' . $paymentmethod];
    $total = InvoiceTotal($vars['invoiceid']);
    if ($total > 0) {
        $amountdue = $fee1 + $total * $fee2 / 100;
        if ($fee1 > 0 & $fee2 > 0) {
            $d = $fee1 . '+' . $fee2 . "%";
        } elseif ($fee2 > 0) {
            $d = $fee2 . "%";
        } elseif ($fee1 > 0) {
            $d = $fee1;
        }
    }
    if ($d) {
        insert_query("tblinvoiceitems", array("userid" => $_SESSION['uid'], "invoiceid" => $vars[invoiceid], "type" => "Fee", "notes" => "gateway_fees", "description" => getGatewayName2($vars['paymentmethod']) . " Fees ({$d})", "amount" => $amountdue, "taxed" => "0", "duedate" => "now()", "paymentmethod" => $vars[paymentmethod]));
    }
    updateInvoiceTotal($vars[invoiceid]);
}