<?php

require_once "util.php";
require_once "NTK/NTK.php";
require_once "DataBase/Product.php";
?>

<html>
<head>
	<title> Index </title>

<?php 
include "Modules/Product/db_action.php";
$main_box = new NTKVBox("main_box", 0, 0, False);
// Toolbar
$page = "product";
$printfile = "";
include "Modules/toolbar.php";
// small Toolbar
include "Modules/Product/toolbar.php";
// main content
$action = var_get_post("action", "");
$search = var_post("search_entry", "");
$product_id = var_get_post("product_id", "");
$onload .= "document.getElementById('search_entry').focus();";
if ($action == "new") {
    include "Modules/Product/new_form.php";
} elseif ($action == "edit" && $product_id != "") {
    $data = $product->get($product_id);
    include "Modules/Product/edit_form.php";
} elseif ($action == "search" && $search != "") {
<?php

require_once "NTK/NTK.php";
require_once "DataBase/Product.php";
?>

<html>
<head>
	<title> Index </title>

<?php 
echo getHead();
include "Modules/Product/db_action.php";
$main_box = new NTKVBox("main_box", 0, 0, False);
$main_box->add(new NTKLabel("", "Programmversion: 1.5"), -1, -1);
echo $main_box->getHtml();
?>

</body>
</html>
    }
    if (var_post("date_to", "")) {
        if ($search) {
            $search .= " AND (date <='" . var_post("date_to", "") . "') ";
        } else {
            $search .= "(date <='" . var_post("date_to", "") . "') ";
        }
    }
    $bill_data = $bill->get("", array("bill_id"), $search);
    $bill_product = new Bill_Product();
    $tour_data[1] = "( Alle Touren )";
    $product = new Product();
    $product_data = $product->get();
    include "Druckvorlagen/tour.php";
} else {
    $toolbar_box = new NTKVBox("toolbar_box", 0, 0, False);
    $main_box = new NTKTable("main_box", 5, 4, False);
    $main_box->setStyle("background-color: #dfe7f3;");
    $main_box->add(new NTKLabel("", "<b>Rechnungszusammenfassung nach Datum</b>"), 0, 0);
    $main_box->add(new NTKLabel("", "Von:"), 2, 0);
    $main_box->add(new NTKEntry("date_from", ""), 2, 1);
    $main_box->add(new NTKLabel("", "Bis:"), 2, 2);
    $main_box->add(new NTKEntry("date_to", ""), 2, 3);
    $main_box->add(new NTKButton("submit", "Druckvorschau", "document.forms['print_re'].submit();"), 4, 3);
    $form = new NTKForm("print_re", "stat_bill_merge.php", $main_box);
    $form->addAttribute("print", "print_re");
    $toolbar_box->add($form, 0, 0);
    echo getHead();
    echo $toolbar_box->getHtml();
}
?>
<?php

require_once "util.php";
$group = new Group();
if ($action == "new") {
    $group->create(var_post("group_id", ""), array(var_post("group_name", "")));
} elseif ($action == "edit") {
    $group->update(var_post("group_id", ""), array(var_post("group_name", "")));
} elseif ($action == "delete") {
    $group->delete(var_get("group_id", ""));
}
$group_box = new NTKVBox("group_box", 0, 0, False);
$label = new NTKLabel("group_label", "<h3>Gruppen</h3>");
$group_box->add($label);
$group_list = $group->get('');
for ($i = 0; $i < count($group_list); $i++) {
    $group_box->add(new NTKEGroup($group_list[$i][0], $group_list[$i][1]));
}
$label = new NTKLabel("group_label", "<h4>neue Gruppe</h4>");
$group_box->add($label);
$group_box->add(new NTKEGroup("", "", True), -1);
$main_box->add($group_box, -1, -1, "background-color: #dfe7f3; vertical-align: top;");
<?php

require_once "util.php";
require_once "NTK/NTK.php";
require_once "DataBase/Tax.php";
require_once "DataBase/Priceset.php";
require_once "DataBase/Group.php";
?>

<html>
<head>
	<title> Index </title>
	
