68 lines
1.6 KiB
PHP
68 lines
1.6 KiB
PHP
<?php
|
|
|
|
class Invoiceposition extends mfBaseModel {
|
|
|
|
public function setOption($name, $value) {
|
|
$options = $this->getOptions;
|
|
|
|
if($options) {
|
|
$options = json_decode($this->options);
|
|
if(json_last_error() !== JSON_ERROR_NONE) {
|
|
$options = new stdClass();
|
|
}
|
|
} else {
|
|
$options = new stdClass();
|
|
}
|
|
|
|
$options->$name = $value;
|
|
|
|
$this->options = json_encode($options);
|
|
}
|
|
|
|
public function getOption($name) {
|
|
if(!$this->options) return null;
|
|
|
|
$this->log->debug("getOptions ($name): ".print_r($this->options, true));
|
|
|
|
$options = json_decode($this->options);
|
|
if(json_last_error() !== JSON_ERROR_NONE) {
|
|
$this->log->debug("getOptions ($name) decoding failed");
|
|
return null;
|
|
}
|
|
|
|
if(property_exists($options, $name)) {
|
|
|
|
return $options->$name;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
public function __clone() {
|
|
$me = new User;
|
|
$me->loadMe();
|
|
|
|
$old_id = $this->id;
|
|
$this->id = null;
|
|
|
|
|
|
// cleanup data
|
|
$this->invoice_id = null;
|
|
$this->create_by = $me->id;
|
|
$this->edit_by = $me->id;
|
|
|
|
$this->create = null;
|
|
$this->edit = null;
|
|
$this->saved = 0;
|
|
$this->mode = "new";
|
|
$this->_old_data = new StdClass();
|
|
|
|
/*$this->save();
|
|
|
|
if($old_id == $this->id) {
|
|
$this->log->error("save() of cloned Contract $old_id failed!");
|
|
throw new Exception("Saving clone failed.");
|
|
}*/
|
|
|
|
//$this->log->debug("Cloned Invoiceposition $old_id");
|
|
}
|
|
} |