74 lines
1.7 KiB
PHP
74 lines
1.7 KiB
PHP
#!/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);
|
|
|
|
$folder = __DIR__."/files/";
|
|
$csvname = "bankdaten-liste.csv";
|
|
$filename = $folder.$csvname;
|
|
|
|
$db = FronkDB::singleton();
|
|
$log = mfLoghandler::singleton();
|
|
|
|
$input = fopen($filename, "r");
|
|
|
|
$l = 0;
|
|
while($csv = fgetcsv($input, 0, ";")) {
|
|
$l++;
|
|
if($l == 1) continue;
|
|
|
|
if(!trim($csv[0])) {
|
|
continue;
|
|
}
|
|
|
|
//var_dump($csv);exit;
|
|
|
|
$fibu_supplier_number = trim($csv[0]);
|
|
$iban = trim($csv[1]);
|
|
|
|
$supplier = AddressModel::getFirst(["fibu_supplier_number" => $fibu_supplier_number]);
|
|
if(!$supplier) {
|
|
echo "Supplier not found $fibu_supplier_number\n";
|
|
}
|
|
|
|
echo $supplier->getCompanyOrName()."\n";
|
|
|
|
$result = IbanValidator::validate($iban);
|
|
if(is_array($result) && $result) {
|
|
var_dump($result);
|
|
|
|
if(!$result["iban_correct"]) {
|
|
echo "IBAN incorrect: $iban\n";
|
|
continue;
|
|
}
|
|
if($result["iban_sus"] && $result["iban_sus"] != "www") {
|
|
echo "IBAN suspicious: $iban\n";
|
|
}
|
|
|
|
if(is_array($result["bic"]) && count($result["bic"])) {
|
|
$bic = array_shift($result["bic"]);
|
|
|
|
if($supplier->bank_account_iban != $iban || $supplier->bank_account_bic != $bic) {
|
|
$supplier->bank_account_iban = $iban;
|
|
$supplier->bank_account_bic = $bic;
|
|
$supplier->save();
|
|
}
|
|
continue;
|
|
}
|
|
|
|
echo "Bic nicht gefunden: $iban\n";
|
|
|
|
|
|
}
|
|
|
|
} |