<?php 
echo getHead();
$main_box = new NTKVBox("main_box", 0, 0, False);
// Toolbar
$page = "configuration";
$printfile = "";
include "Modules/toolbar.php";
// small Toolbar
include "Modules/Configuration/toolbar.php";
// main content
$action = var_get_post("action", "");
$page = var_get_post("page", "");
// tax
if ($page == "tax") {
    include "Modules/Configuration/tax.php";
} elseif ($page == "priceset") {
    include "Modules/Configuration/priceset.php";
} elseif ($page == "group") {
<?php

require_once "util.php";
require_once "NTK/NTK.php";
require_once "DataBase/Tour.php";
require_once "DataBase/Assistant.php";
?>

<html>
<head>
	<title> Index </title>

<?php 
include "Modules/Tour/db_action.php";
$main_box = new NTKVBox("main_box", 0, 0, False);
$action = var_get_post("action", "");
$tour_id = var_get_post("tour_id", "");
$datum = var_get_post("date", "");
// Toolbar
$page = "tour";
$printfile = "";
if ($action == "list_tour") {
    $printfile = "print_tour.php?tour_id=" . $tour_id . "&date=" . $datum;
}
include "Modules/toolbar.php";
// small Toolbar
include "Modules/Tour/toolbar.php";
// main content
if ($action == "new") {
    include "Modules/Tour/new_form.php";
} elseif ($action == "edit" && $tour_id != "") {
<?php

$bill_box = new NTKVBox("bill_box", 0, 0, False);
$customer_data = $customer->get($data[0][1]);
$label = new NTKLabel("bill_label", "<b>Rechung: " . $data[0][5] . "<br>" . $customer_data[0][2] . " " . $customer_data[0][3] . "</b><br><br>");
$bill_box->add($label);
$bill_list = $bill_product->getByBillId($data[0][0]);
$bill_pos_table = new NTKTable("", count($bill_list) + 2, 7, False);
$bill_pos_table->add(new NTKLabel("", "Produktnummer"), 0, 0, 100);
$bill_pos_table->add(new NTKLabel("", "Produkt"), 0, 1);
$bill_pos_table->add(new NTKLabel("", "St&uuml;ck"), 0, 2, 60);
$bill_pos_table->add(new NTKLabel("", "Anmerkung"), 0, 3, 200);
$bill_pos_table->add(new NTKLabel("", "Rabatt"), 0, 4, 60);
$bill_pos_table->addFormRow("bill_product_form_new", "bill.php", 1, array(array('db_action', 'position_add'), array('bill_product_id', ''), array('bill_id', $data[0][0]), array('action', 'edit'), array('from_page', $from_page), array('fp_tour_id', $fp_tour_id), array('fp_date', $fp_date)));
$product_id_entry = new NTKEntry("product_id", "");
$product_id_entry->addEvent("onkeyup", "parent.frames['action'].location.href='action_product.php?form=bill_product_form_new&entry=product_id&next=amount&search='+this.value;");
$onload .= "document.getElementById('product_id').focus();";
$bill_pos_table->add($product_id_entry, 1, 0, 100);
$bill_pos_table->add(new NTKLabel("", "&nbsp;"), 1, 1);
$bill_pos_table->add(new NTKEntry("amount", ""), 1, 2, 60);
$bill_pos_table->add(new NTKEntry("details", ""), 1, 3, 200);
$bill_pos_table->add(new NTKEntry("rabatt", ""), 1, 4, 60);
$bill_pos_table->add(new NTKButton("", "hinzuf&uuml;gen", "document.forms['bill_product_form_new'].submit();"), 1, 6);
for ($i = 0; $i < count($bill_list); $i++) {
    $product_data = $product->get($bill_list[$i][2]);
    $bill_pos_table->addFormRow("bill_product_form_" . $bill_list[$i][0], "bill.php", $i + 2, array(array('db_action', 'position_edit'), array('bill_product_id', $bill_list[$i][0]), array('bill_id', $bill_list[$i][1]), array('action', 'edit'), array('price', $bill_list[$i][6]), array('tax', $bill_list[$i][7]), array('from_page', $from_page), array('fp_tour_id', $fp_tour_id), array('fp_date', $fp_date)));
    $product_id_entry = new NTKEntry("product_id", $bill_list[$i][2]);
    $product_id_entry->addEvent("onkeyup", "parent.frames['action'].location.href='action_product.php?form=bill_product_form_" . $bill_list[$i][0] . "&entry=product_id&next=amount&search='+this.value;");
    $bill_pos_table->add($product_id_entry, $i + 2, 0, 100);
    $bill_pos_table->add(new NTKLabel("", $product_data[0][1]), $i + 2, 1);
    $bill_pos_table->add(new NTKEntry("amount", $bill_list[$i][3]), $i + 2, 2, 60);
require_once "NTK/NTK.php";
?>

<html>
<head>
	<title> Index </title>
	
<?php 
echo getHead();
?>

</head>

<body>

<?php 
$main_box = new NTKVBox("main_box", 0, 0, False);
// Toolbar
$page = "sync";
include "Lib/toolbar.php";
// small Toolbar
include "Lib/customer_toolbar.php";
// main content
$main_box->add($spacer, -1, -1, "background-color:\t\t#dfe7f3;");
echo $main_box->getHtml();
?>

</body>
</html>
<html>
<head>
	<title> Index </title>

<?php 
echo getHead();
?>

</head>

<body>

<?php 
$action = var_get_post("action", "");
$main_box = new NTKVBox("main_box", 0, 0, False);
// Toolbar
$page = "websync";
$printfile = "";
include "Modules/toolbar.php";
// if($action == "upload_0")
// {
// 	$main_box->add(new NTKLabel("", "Neue Produkte / Preise online stellen"), 200, 10, "font-style: bold; background-color: #dfe7f3;");
//
// 	$button_next = new NTKButton("button_next", "Weiter", "location.replace('websync.php?action=upload_1');");
// 	$main_box->add($button_next);
// }
if ($action == "upload_0") {
    require_once "DataBase/Priceset.php";
    require_once "DataBase/Customer.php";
    require_once "DataBase/Product.php";
<?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;");
?>

<html>
<head>
	<title> Index </title>
	
<?php 
echo getHead();
?>

</head>

<body>

<?php 
$main_box = new NTKVBox("main_box", 0, 0, False);
// Toolbar
$page = "sync";
$printfile = "";
include "Modules/toolbar.php";
// $handle = popen("C:\apache\htdocs\bin\backup.bat", "r");
$handle = popen("sudo /var/www/ursprung/bin/backup.sh", "r");
$read = fread($handle, 2096);
pclose($handle);
// main content
$main_box->add(new NTKLabel("", "Datensicherung " . $read), 200, -1, "background-color:\t\t#dfe7f3;");
$main_box->add($spacer, -1, -1, "background-color:\t\t#dfe7f3;");
echo $main_box->getHtml();
?>

</body>
require_once "DataBase/Price.php";
require_once "DataBase/Category.php";
require_once "DataBase/Tax.php";
require_once "DataBase/Assistant.php";
require_once "DataBase/Bill.php";
require_once "DataBase/Bill_Product.php";
$group = new Group();
$priceset = new Priceset();
$category = new Category();
$product = new Product();
$price = new Price();
$tax = new Tax();
$assistant = new Assistant();
$bill = new Bill();
echo getHead();
$toolbar_box = new NTKVBox("toolbar_box", 5, 0, True);
$product_id = var_post("product_id", "");
$date_from = var_post("date_from", "");
$date_to = var_post("date_to", "");
if ($product_id != "" && $date_from != "" && $date_to != "") {
    $product_amount = $product->getAmountByDate($product_id, $date_from, $date_to, 1);
    $bill_data = $product->getBillsByDate($product_id, $date_from, $date_to, 1);
    $customer_data = $product->getCustomersByDate($product_id, $date_from, $date_to, 1);
    $result_box = new NTKTable("result_box", 4, 2, False);
    $result_box->setStyle("background-color: #F8FF77;");
    $result_box->add(new NTKLabel("", "Produktnummer:"), 0, 0);
    $result_box->add(new NTKLabel("", "<b>" . $product_id . "</b>"), 0, 1);
    $result_box->add(new NTKLabel("", "Zeitraum:"), 1, 0);
    $result_box->add(new NTKLabel("", "von <b>" . $date_from . "</b> bis <b>" . $date_to . "</b>"), 1, 1);
    $result_box->add(new NTKLabel("", "Menge:"), 1, 0);
    $result_box->add(new NTKLabel("", "<b>" . round($product_amount, 2) . "</b>"), 1, 1);
<?php

require_once "util.php";
$tax = new Tax();
if ($action == "new") {
    $tax->create(var_post("tax_id", ""), array(var_post("tax_name", ""), var_post("tax_rate", "")));
} elseif ($action == "edit") {
    $tax->update(var_post("tax_id", ""), array(var_post("tax_name", ""), var_post("tax_rate", "")));
} elseif ($action == "delete") {
    $tax->delete(var_get("tax_id", ""));
}
$tax_box = new NTKVBox("tax_box", 0, 0, False);
$label = new NTKLabel("tax_label", "<h3>Steuers&auml;tze</h3>");
$tax_box->add($label);
$taxlist = $tax->get('');
for ($i = 0; $i < count($taxlist); $i++) {
    $tax_box->add(new NTKETax($taxlist[$i][0], $taxlist[$i][1], $taxlist[$i][2]));
}
$label = new NTKLabel("tax_label", "<h4>neuer Steuersatz</h4>");
$tax_box->add($label);
$tax_box->add(new NTKETax("", "", "", True), -1);
$main_box->add($tax_box, -1, -1, "background-color: #dfe7f3; vertical-align: top;");