BMD export update / address Skonto
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
<?php //var_dump($address->parent->types);exit;?>
|
||||
<?php
|
||||
$urlfilter = [];
|
||||
if($s) {
|
||||
@@ -257,19 +256,34 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="fibu_supplier_number">FIBU Lieferanten Nummer</label>
|
||||
<label class="col-lg-2 col-form-label" for="fibu_supplier_number">FIBU Lieferantennummer</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="fibu_supplier_number" id="fibu_supplier_number" value="<?=$address->fibu_supplier_number?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="fibu_supplier_due">FIBU Lieferanten Zahlungsziel</label>
|
||||
<label class="col-lg-2 col-form-label" for="fibu_supplier_due">Lieferant Zahlungsziel</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="fibu_supplier_due" id="fibu_supplier_due" value="<?=$address->fibu_supplier_due?>" />
|
||||
<small>Standard: <?=TT_ADDRESS_DEFAULT_SUPPLIER_DUE?> Tage</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="fibu_supplier_skonto">Lieferant Skontotage</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="fibu_supplier_skonto" id="fibu_supplier_skonto" value="<?=$address->fibu_supplier_skonto?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="fibu_supplier_skonto_rate">Lieferant Skonto %</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="fibu_supplier_skonto_rate" id="fibu_supplier_skonto_rate" value="<?=$address->fibu_supplier_skonto_rate?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
Lieferant;Kunde;address_id;FIBU-Verrechnungsnummer;FIBU Lieferantennummer;Zahlungsziel Lieferant;Firma;Vorname;Nachname;Straße Hausnummer;PLZ;Ort;Land;Telefon;Mobil;Mail;UID;Verrechnungsart;Rechnungsversand;Kreditinstitut;Kontoinhaber;IBAN;BIC
|
||||
<?php
|
||||
$header = "FIBU Kontonummber;Zahlungsziel Lieferant;Skontotage;Skontoprozent;Vorname;Nachname;Straße Hausnummer;PLZ;Ort;Land;Telefon;Mail;UID;SEPA;Kontoinhaber;IBAN;BIC;customer_numbers\n";
|
||||
$this->setReturnValue(["header" => $header]);
|
||||
|
||||
foreach($addresses as $a):
|
||||
?>
|
||||
<?=$a["is_supplier"]?>;<?=$a["is_customer"]?>;<?=$a["id"]?>;<?=$a["fibu_account_number"]?>;<?=$a["fibu_supplier_number"]?>;<?=$a["fibu_supplier_due"]?>;<?=$this->nl2ws($a["company"])?>;<?=$this->nl2ws($a["firstname"])?>;<?=$this->nl2ws($a["lastname"])?>;<?=$this->nl2ws($a["street"])?>;<?=$this->nl2ws($a["$address->zip"])?>;<?=$this->nl2ws($a["city"])?>;<?=$this->nl2ws($a["country"])?>;<?=$this->nl2ws($a["phone"])?>;<?=$this->nl2ws($a["mobile"])?>;<?=$this->nl2ws($a["email"])?>;<?=$this->nl2ws($a["uid"])?>;<?=$a["billing_type"]?>;<?=$a["billing_delivery"]?>;<?=$a["bank"]?>;<?=$a["owner"]?>;<?=$a["iban"]?>;<?=$a["bic"]?>
|
||||
<?=$a["fibu_account_number"]?>;<?=$a["fibu_supplier_due"]?>;<?=$a["fibu_supplier_skonto"]?>;<?=$a["fibu_supplier_skonto_rate"]?>;<?=$this->nl2ws($a["firstname"])?>;<?=$this->nl2ws($a["lastname"])?>;<?=$this->nl2ws($a["street"])?>;<?=$this->nl2ws($a["zip"])?>;<?=$this->nl2ws($a["city"])?>;<?=$this->nl2ws($a["countrycode"])?>;<?=$this->nl2ws($a["phone"])?>;<?=$this->nl2ws($a["email"])?>;<?=$this->nl2ws($a["uid"])?>;<?=$a["billing_type"]?>;<?=$a["bank_owner"]?>;<?=$a["iban"]?>;<?=$a["bic"]?>;<?=implode(" ",$a["customer_numbers"])?>
|
||||
|
||||
<?php
|
||||
endforeach;
|
||||
|
||||
@@ -192,17 +192,22 @@ class AddressController extends mfBaseController {
|
||||
$last_export = $export_ts->value();
|
||||
}
|
||||
|
||||
$type = "inc";
|
||||
if(!file_exists(TT_ADDRESS_BMD_EXPORT_PATH)) {
|
||||
$this->layout()->setFlash("Export Pfad (".TT_ADDRESS_BMD_EXPORT_PATH.") nicht gefunden!", "error");
|
||||
}
|
||||
$filepath = TT_ADDRESS_BMD_EXPORT_PATH."/".TT_ADDRESS_BMD_EXPORT_FILENAME;
|
||||
|
||||
$type = "inc";
|
||||
if($this->request->type == "full") {
|
||||
$last_export = 0;
|
||||
$type = "full";
|
||||
}
|
||||
|
||||
if(!file_exists(TT_ADDRESS_BMD_EXPORT_PATH)) {
|
||||
$this->layout()->setFlash("Export Pfad (".TT_ADDRESS_BMD_EXPORT_PATH.") nicht gefunden!", "error");
|
||||
// delete export file if export if full
|
||||
if($last_export == 0 && file_exists($filepath)) {
|
||||
unlink($filepath);
|
||||
}
|
||||
|
||||
|
||||
$export_ts->value(date('U'));
|
||||
|
||||
$search = ["edit>" => $last_export, "customer_or_fibu_numbers" => true];
|
||||
@@ -215,7 +220,11 @@ class AddressController extends mfBaseController {
|
||||
$addresses = [];
|
||||
|
||||
foreach(AddressModel::search($search) as $address) {
|
||||
|
||||
// if supplier -> add it as extra line
|
||||
if($address->fibu_supplier_number) {
|
||||
$addresses[$address->fibu_supplier_number] = $address;
|
||||
if(!$address->fibu_account_number) continue;
|
||||
}
|
||||
|
||||
// if is primary -> use it
|
||||
if($address->fibu_account_number && $address->fibu_primary_account) {
|
||||
@@ -271,48 +280,68 @@ class AddressController extends mfBaseController {
|
||||
continue;
|
||||
}
|
||||
|
||||
// if supplier -> use it
|
||||
if($address->fibu_supplier_number) {
|
||||
$addresses[$address->fibu_supplier_number] = $address;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
$export_addresses = [];
|
||||
|
||||
foreach($addresses as $address) {
|
||||
foreach($addresses as $fibu_num => $address) {
|
||||
$a = [];
|
||||
$a["id"] = $address->id;
|
||||
$a["is_supplier"] = (array_key_exists("supplier", $address->types) && $address->types['supplier']) ? "1" : "0";
|
||||
$a["is_customer"] = "1";
|
||||
$a["customer_number"] = $address->customer_number;
|
||||
$a["fibu_account_number"] = $address->fibu_account_number;
|
||||
$a["fibu_supplier_number"] = $address->fibu_supplier_number;
|
||||
//$a["is_supplier"] = (array_key_exists("supplier", $address->types) && $address->types['supplier']) ? "1" : "0";
|
||||
//$a["is_customer"] = "1";
|
||||
//$a["customer_number"] = $address->customer_number;
|
||||
$a["fibu_account_number"] = $fibu_num;
|
||||
//$a["fibu_supplier_number"] = $address->fibu_supplier_number;
|
||||
$a["fibu_supplier_due"] = (is_numeric($address->fibu_supplier_due)) ? $address->fibu_supplier_due : TT_ADDRESS_DEFAULT_SUPPLIER_DUE;
|
||||
$a["company"] = $address->company;
|
||||
$a["firstname"] = $address->firstname;
|
||||
$a["lastname"] = $address->lastname;
|
||||
$a["fibu_supplier_skonto"] = $address->fibu_supplier_skonto;
|
||||
$a["fibu_supplier_skonto_rate"] = $address->fibu_supplier_skonto_rate;
|
||||
$a["street"] = $address->street;
|
||||
$a["zip"] = $address->zip;
|
||||
$a["city"] = $address->city;
|
||||
$a["country"] = $address->country;
|
||||
$a["phone"] = $address->phone;
|
||||
$a["mobile"] = $address->mobile;
|
||||
$a["email"] = $address->email;
|
||||
$a["countrycode"] = ($address->country) ? __($address->country, "cc") : "AT";
|
||||
$a["phone"] = "";
|
||||
if($address->mobile) $a["phone"] = $address->mobile;
|
||||
if($address->phone) $a["phone"] = $address->phone;
|
||||
$a["uid"] = $address->uid;
|
||||
$a["billing_type"] = $address->billing_type;
|
||||
$a["billing_delivery"] = $address->billing_delivery;
|
||||
if(array_key_exists("billing", $address->links) && $address->links["billing"]) {
|
||||
$a["bank"] = $address->links["billing"]->bank_account_bank;
|
||||
$a["bank_owner"] = $address->links["billing"]->bank_account_owner;
|
||||
$a["iban"] = $address->links["billing"]->bank_account_iban;
|
||||
$a["bic"] = $address->links["billing"]->bank_account_bic;
|
||||
$a["billing_type"] = ($address->billing_type == "sepa") ? "1" : "0";
|
||||
//$a["billing_delivery"] = $address->billing_delivery;
|
||||
|
||||
if($address->company) {
|
||||
$a["firstname"] = "";
|
||||
$a["lastname"] = $address->company;
|
||||
} else {
|
||||
$a["firstname"] = $address->firstname;
|
||||
$a["lastname"] = $address->lastname;
|
||||
}
|
||||
|
||||
if(array_key_exists("billing", $address->links) && $address->links["billing"][0] && $address->links["billing"][0]->address_id) {
|
||||
//var_dump($address->links);exit;
|
||||
$bill = $address->links["billing"][0]->address;
|
||||
$a["bank"] = $bill->bank_account_bank;
|
||||
$a["bank_owner"] = $bill->bank_account_owner;
|
||||
$a["iban"] = $bill->bank_account_iban;
|
||||
$a["bic"] = $bill->bank_account_bic;
|
||||
$a["email"] = $bill->email;
|
||||
} else {
|
||||
$a["bank"] = $address->bank_account_bank;
|
||||
$a["bank_owner"] = $address->bank_account_owner;
|
||||
$a["iban"] = $address->bank_account_iban;
|
||||
$a["bic"] = $address->bank_account_bic;
|
||||
$a["email"] = $address->email;
|
||||
}
|
||||
|
||||
$a["customer_numbers"] = [];
|
||||
$a["customer_numbers"][] = $address->customer_number;
|
||||
|
||||
// add all customer numbers to customer_numbers
|
||||
if($address->fibu_account_number) {
|
||||
foreach(AddressModel::search(["fibu_account_number" => $address->fibu_account_number]) as $secondary) {
|
||||
if($secondary->customer_number && !in_array($secondary->customer_number, $a["customer_numbers"])) {
|
||||
$a["customer_numbers"][] = $secondary->customer_number;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$export_addresses[] = $a;
|
||||
@@ -325,13 +354,20 @@ class AddressController extends mfBaseController {
|
||||
$tpl->setTemplate("Address/bmd_export.csv");
|
||||
$tpl->set("addresses", $export_addresses);
|
||||
$csv_content = $tpl->render();
|
||||
$return_values = $tpl->getReturnedValue();
|
||||
$csv_header = $return_values['header'];
|
||||
|
||||
$filename = "thetool_address_export_".$type."_".date("Y-m-d-H-i-s").".csv";
|
||||
|
||||
// save to TT_ADDRESS_BMD_EXPORT_PATH
|
||||
$filepath = TT_ADDRESS_BMD_EXPORT_PATH."/".$filename;
|
||||
|
||||
if(!file_put_contents($filepath, $csv_content)) {
|
||||
if(file_exists($filepath)) {
|
||||
// if file exists, append new content
|
||||
$result = file_put_contents($filepath, $csv_content, FILE_APPEND);
|
||||
} else {
|
||||
// else, add content with csv header
|
||||
$result = file_put_contents($filepath, $csv_header.$csv_content);
|
||||
}
|
||||
|
||||
if($result === false) {
|
||||
$this->layout()->setFlash("Datei $filepath konnte nicht gespeichert werden!", "error");
|
||||
} else {
|
||||
$export_ts->save();
|
||||
@@ -385,6 +421,8 @@ class AddressController extends mfBaseController {
|
||||
$data['fibu_primary_account'] = 0;
|
||||
}
|
||||
$data['fibu_supplier_due'] = ($r->fibu_supplier_due) ? $r->fibu_supplier_due : null;
|
||||
$data['fibu_supplier_skonto'] = ($r->fibu_supplier_skonto) ? $r->fibu_supplier_skonto : null;
|
||||
$data['fibu_supplier_skonto_rate'] = ($r->fibu_supplier_skonto_rate) ? $r->fibu_supplier_skonto_rate : null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,9 @@ class AddressModel {
|
||||
public $customer_number;
|
||||
public $fibu_account_number;
|
||||
public $fibu_supplier_number;
|
||||
public $fibu_supplier_due;
|
||||
public $fibu_supplier_skonto;
|
||||
public $fibu_supplier_skonto_rate;
|
||||
public $fibu_primary_account;
|
||||
public $spin;
|
||||
public $company;
|
||||
|
||||
35
db/migrations/20240116132506_address_add_skonto.php
Normal file
35
db/migrations/20240116132506_address_add_skonto.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class AddressAddSkonto extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$table = $this->table("Address");
|
||||
$table->addColumn("fibu_supplier_skonto", "integer", ["null" => true, "default" => null, "after" => "fibu_supplier_due"]);
|
||||
$table->addColumn("fibu_supplier_skonto_rate", "integer", ["null" => true, "default" => null, "after" => "fibu_supplier_skonto"]);
|
||||
$table->update();
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$table = $this->table("Address");
|
||||
$table->removeColumn("fibu_supplier_skonto_rate");
|
||||
$table->removeColumn("fibu_supplier_skonto");
|
||||
$table->save();
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
58
lang/de.php
58
lang/de.php
@@ -56,4 +56,62 @@ $l['contract.downgrade'] = "Downgrade";
|
||||
$l['contract.relocation'] = "Umzug";
|
||||
$l['contract.productchange'] = "Produktwechsel";
|
||||
|
||||
|
||||
$l['cc.österreich'] = "AT";
|
||||
$l['cc.osterreich'] = "AT";
|
||||
$l['cc.oesterreich'] = "AT";
|
||||
$l['cc.austria'] = "AT";
|
||||
$l["cc.bulgarien"] = "BG";
|
||||
$l["cc.bulgaria"] = "BG";
|
||||
$l["cc.schweiz"] = "CH";
|
||||
$l["cc.switzerland"] = "CH";
|
||||
$l["cc.zypern"] = "CY";
|
||||
$l["cc.cyprus"] = "CY";
|
||||
$l["cc.tschechien"] = "CZ";
|
||||
$l["cc.czechia"] = "CZ";
|
||||
$l["cc.tschechische republik"] = "CZ";
|
||||
$l["cc.czech republic"] = "CZ";
|
||||
$l["cc.Česká republika"] = "CZ";
|
||||
$l["cc.deutschland"] = "DE";
|
||||
$l["cc.germany"] = "DE";
|
||||
$l["cc.großbritannien"] = "GB";
|
||||
$l["cc.grossbritannien"] = "GB";
|
||||
$l["cc.britain"] = "GB";
|
||||
$l["cc.great britain"] = "GB";
|
||||
$l["cc.uk"] = "GB";
|
||||
$l["cc.united kingdom"] = "GB";
|
||||
$l["cc.United Kingdom of Great Britain and Northern Ireland"] = "GB";
|
||||
$l["cc.Vereinigtes Königreich"] = "GB";
|
||||
$l["cc.Vereinigtes Königreich Großbritannien und Nordirland"] = "GB";
|
||||
$l["cc.ungarn"] = "HU";
|
||||
$l["cc.hungary"] = "HU";
|
||||
$l["cc.irland"] = "IE";
|
||||
$l["cc.ireland"] = "IE";
|
||||
$l["cc.republic of ireland"] = "IE";
|
||||
$l["cc.italien"] = "IT";
|
||||
$l["cc.italia"] = "IT";
|
||||
$l["cc.japan"] = "JP";
|
||||
$l["cc.jpn"] = "JP";
|
||||
$l["cc.nippon"] = "JP";
|
||||
$l["cc.nihon"] = "JP";
|
||||
$l["cc.日本"] = "JP";
|
||||
$l["cc.日本国"] = "JP";
|
||||
$l["cc.niederlande"] = "NL";
|
||||
$l["cc.netherlands"] = "NL";
|
||||
$l["cc.nederland"] = "NL";
|
||||
$l["cc.holland"] = "NL";
|
||||
$l["cc.polen"] = "PL";
|
||||
$l["cc.poland"] = "PL";
|
||||
$l["cc.polska"] = "PL";
|
||||
$l["cc.rumänien"] = "RO";
|
||||
$l["cc.rumaenien"] = "RO";
|
||||
$l["cc.romania"] = "RO";
|
||||
$l["cc.slowenien"] = "SL";
|
||||
$l["cc.slovenia"] = "SL";
|
||||
$l["cc.slowakei"] = "SK";
|
||||
$l["cc.slovakia"] = "SK";
|
||||
$l["cc.slowakische republik"] = "SK";
|
||||
$l["cc.Slovak Republic"] = "SK";
|
||||
|
||||
|
||||
$lang['de'] = $l;
|
||||
@@ -279,9 +279,12 @@ if(!isset($lang)) {
|
||||
$lang = [];
|
||||
}
|
||||
|
||||
function __($string, $prefix = null) {
|
||||
function __($_string, $prefix = null) {
|
||||
global $lang;
|
||||
|
||||
$string = str_replace(["Ä","Ö","Ü"],["ä","ö","ü"] , strtolower($_string));
|
||||
|
||||
|
||||
if(!$lang) {
|
||||
//mfLoghandler::singleton()->debug("Loading language file for __() function");
|
||||
include(BASEDIR . "/lang/de.php");
|
||||
|
||||
Reference in New Issue
Block a user