diff --git a/Layout/default/Product/Form.php b/Layout/default/Product/Form.php index eeda90436..57dab99f4 100644 --- a/Layout/default/Product/Form.php +++ b/Layout/default/Product/Form.php @@ -106,7 +106,8 @@
Neue Technologie:
Name: - Code: + Kundentyp: + RTR Code: Beschreibung: Interne Notiz:
@@ -115,7 +116,19 @@
- + +
+ +
+
+ +
+
@@ -142,6 +155,13 @@
+
+ +
+ +
+
+ diff --git a/Layout/default/Product/Index.php b/Layout/default/Product/Index.php index dcf08ab7d..5f75c4d5c 100644 --- a/Layout/default/Product/Index.php +++ b/Layout/default/Product/Index.php @@ -10,7 +10,7 @@

Produkte

@@ -37,8 +37,11 @@ Gruppe Name Technologie + Kundentyp Verkaufspreis Verr. Periode + SLA + IVT ID @@ -47,8 +50,11 @@ productgroup->name?> name?> producttech->name?> + producttech->customer_type)?> price?> billing_period?>x Jährlich + sla->name?> + ivt_id?> $product->id])?>"> $product->id])?>" class="text-danger" onclick="if(!confirm('Berechtigungen wirklich löschen?')) return false;" title="Produkt Löschen"> diff --git a/Layout/default/User/Index.php b/Layout/default/User/Index.php index ac8d39ae8..a81907d2f 100644 --- a/Layout/default/User/Index.php +++ b/Layout/default/User/Index.php @@ -13,7 +13,7 @@

Benutzer

