Merge branch 'master' into 'spidev'
# Conflicts: # Layout/default/header.php
This commit is contained in:
@@ -2,4 +2,104 @@
|
||||
|
||||
class ADBWohneinheitController extends mfBaseController {
|
||||
|
||||
protected function init() {
|
||||
$this->needlogin=true;
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me",$me);
|
||||
|
||||
if(!$me->is(["Admin", "netowner"]) && !$me->can("Preorder")) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
}
|
||||
|
||||
protected function addAction() {
|
||||
$this->layout()->setTemplate("ADBWohneinheit/Form");
|
||||
|
||||
if($this->me->is("Admin")) {
|
||||
$my_networks = NetworkModel::getAll();
|
||||
} else {
|
||||
$my_networks = $this->me->myNetworks(["netowner", "salespartner"]);
|
||||
}
|
||||
|
||||
$netzgebiet_ids = [];
|
||||
$my_adb_networks = [];
|
||||
foreach($my_networks as $network) {
|
||||
if($network->adb_netzgebiet_id && !in_array($network->adb_netzgebiet_id, $netzgebiet_ids)) {
|
||||
$netzgebiet_ids[] = $network->adb_netzgebiet_id;
|
||||
$my_adb_networks[$network->adb_netzgebiet_id] = new ADBNetzgebiet($network->adb_netzgebiet_id);
|
||||
}
|
||||
}
|
||||
$this->layout()->set("my_adb_networks", $my_adb_networks);
|
||||
|
||||
}
|
||||
|
||||
protected function editAction() {
|
||||
$id = $this->request->id;
|
||||
if(!is_numeric($id) || $id < 1) {
|
||||
$this->layout()->setFlash("Adresse nicht gefunden", "error");
|
||||
$this->redirect("AddressDB");
|
||||
}
|
||||
|
||||
$unit = new ADBWohneinheit($id);
|
||||
if(!$unit->id) {
|
||||
$this->layout()->setFlash("Wohneinheit nicht gefunden", "error");
|
||||
$this->redirect("AddressDB");
|
||||
}
|
||||
|
||||
/*if(!in_array($hausnummer->netzgebiet_id, $my_adb_networks)) {
|
||||
$this->layout()->setFlash("Adresse nicht gefunden", "error");
|
||||
$this->redirect("AddressDB");
|
||||
}*/
|
||||
|
||||
$this->layout()->set("unit", $unit);
|
||||
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
protected function saveAction() {
|
||||
$r = $this->request;
|
||||
$id = $r->id;
|
||||
//var_dump($r->get());exit;
|
||||
|
||||
$unit_data = [];
|
||||
|
||||
if(is_numeric($id) && $id > 0) {
|
||||
$mode = "edit";
|
||||
$unit = new ADBWohneinheit($id);
|
||||
if(!$unit->id) {
|
||||
$this->layout()->setFlash("Wohneinheit nicht gefunden", "error");
|
||||
$this->redirect("AddressDB");
|
||||
}
|
||||
} else {
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
|
||||
//$unit_data["oaid"] = ($r->oaid) ? trim($r->oaid) : null;
|
||||
$unit_data["extref"] = ($r->extref) ? trim($r->extref) : null;
|
||||
$unit_data["block"] = ($r->block) ? trim($r->block) : null;
|
||||
$unit_data["stiege"] = ($r->stiege) ? trim($r->stiege) : null;
|
||||
$unit_data["stock"] = ($r->stock) ? trim($r->stock) : null;
|
||||
$unit_data["tuer"] = ($r->tuer) ? trim($r->tuer) : null;
|
||||
$unit_data["zusatz"] = ($r->zusatz) ? trim($r->zusatz) : null;
|
||||
$unit_data["bezeichner"] = ($r->bezeichner) ? trim($r->bezeichner) : null;
|
||||
|
||||
if($mode == "add") {
|
||||
$unit = ADBWohneinheitModel::create($unit_data);
|
||||
} else {
|
||||
$unit->update($unit_data);
|
||||
}
|
||||
|
||||
if(!$unit->save()) {
|
||||
$this->layout()->setFlash("Beim Speichern der Wohneinheit ist ein Fehler aufgetreten.", "error");
|
||||
$this->layout()->set("unit", $unit);
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Wohneinheit erfolgreich gespeichert.", "success");
|
||||
$this->redirect("AddressDB", "view", ["id" => $unit->hausnummer_id]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
class ADBWohneinheitModel {
|
||||
public $status_id;
|
||||
public $oaid;
|
||||
public $extref;
|
||||
public $hausnummer_id;
|
||||
public $num;
|
||||
@@ -15,7 +17,9 @@ class ADBWohneinheitModel {
|
||||
public $patch_shelf;
|
||||
public $patch_module;
|
||||
public $patch_port;
|
||||
public $external_data;
|
||||
|
||||
public $note;
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
public $create = null;
|
||||
|
||||
@@ -69,11 +69,21 @@ class Address extends mfBaseModel {
|
||||
$me->loadMe();
|
||||
|
||||
if($this->fibu_account_number) {
|
||||
$fibumerge = XinonFibuMergeModel::getFirst(["old_custnum" => $this->customer_number]);
|
||||
$old_custnum = $this->customer_number;
|
||||
if($old_custnum > 900000) {
|
||||
$old_custnum -= 900000;
|
||||
}
|
||||
|
||||
$name_search = [];
|
||||
if($this->company) $name_search[] = $this->company;
|
||||
if($this->lastname) $name_search[] = $this->lastname;
|
||||
|
||||
$fibumerge = XinonFibuMergeModel::getFirst(["old_custnum" => $old_custnum, "name" => $name_search]);
|
||||
if(!$fibumerge) {
|
||||
// create fibu merge
|
||||
$fibumerge = XinonFibuMergeModel::create([
|
||||
"old_custnum" => $this->customer_number,
|
||||
"source" => "t",
|
||||
"old_custnum" => $old_custnum,
|
||||
"new_custnum" => $this->fibu_account_number,
|
||||
"name" => ($this->company) ? $this->company : $this->lastname,
|
||||
"vorname" => ($this->company) ? "" : $this->firstname,
|
||||
@@ -86,7 +96,7 @@ class Address extends mfBaseModel {
|
||||
$fibumerge->save();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if($fibumerge->new_custnum != $this->fibu_account_number) {
|
||||
$fibumerge->new_custnum = $this->fibu_account_number;
|
||||
$fibumerge->save();
|
||||
|
||||
@@ -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,53 +280,116 @@ class AddressController extends mfBaseController {
|
||||
continue;
|
||||
}
|
||||
|
||||
// if supplier -> use it
|
||||
if($address->fibu_supplier_number) {
|
||||
$addresses[$address->fibu_supplier_number] = $address;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
$country_code_errors = [];
|
||||
$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["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["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;
|
||||
if($fibu_num >= 300000 && $fibu_num < 400000) {
|
||||
$a["fibu_supplier_due"] = (is_numeric($address->fibu_supplier_due)) ? $address->fibu_supplier_due : TT_ADDRESS_DEFAULT_SUPPLIER_DUE;
|
||||
$a["fibu_supplier_skonto"] = $address->fibu_supplier_skonto;
|
||||
$a["fibu_supplier_skonto_rate"] = $address->fibu_supplier_skonto_rate;
|
||||
$a["fibu_supplier_paymentblock"] = $address->fibu_supplier_paymentblock;
|
||||
} else {
|
||||
$a["fibu_supplier_due"] = "";
|
||||
$a["fibu_supplier_skonto"] = "";
|
||||
$a["fibu_supplier_skonto_rate"] = "";
|
||||
$a["fibu_supplier_paymentblock"] = "";
|
||||
}
|
||||
$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;
|
||||
if(strlen($address->country) == 2) {
|
||||
$a["countrycode"] = trim($address->country);
|
||||
} else {
|
||||
$a["countrycode"] = "AT";
|
||||
|
||||
if(trim($address->country)) {
|
||||
$acountry = strtolower(trim($address->country));
|
||||
$cc = __($acountry, "cc");
|
||||
|
||||
$this->log->debug("is $cc == cc.$acountry");
|
||||
$this->log->debug("last translation failed: ".(__last_translation_failed() ? "true" : "false"));
|
||||
|
||||
if(__last_translation_failed()) {
|
||||
//if($cc == "cc.".$acountry) {
|
||||
$a["countrycode"] = "AT";
|
||||
// email to buchhaltung
|
||||
$country_code_errors[$fibu_num] = $address;
|
||||
} else {
|
||||
$a["countrycode"] = $cc;
|
||||
}
|
||||
}
|
||||
}
|
||||
$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;
|
||||
}
|
||||
|
||||
if(count($country_code_errors)) {
|
||||
$msg = "Hallo,\r\n\r\ndas in thetool eingetragene Land von folgenden Kunden/Lieferanten konnte nicht in einen ISO-Code übersetzt werden:\r\n\r\n";
|
||||
foreach($country_code_errors as $fibu_num => $address) {
|
||||
$msg .= "$fibu_num (".$address->getCompanyOrName()."): ".$address->country."\r\n";
|
||||
}
|
||||
|
||||
$email = new Emailnotification();
|
||||
$email->setFrom(TT_OUTGOING_EMAIL, "thetool");
|
||||
$email->setTo(TT_FIBU_EMAIL_TO);
|
||||
$email->setSubject("[BMD-Export] Fehlerhaftes Land");
|
||||
$email->setBody($msg);
|
||||
$email->send();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -325,13 +397,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();
|
||||
@@ -362,29 +441,38 @@ class AddressController extends mfBaseController {
|
||||
|
||||
$data = [];
|
||||
$data['parent_id'] = (!$r->parent_id) ? null : $r->parent_id;
|
||||
$data['company'] = $r->company;
|
||||
$data['firstname'] = $r->firstname;
|
||||
$data['lastname'] = $r->lastname;
|
||||
$data['street'] = $r->street;
|
||||
$data['zip'] = $r->zip;
|
||||
$data['city'] = $r->city;
|
||||
$data['country'] = $r->country;
|
||||
$data['phone'] = $r->phone;
|
||||
$data['fax'] = $r->fax;
|
||||
$data['mobile'] = $r->mobile;
|
||||
$data['email'] = $r->email;
|
||||
$data['note'] = $r->note;
|
||||
$data['uid'] = $r->uid;
|
||||
$data['company'] = trim($r->company);
|
||||
$data['firstname'] = trim($r->firstname);
|
||||
$data['lastname'] = trim($r->lastname);
|
||||
$data['street'] = trim($r->street);
|
||||
$data['zip'] = trim($r->zip);
|
||||
$data['city'] = trim($r->city);
|
||||
$data['country'] = trim($r->country);
|
||||
$data['phone'] = trim($r->phone);
|
||||
$data['fax'] = trim($r->fax);
|
||||
$data['mobile'] = trim($r->mobile);
|
||||
$data['email'] = trim($r->email);
|
||||
$data['note'] = trim($r->note);
|
||||
$data['uid'] = trim($r->uid);
|
||||
|
||||
if($this->me->can("Fibu")) {
|
||||
$data['fibu_account_number'] = ($r->fibu_account_number) ? $r->fibu_account_number : null;
|
||||
$data['fibu_supplier_number'] = ($r->fibu_supplier_number) ? $r->fibu_supplier_number : null;
|
||||
$data['fibu_account_number'] = ($r->fibu_account_number) ? trim($r->fibu_account_number) : null;
|
||||
$data['fibu_supplier_number'] = ($r->fibu_supplier_number) ? trim($r->fibu_supplier_number) : null;
|
||||
if($r->fibu_primary_account) {
|
||||
$data['fibu_primary_account'] = 1;
|
||||
} else {
|
||||
$data['fibu_primary_account'] = 0;
|
||||
}
|
||||
$data['fibu_supplier_due'] = ($r->fibu_supplier_due) ? $r->fibu_supplier_due : null;
|
||||
|
||||
if($r->fibu_supplier_paymentblock) {
|
||||
$data['fibu_supplier_paymentblock'] = 1;
|
||||
} else {
|
||||
$data['fibu_supplier_paymentblock'] = 0;
|
||||
}
|
||||
|
||||
$data['fibu_supplier_due'] = ($r->fibu_supplier_due) ? trim($r->fibu_supplier_due) : null;
|
||||
$data['fibu_supplier_skonto'] = ($r->fibu_supplier_skonto) ? trim($r->fibu_supplier_skonto) : null;
|
||||
$data['fibu_supplier_skonto_rate'] = ($r->fibu_supplier_skonto_rate) ? trim($r->fibu_supplier_skonto_rate) : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -419,10 +507,10 @@ class AddressController extends mfBaseController {
|
||||
}
|
||||
|
||||
|
||||
$data['bank_account_bank'] = $r->bank_account_bank;
|
||||
$data['bank_account_owner'] = $r->bank_account_owner;
|
||||
$data['bank_account_iban'] = $r->bank_account_iban;
|
||||
$data['bank_account_bic'] = $r->bank_account_bic;
|
||||
$data['bank_account_bank'] = trim($r->bank_account_bank);
|
||||
$data['bank_account_owner'] = trim($r->bank_account_owner);
|
||||
$data['bank_account_iban'] = trim($r->bank_account_iban);
|
||||
$data['bank_account_bic'] = trim($r->bank_account_bic);
|
||||
$data['allow_contact'] = ($r->allow_contact) ? 1 : 0;
|
||||
$data['allow_spin'] = ($r->allow_spin) ? 1 : 0;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -234,6 +234,7 @@ class AddressDB {
|
||||
//$hausnummer_data['oaid'] = (array_key_exists("oaid", $data) && $data['oaid']) ? $data['oaid'] : null;
|
||||
$hausnummer_data['adrcd'] = ($data['adrcd']) ? $data['adrcd'] : null;
|
||||
$hausnummer_data['extref'] = ($data['extref']) ? $data['extref'] : null;
|
||||
$hausnummer_data['rimo_id'] = ($data['rimo_id']) ? $data['rimo_id'] : null;
|
||||
$hausnummer_data['netzgebiet_id'] = $netzgebiet_id;
|
||||
$hausnummer_data['ortschaft_id'] = $ortschaft->id;
|
||||
$hausnummer_data['plz_id'] = $plz->id;
|
||||
|
||||
@@ -270,7 +270,7 @@ class AddressDBController extends mfBaseController {
|
||||
if(!$this->me->is("Admin")) {
|
||||
$required[] = "netzgebiet_id";
|
||||
}
|
||||
foreach(['adrcd','extref','netzgebiet_id','strasse','hausnummer','plz','ortschaft','gemeinde','grund_nr','gdaeigenschaft','meridian','rw','hw','gps_lat','gps_long','unit_count'] as $field) {
|
||||
foreach(['adrcd','extref','rimo_id','netzgebiet_id','strasse','hausnummer','plz','ortschaft','gemeinde','grund_nr','gdaeigenschaft','meridian','rw','hw','gps_lat','gps_long','unit_count'] as $field) {
|
||||
if(in_array($field, $required)) {
|
||||
if(!trim($r->$field)) {
|
||||
$this->layout()->setFlash("'".ucfirst($field)."' darf nicht leer sein!", "error");
|
||||
@@ -370,7 +370,9 @@ class AddressDBController extends mfBaseController {
|
||||
$this->layout()->setFlash("Fehler beim Erstellen einer Wohneinheit!", "warning");
|
||||
return $this->addAction();
|
||||
}
|
||||
$wohneinheit->oaid = $wohneinheit->getNewOAID();
|
||||
if($hausnummer->netzgebiet->unit_create_oaid) {
|
||||
$wohneinheit->oaid = $wohneinheit->getNewOAID();
|
||||
}
|
||||
$wohneinheit->save();
|
||||
$w++;
|
||||
}
|
||||
@@ -472,6 +474,9 @@ class AddressDBController extends mfBaseController {
|
||||
case 'findBuildings':
|
||||
$return = $this->findBuildingsApi();
|
||||
break;
|
||||
case 'getUnit':
|
||||
$return = $this->getUnitApi();
|
||||
break;
|
||||
case "findUnit":
|
||||
break;
|
||||
default:
|
||||
@@ -487,6 +492,18 @@ class AddressDBController extends mfBaseController {
|
||||
$this->returnJson($data);
|
||||
}
|
||||
|
||||
private function getUnitApi() {
|
||||
$id = $this->request->id;
|
||||
if(!$id) return false;
|
||||
|
||||
$unit = new ADBWohneinheit($id);
|
||||
if(!$unit->id) return false;
|
||||
|
||||
$return = $unit->hausnummer->getAddress();
|
||||
if((string)$unit) $return .= " ".(string)$unit;
|
||||
return["string" => $return];
|
||||
}
|
||||
|
||||
private function findAddressApi() {
|
||||
$addresses = [];
|
||||
$search = trim($this->request->q);
|
||||
|
||||
@@ -23,8 +23,7 @@ class DashboardController extends mfBaseController {
|
||||
$newss = NewsModel::getAll();
|
||||
$this->layout()->set("newss", $newss);
|
||||
|
||||
//if($this->me->is(["Admin", "netowner", "salespartner"]) || $this->me->can("Preorder")) {
|
||||
if($this->me->is("Admin")) {
|
||||
if($this->me->can("Statistics") && $this->me->is(["Admin", "netowner", "salespartner"])) {
|
||||
return $this->dashboardAction();
|
||||
}
|
||||
|
||||
@@ -40,52 +39,63 @@ class DashboardController extends mfBaseController {
|
||||
$campaign_ids = [$campaign_ids];
|
||||
}
|
||||
|
||||
|
||||
$netowner_id = intval($r->netowner_id);
|
||||
$this->layout()->set("netowner_id", $netowner_id);
|
||||
|
||||
if($this->me->is("Admin")) {
|
||||
$campaigns = PreordercampaignModel::getAll();
|
||||
if($netowner_id) {
|
||||
$campaigns = PreordercampaignModel::search(["owner_id" => $netowner_id]);
|
||||
} else {
|
||||
$campaigns = PreordercampaignModel::getAll();
|
||||
}
|
||||
|
||||
if(!$campaign_ids) {
|
||||
foreach(PreordercampaignModel::getAll() as $campaign) {
|
||||
$campaign_filter = [];
|
||||
if($netowner_id) {
|
||||
$campaign_filter['owner_id'] = $netowner_id;
|
||||
}
|
||||
foreach(PreordercampaignModel::search($campaign_filter) as $campaign) {
|
||||
$campaign_ids[] = $campaign->id;
|
||||
}
|
||||
}
|
||||
|
||||
$max_connections = $this->getTotalHomes($campaign_ids);
|
||||
$count_orders = PreorderModel::count(["preordercampaign_id" => $campaign_ids, "deleted" => 0]);
|
||||
$weekly_orders = $this->getWeeklyOrders($campaign_ids);
|
||||
|
||||
$status_connected_single = PreorderModel::count(["preordercampaign_id" => $campaign_ids, "deleted" => 0, "status_code" => 244]);
|
||||
$status_connected_multi = PreorderModel::count(["preordercampaign_id" => $campaign_ids, "deleted" => 0, "status_code" => 245]);
|
||||
|
||||
$status_connected = PreorderModel::count(["preordercampaign_id" => $campaign_ids, "deleted" => 0, "status_code" => 500]);
|
||||
|
||||
$partner_orders = $this->getPartnerOrderCount($campaign_ids);
|
||||
} else {
|
||||
$campaigns = PreordercampaignModel::search(["owner_id" => $this->me->address_id]);
|
||||
|
||||
$campaign_filter = ["preordercampaign_id" => $campaign_ids];
|
||||
if(!$campaign_ids) {
|
||||
foreach(PreordercampaignModel::search(["owner_id" => $this->me->address_id]) as $campaign) {
|
||||
$campaign_ids[] = $campaign->id;
|
||||
}
|
||||
}
|
||||
|
||||
$max_connections = $this->getTotalHomes($campaign_ids);
|
||||
$count_orders = PreorderModel::count(["preordercampaign_id" => $campaign_ids, "deleted" => 0]);
|
||||
$weekly_orders = $this->getWeeklyOrders($campaign_ids);
|
||||
|
||||
$status_connected_single = PreorderModel::count(["preordercampaign_id" => $campaign_ids, "deleted" => 0, "status_code" => 244]);
|
||||
$status_connected_multi = PreorderModel::count(["preordercampaign_id" => $campaign_ids, "deleted" => 0, "status_code" => 245]);
|
||||
|
||||
$status_connected = PreorderModel::count(["preordercampaign_id" => $campaign_ids, "deleted" => 0, "status_code" => 500]);
|
||||
$partner_orders = $this->getPartnerOrderCount($campaign_ids);
|
||||
}
|
||||
|
||||
if(!$campaign_ids) {
|
||||
$campaign_ids = [0];
|
||||
}
|
||||
|
||||
$max_connections = $this->getTotalHomes($campaign_ids);
|
||||
$count_orders = PreorderModel::count(["preordercampaign_id" => $campaign_ids, "deleted" => 0]);
|
||||
$weekly_orders = $this->getWeeklyOrders($campaign_ids);
|
||||
|
||||
$status_connected_single = PreorderModel::count(["preordercampaign_id" => $campaign_ids, "deleted" => 0, "status_code" => 244]);
|
||||
$status_connected_multi = PreorderModel::count(["preordercampaign_id" => $campaign_ids, "deleted" => 0, "status_code" => 245]);
|
||||
|
||||
$status_connected = PreorderModel::count(["preordercampaign_id" => $campaign_ids, "deleted" => 0, "status_code" => 500]);
|
||||
|
||||
$partner_orders = $this->getPartnerOrderCount($campaign_ids);
|
||||
$partner_orders_by_status = $this->getPartnerOrdersByStatus($campaign_ids);
|
||||
|
||||
$total_orders = $partner_orders["total"];
|
||||
unset($partner_orders["total"]);
|
||||
|
||||
//var_dump($partner_orders);exit;
|
||||
|
||||
$stati = [];
|
||||
foreach(PreorderstatusModel::getAll() as $status) {
|
||||
$stati[$status->id] = ["code" => $status->code, "name" => $status->name];
|
||||
}
|
||||
|
||||
$this->layout()->set("stati", $stati);
|
||||
|
||||
$this->layout()->set("max_connections", $max_connections);
|
||||
$this->layout()->set("count_orders", $count_orders);
|
||||
$this->layout()->set("weekly_orders", $weekly_orders);
|
||||
@@ -95,6 +105,7 @@ class DashboardController extends mfBaseController {
|
||||
$this->layout()->set("status_connected", $status_connected);
|
||||
$this->layout()->set("partner_orders", $partner_orders);
|
||||
$this->layout()->set("total_orders", $total_orders);
|
||||
$this->layout()->set("partner_orders_by_status", $partner_orders_by_status);
|
||||
|
||||
$this->layout()->set("campaigns", $campaigns);
|
||||
$this->layout()->set("campaign_id", $r->campaign_id);
|
||||
@@ -107,7 +118,7 @@ class DashboardController extends mfBaseController {
|
||||
foreach($preordercampaign_id as $campaign_id) {
|
||||
$campaign = new Preordercampaign($campaign_id);
|
||||
if($campaign->id) {
|
||||
$total_homes += $campaign->total_homes;
|
||||
$total_homes += ($campaign->homes_total) ? $campaign->homes_total : $campaign->total_homes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,19 +129,24 @@ class DashboardController extends mfBaseController {
|
||||
$orders = [];
|
||||
$totals = 0;
|
||||
|
||||
|
||||
foreach(AddressModel::search(["addresstype" => ["salespartner"]]) as $partner) {
|
||||
$count = PreorderModel::count(["partner_id" => $partner->id, "preordercampaign_id" => $preordercampaign_id, "deleted" => 0]);
|
||||
if($count) {
|
||||
if(!array_key_exists($partner->getCompanyOrName(), $orders)) {
|
||||
$orders[$partner->getCompanyOrName()] = $count;
|
||||
$sql = "SELECT COUNT(Preorder.id) as cnt, IF(Address.company IS NOT NULL AND Address.company <> '', Address.company, CONCAT(Address.firstname, ' ', Address.lastname)) as partner FROM Preorder
|
||||
LEFT JOIN Address ON (Preorder.partner_id = Address.id)
|
||||
LEFT JOIN Addresstype ON (Addresstype.address_id = Address.id AND Addresstype.type='salespartner')
|
||||
WHERE Preorder.deleted = 0 AND Preorder.preordercampaign_id IN (".implode(",", $preordercampaign_id).")
|
||||
GROUP BY Address.id
|
||||
";
|
||||
$this->log->debug($sql);
|
||||
$res = $this->db()->query($sql);
|
||||
if($this->db()->num_rows($res)) {
|
||||
while($data = $this->db()->fetch_object($res)) {
|
||||
if($data->partner) {
|
||||
$orders[$data->partner] = $data->cnt;
|
||||
} else {
|
||||
$orders[$partner->getCompanyOrName()] += $count;
|
||||
$orders["Kein Partner"] = $data->cnt;
|
||||
}
|
||||
$totals += $count;
|
||||
$totals += $data->cnt;
|
||||
}
|
||||
}
|
||||
|
||||
arsort($orders);
|
||||
$orders["total"] = $totals;
|
||||
return $orders;
|
||||
@@ -161,6 +177,26 @@ class DashboardController extends mfBaseController {
|
||||
//var_dump($orders);exit;
|
||||
}
|
||||
|
||||
private function getPartnerOrdersByStatus($preordercampaign_id = []) {
|
||||
$orders = [];
|
||||
|
||||
foreach(PreorderModel::search(["preordercampaign_id" => $preordercampaign_id, "deleted" => 0]) as $preorder) {
|
||||
$name = $preorder->partner->getCompanyOrName();
|
||||
if(!$name) $name = "Kein Partner";
|
||||
if(!array_key_exists($name, $orders)) {
|
||||
$orders[$name] = [];
|
||||
$orders[$name]["total"] = 0;
|
||||
}
|
||||
if(!array_key_exists($preorder->status->id, $orders[$name])) {
|
||||
$orders[$name][$preorder->status->id] = 0;
|
||||
}
|
||||
$orders[$name][$preorder->status->id]++;
|
||||
$orders[$name]["total"]++;
|
||||
}
|
||||
//var_dump($orders);exit;
|
||||
return $orders;
|
||||
}
|
||||
|
||||
protected function pdfAction() {
|
||||
$order = new Order(7);
|
||||
$owner = new Address(1);
|
||||
|
||||
@@ -1,2 +1,10 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* will be called in mfBaseController after initializing Controller, before
|
||||
* running requested action
|
||||
*/
|
||||
|
||||
/* Get last git merge timestamp */
|
||||
$last_merge_ts = new mfConfig("git.merge.ts");
|
||||
$this->layout()->set("git_merge_ts", $last_merge_ts->value());
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
class OpenAccessId extends mfBaseModel {
|
||||
private $owner;
|
||||
private $adb_wohneinheit;
|
||||
private $adb_wohneinheit_count;
|
||||
private $termination;
|
||||
|
||||
public function loadRandomUnassigned($attributes = []) {
|
||||
@@ -94,8 +95,8 @@ class OpenAccessId extends mfBaseModel {
|
||||
$qs = http_build_query($params);
|
||||
//echo $qs."\n";
|
||||
|
||||
$createOrderEp = RIMO_API_JSON_URL.RIMO_API_JSON_EP_QUERY_HOME;
|
||||
$get_url = $createOrderEp."?".$qs;
|
||||
$queryHomeEp = RIMO_API_JSON_URL.RIMO_API_JSON_EP_QUERY_HOME;
|
||||
$get_url = $queryHomeEp."?".$qs;
|
||||
$ctx = stream_context_create($ctx_opts);
|
||||
$this->log->debug(__METHOD__.": Getting Home to fetch FTU: $get_url");
|
||||
//exit;
|
||||
@@ -189,8 +190,84 @@ class OpenAccessId extends mfBaseModel {
|
||||
$this->save();
|
||||
} else {
|
||||
$this->log->debug(__METHOD__.": OAID ".$this->oaid.": Already created in RIMO");
|
||||
|
||||
/*************************************************************************
|
||||
* get OAID from rimo and check if it's the same FTU as our Wohneinheit
|
||||
*/
|
||||
|
||||
$ftu_data = $wohneinheit->ftu_data;
|
||||
if($ftu_data['id'] && $ftu_data['name']) {
|
||||
|
||||
$params = [];
|
||||
$params['apiKey'] = RIMO_API_JSON_APIKEY;
|
||||
|
||||
$ctx_opts = [
|
||||
'http' => [
|
||||
'method' => 'GET',
|
||||
'header' => 'accept: application/json'
|
||||
]
|
||||
];
|
||||
|
||||
$qs = http_build_query($params);
|
||||
//echo $qs."\n";
|
||||
|
||||
$getOaidEp = RIMO_API_JSON_URL.RIMO_API_JSON_EP_GET_OAID;
|
||||
$getOaidEp .= "/".$this->oaid;
|
||||
$get_url = $getOaidEp."?".$qs;
|
||||
$ctx = stream_context_create($ctx_opts);
|
||||
$this->log->debug(__METHOD__.": Getting OAID from Rimo: $get_url");
|
||||
$response = file_get_contents($get_url, false, $ctx);
|
||||
//var_dump($response);exit;
|
||||
if($response === false) {
|
||||
$this->log->error("Fehler beim abfragen der OAID in RIMO ".$this->oaid."\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
$resp_data = json_decode($response);
|
||||
if($resp_data->terminiationUnit && $resp_data->terminiationUnit->id) {
|
||||
if($ftu_data['id'] != $resp_data->terminiationUnit->id) {
|
||||
$old_ftu_id = $resp_data->terminiationUnit->id;
|
||||
|
||||
|
||||
// unassign oaid from FTU
|
||||
$ctx_opts["http"]["method"] = "DELETE";
|
||||
$unassignEp = RIMO_API_JSON_URL.RIMO_API_JSON_EP_UNASSIGN_OAID_TO_FTU;
|
||||
$unassignEp = str_replace("{oaidName}", $this->oaid, $unassignEp);
|
||||
$unassignEp = str_replace("{ftuExternalId}", $old_ftu_id, $unassignEp);
|
||||
|
||||
$delete_url = $unassignEp."?".$qs;
|
||||
$ctx = stream_context_create($ctx_opts);
|
||||
$this->log->debug(__METHOD__.": Unassigning OAID from FTU $old_ftu_id: $delete_url");
|
||||
$response = file_get_contents($delete_url, false, $ctx);
|
||||
|
||||
|
||||
// assign oaid to Wohneinheit FTU
|
||||
$ctx_opts["http"]["method"] = "POST";
|
||||
$assignEp = RIMO_API_JSON_URL.RIMO_API_JSON_EP_ASSIGN_OAID_TO_FTU;
|
||||
$assignEp = str_replace("{oaidName}", $this->oaid, $assignEp);
|
||||
$assignEp = str_replace("{ftuExternalId}", $ftu_data['id'], $assignEp);
|
||||
|
||||
$post_url = $assignEp."?".$qs;
|
||||
$ctx = stream_context_create($ctx_opts);
|
||||
$this->log->debug(__METHOD__.": Assigning OAID to current FTU ".$ftu_data['id'].": $post_url");
|
||||
$response = file_get_contents($post_url, false, $ctx);
|
||||
|
||||
// update OAID export data
|
||||
$exp_data_update = json_decode($this->export_data);
|
||||
$exp_data_update->rimo->ftu_id = $ftu_data['id'];
|
||||
$exp_data_update->rimo->ftu_name = $ftu_data['name'];
|
||||
$exp_data_update->rimo->ftu_assigned_date = date("U");
|
||||
$this->export_data = json_encode($ext_data_update);
|
||||
$this->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* assign OAID to FTU - POST /v1/oaid-management/oaids/{oaidName}/ftu/{ftuExternalId}
|
||||
*/
|
||||
@@ -332,6 +409,11 @@ class OpenAccessId extends mfBaseModel {
|
||||
return $this->adb_wohneinheit;
|
||||
}
|
||||
|
||||
if($name == "adb_wohneinheit_count") {
|
||||
$this->adb_wohneinheit_count = ADBWohneinheitModel::count(["oaid" => $this->oaid]);
|
||||
return $this->adb_wohneinheit_count;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
@@ -17,11 +17,23 @@ class OpenAccessIdController extends mfBaseController {
|
||||
protected function indexAction() {
|
||||
$this->layout()->setTemplate("OpenAccessId/Index");
|
||||
|
||||
$this->layout->set("filter", $this->request->filter);
|
||||
if($this->request->filter) {
|
||||
$filter = $this->getPreparedFilter($this->request->filter);
|
||||
if($this->request->resetFilter) {
|
||||
unset($_SESSION[MFAPPNAME.'-OpenAccessId-filter']);
|
||||
}
|
||||
|
||||
$filter = [];
|
||||
if(is_array($this->request->filter)) {
|
||||
$filter = $this->request->filter;
|
||||
$_SESSION[MFAPPNAME.'-OpenAccessId-filter'] = $filter;
|
||||
} else {
|
||||
if(array_key_exists(MFAPPNAME.'-OpenAccessId-filter', $_SESSION) && count($_SESSION[MFAPPNAME.'-OpenAccessId-filter'])) {
|
||||
$filter = $_SESSION[MFAPPNAME.'-OpenAccessId-filter'];
|
||||
}
|
||||
}
|
||||
|
||||
$this->layout->set("filter", $filter);
|
||||
$filter = $this->getPreparedFilter($filter);
|
||||
|
||||
// pagination defaults
|
||||
$pagination = [];
|
||||
$pagination['start'] = 0;
|
||||
@@ -73,6 +85,79 @@ class OpenAccessIdController extends mfBaseController {
|
||||
return $new_filter;
|
||||
}
|
||||
|
||||
protected function changeADBWohneinheitAction() {
|
||||
$this->layout()->setTemplate("OpenAccessId/ChangeUnit");
|
||||
$id = $this->request->id;
|
||||
if(!$id || $id <1) {
|
||||
$this->layout()->setFlash("Ungültige OAID", "error");
|
||||
$this->redirect("OpenAccessId");
|
||||
}
|
||||
|
||||
$oaid = new OpenAccessId($id);
|
||||
if(!$oaid->id) {
|
||||
$this->layout()->setFlash("Ungültige OAID", "error");
|
||||
$this->redirect("OpenAccessId");
|
||||
}
|
||||
|
||||
$this->layout()->set("oaid", $oaid);
|
||||
|
||||
if(!$this->request->new_unit_id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// get old and new unit_id
|
||||
$old_unit = ADBWohneinheitModel::getFirst(["oaid" => $oaid->oaid]);
|
||||
$new_unit = new ADBWohneinheit($this->request->new_unit_id);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if($old_unit) {
|
||||
$old_preorder = PreorderModel::getFirst(["adb_wohneinheit_id" => $old_unit->id]);
|
||||
if($old_preorder) {
|
||||
// remove oaid from preorder
|
||||
$old_preorder->oaid = null;
|
||||
$old_preorder->save();
|
||||
}
|
||||
// unassign oaid from rimo ftu
|
||||
// get oaid from rimo
|
||||
// unassign ftu from aoid
|
||||
// remove oaid from old unit
|
||||
|
||||
// remove meta data from oaid
|
||||
$oaid->assigned = 0;
|
||||
$oaid->adb_wohneinheit_id = null;
|
||||
$oaid->termination_id = null;
|
||||
$oaid->exported = 0;
|
||||
$oaid->exported_to = null;
|
||||
$oaid->exported_data = null;
|
||||
$oaid->address = null;
|
||||
$oaid->unit_string = null;
|
||||
$oaid->save();
|
||||
}
|
||||
|
||||
if($new_unit) {
|
||||
$new_preorder = PreorderModel::getFirst(["adb_wohneinheit_id" => $new_unit->id]);
|
||||
// add oaid to new unit
|
||||
// assign oaid to new ftu in rimo
|
||||
if($new_preorder) {
|
||||
// add oaid to preorder
|
||||
$new_preorder->oaid = $oaid->oaid;
|
||||
}
|
||||
// save metadata to oaid
|
||||
$oaid->assigned = date("U");
|
||||
$oaid->adb_wohneinheit_id = $new_unit->id;
|
||||
$oaid->termination_id = null;
|
||||
$oaid->exported = date("U");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function importerAction() {
|
||||
$this->layout()->setTemplate("OpenAccessId/Importer");
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
class Preorder extends mfBaseModel {
|
||||
protected $forcestr = ['street','company','zip','phone','email','note'];
|
||||
private $in_after_save = false;
|
||||
private $in_after_save = 0;
|
||||
|
||||
private $status;
|
||||
private $campaign;
|
||||
@@ -38,7 +38,7 @@ class Preorder extends mfBaseModel {
|
||||
|
||||
// prevent potential infinite loop
|
||||
if($this->in_after_save) return true;
|
||||
$this->in_after_save = true;
|
||||
$this->in_after_save++;
|
||||
// update preorder OAID if it's different from the unit OAID
|
||||
// but only if the unit OAID is of the same origin as the campaign
|
||||
$old_oaid = $this->oaid;
|
||||
@@ -52,6 +52,8 @@ class Preorder extends mfBaseModel {
|
||||
$this->cascadeStatus();
|
||||
// Cascade status changes down all active preorders with the same hausnummer
|
||||
$this->cascadeStatusToPreorders();
|
||||
|
||||
$this->in_after_save--;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -87,6 +87,24 @@ class ProductgroupController extends mfBaseController {
|
||||
|
||||
$group_data = [];
|
||||
$group_data['name'] = $name;
|
||||
$group_data["matchcodeorigin"] = null;
|
||||
|
||||
if($r->matchcodeorigin) {
|
||||
switch($r->matchcodeorigin) {
|
||||
case "address":
|
||||
$group_data["matchcodeorigin"] = "address";
|
||||
break;
|
||||
case "domain":
|
||||
$group_data["matchcodeorigin"] = "domain";
|
||||
break;
|
||||
case "terminationaddress":
|
||||
$group_data["matchcodeorigin"] = "terminationaddress";
|
||||
break;
|
||||
case "voicenumber":
|
||||
$group_data["matchcodeorigin"] = "voicenumber";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if($mode == "edit") {
|
||||
$group->update($group_data);
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
class ProductgroupModel {
|
||||
public $name = null;
|
||||
public $description = null;
|
||||
public $name;
|
||||
public $description;
|
||||
public $matchcodeorigin;
|
||||
|
||||
public $note = null;
|
||||
|
||||
|
||||
@@ -51,7 +51,9 @@ class UserController extends mfBaseController
|
||||
}
|
||||
$this->layout()->setTemplate('User/Form');
|
||||
|
||||
$addresses = AddressModel::getAll();
|
||||
$roles = TT_NETWORK_ROLES_WITH_OWNER;
|
||||
$roles[] = "systemowner";
|
||||
$addresses = AddressModel::search(["addresstype" => $roles]);
|
||||
$this->layout()->set("addresses", $addresses);
|
||||
|
||||
if ($this->request->address_id) {
|
||||
@@ -225,6 +227,7 @@ class UserController extends mfBaseController
|
||||
$user->permissions->canPreorder = "false";
|
||||
$user->permissions->canOrder = "false";
|
||||
$user->permissions->canFibu = "false";
|
||||
$user->permissions->canStatistics = "false";
|
||||
|
||||
if($r->get("can") && is_array($r->can)) {
|
||||
foreach($r->can as $key => $can) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
class XinonFibuMergeModel {
|
||||
|
||||
public $source;
|
||||
public $old_custnum;
|
||||
public $new_custnum;
|
||||
public $name;
|
||||
@@ -117,9 +117,7 @@ class XinonFibuMergeModel {
|
||||
|
||||
private static function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
|
||||
|
||||
if(array_key_exists("old_custnum", $filter)) {
|
||||
$old_custnum = $filter['old_custnum'];
|
||||
if (is_numeric($old_custnum)) {
|
||||
@@ -134,6 +132,15 @@ class XinonFibuMergeModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("name", $filter)) {
|
||||
$name = $filter["name"];
|
||||
if(is_array($name)) {
|
||||
$where .= " AND XinonFibuMerge.name IN ('".implode("','", $name)."')";
|
||||
} elseif($name) {
|
||||
$name = FronkDB::singleton()->escape($filter['name']);
|
||||
$where .= " AND XinonFibuMerge.name='$name'";
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
|
||||
Reference in New Issue
Block a user