WIP Contract Form
This commit is contained in:
@@ -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) {
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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%'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user