function parse_invoices($url, $xml_file, $username, $pw, $inventories)
{
    if ($xml_file != NULL) {
        $results = array();
        //Checks if each of the products is available online
        foreach ($xml_file->order as $order) {
            //Bigcommerce's status for completed order is '10'
            if ($order->status_id == 10) {
                $xml_part1 = '<?xml version="1.0" encoding="UTF-8"?>
                      <invoice>
                        <invoice_date>' . $order->date_shipped . '</invoice_date>
                        <reference>' . $order->id . '</reference>
                        <invoice_lines type="array">';
                //Gets products included on invoice
                //Uses product list link
                $xml_part2 = get_order_products($order->products->link, $inventories);
                $xml_part3 = '</invoice_lines>
                        <payments type="array">
                        <payment>
                          <amount>' . $order->total_inc_tax . '</amount>
                        </payment>
                        </payments>
                      </invoice>';
                //Complete xml_file to be posted
                $xml = $xml_part1 . $xml_part2 . $xml_part3;
                //Checks if product is available in Imonggo
                if ($xml_part2 !== 0) {
                    $result = post_file($url, $xml, $username, $pw);
                }
            }
        }
        //end of foreach
    }
}
Example #2
0
require_once MODULE_DIR . "productcatalog/mod.category.inc";
require_once MODULE_DIR . "productcatalog/mod.variable.inc";
require_once MODULE_DIR . "productcatalog/mod.product.substructure.inc";
if (!$objIPAccess->fnValidate($arrAllowIP["access"], $_SERVER["REMOTE_ADDR"]) or $objIPAccess->fnValidate($arrAllowIP["deny"], $_SERVER["REMOTE_ADDR"])) {
    header("Location: " . LOGINCENTER_PATH);
}
if (!is_object($_SESSION["user"])) {
    header("Location: " . LOGINCENTER_PATH);
}
if ($_GET['tellimus']) {
    $change = get_tellimus($_GET['tellimus']);
    $change_tellimus = $change[0];
    $tellimus->id = $change_tellimus['id'];
    $tellimus->viitenumber = $change_tellimus['reference_number'];
    $tellimus->explanation = $change_tellimus['explanation'];
    $tellimus->products = get_order_products($tellimus->id);
}
if ($_SESSION['order_changed'] == 1) {
    $tellimus->changes_applayed = 1;
    unset($_SESSION['order_changed']);
}
if ($_SESSION['order_added'] == 1) {
    $tellimus->order_added = 1;
    unset($_SESSION['order_added']);
}
$arrUsers = $objUser->fnGetUserList(0, "client");
$tellimus->arrUsers = $arrUsers->arrData;
$arrProducts = $objProductAdmin->fnGetProductList();
$arrProducts = $arrProducts->arrData;
if ($_POST['transport']) {
    $tellimus->transport = $_POST['transport'];
Example #3
0
require_once MODULE_DIR . "productcatalog/mod.product.substructure.inc";
require_once MODULE_DIR . "phpmailer/class.phpmailer.php";
if (!$objIPAccess->fnValidate($arrAllowIP["access"], $_SERVER["REMOTE_ADDR"]) or $objIPAccess->fnValidate($arrAllowIP["deny"], $_SERVER["REMOTE_ADDR"])) {
    header("Location: " . LOGINCENTER_PATH);
}
if (!is_object($_SESSION["user"])) {
    header("Location: " . LOGINCENTER_PATH);
}
if ($_GET['tellimus']) {
    if ($_SESSION['email'][$_GET['tellimus']] && $_SESSION['email'][$_GET['tellimus']] > time() - 300 && $_GET['send']) {
        $engSmarty->display("admin/not_sended.tpl");
        exit;
    }
    $change = get_tellimus($_GET['tellimus']);
    $tellimus = $change[0];
    $products = get_order_products($tellimus['id']);
    if ($tellimus['bank_id'] == 5) {
        $installment[0] = $tellimus['installment_period'];
        $installment[1] = $tellimus['installment_price'];
    }
} else {
    exit;
}
$arrData->invoice = str_replace("Arve Nr:", "", $tellimus['explanation']);
$arrData->date = date("d.m.Y", $tellimus['date_add_u']);
if (!$installment) {
    $arrData->total_price = $tellimus['total_price'];
}
if (!$installment && !$banklink) {
    $expire = mktime(0, 0, 0, date("m", $tellimus['date_add_u']), date("d", $tellimus['date_add_u']) + 7, date("Y", $tellimus['date_add_u']));
} else {