IVT Contract Import WIP

This commit is contained in:
Frank Schubert
2023-11-02 16:05:40 +01:00
parent 90f65abd6f
commit e5f7b59ab4
14 changed files with 610 additions and 7 deletions

View File

@@ -120,7 +120,7 @@
<td colspan="2"><h4>Zusatzdaten</h4></td>
</tr><tr>
<th>RTR Code</th>
<td><?=$address->attributes['rtrcode']->value?></td>
<td><?=(is_array($address->attributes) && array_key_exists("rtrcode", $address->attributes)) ? $address->attributes['rtrcode']->value : ""?></td>
</tr>
</table>
@@ -192,7 +192,7 @@
<?php if(is_array($address->contracts) && count($address->contracts)): ?>
<ul class="list-group list-group-flush">
<?php foreach($address->contracts as $contract): ?>
<li class="list-group-item"><a href="<?=self::getUrl("Contract", "View", ["id" => $contract->id])?>"><?=$contract->product_name?> [<?=$contract->matchcode?>]</a> <span class='text-secondary'><?=($contract->finish_date) ? "Fertigstellung: ".date('d.m.Y', $contract->finish_date) : "in Herstellung"?></span></li>
<li class="list-group-item"><a href="<?=self::getUrl("Contract", "View", ["id" => $contract->id])?>"><?=$contract->product_name?> <?=($contract->matchcode) ? "[".$contract->matchcode."]" : ""?></a> <span class='text-secondary'><?=($contract->finish_date) ? "Fertigstellung: ".date('d.m.Y', $contract->finish_date) : "in Herstellung"?></span></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>

View File

@@ -45,5 +45,17 @@
</div>
</div>
<div class="row">
<div class="col-12 col-xl-10">
<h5>IVT Contract Import</h5>
<div class="card">
<div class="card-body">
<div class="row col-12">
<div><a href="<?=self::getUrl("Admin", "ivtAdminImport")?>" class="text-danger">IVT Contracts importieren</a></div>
</div>
</div>
</div>
</div>
</div>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>

View File

@@ -0,0 +1,79 @@
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css?<?= date('U') ?>" rel="stylesheet"
type="text/css"/>
<!-- start page title -->
<div class="row">
<div class="col-12">
<div class="page-title-box">
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
<li class="breadcrumb-item"><a href="<?=self::getUrl("Admin")?>">Admin</a></li>
<li class="breadcrumb-item active">IVT Contract Import</li>
</ol>
</div>
<h4 class="page-title">IVT Import</h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-lg-12">
<div class="row">
<div class="col-8">
<div class="card border-top-primary">
<div class="card-body">
<table id="datatable" class="table table-sm table-striped table-sm">
<thead>
<tr>
<th>Kunde</th>
<th>IVT Produkt</th>
<th>Produkt</th>
<th>Preis Setup</th>
<th>Preis</th>
<th>Rech. Interval</th>
<th>Aktion</th>
</tr>
</thead>
<tbody>
<?php foreach($data['contracts'] as $d): ?>
<tr>
<td><?=$d["customer"]->getCompanyOrName()?></td>
<td><?=$d["ivtproduct"]->name?></td>
<td><?=$d["product"]->name?></td>
<td><?=$d["contract"]->price_setup?></td>
<td><?=$d["contract"]->price?></td>
<td>
<?=$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" : ""?>)
</td>
<td><?=$d["action"]?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<div>
<a href="<?=self::getUrl("Admin", "ivtAdminImport", ["doit" => 1])?>"><button class="btn btn-primary" id="doitbutton"><i class="far fa-fw fa-exclamation-circle"></i> Jetzt importieren</button></a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="<?= self::getResourcePath() ?>assets/js/datatables-std.js?<?= date('U') ?>"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#doitbutton").click(function() {
$("#doitbutton").text("Bitte warten...");
$("#doitbutton").prop("disabled", true);
});
});
</script>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>

View File

@@ -139,8 +139,8 @@
<td class="text-monospace"><?=date('d.m.Y H:i', $contract->create)?><br /><?=$contract->creator->name?></td>
<td class="text-monospace"><?=date('d.m.Y H:i', $contract->edit)?><br /><?=$contract->editor->name?></td>
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
<a href="<?=self::getUrl("Contract", "view", ["contract_id" => $contract->id, "s" => $s, "filter" => $filter])?>"><i class="far fa-eyes" title="Aktives Produkt anzeigen"></i></a>
<a href="<?=self::getUrl("Contract", "edit", ["contract_id" => $contract->id, "s" => $s, "filter" => $filter])?>"><i class="far fa-edit" title="Aktives Produkt bearbeiten"></i></a>
<a href="<?=self::getUrl("Contract", "view", ["contract_id" => $contract->id])?>"><i class="far fa-eyes" title="Aktives Produkt anzeigen"></i></a>
<a href="<?=self::getUrl("Contract", "edit", ["contract_id" => $contract->id])?>"><i class="far fa-edit" title="Aktives Produkt bearbeiten"></i></a>
<?php if($contract->orderproduct_id): ?><a href="<?=self::getUrl("Order", "edit", ["id" => $contract->orderproduct->order_id])?>" target="_blank"><i class="far fa-file-signature" title="Bestellung anzeigen"></i></a><?php endif; ?>
</td>
</tr>

View File

@@ -259,6 +259,8 @@
<td style="width: 100%">
<?php if($j->value == "manual"): ?>
<em>Vertrag manuell angelegt</em>
<?php elseif($j->value == "import"): ?>
<em>Vertrag importiert: <?=nl2br(htmlentities($j->text))?>
<?php endif; ?>
</td>

View File

@@ -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) {

View File

@@ -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");
}
}
}
}

View File

@@ -0,0 +1,305 @@
<?php
class Admin_IvtAdminImport {
private $request;
public function __construct($request) {
$this->request = $request;
}
public function run($doit = false) {
echo "running...<br />\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<br />\n";
exit;
}
$productMatch = IvtProductMatchModel::getFirst(["ivt_product_id" => $ivt_contract->pid]);
if(!$productMatch) {
echo "Kein Match zu IVT Product ".$ivt_contract->pid." gefunden.<br />\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<br />\n";
$customer = $this->createAddressFromIvtCustomer($ivt_contract->customer);
if(!$customer) {
echo "Fehler beim anlegen der Adresse<br />\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."<br />\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!<br />\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.<br />\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<br />\n";
return false;
}
if(!$product->name) {
echo __METHOD__.": Keine Produkt id<br />\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."<br />\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;
}
}

View File

@@ -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'];
}

View File

@@ -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;

View File

@@ -3,6 +3,7 @@
class IvtCustomerProduct extends mfBaseModel {
protected $forcestr = [];
private $customer;
private $product;
/**
* Takes ID or DB row as arguments

View File

@@ -22,6 +22,7 @@ class IvtProduct extends mfBaseModel {
} elseif(is_object($_)) {
$this->load($_);
}
}
public function save() {

View File

@@ -0,0 +1,150 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class AddContractTables extends AbstractMigration
{
public function up(): void
{
if($this->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") {
}
}
}

View File

@@ -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) {