More Contract stuff
This commit is contained in:
@@ -10,12 +10,100 @@ class Contract extends mfBaseModel {
|
||||
private $contractConfigGroups;
|
||||
private $contractConfigItems;
|
||||
private $configgroups;
|
||||
private $links;
|
||||
private $linkFrom;
|
||||
private $linkTo;
|
||||
private $upgradeFrom;
|
||||
private $upgradeTo;
|
||||
private $downgradeFrom;
|
||||
private $downgradeTo;
|
||||
private $productchangeFrom;
|
||||
private $productchangeTo;
|
||||
private $relocationFrom;
|
||||
private $relocationTo;
|
||||
private $finisher;
|
||||
private $canceler;
|
||||
private $creator;
|
||||
private $editor;
|
||||
|
||||
|
||||
private function getLinks() {
|
||||
$this->linkFrom = [];
|
||||
$this->linkTo = [];
|
||||
$this->upgradeFrom = [];
|
||||
$this->upgradeTo = [];
|
||||
$this->downgradeFrom = [];
|
||||
$this->downgradeTo = [];
|
||||
$this->productchangeFrom = [];
|
||||
$this->productchangeTo = [];
|
||||
$this->relocationFrom = [];
|
||||
$this->relocationTo = [];
|
||||
|
||||
// Links targeting this contract (to)
|
||||
foreach(ContractLinkModel::search(['origin_contract_id' => $this->id]) as $link) {
|
||||
switch($link->type) {
|
||||
case "link":
|
||||
$this->linkTo[] = $link;
|
||||
break;
|
||||
case "upgrade":
|
||||
$this->upgradeTo[] = $link;
|
||||
break;
|
||||
case "downgrade":
|
||||
$this->downgradeTo[] = $link;
|
||||
break;
|
||||
case "productchange":
|
||||
$this->productchangeTo[] = $link;
|
||||
break;
|
||||
case "relocation":
|
||||
$this->relocationTo[] = $link;
|
||||
break;
|
||||
default:
|
||||
$this->log->warn("ContractLink with invalid type: ".$link->id." ".$link->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach(ContractLinkModel::search(['contract_id' => $this->id]) as $link) {
|
||||
switch($link->type) {
|
||||
case "link":
|
||||
$this->linkFrom[] = $link;
|
||||
break;
|
||||
case "upgrade":
|
||||
$this->upgradeFrom[] = $link;
|
||||
break;
|
||||
case "downgrade":
|
||||
$this->downgradeFrom[] = $link;
|
||||
break;
|
||||
case "productchange":
|
||||
$this->productchangeFrom[] = $link;
|
||||
break;
|
||||
case "relocation":
|
||||
$this->relocationFrom[] = $link;
|
||||
break;
|
||||
default:
|
||||
$this->log->warn("ContractLink with invalid type: ".$link->id." ".$link->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*$this->links = mfValuecache::singleton()->get("ContractLinks-origin-".$this->id);
|
||||
if(!$this->links) {
|
||||
$this->links = [];
|
||||
foreach(ContractLinkModel::search(["origin_contract_id" => $this->id]) as $link) {
|
||||
if(array_key_exists($link->type, $this->links)) {
|
||||
$this->links[$link->type] = [];
|
||||
}
|
||||
$this->links[$link->type][] = $link;
|
||||
}
|
||||
}
|
||||
if(count($this->links)) {
|
||||
mfValuecache::singleton()->set("ContractLinks-origin-".$this->id, $this->links);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
@@ -96,6 +184,18 @@ class Contract extends mfBaseModel {
|
||||
return $this->contractConfigItems;
|
||||
}
|
||||
|
||||
if($name == "links") {
|
||||
$this->links = ContractLinkModel::includesContractId($this->id, ["type" => $link]);
|
||||
return $this->links;
|
||||
}
|
||||
|
||||
if(in_array($name, ['linkFrom','linkTo','upgradeFrom','upgradeTo','downgradeFrom','downgradeTo','productchangeFrom','productchangeTo','relocationFrom','relocationTo'])) {
|
||||
if($this->$name === null) {
|
||||
$this->getLinks();
|
||||
}
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
if($name == "finisher") {
|
||||
$this->finisher = mfValuecache::singleton()->get("Worker-id-".$this->finish_date_by);
|
||||
if($this->finisher === null) {
|
||||
|
||||
@@ -47,6 +47,14 @@ class ContractController extends mfBaseController {
|
||||
private function getPreparedFilter($filter) {
|
||||
$new_filter = [];
|
||||
|
||||
if(array_key_exists("show_canceled", $filter)) {
|
||||
if($filter['show_canceled'] == 0) {
|
||||
$new_filter['add-where'] = " AND (cancel_date IS NULL OR cancel_date > UNIX_TIMESTAMP())";
|
||||
}
|
||||
} else {
|
||||
$new_filter['add-where'] = " AND (cancel_date IS NULL OR cancel_date > UNIX_TIMESTAMP())";
|
||||
}
|
||||
|
||||
if(is_array($filter) && count($filter)) {
|
||||
foreach($filter as $name => $value) {
|
||||
$new_filter[$name] = $value;
|
||||
@@ -198,7 +206,8 @@ class ContractController extends mfBaseController {
|
||||
$this->layout()->setFlash("Vertrag erfolgreich gespeichert.", "success");
|
||||
|
||||
|
||||
|
||||
/* ContractLinks */
|
||||
|
||||
|
||||
$query = [];
|
||||
if($r->s) {
|
||||
|
||||
@@ -201,6 +201,13 @@ class ContractModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("customer_number", $filter)) {
|
||||
$customer_number = $filter['customer_number'];
|
||||
if(is_numeric($customer_number)) {
|
||||
$where .= " AND Address.customer_number=$customer_number";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("owner", $filter)) {
|
||||
$owner = FronkDB::singleton()->escape($filter["owner"]);
|
||||
if($owner) {
|
||||
@@ -208,6 +215,10 @@ class ContractModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("add-where", $filter)) {
|
||||
$where .= " ".$filter['add-where'];
|
||||
}
|
||||
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
|
||||
69
application/ContractLink/ContractLink.php
Normal file
69
application/ContractLink/ContractLink.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
class ContractLink extends mfBaseModel {
|
||||
private $contract;
|
||||
private $origin;
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if(!$this->id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if($name == "origin") {
|
||||
$this->origin = mfValuecache::singleton()->get("mfObjectmodel-Contract-".$this->origin_contract_id);
|
||||
if($this->origin === null) {
|
||||
$this->origin = new Contract($this->origin_contract_id);
|
||||
if($this->origin->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-Contract-".$this->id, $this->origin);
|
||||
}
|
||||
}
|
||||
return $this->origin;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
170
application/ContractLink/ContractLinkModel.php
Normal file
170
application/ContractLink/ContractLinkModel.php
Normal file
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
|
||||
class ContractLinkModel {
|
||||
public $contract_id;
|
||||
public $origin_contract_id;
|
||||
public $type;
|
||||
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
public $create = null;
|
||||
public $edit = null;
|
||||
|
||||
|
||||
public static function create(Array $data) {
|
||||
$model = new ContractLink();
|
||||
|
||||
foreach($data as $field => $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("ContractLink", "*", "1 = 1 ORDER BY contract_id,origin_contract_id");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new ContractLink($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT * FROM ContractLink
|
||||
WHERE $where
|
||||
ORDER BY contract_id,origin_contract_id
|
||||
LIMIT 1";
|
||||
//var_dump($sql);exit;
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new ContractLink($data);
|
||||
if($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function includesContractId($contract_id, $filter=[]) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT * FROM ContractLink
|
||||
WHERE (contract_id=$contract_id OR origin_contract_id=$contract_id)
|
||||
AND $where
|
||||
ORDER BY contract_id,origin_contract_id";
|
||||
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[$data->id] = new ContractLink($data);
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
public static function count($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) FROM ContractLink
|
||||
WHERE $where
|
||||
";
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
return $data->cnt;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function search($filter, $limit = false) {
|
||||
//var_dump($filter);exit;
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT * FROM ContractLink
|
||||
WHERE $where
|
||||
ORDER BY contract_id,origin_contract_id";
|
||||
|
||||
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 ContractLink($data);
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
private static function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
//var_dump($filter);exit;
|
||||
|
||||
if(array_key_exists("contract_id", $filter)) {
|
||||
$contract_id = $filter['contract_id'];
|
||||
if(is_numeric($contract_id)) {
|
||||
$where .= " AND ContractLink.contract_id = '$contract_id'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("origin_contract_id", $filter)) {
|
||||
$origin_contract_id = $filter['origin_contract_id'];
|
||||
if(is_numeric($origin_contract_id)) {
|
||||
$where .= " AND ContractLink.origin_contract_id = '$origin_contract_id'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,100 +15,37 @@ class ContractconfigController extends mfBaseController {
|
||||
}
|
||||
|
||||
protected function indexAction() {
|
||||
$groups = ContractconfigGroupModel::search([]);
|
||||
|
||||
$this->layout()->set("configgroups", $groups);
|
||||
}
|
||||
|
||||
protected function viewAction() {
|
||||
|
||||
}
|
||||
|
||||
protected function editAction() {
|
||||
$this->layout()->setTemplate("Contractconfig/Form");
|
||||
|
||||
$contract_id = $this->request->contract_id;
|
||||
if(!$contract_id) {
|
||||
$this->layout()->setFlash("Contract ID nicht gefunden.","danger");
|
||||
$this->redirect("Contract");
|
||||
}
|
||||
|
||||
$contract = new Contract($contract_id);
|
||||
if(!$contract_id) {
|
||||
$this->layout()->setFlash("Contract ID nicht gefunden.","danger");
|
||||
$this->redirect("Contract");
|
||||
}
|
||||
|
||||
if(!is_array($contract->configgroups) || !count($contract->configgroups)) {
|
||||
$this->layout()->setFlash("Produkt hat keine Vertragsconfiggruppen hinterlegt.","info");
|
||||
$this->redirect("Contract", "View", ["id" => $contract_id]);
|
||||
}
|
||||
|
||||
$this->layout()->set("contract", $contract);
|
||||
$this->layout()->set("groups", $contract->configgroups);
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected function addGroupAction() {
|
||||
$groupname = ucfirst(trim($this->request->name));
|
||||
|
||||
if(!$groupname) {
|
||||
$this->layout()->setFlash("Gruppenname darf nicht leer sein!", "error");
|
||||
$this->redirect("Contractconfig");
|
||||
}
|
||||
|
||||
$group = ContractconfigGroupModel::getFirst(["name" => $groupname]);
|
||||
if($group) {
|
||||
$this->layout()->setFlash("Gruppe gibs scho", "warn");
|
||||
$this->redirect("Contractconfig");
|
||||
}
|
||||
|
||||
$group = ContractconfigGroupModel::create(["name" => $groupname]);
|
||||
$group_id = $group->save();
|
||||
if(!$group_id) {
|
||||
$this->layout()->setFlash("Fehler beim Speichern", "error");
|
||||
$this->redirect("Contractconfig");
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Gruppe $groupname erfolgreich angelegt", "success");
|
||||
$this->redirect("Contractconfig");
|
||||
}
|
||||
|
||||
protected function saveAction() {
|
||||
$r = $this->request;
|
||||
|
||||
$item_id = $r->item_id;
|
||||
if(is_numeric($item_id) && $item_id > 0) {
|
||||
$mode = "edit";
|
||||
$item = new ContractconfigItem($item_id);
|
||||
if(!$item->id) {
|
||||
$this->layout()->setFlash("Element nicht gefunden", "error");
|
||||
$this->redirect("Contractconfig");
|
||||
}
|
||||
} else {
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
$item_data['contractconfiggroup_id'] = $r->group_id;
|
||||
$item_data['name'] = $r->name;
|
||||
$item_data['displayname'] = $r->displayname;
|
||||
$item_data['description'] = $r->description;
|
||||
|
||||
$item_data['typedata'] = "";
|
||||
$item_data['pattern'] = "";
|
||||
|
||||
switch($r->type) {
|
||||
case "string":
|
||||
$item_data['type'] = "string";
|
||||
$item_data['pattern'] = $r->pattern;
|
||||
break;
|
||||
case "enum":
|
||||
$item_data['type'] = "enum";
|
||||
$item_data['typedata'] = $r->data;
|
||||
break;
|
||||
case "int":
|
||||
$item_data['type'] = "int";
|
||||
break;
|
||||
case "decimal":
|
||||
$item_data['type'] = "decimal";
|
||||
break;
|
||||
default:
|
||||
$this->layout()->setFlash("Ungültiger Datentyp!");
|
||||
$this->redirect("Contractconfig");
|
||||
}
|
||||
|
||||
if($mode == "edit") {
|
||||
$item->update($item_data);
|
||||
} else {
|
||||
$item = ContractconfigItemModel::create($item_data);
|
||||
}
|
||||
|
||||
//var_dump($item);exit;
|
||||
|
||||
$item_id = $item->save();
|
||||
|
||||
if(!$item_id) {
|
||||
$this->layout()->setFlash("Fehler beim Speichern!");
|
||||
$this->redirect("Contractconfig");
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Element erfolgreich gespeichert", "success");
|
||||
$this->redirect("Contractconfig");
|
||||
//$this->redirect("Contractconfig","Index","","item=$item_id");
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
class ContractconfigItemController extends mfBaseController {
|
||||
|
||||
protected function init() {
|
||||
$this->needlogin=true;
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me",$me);
|
||||
|
||||
if(!$me->is(["Admin"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
}
|
||||
|
||||
protected function saveAction() {
|
||||
$r = $this->request;
|
||||
|
||||
$item_id = $r->item_id;
|
||||
if(is_numeric($item_id) && $item_id > 0) {
|
||||
$mode = "edit";
|
||||
$item = new ContractconfigItem($item_id);
|
||||
if(!$item->id) {
|
||||
$this->layout()->setFlash("Element nicht gefunden", "error");
|
||||
$this->redirect("Contractconfiggroup");
|
||||
}
|
||||
} else {
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
$item_data['contractconfiggroup_id'] = $r->group_id;
|
||||
$item_data['name'] = $r->name;
|
||||
$item_data['displayname'] = $r->displayname;
|
||||
$item_data['description'] = $r->description;
|
||||
|
||||
$item_data['typedata'] = "";
|
||||
$item_data['pattern'] = "";
|
||||
|
||||
switch($r->type) {
|
||||
case "string":
|
||||
$item_data['type'] = "string";
|
||||
$item_data['pattern'] = $r->pattern;
|
||||
break;
|
||||
case "enum":
|
||||
$item_data['type'] = "enum";
|
||||
$item_data['typedata'] = $r->data;
|
||||
break;
|
||||
case "int":
|
||||
$item_data['type'] = "int";
|
||||
break;
|
||||
case "decimal":
|
||||
$item_data['type'] = "decimal";
|
||||
break;
|
||||
default:
|
||||
$this->layout()->setFlash("Ungültiger Datentyp!");
|
||||
$this->redirect("Contractconfiggroup");
|
||||
}
|
||||
|
||||
if($mode == "edit") {
|
||||
$item->update($item_data);
|
||||
} else {
|
||||
$item = ContractconfigItemModel::create($item_data);
|
||||
}
|
||||
|
||||
//var_dump($item);exit;
|
||||
|
||||
$item_id = $item->save();
|
||||
|
||||
if(!$item_id) {
|
||||
$this->layout()->setFlash("Fehler beim Speichern!");
|
||||
$this->redirect("Contractconfiggroup");
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Element erfolgreich gespeichert", "success");
|
||||
$this->redirect("Contractconfiggroup");
|
||||
//$this->redirect("Contractconfig","Index","","item=$item_id");
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class ContractconfigGroup extends mfBaseModel {
|
||||
class Contractconfiggroup extends mfBaseModel {
|
||||
private $items;
|
||||
private $contract_id;
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
class ContractconfiggroupController extends mfBaseController {
|
||||
|
||||
protected function init() {
|
||||
$this->needlogin=true;
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me",$me);
|
||||
|
||||
if(!$me->is(["Admin"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
}
|
||||
|
||||
protected function indexAction() {
|
||||
$groups = ContractconfiggroupModel::search([]);
|
||||
|
||||
$this->layout()->set("configgroups", $groups);
|
||||
}
|
||||
|
||||
|
||||
protected function saveAction() {
|
||||
$groupname = ucfirst(trim($this->request->name));
|
||||
|
||||
if(!$groupname) {
|
||||
$this->layout()->setFlash("Gruppenname darf nicht leer sein!", "error");
|
||||
$this->redirect("Contractconfiggroup");
|
||||
}
|
||||
|
||||
$group = ContractconfiggroupModel::getFirst(["name" => $groupname]);
|
||||
if($group) {
|
||||
$this->layout()->setFlash("Gruppe gibs scho", "warn");
|
||||
$this->redirect("Contractconfiggroup");
|
||||
}
|
||||
|
||||
$group = ContractconfiggroupModel::create(["name" => $groupname]);
|
||||
$group_id = $group->save();
|
||||
if(!$group_id) {
|
||||
$this->layout()->setFlash("Fehler beim Speichern", "error");
|
||||
$this->redirect("Contractconfiggroup");
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Gruppe $groupname erfolgreich angelegt", "success");
|
||||
$this->redirect("Contractconfiggroup");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class ContractconfigGroupModel {
|
||||
class ContractconfiggroupModel {
|
||||
public $name;
|
||||
|
||||
public $create_by = null;
|
||||
@@ -10,7 +10,7 @@ class ContractconfigGroupModel {
|
||||
|
||||
|
||||
public static function create(Array $data) {
|
||||
$model = new ContractconfigGroup();
|
||||
$model = new Contractconfiggroup();
|
||||
|
||||
foreach($data as $field => $value) {
|
||||
if(property_exists(get_called_class(), $field)) {
|
||||
@@ -36,10 +36,10 @@ class ContractconfigGroupModel {
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("ContractconfigGroup", "*", "1=1 ORDER BY name, `create`");
|
||||
$res = $db->select("Contractconfiggroup", "*", "1=1 ORDER BY name, `create`");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new ContractconfigGroup($data);
|
||||
$items[] = new Contractconfiggroup($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
@@ -50,10 +50,10 @@ class ContractconfigGroupModel {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("ContractconfigGroup", "*", "$where ORDER BY name, `create` LIMIT 1");
|
||||
$res = $db->select("Contractconfiggroup", "*", "$where ORDER BY name, `create` LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new ContractconfigGroup($data);
|
||||
$item = new Contractconfiggroup($data);
|
||||
if($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
@@ -68,19 +68,19 @@ class ContractconfigGroupModel {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT ContractconfigGroup.* FROM ContractconfigGroup
|
||||
LEFT JOIN ContractconfiggroupProductgroup ON (ContractconfigGroup.id = ContractconfiggroupProductgroup.contractconfiggroup_id)
|
||||
$sql = "SELECT Contractconfiggroup.* FROM Contractconfiggroup
|
||||
LEFT JOIN ContractconfiggroupProductgroup ON (Contractconfiggroup.id = ContractconfiggroupProductgroup.contractconfiggroup_id)
|
||||
LEFT JOIN Productgroup ON (ContractconfiggroupProductgroup.productgroup_id = Productgroup.id)
|
||||
WHERE $where
|
||||
GROUP BY ContractconfigGroup.id
|
||||
ORDER BY ContractconfigGroup.name, ContractconfigGroup.`create`
|
||||
GROUP BY Contractconfiggroup.id
|
||||
ORDER BY Contractconfiggroup.name, Contractconfiggroup.`create`
|
||||
";
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
$res = $db->query($sql);
|
||||
//$res = $db->select("ContractconfigGroup", "*", "$where ORDER BY name, `create`");
|
||||
//$res = $db->select("Contractconfiggroup", "*", "$where ORDER BY name, `create`");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new ContractconfigGroup($data);
|
||||
$items[] = new Contractconfiggroup($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
@@ -93,7 +93,7 @@ class ContractconfigGroupModel {
|
||||
if(array_key_exists("name", $filter)) {
|
||||
$name = FronkDB::singleton()->escape($filter['name']);
|
||||
if($name) {
|
||||
$where .= " AND ContractconfigGroup.name='$name'";
|
||||
$where .= " AND Contractconfiggroup.name='$name'";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class ContractconfiggroupProductgroup extends mfBaseModel {
|
||||
}
|
||||
|
||||
if($name == "contractconfiggroup") {
|
||||
$this->contractconfiggroup = new ContractconfigGroup($this->contractconfiggroup_id);
|
||||
$this->contractconfiggroup = new Contractconfiggroup($this->contractconfiggroup_id);
|
||||
return $this->contractconfiggroup;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user