Created script to import customers from IVT

This commit is contained in:
Frank Schubert
2022-01-20 21:29:27 +01:00
parent 39d07f948e
commit 2cd9c44bda
7 changed files with 238 additions and 27 deletions

View File

@@ -15,6 +15,18 @@ class AddressModel {
public $fax = null;
public $mobile = null;
public $email = null;
public $uid;
public $billing_type;
public $billing_delivery;
public $bank_account_bank;
public $bank_account_owner;
public $bank_account_iban;
public $bank_account_bic;
public $allow_contact;
public $allow_spin;
public $note = null;
public $create_by = null;
@@ -34,10 +46,10 @@ class AddressModel {
$me = new User();
$me->loadMe();
if($model->create_by === null) {
if(!is_numeric($model->create_by) && !$model->create_by) {
$model->create_by = $me->id;
}
if($model->edit_by === null) {
if(!is_numeric($model->edit_by) && !$model->edit_by) {
$model->edit_by = $me->id;
}
@@ -47,20 +59,23 @@ class AddressModel {
return $model;
}
public static function getOne($id) {
if(!is_numeric($id) || !$id) {
throw new Exception("Invalid number", 400);
}
$item = [];
public static function getFirst($filter = null) {
$db = FronkDB::singleton();
$res = $db->select("Address", "*", "id=$id LIMIT 1");
$where = self::getSqlFilter($filter);
//mfLoghandler::singleton()->debug($where);
$res = $db->select("Address", "*", "$where ORDER BY company, lastname, firstname, zip, city LIMIT 1");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new Address($data);
$item = new Voicenumber($data);
if($item->id) {
return $item;
} else {
return null;
}
}
return $item;
return null;
}
public static function getAll() {
@@ -130,7 +145,7 @@ class AddressModel {
WHERE $where
GROUP BY Address.id
) as tbl";
mfLoghandler::singleton()->debug($sql);
//mfLoghandler::singleton()->debug($sql);
$res = $db->query($sql);
if($db->num_rows($res)) {
@@ -166,7 +181,7 @@ class AddressModel {
}
}
mfLoghandler::singleton()->debug($sql);
//mfLoghandler::singleton()->debug($sql);
$res = $db->query($sql);
if($db->num_rows($res)) {