diff --git a/Layout/default/menu.php b/Layout/default/menu.php index a0d431b15..5434efb8a 100644 --- a/Layout/default/menu.php +++ b/Layout/default/menu.php @@ -23,7 +23,6 @@
  • ">Benutzer
  • ">Neztgebiete
  • ">Produkte
  • -
  • ">Produktgruppen
  • diff --git a/application/Product/Product.php b/application/Product/Product.php index 47391993f..fd1b9ef69 100644 --- a/application/Product/Product.php +++ b/application/Product/Product.php @@ -17,5 +17,7 @@ class Product extends mfBaseModel { return null; } } + + return $this->$name; } } \ No newline at end of file diff --git a/application/Product/ProductController.php b/application/Product/ProductController.php index 18fdfa554..7b3a618e6 100644 --- a/application/Product/ProductController.php +++ b/application/Product/ProductController.php @@ -22,6 +22,7 @@ class ProductController extends mfBaseController { $this->layout()->setTemplate("Product/Form"); $this->layout()->set("productgroups", ProductgroupModel::getAll()); $this->layout()->set("producttechs", ProducttechModel::getAll()); + $this->layout()->set("slas", SlaModel::getAll()); } @@ -57,18 +58,24 @@ class ProductController extends mfBaseController { $data = []; $data['name'] = $r->name; $data['description'] = $r->description; + $data['sla_id'] = $r->sla_id; $data['external'] = ($r->external == 1) ? "1" : "0"; $data['price_nne'] = Layout::commaToDot($r->price_nne); $data['price_nbe'] = Layout::commaToDot($r->price_nbe); $data['price'] = Layout::commaToDot($r->price); $data['billing_period'] = $r->billing_period; + $data['ivt_id'] = ($r->ivt_id) ? $r->ivt_id : null; $data['note'] = $r->note; if(is_numeric($r->producttech_id)) { $data['producttech_id'] = $r->producttech_id; + } else { + $data['producttech_id'] = null; } if(is_numeric($r->productgroup_id)) { $data['productgroup_id'] = $r->productgroup_id; + } else { + $data['productgroup_id'] = null; } $data['edit_by'] = 1; @@ -105,7 +112,8 @@ class ProductController extends mfBaseController { if($r->producttech_id == "new") { $nt = []; $nt['name'] = $r->producttech_new_name; - $nt['code'] = $r->producttech_new_code; + $nt['rtrcode'] = $r->producttech_new_rtrcode; + $nt['customer_type'] = ($r->producttech_new_customer_type == "business") ? "business" : "residential"; $nt['description'] = $r->producttech_new_description; $nt['note'] = $r->producttech_new_note; $tech = ProducttechModel::create($nt); diff --git a/application/Product/ProductModel.php b/application/Product/ProductModel.php index 1882b431f..9bcb88580 100644 --- a/application/Product/ProductModel.php +++ b/application/Product/ProductModel.php @@ -3,6 +3,7 @@ class ProductModel { public $name = null; public $description = null; + public $sla_id = null; public $external = null; public $productgroup_id = null; public $producttech_id = null; @@ -10,6 +11,7 @@ class ProductModel { public $price_nne = null; public $price_nbe = null; public $billing_period = null; + public $ivt_id = null; public $note = null; public $create_by = null; diff --git a/application/Producttech/ProducttechModel.php b/application/Producttech/ProducttechModel.php index 67f11f657..e5e84bc8e 100644 --- a/application/Producttech/ProducttechModel.php +++ b/application/Producttech/ProducttechModel.php @@ -2,7 +2,8 @@ class ProducttechModel { public $name = null; - public $code = null; + public $rtrcode = null; + public $customer_type = null; public $description = null; public $note = null; @@ -115,13 +116,18 @@ class ProducttechModel { } } - if(array_key_exists("code", $filter)) { - $code = $db->escape($filter['code']); - if($code) { - $where .= " AND `code` like '$code'"; + if(array_key_exists("rtrcode", $filter)) { + $rtrcode = $db->escape($filter['rtrcode']); + if($rtrcode) { + $where .= " AND `code` like '$rtrcode'"; } } + if(array_key_exists("customer_type", $filter)) { + $customer_type = ($customer_type == "business") ? "business" : "residential"; + $where .= " AND `customer_type`='$customer_type'"; + } + //var_dump($filter, $where);exit; return $where; } diff --git a/application/Sla/Sla.php b/application/Sla/Sla.php new file mode 100644 index 000000000..1b5d08640 --- /dev/null +++ b/application/Sla/Sla.php @@ -0,0 +1,5 @@ + $value) { + if(property_exists(get_called_class(), $field)) { + $model ->$field = $value; + } + } + + $me = new User(); + $me->loadMe(); + + if($model->create_by === null) { + $model->create_by = $me->id; + } + if($model->edit_by === null) { + $model->edit_by = $me->id; + } + + return $model; + } + + public static function getOne($id) { + if(!is_numeric($id) || !$id) { + throw new Exception("Invalid number", 400); + } + $item = []; + $db = FronkDB::singleton(); + + $res = $db->select("Sla", "*", "id=$id LIMIT 1"); + if($db->num_rows($res)) { + $data = $db->fetch_object($res); + $item = new Sla($data); + } + return $item; + } + + public static function getAll() { + $items = []; + + $db = FronkDB::singleton(); + + $res = $db->select("Sla", "*", "1 = 1 ORDER BY name"); + if($db->num_rows($res)) { + while($data = $db->fetch_object($res)) { + $items[] = new Sla($data); + } + } + return $items; + + } + + public static function getFirst() { + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + $res = $db->select("Sla", "*", "$where ORDER BY name LIMIT 1"); + if($db->num_rows($res)) { + $data = $db->fetch_object($res); + $item = new Sla($data); + if($item->id) { + return $item; + } else { + return null; + } + } + return null; + } + + public static function search($filter) { + $items = []; + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + $res = $db->select("Sla", "*", "$where ORDER BY name"); + if($db->num_rows($res)) { + while($data = $db->fetch_object($res)) { + $items[] = new Sla($data); + } + } + return $items; + } + + private function getSqlFilter($filter) { + $where = "1=1 "; + + $db = FronkDB::singleton(); + + //var_dump($filter);exit; + + if(array_key_exists("name", $filter)) { + $name = $db->escape($filter['name']); + if($name) { + $where .= " AND `name` like '$name'"; + } + } + + if(array_key_exists("nameLike", $filter)) { + $name = $db->escape($filter['nameLike']); + if($name) { + $where .= " AND `name` like '%$name%'"; + } + } + + //var_dump($filter, $where);exit; + return $where; + } + +} \ No newline at end of file diff --git a/contrib/migrations/20210705-product-tables.sql b/contrib/migrations/20210705-product-tables.sql index 2c97abf47..810d5f8d7 100644 --- a/contrib/migrations/20210705-product-tables.sql +++ b/contrib/migrations/20210705-product-tables.sql @@ -2,6 +2,8 @@ CREATE TABLE `Product` ( `id` int NOT NULL AUTO_INCREMENT, `name` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL, `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci, + `customer_type` ENUM('residential','business') NOT NULL DEFAULT 'residential', + `sla_id` int NOT NULL, `external` tinyint(1) NOT NULL DEFAULT '0', `producttech_id` int DEFAULT NULL, `productgroup_id` int DEFAULT NULL, @@ -9,13 +11,14 @@ CREATE TABLE `Product` ( `price_nbe` decimal(12,2) DEFAULT NULL, `price` decimal(12,2) NOT NULL, `billing_period` int NOT NULL COMMENT 'in months', + `ivt_id` INT(11) NULL DEFAULT NULL, `note` text COLLATE utf8mb4_unicode_520_ci, `create_by` int NOT NULL, `edit_by` int NOT NULL, `create` int NOT NULL, `edit` int NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; CREATE TABLE `ProductNetwork` ( `id` int NOT NULL AUTO_INCREMENT, @@ -26,7 +29,7 @@ CREATE TABLE `ProductNetwork` ( `create` int NOT NULL, `edit` int NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; CREATE TABLE `Productattribute` ( `id` int NOT NULL AUTO_INCREMENT, @@ -42,7 +45,7 @@ CREATE TABLE `Productattribute` ( `create` int NOT NULL, `edit` int NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; CREATE TABLE `Productgroup` ( `id` int NOT NULL AUTO_INCREMENT, @@ -54,7 +57,7 @@ CREATE TABLE `Productgroup` ( `create` int NOT NULL, `edit` int NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; CREATE TABLE `Producttech` ( `id` int NOT NULL AUTO_INCREMENT, @@ -67,7 +70,7 @@ CREATE TABLE `Producttech` ( `create` int NOT NULL, `edit` int NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; CREATE TABLE `ProducttechAttribute` ( `id` int NOT NULL, @@ -80,4 +83,4 @@ CREATE TABLE `ProducttechAttribute` ( `edit_by` int NOT NULL, `create` int NOT NULL, `edit` int NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; diff --git a/lang/de.php b/lang/de.php index b689f0cf1..008799c9f 100644 --- a/lang/de.php +++ b/lang/de.php @@ -18,6 +18,7 @@ $l['supplier'] = "Lieferant"; $l['suppliers'] = "Lieferanten"; $l['contact'] = "Kontakt"; $l['billing'] = "Verrechnungsadresse"; - +$l['business'] = "Business"; +$l['residential'] = "Residential"; $lang['de'] = $l; \ No newline at end of file