auto generate fibu_num for billingaddresses
This commit is contained in:
@@ -176,8 +176,8 @@
|
|||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
<?php foreach(TT_ADDRESS_LINK_TYPES as $type): ?>
|
<?php foreach(TT_ADDRESS_LINK_TYPES as $type): ?>
|
||||||
<?php if(array_key_exists($type, $address->links)): ?>
|
<?php if(is_array($address->links_to) && array_key_exists($type, $address->links_to)): ?>
|
||||||
<?php foreach($address->links[$type] as $link): ?>
|
<?php foreach($address->links_to[$type] as $link): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="font-weight-bold"><?=__($type)?></td>
|
<td class="font-weight-bold"><?=__($type)?></td>
|
||||||
<td><a href="<?=self::getUrl("Address", "view", ["id" => $link->address_id])?>"><?=$link->address->company?></a></td>
|
<td><a href="<?=self::getUrl("Address", "view", ["id" => $link->address_id])?>"><?=$link->address->company?></a></td>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class Address extends mfBaseModel {
|
|||||||
private $childaddresses;
|
private $childaddresses;
|
||||||
private $links = [];
|
private $links = [];
|
||||||
private $linked_as = [];
|
private $linked_as = [];
|
||||||
|
private $links_to = [];
|
||||||
private $types;
|
private $types;
|
||||||
private $attributes;
|
private $attributes;
|
||||||
private $permissions;
|
private $permissions;
|
||||||
@@ -29,11 +30,30 @@ class Address extends mfBaseModel {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function generateFibuAccountNumber() {
|
public function generateFibuAccountNumber() {
|
||||||
if($this->fibu_account_number || !$this->customer_number) {
|
if($this->fibu_account_number) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$create_fibu_num = false;
|
||||||
|
|
||||||
|
if($this->customer_number) {
|
||||||
|
$create_fibu_num = true;
|
||||||
|
} else {
|
||||||
|
// check if we are billingaddress
|
||||||
|
if(ContractModel::getFirst(["billingaddress_id" => $this->id])) {
|
||||||
|
$create_fibu_num = true;
|
||||||
|
} elseif(OrderModel::getFirst(["billingaddress_id" => $this->id])) {
|
||||||
|
$create_fibu_num = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$create_fibu_num) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$fibu_account_number = Address::getNextFibuAccountNumber();
|
$fibu_account_number = Address::getNextFibuAccountNumber();
|
||||||
if(!$fibu_account_number) {
|
if(!$fibu_account_number) {
|
||||||
return false;
|
return false;
|
||||||
@@ -615,7 +635,18 @@ class Address extends mfBaseModel {
|
|||||||
}
|
}
|
||||||
return $this->linked_as;
|
return $this->linked_as;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($name == "links_to") {
|
||||||
|
$links_to = AddressLinkModel::search(['origin_address_id' => $this->id]);
|
||||||
|
foreach($links_to as $link) {
|
||||||
|
if(!array_key_exists($link->type, $this->links_to)) {
|
||||||
|
$this->links_to[$link->type] = [];
|
||||||
|
}
|
||||||
|
$this->links_to[$link->type][] = $link;
|
||||||
|
//var_dump($this->links);exit;
|
||||||
|
}
|
||||||
|
return $this->links_to;
|
||||||
|
}
|
||||||
|
|
||||||
$classname = ucfirst($name);
|
$classname = ucfirst($name);
|
||||||
$idfield = $name."_id";
|
$idfield = $name."_id";
|
||||||
|
|||||||
@@ -132,6 +132,8 @@ class AddressController extends mfBaseController {
|
|||||||
|
|
||||||
$address = new Address($this->request->id);
|
$address = new Address($this->request->id);
|
||||||
$this->layout()->set("address", $address);
|
$this->layout()->set("address", $address);
|
||||||
|
|
||||||
|
//var_dump($address->links_to);exit;
|
||||||
|
|
||||||
if(!$address->id) {
|
if(!$address->id) {
|
||||||
$this->layout()->setFlash("Addresse nicht gefunden", "error");
|
$this->layout()->setFlash("Addresse nicht gefunden", "error");
|
||||||
|
|||||||
@@ -94,6 +94,13 @@ class BillingController extends mfBaseController {
|
|||||||
protected function importContractsAction() {
|
protected function importContractsAction() {
|
||||||
$r = $this->request;
|
$r = $this->request;
|
||||||
|
|
||||||
|
$last_run_ts = new mfConfig("voicecallhistory.contact-job.ts");
|
||||||
|
if($last_run_ts->value() < date("U") - 43200) {
|
||||||
|
$this->layout()->setFlash("Voicecall History Contract Job ist heute noch nicht gelaufen", "error");
|
||||||
|
$this->redirect("Billing");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$v = 0;
|
$v = 0;
|
||||||
|
|
||||||
@@ -114,6 +121,9 @@ class BillingController extends mfBaseController {
|
|||||||
$del = 0;
|
$del = 0;
|
||||||
// first delete all non-invoiced billing records
|
// first delete all non-invoiced billing records
|
||||||
foreach(BillingModel::search(["invoice_id" => null]) as $bill) {
|
foreach(BillingModel::search(["invoice_id" => null]) as $bill) {
|
||||||
|
foreach(BillingVoicenumberModel::search(["billing_id" => $bill->id]) as $billingVoicenumber) {
|
||||||
|
$billingVoicenumber->delete();
|
||||||
|
}
|
||||||
$bill->delete();
|
$bill->delete();
|
||||||
$del++;
|
$del++;
|
||||||
}
|
}
|
||||||
@@ -367,7 +377,7 @@ class BillingController extends mfBaseController {
|
|||||||
$data["owner_id"] = $contract->owner_id;
|
$data["owner_id"] = $contract->owner_id;
|
||||||
$data["billingaddress_id"] = ($contract->billingaddress_id) ? $contract->billingaddress_id : $contract->owner_id;
|
$data["billingaddress_id"] = ($contract->billingaddress_id) ? $contract->billingaddress_id : $contract->owner_id;
|
||||||
$data["customer_number"] = $contract->owner->customer_number;
|
$data["customer_number"] = $contract->owner->customer_number;
|
||||||
$data["fibu_account_number"] = $contract->owner->fibu_account_number;
|
$data["fibu_account_number"] = $contract->owner->fibu_account_number; // TODO: fibu_account_number von billingaddress
|
||||||
$data["company"] = $billingaddress->company;
|
$data["company"] = $billingaddress->company;
|
||||||
$data["firstname"] = $billingaddress->firstname;
|
$data["firstname"] = $billingaddress->firstname;
|
||||||
$data["lastname"] = $billingaddress->lastname;
|
$data["lastname"] = $billingaddress->lastname;
|
||||||
|
|||||||
@@ -34,7 +34,14 @@ class Contract extends mfBaseModel {
|
|||||||
private $canceler;
|
private $canceler;
|
||||||
private $creator;
|
private $creator;
|
||||||
private $editor;
|
private $editor;
|
||||||
|
|
||||||
|
|
||||||
|
protected function afterSave() {
|
||||||
|
if($this->billingaddress_id) {
|
||||||
|
$this->getProperty("billingaddress")->generateFibuAccountNumber();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private function getLinks() {
|
private function getLinks() {
|
||||||
$this->linkFrom = [];
|
$this->linkFrom = [];
|
||||||
|
|||||||
@@ -15,7 +15,13 @@ class Order extends mfBaseModel {
|
|||||||
private $editor;
|
private $editor;
|
||||||
|
|
||||||
private $shippingdate;
|
private $shippingdate;
|
||||||
|
|
||||||
|
protected function afterSave() {
|
||||||
|
if($this->billingaddress_id) {
|
||||||
|
$this->getProperty("billingaddress")->generateFibuAccountNumber();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function getNewPos() {
|
public function getNewPos() {
|
||||||
if(!$this->id) {
|
if(!$this->id) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
//require 'vendor/autoload.php';
|
||||||
|
require("../../config/config.php");
|
||||||
|
|
||||||
|
define('FRONKDB_SQLDEBUG',false);
|
||||||
|
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
|
||||||
|
|
||||||
|
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
|
||||||
|
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
|
||||||
|
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
|
||||||
|
|
||||||
|
$me = new User(1);
|
||||||
|
|
||||||
|
foreach(ContractModel::searchActive([]) as $contract) {
|
||||||
|
if($contract->billingaddress_id) {
|
||||||
|
$contract->billingaddress->generateFibuAccountNumber();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach(OrderModel::getAll() as $order) {
|
||||||
|
if($order->billingaddress_id) {
|
||||||
|
$order->billingaddress->generateFibuAccountNumber();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user