<?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>
<?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;");
    if ($search_category != "") {
        if ($search_toggle && count($search_category) > 0) {
            for ($i = 0; $i < count($search_category); $i++) {
                $search_in .= " category_id='" . $search_category[$i] . "' AND ";
            }
        } elseif (count($search_category) > 0) {
            for ($i = 0; $i < count($search_category); $i++) {
                $search_in .= " category_id<>'" . $search_category[$i] . "' AND ";
            }
        }
    }
    $list_view = new NTKListView("list_view", array('Produktnummer', 'Name', 'Beschreibung'), "location.href = 'product.php?action=edit&product_id=%0%';");
    $results = $product->get('', array('product_id', 'name', 'details'), $search_in . " (product_id LIKE '%{$search}%' OR name LIKE'%{$search}%' OR details LIKE '%{$search}%' OR order_number LIKE '%{$search}%')");
    if (count($results) == 1) {
        $onload = "location.href = 'product.php?action=edit&product_id=" . $results[0][0] . "';";
    }
    $list_view->addLines($results);
    $main_box->add($list_view, -1, -1, "background-color: #dfe7f3; vertical-align: top;");
} else {
    /*$list_view = new NTKListView("list_view", array('Produktnummer','Name','Beschreibung'), "location.href = '$PHP_SELF?action=edit&product_id=%0%';");
    	$list_view->addLines($product->get('', array('product_id', 'name', 'details')));
    	$main_box->add($list_view, -1, -1, "background-color: #dfe7f3; vertical-align: top;");*/
    $main_box->add(new NTKSpacer(), -1, -1);
}
echo getHead();
echo $main_box->getHtml();
?>

</body>
</html>
<?php

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

<html>
<head>
	<title> Index </title>
	
<?php 
echo getHead();
$search = var_get("search", "");
if (strlen($search) >= 3) {
    $customer = new Customer();
    $main_box = new NTKVBox("main_box", 0, 0, False);
    $list_view = new NTKListView("list_view", array('Kundennummer', 'Vorname', 'Nachname'), "parent.frames['main'].document." . var_get("form", "") . "." . var_get("entry", "") . ".value = '%0%';parent.frames['main'].document." . var_get("form", "") . "." . var_get("next", "") . ".focus();");
    $list_view->addLines($customer->get('', array('customer_id', 'prename', 'postname'), "customer_id LIKE '%{$search}%' OR prename LIKE'%{$search}%' OR postname LIKE '%{$search}%'"));
    $main_box->add($list_view, -1, -1, "background-color: #dfe7f3; vertical-align: top;");
    echo $main_box->getHtml();
}
?>

</body>
</html>
            $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();
}
?>
		</body>
		</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") {
    include "Modules/Configuration/group.php";
} else {
    $main_box->add($spacer, -1, -1, "background-color: #dfe7f3; vertical-align: top;");
}
echo $main_box->getHtml();
?>

