Exemplo n.º 1
0
require_once "util.php";
require_once "DataBase/Product.php";
require_once "DataBase/Customer.php";
require_once "DataBase/Price.php";
require_once "DataBase/Priceset.php";
/* TODO: check if valid $priceset_id and what if no $customer_data found? */
$customer = new Customer();
$customer_data = $customer->get($_SESSION["username"]);
$priceset_id = 0;
if (count($customer_data) > 0) {
    $priceset_id = $customer_data[0][11];
}
$priceset = new Priceset();
$product = new Product();
$price = new Price();
$tmp_priceset = $priceset->get($priceset_id);
$netto = 0;
if (count($tmp_priceset) > 0) {
    $netto = $tmp_priceset[0][2];
}
?>

<div width="100%" align="center">

<?php 
// prepare search/filter params
$search_product = var_get_post("search_product", "");
$search_category = var_get_post("search_category", "");
$item_offset = var_get_post("item_offset", 0);
$item_count = var_get_post("item_count", 40);
if ($search_category != "") {
require_once "DataBase/Priceset.php";
// sync Product database
$product = new Product();
$product_net = new Product_Net();
$price = new Price();
$price_net = new Price_Net();
$priceset = new Priceset();
$new_product_count = 0;
$del_product_count = 0;
// delete remote products if not locally available anymore
$remote_product = $product_net->get('', array('product_id'));
foreach ($remote_product as $tmp) {
    if ($product->exists($tmp[0], " available=1 ") == false) {
        $product_net->delete($tmp[0]);
        // delete also the prices
        $local_pricesets = $priceset->get('');
        foreach ($local_pricesets as $tmp_priceset) {
            $tmp_price = $price_net->getPrice($tmp_priceset[0], $tmp[0]);
            if (count($tmp_price) > 0) {
                $price_net->delete($tmp_price[0][0]);
            }
        }
        $del_product_count++;
    }
}
// add products remote if newly available locally
$remote_products = $product_net->get('', array('product_id'));
$local_products = $product->get('', array('product_id'), " available=1 ");
foreach ($local_products as $tmp) {
    $found = false;
    foreach ($remote_products as $remote_tmp) {
require_once "DataBase/Bill.php";
require_once "DataBase/Assistant.php";
require_once "DataBase/Customer.php";
require_once "DataBase/Product.php";
require_once "DataBase/Bill_Product.php";
require_once "DataBase/Price.php";
require_once "DataBase/Priceset.php";
require_once "DataBase/Tax.php";
$bill_id = var_get_post("bill_id", "");
$bill = new Bill();
$tmp = $bill->get($bill_id);
$bill_data = $tmp[0];
$customer = new Customer();
$tmp = $customer->get($bill_data[1]);
$customer_data = $tmp[0];
$assistant = new Assistant();
$tmp = $assistant->get($bill_data[4]);
$assistant_data = $tmp[0];
$priceset = new Priceset();
$tmp = $priceset->get($customer_data[11]);
$priceset_data = $tmp[0];
$bill_product = new Bill_Product();
$bill_product_data = $bill_product->getByBillId($bill_id);
$product = new Product();
$price = new Price();
$tax = new Tax();
include "Druckvorlagen/zeilen.php";
include "Druckvorlagen/rechnung.php";
?>

Exemplo n.º 4
0
require_once "DataBase/Tax.php";
require_once "DataBase/Category.php";
require_once "DataBase/Priceset.php";
require_once "DataBase/Group.php";
require_once "DataBase/Price.php";
$db_action = var_get_post("db_action", "");
$product = new Product();
$tax = new Tax();
$category = new Category();
$priceset = new Priceset();
$price = new Price();
$group = new Group();
switch ($db_action) {
    case "new":
        $product->create(var_post("product_id", ""), array(var_post("name", ""), var_post("details", ""), var_post("category_id", ""), var_post("tax_id", ""), var_post("available", ""), var_post("group_id", ""), var_post("order_number", ""), var_post("anmerkung", "")));
        $priceset_list = $priceset->get();
        for ($i = 0; $i < count($priceset_list); $i++) {
            $price->create(var_post("priceset_id_" . $i, ""), var_post("product_id", ""), array(var_post("priceset_price_" . $i, "")));
        }
        break;
    case "edit":
        $product->update(var_post("product_id", ""), array(var_post("name", ""), var_post("details", ""), var_post("category_id", ""), var_post("tax_id", ""), var_post("available", ""), var_post("group_id", ""), var_post("order_number", ""), var_post("anmerkung", "")));
        $priceset_list = $priceset->get();
        for ($i = 0; $i < count($priceset_list); $i++) {
            if ($price->exists(var_post("priceset_id_" . $i, ""), var_post("product_id", ""))) {
                $price->update(var_post("priceset_id_" . $i, ""), var_post("product_id", ""), array(var_post("priceset_price_" . $i, "")));
            } else {
                $price->create(var_post("priceset_id_" . $i, ""), var_post("product_id", ""), array(var_post("priceset_price_" . $i, "")));
            }
        }
        break;
Exemplo n.º 5
0
            $search .= " AND (product_id >=" . $var_product_id_from . ") ";
        } else {
            $search .= "(product_id >=" . $var_product_id_from . ") ";
        }
    }
    if ($var_product_id_to) {
        if ($search) {
            $search .= " AND (product_id <=" . $var_product_id_to . ") ";
        } else {
            $search .= "(product_id <=" . $var_product_id_to . ") ";
        }
    }
    $product_data = $product->get('', array(), $search);
    $assistant_data = $assistant->get($var_assistant);
    $priceset = new Priceset();
    $tmp = $priceset->get($var_priceset);
    $priceset_data = $tmp[0];
    include "Druckvorlagen/zeilen.php";
    include "Druckvorlagen/list.php";
} elseif ($var_print == "print_re") {
    $search = "";
    if ($var_product_id) {
        if ($search) {
            $search .= " AND (product_id >=" . $var_product_id . ") ";
        } else {
            $search .= "(product_id >=" . $var_product_id . ") ";
        }
    }
    if ($var_date_from) {
        if ($search) {
            $search .= " AND (date >='" . $var_date_from . "') ";
Exemplo n.º 6
0
<?php

require_once "util.php";
$priceset = new Priceset();
if ($action == "new") {
    $priceset->create(var_post("priceset_id", ""), array(var_post("priceset_name", ""), var_post("priceset_netto", "")));
} elseif ($action == "edit") {
    $priceset->update(var_post("priceset_id", ""), array(var_post("priceset_name", ""), var_post("priceset_netto", "")));
} elseif ($action == "delete") {
    $priceset->delete(var_get("priceset_id", ""));
}
$priceset_box = new NTKVBox("priceset_box", 0, 1, False);
$label = new NTKLabel("priceset_label", "<h3>Preiss&auml;tze</h3>");
$priceset_box->add($label);
$priceset_list = $priceset->get('');
for ($i = 0; $i < count($priceset_list); $i++) {
    $priceset_box->add(new NTKEPriceset($priceset_list[$i][0], $priceset_list[$i][1], $priceset_list[$i][2]));
}
$label = new NTKLabel("priceset_label", "<h4>neuer Preissatz</h4>");
$priceset_box->add($label);
$priceset_box->add(new NTKEPriceset("", "", 1, True), -1);
$main_box->add($priceset_box, -1, -1, "background-color: #dfe7f3; vertical-align: top;");
require_once "DataBase_Net/Priceset_Net.php";
require_once "DataBase/Priceset.php";
// sync Priceset database
$priceset = new Priceset();
$priceset_net = new Priceset_Net();
$new_priceset_count = 0;
$del_priceset_count = 0;
$remote_pricesets = $priceset_net->get('', array('priceset_id'));
foreach ($remote_pricesets as $tmp) {
    if ($priceset->exists($tmp[0]) == false) {
        $priceset_net->delete($tmp[0]);
        $del_priceset_count++;
    }
}
$remote_pricesets = $priceset_net->get('', array('priceset_id'));
$local_pricesets = $priceset->get('', array('priceset_id'));
foreach ($local_pricesets as $tmp) {
    $found = false;
    foreach ($remote_pricesets as $remote_tmp) {
        if ($remote_tmp[0] == $tmp[0]) {
            $found = true;
            break;
        }
    }
    $tmp_data = $priceset->get($tmp[0], array("name", "netto"));
    if (!$found) {
        $priceset_net->create($tmp[0], $tmp_data[0]);
        $new_priceset_count++;
    } else {
        $priceset_net->update($tmp[0], $tmp_data[0]);
    }