#!/usr/bin/php id); define("INTERNAL_USER_USERNAME", $me->username); $i = 0; foreach(AddressModel::search(["customer_number" => true, "billing_type" => "sepa"]) as $address) { if($address->sepa_date) continue; $bill = IvtBillModel::getFirst(["cid" => $address->customer_number]); if(!$bill) continue; if(!trim($bill->IBAN) || !trim($bill->BIC)) continue; if(!$bill->date_outgoing) { echo "date outgoing fehlt im ivt: ".$address->customer_number."\n"; continue; } $out_date = new DateTime($bill->date_outgoing); $sepa_date = $out_date->getTimestamp(); echo "$sepa_date - ".$bill->date_outgoing."\n"; if(!$sepa_date){ echo "Konnte Datum nicht umwandeln\n"; } $address->sepa_date = $sepa_date; $address->save(); $i++; } echo "Updated $i addresses\n\n";