diff --git a/Layout/default/Address/View.php b/Layout/default/Address/View.php
index c3e8a461a..7d2384d2b 100644
--- a/Layout/default/Address/View.php
+++ b/Layout/default/Address/View.php
@@ -120,7 +120,7 @@
Zusatzdaten
RTR Code
- =$address->attributes['rtrcode']->value?>
+ =(is_array($address->attributes) && array_key_exists("rtrcode", $address->attributes)) ? $address->attributes['rtrcode']->value : ""?>
@@ -192,7 +192,7 @@
contracts) && count($address->contracts)): ?>
diff --git a/Layout/default/Admin/Index.php b/Layout/default/Admin/Index.php
index 228e56382..e5a6cca0b 100644
--- a/Layout/default/Admin/Index.php
+++ b/Layout/default/Admin/Index.php
@@ -45,5 +45,17 @@
+
+
+
IVT Contract Import
+
+
+
\ No newline at end of file
diff --git a/Layout/default/Admin/IvtAdminImport.php b/Layout/default/Admin/IvtAdminImport.php
new file mode 100644
index 000000000..1e69bbcc2
--- /dev/null
+++ b/Layout/default/Admin/IvtAdminImport.php
@@ -0,0 +1,79 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Kunde
+ IVT Produkt
+ Produkt
+ Preis Setup
+ Preis
+ Rech. Interval
+ Aktion
+
+
+
+
+
+ =$d["customer"]->getCompanyOrName()?>
+ =$d["ivtproduct"]->name?>
+ =$d["product"]->name?>
+ =$d["contract"]->price_setup?>
+ =$d["contract"]->price?>
+
+ =$d["contract"]->billing_period?> (=($d["contract"]->billing_period == 1) ? "Monatlich" : ""?>=($d["contract"]->billing_period == 12) ? "Jährlich" : ""?>=($d["contract"]->billing_period == 24) ? "Zweijährlich" : ""?>=($d["contract"]->billing_period == 36) ? "Dreijährlich" : ""?>)
+
+ =$d["action"]?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Layout/default/Contract/Index.php b/Layout/default/Contract/Index.php
index f7140565e..70f7aeba2 100644
--- a/Layout/default/Contract/Index.php
+++ b/Layout/default/Contract/Index.php
@@ -139,8 +139,8 @@
=date('d.m.Y H:i', $contract->create)?> =$contract->creator->name?>
=date('d.m.Y H:i', $contract->edit)?> =$contract->editor->name?>
- $contract->id, "s" => $s, "filter" => $filter])?>">
- $contract->id, "s" => $s, "filter" => $filter])?>">
+ $contract->id])?>">
+ $contract->id])?>">
orderproduct_id): ?> $contract->orderproduct->order_id])?>" target="_blank">
diff --git a/Layout/default/Contract/View.php b/Layout/default/Contract/View.php
index 5cbba2c05..f3039d68b 100644
--- a/Layout/default/Contract/View.php
+++ b/Layout/default/Contract/View.php
@@ -259,6 +259,8 @@
value == "manual"): ?>
Vertrag manuell angelegt
+ value == "import"): ?>
+ Vertrag importiert: =nl2br(htmlentities($j->text))?>
diff --git a/application/Address/AddressModel.php b/application/Address/AddressModel.php
index aba807353..1792778a5 100644
--- a/application/Address/AddressModel.php
+++ b/application/Address/AddressModel.php
@@ -312,7 +312,7 @@ class AddressModel {
/*
* Address Type
*/
- if(is_array($filter['addresstype']) && count($filter['addresstype'])) {
+ if(array_key_exists("addresstype", $filter) && is_array($filter['addresstype']) && count($filter['addresstype'])) {
$at = $filter['addresstype'];
$in = [];
foreach(TT_ROLES as $role) {
diff --git a/application/Admin/AdminController.php b/application/Admin/AdminController.php
index 62cf71e1b..310515260 100644
--- a/application/Admin/AdminController.php
+++ b/application/Admin/AdminController.php
@@ -150,4 +150,27 @@ class AdminController extends mfBaseController {
$this->layout()->set("products", $products);
}
+ protected function ivtAdminImportAction() {
+ exit;
+ $doit = false;
+ if($this->request->doit == 1) {
+ $doit = true;
+ }
+
+ require_once(realpath(dirname(__FILE__)."/functions")."/IvtAdminImport.php");
+
+ if(class_exists("Admin_IvtAdminImport")) {
+ $import = new Admin_IvtAdminImport($this->request);
+ $data = $import->run($doit);
+
+ $this->layout()->setTemplate("Admin/IvtAdminImport");
+ $this->layout()->set("data", $data);
+
+ if($doit) {
+ $this->layout()->setFlash((count($data['contracts']) - $data['ignore'])." Contracts aus IVT importiert!", "success");
+ }
+
+ }
+ }
+
}
\ No newline at end of file
diff --git a/application/Admin/functions/IvtAdminImport.php b/application/Admin/functions/IvtAdminImport.php
new file mode 100644
index 000000000..217ef5c20
--- /dev/null
+++ b/application/Admin/functions/IvtAdminImport.php
@@ -0,0 +1,305 @@
+request = $request;
+ }
+
+ public function run($doit = false) {
+ echo "running... \n";
+ $data = [];
+ $data['ignore'] = 0;
+ $data["contracts"] = [];
+ foreach(IvtCustomerProductModel::search(["pid" => 784]) as $ivt_contract) {
+ $ivt_customer = $ivt_contract->customer;
+ $ivt_product = $ivt_contract->product;
+
+ if(!$this->checkIvtCustomer($ivt_customer)) {
+ echo "IVT Customer ".$ivt_contract->cid." nicht im tool \n";
+ exit;
+ }
+
+ $productMatch = IvtProductMatchModel::getFirst(["ivt_product_id" => $ivt_contract->pid]);
+ if(!$productMatch) {
+ echo "Kein Match zu IVT Product ".$ivt_contract->pid." gefunden. \n";
+ exit;
+ }
+
+
+ if(!$this->checkIvtProduct($productMatch->ivtproduct)) {
+ exit;
+ }
+
+ $customer = AddressModel::getFirst(["customer_number" => $ivt_contract->cid]);
+ $ip = $productMatch->ivtproduct;
+ $product = $productMatch->product;
+
+ if(!$customer->id) {
+ echo "Kein thetool Kunde zu IVT customer ".$ivt_contract->cid." gefunden -> wird angelegt \n";
+ $customer = $this->createAddressFromIvtCustomer($ivt_contract->customer);
+ if(!$customer) {
+ echo "Fehler beim anlegen der Adresse \n";
+ exit;
+ }
+ }
+ /*
+ // check if contract was imported already
+ $existing_contract = ContractModel::getFirst(["imported_from" => "ivt", "imported_data" => $ivt_contract->id]);
+ if($existing_contract) {
+ //echo "Contract gibts schon ".$existing_contract->id." \n";
+ continue;
+ }
+ */
+
+
+ $contract_data = [];
+ $contract_data['owner_id'] = $customer->id;
+ //$contract_data['billingaddress_id'] = $customer->id;
+ $contract_data['product_id'] = $product->id;
+ $contract_data['product_name'] = $ip->name;
+ $contract_data['matchcode'] = "";
+ $contract_data['amount'] = 1;
+ $contract_data['price'] = $ip->price;
+ $contract_data['price_setup'] = 0;
+ $contract_data['finish_date'] = mktime(2,0,0,date("m"),1,date("Y"));
+ $contract_data['finish_date_by'] = 1;
+ $contract_data['imported_from'] = "ivt";
+ $contract_data['imported_data'] = $ivt_contract->id;
+
+ switch($ip->interval) {
+ case 0:
+ $contract_data['billing_period'] = 1;
+ break;
+ case 1:
+ $contract_data['billing_period'] = 12;
+ break;
+ }
+
+
+ $neu["customer"] = $customer;
+ $neu["ivtproduct"] = $ip;
+ $neu["product"] = $product;
+ $neu['action'] = "import";
+ $ignore = false;
+
+ if($product->price <= 0) {
+ $contract_data['price'] = 0;
+ $contract_data['price_setup'] = $ip->price;
+ $contract_data['billing_period'] = 0;
+ $neu['action'] = "ignore";
+ $ignore = true;
+ }
+
+ $contract = ContractModel::create($contract_data);
+ $neu["contract"] = $contract;
+
+ if($doit && !$ignore) {
+ $contract_id = $contract->save();
+ if(!$contract_id) {
+ echo "Fehler beim Contract speichern! \n";
+ exit;
+ }
+
+ // create journal entry
+ $journal = ContractjournalModel::create([
+ 'contract_id' => $contract_id,
+ 'type' => "created_from",
+ 'value' => "import",
+ 'text' => "IVT"
+ ]);
+ $journal_id = $journal->save();
+ if(!$journal_id) {
+ echo "Fehler beim Journal erstellen. \n";
+ exit;
+ }
+
+ // import Contractconfig
+ $this->importContractconfig($ivt_customer, $ivt_product, $contract);
+
+
+ }
+
+ $data["contracts"][] = $neu;
+ if($neu['action'] == "ignore") {
+ $data['ignore']++;
+ }
+ }
+ return $data;
+ }
+
+ private function checkIvtCustomer($customer) {
+ // create customer if not exists
+ $old_custnum = $customer->id;
+ if(!$old_custnum) return false;
+
+ // TODO: sync bank data
+
+ return true;
+ }
+
+ private function checkIvtProduct($product) {
+ if(!$product->id) {
+ echo __METHOD__.": Keine Produkt id \n";
+ return false;
+ }
+ if(!$product->name) {
+ echo __METHOD__.": Keine Produkt id \n";
+ return false;
+ }
+ return true;
+ }
+
+ private function importContractconfig($ivt_customer, $ivt_product, $contract) {
+ var_dump($contract, $contract->product, $contract->configgroups);
+
+
+ if(!is_array($contract->configgroups) || !count($contract->configgroups)) {
+ return true;
+ }
+
+ $product = $contract->product;
+ if(!$product->id) {
+ echo "Produkt nicht gefunden für Contract ".$contract->id." \n";
+ exit;
+ }
+
+ // lookup radius data
+ $radius_data = $this->getRadiusUser($ivt_customer, $ivt_product, $contract);
+ // lookup voip data
+ $voip_data = $this->getVoipData($ivt_customer, $ivt_product, $contract);
+
+ foreach($contract->configgroups as $cgroup) {
+
+ $items = $cgroup->items;
+ var_dump($cgroup);
+ var_dump($items);
+
+ foreach($items as $i) {
+ switch($i->name) {
+ case "bandwidth_down":
+ $i->value->set($product->attributes["bw_down"]->value);
+ $i->value->save();
+ break;
+ case "bandwidth_up":
+ $i->value->set($product->attributes["bw_up"]->value);
+ $i->value->save();
+ break;
+
+ case "radiususer_username":
+ $i->value->set($radius_data["username"]);
+ $i->value->sav();
+ break;
+ case "radiususer_password":
+ $i->value->set($radius_data["username"]);
+ $i->value->sav();
+ break;
+ case "radiususer_ipaddress":
+ $i->value->set($radius_data["ipaddress"]);
+ $i->value->sav();
+ break;
+ case "radiususer_ipprefix":
+ $i->value->set($radius_data["subnetmask"]);
+ $i->value->sav();
+ break;
+
+
+ }
+ }
+
+
+ }
+ exit;
+
+ /*
+ * backbone (vlan)
+ * Radiususer
+ * Bandbreite
+ * IPv4
+ * SIP daten
+ * Voip
+ * Rufnummer
+ * Webhosting
+ *
+ */
+ }
+
+ private function getRadiusUser($ivt_customer, $ivt_product, $contract) {
+ // find radius user
+
+ // return data
+ }
+
+ private function getVoipData($ivt_customer, $ivt_product, $contract) {
+
+ }
+
+ private function createAddressFromIvtCustomer(IvtCustomer $cust) {
+ $address_data['customer_number'] = $cust->id;
+ $address_data['spin'] = $cust->MandatID;
+ $address_data['company'] = $cust->company;
+ $address_data['firstname'] = $cust->firstname;
+ $address_data['lastname'] = $cust->surname;
+
+ if($cust->company && !$cust->firstname && $cust->company == $cust->surname) {
+ $address_data["firstname"] = "";
+ $address_data["lastname"] = "";
+ }
+
+ $address_data['street'] = $cust->street;
+ if(strlen($cust->housenumber)) {
+ $address_data['street'] .= " ".$cust->housenumber;
+ }
+ $address_data['zip'] = $cust->zip;
+ $address_data['city'] = $cust->location;
+ $address_data['country'] = "";
+ $address_data['phone'] = $cust->phone;
+ $address_data['fax'] = "";
+ $address_data['mobile'] = "";
+ $address_data['email'] = $cust->email;
+ $address_data['note'] = $cust->extrainfo;
+
+ $address_data['uid'] = ($cust->UID) ? $cust->UID : null;
+ $address_data["bank_account_bank"] = "";
+ $address_data["bank_account_owner"] = ($cust->company) ? $cust->company : $cust->firstname . " " . $cust->surname;
+ $address_data["bank_account_iban"] = $cust->IBAN;
+ $address_data["bank_account_bic"] = $cust->BIC;
+
+ if($cust->payment == 0 ) { // 0 = sepa / 1 = rechnung
+ $address_data['billing_type'] = "sepa";
+ } else {
+ $address_data['billing_type'] = "invoice";
+ }
+
+ if($cust->paper_invoice == 1) {
+ $address_data["billing_delivery"] = "paper";
+ } else {
+ $address_data["billing_delivery"] = "email";
+ }
+
+ if($cust->accept_adver == 2) {
+ $address_data["allow_contact"] = 1;
+ } else {
+ $address_data["allow_contact"] = 0;
+ }
+
+ if($cust->accept_info == 2) {
+ $address_data["allow_spin"] = 1;
+ } else {
+ $address_data["allow_spin"] = 0;
+ }
+
+ $address_data['create_by'] = 1;
+ $address_data['edit_by'] = 1;
+
+ $address = AddressModel::create($address_data);
+
+ if(!$address->save()) {
+ var_dump($address);
+ return false;
+ }
+ return $address;
+ }
+}
+
diff --git a/application/Contract/ContractModel.php b/application/Contract/ContractModel.php
index 26deea5c6..b8b67a4a9 100644
--- a/application/Contract/ContractModel.php
+++ b/application/Contract/ContractModel.php
@@ -24,6 +24,8 @@ class ContractModel {
public $finish_date_by;
public $cancel_date;
public $cancel_date_by;
+ public $imported_from;
+ public $imported_data;
public $note = null;
public $create_by = null;
@@ -152,13 +154,18 @@ class ContractModel {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
- $sql = "SELECT COUNT(*) as cnt FROM Contract
+ $sql = "SELECT COUNT(*) as cnt FROM (
+ SELECT Contract.* FROM Contract
LEFT JOIN Address ON (Contract.owner_id = Address.id)
LEFT JOIN OrderProduct ON (Contract.orderproduct_id = OrderProduct.id)
LEFT JOIN `Order` ON (OrderProduct.order_id = `Order`.id)
LEFT JOIN Product ON (Contract.product_id = Product.id)
WHERE $where
- GROUP BY Contract.id";
+ AND (cancel_date IS NULL OR cancel_date > UNIX_TIMESTAMP())
+ GROUP BY Contract.id
+ ) contract";
+
+ mfLoghandler::singleton()->debug($sql);
$res = $db->query($sql);
if($db->num_rows($res)) {
@@ -317,6 +324,20 @@ class ContractModel {
}
}
+ if(array_key_exists("imported_from", $filter)) {
+ $imported_from = FronkDB::singleton()->escape($filter["imported_from"]);
+ if($imported_from) {
+ $where .= " AND Contract.imported_from like '$imported_from'";
+ }
+ }
+
+ if(array_key_exists("imported_data", $filter)) {
+ $imported_data = FronkDB::singleton()->escape($filter["imported_data"]);
+ if($imported_data) {
+ $where .= " AND Contract.imported_data like '$imported_data'";
+ }
+ }
+
if(array_key_exists("add-where", $filter)) {
$where .= " ".$filter['add-where'];
}
diff --git a/application/ContractconfigItem/ContractconfigItem.php b/application/ContractconfigItem/ContractconfigItem.php
index 8edc2611d..a43ea5613 100644
--- a/application/ContractconfigItem/ContractconfigItem.php
+++ b/application/ContractconfigItem/ContractconfigItem.php
@@ -58,6 +58,7 @@ class ContractconfigItem extends mfBaseModel {
$value->item_id = $this->id;
$value->contract_id = $this->contract_id;
$value->create_by = $me->id;
+ $value->edit_by = $me->id;
}
//var_dump($value);exit;
$this->value = $value;
diff --git a/application/IvtCustomerProduct/IvtCustomerProduct.php b/application/IvtCustomerProduct/IvtCustomerProduct.php
index 21686c6f6..592f7b431 100644
--- a/application/IvtCustomerProduct/IvtCustomerProduct.php
+++ b/application/IvtCustomerProduct/IvtCustomerProduct.php
@@ -3,6 +3,7 @@
class IvtCustomerProduct extends mfBaseModel {
protected $forcestr = [];
private $customer;
+ private $product;
/**
* Takes ID or DB row as arguments
diff --git a/application/IvtProduct/IvtProduct.php b/application/IvtProduct/IvtProduct.php
index d35950912..f522fdc47 100644
--- a/application/IvtProduct/IvtProduct.php
+++ b/application/IvtProduct/IvtProduct.php
@@ -22,6 +22,7 @@ class IvtProduct extends mfBaseModel {
} elseif(is_object($_)) {
$this->load($_);
}
+
}
public function save() {
diff --git a/db/migrations/20231031135229_add_contract_tables.php b/db/migrations/20231031135229_add_contract_tables.php
new file mode 100644
index 000000000..b11c97e3a
--- /dev/null
+++ b/db/migrations/20231031135229_add_contract_tables.php
@@ -0,0 +1,150 @@
+getEnvironment() == "thetool") {
+
+ $contract = $this->table("Contract");
+ $contract->addColumn("orderproduct_id", "integer", ["null" => true, "default" => null]);
+ $contract->addColumn("owner_id", "integer", ["null" => false]);
+ $contract->addColumn("billingaddress_id", "integer", ["null" => true, "default" => null]);
+ $contract->addColumn("termination_id", "integer", ["null" => true, "default" => null]);
+ $contract->addColumn("product_id", "integer", ["null" => true, "default" => null]);
+ $contract->addColumn("product_name", "string", ["null" => false, "limit" => 255]);
+ $contract->addColumn("product_info", "text", ["null" => true, "default" => null]);
+ $contract->addColumn("matchcode", "string", ["null" => true, "default" => null, "limit" => 255]);
+ $contract->addColumn("amount", "decimal", ["null" => false, "precision" => 9, "scale" => 6]);
+ $contract->addColumn("sla_id", "integer", ["null" => true, "default" => null]);
+ $contract->addColumn("product_external", "integer", ["null" => false, "default" => 0, "limit" => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY]);
+ $contract->addColumn("product_external_id", "integer", ["null" => true, "default" => null]);
+ $contract->addColumn("price", "decimal", ["null" => false, "precision" => 14, "scale" => 4]);
+ $contract->addColumn("price_setup", "decimal", ["null" => false, "precision" => 14, "scale" => 4]);
+ $contract->addColumn("price_nne", "decimal", ["null" => false, "default" => null, "precision" => 14, "scale" => 4]);
+ $contract->addColumn("price_nbe", "decimal", ["null" => false, "default" => null, "precision" => 14, "scale" => 4]);
+ $contract->addColumn("billing_delay", "integer", ["null" => false, "default" => 0]);
+ $contract->addColumn("billing_period", "integer", ["null" => false, "default" => 1]);
+ $contract->addColumn("order_date", "integer", ["null" => true, "default" => null]);
+ $contract->addColumn("finish_date", "integer", ["null" => true, "default" => null]);
+ $contract->addColumn("finish_date_by", "integer", ["null" => true, "default" => null]);
+ $contract->addColumn("cancel_date", "integer", ["null" => true, "default" => null]);
+ $contract->addColumn("cancel_date_by", "integer", ["null" => true, "default" => null]);
+ $contract->addColumn("imported_from", "string", ["null" => true, "default" => null, "limit" => 255]);
+ $contract->addColumn("imported_data", "string", ["null" => true, "default" => null, "limit" => 255]);
+ $contract->addColumn("note", "text", ["null" => true, "default" => null]);
+ $contract->addColumn("create_by", "integer", ["null" => false]);
+ $contract->addColumn("edit_by", "integer", ["null" => false]);
+ $contract->addColumn("create", "integer", ["null" => false]);
+ $contract->addColumn("edit", "integer", ["null" => false]);
+ $contract->create();
+
+ $ccg = $this->table("Contractconfiggroup");
+ $ccg->addColumn("name", "string", ["null" => false, "limit" => 255]);
+ $ccg->addColumn("create_by", "integer", ["null" => false]);
+ $ccg->addColumn("edit_by", "integer", ["null" => false]);
+ $ccg->addColumn("create", "integer", ["null" => false]);
+ $ccg->addColumn("edit", "integer", ["null" => false]);
+ $ccg->create();
+
+ $ccgp = $this->table("ContractconfiggroupProductgroup");
+ $ccgp->addColumn("productgroup_id", "integer", ["null" => false]);
+ $ccgp->addColumn("contractconfiggroup_id", "integer", ["null" => false]);
+ $ccgp->addColumn("create_by", "integer", ["null" => false]);
+ $ccgp->addColumn("edit_by", "integer", ["null" => false]);
+ $ccgp->addColumn("create", "integer", ["null" => false]);
+ $ccgp->addColumn("edit", "integer", ["null" => false]);
+ $ccgp->create();
+
+ $cci = $this->table("ContractconfigItem");
+ $cci->addColumn("order", "integer", ["null" => true, "default" => null]);
+ $cci->addColumn("contractconfiggroup_id", "integer", ["null" => false]);
+ $cci->addColumn("type", "string", ["null" => false, "limit" => 255]);
+ $cci->addColumn("multiple", "integer", ["null" => false, "default" => 0, "limit" => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY]);
+ $cci->addColumn("name", "string", ["null" => false, "limit" => 255]);
+ $cci->addColumn("displayname", "string", ["null" => true, "default" => null, "limit" => 255]);
+ $cci->addColumn("description", "text", ["null" => true, "default" => null]);
+ $cci->addColumn("typedata", "text", ["null" => true, "default" => null]);
+ $cci->addColumn("pattern", "string", ["null" => true, "limit" => 255]);
+ $cci->addColumn("create_by", "integer", ["null" => false]);
+ $cci->addColumn("edit_by", "integer", ["null" => false]);
+ $cci->addColumn("create", "integer", ["null" => false]);
+ $cci->addColumn("edit", "integer", ["null" => false]);
+ $cci->create();
+
+ $ccv = $this->table("ContractconfigValue");
+ $ccv->addColumn("contract_id", "integer", ["null" => false]);
+ $ccv->addColumn("item_id", "integer", ["null" => false]);
+ $ccv->addColumn("string", "string", ["null" => true, "default" => null]);
+ $ccv->addColumn("int", "integer", ["null" => true, "default" => null]);
+ $ccv->addColumn("number", "decimal", ["null" => true, "default" => null]);
+ $ccv->addColumn("json", "json", ["null" => true, "default" => null]);
+ $ccv->addColumn("create_by", "integer", ["null" => false]);
+ $ccv->addColumn("edit_by", "integer", ["null" => false]);
+ $ccv->addColumn("create", "integer", ["null" => false]);
+ $ccv->addColumn("edit", "integer", ["null" => false]);
+ $ccv->create();
+
+ $cf = $this->table("ContractFile");
+ $cf->addColumn("contract_id", "integer", ["null" => false]);
+ $cf->addColumn("file_id", "integer", ["null" => false]);
+ $cf->addColumn("name", "string", ["null" => false, "limit" => 255]);
+ $cf->addColumn("description", "text", ["null" => true, "default" => null]);
+ $cf->addColumn("create_by", "integer", ["null" => false]);
+ $cf->addColumn("edit_by", "integer", ["null" => false]);
+ $cf->addColumn("create", "integer", ["null" => false]);
+ $cf->addColumn("edit", "integer", ["null" => false]);
+ $cf->create();
+
+ $cj = $this->table("Contractjournal");
+ $cj->addColumn("contract_id", "integer", ["null" => false]);
+ $cj->addColumn("type", "string", ["null" => false, "limit" => 64]);
+ $cj->addColumn("string", "string", ["null" => true, "default" => null, "limit" => 64]);
+ $cj->addColumn("text", "text", ["null" => true, "default" => null]);
+ $cj->addColumn("create_by", "integer", ["null" => false]);
+ $cj->addColumn("edit_by", "integer", ["null" => false]);
+ $cj->addColumn("create", "integer", ["null" => false]);
+ $cj->addColumn("edit", "integer", ["null" => false]);
+ $cj->create();
+
+ $cl = $this->table("ContractLink");
+ $cl->addColumn("contract_id", "integer", ["null" => false]);
+ $cl->addColumn("origin_contract_id", "integer", ["null" => false]);
+ $cl->addColumn("type", "enum", ["null" => false, "values" => "link,upgrade,downgrade,relocation,productchange"]);
+ $cl->addColumn("change_action", "enum", ["null" => true, "default" => null, "values" => "keep,cancel"]);
+ $cl->addColumn("create_by", "integer", ["null" => false]);
+ $cl->addColumn("edit_by", "integer", ["null" => false]);
+ $cl->addColumn("create", "integer", ["null" => false]);
+ $cl->addColumn("edit", "integer", ["null" => false]);
+ $cl->create();
+
+ }
+
+ if($this->getEnvironment() == "addressdb") {
+
+ }
+ }
+
+ public function down(): void
+ {
+ if($this->getEnvironment() == "thetool") {
+ /*
+ $this->table("ContractLink")->drop()->save();
+ $this->table("Contractjournal")->drop()->save();
+ $this->table("ContractFile")->drop()->save();
+ $this->table("ContractconfigValue")->drop()->save();
+ $this->table("ContractconfigItem")->drop()->save();
+ $this->table("ContractconfiggroupProductgroup")->drop()->save();
+ $this->table("Contractconfiggroup")->drop()->save();
+ $this->table("Contract")->drop()->save();
+ */
+ }
+
+ if($this->getEnvironment() == "addressdb") {
+
+ }
+ }
+}
diff --git a/lib/mvcfronk/mfBase/mfBaseModel.php b/lib/mvcfronk/mfBase/mfBaseModel.php
index 9b118177b..8fda47f5e 100644
--- a/lib/mvcfronk/mfBase/mfBaseModel.php
+++ b/lib/mvcfronk/mfBase/mfBaseModel.php
@@ -77,6 +77,14 @@ class mfBaseModel {
}
$this->id=$row->id;
+
+ if(!property_exists($row, "create")) {
+ $row->create = date("U");
+ }
+ if(!property_exists($row, "edit")) {
+ $row->edit = date("U");
+ }
+
$this->create=$row->create;
$this->edit=$row->edit;
if($this->fieldprefix) {