diff --git a/Layout/default/Address/View.php b/Layout/default/Address/View.php index db316cd22..bd4cf24a0 100644 --- a/Layout/default/Address/View.php +++ b/Layout/default/Address/View.php @@ -27,163 +27,187 @@ -
| Kundennummer | -=$address->customer_number?> | -||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Firmenname | -=nl2br($address->company)?> | -||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Vorname | -=$address->firstname?> | -||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Nachname | -=$address->lastname?> | -||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Straße | -=$address->street?> | -||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PLZ / Ort | -=$address->zip?> =$address->city?> | -||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Land | -=$address->country?> | -||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Telefon | -=$address->phone?> | -||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Mobil | -=$address->mobile?> | -||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Fax | -=$address->fax?> | -||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| =$address->email?> | -|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Service PIN | -=$address->spin?> | -||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Einwilligungen | -
- "> Informationen per Post/Email/Telefon -">Auskunft mit Service PIN - |
- ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Rollen | -
- types) && count($address->types)): ?>
-
-
+
- contracts) && count($address->contracts)): ?>
-
+
+ =$address->getCompanyOrName()?>=($address->customer_number) ? " [".$address->customer_number."]" : ""?>+ +
Verknüpfungen- links) && count($address->links)): ?> -
-
-
-
- linked_as) && count($address->linked_as)): ?>
-
-
Verknüpfungen+ links) && count($address->links)): ?> +
+
+
+
+ linked_as) && count($address->linked_as)): ?>
+
+
+
Verknüpft als+
+
+
+
+
+
Verknüpft als-
-
-
+
-
-
+
+
+
+
+ Aktive Produkte (Contracts)
+
+ contracts) && count($address->contracts)): ?>
+
+ active_contracts) && count($address->active_contracts)): ?>
+
+
-
+ Verträge
+
-
Verträge
+
finish_date || $contract->finish_date > date('U')): ?>
In Herstellung@@ -215,8 +215,50 @@
+
+
+
linkFrom) && count($contract->linkFrom)) || (is_array($contract->linkTo) && count($contract->linkTo))): ?>
-
+
+ Journaleinträge+
+
+
+
+
+
+
+
+
+ Verknüpfte Verträge $contract->id])?>">Neuen Contract anlegendiff --git a/application/Address/Address.php b/application/Address/Address.php index 889de6ae3..e4a79b023 100644 --- a/application/Address/Address.php +++ b/application/Address/Address.php @@ -10,6 +10,7 @@ class Address extends mfBaseModel { private $attributes; private $permissions; private $contracts; + private $active_contracts; private $phoneparts; @@ -190,6 +191,13 @@ class Address extends mfBaseModel { return $this->contracts; } + if($name == "active_contracts") { + $owning = ContractModel::searchActive(['owner_id' => $this->id]); + $billing = ContractModel::searchActive(['billingaddress_id' => $this->id]); + $this->contracts = array_merge($owning, $billing); + return $this->contracts; + } + /* if($name == "links_to") { $links = AddressLinkModel::search(['address_id' => $this->id]); diff --git a/application/Contract/Contract.php b/application/Contract/Contract.php index 50c120017..eb35dfcbf 100644 --- a/application/Contract/Contract.php +++ b/application/Contract/Contract.php @@ -11,6 +11,7 @@ class Contract extends mfBaseModel { private $contractConfigItems; private $configgroups; private $isCancelled; + private $journals; private $links; private $linkFrom; private $linkTo; @@ -188,6 +189,11 @@ class Contract extends mfBaseModel { return $this->contractConfigItems; } + if($name == "journals") { + $this->journals = array_reverse(ContractjournalModel::search(["contract_id" => $this->id])); + return $this->journals; + } + if($name == "links") { $this->links = ContractLinkModel::includesContractId($this->id, ["type" => $link]); //var_dump($this->links);exit; diff --git a/application/Contract/ContractModel.php b/application/Contract/ContractModel.php index 67fabb5f9..c05182549 100644 --- a/application/Contract/ContractModel.php +++ b/application/Contract/ContractModel.php @@ -116,6 +116,42 @@ class ContractModel { return 0; } + public static function searchActive($filter, $limit = false) { + //var_dump($filter);exit; + $items = []; + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + $sql = "SELECT Contract.* FROM Contract + LEFT JOIN Address ON (Contract.owner_id = Address.id) + LEFT JOIN OrderProduct ON (Contract.orderproduct_id = OrderProduct.id) + LEFT JOIN `Order` ON (OrderProduct.order_id = `Order`.id) + LEFT JOIN Product ON (Contract.product_id = Product.id) + WHERE $where + AND (cancel_date IS NULL OR cancel_date > UNIX_TIMESTAMP()) + GROUP BY Contract.id + ORDER BY Contract.owner_id,Contract.`create`"; + + if(is_array($limit) && count($limit)) { + if(is_numeric($limit['start']) && is_numeric($limit['count'])) { + $sql .= " LIMIT ".$limit['start'].", ".$limit['count']; + } elseif(is_numeric($count)) { + $sql .= " LIMIT ".$limit['count']; + } + } + + mfLoghandler::singleton()->debug($sql); + + $res = $db->query($sql); + if($db->num_rows($res)) { + while($data = $db->fetch_object($res)) { + $items[$data->id] = new Contract($data); + } + } + + return $items; + } + public static function search($filter, $limit = false) { //var_dump($filter);exit; $items = []; diff --git a/application/ContractFile/ContractFile.php b/application/ContractFile/ContractFile.php new file mode 100644 index 000000000..f8f88ebda --- /dev/null +++ b/application/ContractFile/ContractFile.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("ContractFile", "*", "id=$id LIMIT 1"); + if($db->num_rows($res)) { + $data = $db->fetch_object($res); + $item = new ContractFile($data); + } + return $item; + } + + public static function getAll() { + $items = []; + + $db = FronkDB::singleton(); + + $res = $db->select("ContractFile", "*", "1=1 ORDER BY contract_id, `create`"); + if($db->num_rows($res)) { + while($data = $db->fetch_object($res)) { + $items[] = new ContractFile($data); + } + } + return $items; + + } + + public static function getFirst() { + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + $res = $db->select("ContractFile", "*", "$where ORDER BY contract_id, `create`"); + if($db->num_rows($res)) { + $data = $db->fetch_object($res); + $item = new ContractFile($data); + if($item->id) { + return $item; + } else { + return null; + } + } + return null; + } + + public static function search($filter) { + $items = []; + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + + $sql = "SELECT ContractFile.* FROM ContractFile + LEFT JOIN File ON (ContractFile.file_id = File.id) + WHERE $where + ORDER BY contract_id, `create`"; + + $res = $db->query($sql); + + if($db->num_rows($res)) { + while($data = $db->fetch_object($res)) { + $items[] = new ContractFile($data); + } + } + return $items; + } + + private static function getSqlFilter($filter) { + $where = "1=1 "; + + + if(array_key_exists("file_id", $filter)) { + $file_id = $filter['file_id']; + if(is_numeric($file_id)) { + $where .= " AND file_id=$file_id"; + } + } + + if(array_key_exists("contract_id", $filter)) { + $contract_id = $filter['contract_id']; + if(is_numeric($contract_id)) { + $where .= " AND contract_id=$contract_id"; + } + } + + //var_dump($filter);exit; + if(array_key_exists("name", $filter)) { + $name = FronkDB::singleton()->escape($filter['name']); + if($name) { + $where .= " AND name='$name'"; + } + } + + if(array_key_exists("filename", $filter)) { + $filename = FronkDB::singleton()->escape($filter['filename']); + if($filename) { + $where .= " AND File.filename='$filename'"; + } + } + + if(array_key_exists("subfolder", $filter)) { + $subfolder = FronkDB::singleton()->escape($filter['subfolder']); + if($subfolder) { + $where .= " AND File.subfolder='$subfolder'"; + } + } + + //var_dump($filter, $where);exit; + return $where; + } + +} \ No newline at end of file diff --git a/application/Contractjournal/Contractjournal.php b/application/Contractjournal/Contractjournal.php new file mode 100644 index 000000000..055ea31d4 --- /dev/null +++ b/application/Contractjournal/Contractjournal.php @@ -0,0 +1,59 @@ +$name == null) { + + if($name == "contractfile") { + if(!is_numeric($this->value)) return null; + $this->contractfile = new ContractFile($this->value); + return $this->contractfile; + } + + if($name == "creator") { + $this->creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by); + if($this->creator === null) { + $this->creator = new User($this->create_by); + if($this->creator->id) { + mfValuecache::singleton()->set("Worker-id-".$this->create_by, $this->creator); + } + } + return $this->creator; + } + + if($name == "editor") { + $this->editor = mfValuecache::singleton()->get("Worker-id-".$this->edit_by); + if($this->editor === null) { + $this->editor = new User($this->edit_by); + if($this->editor->id) { + mfValuecache::singleton()->set("Worker-id-".$this->edit_by, $this->editor); + } + } + return $this->editor; + } + + + $classname = ucfirst($name); + $idfield = $name."_id"; + $this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield); + if(!$this->$name) { + $this->$name = new $classname($this->$idfield); + } + + if($this->$name->id) { + mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name); + return $this->$name; + } else { + return null; + } + + } + + return $this->$name; + } +} \ No newline at end of file diff --git a/application/Contractjournal/ContractjournalModel.php b/application/Contractjournal/ContractjournalModel.php new file mode 100644 index 000000000..33007cd43 --- /dev/null +++ b/application/Contractjournal/ContractjournalModel.php @@ -0,0 +1,128 @@ + $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 getAll() { + $items = []; + + $db = FronkDB::singleton(); + + $res = $db->select("Contractjournal", "*", "1=1 ORDER BY contract_id,`create`"); + if($db->num_rows($res)) { + while($data = $db->fetch_object($res)) { + $items[] = new Contractjournal($data); + } + } + return $items; + + } + + public static function getFirst($filter = false) { + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + $res = $db->select("Contractjournal", "*", "$where ORDER BY contract_id,`create`"); + if($db->num_rows($res)) { + $data = $db->fetch_object($res); + $item = new Contractjournal($data); + if($item->id) { + return $item; + } else { + return null; + } + } + return null; + } + + public static function search($filter) { + $items = []; + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + /* + $sql = "SELECT Contractjournal.* FROM Contractjournal + LEFT JOIN File ON (Contractjournal.file_id = File.id) + WHERE $where + ORDER BY order_id, name"; + + $res = $db->query($sql); + */ + $res = $db->select("Contractjournal", "*", $where); + if($db->num_rows($res)) { + while($data = $db->fetch_object($res)) { + $items[] = new Contractjournal($data); + } + } + return $items; + } + + private static function getSqlFilter($filter) { + $where = "1=1 "; + + + if(array_key_exists("contract_id", $filter)) { + $contract_id = $filter['contract_id']; + if(is_numeric($contract_id)) { + $where .= " AND contract_id=$contract_id"; + } + } + + if(array_key_exists("order_id", $filter)) { + $order_id = $filter['order_id']; + if(is_numeric($order_id)) { + $where .= " AND order_id=$order_id"; + } + } + + if(array_key_exists("type", $filter)) { + $type = FronkDB::singleton()->escape($filter['type']); + if($type) { + $where .= " AND type='$type'"; + } + } + + if(array_key_exists("value", $filter)) { + $value = FronkDB::singleton()->escape($filter['value']); + if($value) { + $where .= " AND value='$value'"; + } + } + + + //var_dump($filter, $where);exit; + return $where; + } + +} \ No newline at end of file diff --git a/public/assets/css/thetool.css b/public/assets/css/thetool.css index 341894cbd..3b6ec51fd 100644 --- a/public/assets/css/thetool.css +++ b/public/assets/css/thetool.css @@ -71,6 +71,22 @@ h1, h2, h3, h4, h5, h6 { border-color: #f0f0f0; box-shadow: 3px 3px 2px #a0a0a0; } +.card.border-top-primary { + border-top: 2px solid #007bff; +} +.card.border-top-danger { + border-top: 2px solid #f1556c; +} +.card.border-top-success { + border-top: 2px solid #25b343; +} +.card.border-top-warning { + border-top: 2px solid #f7b84b; +} +/* +.card-header.underline-danger { + border-bottom: 2px solid #f1556c; +}*/ #topnav { box-shadow: 2px 2px 1px #a0a0a0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||