116 lines
3.3 KiB
PHP
116 lines
3.3 KiB
PHP
<?php
|
|
|
|
class Preorder extends mfBaseModel {
|
|
protected $forcestr = ['street','company','zip','phone','email','note'];
|
|
private $campaign;
|
|
private $partner;
|
|
private $building;
|
|
private $adb_hausnummer;
|
|
private $adb_wohneinheit;
|
|
|
|
|
|
public function afterLoad() {
|
|
if($this->uid === "string") {
|
|
$this->uid = "";
|
|
}
|
|
}
|
|
|
|
public function createUcode() {
|
|
$ucode = $this->generateNewUcode();
|
|
while(PreorderModel::search(['ucode' => $ucode])) {
|
|
$ucode = $this->generateNewUcode();
|
|
}
|
|
$this->ucode = $ucode;
|
|
return $this->ucode;
|
|
}
|
|
|
|
private function generateNewUcode() {
|
|
$chars = '23456789ABCDEFGHJKLMNPQRSTUVWXYZ';
|
|
$charsLength = strlen($chars);
|
|
$ucode = '';
|
|
for ($i = 0; $i < 8; $i++) {
|
|
$ucode .= $chars[rand(0, $charsLength - 1)];
|
|
}
|
|
return $ucode;
|
|
}
|
|
|
|
public function getProperty($name) {
|
|
if($this->$name == null) {
|
|
|
|
if($name == "campaign") {
|
|
$this->campaign = new Preordercampaign($this->preordercampaign_id);
|
|
return $this->campaign;
|
|
}
|
|
|
|
if($name == "partner") {
|
|
$this->partner = mfValuecache::singleton()->get("mfObjectmodel-Address-".$this->partner_id);
|
|
if(!$this->partner) {
|
|
$this->partner = new Address($this->partner_id);
|
|
if($this->partner->id) {
|
|
mfValuecache::singleton()->set("mfObjectmodel-Address-".$this->partner_id, $this->partner);
|
|
}
|
|
}
|
|
return $this->partner;
|
|
}
|
|
|
|
if($name == "building") {
|
|
$this->building = mfValuecache::singleton()->get("mfObjectmodel-Building-".$this->building_id);
|
|
if(!$this->building) {
|
|
$this->building = new Building($this->building_id);
|
|
if($this->building->id) {
|
|
mfValuecache::singleton()->set("mfObjectmodel-Building-".$this->building_id, $this->building);
|
|
}
|
|
}
|
|
return $this->building;
|
|
}
|
|
|
|
if($name == "adb_hausnummer") {
|
|
$this->adb_hausnummer = new ADBHausnummer($this->adb_hausnummer_id);
|
|
return $this->adb_hausnummer;
|
|
}
|
|
|
|
if($name == "adb_wohneinheit") {
|
|
$this->adb_wohneinheit = new ADBWohneinheit($this->adb_wohneinheit_id);
|
|
return $this->adb_wohneinheit;
|
|
}
|
|
|
|
if($name == "addon_services") {
|
|
|
|
}
|
|
|
|
if($name == "creator") {
|
|
$user = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
|
|
if($user) {
|
|
$this->creator = $user;
|
|
return $this->creator;
|
|
}
|
|
$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 = new User($this->edit_by);
|
|
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;
|
|
}
|
|
} |