Merge branch 'fronkdev'
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
class ADBHausnummer extends mfBaseModel {
|
||||
protected $forcestr = ["oaid","adrcd","subcd","extref","hausnummer","zusatz","grund_nr","gdaeigenschaft","meridian","rollout_info","rimo_fcp_name"];
|
||||
protected $forcestr = ["oaid","adrcd","extref","hausnummer","zusatz","grund_nr","gdaeigenschaft","meridian","rollout_info","rimo_fcp_name"];
|
||||
private $netzgebiet;
|
||||
private $ortschaft;
|
||||
private $strasse;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
class ADBHausnummerModel {
|
||||
public $oaid;
|
||||
public $adrcd;
|
||||
public $subcd;
|
||||
public $netzgebiet_id;
|
||||
public $extref;
|
||||
public $ortschaft_id;
|
||||
@@ -179,6 +180,15 @@ class ADBHausnummerModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("subcd", $filter)) {
|
||||
$subcd = FronkDB::singleton()->escape($filter['subcd']);
|
||||
if($subcd === false || $subcd === null) {
|
||||
$where .= " AND (Hausnummer.`subcd` IS NULL OR Hausnummer.`subcd` = 0)";
|
||||
}
|
||||
if($subcd) {
|
||||
$where .= " AND Hausnummer.`subcd` = $subcd";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("oaid", $filter)) {
|
||||
$oaid = FronkDB::singleton()->escape($filter['oaid']);
|
||||
|
||||
@@ -90,8 +90,8 @@ class Address extends mfBaseModel {
|
||||
"strasse" => $this->street,
|
||||
"plz" => $this->zip,
|
||||
"ort" => $this->city,
|
||||
"create_by" => $me->id,
|
||||
"edit_by" => $me->id
|
||||
"create_by" => 1,
|
||||
"edit_by" => 1
|
||||
]);
|
||||
$fibumerge->save();
|
||||
return true;
|
||||
@@ -284,6 +284,239 @@ class Address extends mfBaseModel {
|
||||
|
||||
}
|
||||
|
||||
public static function runBmdExport($request_type) {
|
||||
$last_export = 0;
|
||||
$log = mfLoghandler::singleton();
|
||||
|
||||
$export_ts = new mfConfig("bmd.export.ts");
|
||||
if($export_ts->value()) {
|
||||
$last_export = $export_ts->value();
|
||||
}
|
||||
|
||||
if(!file_exists(TT_ADDRESS_BMD_EXPORT_PATH)) {
|
||||
return 10;
|
||||
}
|
||||
$filepath = TT_ADDRESS_BMD_EXPORT_PATH."/".TT_ADDRESS_BMD_EXPORT_FILENAME;
|
||||
|
||||
$type = "inc";
|
||||
if($request_type == "full") {
|
||||
$last_export = 0;
|
||||
$type = "full";
|
||||
}
|
||||
|
||||
// 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];
|
||||
|
||||
if(!AddressModel::count($search)) {
|
||||
return 11;
|
||||
}
|
||||
|
||||
$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) {
|
||||
$addresses[$address->fibu_account_number] = $address;
|
||||
continue;
|
||||
}
|
||||
|
||||
// if only address with fibu_account_num -> make primary
|
||||
if($address->fibu_account_number && !$address->fibu_primary_account) {
|
||||
// look up other addresses with same account num
|
||||
$address_count = AddressModel::count(["fibu_account_number" => $address->fibu_account_number]);
|
||||
if($address_count === 1) {
|
||||
$address->fibu_primary_account = 1;
|
||||
$address->save();
|
||||
$addresses[$address->fibu_account_number] = $address;
|
||||
continue;
|
||||
}
|
||||
|
||||
// if more addresses with fibu_account_num -> find primary
|
||||
if($address_count > 1) {
|
||||
// find primary
|
||||
$primary = AddressModel::getFirst(["fibu_account_number" => $address->fibu_account_number, "fibu_primary_account" => true]);
|
||||
if($primary) {
|
||||
// use single primary
|
||||
$addresses[$primary->fibu_account_number] = $primary;
|
||||
continue;
|
||||
} else {
|
||||
// if no primary -> make last one primary
|
||||
$new_primary = false;
|
||||
foreach(AddressModel::search(["fibu_account_number" => $address->fibu_account_number]) as $primary) {
|
||||
$new_primary = $primary;
|
||||
}
|
||||
if(!$new_primary) {
|
||||
var_dump($address);exit;
|
||||
}
|
||||
$new_primary->fibu_primary_account = 1;
|
||||
$new_primary->save();
|
||||
$addresses[$new_primary->fibu_account_number] = $new_primary;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
var_dump($address);exit;
|
||||
}
|
||||
|
||||
// if no fibu account number but customer number -> create fibu account number
|
||||
if($address->customer_number && !$address->fibu_account_number) {
|
||||
// Address::afterSave() generates new fibu account number
|
||||
$address->save();
|
||||
if(!$address->fibu_account_number) {
|
||||
var_dump($address);exit;
|
||||
}
|
||||
$addresses[$address->fibu_account_number] = $address;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
$country_code_errors = [];
|
||||
$export_addresses = [];
|
||||
|
||||
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"] = $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;
|
||||
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");
|
||||
|
||||
$log->debug("is $cc == cc.$acountry");
|
||||
$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 == "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();
|
||||
}
|
||||
|
||||
$tpl = new Layout();
|
||||
$tpl->setTemplate("Address/bmd_export.csv");
|
||||
$tpl->set("addresses", $export_addresses);
|
||||
$csv_content = $tpl->render();
|
||||
$return_values = $tpl->getReturnedValue();
|
||||
$csv_header = $return_values['header'];
|
||||
|
||||
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) {
|
||||
return 19;
|
||||
} else {
|
||||
$export_ts->save();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
|
||||
@@ -24,9 +24,22 @@ class AddressController extends mfBaseController {
|
||||
$rfilter["addresstype"] = [];
|
||||
}
|
||||
|
||||
$this->layout->set("filter", $rfilter);
|
||||
if($this->request->resetFilter) {
|
||||
unset($_SESSION[MFAPPNAME.'-Address-filter']);
|
||||
}
|
||||
|
||||
$filter = $this->getPreparedFilter($rfilter);
|
||||
$filter = [];
|
||||
if(is_array($this->request->filter)) {
|
||||
$filter = $this->request->filter;
|
||||
$_SESSION[MFAPPNAME.'-Address-filter'] = $filter;
|
||||
} else {
|
||||
if(array_key_exists(MFAPPNAME.'-Address-filter', $_SESSION) && count($_SESSION[MFAPPNAME.'-Address-filter'])) {
|
||||
$filter = $_SESSION[MFAPPNAME.'-Address-filter'];
|
||||
}
|
||||
}
|
||||
|
||||
$this->layout->set("filter", $filter);
|
||||
$filter = $this->getPreparedFilter($filter);
|
||||
|
||||
// pagination defaults
|
||||
$pagination = [];
|
||||
@@ -54,22 +67,6 @@ class AddressController extends mfBaseController {
|
||||
$this->layout()->set("last_bmd_export", $last_export);
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
|
||||
//var_dump($this->request->filter);
|
||||
$default_filter = ['parents_only' => 1];
|
||||
if(is_array($this->request->filter) && count($this->request->filter)) {
|
||||
$filter = array_merge($default_filter, $this->request->filter);
|
||||
} else {
|
||||
$filter = $default_filter;
|
||||
}
|
||||
//var_dump($filter);exit;
|
||||
$addresses = AddressModel::search($filter);
|
||||
|
||||
$this->layout()->set("addresses", $addresses);
|
||||
$this->layout()->set("filter", $filter);
|
||||
$this->layout()->set("request", $this->request);
|
||||
}
|
||||
|
||||
|
||||
@@ -181,252 +178,34 @@ class AddressController extends mfBaseController {
|
||||
|
||||
}
|
||||
|
||||
protected function exportBmd() {
|
||||
/*$last_export = new mfConfig("bmd.export.ts");
|
||||
$last_export->type("int");
|
||||
$last_export->value(date("U"));
|
||||
$last_export->save();
|
||||
*/
|
||||
|
||||
protected function exportBmdAction() {
|
||||
if(!$this->me->can("Fibu")) {
|
||||
$this->layout()->setFlash("Sicha ned!", "error");
|
||||
$this->redirect("Address");
|
||||
}
|
||||
|
||||
$last_export = 0;
|
||||
$return = Address::runBmdExport($this->request->type);
|
||||
|
||||
$export_ts = new mfConfig("bmd.export.ts");
|
||||
if($export_ts->value()) {
|
||||
$last_export = $export_ts->value();
|
||||
}
|
||||
|
||||
if(!file_exists(TT_ADDRESS_BMD_EXPORT_PATH)) {
|
||||
if($return === 10) {
|
||||
$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";
|
||||
$this->redirect("Address");
|
||||
}
|
||||
|
||||
// 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];
|
||||
|
||||
if(!AddressModel::count($search)) {
|
||||
if($return === 11) {
|
||||
$this->layout()->setFlash("Keine geänderten Adressdatensätze gefunden. Export abgebrochen.", "warn");
|
||||
$this->redirect("Address");
|
||||
}
|
||||
|
||||
$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) {
|
||||
$addresses[$address->fibu_account_number] = $address;
|
||||
continue;
|
||||
}
|
||||
|
||||
// if only address with fibu_account_num -> make primary
|
||||
if($address->fibu_account_number && !$address->fibu_primary_account) {
|
||||
// look up other addresses with same account num
|
||||
$address_count = AddressModel::count(["fibu_account_number" => $address->fibu_account_number]);
|
||||
if($address_count === 1) {
|
||||
$address->fibu_primary_account = 1;
|
||||
$address->save();
|
||||
$addresses[$address->fibu_account_number] = $address;
|
||||
continue;
|
||||
}
|
||||
|
||||
// if more addresses with fibu_account_num -> find primary
|
||||
if($address_count > 1) {
|
||||
// find primary
|
||||
$primary = AddressModel::getFirst(["fibu_account_number" => $address->fibu_account_number, "fibu_primary_account" => true]);
|
||||
if($primary) {
|
||||
// use single primary
|
||||
$addresses[$primary->fibu_account_number] = $primary;
|
||||
continue;
|
||||
} else {
|
||||
// if no primary -> make last one primary
|
||||
$new_primary = false;
|
||||
foreach(AddressModel::search(["fibu_account_number" => $address->fibu_account_number]) as $primary) {
|
||||
$new_primary = $primary;
|
||||
}
|
||||
if(!$new_primary) {
|
||||
var_dump($address);exit;
|
||||
}
|
||||
$new_primary->fibu_primary_account = 1;
|
||||
$new_primary->save();
|
||||
$addresses[$new_primary->fibu_account_number] = $new_primary;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
var_dump($address);exit;
|
||||
}
|
||||
|
||||
// if no fibu account number but customer number -> create fibu account number
|
||||
if($address->customer_number && !$address->fibu_account_number) {
|
||||
// Address::afterSave() generates new fibu account number
|
||||
$address->save();
|
||||
if(!$address->fibu_account_number) {
|
||||
var_dump($address);exit;
|
||||
}
|
||||
$addresses[$address->fibu_account_number] = $address;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if($return === 19) {
|
||||
$this->layout()->setFlash("Datei ".TT_ADDRESS_BMD_EXPORT_PATH."/".TT_ADDRESS_BMD_EXPORT_FILENAME." konnte nicht gespeichert werden!", "error");
|
||||
$this->redirect("Address");
|
||||
}
|
||||
|
||||
$country_code_errors = [];
|
||||
$export_addresses = [];
|
||||
|
||||
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"] = $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;
|
||||
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 == "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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
$tpl = new Layout();
|
||||
$tpl->setTemplate("Address/bmd_export.csv");
|
||||
$tpl->set("addresses", $export_addresses);
|
||||
$csv_content = $tpl->render();
|
||||
$return_values = $tpl->getReturnedValue();
|
||||
$csv_header = $return_values['header'];
|
||||
|
||||
|
||||
|
||||
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();
|
||||
if($return === true) {
|
||||
$this->layout()->setFlash("Adressen erfolgreich exportiert", "success");
|
||||
$this->redirect("Address");
|
||||
}
|
||||
|
||||
$this->redirect("Address");
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -464,6 +243,8 @@ class AddressController extends mfBaseController {
|
||||
$data['uid'] = trim($r->uid);
|
||||
|
||||
if($this->me->can("Fibu")) {
|
||||
$data["sepa_date"] = ($r->sepa_date) ? Layout::dateToInt($r->sepa_date) : 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) {
|
||||
@@ -504,6 +285,13 @@ class AddressController extends mfBaseController {
|
||||
|
||||
if($r->billing_type == "sepa") {
|
||||
$data['billing_type'] = "sepa";
|
||||
if(!$r->sepa_date) {
|
||||
if($mode == "add" || ($mode == "edit" && !$address->sepa_date)) {
|
||||
$data['sepa_date'] = date('U');
|
||||
}
|
||||
} else {
|
||||
$data['sepa_date'] = $r->sepa_date;
|
||||
}
|
||||
} else {
|
||||
$data['billing_type'] = "invoice";
|
||||
}
|
||||
@@ -634,16 +422,12 @@ class AddressController extends mfBaseController {
|
||||
if($r->s) {
|
||||
$query['s'] = $r->s;
|
||||
}
|
||||
if($r->filter) {
|
||||
$query["filter"] = $r->filter;
|
||||
}
|
||||
if($r->return != "index") {
|
||||
$query['id'] = $new_id;
|
||||
}
|
||||
|
||||
$qs = http_build_query($query);
|
||||
|
||||
|
||||
$this->layout()->setFlash("Adresse erfolgreich gespeichert.", "success");
|
||||
if($r->return == "index") {
|
||||
$this->redirect("Address", "Index", $qs);
|
||||
|
||||
@@ -8,6 +8,7 @@ class AddressModel {
|
||||
public $fibu_supplier_due;
|
||||
public $fibu_supplier_skonto;
|
||||
public $fibu_supplier_skonto_rate;
|
||||
public $fibu_supplier_paymentblock;
|
||||
public $fibu_primary_account;
|
||||
public $spin;
|
||||
public $company;
|
||||
@@ -28,6 +29,7 @@ class AddressModel {
|
||||
public $bank_account_owner;
|
||||
public $bank_account_iban;
|
||||
public $bank_account_bic;
|
||||
public $sepa_date;
|
||||
public $allow_contact;
|
||||
public $allow_spin;
|
||||
|
||||
@@ -365,6 +367,14 @@ class AddressModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("billing_type", $filter)) {
|
||||
$billing_type = FronkDB::singleton()->escape($filter["billing_type"]);
|
||||
if($billing_type) {
|
||||
$where .= " AND billing_type='$billing_type'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Address Type
|
||||
*/
|
||||
|
||||
@@ -23,6 +23,7 @@ class AddressDB {
|
||||
`Hausnummer`.`id` AS `hausnummer_id`,
|
||||
`Hausnummer`.`oaid` AS `oaid`,
|
||||
`Hausnummer`.`adrcd` AS `adrcd`,
|
||||
`Hausnummer`.`subcd` AS `subcd`,
|
||||
`Hausnummer`.`oaid` AS `hausnummer_oaid`,
|
||||
`Hausnummer`.`hausnummer` AS `hausnummer`,
|
||||
`Hausnummer`.`extref` AS `hausnummer_extref`,
|
||||
@@ -36,6 +37,7 @@ class AddressDB {
|
||||
`Hausnummer`.`rollout` AS `rollout`,
|
||||
`Hausnummer`.`rollout_info` AS `rollout_info`,
|
||||
`Hausnummer`.`freigabe` AS `freigabe`,
|
||||
`Hausnummer`.`rimo_id` AS `hausnummer_rimo_id`,
|
||||
`Hausnummer`.`rimo_fcp_name` AS `rimo_fcp_name`,
|
||||
`Wohneinheit`.`id` AS `wohneinheit_id`,
|
||||
`Wohneinheit`.`oaid` AS `wohneinheit_oaid`,
|
||||
@@ -58,7 +60,7 @@ class AddressDB {
|
||||
left join `Ortschaft` on (`Ortschaft`.`id` = `Hausnummer`.`ortschaft_id`)
|
||||
left join `Gemeinde` on (`Gemeinde`.`id` = `Strasse`.`gemeinde_id`)
|
||||
left join `Wohneinheit` on (`Wohneinheit`.`hausnummer_id` = `Hausnummer`.`id`)
|
||||
left join `".FRONKDB_DBNAME."`.`Preorder` as tbl_preorder on (tbl_preorder.`adb_wohneinheit_id` = `Wohneinheit`.`id`)
|
||||
left join `".FRONKDB_DBNAME."`.`Preorder` as tbl_preorder on (tbl_preorder.`adb_wohneinheit_id` = `Wohneinheit`.`id` AND (tbl_preorder.`deleted` = 0 OR tbl_preorder.`deleted` IS NULL))
|
||||
left join `".FRONKDB_DBNAME."`.`Address` as tbl_address on (tbl_address.`id` = tbl_preorder.partner_id)
|
||||
";
|
||||
|
||||
@@ -230,6 +232,20 @@ class AddressDB {
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
|
||||
$adrcd = null;
|
||||
$subcd = null;
|
||||
|
||||
if(array_key_exists("adrcd", $data) && $data["adrcd"]) {
|
||||
$adr = trim($data["adrcd"]);
|
||||
$adr_parts = explode("-", $adr);
|
||||
if(count($adr_parts)) {
|
||||
$adrcd = $adr_parts[0];
|
||||
if(array_key_exists(1, $adr_parts)) {
|
||||
$subcd = $adr_parts[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// build hausnummer data
|
||||
//$hausnummer_data['oaid'] = (array_key_exists("oaid", $data) && $data['oaid']) ? $data['oaid'] : null;
|
||||
$hausnummer_data['adrcd'] = ($data['adrcd']) ? $data['adrcd'] : null;
|
||||
|
||||
@@ -11,8 +11,6 @@ class DashboardController extends mfBaseController {
|
||||
}
|
||||
|
||||
protected function indexAction() {
|
||||
|
||||
|
||||
if($this->me->is("preorderfront")) {
|
||||
$this->redirect("Preorder");
|
||||
}
|
||||
@@ -82,8 +80,8 @@ class DashboardController extends mfBaseController {
|
||||
$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);
|
||||
|
||||
$partner_orders_by_status = $this->getPartnerOrdersByStatus($campaign_ids);
|
||||
|
||||
$total_orders = $partner_orders["total"];
|
||||
unset($partner_orders["total"]);
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
class IvtBill extends mfBaseModel {
|
||||
|
||||
/**
|
||||
* Takes ID or DB row as arguments
|
||||
* @param id or table row $_
|
||||
*/
|
||||
public function __construct($_=NULL) {
|
||||
$this->log = mfLoghandler::singleton();
|
||||
$this->table = get_class($this);
|
||||
$this->data = new stdClass();
|
||||
$this->table = "bills";
|
||||
|
||||
$this->db = FronkDB::singleton(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME);
|
||||
|
||||
if(is_numeric($_)) {
|
||||
$this->fetch($_);
|
||||
} elseif(is_object($_)) {
|
||||
$this->load($_);
|
||||
}
|
||||
}
|
||||
|
||||
public function save() {
|
||||
throw new Exception("Cannot save Ivt Bills");
|
||||
}
|
||||
|
||||
public function __debugInfo() {
|
||||
$vars = get_object_vars($this);
|
||||
if(is_object($vars['db'])) $vars['db'] = "object(FronkDB)";
|
||||
if(is_object($vars['log'])) $vars['log'] = 'object(mfLoghandler)';
|
||||
return $vars;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
class IvtBillModel {
|
||||
|
||||
public static function create(Array $data) {
|
||||
throw new Exception("Please use IvtBillController to create IvtBills");
|
||||
}
|
||||
|
||||
public static function getAll() {
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME);
|
||||
|
||||
$res = $db->select("bills", "*", "1=1 ORDER BY id");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new IvtBill($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
public static function getFirst($filter = []) {
|
||||
$db = FronkDB::singleton(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("bills", "*", "$where ORDER BY id LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new IvtBill($data);
|
||||
if($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getLast($filter = []) {
|
||||
$db = FronkDB::singleton(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("bills", "*", "$where ORDER BY id DESC LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new IvtBill($data);
|
||||
if($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function search($filter, $limit = false) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT * FROM bills $where ORDER by id";
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
|
||||
} elseif(is_numeric($count)) {
|
||||
$sql .= " LIMIT ".$limit['count'];
|
||||
}
|
||||
}
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new IvtBill($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
private static function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
if(array_key_exists("cid", $filter)) {
|
||||
$cid = $filter['cid'];
|
||||
if(is_numeric($cid)) {
|
||||
$where .= " AND bills.cid=$cid";
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if(array_key_exists("status_id", $filter)) {
|
||||
$status_id = $filter['status_id'];
|
||||
if(is_numeric($status_id)) {
|
||||
$where .= " AND IvtBill.status_id=$status_id";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(array_key_exists("street", $filter)) {
|
||||
$street = FronkDB::singleton()->escape($filter["street"]);
|
||||
if($street) {
|
||||
$where .= " AND street like '%$street%'";
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -306,7 +306,7 @@ class LineworkController extends mfBaseController {
|
||||
|
||||
//var_dump($r->get());exit;
|
||||
|
||||
if($this->me->is(["Admin", "netowner","pipeplanner", "lineplanner"])) {
|
||||
if($r->isset("linework_enabled") && $this->me->is(["Admin", "pipeplanner", "lineplanner"])) {
|
||||
if($r->linework_enabled == 1 && $termination->linework_enabled != 1) {
|
||||
$termination->linework_enabled = 1;
|
||||
$termination->linework_enabled_date = date('U');
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
require_once APPDIR."/OpenAccessId/helper/rimo.php";
|
||||
|
||||
class OpenAccessId extends mfBaseModel {
|
||||
private $owner;
|
||||
private $adb_wohneinheit;
|
||||
@@ -46,6 +48,8 @@ class OpenAccessId extends mfBaseModel {
|
||||
|
||||
|
||||
public function exportToRimoAndAssignFtu() {
|
||||
$rimo = new OpenAccessId_Helper_Rimo($this->oaid);
|
||||
|
||||
// XXX for now only support ADB Addresses
|
||||
if(!$this->adb_wohneinheit_id) {
|
||||
return true;
|
||||
@@ -68,7 +72,10 @@ class OpenAccessId extends mfBaseModel {
|
||||
$unit_extdata = new StdClass();
|
||||
|
||||
if($wohneinheit->external_data) {
|
||||
$extdata = json_decode($wohneinheit->external_data);
|
||||
$json_data = json_decode($wohneinheit->external_data);
|
||||
if(is_object($json_data)) {
|
||||
$extdata = $json_data;
|
||||
}
|
||||
|
||||
if(is_object($extdata)) {
|
||||
$unit_extdata = $extdata;
|
||||
@@ -81,39 +88,7 @@ class OpenAccessId extends mfBaseModel {
|
||||
}
|
||||
|
||||
if($fetch_ftu) {
|
||||
// query Home to get FTU data from RIMO - GET /queryHomeWithId
|
||||
$params['apiKey'] = RIMO_API_JSON_APIKEY;
|
||||
$params["homeId"] = $wohneinheit->extref;
|
||||
|
||||
$ctx_opts = [
|
||||
'http' => [
|
||||
'method' => 'GET',
|
||||
'header' => 'accept: application/json'
|
||||
]
|
||||
];
|
||||
|
||||
$qs = http_build_query($params);
|
||||
//echo $qs."\n";
|
||||
|
||||
$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;
|
||||
$response = file_get_contents($get_url, false, $ctx);
|
||||
|
||||
if($response === false) {
|
||||
$this->log->error("Fehler beim auslesen der FTU ".$this->oaid."\n");
|
||||
return false;
|
||||
}
|
||||
//$preorder->workorder_export_date = date('U');
|
||||
//$preorder->workorder_export_data = $response;
|
||||
//$preorder->save();
|
||||
$resp_data = json_decode($response);
|
||||
if(!is_object($resp_data)) {
|
||||
$this->log->error(__METHOD__.": OAID ".$this->oaid.": Cannot fetch Home from RIMO! Invalid Response!");
|
||||
return false;
|
||||
}
|
||||
$resp_data = $rimo->getFtuData($wohneinheit->extref);
|
||||
|
||||
if(!is_array($resp_data->ftus->item) || !count($resp_data->ftus->item)) {
|
||||
$this->log->warning(__METHOD__.": Homes ftus object has no items ".$this->oaid);
|
||||
@@ -140,129 +115,60 @@ class OpenAccessId extends mfBaseModel {
|
||||
*/
|
||||
|
||||
$existing_rimo_export_data = $this->getExportData("rimo");
|
||||
if(!is_object($existing_rimo_export_data) || !isset($existing_rimo_export_data->oaid_id) || !isset($existing_rimo_export_data->name)) {
|
||||
$params = [];
|
||||
$params['apiKey'] = RIMO_API_JSON_APIKEY;
|
||||
$params['oaidName'] = $this->oaid;
|
||||
|
||||
$ctx_opts = [
|
||||
'http' => [
|
||||
'method' => 'POST',
|
||||
'header' => 'accept: application/json'
|
||||
]
|
||||
];
|
||||
//if(!is_object($existing_rimo_export_data) || (!isset($existing_rimo_export_data->oaid_id) || !$existing_rimo_export_data->oaid_id) || (!isset($existing_rimo_export_data->name) || !$existing_rimo_export_data->name)) {
|
||||
|
||||
$oaid_data = $rimo->getOaid();
|
||||
// try to create, if it fails, it already exists
|
||||
if(!$oaid_data) {
|
||||
$this->createInRimo();
|
||||
}
|
||||
|
||||
//$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']) {
|
||||
|
||||
$qs = http_build_query($params);
|
||||
//echo $qs."\n";
|
||||
$resp_data = $rimo->getOaid();
|
||||
|
||||
$createOrderEp = RIMO_API_JSON_URL.RIMO_API_JSON_EP_CREATE_OAID;
|
||||
$post_url = $createOrderEp."?".$qs;
|
||||
$ctx = stream_context_create($ctx_opts);
|
||||
$this->log->debug(__METHOD__.": Creating OAID in Rimo: $post_url");
|
||||
$response = file_get_contents($post_url, false, $ctx);
|
||||
//var_dump($response);exit;
|
||||
if($response === false) {
|
||||
$this->log->error("Fehler beim Erstellen der OAID in RIMO ".$this->oaid."\n");
|
||||
$workorders_failed++;
|
||||
return false;
|
||||
if(!$resp_data) {
|
||||
// oaid was not found in rimo, try creating it
|
||||
$this->createInRimo();
|
||||
$resp_data = $rimo->getOaid();
|
||||
}
|
||||
|
||||
$resp_data = json_decode($response);
|
||||
if(!$resp_data->id || !$resp_data->name) {
|
||||
$this->log->warning(__METHOD__.": Create OAID returned no ID or oaid name ".$this->oaid);
|
||||
return false;
|
||||
}
|
||||
$assign_oaid = false;
|
||||
|
||||
// mark OAID as exported
|
||||
$oaid_export_data = new StdClass();
|
||||
if($this->export_data) {
|
||||
$oaid_export_data = json_decode($this->export_data);
|
||||
}
|
||||
if(!isset($oaid_export_data->rimo)) {
|
||||
$oaid_export_data->rimo = new StdClass();
|
||||
}
|
||||
$oaid_export_data->rimo->oaid_id = $resp_data->id;
|
||||
$oaid_export_data->rimo->name = $resp_data->name;
|
||||
$oaid_export_data->rimo->ftu_id = null;
|
||||
$this->exported_to = "rimo";
|
||||
$this->exported = date('U');
|
||||
$this->export_data = json_encode($oaid_export_data);
|
||||
$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;
|
||||
if($resp_data && $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
|
||||
$resp_data = $rimo->unassignOaid($old_ftu_id);
|
||||
$assign_oaid = true;
|
||||
|
||||
}
|
||||
} else {
|
||||
$assign_oaid = true;
|
||||
}
|
||||
|
||||
if ($assign_oaid) {
|
||||
// assign oaid to Wohneinheit FTU
|
||||
$resp_data = $rimo->assignOaid($ftu_data['id']);
|
||||
|
||||
$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();
|
||||
}
|
||||
}
|
||||
// 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($exp_data_update);
|
||||
$this->save();
|
||||
}
|
||||
}
|
||||
//}
|
||||
|
||||
|
||||
|
||||
@@ -272,42 +178,19 @@ class OpenAccessId extends mfBaseModel {
|
||||
* assign OAID to FTU - POST /v1/oaid-management/oaids/{oaidName}/ftu/{ftuExternalId}
|
||||
*/
|
||||
|
||||
/*
|
||||
// check if we assigned the OAID to a RIMO FTU already
|
||||
$existing_rimo_export_data = $this->getExportData("rimo");
|
||||
if(!is_object($existing_rimo_export_data) || !isset($existing_rimo_export_data->oaid_id) || !isset($existing_rimo_export_data->ftu_id)) {
|
||||
$params = [];
|
||||
$params['apiKey'] = RIMO_API_JSON_APIKEY;
|
||||
|
||||
$ctx_opts = [
|
||||
'http' => [
|
||||
'method' => 'POST',
|
||||
'header' => 'accept: application/json'
|
||||
]
|
||||
];
|
||||
|
||||
$qs = http_build_query($params);
|
||||
//echo $qs."\n";
|
||||
|
||||
$createOrderEp = RIMO_API_JSON_URL.RIMO_API_JSON_EP_ASSIGN_OAID_TO_FTU;
|
||||
$createOrderEp = str_replace("{oaidName}", $this->oaid, $createOrderEp);
|
||||
$createOrderEp = str_replace("{ftuExternalId}", $unit_extdata->rimo->ftu->id, $createOrderEp);
|
||||
$post_url = $createOrderEp."?".$qs;
|
||||
|
||||
$ctx = stream_context_create($ctx_opts);
|
||||
$this->log->debug(__METHOD__.": Assigning OAID to FTU in Rimo: $post_url");
|
||||
|
||||
$response = file_get_contents($post_url, false, $ctx);
|
||||
|
||||
if($response === false) {
|
||||
$this->log->error("Fehler beim Zuweisen der OAID '".$this->oaid."' zu RIMO FTU '".$unit_extdata->rimo->ftu->id."'\n");
|
||||
$workorders_failed++;
|
||||
return false;
|
||||
}
|
||||
$resp_data = $rimo->assignOaid($unit_extdata->rimo->ftu->id);
|
||||
|
||||
// add FTU id to external_data
|
||||
$oaid_export_data = new StdClass();
|
||||
if($this->export_data) {
|
||||
$oaid_export_data = json_decode($this->export_data);
|
||||
$json_data = json_decode($this->export_data);
|
||||
if(is_object($json_data)) {
|
||||
$oaid_export_data = $json_data;
|
||||
}
|
||||
}
|
||||
if(!isset($oaid_export_data->rimo)) {
|
||||
$oaid_export_data->rimo = new StdClass();
|
||||
@@ -321,6 +204,36 @@ class OpenAccessId extends mfBaseModel {
|
||||
} else {
|
||||
$this->log->debug(__METHOD__.": OAID ".$this->oaid.": Already assigned to FTU in Rimo");
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
public function createInRimo() {
|
||||
$rimo = new OpenAccessId_Helper_Rimo($this->oaid);
|
||||
|
||||
$resp_data = $rimo->createOaid();
|
||||
if(!$resp_data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// mark OAID as exported
|
||||
$oaid_export_data = new StdClass();
|
||||
if($this->export_data) {
|
||||
$json_data = json_decode($this->export_data);
|
||||
if(is_object($json_data)) {
|
||||
$oaid_export_data = $json_data;
|
||||
}
|
||||
}
|
||||
if(!isset($oaid_export_data->rimo)) {
|
||||
$oaid_export_data->rimo = new StdClass();
|
||||
}
|
||||
$oaid_export_data->rimo->oaid_id = $resp_data->id;
|
||||
$oaid_export_data->rimo->name = $resp_data->name;
|
||||
$oaid_export_data->rimo->ftu_id = null;
|
||||
$this->exported_to = "rimo";
|
||||
$this->exported = date('U');
|
||||
$this->export_data = json_encode($oaid_export_data);
|
||||
$this->save();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -108,7 +108,9 @@ class OpenAccessIdController extends mfBaseController {
|
||||
// get old and new unit_id
|
||||
$old_unit = ADBWohneinheitModel::getFirst(["oaid" => $oaid->oaid]);
|
||||
$new_unit = new ADBWohneinheit($this->request->new_unit_id);
|
||||
|
||||
if(!$new_unit->id) {
|
||||
$new_unit = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
|
||||
class OpenAccessId_Helper_Rimo {
|
||||
private $log;
|
||||
public $oaid;
|
||||
|
||||
public function __construct($oaid) {
|
||||
$this->oaid = $oaid;
|
||||
$this->log = mfLoghandler::singleton();
|
||||
}
|
||||
|
||||
public function getFtuData($home_external_id) {
|
||||
// query Home to get FTU data from RIMO - GET /queryHomeWithId
|
||||
$params = [];
|
||||
$params['apiKey'] = RIMO_API_JSON_APIKEY;
|
||||
$params["homeId"] = $home_external_id;
|
||||
|
||||
$ctx_opts = [
|
||||
'http' => [
|
||||
'method' => 'GET',
|
||||
'header' => 'accept: application/json'
|
||||
]
|
||||
];
|
||||
|
||||
$qs = http_build_query($params);
|
||||
//echo $qs."\n";
|
||||
|
||||
$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");
|
||||
$response = file_get_contents($get_url, false, $ctx);
|
||||
|
||||
if($response === false) {
|
||||
$this->log->error("Fehler beim auslesen der FTU ".$this->oaid);
|
||||
return false;
|
||||
}
|
||||
|
||||
$resp_data = json_decode($response);
|
||||
if(!is_object($resp_data)) {
|
||||
$this->log->error(__METHOD__.": OAID ".$this->oaid.": Cannot fetch Home from RIMO! Invalid Response!");
|
||||
return false;
|
||||
}
|
||||
|
||||
return $resp_data;
|
||||
}
|
||||
|
||||
public function getOaid() {
|
||||
$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);
|
||||
return false;
|
||||
}
|
||||
|
||||
$resp_data = json_decode($response);
|
||||
if(!is_object($resp_data)) {
|
||||
$this->log->error(__METHOD__.": OAID ".$this->oaid.": Cannot fetch OAID from RIMO! Invalid Response!");
|
||||
return false;
|
||||
}
|
||||
|
||||
return $resp_data;
|
||||
}
|
||||
|
||||
public function createOaid() {
|
||||
$params = [];
|
||||
$params['apiKey'] = RIMO_API_JSON_APIKEY;
|
||||
$params['oaidName'] = $this->oaid;
|
||||
|
||||
$ctx_opts = [
|
||||
'http' => [
|
||||
'method' => 'POST',
|
||||
'header' => 'accept: application/json'
|
||||
]
|
||||
];
|
||||
|
||||
$qs = http_build_query($params);
|
||||
//echo $qs."\n";
|
||||
|
||||
$createOrderEp = RIMO_API_JSON_URL.RIMO_API_JSON_EP_CREATE_OAID;
|
||||
$post_url = $createOrderEp."?".$qs;
|
||||
$ctx = stream_context_create($ctx_opts);
|
||||
$this->log->debug(__METHOD__.": Creating OAID in Rimo: $post_url");
|
||||
$response = file_get_contents($post_url, false, $ctx);
|
||||
//var_dump($response);exit;
|
||||
if($response === false) {
|
||||
$this->log->error("Fehler beim Erstellen der OAID in RIMO ".$this->oaid);
|
||||
return false;
|
||||
}
|
||||
|
||||
$resp_data = json_decode($response);
|
||||
if(!$resp_data->id || !$resp_data->name) {
|
||||
$this->log->warning(__METHOD__.": Create OAID returned no ID or oaid name ".$this->oaid);
|
||||
return false;
|
||||
}
|
||||
|
||||
return $resp_data;
|
||||
}
|
||||
|
||||
public function unassignOaid($ftu_external_id) {
|
||||
$params = [];
|
||||
$params['apiKey'] = RIMO_API_JSON_APIKEY;
|
||||
|
||||
$ctx_opts = [
|
||||
'http' => [
|
||||
'method' => 'DELETE',
|
||||
'header' => 'accept: application/json'
|
||||
]
|
||||
];
|
||||
|
||||
$qs = http_build_query($params);
|
||||
|
||||
$unassignEp = RIMO_API_JSON_URL.RIMO_API_JSON_EP_UNASSIGN_OAID_TO_FTU;
|
||||
$unassignEp = str_replace("{oaidName}", $this->oaid, $unassignEp);
|
||||
$unassignEp = str_replace("{ftuExternalId}", $ftu_external_id, $unassignEp);
|
||||
|
||||
$delete_url = $unassignEp."?".$qs;
|
||||
$ctx = stream_context_create($ctx_opts);
|
||||
$this->log->debug(__METHOD__.": Unassigning OAID from FTU $ftu_external_id: $delete_url");
|
||||
$response = file_get_contents($delete_url, false, $ctx);
|
||||
|
||||
if($response === false) {
|
||||
$this->log->error("Fehler beim Unassignen der OAID in RIMO ".$this->oaid.": $delete_url");
|
||||
return false;
|
||||
}
|
||||
|
||||
$resp_data = json_decode($response);
|
||||
return $resp_data;
|
||||
}
|
||||
|
||||
public function assignOaid($ftu_external_id) {
|
||||
$params = [];
|
||||
$params['apiKey'] = RIMO_API_JSON_APIKEY;
|
||||
|
||||
$ctx_opts = [
|
||||
'http' => [
|
||||
'method' => 'POST',
|
||||
'header' => 'accept: application/json'
|
||||
]
|
||||
];
|
||||
|
||||
$qs = http_build_query($params);
|
||||
|
||||
$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_external_id, $assignEp);
|
||||
|
||||
$post_url = $assignEp."?".$qs;
|
||||
$ctx = stream_context_create($ctx_opts);
|
||||
$this->log->debug(__METHOD__.": Assigning OAID to current FTU $ftu_external_id: $post_url");
|
||||
$response = file_get_contents($post_url, false, $ctx);
|
||||
|
||||
if($response === false) {
|
||||
$this->log->error("Fehler beim Assignen der OAID ".$this->oaid." in RIMO ".$this->oaid);
|
||||
return false;
|
||||
}
|
||||
|
||||
$resp_data = json_decode($response);
|
||||
return $resp_data;
|
||||
}
|
||||
}
|
||||
@@ -498,6 +498,10 @@ class OrderController extends mfBaseController {
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
/*
|
||||
* Contacts/Addresses and Billing data
|
||||
*/
|
||||
|
||||
// validate owner
|
||||
$owner = false;
|
||||
$owner_new = false;
|
||||
@@ -642,6 +646,7 @@ class OrderController extends mfBaseController {
|
||||
if($billingaddress_new) {
|
||||
if($r->billing_type == "sepa") {
|
||||
$billing_data['billing_type'] = "sepa";
|
||||
$billing_data['sepa_date'] = date("U");
|
||||
} else {
|
||||
$billing_data['billing_type'] = "invoice";
|
||||
}
|
||||
@@ -659,6 +664,7 @@ class OrderController extends mfBaseController {
|
||||
} elseif($owner_new) {
|
||||
if($r->billing_type == "sepa") {
|
||||
$owner_data['billing_type'] = "sepa";
|
||||
$owner_data['sepa_date'] = date("U");
|
||||
} else {
|
||||
$owner_data['billing_type'] = "invoice";
|
||||
}
|
||||
@@ -685,6 +691,20 @@ class OrderController extends mfBaseController {
|
||||
$techcontact = AddressModel::create($techcontact_data);
|
||||
}
|
||||
|
||||
// set sepa date if not yet set and sepa is active
|
||||
if($billingaddress) {
|
||||
if($billingaddress->billing_type == "sepa" && !$billingaddress->sepa_date) {
|
||||
$billingaddress->sepa_date = date("U");
|
||||
$billingaddress->save();
|
||||
}
|
||||
} else {
|
||||
if($owner->billing_type == "sepa" && !$owner->sepa_date) {
|
||||
$owner->sepa_date = date("U");
|
||||
$owner->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// create or save Order object
|
||||
|
||||
$order_data = [];
|
||||
@@ -703,7 +723,7 @@ class OrderController extends mfBaseController {
|
||||
$order_data['allow_spin'] = ($r->allow_spin) ? 1 : 0;
|
||||
$order_data['note'] = $r->note;
|
||||
|
||||
$order_data['order_date'] = Layout::dateToInt($r->order_date);
|
||||
$order_data['order_date'] = ($order_data['order_date']) ? Layout::dateToInt($r->order_date) : null;
|
||||
|
||||
if($r->finish_after) {
|
||||
$order_data['finish_after'] = Layout::dateToInt($r->finish_after);
|
||||
@@ -876,6 +896,7 @@ class OrderController extends mfBaseController {
|
||||
$product_data["billing_delay"] = 6;
|
||||
}
|
||||
$product_data["billing_period"] = $p["billing_period"];
|
||||
$product_data["contract_term"] = $p["contract_term"];
|
||||
|
||||
$product_data['upgrade'] = $order_data['upgrade'];
|
||||
|
||||
@@ -912,6 +933,7 @@ class OrderController extends mfBaseController {
|
||||
$product_data['voicenumber'] = null;
|
||||
}
|
||||
|
||||
$product_data['edit_by'] = $this->me->id;
|
||||
|
||||
if(!$orderproduct_id) {
|
||||
$product = OrderProductModel::create($product_data);
|
||||
|
||||
@@ -284,6 +284,20 @@ class OrderModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("finish_date>", $filter)) {
|
||||
$finish_date = $filter['finish_date>'];
|
||||
if($finish_date) {
|
||||
$where .= " AND `Order`.finish_date > $finish_date";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("finish_date<", $filter)) {
|
||||
$finish_date = $filter['finish_date<'];
|
||||
if($finish_date) {
|
||||
$where .= " AND `Order`.finish_date < $finish_date";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("upgrade", $filter)) {
|
||||
if($filter['upgrade'] == 1) {
|
||||
$where .= " AND `Order`.upgrade = 1";
|
||||
|
||||
@@ -15,6 +15,7 @@ class OrderProductModel
|
||||
public $price_nbe;
|
||||
public $billing_delay;
|
||||
public $billing_period;
|
||||
public $contract_term;
|
||||
public $note;
|
||||
|
||||
public $create_by = null;
|
||||
|
||||
@@ -300,7 +300,7 @@ class PipeworkController extends mfBaseController {
|
||||
|
||||
//var_dump($r->get());exit;
|
||||
|
||||
if($this->me->is(["Admin", "netowner", "pipeplanner"])) {
|
||||
if($r->isset("pipework_enabled") && $this->me->is(["Admin", "pipeplanner"])) {
|
||||
if($r->pipework_enabled == 1 && $building->pipework_enabled != 1) {
|
||||
$building->pipework_enabled = 1;
|
||||
$building->pipework_enabled_date = date('U');
|
||||
|
||||
@@ -321,11 +321,9 @@ class Preorder extends mfBaseModel {
|
||||
if($this->adb_wohneinheit_id) {
|
||||
$unit = new ADBWohneinheit($this->adb_wohneinheit_id);
|
||||
if($unit && $unit->oaid && $this->oaid != $unit->oaid) {
|
||||
|
||||
$campaign = new Preordercampaign($this->preordercampaign_id);
|
||||
$unit_oaid = OpenAccessIdModel::getFirst(["oaid" => $unit->oaid]);
|
||||
|
||||
if($unit_oaid->origin == $campaign->oaid_origin) {
|
||||
if($unit_oaid && $unit_oaid->origin == $campaign->oaid_origin) {
|
||||
return $unit->oaid;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,14 +175,30 @@ class PreorderController extends mfBaseController {
|
||||
|
||||
$new_filter['add-where'] = "";
|
||||
|
||||
if(array_key_exists("search",$filter) && trim($filter['search'])) {
|
||||
$search = trim($filter['search']);
|
||||
if(array_key_exists("magic_search",$filter) && trim($filter['magic_search'])) {
|
||||
$search = trim($filter['magic_search']);
|
||||
$new_filter['add-where'] .= " AND (";
|
||||
$new_filter['add-where'] .= " adb_hausnummer.gemeinde like '%$search%' OR adb_hausnummer.plz like '%$search%' OR adb_hausnummer.strasse like '%$search%'";
|
||||
$new_filter['add-where'] .= " OR company like '%$search%' OR firstname like '%$search%' OR lastname like '%$search%' OR concat(firstname, ' ', lastname) like '%$search%' OR concat(lastname, ' ', firstname) like '%$search%' OR street like '%$search%' OR zip like '%$search%' OR city like '%$search%' OR email like '%$search' OR phone like '%$search'";
|
||||
$new_filter['add-where'] .= " OR ucode like '%$search' OR oaid like '%$search'";
|
||||
$new_filter['add-where'] .= " adb_hausnummer.gemeinde like '%$search%' OR adb_hausnummer.plz like '%$search%' OR adb_hausnummer.strasse like '%$search%'
|
||||
OR adb_hausnummer.hausnummer like '%$search%' OR CONCAT (adb_hausnummer.strasse, ' ', adb_hausnummer.hausnummer) like '%$search%'
|
||||
OR CONCAT (adb_hausnummer.strasse, ' ', adb_hausnummer.hausnummer) like '%".str_replace(" ", "%", $search)."%'";
|
||||
$new_filter['add-where'] .= " OR company like '%$search%' OR firstname like '%$search%' OR lastname like '%$search%' OR concat(firstname, ' ', lastname) like '%$search%' OR concat(lastname, ' ', firstname) like '%$search%' OR street like '%$search%' OR zip like '%$search%' OR city like '%$search%' OR email like '%$search%' OR phone like '%$search%'";
|
||||
$new_filter['add-where'] .= " OR tt_preorder.ucode like '%$search%' OR tt_preorder.oaid like '%$search%'";
|
||||
|
||||
$new_filter['add-where'] .= " OR adb_wohneinheit.extref like '%$search%'";
|
||||
$new_filter['add-where'] .= " OR adb_hausnummer.hausnummer_extref like '%$search%'";
|
||||
$new_filter['add-where'] .= " OR adb_hausnummer.adrcd like '%$search%'";
|
||||
$new_filter['add-where'] .= " OR adb_hausnummer.grund_nr like '%$search%'";
|
||||
|
||||
$new_filter['add-where'] .= " OR adb_hausnummer.rimo_fcp_name like '%$search%'";
|
||||
$new_filter['add-where'] .= " OR workorder.rimo_status like '%$search%'";
|
||||
$new_filter['add-where'] .= " OR workorder.rimo_name like '%$search%'";
|
||||
|
||||
//$new_filter['add-where'] .= " OR ";
|
||||
$new_filter['add-where'] .= " )";
|
||||
}
|
||||
|
||||
//echo $new_filter['add-where'];exit;
|
||||
|
||||
if(array_key_exists("address", $filter) && $filter["address"]) {
|
||||
$address = $this->db()->escape($filter['address']);
|
||||
$new_filter['add-where'] .= " AND (adb_hausnummer.gemeinde like '%$address%' OR adb_hausnummer.plz like '%$address%' OR adb_hausnummer.strasse like '%$address%'
|
||||
@@ -241,6 +257,14 @@ class PreorderController extends mfBaseController {
|
||||
unset($filter['rimo_workorder']);
|
||||
}
|
||||
|
||||
if(array_key_exists("rimo_workorder_status", $filter) && $filter['rimo_workorder_status']) {
|
||||
$new_filter["rimo_workorder_status"] = $filter['rimo_workorder_status'];
|
||||
}
|
||||
|
||||
if(array_key_exists("rimo_workorder_name", $filter) && $filter['rimo_workorder_name']) {
|
||||
$new_filter["rimo_workorder_name"] = $filter['rimo_workorder_name'];
|
||||
}
|
||||
|
||||
if(array_key_exists("ucode", $filter) && $filter['ucode']) {
|
||||
$new_filter['ucode'] = "%".$filter['ucode']."%";
|
||||
unset($filter['ucode']);
|
||||
@@ -438,8 +462,8 @@ class PreorderController extends mfBaseController {
|
||||
|
||||
$data['company'] = (trim($r->company)) ? trim($r->company) : null;
|
||||
$data['uid'] = (trim($r->uid)) ? trim($r->uid) : null;
|
||||
$data['firstname'] = (trim($r->firstname)) ? trim($r->firstname) : null;
|
||||
$data['lastname'] = (trim($r->lastname)) ? trim($r->lastname) : null;
|
||||
$data['firstname'] = trim($r->firstname);
|
||||
$data['lastname'] = trim($r->lastname);
|
||||
$data['street'] = (trim($r->street)) ? trim($r->street) : null;
|
||||
$data['housenumber'] = (trim($r->housenumber)) ? trim($r->housenumber) : null;
|
||||
$data['block'] = (trim($r->block)) ? trim($r->block) : null;
|
||||
@@ -724,7 +748,7 @@ class PreorderController extends mfBaseController {
|
||||
|
||||
$preorder->deleted = date('U');
|
||||
$preorder->deleted_by = $this->me->id;
|
||||
$preorder->status_id = 15; // 899 - Cancelled
|
||||
$preorder->status_id = 23; // 910 - Cancelled (ohne weitere Begründung)
|
||||
$preorder->save();
|
||||
|
||||
$this->layout()->setFlash("Vorbestellung erfolgreich gelöscht!", "success");
|
||||
|
||||
@@ -142,7 +142,7 @@ class PreorderModel {
|
||||
LEFT JOIN `".FRONKDB_DBNAME."`.Preorderstatus tt_preorderstatus ON (tt_preorder.status_id = tt_preorderstatus.id)
|
||||
LEFT JOIN `".ADDRESSDB_DBNAME."`.view_hausnummer as adb_hausnummer ON (tt_preorder.adb_hausnummer_id = adb_hausnummer.hausnummer_id)
|
||||
LEFT JOIN `".ADDRESSDB_DBNAME."`.Wohneinheit as adb_wohneinheit ON (tt_preorder.adb_wohneinheit_id = adb_wohneinheit.id)
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt FROM `".FRONKDB_DBNAME."`.RimoWorkorder GROUP BY adb_wohneinheit_id) wocount ON adb_wohneinheit.id = wocount.adb_wohneinheit_id
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt, MAX(rimo_status) as rimo_status, MAX(rimo_name) as rimo_name FROM `".FRONKDB_DBNAME."`.RimoWorkorder GROUP BY adb_wohneinheit_id) workorder ON adb_wohneinheit.id = workorder.adb_wohneinheit_id
|
||||
WHERE $where
|
||||
ORDER BY $orderBy
|
||||
LIMIT 1";
|
||||
@@ -171,7 +171,7 @@ class PreorderModel {
|
||||
LEFT JOIN `".FRONKDB_DBNAME."`.Preorderstatus tt_preorderstatus ON (tt_preorder.status_id = tt_preorderstatus.id)
|
||||
LEFT JOIN `".ADDRESSDB_DBNAME."`.view_hausnummer as adb_hausnummer ON (tt_preorder.adb_hausnummer_id = adb_hausnummer.hausnummer_id)
|
||||
LEFT JOIN `".ADDRESSDB_DBNAME."`.Wohneinheit as adb_wohneinheit ON (tt_preorder.adb_wohneinheit_id = adb_wohneinheit.id)
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt FROM `".FRONKDB_DBNAME."`.RimoWorkorder GROUP BY adb_wohneinheit_id) wocount ON adb_wohneinheit.id = wocount.adb_wohneinheit_id
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt, MAX(rimo_status) as rimo_status, MAX(rimo_name) as rimo_name FROM `".FRONKDB_DBNAME."`.RimoWorkorder GROUP BY adb_wohneinheit_id) workorder ON adb_wohneinheit.id = workorder.adb_wohneinheit_id
|
||||
LEFT JOIN Preorderlogistics ON (Preorderlogistics.preorder_id = tt_preorder.id)
|
||||
WHERE $where
|
||||
";
|
||||
@@ -196,7 +196,7 @@ class PreorderModel {
|
||||
LEFT JOIN `".FRONKDB_DBNAME."`.Preorderstatus tt_preorderstatus ON (tt_preorder.status_id = tt_preorderstatus.id)
|
||||
LEFT JOIN `".ADDRESSDB_DBNAME."`.view_hausnummer as adb_hausnummer ON (tt_preorder.adb_hausnummer_id = adb_hausnummer.hausnummer_id)
|
||||
LEFT JOIN `".ADDRESSDB_DBNAME."`.Wohneinheit as adb_wohneinheit ON (tt_preorder.adb_wohneinheit_id = adb_wohneinheit.id)
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt FROM `".FRONKDB_DBNAME."`.RimoWorkorder GROUP BY adb_wohneinheit_id) wocount ON adb_wohneinheit.id = wocount.adb_wohneinheit_id
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt, MAX(rimo_status) as rimo_status, MAX(rimo_name) as rimo_name FROM `".FRONKDB_DBNAME."`.RimoWorkorder GROUP BY adb_wohneinheit_id) workorder ON adb_wohneinheit.id = workorder.adb_wohneinheit_id
|
||||
LEFT JOIN Preorderlogistics ON (Preorderlogistics.preorder_id = tt_preorder.id)
|
||||
WHERE $where
|
||||
ORDER BY lastname, firstname
|
||||
@@ -240,8 +240,8 @@ class PreorderModel {
|
||||
SELECT tt_preorder.* FROM`".FRONKDB_DBNAME."`.Preorder tt_preorder
|
||||
LEFT JOIN `".FRONKDB_DBNAME."`.Preorderstatus as tt_preorderstatus ON (tt_preorder.status_id = tt_preorderstatus.id)
|
||||
LEFT JOIN `".ADDRESSDB_DBNAME."`.view_hausnummer as adb_hausnummer ON (tt_preorder.adb_hausnummer_id = adb_hausnummer.hausnummer_id)
|
||||
LEFT JOIN `".ADDRESSDB_DBNAME."`.Wohneinheit as adb_wohneinheit ON (tt_preorder.adb_wohneinheit_id = adb_wohneinheit.id),
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt FROM `".FRONKDB_DBNAME."`.RimoWorkorder GROUP BY adb_wohneinheit_id) wocount ON adb_wohneinheit.id = wocount.adb_wohneinheit_id
|
||||
LEFT JOIN `".ADDRESSDB_DBNAME."`.Wohneinheit as adb_wohneinheit ON (tt_preorder.adb_wohneinheit_id = adb_wohneinheit.id)
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt, MAX(rimo_status) as rimo_status, MAX(rimo_name) as rimo_name FROM `".FRONKDB_DBNAME."`.RimoWorkorder GROUP BY adb_wohneinheit_id) workorder ON adb_wohneinheit.id = workorder.adb_wohneinheit_id,
|
||||
JSON_TABLE(tt_preorder.addon_services,
|
||||
'$[*]' COLUMNS (
|
||||
ordered VARCHAR(64) PATH '$.ordered'
|
||||
@@ -272,8 +272,8 @@ class PreorderModel {
|
||||
$sql = "SELECT tt_preorder.* FROM `".FRONKDB_DBNAME."`.Preorder tt_preorder
|
||||
LEFT JOIN `".FRONKDB_DBNAME."`.Preorderstatus as tt_preorderstatus ON (tt_preorder.status_id = tt_preorderstatus.id)
|
||||
LEFT JOIN `".ADDRESSDB_DBNAME."`.view_hausnummer as adb_hausnummer ON (tt_preorder.adb_hausnummer_id = adb_hausnummer.hausnummer_id)
|
||||
LEFT JOIN `".ADDRESSDB_DBNAME."`.Wohneinheit as adb_wohneinheit ON (tt_preorder.adb_wohneinheit_id = adb_wohneinheit.id),
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt FROM `".FRONKDB_DBNAME."`.RimoWorkorder GROUP BY adb_wohneinheit_id) wocount ON adb_wohneinheit.id = wocount.adb_wohneinheit_id
|
||||
LEFT JOIN `".ADDRESSDB_DBNAME."`.Wohneinheit as adb_wohneinheit ON (tt_preorder.adb_wohneinheit_id = adb_wohneinheit.id)
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt, MAX(rimo_status) as rimo_status, MAX(rimo_name) as rimo_name FROM `".FRONKDB_DBNAME."`.RimoWorkorder GROUP BY adb_wohneinheit_id) workorder ON adb_wohneinheit.id = workorder.adb_wohneinheit_id,
|
||||
JSON_TABLE(tt_preorder.addon_services,
|
||||
'$[*]' COLUMNS (
|
||||
ordered VARCHAR(64) PATH '$.ordered'
|
||||
@@ -313,7 +313,7 @@ class PreorderModel {
|
||||
LEFT JOIN `".FRONKDB_DBNAME."`.Preorderstatus tt_preorderstatus ON (tt_preorder.status_id = tt_preorderstatus.id)
|
||||
LEFT JOIN `".ADDRESSDB_DBNAME."`.view_hausnummer as adb_hausnummer ON (tt_preorder.adb_hausnummer_id = adb_hausnummer.hausnummer_id)
|
||||
LEFT JOIN `".ADDRESSDB_DBNAME."`.Wohneinheit as adb_wohneinheit ON (tt_preorder.adb_wohneinheit_id = adb_wohneinheit.id)
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt FROM `".FRONKDB_DBNAME."`.RimoWorkorder GROUP BY adb_wohneinheit_id) wocount ON adb_wohneinheit.id = wocount.adb_wohneinheit_id
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt, MAX(rimo_status) as rimo_status, MAX(rimo_name) as rimo_name FROM `".FRONKDB_DBNAME."`.RimoWorkorder GROUP BY adb_wohneinheit_id) workorder ON adb_wohneinheit.id = workorder.adb_wohneinheit_id
|
||||
WHERE $where
|
||||
";
|
||||
|
||||
@@ -337,7 +337,7 @@ class PreorderModel {
|
||||
LEFT JOIN `".FRONKDB_DBNAME."`.Preorderstatus tt_preorderstatus ON (tt_preorder.status_id = tt_preorderstatus.id)
|
||||
LEFT JOIN `".ADDRESSDB_DBNAME."`.view_hausnummer as adb_hausnummer ON (tt_preorder.adb_hausnummer_id = adb_hausnummer.hausnummer_id)
|
||||
LEFT JOIN `".ADDRESSDB_DBNAME."`.Wohneinheit as adb_wohneinheit ON (tt_preorder.adb_wohneinheit_id = adb_wohneinheit.id)
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt FROM `".FRONKDB_DBNAME."`.RimoWorkorder GROUP BY adb_wohneinheit_id) wocount ON adb_wohneinheit.id = wocount.adb_wohneinheit_id
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt, MAX(rimo_status) as rimo_status, MAX(rimo_name) as rimo_name FROM `".FRONKDB_DBNAME."`.RimoWorkorder GROUP BY adb_wohneinheit_id) workorder ON adb_wohneinheit.id = workorder.adb_wohneinheit_id
|
||||
WHERE $where
|
||||
ORDER BY lastname, firstname
|
||||
";
|
||||
@@ -568,9 +568,23 @@ class PreorderModel {
|
||||
if(array_key_exists("rimo_workorder", $filter)) {
|
||||
$rimo_workorder = $filter['rimo_workorder'];
|
||||
if($rimo_workorder === null || $rimo_workorder === false) {
|
||||
$where .= " AND (wocount.cnt IS NULL OR wocount.cnt = 0)";
|
||||
$where .= " AND (workorder.cnt IS NULL OR workorder.cnt = 0)";
|
||||
} elseif($rimo_workorder) {
|
||||
$where .= " AND wocount.cnt > 0";
|
||||
$where .= " AND workorder.cnt > 0";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("rimo_workorder_status", $filter)) {
|
||||
$rimo_workorder_status = FronkDB::singleton()->escape($filter['rimo_workorder_status']);
|
||||
if($rimo_workorder_status) {
|
||||
$where .= " AND workorder.rimo_status = '$rimo_workorder_status'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("rimo_workorder_name", $filter)) {
|
||||
$rimo_workorder_name = FronkDB::singleton()->escape($filter['rimo_workorder_name']);
|
||||
if($rimo_workorder_name) {
|
||||
$where .= " AND workorder.rimo_name = '$rimo_workorder_name'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -529,7 +529,7 @@ class PreordercampaignController extends mfBaseController {
|
||||
$assigned_oaids = 0;
|
||||
$multiple_unit = 0;
|
||||
|
||||
foreach(PreorderModel::search(["preordercampaign_id" => $id, "oaid" => null, 'deleted' => 0]) as $preorder) {
|
||||
foreach(PreorderModel::search(["preordercampaign_id" => $id, "oaid" => null, "connection_count" => 1, 'deleted' => 0]) as $preorder) {
|
||||
if($preorder->type == "interest") {
|
||||
continue;
|
||||
}
|
||||
@@ -608,7 +608,7 @@ class PreordercampaignController extends mfBaseController {
|
||||
$workorders_created = 0;
|
||||
$workorders_failed = 0;
|
||||
|
||||
foreach(PreorderModel::search(["preordercampaign_id" => $id, "rimo_workorder" => false, 'deleted' => 0]) as $preorder) {
|
||||
foreach(PreorderModel::search(["preordercampaign_id" => $id, "rimo_workorder" => false, "connection_count" => 1, 'deleted' => 0]) as $preorder) {
|
||||
if($preorder->workorder_export_date) {
|
||||
$this->log->warning(__METHOD__.": workorder_export_date not null");
|
||||
}
|
||||
@@ -754,7 +754,7 @@ class PreordercampaignController extends mfBaseController {
|
||||
$missing_extrefs = 0;
|
||||
$missing_oaid = 0;
|
||||
|
||||
foreach(PreorderModel::search(["preordercampaign_id" => $id, 'deleted' => 0]) as $preorder) {
|
||||
foreach(PreorderModel::search(["preordercampaign_id" => $id, "connection_count" => 1, 'deleted' => 0]) as $preorder) {
|
||||
if($preorder->type == "interest") {
|
||||
$this->log->debug(__METHOD__.": Ignoring Preorder ".$preorder->id.": is interest");
|
||||
continue;
|
||||
|
||||
@@ -34,6 +34,7 @@ class Product extends mfBaseModel {
|
||||
$attrib->note = $pta->note;
|
||||
}
|
||||
$attrib->name = $pta->name;
|
||||
$attrib->type = $pta->type;
|
||||
$attrib->displayname = $pta->displayname;
|
||||
$attrib->description = $pta->description;
|
||||
$this->attributes[$attrib->name] = $attrib;
|
||||
|
||||
@@ -156,6 +156,7 @@ class ProductController extends mfBaseController {
|
||||
$data['price_setup'] = ($r->price_setup) ? Layout::commaToDot($r->price_setup) : 0;
|
||||
$data['billing_period'] = $r->billing_period;
|
||||
$data['billing_delay'] = ($r->billing_delay) ? $r->billing_delay : 0;
|
||||
$data['contract_term'] = $r->contract_term;
|
||||
$data['ivt_id'] = ($r->ivt_id) ? $r->ivt_id : null;
|
||||
$data['note'] = $r->note;
|
||||
|
||||
@@ -316,7 +317,7 @@ class ProductController extends mfBaseController {
|
||||
if(!$product->id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(is_array($product->attributes) && count($product->attributes)) {
|
||||
$attributes = $product->attributes;
|
||||
$product->data->attributes = [];
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
<?php
|
||||
|
||||
class ProductModel {
|
||||
public $name = null;
|
||||
public $description = null;
|
||||
public $sla_id = null;
|
||||
public $external = null;
|
||||
public $name;
|
||||
public $description;
|
||||
public $sla_id;
|
||||
public $external;
|
||||
public $external_id;
|
||||
public $productgroup_id = null;
|
||||
public $producttech_id = null;
|
||||
public $price = null;
|
||||
public $price_setup = null;
|
||||
public $price_nne = null;
|
||||
public $price_nbe = null;
|
||||
public $billing_delay = null;
|
||||
public $billing_period = null;
|
||||
public $ivt_id = null;
|
||||
public $productgroup_id;
|
||||
public $producttech_id;
|
||||
public $price;
|
||||
public $price_setup;
|
||||
public $price_nne;
|
||||
public $price_nbe;
|
||||
public $billing_delay;
|
||||
public $billing_period;
|
||||
public $contract_term;
|
||||
public $ivt_id;
|
||||
|
||||
public $note = null;
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
public $create = null;
|
||||
public $edit = null;
|
||||
public $note;
|
||||
public $create_by;
|
||||
public $edit_by;
|
||||
public $create;
|
||||
public $edit;
|
||||
|
||||
|
||||
public static function create(Array $data) {
|
||||
|
||||
@@ -84,10 +84,11 @@ class ProducttechController extends mfBaseController {
|
||||
if(!trim($attribute['name']) || !trim($attribute['displayname'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$a = [];
|
||||
$a['name'] = $attribute['name'];
|
||||
$a['producttech_id'] = $new_id;
|
||||
$a['type'] = $attribute['type'];
|
||||
$a['displayname'] = htmlentities($attribute['displayname']);
|
||||
$a['value'] = $attribute['value'];
|
||||
$a['description'] = htmlentities($attribute['description']);
|
||||
|
||||
@@ -7,9 +7,9 @@ class WorkerFlag {
|
||||
private $name = null;
|
||||
private $value = null;
|
||||
private $user = null;
|
||||
|
||||
|
||||
public function __construct($worker_id, $name) {
|
||||
$this->db = new FronkDB();
|
||||
$this->db = FronkDB::singleton();
|
||||
|
||||
$user = new User($worker_id);
|
||||
$this->user = $user;
|
||||
|
||||
Reference in New Issue
Block a user