diff --git a/Layout/default/Contract/Form.php b/Layout/default/Contract/Form.php new file mode 100644 index 000000000..341702fa4 --- /dev/null +++ b/Layout/default/Contract/Form.php @@ -0,0 +1,218 @@ + + +
| Contract ID | Inhaber | Produkt | -Anschluss | +Matchcode | Preis | Preis Setup | Rechnungsperiode | +Fertigstellung | +Kündigung | Erstellt | Zuletzt bearbeitet | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| $contract->owner_id])?>" target="_blank">=$contract->owner->getCompanyOrName()?> | -=$contract->product->product->name?> | -+ | =$contract->id?> | +$contract->owner_id])?>" target="_blank">=$contract->owner->getCompanyOrName()?> | +$contract->id])?>">=$contract->product->name?> | +$contract->id])?>">=$contract->matchcode?> | +=$contract->price?> | =$contract->price_setup?> | @@ -74,12 +122,15 @@ =(12 / $contract->billing_period)?>x Jährlich | -=date('d.m.Y H:i', $contract->create)?> (=$contract->creator->name?>) | -=date('d.m.Y H:i', $contract->edit)?> (=$contract->editor->name?>) | +=($contract->finish_date) ? date('d.m.Y', $contract->finish_date) : ""?> | +=($contract->cancel_date) ? date('d.m.Y', $contract->cancel_date) : ""?> | +=date('d.m.Y H:i', $contract->create)?> =$contract->creator->name?> |
+ =date('d.m.Y H:i', $contract->edit)?> =$contract->editor->name?> |
+ $contract->id])?>"> $contract->id])?>"> - $contract->product->order_id])?>"> - $contract->id])?>" class="text-danger" title="Vertrag kündigen"> + $contract->id])?>" class="text-danger" title="Vertrag kündigen"> + orderproduct_id): ?> $contract->orderproduct->order_id])?>"> | Firma / Person | Admin | +Techniker | @@ -68,6 +69,7 @@ | =($user->address->company) ? $user->address->company : $user->address->getFullName()?> | =$user->email?> | =($user->isAdmin()) ? "Ja" : "Nein"?> | +=($user->is("Technician")) ? "Ja" : "Nein"?> | $user->id])?>" title="User bearbeiten"> id > 1): ?> diff --git a/application/Address/Address.php b/application/Address/Address.php index 92fe7a940..92fca065a 100644 --- a/application/Address/Address.php +++ b/application/Address/Address.php @@ -121,6 +121,20 @@ class Address extends mfBaseModel { return $spin; } + public function toArray() { + if(!$this->id) { + return []; + } + + $a = []; + $a['id'] = $this->id; + foreach($this->data as $key => $value) { + $a[$key] = $value; + } + + return $a; + } + public function getProperty($name) { if($this->$name == null) { diff --git a/application/Address/AddressController.php b/application/Address/AddressController.php index 605f48447..951afb2ec 100644 --- a/application/Address/AddressController.php +++ b/application/Address/AddressController.php @@ -241,6 +241,9 @@ class AddressController extends mfBaseController { $data = []; switch($do) { + case "getAddress": + $return = $this->getAddressApi(); + break; case "findAddress": $return = $this->findAddressApi(); break; @@ -257,6 +260,22 @@ class AddressController extends mfBaseController { $this->returnJson($data); } + private function getAddressApi() { + $id = trim($this->request->id); + if(!is_numeric($id) || !$id) { + return false; + } + + $address = new Address($id); + if(!$address->id) { + return false; + } + + $a = $address->toArray(); + + return ['address' => $a]; + } + private function findAddressApi() { $search = trim($this->request->q); $autocomplete = $this->request->autocomplete; @@ -284,7 +303,7 @@ class AddressController extends mfBaseController { $addresses = array_merge($addresses, AddressModel::search(["parents_only" => $po, "addresstype" => [$role], "firstname" => $search])); $addresses = array_merge($addresses, AddressModel::search(["parents_only" => $po, "addresstype" => [$role], "lastname" => $search])); - if(!is_array($addresses) && !count($addresses)) { + if(!is_array($addresses) || !count($addresses)) { return false; } @@ -302,7 +321,7 @@ class AddressController extends mfBaseController { if(!$autocomplete) { foreach($all_addresses as $id => $address) { $results[$id] = str_replace("'", "\\'", str_replace(["\n", "\r"], " ",$address->getCompanyOrName()))." (".$address->zip." ".$address->city.", ".$address->street.")".(($address->customer_number) ? " [".$address->customer_number."]" : ""); - if(count($results) > 5) { + if(count($results) > 15) { $results["more"] = "..."; break; } @@ -315,7 +334,7 @@ class AddressController extends mfBaseController { foreach($all_addresses as $id => $address) { $result = ['value' => $id, 'text' => str_replace("'", "\\'", str_replace(["\n", "\r"], " ",$address->getCompanyOrName()))." (".$address->zip." ".$address->city.", ".$address->street.")".(($address->customer_number) ? " [".$address->customer_number."]" : "")]; $results[] = $result; - if(count($results) > 5) { + if(count($results) > 15) { $results[] = ['value' => 0, 'text' => " --> Mehr Suchergebnisse vorhanden. Bitte Suchbegriff genauer definieren <--"]; break; } @@ -324,7 +343,5 @@ class AddressController extends mfBaseController { $this->returnJson($results); } - private function searchAddress() { - - } + } diff --git a/application/Contract/Contract.php b/application/Contract/Contract.php index b084199a4..2607c62ac 100644 --- a/application/Contract/Contract.php +++ b/application/Contract/Contract.php @@ -51,11 +51,11 @@ class Contract extends mfBaseModel { } if($name == "orderproduct") { - $this->orderproduct = mfValuecache::singleton()->get("mfObjectmodel-OrderProduct-".$this->orderorderproduct_id); + $this->orderproduct = mfValuecache::singleton()->get("mfObjectmodel-OrderProduct-".$this->orderproduct_id); if($this->orderproduct === null) { - $this->orderproduct = new OrderProduct($this->orderorderproduct_id); + $this->orderproduct = new OrderProduct($this->orderproduct_id); if($this->orderproduct->id) { - mfValuecache::singleton()->set("mfObjectmodel-OrderProduct-".$this->orderorderproduct_id, $this->orderproduct); + mfValuecache::singleton()->set("mfObjectmodel-OrderProduct-".$this->orderproduct_id, $this->orderproduct); } } return $this->orderproduct; diff --git a/application/Contract/ContractController.php b/application/Contract/ContractController.php index 5f243a4b1..d5a659bd6 100644 --- a/application/Contract/ContractController.php +++ b/application/Contract/ContractController.php @@ -55,4 +55,14 @@ class ContractController extends mfBaseController { return $new_filter; } + + protected function addAction() { + $this->layout()->setTemplate("Contract/Form"); + } + + protected function editAction() { + + + return $this->addAction(); + } } \ No newline at end of file diff --git a/application/Product/ProductController.php b/application/Product/ProductController.php index 25a71f851..a6ca54caf 100644 --- a/application/Product/ProductController.php +++ b/application/Product/ProductController.php @@ -220,6 +220,8 @@ class ProductController extends mfBaseController { case "getProduct": $return = $this->getProductApi(); break; + case "findProduct": + $return = $this->findProductApi(); default: $return = false; } @@ -259,4 +261,38 @@ class ProductController extends mfBaseController { return ["product" => $product->data, "form_id" => $form_id]; } + + private function findProductApi() { + $search = trim($this->request->q); + $autocomplete = $this->request->autocomplete; + + $products = []; + + if(is_numeric($search)) { + $pnumbers = ProductModel::search(["id" => $search]); + if($pnumbers) { + $products = array_merge($products, $pnumbers); + } + } + + + $products = array_merge($products, ProductModel::search(["nameLike" => $search])); + + if(!is_array($products) && !count($products)) { + return false; + } + + $results = []; + + // return bootstrap-autocomplete format + foreach($products as $product) { + $result = ['value' => $product->id, 'text' => str_replace("'", "\\'", str_replace(["\n", "\r"], " ",$product->name))]; + $results[] = $result; + if(count($results) > 15) { + $results[] = ['value' => 0, 'text' => " --> Mehr Suchergebnisse vorhanden. Bitte Suchbegriff genauer definieren <--"]; + break; + } + } + $this->returnJson($results); + } } \ No newline at end of file diff --git a/application/Product/ProductModel.php b/application/Product/ProductModel.php index 0a54eb135..5d6b49b95 100644 --- a/application/Product/ProductModel.php +++ b/application/Product/ProductModel.php @@ -121,6 +121,13 @@ class ProductModel { $db = FronkDB::singleton(); //var_dump($filter);exit; + if(array_key_exists("id", $filter)) { + $id = $db->escape($filter['id']); + if($id) { + $where .= " AND Product.`id` like '%$id%'"; + } + } + if(array_key_exists("productgroup_id", $filter)) { $productgroup_id = $filter['productgroup_id']; if(is_numeric($productgroup_id)) { @@ -138,14 +145,14 @@ class ProductModel { if(array_key_exists("name", $filter)) { $name = $db->escape($filter['name']); if($name) { - $where .= " AND `name` like '$name'"; + $where .= " AND Product.`name` like '$name'"; } } if(array_key_exists("nameLike", $filter)) { $name = $db->escape($filter['nameLike']); if($name) { - $where .= " AND `name` like '%$name%'"; + $where .= " AND Product.`name` like '%$name%'"; } } diff --git a/application/User/User.php b/application/User/User.php index 7a090b63e..9e7376e02 100644 --- a/application/User/User.php +++ b/application/User/User.php @@ -114,8 +114,9 @@ class User extends mfBaseModel { } foreach($what as $w) { - if(is_object($this->permissions) && property_exists($this->permissions, "is$w")) { - if($this->permissions->{"is$w"} === true) { + $perm = ucfirst(strtolower($w)); + if(is_object($this->permissions) && property_exists($this->permissions, "is$perm")) { + if($this->permissions->{"is$perm"} === true) { return true; } } |