Added Contractconfig Edit
This commit is contained in:
@@ -1,5 +1,63 @@
|
||||
<?php
|
||||
|
||||
class ContractconfigValue extends mfBaseModel {
|
||||
private $item;
|
||||
|
||||
public function set($new_value) {
|
||||
$item = $this->getProperty("item");
|
||||
|
||||
if($new_value === null || strlen($new_value) == 0) {
|
||||
$this->int = null;
|
||||
$this->number = null;
|
||||
$this->string = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
if($item->type == "int") {
|
||||
if(!is_numeric($new_value)) return false;
|
||||
$this->int = $new_value;
|
||||
} elseif($item->type == "decimal") {
|
||||
if(!is_float($new_value) && !is_numeric($new_value)) return false;
|
||||
$this->number = $new_value;
|
||||
} elseif(is_scalar($new_value)) {
|
||||
$this->string = $new_value;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
$this->edit_by = $me->id;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if(!$this->id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if($name == "item") {
|
||||
$this->item = new ContractconfigItem($this->item_id);
|
||||
if(!$this->item->id) {
|
||||
return null;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user