</body>
</html>
    $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 != "") {
    $data = $tour->get($tour_id);
    include "Modules/Tour/edit_form.php";
} elseif ($action == "search" && var_post("search_entry", "") != "") {
    $search = var_post("search_entry", "");
    $list_view = new NTKListView("list_view", array('Tournummer', 'Bezeichner'), "location.href = 'tour.php?action=edit&tour_id=%0%';");
    $list_view->addLines($tour->get('', array('tour_id', 'name'), "tour_id LIKE '%{$search}%' OR name LIKE'%{$search}%'"));
    $main_box->add($list_view, -1, -1, "background-color: #dfe7f3; vertical-align: top;");
} elseif ($action == "list_tour") {
    $assistant = new Assistant();
    $tour = new Tour();
    $bill_box = new NTKHBox("bill_box", 0, 0);
    $bill_box->add(new NTKLabel("", "<b>Tournummer: " . $tour_id . " - Datum: " . $datum . "</b>"), False, False, "background-color: #dfe7f3;");
    $bill_box->add(new NTKLabel("", "Kundennummer:"), 150);
    $bill_box->add(new NTKEntry("customer_id", ""), 120);
    $bill_box->add(new NTKLabel("", "Mitarbeiter:"), 120);
    $bill_box->add(new NTKComboBox("assistant_id", $assistant->get()), 120);
    $bill_box->add(new NTKLabel("", "Tour:"), 80);
    $bill_box->add(new NTKComboBox("tour_id", $tour->get()), 120);
    $bill_box->add(new NTKButton("bill_button", "Erstelle Rechnung", "document.forms['bill_form'].submit();"), 200);
    $bill_form = new NTKForm("bill_form", "tour.php", $bill_box);
    $bill_form->addAttribute("db_action", "tour_to_bill");
    $bill_form->addAttribute("date", $datum);
<?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>
    require_once "DataBase/Price.php";
    require_once "DataBase/Category.php";
    $priceset = new Priceset();
    $customer = new Customer();
    $product = new Product();
    $price = new Price();
    $category = new Category();
    $priceset->export("mysql_export/priceset.csv");
    $customer->export("mysql_export/customer.csv");
    $product->export("mysql_export/product.csv");
    $price->export("mysql_export/price.csv");
    $category->export("mysql_export/category.csv");
    // upload all db-files "mysql_export"
    $handle = popen("/var/www/ursprung/bin/upload.sh", "r");
    pclose($handle);
    $main_box->add(new NTKLabel("", "Schritt erfolgreich"), 200, -1, "color: #00ff00; background-color: #dfe7f3;");
    $button_next = new NTKButton("button_next", "Weiter", "location.replace('websync.php?action=upload_1');");
    $main_box->add($button_next, 500);
} elseif ($action == "upload_1") {
    $iframe = new NTKIFrame("upload_frame", "http://www.natuerlich-grobi.de/db_import.php", "width: 300px; height: 200px; background-color: #dfe7f3;");
    $main_box->add($spacer, True, True, "background-color: #dfe7f3;");
    $main_box->add(new NTKLabel("", "Serverausgabe (dauert etwas):"), False, False, "font-style: bold; background-color: #dfe7f3;");
    $main_box->add($iframe, False, False, "background-color: #dfe7f3;");
    $main_box->add($spacer, True, True, "background-color: #dfe7f3;");
} elseif ($action == "download_0") {
    $iframe = new NTKIFrame("download_frame", "http://www.natuerlich-grobi.de/db_export.php", "width: 300px; height: 200px; background-color: #dfe7f3;");
    // 	$iframe = new NTKIFrame("download_frame", "http://localhost/ursprung/db_export.php", "width: 300px; height: 200px; background-color: #dfe7f3;");
    $main_box->add($spacer, True, True, "background-color: #dfe7f3;");
    $main_box->add(new NTKLabel("", "Serverausgabe (dauert etwas):"), False, False, "font-style: bold; background-color: #dfe7f3;");
    $main_box->add($iframe, False, False, "background-color: #dfe7f3;");
    $main_box->add($spacer, True, True, "background-color: #dfe7f3;");
<?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>
</html>
    $result_box->add(new NTKLabel("", "<b>" . round($product_amount, 2) . "</b>"), 1, 1);
    $result_box->add(new NTKLabel("", "In Rechnungen (Menge):"), 2, 0);
    $bills = "";
    for ($i = 0; $i < count($bill_data); $i++) {
        $bills = $bills . " " . $bill_data[$i][0] . " (";
        $bills = $bills . " " . $bill_data[$i][1] . ") ; ";
    }
    $result_box->add(new NTKLabel("", $bills), 2, 1);
    $result_box->add(new NTKLabel("", "Von Kunden:"), 3, 0);
    $customer_string = "";
    for ($i = 0; $i < count($customer_data); $i++) {
        $customer_string = $customer_string . " " . $customer_data[$i][0] . "(";
        $customer_string = $customer_string . " " . $customer_data[$i][1] . ") ; ";
    }
    $result_box->add(new NTKLabel("", $customer_string), 3, 1);
    $toolbar_box->add($result_box, 0, 0);
}
$main_box = new NTKTable("main_box", 6, 4, False);
$main_box->setStyle("background-color: #dfe7f3;");
$main_box->add(new NTKLabel("", "<b>Produktverkauf in einem bestimmten Zeitraum</b>"), 0, 0);
$main_box->add(new NTKLabel("", "Produktnummer:"), 2, 0);
$main_box->add(new NTKEntry("product_id", $product_id), 2, 1);
$main_box->add(new NTKLabel("", "Von:"), 3, 0);
$main_box->add(new NTKEntry("date_from", $date_from), 3, 1);
$main_box->add(new NTKLabel("", "Bis:"), 3, 2);
$main_box->add(new NTKEntry("date_to", $date_to), 3, 3);
$main_box->add(new NTKButton("submit", "OK", "document.forms['stat_product_date_count'].submit();"), 5, 3);
$form = new NTKForm("stat_product_date_count", "stat_product_date_count.php", $main_box);
$toolbar_box->add($form, 10, 0);
echo $toolbar_box->getHtml();
?>
<?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;");