+ products) && count($order->products)): ?>
products as $product): ?>
diff --git a/Layout/default/Pipework/Index.php b/Layout/default/Pipework/Index.php
new file mode 100644
index 000000000..64d1ef30b
--- /dev/null
+++ b/Layout/default/Pipework/Index.php
@@ -0,0 +1,164 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Netzgebiet
+ POP
+ Typ
+ Objektcode
+ OAN ID
+ Adresse
+ Einheiten
+ Status
+
+
+
+
+ =$building->network->name?>
+ =$building->pop->name?>
+ =$building->type->name?>
+ =$building->code?>
+ =$building->oan_id?>
+
+ =$building->street?>
+ =$building->zip?> =$building->city?>
+
+ =$building->units?>
+ =__($building->status->name."-b")?>
+
+
+
+
+
+
+
+
+
+
Tätigkeiten im Objekt =$building->code?>
+
+ =$building->street?>
+ =$building->zip?> =$building->city?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Layout/default/Workflow/form.php b/Layout/default/Workflow/form.php
new file mode 100644
index 000000000..d13433944
--- /dev/null
+++ b/Layout/default/Workflow/form.php
@@ -0,0 +1,41 @@
+
diff --git a/Layout/default/Workflow/items/bool.php b/Layout/default/Workflow/items/bool.php
new file mode 100644
index 000000000..c1ca48fe1
--- /dev/null
+++ b/Layout/default/Workflow/items/bool.php
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/Layout/default/Workflow/items/color.php b/Layout/default/Workflow/items/color.php
new file mode 100644
index 000000000..c1ca48fe1
--- /dev/null
+++ b/Layout/default/Workflow/items/color.php
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/Layout/default/Workflow/items/delimiter.php b/Layout/default/Workflow/items/delimiter.php
new file mode 100644
index 000000000..1d6667d2e
--- /dev/null
+++ b/Layout/default/Workflow/items/delimiter.php
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/Layout/default/Workflow/items/enum.php b/Layout/default/Workflow/items/enum.php
new file mode 100644
index 000000000..083e7119b
--- /dev/null
+++ b/Layout/default/Workflow/items/enum.php
@@ -0,0 +1,21 @@
+typedata);
+?>
+
+
+
+
+
+
+ =$label?>
+
+
diff --git a/Layout/default/Workflow/items/file.php b/Layout/default/Workflow/items/file.php
new file mode 100644
index 000000000..c1ca48fe1
--- /dev/null
+++ b/Layout/default/Workflow/items/file.php
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/Layout/default/Workflow/items/gps.php b/Layout/default/Workflow/items/gps.php
new file mode 100644
index 000000000..0f4b4301e
--- /dev/null
+++ b/Layout/default/Workflow/items/gps.php
@@ -0,0 +1,26 @@
+value_string) {
+ $gps_parts = explode(";", $item->value_string);
+ $lat = $gps_parts[0];
+ $long = $gps_parts[1];
+ }
+?>
+
+
+
+
+
Auf Google Maps öffnen
+
+
diff --git a/Layout/default/Workflow/items/int.php b/Layout/default/Workflow/items/int.php
new file mode 100644
index 000000000..c1ca48fe1
--- /dev/null
+++ b/Layout/default/Workflow/items/int.php
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/Layout/default/Workflow/items/string.php b/Layout/default/Workflow/items/string.php
new file mode 100644
index 000000000..29ffd6cb1
--- /dev/null
+++ b/Layout/default/Workflow/items/string.php
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/Layout/default/Workflow/items/text.php b/Layout/default/Workflow/items/text.php
new file mode 100644
index 000000000..c1ca48fe1
--- /dev/null
+++ b/Layout/default/Workflow/items/text.php
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/Layout/default/menu.php b/Layout/default/menu.php
index ad55f6c6f..699e3881a 100644
--- a/Layout/default/menu.php
+++ b/Layout/default/menu.php
@@ -37,6 +37,8 @@
diff --git a/application/Building/Building.php b/application/Building/Building.php
index 58d50384d..29d773a27 100644
--- a/application/Building/Building.php
+++ b/application/Building/Building.php
@@ -9,6 +9,7 @@ class Building extends mfBaseModel {
private $status;
private $pipeworker;
private $terminations;
+ private $workflowitems;
public function getAddress($singelLine = false) {
if(!$this->id) {
@@ -122,6 +123,14 @@ class Building extends mfBaseModel {
return $this->terminations;
}
+ if($name == "workflowitems") {
+ foreach(WorkflowitemModel::search(["object_type" => "building", "active" => 1]) as $item) {
+ $item->setObjectId($this->id);
+ $this->workflowitems[] = $item;
+ }
+ return $this->workflowitems;
+ }
+
$classname = ucfirst($name);
$idfield = $name."_id";
$this->$name = new $classname($this->$idfield);
diff --git a/application/Order/OrderModel.php b/application/Order/OrderModel.php
index 339a0b92c..b59f85d40 100644
--- a/application/Order/OrderModel.php
+++ b/application/Order/OrderModel.php
@@ -145,7 +145,7 @@ class OrderModel {
$res = $db->select("Order", "*", "$where ORDER BY id");
}
if($db->num_rows($res)) {
- while($data = $db->fetch_object()) {
+ while($data = $db->fetch_object($res)) {
$items[] = new Order($data);
}
}
diff --git a/application/Pipework/PipeworkController.php b/application/Pipework/PipeworkController.php
new file mode 100644
index 000000000..84e27c7ba
--- /dev/null
+++ b/application/Pipework/PipeworkController.php
@@ -0,0 +1,39 @@
+needlogin=true;
+ $me = new User();
+ $me->loadMe();
+ $this->me = $me;
+ $this->layout()->set("me",$me);
+
+ if(!$me->is(["Admin", "netowner", "pipeplanner", "pipeworker"])) {
+ $this->redirect("Dashboard");
+ }
+ }
+
+ protected function indexAction() {
+ $this->layout()->setTemplate("Pipework/Index");
+
+ if($this->me->is("Admin")) {
+ $this->layout()->set("buildings", BuildingModel::search(["workflow_finished" => 0]));
+ } else {
+ $buildings = [];
+ foreach($this->me->my_networks as $network) {
+ foreach(BuildingModel::search(["network_id" => $network->id, "workflow_finished" => 0]) as $b) {
+ if(!array_key_exists($b->id, $buildings)) {
+ $buildings[$b->id] = $b;
+ }
+ }
+ }
+ //var_dump($buildings);exit;
+
+
+ $this->layout()->set("buildings", $buildings);
+ }
+ }
+
+
+}
\ No newline at end of file
diff --git a/application/Workflowitem/Workflowitem.php b/application/Workflowitem/Workflowitem.php
new file mode 100644
index 000000000..4cf1e7fb9
--- /dev/null
+++ b/application/Workflowitem/Workflowitem.php
@@ -0,0 +1,46 @@
+object_id = $object_id;
+ return true;
+ }
+
+ public function getProperty($name) {
+ if($this->$name == null) {
+
+ if($name == "value") {
+ if(!$this->object_id) {
+ $this->log->warn(__CLASS__."::getProperty('value'): Object ID not set");
+ return null;
+ }
+ $value = WorkflowvalueModel::getFirst(['item_id' => $this->id, "object_id" => $this->object_id]);
+ if(!$value) {
+ $vdata['item_id'] = $this->id;
+ $vdata['object_id'] = $this->object_id;
+ $value = WorkflowvalueModel::create($vdata);
+ }
+ $this->value = $value;
+ return $this->value;
+ }
+
+ $classname = ucfirst($name);
+ $idfield = $name."_id";
+ $this->$name = new $classname($this->$idfield);
+
+ if($this->$name->id) {
+ return $this->$name;
+ } else {
+ return null;
+ }
+ }
+
+ return $this->$name;
+ }
+}
\ No newline at end of file
diff --git a/application/Workflowitem/WorkflowitemModel.php b/application/Workflowitem/WorkflowitemModel.php
new file mode 100644
index 000000000..adde25541
--- /dev/null
+++ b/application/Workflowitem/WorkflowitemModel.php
@@ -0,0 +1,149 @@
+ $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("Workflowitem", "*", "id=$id LIMIT 1");
+ if($db->num_rows($res)) {
+ $data = $db->fetch_object($res);
+ $item = new Workflowitem($data);
+ }
+ return $item;
+ }
+
+ public static function getAll() {
+ $items = [];
+
+ $db = FronkDB::singleton();
+
+ $res = $db->select("Workflowitem", "*", "1=1 ORDER BY name");
+ if($db->num_rows($res)) {
+ while($data = $db->fetch_object($res)) {
+ $items[] = new Workflowitem($data);
+ }
+ }
+ return $items;
+
+ }
+
+ public static function getFirst($filter) {
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $res = $db->select("Workflowitem", "*", "$where ORDER BY name");
+ if($db->num_rows($res)) {
+ $data = $db->fetch_object($res);
+ $item = new Workflowitem($data);
+ if($item->id) {
+ return $item;
+ } else {
+ return null;
+ }
+ }
+ return null;
+ }
+
+
+ public static function search($filter) {
+ $items = [];
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ //var_dump($where);exit;
+ $res = $db->select("Workflowitem", "*", "$where ORDER BY num");
+ if($db->num_rows($res)) {
+ while($data = $db->fetch_object($res)) {
+ $items[] = new Workflowitem($data);
+ }
+ }
+
+ return $items;
+ }
+
+ private function getSqlFilter($filter) {
+ $where = "1=1 ";
+
+ //var_dump($filter);exit;
+ if(array_key_exists("active", $filter)) {
+ $active = $filter['active'];
+ if($active == 1) {
+ $where .= " AND active = 1";
+ }
+ if($active == 0) {
+ $where .= " AND active = 0";
+ }
+ }
+
+ if(array_key_exists("create_by", $filter)) {
+ $create_by = $filter['create_by'];
+ if(is_numeric($create_by)) {
+ $where .= " AND create_by=$create_by";
+ }
+ }
+
+ if(array_key_exists("name", $filter)) {
+ $name = FronkDB::singleton()->escape($filter['name']);
+ if($name) {
+ $where .= " AND name='$name'";
+ }
+ }
+
+ if(array_key_exists("object_type", $filter)) {
+ $otype = $filter['object_type'];
+ if(strtolower($otype) == "building") {
+ $where .= " AND object_type='Building'";
+ }
+ if(strtolower($otype) == "termination") {
+ $where .= " AND object_type='Termination'";
+ }
+ }
+
+ //var_dump($filter, $where);exit;
+ return $where;
+ }
+
+}
\ No newline at end of file
diff --git a/application/Workflowvalue/Workflowvalue.php b/application/Workflowvalue/Workflowvalue.php
new file mode 100644
index 000000000..c3862ae2a
--- /dev/null
+++ b/application/Workflowvalue/Workflowvalue.php
@@ -0,0 +1,27 @@
+$name == null) {
+
+ if($name == "item") {
+ $this->item = new Workflowitem($this->item_id);
+ return $this->item;
+ }
+
+ $classname = ucfirst($name);
+ $idfield = $name."_id";
+ $this->$name = new $classname($this->$idfield);
+
+ if($this->$name->id) {
+ return $this->$name;
+ } else {
+ return null;
+ }
+ }
+
+ return $this->$name;
+ }
+}
\ No newline at end of file
diff --git a/application/Workflowvalue/WorkflowvalueModel.php b/application/Workflowvalue/WorkflowvalueModel.php
new file mode 100644
index 000000000..de8c1c009
--- /dev/null
+++ b/application/Workflowvalue/WorkflowvalueModel.php
@@ -0,0 +1,142 @@
+ $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("Workflowvalue", "*", "id=$id LIMIT 1");
+ if($db->num_rows($res)) {
+ $data = $db->fetch_object($res);
+ $item = new Workflowvalue($data);
+ }
+ return $item;
+ }
+
+ public static function getAll() {
+ $items = [];
+
+ $db = FronkDB::singleton();
+
+ $res = $db->select("Workflowvalue", "*");
+ if($db->num_rows($res)) {
+ while($data = $db->fetch_object($res)) {
+ $items[] = new Workflowvalue($data);
+ }
+ }
+ return $items;
+
+ }
+
+ public static function getFirst($filter) {
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $res = $db->select("Workflowvalue", "*", "$where");
+ if($db->num_rows($res)) {
+ $data = $db->fetch_object($res);
+ $item = new Workflowvalue($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("Workflowvalue", "*", $where);
+ if($db->num_rows($res)) {
+ while($data = $db->fetch_object($res)) {
+ $items[] = new Workflowvalue($data);
+ }
+ }
+
+ return $items;
+ }
+
+ private function getSqlFilter($filter) {
+ $where = "1=1 ";
+
+ //var_dump($filter);exit;
+
+ if(array_key_exists("create_by", $filter)) {
+ $create_by = $filter['create_by'];
+ if(is_numeric($create_by)) {
+ $where .= " AND create_by=$create_by";
+ }
+ }
+
+ if(array_key_exists("changed_by", $filter)) {
+ $changed_by = $filter['changed_by'];
+ if(is_numeric($create_by)) {
+ $where .= " AND changed_by=$changed_by";
+ }
+ }
+
+ if(array_key_exists("item_id", $filter)) {
+ $item_id = $filter['item_id'];
+ if(is_numeric($item_id)) {
+ $where .= " AND item_id=$item_id";
+ }
+ }
+
+ if(array_key_exists("object_id", $filter)) {
+ $object_id = $filter['object_id'];
+ if(is_numeric($object_id)) {
+ $where .= " AND object_id=$object_id";
+ }
+ }
+
+
+
+ //var_dump($filter, $where);exit;
+ return $where;
+ }
+
+}
\ No newline at end of file
diff --git a/contrib/migrations/2021-08-24-create-workflow.sql b/contrib/migrations/2021-08-24-create-workflow.sql
new file mode 100644
index 000000000..da8002a91
--- /dev/null
+++ b/contrib/migrations/2021-08-24-create-workflow.sql
@@ -0,0 +1,37 @@
+ALTER TABLE `Building` ADD `workflow_finished` INT NOT NULL DEFAULT '0' AFTER `networksection_id`;
+
+CREATE TABLE `Workflowitem` (
+ `id` int NOT NULL AUTO_INCREMENT,
+ `num` int NOT NULL DEFAULT '0',
+ `object_type` enum('Building','Termination') COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT 'Building',
+ `active` int NOT NULL DEFAULT '1',
+ `visible` int NOT NULL DEFAULT '1',
+ `required` int NOT NULL DEFAULT '1',
+ `name` varchar(1024) COLLATE utf8mb4_unicode_520_ci NOT NULL,
+ `label` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL,
+ `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci,
+ `type` enum('string','int','bool','enum','text','file','gps','color','delimiter') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT 'string',
+ `typedata` text COLLATE utf8mb4_unicode_520_ci,
+ `placeholder` varchar(1024) COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
+ `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;
+
+CREATE TABLE `Workflowvalue` (
+ `id` int NOT NULL AUTO_INCREMENT,
+ `item_id` int NOT NULL,
+ `object_id` int NOT NULL,
+ `value_string` varchar(1024) COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
+ `value_int` int DEFAULT NULL,
+ `value_text` text COLLATE utf8mb4_unicode_520_ci NOT NULL,
+ `changed_by` int NOT NULL,
+ `changed` int NOT NULL,
+ `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;
\ No newline at end of file
diff --git a/public/assets/css/thetool.css b/public/assets/css/thetool.css
index 1dce18cfd..758e3ec33 100644
--- a/public/assets/css/thetool.css
+++ b/public/assets/css/thetool.css
@@ -29,6 +29,10 @@
}
+.building-list-tr {
+ cursor: pointer;
+}
+
td.controls {
cursor: default;
text-align: left; letter-spacing: 4px; font-size: 1.1em;