Added billingaddress cleanup script
This commit is contained in:
@@ -250,6 +250,13 @@ class OrderModel {
|
||||
$where .= " AND (Address.street like '%$owner_address%' OR Address.zip like '%$owner_address%' OR Address.city like '%$owner_address%')";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("billingaddress_id", $filter)) {
|
||||
$ownerid = $filter['billingaddress_id'];
|
||||
if(is_numeric($ownerid)) {
|
||||
$where .= " AND `Order`.billingaddress_id=$ownerid";
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if(array_key_exists("owner", $filter)) {
|
||||
|
||||
42
scripts/contract/check-addresses.php
Normal file
42
scripts/contract/check-addresses.php
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/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::getAll() as $contract) {
|
||||
$address = new Address($contract->owner_id);
|
||||
if(!$address) {
|
||||
echo "contract id ".$contract->id." missing owner\n";
|
||||
}
|
||||
|
||||
if($contract->billingaddress_id) {
|
||||
$address = new Address($contract->billingaddress_id);
|
||||
if(!$address) {
|
||||
echo "contract id ".$contract->id." missing billingaddress\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach(OrderModel::getAll() as $order) {
|
||||
$address = new Address($order->owner_id);
|
||||
if(!$address) {
|
||||
echo "order id ".$order->id." missing owner\n";
|
||||
}
|
||||
|
||||
if($order->billingaddress_id) {
|
||||
$address = new Address($order->billingaddress_id);
|
||||
if(!$address) {
|
||||
echo "order id ".$order->id." missing billingaddress\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
74
scripts/contract/delete-unused-billingaddresses.php
Normal file
74
scripts/contract/delete-unused-billingaddresses.php
Normal file
@@ -0,0 +1,74 @@
|
||||
#!/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(AddressLinkModel::search(["type" => "billing"]) as $link) {
|
||||
//var_dump($link);exit;
|
||||
|
||||
if($link->address_id == $link->origin_address_id) {
|
||||
echo $link->address_id." == ".$link->origin_address_id."\n";
|
||||
$link->delete();
|
||||
}
|
||||
|
||||
$bill_id = $link->address_id;
|
||||
|
||||
|
||||
$contract = ContractModel::getFirst(["owner_id" => $bill_id]);
|
||||
if($contract) {
|
||||
//echo "$bill_id als owner in Contract ID ".$contract->id." gefunden\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
$contract = ContractModel::getFirst(["billingaddress_id" => $bill_id]);
|
||||
if($contract) {
|
||||
//echo "$bill_id als billing in Contract ID ".$contract->id." gefunden\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
$order = OrderModel::getFirst(["owner_id" => $bill_id]);
|
||||
if($order) {
|
||||
//echo "$bill_id in als owner Order ".$order->id." gefunden\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
$order = OrderModel::getFirst(["billingaddress_id" => $bill_id]);
|
||||
if($order) {
|
||||
//echo "$bill_id in als billing Order ".$order->id." gefunden\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
$bill = new Address($bill_id);
|
||||
if(!$bill || $bill->id != $bill_id) {
|
||||
echo "what !?\n";
|
||||
}
|
||||
|
||||
if($bill->customer_number) {
|
||||
echo $bill_id." has customer number\n";
|
||||
}
|
||||
if($bill->fibu_account_number) {
|
||||
echo $bill_id." has fibu account number\n";
|
||||
}
|
||||
|
||||
echo "deleting ".$bill_id."\n";
|
||||
//$bill->delete();
|
||||
foreach(AddresstypeModel::search(["address_id" => $bill_id]) as $type) {
|
||||
echo "deleting AddressType bill_id $bill_id\n";
|
||||
//$type->delete();
|
||||
}
|
||||
echo "deleting link ".$link->origin_address_id." -> ".$link->address_id."\n";
|
||||
//$link->delete();
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user