Example #1
0
try {
    $billTotal = new number_formatting();
    // Used to make sure the bills are showing in the admins currency
    $billTotal->set_custom_cur_defaults($config['settings']['defaultcur']);
    $parms['noDefault'] = true;
    if (!$billID and !$orderID) {
        die('No bill/order ID was passed');
    }
    // Just to be safe make sure a bill/order ID was passed
    $invoiceObj = new invoiceTools();
    // Create new invoice object
    $invoiceObj->options = false;
    // Do not select options here
    $adminCurrency = getCurrencyInfo($config['settings']['defaultcur']);
    if ($billID) {
        $invoiceObj->setUBillID($billID);
        if ($billInfo = $invoiceObj->getBillDetails()) {
            $invoice = $invoiceObj->getInvoiceDetailsViaBillDBID($billInfo['bill_id']);
            if ($billInfo['bill_type'] == 2) {
                $ordersResult = mysqli_query($db, "\r\n\t\t\t\t\t\tSELECT * FROM {$dbinfo[pre]}orders \r\n\t\t\t\t\t\tLEFT JOIN {$dbinfo[pre]}invoices \r\n\t\t\t\t\t\tON {$dbinfo[pre]}orders.order_id = {$dbinfo[pre]}invoices.order_id\r\n\t\t\t\t\t\tWHERE {$dbinfo[pre]}orders.bill_id = {$billInfo[bill_id]}\r\n\t\t\t\t\t\t");
                // Select invoice items
                $invoiceItemsCount = mysqli_num_rows($ordersResult);
                while ($order = mysqli_fetch_array($ordersResult)) {
                    $invoiceItems[$order['order_id']] = $order;
                    $invoiceItems[$order['order_id']]['name'] = "{$lang[order]} {$order[order_number]}";
                    $invoiceItems[$order['order_id']]['quantity'] = 1;
                    if ($invoice['payment_status'] != 2) {
                        $invoiceItems[$order['order_id']]['price_total'] = $billTotal->currency_display($order['total'], 1);
                    } else {
                        $priceTotal = getCorrectedPrice($order['total'], $parms);
                        // Unpaid invoice can show in the members currency