product.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. require_once("util.php");
  3. require_once("NTK/NTK.php");
  4. require_once("DataBase/Product.php");
  5. ?>
  6. <html>
  7. <head>
  8. <title> Index </title>
  9. <?php
  10. include("Modules/Product/db_action.php");
  11. $main_box = new NTKVBox("main_box", 0, 0, False);
  12. // Toolbar
  13. $page = "product";
  14. $printfile = "";
  15. include("Modules/toolbar.php");
  16. // small Toolbar
  17. include("Modules/Product/toolbar.php");
  18. // main content
  19. $action = var_get_post("action", "");
  20. $search = var_post("search_entry", "");
  21. $product_id = var_get_post("product_id", "");
  22. $onload .= "document.getElementById('search_entry').focus();";
  23. if($action == "new")
  24. {
  25. include("Modules/Product/new_form.php");
  26. }
  27. elseif($action == "edit" && $product_id != "")
  28. {
  29. $data = $product->get($product_id);
  30. include("Modules/Product/edit_form.php");
  31. }
  32. elseif($action == "search" && $search != "")
  33. {
  34. $search_toggle = var_post("search_toggle", "");
  35. $search_category = var_post("search_category", "");
  36. $search_in = "";
  37. if($search_category != "")
  38. {
  39. if($search_toggle && count($search_category) > 0)
  40. {
  41. for($i = 0; $i < count($search_category); $i++)
  42. $search_in .= " category_id='".$search_category[$i]."' AND ";
  43. }
  44. elseif(count($search_category) > 0)
  45. {
  46. for($i = 0; $i < count($search_category); $i++)
  47. $search_in .= " category_id<>'".$search_category[$i]."' AND ";
  48. }
  49. }
  50. $list_view = new NTKListView("list_view", array('Produktnummer','Name','Beschreibung'), "location.href = 'product.php?action=edit&product_id=%0%';");
  51. $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%')");
  52. if(count($results) == 1)
  53. $onload = "location.href = 'product.php?action=edit&product_id=".$results[0][0]."';";
  54. $list_view->addLines($results);
  55. $main_box->add($list_view, -1, -1, "background-color: #dfe7f3; vertical-align: top;");
  56. }
  57. else
  58. {
  59. /*$list_view = new NTKListView("list_view", array('Produktnummer','Name','Beschreibung'), "location.href = '$PHP_SELF?action=edit&product_id=%0%';");
  60. $list_view->addLines($product->get('', array('product_id', 'name', 'details')));
  61. $main_box->add($list_view, -1, -1, "background-color: #dfe7f3; vertical-align: top;");*/
  62. $main_box->add(new NTKSpacer(), -1, -1);
  63. }
  64. echo getHead();
  65. echo $main_box->getHtml();
  66. ?>
  67. </body>
  68. </html>