Fixed not setting flag 141 in rimo-import

This commit is contained in:
Frank Schubert
2025-08-20 16:28:12 +02:00
parent 5d4b6a6d04
commit 73cf1098a5
8 changed files with 128 additions and 80 deletions

View File

@@ -672,10 +672,10 @@
<h3>ONT</h3> <h3>ONT</h3>
<table class="table table-sm table-striped"> <table class="table table-sm table-striped">
<tr> <tr>
<th>SN</th> <th class="text-right">S/N</th>
<td class="text-monospace"><?=($preorder->citycomoan) ? $preorder->citycomoan->ont_sn : ""?></td> <td class="text-monospace"><?=($preorder->citycomoan) ? $preorder->citycomoan->ont_sn : ""?></td>
</tr><tr> </tr><tr>
<th>FSAN</th> <th class="text-right">FSAN</th>
<td class="text-monospace"><?=($preorder->citycomoan) ? $preorder->citycomoan->ont_gpid : ""?></td> <td class="text-monospace"><?=($preorder->citycomoan) ? $preorder->citycomoan->ont_gpid : ""?></td>
</tr> </tr>
</table> </table>

View File

@@ -11,6 +11,8 @@ class ADBHausnummer extends mfBaseModel {
private $freigaben = []; private $freigaben = [];
private $wohneinheiten = []; private $wohneinheiten = [];
protected function init() { protected function init() {
$this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME); $this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
$this->table = "Hausnummer"; $this->table = "Hausnummer";
@@ -19,7 +21,10 @@ class ADBHausnummer extends mfBaseModel {
public function afterSave($_params = []) { public function afterSave($_params = []) {
if(array_key_exists("no_aftersave", $_params) && $_params["no_aftersave"]) return true; if(array_key_exists("no_aftersave", $_params) && $_params["no_aftersave"]) return true;
$this->log->debug("[".$this->_ruid."] "."-----------------------------------------");
$this->log->debug("[".$this->_ruid."] ".__METHOD__.": hausnummer_id: ".$this->id);
// prevent potential infinite loop // prevent potential infinite loop
$nesting_level = mfValuecache::singleton()->get("adbhausnummer-save-nesting-level-".$this->id); $nesting_level = mfValuecache::singleton()->get("adbhausnummer-save-nesting-level-".$this->id);
if(!$nesting_level) { if(!$nesting_level) {
@@ -30,6 +35,7 @@ class ADBHausnummer extends mfBaseModel {
mfValuecache::singleton()->set("adbhausnummer-save-nesting-level-".$this->id, $nesting_level); mfValuecache::singleton()->set("adbhausnummer-save-nesting-level-".$this->id, $nesting_level);
if($nesting_level > 1) { if($nesting_level > 1) {
$this->log->debug("[".$this->_ruid."] ".__METHOD__.": Preventing potential infinite loop");
return true; return true;
} }
@@ -45,6 +51,9 @@ class ADBHausnummer extends mfBaseModel {
AddressDB::handleRimoStatusUpdate($wohneinheit->id); AddressDB::handleRimoStatusUpdate($wohneinheit->id);
} }
// reload self from database
$this->fetch($this->id);
return true; return true;
} }
@@ -81,7 +90,7 @@ class ADBHausnummer extends mfBaseModel {
$me = new User(); $me = new User();
$me->loadMe(); $me->loadMe();
$this->log->info(__CLASS__." Changes: User ".$me->username." $logstr"); $this->log->info("[".$this->_ruid."] ".__CLASS__." Changes: User ".$me->username." $logstr");
return true; return true;
@@ -106,7 +115,7 @@ class ADBHausnummer extends mfBaseModel {
public function setNewStatusCode($new_status_code) { public function setNewStatusCode($new_status_code) {
if(!$new_status_code) return false; if(!$new_status_code) return false;
$this->log->debug(__METHOD__.": Want new Hausnummer (".$this->id.") Status ".$new_status_code); $this->log->debug("[".$this->_ruid."] ".__METHOD__.": Want new Hausnummer (".$this->id.") Status ".$new_status_code);
$new_status = ADBStatusModel::getFirst(["code" => $new_status_code]); $new_status = ADBStatusModel::getFirst(["code" => $new_status_code]);
@@ -115,7 +124,7 @@ class ADBHausnummer extends mfBaseModel {
$flag = ADBStatusflagModel::getFirst(["code" => $new_status_code]); $flag = ADBStatusflagModel::getFirst(["code" => $new_status_code]);
if(!$flag) return false; if(!$flag) return false;
$this->log->debug(__METHOD__.": Statuscode $new_status_code is Flag"); $this->log->debug("[".$this->_ruid."] ".__METHOD__.": Statuscode $new_status_code is Flag");
$flag_value = ADBHausnummerStatusflagValueModel::getFirst(["flag_id" => $flag->id, "hausnummer_id" => $this->id]); $flag_value = ADBHausnummerStatusflagValueModel::getFirst(["flag_id" => $flag->id, "hausnummer_id" => $this->id]);
if(!$flag_value) { if(!$flag_value) {
$flag_value = ADBHausnummerStatusflagValueModel::create([ $flag_value = ADBHausnummerStatusflagValueModel::create([
@@ -130,7 +139,7 @@ class ADBHausnummer extends mfBaseModel {
$old_status = $this->getProperty("status"); $old_status = $this->getProperty("status");
if($old_status->code < $new_status->code) { if($old_status->code < $new_status->code) {
$this->log->debug(__METHOD__.": Setting Hausnummer (".$this->id.") Status from ".$old_status->code." to ".$new_status->code); $this->log->debug("[".$this->_ruid."] ".__METHOD__.": Setting Hausnummer (".$this->id.") Status from ".$old_status->code." to ".$new_status->code);
$this->status_id = $new_status->id; $this->status_id = $new_status->id;
} }
@@ -145,7 +154,7 @@ class ADBHausnummer extends mfBaseModel {
'street' => $this->getProperty("strasse")->name 'street' => $this->getProperty("strasse")->name
]; ];
if(!$search['country'] || !$search['city'] || !$search['zip'] || !$search['street']) { if(!$search['country'] || !$search['city'] || !$search['zip'] || !$search['street']) {
$this->log->warning(__METHOD__.": Unable to retrieve GPS Coordinates. Search key missing (hausnummer_id: ".$this->id.")"); $this->log->warning("[".$this->_ruid."] ".__METHOD__.": Unable to retrieve GPS Coordinates. Search key missing (hausnummer_id: ".$this->id.")");
return false; return false;
} }
@@ -191,7 +200,7 @@ class ADBHausnummer extends mfBaseModel {
} }
if(ADBHausnummerModel::search(['oaid' => $code])) { if(ADBHausnummerModel::search(['oaid' => $code])) {
$this->log->warn(__FILE__."::getNewObjectCode: New Code already in use. Trying again for a maximum of $try times."); $this->log->warn("[".$this->_ruid."] ".__FILE__."::getNewObjectCode: New Code already in use. Trying again for a maximum of $try times.");
} else { } else {
// code is unique // code is unique
break; break;

View File

@@ -9,13 +9,16 @@ class ADBHausnummerStatusflagValue extends mfBaseModel {
} }
protected function afterSave() { protected function afterSave() {
$this->log->debug("[".$this->_ruid."] "."-----------------------------------------");
$this->log->debug("[".$this->_ruid."] ".__METHOD__.": statusflagvalue_id: ".$this->id);
if(!property_exists($this->_old_data, "value") || $this->_old_data->value != $this->data->value) { if(!property_exists($this->_old_data, "value") || $this->_old_data->value != $this->data->value) {
// cascade new status to all preorders // cascade new status to all preorders
foreach(PreorderModel::search(["adb_hausnummer_id" => $this->hausnummer_id]) as $preorder) { foreach(PreorderModel::search(["adb_hausnummer_id" => $this->hausnummer_id]) as $preorder) {
// get PreorederStatusflag // get PreorederStatusflag
$pflag = PreorderStatusflagModel::getFirst(["code" => $this->getProperty("flag")->code]); $pflag = PreorderStatusflagModel::getFirst(["code" => $this->getProperty("flag")->code]);
if(!$pflag) { if(!$pflag) {
$this->log->debug(__METHOD__ . ": Preorder statusflag " . $this->getProperty("flag")->code . " not found"); $this->log->debug("[".$this->_ruid."] ".__METHOD__ . ": Preorder statusflag " . $this->getProperty("flag")->code . " not found");
return true; return true;
} }
@@ -32,9 +35,9 @@ class ADBHausnummerStatusflagValue extends mfBaseModel {
} }
if($new || $pflagval->value != $this->value) { if($new || $pflagval->value != $this->value) {
$pflagval->value = $this->value; $pflagval->value = $this->value;
//$this->log->debug(__METHOD__.": ".print_r($pflagval, true)); //$this->log->debug("[".$this->_ruid."] ".__METHOD__.": ".print_r($pflagval, true));
$pflagval->save(); $pflagval->save();
$this->log->debug(__METHOD__ . ": statusflag " . $this->getProperty("flag")->code . " saved for preorder " . $preorder->id); $this->log->debug("[".$this->_ruid."] ".__METHOD__ . ": statusflag " . $this->getProperty("flag")->code . " saved for preorder " . $preorder->id);
} }
} }
} }

View File

@@ -28,6 +28,9 @@ class ADBWohneinheit extends mfBaseModel {
if(array_key_exists("no_aftersave", $_params) && $_params["no_aftersave"]) return true; if(array_key_exists("no_aftersave", $_params) && $_params["no_aftersave"]) return true;
$this->log->debug("[".$this->_ruid."] "."-----------------------------------------");
$this->log->debug("[".$this->_ruid."] ".__METHOD__.": wohneinheit_id: ".$this->id);
// prevent potential infinite loop // prevent potential infinite loop
$nesting_level = mfValuecache::singleton()->get("adbwohneinheit-save-nesting-level-".$this->id); $nesting_level = mfValuecache::singleton()->get("adbwohneinheit-save-nesting-level-".$this->id);
if(!$nesting_level) { if(!$nesting_level) {
@@ -38,6 +41,7 @@ class ADBWohneinheit extends mfBaseModel {
mfValuecache::singleton()->set("adbwohneinheit-save-nesting-level-".$this->id, $nesting_level); mfValuecache::singleton()->set("adbwohneinheit-save-nesting-level-".$this->id, $nesting_level);
if($nesting_level > 1) { if($nesting_level > 1) {
$this->log->debug("[".$this->_ruid."] ".__METHOD__.": Preventing potential infinite loop");
return true; return true;
} }
@@ -48,8 +52,11 @@ class ADBWohneinheit extends mfBaseModel {
AddressDB::handleRimoStatusUpdate($this->id); AddressDB::handleRimoStatusUpdate($this->id);
} }
$this->refreshUnitCount(); $this->refreshUnitCount();
// reload self from database
$this->fetch($this->id);
return true;
} }
public function refreshUnitCount() { public function refreshUnitCount() {
@@ -138,7 +145,7 @@ class ADBWohneinheit extends mfBaseModel {
$me = new User(); $me = new User();
$me->loadMe(); $me->loadMe();
$this->log->info(__CLASS__." Changes: User ".$me->username." $logstr"); $this->log->info("[".$this->_ruid."] ".__CLASS__." Changes: User ".$me->username." $logstr");
return true; return true;

View File

@@ -9,13 +9,16 @@ class ADBWohneinheitStatusflagValue extends mfBaseModel {
} }
protected function afterSave($_params = []) { protected function afterSave($_params = []) {
$this->log->debug("[".$this->_ruid."] "."-----------------------------------------");
$this->log->debug("[".$this->_ruid."] ".__METHOD__.": statusflagvalue_id: ".$this->id);
if(!property_exists($this->_old_data, "value") || $this->_old_data->value != $this->data->value) { if(!property_exists($this->_old_data, "value") || $this->_old_data->value != $this->data->value) {
// cascade new status to all preorders // cascade new status to all preorders
foreach(PreorderModel::search(["adb_wohneinheit_id" => $this->wohneinheit_id]) as $preorder) { foreach(PreorderModel::search(["adb_wohneinheit_id" => $this->wohneinheit_id]) as $preorder) {
// get PreorederStatusflag // get PreorederStatusflag
$pflag = PreorderStatusflagModel::getFirst(["code" => $this->getProperty("flag")->code]); $pflag = PreorderStatusflagModel::getFirst(["code" => $this->getProperty("flag")->code]);
if(!$pflag) { if(!$pflag) {
$this->log->debug(__METHOD__ . ": Preorder statusflag " . $this->getProperty("flag")->code . " not found"); $this->log->debug("[".$this->_ruid."] ".__METHOD__ . ": Preorder statusflag " . $this->getProperty("flag")->code . " not found");
return true; return true;
} }
@@ -32,9 +35,9 @@ class ADBWohneinheitStatusflagValue extends mfBaseModel {
} }
if($new || $pflagval->value != $this->value) { if($new || $pflagval->value != $this->value) {
$pflagval->value = $this->value; $pflagval->value = $this->value;
//$this->log->debug(__METHOD__.": ".print_r($pflagval, true)); //$this->log->debug("[".$this->_ruid."] ".__METHOD__.": ".print_r($pflagval, true));
$pflagval->save(); $pflagval->save();
$this->log->debug(__METHOD__ . ": statusflag " . $this->getProperty("flag")->code . " saved for preorder " . $preorder->id); $this->log->debug("[".$this->_ruid."] ".__METHOD__ . ": statusflag " . $this->getProperty("flag")->code . " saved for preorder " . $preorder->id);
} }
} }
} }

View File

@@ -189,7 +189,6 @@ class AddressDB {
$status_matrix = array_reverse(TT_PREORDER_RIMO_STATUS_MATRIX); $status_matrix = array_reverse(TT_PREORDER_RIMO_STATUS_MATRIX);
$log->debug(__METHOD__.": b_ex_state: ".$b_ex_state); $log->debug(__METHOD__.": b_ex_state: ".$b_ex_state);
$log->debug(__METHOD__.": b_op_state: ".$b_op_state); $log->debug(__METHOD__.": b_op_state: ".$b_op_state);
$log->debug(__METHOD__.": h_ex_state: ".$h_ex_state); $log->debug(__METHOD__.": h_ex_state: ".$h_ex_state);
@@ -224,6 +223,10 @@ class AddressDB {
// seems all criteria match => set new status // seems all criteria match => set new status
$log->debug(__METHOD__.": new Preorder Status: ".$matrix["p"]); $log->debug(__METHOD__.": new Preorder Status: ".$matrix["p"]);
$log->debug(__METHOD__.": new Preorder Status flag: ".$matrix["pf"]);
$preorder = PreorderModel::getFirstActive(["adb_wohneinheit_id" => $wohneinheit->id]);
$preorder->resetSaveNesting();
if($preorder) { if($preorder) {
$preorderstatus = null; $preorderstatus = null;
@@ -234,18 +237,22 @@ class AddressDB {
if(array_key_exists("pf", $matrix) && $matrix["pf"]) { if(array_key_exists("pf", $matrix) && $matrix["pf"]) {
$preorderstatus_flag = $matrix["pf"]; $preorderstatus_flag = $matrix["pf"];
} }
if($preorderstatus) { if($preorderstatus) {
$log->debug(__METHOD__.": Setting Preorder Status to ".$preorderstatus); $log->debug(__METHOD__.": Setting Preorder Status to ".$preorderstatus);
$preorder->setNewStatusCode($preorderstatus); $preorder->setNewStatusCode($preorderstatus);
$preorder->save(); $preorder->save();
$preorder = PreorderModel::getFirstActive(["adb_wohneinheit_id" => $wohneinheit->id]);
$preorder->resetSaveNesting(); $preorder->resetSaveNesting();
} }
if($preorderstatus_flag) { if($preorderstatus_flag) {
$log->debug(__METHOD__.": Setting Preorder Status Flag ".$preorderstatus); $log->debug(__METHOD__.": Setting Preorder Status Flag ".$preorderstatus_flag);
$preorder->setNewStatusCode($preorderstatus); $preorder->setStatusFlag($preorderstatus_flag);
$preorder->save();
$preorder->resetSaveNesting(); /*
$sflag = PreorderStatusflagModel::getFirst(["code" => $preorderstatus_flag]);
$sflag->preorder_id = $preorder->id;
$log->debug(__METHOD__." Just set Preorder ".$preorder->id." status flag $preorderstatus_flag to 1. Actual value: ".$sflag->value->value);
*/
} }
} }

View File

@@ -61,6 +61,9 @@ class Preorder extends mfBaseModel {
if(array_key_exists("no_aftersave", $_params) && $_params["no_aftersave"]) return true; if(array_key_exists("no_aftersave", $_params) && $_params["no_aftersave"]) return true;
$this->log->debug("[".$this->_ruid."] "."-----------------------------------------");
$this->log->debug("[".$this->_ruid."] ".__METHOD__.": preorder_id: ".$this->id);
// prevent potential infinite loop // prevent potential infinite loop
$nesting_level = mfValuecache::singleton()->get("preorder-save-nesting-level-" . $this->id); $nesting_level = mfValuecache::singleton()->get("preorder-save-nesting-level-" . $this->id);
if(!$nesting_level) { if(!$nesting_level) {
@@ -71,7 +74,7 @@ class Preorder extends mfBaseModel {
mfValuecache::singleton()->set("preorder-save-nesting-level-" . $this->id, $nesting_level); mfValuecache::singleton()->set("preorder-save-nesting-level-" . $this->id, $nesting_level);
if($nesting_level > 1) { if($nesting_level > 1) {
$this->log->debug(__METHOD__.": (Preorder ".$this->id.") Nesting level limit reached ($nesting_level) -> aborting"); $this->log->debug("[".$this->_ruid."] ".__METHOD__.": (Preorder ".$this->id.") Nesting level limit reached ($nesting_level) -> aborting");
return true; return true;
} }
@@ -162,7 +165,7 @@ class Preorder extends mfBaseModel {
try { try {
foreach($changed as $field) { foreach($changed as $field) {
$this->log->debug(__METHOD__ . ": $field changed from '" . $this->_old_data->$field . "' to '" . $this->data->$field . "'"); $this->log->debug("[".$this->_ruid."] ".__METHOD__ . ": $field changed from '" . $this->_old_data->$field . "' to '" . $this->data->$field . "'");
$history = PreorderHistoryModel::create([ $history = PreorderHistoryModel::create([
"preorder_id" => $this->id, "preorder_id" => $this->id,
"key" => $field, "key" => $field,
@@ -173,7 +176,7 @@ class Preorder extends mfBaseModel {
$history->save(); $history->save();
} }
} catch(Exception $e) { } catch(Exception $e) {
$this->log->debug($e->getTraceAsString()); $this->log->debug("[".$this->_ruid."] ".$e->getTraceAsString());
} }
} }
@@ -181,7 +184,7 @@ class Preorder extends mfBaseModel {
if(!$this->id) return true; if(!$this->id) return true;
if(property_exists($this->_old_data, "status_id") && $this->status_id == $this->_old_data->status_id) return true; if(property_exists($this->_old_data, "status_id") && $this->status_id == $this->_old_data->status_id) return true;
$this->log->debug(__METHOD__ . " running"); $this->log->debug("[".$this->_ruid."] ".__METHOD__ . " running");
$new_status = $this->getProperty("status"); $new_status = $this->getProperty("status");
if(!property_exists($this->_old_data, "status_id")) { if(!property_exists($this->_old_data, "status_id")) {
@@ -191,12 +194,12 @@ class Preorder extends mfBaseModel {
$old_status = new Preorderstatus($this->_old_data->status_id); $old_status = new Preorderstatus($this->_old_data->status_id);
if(!$new_status->id || !$old_status->id) return true; if(!$new_status->id || !$old_status->id) return true;
$this->log->debug(__METHOD__ . " status changed from '" . ($old_status ? $old_status->code : "") . "' to '" . $new_status->code . "'"); $this->log->debug("[".$this->_ruid."] ".__METHOD__ . " status changed from '" . ($old_status ? $old_status->code : "") . "' to '" . $new_status->code . "'");
if($new_status->code <= $old_status->code) return true; if($new_status->code <= $old_status->code) return true;
if(!defined("TT_PREORDER_STATUS_MATRIX") || !TT_PREORDER_STATUS_MATRIX) { if(!defined("TT_PREORDER_STATUS_MATRIX") || !TT_PREORDER_STATUS_MATRIX) {
$this->log->error("config TT_PREORDER_STATUS_MATRIX not defined!"); $this->log->error("[".$this->_ruid."] "."config TT_PREORDER_STATUS_MATRIX not defined!");
} }
$actions = []; $actions = [];
@@ -211,7 +214,7 @@ class Preorder extends mfBaseModel {
$classname = "Preorder_Statustrigger_$code"; $classname = "Preorder_Statustrigger_$code";
$filepath = __DIR__ . "/statustrigger/$code.php"; $filepath = __DIR__ . "/statustrigger/$code.php";
$this->log->debug(__METHOD__ . ": Looking for $classname in $filepath"); $this->log->debug("[".$this->_ruid."] ".__METHOD__ . ": Looking for $classname in $filepath");
if(file_exists($filepath)) { if(file_exists($filepath)) {
require_once $filepath; require_once $filepath;
@@ -234,7 +237,7 @@ class Preorder extends mfBaseModel {
} }
}*/ }*/
} else { } else {
$this->log->debug(__METHOD__ . ": $classname not found"); $this->log->debug("[".$this->_ruid."] ".__METHOD__ . ": $classname not found");
} }
// TODO create email action if status templates configured in Campaign // TODO create email action if status templates configured in Campaign
@@ -263,7 +266,7 @@ class Preorder extends mfBaseModel {
$this->log->debug(print_r($actions, true)); $this->log->debug("[".$this->_ruid."] ".print_r($actions, true));
//var_dump($actions);exit; //var_dump($actions);exit;
// run last email action // run last email action
if(array_key_exists("email", $actions) && is_array($actions["email"]) && count($actions["email"])) { if(array_key_exists("email", $actions) && is_array($actions["email"]) && count($actions["email"])) {
@@ -285,23 +288,23 @@ class Preorder extends mfBaseModel {
$current_status_mt = PreordercampaignStatusnotificationMailtemplate::getFirst(["preordercampaign_id" => $this->preordercampaign_id, "status_code" => $new_status->code]); $current_status_mt = PreordercampaignStatusnotificationMailtemplate::getFirst(["preordercampaign_id" => $this->preordercampaign_id, "status_code" => $new_status->code]);
if($current_status_mt && $current_status_mt->prevent_previous) { if($current_status_mt && $current_status_mt->prevent_previous) {
$send_email = false; $send_email = false;
$this->log->debug(__METHOD__.": Sending disallowed by current status"); $this->log->debug("[".$this->_ruid."] ".__METHOD__.": Sending disallowed by current status");
} }
// check if email action allows sending if skipped over it // check if email action allows sending if skipped over it
if(!$email_action["allow_on_skip"]) { if(!$email_action["allow_on_skip"]) {
$send_email = false; $send_email = false;
$this->log->debug(__METHOD__.": Sending disallowed by previous status"); $this->log->debug("[".$this->_ruid."] ".__METHOD__.": Sending disallowed by previous status");
} }
} }
if($send_email) { if($send_email) {
$this->log->debug(__METHOD__.": Sending Email Action for Status ".$email_action["status_code"]); $this->log->debug("[".$this->_ruid."] ".__METHOD__.": Sending Email Action for Status ".$email_action["status_code"]);
$email_to = $this->runTriggerEmailAction($email_action); $email_to = $this->runTriggerEmailAction($email_action);
if($email_to === false) { if($email_to === false) {
$this->log->warning(__METHOD__ . ": Could not send preorder action email (Preorder " . $this->id . ")"); $this->log->warning("[".$this->_ruid."] ".__METHOD__ . ": Could not send preorder action email (Preorder " . $this->id . ")");
} elseif(is_string($email_to)) { } elseif(is_string($email_to)) {
// TODO Save history // TODO Save history
$psn_log = PreorderStatusnotificationLog::create([ $psn_log = PreorderStatusnotificationLog::create([
@@ -312,7 +315,7 @@ class Preorder extends mfBaseModel {
$psn_log->save(); $psn_log->save();
} }
} else { } else {
$this->log->warning(__METHOD__.": Not sending status (".$email_action["status_code"].") email because disallowed by current status or same or higher status email was sent already (Preorder ".$this->id.")"); $this->log->warning("[".$this->_ruid."] ".__METHOD__.": Not sending status (".$email_action["status_code"].") email because disallowed by current status or same or higher status email was sent already (Preorder ".$this->id.")");
} }
} }
@@ -337,7 +340,7 @@ class Preorder extends mfBaseModel {
} }
if(!$to) { if(!$to) {
$this->log->warning(__METHOD__.": Keine To Adresse (Preorder ".$this->id.")"); $this->log->warning("[".$this->_ruid."] ".__METHOD__.": Keine To Adresse (Preorder ".$this->id.")");
return false; return false;
} }
@@ -370,7 +373,7 @@ class Preorder extends mfBaseModel {
$mailtemplate = MailtemplateModel::getFirst(["code" => $action["template"]]); $mailtemplate = MailtemplateModel::getFirst(["code" => $action["template"]]);
if(!$mailtemplate) { if(!$mailtemplate) {
$this->log->warning(__METHOD__.": Mailtemplate nicht gefunden: ".$action["template"]." (Preorder ".$this->id.")"); $this->log->warning("[".$this->_ruid."] ".__METHOD__.": Mailtemplate nicht gefunden: ".$action["template"]." (Preorder ".$this->id.")");
return false; return false;
} }
@@ -409,15 +412,15 @@ class Preorder extends mfBaseModel {
try { try {
foreach ($mailtemplate->files as $file) { foreach ($mailtemplate->files as $file) {
if (!$file->filename || !$file->file_id || !$file->file->store_filename) continue; if (!$file->filename || !$file->file_id || !$file->file->store_filename) continue;
$this->log->debug($file->file->getFullPath()); $this->log->debug("[".$this->_ruid."] ".$file->file->getFullPath());
$email->addAttachment($file->file->getFullPath(), null, $file->filename, $file->file->mimetype ?: null); $email->addAttachment($file->file->getFullPath(), null, $file->filename, $file->file->mimetype ?: null);
} }
$email->send(); $email->send();
} catch (Exception $e) { } catch (Exception $e) {
$this->log->warning(__METHOD__.": ".$e->getMessage()); $this->log->warning("[".$this->_ruid."] ".__METHOD__.": ".$e->getMessage());
} }
$this->log->info(__METHOD__.": Sending StatusTrigger Email to $to"); $this->log->info("[".$this->_ruid."] ".__METHOD__.": Sending StatusTrigger Email to $to");
return $to; return $to;
@@ -447,7 +450,7 @@ class Preorder extends mfBaseModel {
* Cascade status changes down to adb_hausnummer and adb_wohneinheit * Cascade status changes down to adb_hausnummer and adb_wohneinheit
*/ */
public function cascadeStatus() { public function cascadeStatus() {
$this->log->debug(__METHOD__. " entered"); $this->log->debug("[".$this->_ruid."] ".__METHOD__. " entered");
/* /*
* defines status alignments of preorder status to hausnummer (h) and wohneinheit (w) * defines status alignments of preorder status to hausnummer (h) and wohneinheit (w)
* if h or w are greater than defined here, don't change them * if h or w are greater than defined here, don't change them
@@ -465,13 +468,13 @@ class Preorder extends mfBaseModel {
} }
if(!defined("TT_PREORDER_STATUS_MATRIX") || !is_array(TT_PREORDER_STATUS_MATRIX) || !count(TT_PREORDER_STATUS_MATRIX)) { if(!defined("TT_PREORDER_STATUS_MATRIX") || !is_array(TT_PREORDER_STATUS_MATRIX) || !count(TT_PREORDER_STATUS_MATRIX)) {
$this->log->warning(__METHOD__ . ": TT_PREORDER_STATUS_MATRIX undefined! Cannot cascade Preorder status to Hausnummer and Wohneinheit"); $this->log->warning("[".$this->_ruid."] ".__METHOD__ . ": TT_PREORDER_STATUS_MATRIX undefined! Cannot cascade Preorder status to Hausnummer and Wohneinheit");
return true; return true;
} }
$new_status = new Preorderstatus($this->status_id); $new_status = new Preorderstatus($this->status_id);
if(!$new_status->id) { if(!$new_status->id) {
$this->log->warning(__METHOD__ . ": Preorder has invalid status! ".print_r($this, true)); $this->log->warning("[".$this->_ruid."] ".__METHOD__ . ": Preorder has invalid status! ".print_r($this, true));
return true; return true;
} }
@@ -485,21 +488,21 @@ class Preorder extends mfBaseModel {
// set new hausnummer status // set new hausnummer status
$new_hausnummer_status = ADBStatusModel::getFirst(["code" => $cascade["h"]]); $new_hausnummer_status = ADBStatusModel::getFirst(["code" => $cascade["h"]]);
if(!$new_hausnummer_status) { if(!$new_hausnummer_status) {
$this->log->warning(__METHOD__ . ": new ADBStatus code " . $cascade["h"] . " not found!"); $this->log->warning("[".$this->_ruid."] ".__METHOD__ . ": new ADBStatus code " . $cascade["h"] . " not found!");
return true; return true;
} }
$hausnummer = new ADBHausnummer($this->adb_hausnummer_id); $hausnummer = new ADBHausnummer($this->adb_hausnummer_id);
if(!$hausnummer->id) { if(!$hausnummer->id) {
$this->log->warning(__METHOD__ . ": hausnummer " . $this->adb_hausnummer_id . " not found!"); $this->log->warning("[".$this->_ruid."] ".__METHOD__ . ": hausnummer " . $this->adb_hausnummer_id . " not found!");
return true; return true;
} }
$this->log->debug(__METHOD__ . ": new hausnummer status code " . $new_hausnummer_status->code); $this->log->debug("[".$this->_ruid."] ".__METHOD__ . ": new hausnummer status code " . $new_hausnummer_status->code);
// only update if current status is less than new status // only update if current status is less than new status
if($hausnummer->status->code < $new_hausnummer_status->code) { if($hausnummer->status->code < $new_hausnummer_status->code) {
$this->log->debug(__METHOD__ . ": Setting new hausnummer status code: " . $new_hausnummer_status->code); $this->log->debug("[".$this->_ruid."] ".__METHOD__ . ": Setting new hausnummer status code: " . $new_hausnummer_status->code);
$hausnummer->status_id = $new_hausnummer_status->id; $hausnummer->status_id = $new_hausnummer_status->id;
$hausnummer->save(); $hausnummer->save();
} }
@@ -509,17 +512,17 @@ class Preorder extends mfBaseModel {
// set new wohneinheit status // set new wohneinheit status
$new_wohneinheit_status = ADBStatusModel::getFirst(["code" => $cascade["w"]]); $new_wohneinheit_status = ADBStatusModel::getFirst(["code" => $cascade["w"]]);
if(!$new_wohneinheit_status) { if(!$new_wohneinheit_status) {
$this->log->warning(__METHOD__ . ": new ADBStatus code " . $cascade["w"] . " not found!"); $this->log->warning("[".$this->_ruid."] ".__METHOD__ . ": new ADBStatus code " . $cascade["w"] . " not found!");
return true; return true;
} }
$wohneinheit = new ADBWohneinheit($this->adb_wohneinheit_id); $wohneinheit = new ADBWohneinheit($this->adb_wohneinheit_id);
if(!$wohneinheit->id) return true; if(!$wohneinheit->id) return true;
$this->log->debug(__METHOD__ . ": new wohneinheit status code " . $new_wohneinheit_status->code); $this->log->debug("[".$this->_ruid."] ".__METHOD__ . ": new wohneinheit status code " . $new_wohneinheit_status->code);
// only update if current status is less than new status // only update if current status is less than new status
if($wohneinheit->status->code < $new_wohneinheit_status->code) { if($wohneinheit->status->code < $new_wohneinheit_status->code) {
$this->log->debug(__METHOD__ . ": Setting new wohneinheit status code: " . $new_wohneinheit_status->code); $this->log->debug("[".$this->_ruid."] ".__METHOD__ . ": Setting new wohneinheit status code: " . $new_wohneinheit_status->code);
$wohneinheit->status_id = $new_wohneinheit_status->id; $wohneinheit->status_id = $new_wohneinheit_status->id;
$wohneinheit->save(); $wohneinheit->save();
} }
@@ -532,12 +535,12 @@ class Preorder extends mfBaseModel {
if(strlen($flag->value->value) && array_key_exists($flag->code, TT_PREORDER_STATUS_MATRIX)) { if(strlen($flag->value->value) && array_key_exists($flag->code, TT_PREORDER_STATUS_MATRIX)) {
$flag_matrix_item = TT_PREORDER_STATUS_MATRIX[$flag->code]; $flag_matrix_item = TT_PREORDER_STATUS_MATRIX[$flag->code];
if(!$flag_matrix_item["flag"]) continue; if(!$flag_matrix_item["flag"]) continue;
// set hausnummer flag // set hausnummer flag
if($flag_matrix_item["h"]) { if($flag_matrix_item["h"]) {
$hflag = ADBStatusflagModel::getFirst(["code" => $flag_matrix_item["h"]]); $hflag = ADBStatusflagModel::getFirst(["code" => $flag_matrix_item["h"]]);
if(!$hflag) { if(!$hflag) {
$this->log->warn("Statusflag Code ".$flag->code." does not exist"); $this->log->warn("[".$this->_ruid."] "."Statusflag Code ".$flag->code." does not exist");
} }
$hflagval = ADBHausnummerStatusflagValueModel::getFirst(["hausnummer_id" => $this->adb_hausnummer_id, "flag_id" => $hflag->id]); $hflagval = ADBHausnummerStatusflagValueModel::getFirst(["hausnummer_id" => $this->adb_hausnummer_id, "flag_id" => $hflag->id]);
@@ -550,14 +553,14 @@ class Preorder extends mfBaseModel {
} }
$hflagval->value = $flag->value->value; $hflagval->value = $flag->value->value;
$hflagval->save(); $hflagval->save();
$this->log->debug(__METHOD__.": Hausnummer flag ".$hflag->code." value '".$hflagval->value."' gespeichert"); $this->log->debug("[".$this->_ruid."] ".__METHOD__.": Hausnummer flag ".$hflag->code." value '".$hflagval->value."' gespeichert");
} }
// set wohneiheit flag // set wohneiheit flag
if($flag_matrix_item["w"] && $this->adb_wohneinheit_id) { if($flag_matrix_item["w"] && $this->adb_wohneinheit_id) {
$wflag = ADBStatusflagModel::getFirst(["code" => $flag_matrix_item["w"]]); $wflag = ADBStatusflagModel::getFirst(["code" => $flag_matrix_item["w"]]);
if(!$wflag) { if(!$wflag) {
$this->log->warn("Statusflag Code ".$flag->code." does not exist"); $this->log->warn("[".$this->_ruid."] "."Statusflag Code ".$flag->code." does not exist");
} }
$wflagval = ADBWohneinheitStatusflagValueModel::getFirst(["wohneinheit_id" => $this->adb_wohneinheit_id, "flag_id" => $wflag->id]); $wflagval = ADBWohneinheitStatusflagValueModel::getFirst(["wohneinheit_id" => $this->adb_wohneinheit_id, "flag_id" => $wflag->id]);
@@ -570,7 +573,7 @@ class Preorder extends mfBaseModel {
} }
$wflagval->value = $flag->value->value; $wflagval->value = $flag->value->value;
$wflagval->save(); $wflagval->save();
$this->log->debug(__METHOD__.": Wohneinheit flag ".$hflag->code." gespeichert"); $this->log->debug("[".$this->_ruid."] ".__METHOD__.": Wohneinheit flag ".$hflag->code." gespeichert");
} }
} }
@@ -597,8 +600,8 @@ class Preorder extends mfBaseModel {
$tmp_s = $preorder->getProperty("status"); $tmp_s = $preorder->getProperty("status");
/*if(!$preorder->status->code || !$status->code) { /*if(!$preorder->status->code || !$status->code) {
$this->log->debug("Preorder->status->code". print_r($preorder->status, true)); $this->log->debug("[".$this->_ruid."] "."Preorder->status->code". print_r($preorder->status, true));
$this->log->debug("Status->code". print_r($status->code, true)); $this->log->debug("[".$this->_ruid."] "."Status->code". print_r($status->code, true));
}*/ }*/
if($preorder->status->code < $status->code && $status->code <= 244) { if($preorder->status->code < $status->code && $status->code <= 244) {
@@ -630,7 +633,7 @@ class Preorder extends mfBaseModel {
$pflag = PreorderStatusflagModel::getFirst(["preorder_id" => $this->id, "code" => $hflag->code]); $pflag = PreorderStatusflagModel::getFirst(["preorder_id" => $this->id, "code" => $hflag->code]);
if(!$pflag) { if(!$pflag) {
$this->log->error(__METHOD__."PreorderStatusFlag with code ".$hflag->code." not found!"); $this->log->error("[".$this->_ruid."] ".__METHOD__."PreorderStatusFlag with code ".$hflag->code." not found!");
continue; continue;
} }
$pflag_value = PreorderStatusflagValueModel::getFirst(["preorder_id" => $this->id, "flag_id" => $pflag->id]); $pflag_value = PreorderStatusflagValueModel::getFirst(["preorder_id" => $this->id, "flag_id" => $pflag->id]);
@@ -782,7 +785,7 @@ class Preorder extends mfBaseModel {
// oaid aus wohneinheit übernehmen, falls vorhanden // oaid aus wohneinheit übernehmen, falls vorhanden
$this->log->debug(__METHOD__.": Kampagne unterstützt keine OAIDs"); $this->log->debug("[".$this->_ruid."] ".__METHOD__.": Kampagne unterstützt keine OAIDs");
return true; return true;
}*/ }*/
@@ -798,7 +801,7 @@ class Preorder extends mfBaseModel {
if($campaign->oaid_origin == "thetool") { if($campaign->oaid_origin == "thetool") {
$current_oaid = OpenAccessIdModel::getFirstOaid($this->oaid); $current_oaid = OpenAccessIdModel::getFirstOaid($this->oaid);
if($current_oaid) { if($current_oaid) {
$this->log->warning("OAID of Preorder " . $this->id . " should be thetool, but is OFAA"); $this->log->warning("[".$this->_ruid."] "."OAID of Preorder " . $this->id . " should be thetool, but is OFAA");
} else { } else {
if($wohneinheit->oaid != $this->oaid) { if($wohneinheit->oaid != $this->oaid) {
$this->oaid = $wohneinheit->oaid; $this->oaid = $wohneinheit->oaid;
@@ -809,7 +812,7 @@ class Preorder extends mfBaseModel {
$current_oaid = OpenAccessIdModel::getFirstOaid($this->oaid); $current_oaid = OpenAccessIdModel::getFirstOaid($this->oaid);
//var_dump($current_oaid);exit; //var_dump($current_oaid);exit;
if(!$current_oaid) { if(!$current_oaid) {
$this->log->error("OAID of Preorder " . $this->id . " not found in OpenAccessIds"); $this->log->error("[".$this->_ruid."] "."OAID of Preorder " . $this->id . " not found in OpenAccessIds");
// assume it's from a different origin // assume it's from a different origin
} else { } else {
if($campaign->oaid_origin == $current_oaid->origin) { if($campaign->oaid_origin == $current_oaid->origin) {
@@ -831,7 +834,7 @@ class Preorder extends mfBaseModel {
if($this->type == "interest") return true; if($this->type == "interest") return true;
if(!$this->id) { if(!$this->id) {
$this->log->error(__METHOD__ . ": Tried to create OAID in unsaved Preorder"); $this->log->error("[".$this->_ruid."] ".__METHOD__ . ": Tried to create OAID in unsaved Preorder");
throw new Exception(__METHOD__ . ": Tried to create OAID in unsaved Preorder"); throw new Exception(__METHOD__ . ": Tried to create OAID in unsaved Preorder");
} }
@@ -848,12 +851,12 @@ class Preorder extends mfBaseModel {
// else create new OAID // else create new OAID
if(!$campaign->network) { if(!$campaign->network) {
$this->log->warning(__METHOD__ . ": Cannot create OAID: Invalid campaign Network"); $this->log->warning("[".$this->_ruid."] ".__METHOD__ . ": Cannot create OAID: Invalid campaign Network");
return false; return false;
} }
$netowner = new Address($campaign->network->owner_id); $netowner = new Address($campaign->network->owner_id);
if(!$netowner->id) { if(!$netowner->id) {
$this->log->warning(__METHOD__ . ": Cannot create OAID: Invalid campaign Network Owner"); $this->log->warning("[".$this->_ruid."] ".__METHOD__ . ": Cannot create OAID: Invalid campaign Network Owner");
return false; return false;
} }
@@ -871,7 +874,7 @@ class Preorder extends mfBaseModel {
$oaid->loadRandomUnassigned($oaid_attributes); $oaid->loadRandomUnassigned($oaid_attributes);
if(!$oaid->oaid) { if(!$oaid->oaid) {
$this->log->error("Keine weiteren OAIDs verfügbar"); $this->log->error("[".$this->_ruid."] "."Keine weiteren OAIDs verfügbar");
throw new Exception("Keine weiteren OAIDs verfügbar in " . $netowner->getCompanyOrName()); throw new Exception("Keine weiteren OAIDs verfügbar in " . $netowner->getCompanyOrName());
} else { } else {
// make sure this OAID is not in use on another wohneinheit by accident // make sure this OAID is not in use on another wohneinheit by accident
@@ -879,7 +882,7 @@ class Preorder extends mfBaseModel {
$oaid_unit_try = 0; $oaid_unit_try = 0;
while($oaid_unit_count) { while($oaid_unit_count) {
if($oaid_unit_try > 5) { if($oaid_unit_try > 5) {
$this->log->error(__METHOD__ . ": Can't find random OAID which is not already used in Wohneinheit by accident after 5 tries. Giving up"); $this->log->error("[".$this->_ruid."] ".__METHOD__ . ": Can't find random OAID which is not already used in Wohneinheit by accident after 5 tries. Giving up");
throw new Exception("Can't find random OAID which is not already used in Wohneinheit by accident after 5 tries. Giving up"); throw new Exception("Can't find random OAID which is not already used in Wohneinheit by accident after 5 tries. Giving up");
} }
$oaid_unit_try++; $oaid_unit_try++;
@@ -891,7 +894,7 @@ class Preorder extends mfBaseModel {
} }
if(!$oaid->oaid) { if(!$oaid->oaid) {
$this->log->error(__METHOD__ . ": Cannot generate OAID: OpenAccessId::loadRandomUnassigned() failed."); $this->log->error("[".$this->_ruid."] ".__METHOD__ . ": Cannot generate OAID: OpenAccessId::loadRandomUnassigned() failed.");
return false; return false;
} }
@@ -908,8 +911,8 @@ class Preorder extends mfBaseModel {
$oaid->unit_string = (string)$wohneinheit; $oaid->unit_string = (string)$wohneinheit;
//var_dump($oaid);exit; //var_dump($oaid);exit;
if(!$oaid->save()) { if(!$oaid->save()) {
$this->log->error("Fehler beim Speichern der OAID für Preorder " . $this->id); $this->log->error("[".$this->_ruid."] "."Fehler beim Speichern der OAID für Preorder " . $this->id);
$this->redirect("Preordercampaign", "Admin"); return false;
} }
if(!$this->save()) { if(!$this->save()) {
$oaid->assigned = 0; $oaid->assigned = 0;
@@ -957,7 +960,7 @@ class Preorder extends mfBaseModel {
} }
$wohneinheit = new ADBWohneinheit($this->adb_wohneinheit_id); $wohneinheit = new ADBWohneinheit($this->adb_wohneinheit_id);
if(!$wohneinheit->id) { if(!$wohneinheit->id) {
$this->log->error(__METHOD__.": Wohneinheit nicht gefunden (Preorder ".$this->id." ".$this->ucode." ".$this->oaid.")"); $this->log->error("[".$this->_ruid."] ".__METHOD__.": Wohneinheit nicht gefunden (Preorder ".$this->id." ".$this->ucode." ".$this->oaid.")");
return false; return false;
} }
@@ -968,7 +971,7 @@ class Preorder extends mfBaseModel {
$campaign = new Preordercampaign($this->preordercampaign_id); $campaign = new Preordercampaign($this->preordercampaign_id);
if($campaign->oaid_origin == "other") { if($campaign->oaid_origin == "other") {
$this->log->debug(__METHOD__.": Kampagne unterstützt keine OAIDs"); $this->log->debug("[".$this->_ruid."] ".__METHOD__.": Kampagne unterstützt keine OAIDs");
return false; return false;
} }
@@ -981,7 +984,7 @@ class Preorder extends mfBaseModel {
$oaid = OpenAccessIdModel::getFirstOaid($wohneinheit->oaid); $oaid = OpenAccessIdModel::getFirstOaid($wohneinheit->oaid);
if(!$oaid) { if(!$oaid) {
$this->log->warning(__METHOD__.": OAID '".$wohneinheit->oaid."' not found"); $this->log->warning("[".$this->_ruid."] ".__METHOD__.": OAID '".$wohneinheit->oaid."' not found");
return false; return false;
} }
// create and assign OAID if not yet done // create and assign OAID if not yet done
@@ -999,7 +1002,7 @@ class Preorder extends mfBaseModel {
$response = Rimoapi::createWorkorder($wohneinheit->extref, $data); $response = Rimoapi::createWorkorder($wohneinheit->extref, $data);
//var_dump($response);exit; //var_dump($response);exit;
if(!$response) { if(!$response) {
$this->log->error(__METHOD__."Cannot create RimoWorkorder! Invalid Response! (Preorder ucode: ".$this->ucode.")"); $this->log->error("[".$this->_ruid."] ".__METHOD__."Cannot create RimoWorkorder! Invalid Response! (Preorder ucode: ".$this->ucode.")");
return false; return false;
} }
@@ -1034,12 +1037,24 @@ class Preorder extends mfBaseModel {
return true; return true;
} }
public function setStatusFlag($code, $value = 1) {
if(!$code) return false;
$sflag = PreorderstatusflagModel::getFirst(["code" => $code]);
if(!$sflag) return false;
$sflag->preorder_id = $this->id;
$sflag->value->value = $value;
$sflag->value->save();
return true;
}
public function getNetowner() { public function getNetowner() {
if(!$this->id) return false; if(!$this->id) return false;
if(!$this->adb_hausnummer_id) return false; if(!$this->adb_hausnummer_id) return false;
$network = $this->getProperty("campaign")->network; $network = $this->getProperty("campaign")->network;
$this->log->debug(__METHOD__.": campaign: ".$this->getProperty("campaign")->name); $this->log->debug("[".$this->_ruid."] ".__METHOD__.": campaign: ".$this->getProperty("campaign")->name);
$this->log->debug(__METHOD__.": network: ".$network->name); $this->log->debug("[".$this->_ruid."] ".__METHOD__.": network: ".$network->name);
if(!$network) return false; if(!$network) return false;
return $network->owner; return $network->owner;
@@ -1198,7 +1213,7 @@ class Preorder extends mfBaseModel {
$fs_filename = "$filename.jpg"; $fs_filename = "$filename.jpg";
if(!file_put_contents(MFUPLOAD_FILE_SAVE_PATH."/preorder-borderpoint/$fs_filename", $image_content)) { if(!file_put_contents(MFUPLOAD_FILE_SAVE_PATH."/preorder-borderpoint/$fs_filename", $image_content)) {
$this->log->error(__METHOD__.": Error saving Borderpoint Static Map Image File"); $this->log->error("[".$this->_ruid."] ".__METHOD__.": Error saving Borderpoint Static Map Image File");
return false; return false;
} }
@@ -1212,7 +1227,7 @@ class Preorder extends mfBaseModel {
"subfolder" => "preorder-borderpoint", "subfolder" => "preorder-borderpoint",
]); ]);
if(!$file->save()) { if(!$file->save()) {
$this->log->error(__METHOD__.": Error saving File Object"); $this->log->error("[".$this->_ruid."] ".__METHOD__.": Error saving File Object");
return false; return false;
} }
@@ -1226,7 +1241,7 @@ class Preorder extends mfBaseModel {
]); ]);
if(!$pf->save()) { if(!$pf->save()) {
$this->log->error(__METHOD__.": Error saving PreorderFile Object"); $this->log->error("[".$this->_ruid."] ".__METHOD__.": Error saving PreorderFile Object");
return false; return false;
} }
@@ -1601,6 +1616,7 @@ class Preorder extends mfBaseModel {
$old_id = $this->id; $old_id = $this->id;
//$old_ucode = $this->ucode; //$old_ucode = $this->ucode;
$this->id = null; $this->id = null;
$this->_ruid = bin2hex(random_bytes(16));
$this->data = clone($this->data); $this->data = clone($this->data);
$this->_old_data = new StdClass(); $this->_old_data = new StdClass();

View File

@@ -28,11 +28,14 @@ class mfBaseModel {
protected $table = false; protected $table = false;
protected $fieldprefix = false; protected $fieldprefix = false;
protected $_ruid;
/** /**
* Takes ID or DB row as arguments * Takes ID or DB row as arguments
* @param id or table row $_ * @param id or table row $_
*/ */
public function __construct($_ = NULL, $new_db_connection = false) { public function __construct($_ = NULL, $new_db_connection = false) {
$this->_ruid = substr(hash("sha256", random_bytes(32)), 0, 8);
$this->log = mfLoghandler::singleton(); $this->log = mfLoghandler::singleton();
$this->table = get_class($this); $this->table = get_class($this);
$this->data = new stdClass(); $this->data = new stdClass();