Merge branch 'fronkdev'
This commit is contained in:
@@ -6,9 +6,6 @@
|
||||
if($f) {
|
||||
$urlfilter['f'] = $f;
|
||||
}
|
||||
if(is_array($filter) && count($filter)) {
|
||||
$urlfilter["filter"] = $filter;
|
||||
}
|
||||
$posturl = self::getUrl("Address", "save", $urlfilter);
|
||||
?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||
@@ -232,6 +229,14 @@
|
||||
<div class="col-lg-10 alert alert-danger hidden" id="bank-error"></div>
|
||||
</div>
|
||||
|
||||
<?php if($me->can("Fibu")): ?>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="sepa_date">Sepa Mandatsdatum</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="sepa_date" id="sepa_date" value="<?=($address->sepa_date) ? date("d.m.Y", $address->sepa_date) : ""?>" />
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -429,6 +434,14 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$('#sepa_date').datepicker({
|
||||
language: 'de',
|
||||
format: "dd.mm.yyyy",
|
||||
showWeekDays: true,
|
||||
todayBtn: 'linked',
|
||||
autoclose: true
|
||||
});
|
||||
|
||||
var bankdata_valid = false;
|
||||
|
||||
$("#parent_id").select2({
|
||||
@@ -490,7 +503,7 @@
|
||||
$("#bank-error").hide();
|
||||
$("#bank-error").text("");
|
||||
|
||||
if(data.iban_correct && !data.iban_sus && data.bic_correct) {
|
||||
if(data.iban_correct && data.bic_correct && (!data.iban_sus || data.iban_sus === "www")) {
|
||||
bankdata_valid = true;
|
||||
$('#addressForm').submit();
|
||||
return;
|
||||
@@ -502,7 +515,7 @@
|
||||
$("#bank_account_iban").addClass("invalid");
|
||||
bank_error.push("Ungültige IBAN!");
|
||||
}
|
||||
if(data.iban_sus) {
|
||||
if(data.iban_sus && data.iban_sus !== "www") {
|
||||
$("#bank_account_iban").addClass("invalid");
|
||||
bank_error.push("IBAN verdächtig (" + data.iban_sus + ")!");
|
||||
}
|
||||
|
||||
@@ -60,22 +60,22 @@
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_addresstype">Rolle</label>
|
||||
<select name="filter[addresstype][]" id="filter_addresstype" class="form-control" multiple="multiple">
|
||||
<option value="systemowner" <?=(in_array("systemowner", $filter["addresstype"])) ? "selected='selected'" : ""?>><?=__("systemowner")?></option>
|
||||
<option value="productowner" <?=(in_array("productowner", $filter["addresstype"])) ? "selected='selected'" : ""?>><?=__("productowner")?></option>
|
||||
<option value="netowner" <?=(in_array("netowner", $filter["addresstype"])) ? "selected='selected'" : "netowner"?>><?=__("netowner")?></option>
|
||||
<option value="salespartner" <?=(in_array("salespartner", $filter["addresstype"])) ? "selected='selected'" : "salespartner"?>><?=__("salespartner")?></option>
|
||||
<option value="pipeworker" <?=(in_array("pipeworker", $filter["addresstype"])) ? "selected='selected'" : "pipeworker"?>><?=__("pipeworker")?></option>
|
||||
<option value="lineworker" <?=(in_array("lineworker", $filter["addresstype"])) ? "selected='selected'" : "lineworker"?>><?=__("lineworker")?></option>
|
||||
<option value="pipeplanner" <?=(in_array("pipeplanner", $filter["addresstype"])) ? "selected='selected'" : "pipeplanner"?>><?=__("pipeplanner")?></option>
|
||||
<option value="lineplanner" <?=(in_array("lineplanner", $filter["addresstype"])) ? "selected='selected'" : "lineplanner"?>><?=__("lineplanner")?></option>
|
||||
<option value="netoperator" <?=(in_array("netoperator", $filter["addresstype"])) ? "selected='selected'" : "netoperator"?>><?=__("netoperator")?></option>
|
||||
<option value="support" <?=(in_array("support", $filter["addresstype"])) ? "selected='selected'" : "support"?>><?=__("support")?></option>
|
||||
<option value="billing" <?=(in_array("billing", $filter["addresstype"])) ? "selected='selected'" : ""?>><?=__("billing")?></option>
|
||||
<option value="employee" <?=(in_array("employee", $filter["addresstype"])) ? "selected='selected'" : ""?>><?=__("employee")?></option>
|
||||
<option value="customer" <?=(in_array("customer", $filter["addresstype"])) ? "selected='selected'" : ""?>><?=__("customer")?></option>
|
||||
<option value="supplier" <?=(in_array("supplier", $filter["addresstype"])) ? "selected='selected'" : ""?>><?=__("supplier")?></option>
|
||||
<option value="contact" <?=(in_array("contact", $filter["addresstype"])) ? "selected='selected'" : ""?>><?=__("contact")?></option>
|
||||
<option value="techcontact" <?=(in_array("techcontact", $filter["addresstype"])) ? "selected='selected'" : ""?>><?=__("techcontact")?></option>
|
||||
<option value="systemowner" <?=(array_key_exists("addresstype", $filter) && in_array("systemowner", $filter["addresstype"])) ? "selected='selected'" : ""?>><?=__("systemowner")?></option>
|
||||
<option value="productowner" <?=(array_key_exists("addresstype", $filter) && in_array("productowner", $filter["addresstype"])) ? "selected='selected'" : ""?>><?=__("productowner")?></option>
|
||||
<option value="netowner" <?=(array_key_exists("addresstype", $filter) && in_array("netowner", $filter["addresstype"])) ? "selected='selected'" : "netowner"?>><?=__("netowner")?></option>
|
||||
<option value="salespartner" <?=(array_key_exists("addresstype", $filter) && in_array("salespartner", $filter["addresstype"])) ? "selected='selected'" : "salespartner"?>><?=__("salespartner")?></option>
|
||||
<option value="pipeworker" <?=(array_key_exists("addresstype", $filter) && in_array("pipeworker", $filter["addresstype"])) ? "selected='selected'" : "pipeworker"?>><?=__("pipeworker")?></option>
|
||||
<option value="lineworker" <?=(array_key_exists("addresstype", $filter) && in_array("lineworker", $filter["addresstype"])) ? "selected='selected'" : "lineworker"?>><?=__("lineworker")?></option>
|
||||
<option value="pipeplanner" <?=(array_key_exists("addresstype", $filter) && in_array("pipeplanner", $filter["addresstype"])) ? "selected='selected'" : "pipeplanner"?>><?=__("pipeplanner")?></option>
|
||||
<option value="lineplanner" <?=(array_key_exists("addresstype", $filter) && in_array("lineplanner", $filter["addresstype"])) ? "selected='selected'" : "lineplanner"?>><?=__("lineplanner")?></option>
|
||||
<option value="netoperator" <?=(array_key_exists("addresstype", $filter) && in_array("netoperator", $filter["addresstype"])) ? "selected='selected'" : "netoperator"?>><?=__("netoperator")?></option>
|
||||
<option value="support" <?=(array_key_exists("addresstype", $filter) && in_array("support", $filter["addresstype"])) ? "selected='selected'" : "support"?>><?=__("support")?></option>
|
||||
<option value="billing" <?=(array_key_exists("addresstype", $filter) && in_array("billing", $filter["addresstype"])) ? "selected='selected'" : ""?>><?=__("billing")?></option>
|
||||
<option value="employee" <?=(array_key_exists("addresstype", $filter) && in_array("employee", $filter["addresstype"])) ? "selected='selected'" : ""?>><?=__("employee")?></option>
|
||||
<option value="customer" <?=(array_key_exists("addresstype", $filter) && in_array("customer", $filter["addresstype"])) ? "selected='selected'" : ""?>><?=__("customer")?></option>
|
||||
<option value="supplier" <?=(array_key_exists("addresstype", $filter) && in_array("supplier", $filter["addresstype"])) ? "selected='selected'" : ""?>><?=__("supplier")?></option>
|
||||
<option value="contact" <?=(array_key_exists("addresstype", $filter) && in_array("contact", $filter["addresstype"])) ? "selected='selected'" : ""?>><?=__("contact")?></option>
|
||||
<option value="techcontact" <?=(array_key_exists("addresstype", $filter) && in_array("techcontact", $filter["addresstype"])) ? "selected='selected'" : ""?>><?=__("techcontact")?></option>
|
||||
</select>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
@@ -155,7 +155,7 @@
|
||||
<div class="row mt-2">
|
||||
<div class="col">
|
||||
<button type="submit" class="btn btn-primary"><i class="far fa-search fa-fw"></i> Filter anwenden</button>
|
||||
<a class="btn btn-secondary" href="<?=self::getUrl("Address")?>"><i class="far fa-xmark fa-fw"></i> Filter zurücksetzen</a>
|
||||
<a class="btn btn-secondary" href="<?=self::getUrl("Address", "", ["resetFilter" => 1])?>"><i class="far fa-xmark fa-fw"></i> Filter zurücksetzen</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -209,7 +209,7 @@
|
||||
<td></td>
|
||||
<?php endif; ?>
|
||||
<td>
|
||||
<a href="<?=self::getUrl("Address", "view", ["id" => $address->id, 'filter' => $filter, 's' => $pagination['start']])?>">
|
||||
<a href="<?=self::getUrl("Address", "view", ["id" => $address->id, 's' => $pagination['start']])?>">
|
||||
<?=$address->customer_number?>
|
||||
<?=($address->spin) ? "<br /><span class='text-pink'>".$address->spin."</span>" : ""?>
|
||||
</a>
|
||||
@@ -222,8 +222,8 @@
|
||||
<br /><span title="Lieferantenkonto"><?=$address->fibu_supplier_number?></span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><a href="<?=self::getUrl("Address", "view", ["id" => $address->id, 'filter' => $filter, 's' => $pagination['start']])?>"><?=nl2br($address->company)?></a></td>
|
||||
<td><a href="<?=self::getUrl("Address", "view", ["id" => $address->id, 'filter' => $filter, 's' => $pagination['start']])?>"><?=$address->getFullName()?></a></td>
|
||||
<td><a href="<?=self::getUrl("Address", "view", ["id" => $address->id, 's' => $pagination['start']])?>"><?=nl2br($address->company)?></a></td>
|
||||
<td><a href="<?=self::getUrl("Address", "view", ["id" => $address->id, 's' => $pagination['start']])?>"><?=$address->getFullName()?></a></td>
|
||||
<td>
|
||||
<?=$address->street?><br />
|
||||
<?=$address->zip?> <?=$address->city?>
|
||||
@@ -232,7 +232,7 @@
|
||||
<td><?=$address->email?></td>
|
||||
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
||||
<a href="<?=self::getUrl("User", "Index", ["filter" => ["address_id" => $address->id]])?>" title="Benutzer anzeigen"><i class="fas fa-users"></i></a>
|
||||
<a href="<?=self::getUrl("Address", "view", ["id" => $address->id, 'filter' => $filter, 's' => $pagination['start']])?>"><i class="far fa-eyes" title="Anzeigen"></i></a>
|
||||
<a href="<?=self::getUrl("Address", "view", ["id" => $address->id, 's' => $pagination['start']])?>"><i class="far fa-eyes" title="Anzeigen"></i></a>
|
||||
<a href="<?=self::getUrl("Address", "edit", ["id" => $address->id, 's' => $pagination['start']])?>"><i class="far fa-edit" title="Bearbeiten"></i></a>
|
||||
<a href="<?=self::getUrl("Address", "delete", ["id" => $address->id, 's' => $pagination['start']])?>" onclick="if(!confirm('Person/Firma wirklich löschen?')) return false;" class="text-danger" title="Löschen"><i class="fas fa-trash"></i></a>
|
||||
</td>
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<a href="<?=self::getUrl("Address","Index", ['filter' => $filter, 's' => $s])?>" class="btn btn-secondary mr-1"><i class="fas fa-list"></i> Zurück zur Übersicht</a>
|
||||
<a href="<?=self::getUrl("Address","edit", ['id' => $address->id, 'filter' => $filter, 's' => $s, 'f' => "view"])?>" class="btn btn-outline-success"><i class="fas fa-edit"></i> Adresse bearbeiten</a>
|
||||
<a href="<?=self::getUrl("Address","Index", ['s' => $s])?>" class="btn btn-secondary mr-1"><i class="fas fa-list"></i> Zurück zur Übersicht</a>
|
||||
<a href="<?=self::getUrl("Address","edit", ['id' => $address->id, 's' => $s, 'f' => "view"])?>" class="btn btn-outline-success"><i class="fas fa-edit"></i> Adresse bearbeiten</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -116,7 +116,14 @@
|
||||
</tr><tr>
|
||||
<th>BIC</th>
|
||||
<td><?=$address->bank_account_bic?></td>
|
||||
</tr><tr>
|
||||
</tr>
|
||||
<?php if($me->can("Fibu")): ?>
|
||||
<tr>
|
||||
<th>Sepa Mandatsdatum</th>
|
||||
<td><?=($address->sepa_date) ? date("d.m.Y", $address->sepa_date) : ""?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<tr>
|
||||
<td colspan="2"><h4>FIBU</h4></td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -270,8 +277,8 @@
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<a href="<?=self::getUrl("Address","Index", ['filter' => $filter, 's' => $s])?>" class="btn btn-secondary mr-1"><i class="fas fa-list"></i> Zurück zur Übersicht</a>
|
||||
<a href="<?=self::getUrl("Address","edit", ['id' => $address->id, 'filter' => $filter, 's' => $s, 'f' => "view"])?>" class="btn btn-outline-success"><i class="fas fa-edit"></i> Adresse bearbeiten</a>
|
||||
<a href="<?=self::getUrl("Address","Index", ['s' => $s])?>" class="btn btn-secondary mr-1"><i class="fas fa-list"></i> Zurück zur Übersicht</a>
|
||||
<a href="<?=self::getUrl("Address","edit", ['id' => $address->id, 's' => $s, 'f' => "view"])?>" class="btn btn-outline-success"><i class="fas fa-edit"></i> Adresse bearbeiten</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@
|
||||
<?php foreach($addresses as $address): ?>
|
||||
<tr>
|
||||
<td><?=$address->netzgebiet->name?></td>
|
||||
<td><?=$address->adrcd?></td>
|
||||
<td><?=$address->adrcd?><?=($address->subcd) ? "-".$address->subcd : ""?></td>
|
||||
<td><?=$address->oaid?></td>
|
||||
<td><?=$address->extref?></td>
|
||||
<td><?=$address->plz->plz?></td>
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<td class="text-monospace text-pink"><?=$address->oaid?></td>
|
||||
</tr><tr>
|
||||
<th>ADRCD</th>
|
||||
<td class="text-monospace"><?=$address->adrcd?></td>
|
||||
<td class="text-monospace"><?=$address->adrcd?><?=($address->subcd) ? "-".$address->subcd : ""?></td>
|
||||
</tr><tr>
|
||||
<th>Extref</th>
|
||||
<td><?=$address->extref?></td>
|
||||
@@ -76,6 +76,9 @@
|
||||
</tr><tr>
|
||||
<th>Straße / Hausnummer</th>
|
||||
<td><?=$address->strasse->name?> <?=$address->hausnummer?></td>
|
||||
</tr><tr>
|
||||
<th>Adresszusatz</th>
|
||||
<td><?=$address->zusatz?></td>
|
||||
</tr><tr>
|
||||
<th>PLZ / Ort</th>
|
||||
<td><?=$address->plz->plz?> <?=$address->ortschaft->name?></td>
|
||||
@@ -122,6 +125,7 @@
|
||||
<th>Status</th>
|
||||
<th>Beschreibung</th>
|
||||
<th>Extref</th>
|
||||
<th>Best.</th>
|
||||
</tr>
|
||||
<?php foreach($address->wohneinheiten as $unit): ?>
|
||||
<tr>
|
||||
@@ -139,6 +143,7 @@
|
||||
<td class="text-monospace"><?=$unit->status->code?> - <?=$unit->status->name?></td>
|
||||
<td><?=((string)$unit) ? "<strong>".(string)$unit."</strong>" : ""?></td>
|
||||
<td><?=($unit->extref) ? "[".$unit->extref."]" : ""?></td>
|
||||
<td title="Anzahl Bestellungen"><?=PreorderModel::count(["adb_wohneinheit_id" => $unit->id, "deleted" => 0])?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
$thetime = microtime(true);
|
||||
|
||||
$additionalJS = ["plugins/chart.js/Chart.min.js"];
|
||||
|
||||
@@ -382,10 +384,6 @@ $chartColors = [
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
var status = [];
|
||||
<?php foreach(PreorderstatusModel::getAll() as $status):?>
|
||||
status[<?=$status->id?>] = {"code": "<?=$status->code?>", "name": "<?=$status->name?>"};
|
||||
<?php endforeach; ?>
|
||||
|
||||
|
||||
|
||||
@@ -436,4 +434,8 @@ $chartColors = [
|
||||
|
||||
</script>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
||||
<?php
|
||||
$thetime = microtime(true) - $thetime;
|
||||
$this->log->debug("Rendering Dashboard page took $thetime microseconds");
|
||||
?>
|
||||
@@ -688,8 +688,8 @@ function validateWorkflowItem(id) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
var export_uid = "";
|
||||
var export_progress = 0;
|
||||
var downloadUrl;
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
<div class="col-lg-10">
|
||||
<?php if($oaid->adb_wohneinheit_id && is_object($oaid->adb_wohneinheit)): ?>
|
||||
<input type="text" class="form-control" disabled="disabled"
|
||||
value="[<?=$oaid->adb_wohneinheit->hausnummer->strasse->gemeinde->name?>] <?=$oaid->adb_wohneinheit->hausnummer->plz->plz?><?=$oaid->adb_wohneinheit->hausnummer->ortschaft->name?>, <?=$oaid->adb_wohneinheit->hausnummer->strasse->name?><?=$oaid->adb_wohneinheit->hausnummer->hausnummer?><?=((string)$oaid->adb_wohneinheit) ? " - ".(string)$oaid->adb_wohneinheit : ""?>"
|
||||
value="[<?=$oaid->adb_wohneinheit->hausnummer->strasse->gemeinde->name?>] <?=$oaid->adb_wohneinheit->hausnummer->plz->plz?><?=$oaid->adb_wohneinheit->hausnummer->ortschaft->name?>, <?=$oaid->adb_wohneinheit->hausnummer->strasse->name?> <?=$oaid->adb_wohneinheit->hausnummer->hausnummer?><?=((string)$oaid->adb_wohneinheit) ? " - ".(string)$oaid->adb_wohneinheit : ""?>"
|
||||
/>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
if($noTermProducts) {
|
||||
$urlfilter['noTermProducts'] = 1;
|
||||
}
|
||||
if(is_array($filter) && count($filter)) {
|
||||
if(isset($filter) && is_array($filter) && count($filter)) {
|
||||
$urlfilter["filter"] = $filter;
|
||||
}
|
||||
$posturl = self::getUrl("Order", "save", $urlfilter);
|
||||
@@ -589,8 +589,8 @@
|
||||
<input type="number" class="form-control" name="products[<?=$i?>][amount]" id="amount-<?=$i?>" value="<?=($product) ? $product->formatAmount() : ""?>" placeholder="Anzahl/Menge" />
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="billing_period-<?=$i?>">Verrechungsperiode</label>
|
||||
<select class="form-control" name="products[<?=$i?>][billing_period]" id="billing_period-<?=$i?>" placeholder="Verrechnungsperiode">
|
||||
<label class="form-label" for="billing_period-<?=$i?>">Rechungsperiode</label>
|
||||
<select class="form-control" name="products[<?=$i?>][billing_period]" id="billing_period-<?=$i?>" placeholder="Rechnungsperiode">
|
||||
<option value="1" <?=($product->billing_period == 1) ? "selected='selected'" : ""?>>Monatlich</option>
|
||||
<option value="12" <?=($product->billing_period == 12) ? "selected='selected'" : ""?>>Jährlich</option>
|
||||
</select>
|
||||
@@ -649,10 +649,22 @@
|
||||
|
||||
<div class="row mt-1 mb-2">
|
||||
<!-- line 2 -->
|
||||
<div class="col-8">
|
||||
<div class="col-6">
|
||||
<label class="form-label" for="description-<?=$i?>" >Zusatztext</label>
|
||||
<textarea class="form-control" name="products[<?=$i?>][description]" id="description-<?=$i?>" placeholder="Zusatztext"><?=$product->description?></textarea>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="contract_term-<?=$i?>">Mindestvertragslaufzeit</label>
|
||||
<select class="form-control" name="products[<?=$i?>][contract_term]" id="contract_term-<?=$i?>" placeholder="Mindestvertragslaufzeit">
|
||||
<option value="0" <?=($product->contract_term == 0) ? "selected='selected'" : ""?>>Keine</option>
|
||||
<option value="1" <?=($product->contract_term == 1) ? "selected='selected'" : ""?>>1 Monat</option>
|
||||
<option value="12" <?=($product->contract_term == 12) ? "selected='selected'" : ""?>>12 Monate</option>
|
||||
<option value="24" <?=($product->contract_term == 24) ? "selected='selected'" : ""?>>24 Monate</option>
|
||||
<option value="36" <?=($product->contract_term == 36) ? "selected='selected'" : ""?>>36 Monate</option>
|
||||
<option value="48" <?=($product->contract_term == 48) ? "selected='selected'" : ""?>>48 Monate</option>
|
||||
<option value="60" <?=($product->contract_term == 60) ? "selected='selected'" : ""?>>60 Monate</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="billing_delay-<?=$i?>" >Verzögerter Verrechnungsstart</label>
|
||||
<input type="number" class="form-control" name="products[<?=$i?>][billing_delay]" id="billing_delay-<?=$i?>" value="<?=$product->billing_delay?>" placeholder="Freimonate" />
|
||||
@@ -718,7 +730,7 @@
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="billing_period-<?=$i?>">Verrechungsperiode</label>
|
||||
<select class="form-control" name="products[<?=$i?>][billing_period]" id="billing_period-<?=$i?>" placeholder="Verrechnungsperiode">
|
||||
<select class="form-control" name="products[<?=$i?>][billing_period]" id="billing_period-<?=$i?>" placeholder="Rechnungsperiode">
|
||||
<option value="1">Monatlich</option>
|
||||
<option value="12">Jährlich</option>
|
||||
</select>
|
||||
@@ -757,10 +769,22 @@
|
||||
|
||||
<div class="row mt-1 mb-2">
|
||||
<!-- line 2 -->
|
||||
<div class="col-8">
|
||||
<div class="col-6">
|
||||
<label class="form-label" for="description-<?=$i?>" >Zusatztext</label>
|
||||
<textarea class="form-control" name="products[<?=$i?>][description]" id="description-<?=$i?>" placeholder="Zusatztext"></textarea>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="contract_term-<?=$i?>">Mindestvertragslaufzeit</label>
|
||||
<select class="form-control" name="products[<?=$i?>][contract_term]" id="contract_term-<?=$i?>" placeholder="Mindestvertragslaufzeit">
|
||||
<option value="0">Keine</option>
|
||||
<option value="1">1 Monat</option>
|
||||
<option value="12">12 Monate</option>
|
||||
<option value="24">24 Monate</option>
|
||||
<option value="36">36 Monate</option>
|
||||
<option value="48">48 Monate</option>
|
||||
<option value="60">60 Monate</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="billing_delay-<?=$i?>" >Verzögerter Verrechnungsstart</label>
|
||||
<input type="number" class="form-control" name="products[<?=$i?>][billing_delay]" id="billing_delay-<?=$i?>" value="" placeholder="Freimonate" />
|
||||
@@ -1195,12 +1219,13 @@
|
||||
form_id: id
|
||||
},
|
||||
function (success) {
|
||||
//console.log(success);
|
||||
console.log(success);
|
||||
p = success.result.product;
|
||||
id = success.result.form_id;
|
||||
|
||||
$('#billing_delay-' + id).val(p.billing_delay);
|
||||
$('#billing_period-' + id).val(p.billing_period);
|
||||
$('#contract_term-' + id).val(p.contract_term);
|
||||
$('#price-' + id).val(p.price);
|
||||
$('#price_setup-' + id).val(p.price_setup);
|
||||
$('#price_nne-' + id).val(p.price_nne);
|
||||
@@ -1293,7 +1318,7 @@
|
||||
$("#bank-error").hide();
|
||||
$("#bank-error").text("");
|
||||
|
||||
if(data.iban_correct && !data.iban_sus && data.bic_correct) {
|
||||
if(data.iban_correct && data.bic_correct && (!data.iban_sus || data.iban_sus === "www")) {
|
||||
bankdata_valid = true;
|
||||
$('#orderForm').submit();
|
||||
return;
|
||||
@@ -1305,7 +1330,7 @@
|
||||
$("#bank_account_iban").addClass("invalid");
|
||||
bank_error.push("Ungültige IBAN!");
|
||||
}
|
||||
if(data.iban_sus) {
|
||||
if(data.iban_sus && data.iban_sus !== "www") {
|
||||
$("#bank_account_iban").addClass("invalid");
|
||||
bank_error.push("IBAN verdächtig (" + data.iban_sus + ")!");
|
||||
}
|
||||
@@ -1576,7 +1601,7 @@
|
||||
</div> \
|
||||
<div class="col-2"> \
|
||||
<label class="form-label" for="billing_period-' + i +'">Verrechungsperiode</label> \
|
||||
<select class="form-control" name="products[' + i +'][billing_period]" id="billing_period-' + i +'" placeholder="Verrechnungsperiode"> \
|
||||
<select class="form-control" name="products[' + i +'][billing_period]" id="billing_period-' + i +'" placeholder="Rechnungsperiode"> \
|
||||
<option value="1">Monatlich</option> \
|
||||
<option value="12">Jährlich</option> \
|
||||
</select> \
|
||||
@@ -1616,10 +1641,22 @@
|
||||
\
|
||||
<div class="row mt-1 mb-2"> \
|
||||
<!-- line 2 --> \
|
||||
<div class="col-8"> \
|
||||
<div class="col-6"> \
|
||||
<label class="form-label" for="description-' + i +'" >Zusatztext</label> \
|
||||
<textarea class="form-control" name="products[' + i +'][description]" id="description-' + i +'" placeholder="Zusatztext"></textarea> \
|
||||
</div> \
|
||||
<div class="col-2"> \
|
||||
<label class="form-label" for="contract_term-' + i + '">Mindestvertragslaufzeit</label> \
|
||||
<select class="form-control" name="products[' + i + '][contract_term]" id="contract_term-<?=$i?>" placeholder="Mindestvertragslaufzeit"> \
|
||||
<option value="0">Keine</option> \
|
||||
<option value="1">1 Monat</option> \
|
||||
<option value="12">12 Monate</option> \
|
||||
<option value="24">24 Monate</option> \
|
||||
<option value="36">36 Monate</option> \
|
||||
<option value="48">48 Monate</option> \
|
||||
<option value="60">60 Monate</option> \
|
||||
</select> \
|
||||
</div> \
|
||||
<div class="col-2"> \
|
||||
<label class="form-label" for="billing_delay-' + i +'" >Verzögerter Verrechnungsstart</label> \
|
||||
<input type="number" class="form-control" name="products[' + i +'][billing_delay]" id="billing_delay-' + i + '" value="" placeholder="Freimonate" /> \
|
||||
|
||||
@@ -105,18 +105,14 @@
|
||||
<input type="text" class="form-control" name="filter[kunde]" id="filter_kunde" value="<?=$filter['kunde'] ?? ""?>" />
|
||||
</div>
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_magic_search">erweiterte Suche</label>
|
||||
<input type="text" class="form-control" name="filter[magic_search]" id="filter_magic_search" value="<?=$filter['magic_search'] ?? ""?>" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row mt-2">
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_address_source">Adressherkunft</label>
|
||||
<select name="filter[address_source]" id="filter_address_source" class="form-control">
|
||||
<option value=""></option>
|
||||
<option value="addressdb" <?=(isset($filter) && array_key_exists("address_source", $filter) && $filter['address_source'] == "addressdb") ? "selected='selected'" : ""?>>thetool AddressDB</option>
|
||||
<option value="manual" <?=(isset($filter) && array_key_exists("address_source", $filter) && $filter['address_source'] == "manual") ? "selected='selected'" : ""?>>manuelle Eingabe</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-1">
|
||||
<label class="form-label" for="filter_unit_missing">Wohneinheit</label>
|
||||
<select name="filter[unit_missing]" id="filter_unit_missing" class="form-control">
|
||||
@@ -135,18 +131,8 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_unit_count">Anzahl Wohneinheiten in GWR</label>
|
||||
<select name="filter[unit_count]" id="filter_unit_count" class="form-control">
|
||||
<option value=""></option>
|
||||
<option value="0" <?=(isset($filter) && array_key_exists("unit_count", $filter) && strlen($filter['unit_count']) && intval($filter['unit_count']) === 0) ? "selected='selected'" : ""?>>0</option>
|
||||
<option value="1" <?=(isset($filter) && array_key_exists("unit_count", $filter) && intval($filter['unit_count']) === 1) ? "selected='selected'" : ""?>>1</option>
|
||||
<option value="2" <?=(isset($filter) && array_key_exists("unit_count", $filter) && intval($filter['unit_count']) === 2) ? "selected='selected'" : ""?>> > 1</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<?php if($campaign->fulfillment == "rimo"): ?>
|
||||
<div class="col-2">
|
||||
<?php if((isset($campaign) && $campaign->fulfillment == "rimo") || !isset($campaign) || !$campaign->id): ?>
|
||||
<div class="col-1">
|
||||
<label class="form-label" for="filter_rimo_workorder">Rimo Workorder</label>
|
||||
<select name="filter[rimo_workorder]" id="filter_rimo_workorder" class="form-control">
|
||||
<option value=""></option>
|
||||
@@ -155,6 +141,24 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_rimo_workorder">Rimo Workorder Status</label>
|
||||
<select name="filter[rimo_workorder_status]" id="filter_rimo_workorder_status" class="form-control">
|
||||
<option value=""></option>
|
||||
<option value="new" <?=(isset($filter) && array_key_exists("rimo_workorder_status", $filter) && $filter["rimo_workorder_status"] == "new" ) ? "selected='selected'" : ""?>>New</option>
|
||||
<option value="Clarify" <?=(isset($filter) && array_key_exists("rimo_workorder_status", $filter) && $filter["rimo_workorder_status"] == "Clarify" ) ? "selected='selected'" : ""?>>Clarify</option>
|
||||
<option value="Accepted" <?=(isset($filter) && array_key_exists("rimo_workorder_status", $filter) && $filter["rimo_workorder_status"] == "Accepted" ) ? "selected='selected'" : ""?>>Accepted</option>
|
||||
<option value="Plan released" <?=(isset($filter) && array_key_exists("rimo_workorder_status", $filter) && $filter["rimo_workorder_status"] == "Plan released" ) ? "selected='selected'" : ""?>>Plan released</option>
|
||||
<option value="Assigned" <?=(isset($filter) && array_key_exists("rimo_workorder_status", $filter) && $filter["rimo_workorder_status"] == "Assigned" ) ? "selected='selected'" : ""?>>Assigned</option>
|
||||
<option value="Documented" <?=(isset($filter) && array_key_exists("rimo_workorder_status", $filter) && $filter["rimo_workorder_status"] == "Documented" ) ? "selected='selected'" : ""?>>Documented</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_kunde">Rimo Workorder Name</label>
|
||||
<input type="text" class="form-control" name="filter[rimo_workorder_name]" id="filter_workorder_name" value="<?=$filter['workorder_name'] ?? ""?>" />
|
||||
</div>
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="rimo_home_extref">Wohneinheit Rimo-Extref</label>
|
||||
<select name="filter[rimo_home_extref]" id="filter_rimo_home_extref" class="form-control">
|
||||
@@ -239,7 +243,7 @@
|
||||
<th>Partner</th>
|
||||
<th>Attribute</th>
|
||||
<th>Erstellt<br />Bearbeitet</th>
|
||||
<?php if($me->is(["Admin","netowner"]) && $campaign->fulfillment == "rimo"): ?>
|
||||
<?php if($me->is(["Admin","netowner"])): ?>
|
||||
<th></th>
|
||||
<?php endif; ?>
|
||||
<th></th>
|
||||
@@ -295,7 +299,7 @@
|
||||
<span id="update-<?=$preorder->id?>"><?=date('d.m.Y H:i', $preorder->edit)?></span>
|
||||
</td>
|
||||
|
||||
<?php if($me->is(["Admin", "netowner"]) && $campaign->fulfillment == "rimo"): ?>
|
||||
<?php if($me->is(["Admin", "netowner"])): ?>
|
||||
<td><?php if($preorder->adb_wohneinheit_id && is_object($preorder->adb_wohneinheit->rimo_workorder)):?><i class="fas fa-r" title="Rimo Workorder erstellt"></i><?php endif; ?></td>
|
||||
<?php endif; ?>
|
||||
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
||||
|
||||
@@ -210,6 +210,9 @@
|
||||
</tr><tr>
|
||||
<th>Gemeinde</th>
|
||||
<td><?=$preorder->adb_hausnummer->strasse->gemeinde->name?></td>
|
||||
</tr><tr>
|
||||
<th>Anzahl Wohneinheiten</th>
|
||||
<td><?=(is_array($preorder->adb_hausnummer->wohneinheiten) && count($preorder->adb_hausnummer->wohneinheiten)) ? count($preorder->adb_hausnummer->wohneinheiten) : "0"?></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
@@ -210,7 +210,21 @@
|
||||
<input type="text" name="billing_delay" id="billing_delay" class="form-control" value="<?=$this::dotToComma($product->billing_delay)?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="contract_term">Mindestvertragslaufzeit</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="form-control" name="contract_term" id="contract_term">
|
||||
<option value="0" <?=($product->contract_term == 0) ? "selected='selected'" : ""?>>Keine</option>
|
||||
<option value="1" <?=($product->contract_term == 1) ? "selected='selected'" : ""?>>1 Monat</option>
|
||||
<option value="12" <?=($product->contract_term == 12) ? "selected='selected'" : ""?>>12 Monate</option>
|
||||
<option value="24" <?=($product->contract_term == 24) ? "selected='selected'" : ""?>>24 Monate</option>
|
||||
<option value="36" <?=($product->contract_term == 36) ? "selected='selected'" : ""?>>36 Monate</option>
|
||||
<option value="48" <?=($product->contract_term == 48) ? "selected='selected'" : ""?>>48 Monate</option>
|
||||
<option value="60" <?=($product->contract_term == 60) ? "selected='selected'" : ""?>>60 Monate</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -222,7 +236,16 @@
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="attributes_<?=$attrib->producttechattribute_id?>"><?=$attrib->displayname?></label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="attributes[<?=$attrib->producttechattribute_id?>]" id="attributes_<?=$attrib->producttechattribute_id?>" value="<?=$attrib->value?>" />
|
||||
<?php if($attrib->type == "salespartner"): ?>
|
||||
<select class="form-control select2" name="attributes[<?=$attrib->producttechattribute_id?>]" id="attributes_<?=$attrib->producttechattribute_id?>">
|
||||
<option value=""></option>
|
||||
<?php foreach(AddressModel::search(["addresstype" => ["salespartner"]]) as $address): ?>
|
||||
<option value="<?=$address->id?>" <?=($attrib->value && $address->id == $attrib->value) ? "selected='selected'" : ""?>><?=$address->getCompanyOrName()?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php else: ?>
|
||||
<input type="text" class="form-control" name="attributes[<?=$attrib->producttechattribute_id?>]" id="attributes_<?=$attrib->producttechattribute_id?>" value="<?=$attrib->value?>" />
|
||||
<?php endif; ?>
|
||||
<?php if($attrib->description): ?>
|
||||
<small><?=$attrib->description?></small>
|
||||
<?php endif; ?>
|
||||
@@ -263,6 +286,10 @@
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
$(".select2").select2({
|
||||
allowClear: true,
|
||||
placeholder: ""
|
||||
});
|
||||
$("#productgroup_id").select2({
|
||||
allowClear: true,
|
||||
placeholder: ""
|
||||
|
||||
@@ -75,12 +75,21 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<label for="attributes_<?=$attribute->id?>_name">Name <small class="text-monospace">[a-z0-9._-]</small></label>
|
||||
<input type="text" class="form-control" id="attributes_<?=$attribute->id?>_name" name="attributes[<?=$attribute->id?>][name]" value="<?=$attribute->name?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
<div class="form-group">
|
||||
<label for="attributes_<?=$attribute->id?>_type">Typ</label>
|
||||
<select class="form-control" name="attributes[<?=$attribute->id?>][type]" id="attributes_<?=$attribute->id?>_type">
|
||||
<option value="text" <?=($attribute->type == "text") ? "selected='selected'" : ""?>>Text</option>
|
||||
<option value="salespartner" <?=($attribute->type == "salespartner") ? "selected='selected'" : ""?>>Vertriebspartner</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="attributes_<?=$attribute->id?>_displayname">Anzeigename</label>
|
||||
|
||||
@@ -47,7 +47,7 @@ if ($twofa == 0) {
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<div class="card">
|
||||
<div class="card bg-light">
|
||||
<div class="card-body">
|
||||
<h4 class="header-title mb-2">Allgemeine Daten</h4>
|
||||
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
<div class="page-title-box">
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="<?= self::getUrl("Dashboard") ?>"><?= MFAPPNAME_SLUG ?></a>
|
||||
</li>
|
||||
<li class="breadcrumb-item"><a href="<?= self::getUrl("Dashboard") ?>"><?= MFAPPNAME_SLUG ?></a></li>
|
||||
<li class="breadcrumb-item active">Benutzerprofil</li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Benutzerprofil</h4>
|
||||
@@ -66,7 +66,7 @@ if ($userprofile->twofactor == 0) {
|
||||
<i class="bi bi-exclamation-triangle"></i>
|
||||
<div class="row">
|
||||
<div class="col-lg">
|
||||
<div class="card">
|
||||
<div class="card bg-light">
|
||||
<div class="card-body">
|
||||
<h4 class=" mb-2">Allgemeine Daten</h4>
|
||||
<div class="card">
|
||||
@@ -130,6 +130,9 @@ if ($userprofile->twofactor == 0) {
|
||||
<div class="w-100 border-bottom"></div>
|
||||
<h4 class="form-group mb-2 mt-3">2FA</h4>
|
||||
<?php if (!$verification || $verification == 0): ?>
|
||||
<?php if(!$userprofile->twofactor): ?>
|
||||
<div class="alert alert-danger"><i class="fas fa-exclamation-circle"></i> Derzeit ist keine Methode für die Zwei-Faktor-Authentifizerung aktiviert. Bitte aktivieren Sie eine Zwei-Faktor-Authentifizerungsmethode!</div>
|
||||
<?php endif; ?>
|
||||
<form class="form-horizontal" method="post"
|
||||
action="<?= self::getUrl("UserProfile", $twoFactorFormaction) ?>">
|
||||
<div class="form-group row">
|
||||
|
||||
@@ -26,7 +26,12 @@
|
||||
<a class="nav-link nav-user mr-0" href="<?=self::getUrl("UserProfile")?>">
|
||||
<!-- <img src="<?=self::getResourcePath()?>assets/images/users/avatar-4.jpg" alt="user-image" class="rounded-circle"> -->
|
||||
<!-- <i style="font-size: 24px; border-radius: 50%;" class="fas fa-user-secret text-white img-circle bg-info"></i>-->
|
||||
<i class="fa-sharp fa-light fa-gear text-white img-circle font-15 "></i>
|
||||
<?php if(!$me->twofactor): ?>
|
||||
<i class="fas fa-exclamation-triangle text-warning" title="Zwei-Faktor-Authentifizierung (2FA) nicht aktiviert!"></i>
|
||||
<?php else: ?>
|
||||
<i class="fa-sharp fa-light fa-gear text-white img-circle font-15 "></i>
|
||||
<?php endif; ?>
|
||||
|
||||
<span class="pro-user-name ml-1">
|
||||
<?=$me->username?>
|
||||
</span>
|
||||
|
||||
@@ -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"]);
|
||||
|
||||
|
||||
35
application/IvtBill/IvtBill.php
Normal file
35
application/IvtBill/IvtBill.php
Normal file
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
113
application/IvtBill/IvtBillModel.php
Normal file
113
application/IvtBill/IvtBillModel.php
Normal file
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
179
application/OpenAccessId/helper/rimo.php
Normal file
179
application/OpenAccessId/helper/rimo.php
Normal file
@@ -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;
|
||||
|
||||
63
db/migrations/20240125122644_create_contractqueue.php
Normal file
63
db/migrations/20240125122644_create_contractqueue.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class CreateContractqueue extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$table = $this->table("Contractqueue");
|
||||
$table->addColumn("approved", "integer", ["null" => false, "default" => 0]);
|
||||
$table->addColumn("contract_id", "integer", ["null" => true, "default" => null]);
|
||||
$table->addColumn("order_id", "integer", ["null" => false]);
|
||||
$table->addColumn("orderproduct_id", "integer", ["null" => true, "default" => null]);
|
||||
$table->addColumn("owner_id", "integer", ["null" => false]);
|
||||
$table->addColumn("billingaddress_id", "integer", ["null" => true, "default" => null]);
|
||||
$table->addColumn("termination_id", "integer", ["null" => true, "default" => null]);
|
||||
$table->addColumn("product_id", "integer", ["null" => true, "default" => null]);
|
||||
$table->addColumn("product_name", "string", ["null" => false, "limit" => 255]);
|
||||
$table->addColumn("product_info", "text", ["null" => true, "default" => null]);
|
||||
$table->addColumn("matchcode", "string", ["null" => true, "default" => null, "limit" => 255]);
|
||||
$table->addColumn("amount", "decimal", ["null" => false, "precision" => 9, "scale" => 6]);
|
||||
$table->addColumn("sla_id", "integer", ["null" => true, "default" => null]);
|
||||
$table->addColumn("product_external", "integer", ["null" => false, "default" => 0, "limit" => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY]);
|
||||
$table->addColumn("product_external_id", "integer", ["null" => true, "default" => null]);
|
||||
$table->addColumn("price", "decimal", ["null" => false, "precision" => 14, "scale" => 4]);
|
||||
$table->addColumn("price_setup", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4]);
|
||||
$table->addColumn("price_nne", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4]);
|
||||
$table->addColumn("price_nbe", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4]);
|
||||
$table->addColumn("billing_delay", "integer", ["null" => false, "default" => 0]);
|
||||
$table->addColumn("billing_period", "integer", ["null" => false, "default" => 1]);
|
||||
$table->addColumn("order_date", "integer", ["null" => true, "default" => null]);
|
||||
$table->addColumn("finish_date", "integer", ["null" => true, "default" => null]);
|
||||
$table->addColumn("finish_date_by", "integer", ["null" => true, "default" => null]);
|
||||
$table->addColumn("cancel_date", "integer", ["null" => true, "default" => null]);
|
||||
$table->addColumn("cancel_date_by", "integer", ["null" => true, "default" => null]);
|
||||
$table->addColumn("imported_from", "string", ["null" => true, "default" => null, "limit" => 255]);
|
||||
$table->addColumn("imported_data", "string", ["null" => true, "default" => null, "limit" => 255]);
|
||||
$table->addColumn("note", "text", ["null" => true, "default" => null]);
|
||||
$table->addColumn("create_by", "integer", ["null" => false]);
|
||||
$table->addColumn("edit_by", "integer", ["null" => false]);
|
||||
$table->addColumn("create", "integer", ["null" => false]);
|
||||
$table->addColumn("edit", "integer", ["null" => false]);
|
||||
$table->create();
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$table = $this->table("Contractqueue")->drop()->save();
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
31
db/migrations/20240125183839_address_add_sepa_date.php
Normal file
31
db/migrations/20240125183839_address_add_sepa_date.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class AddressAddSepaDate extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$table = $this->table("Address");
|
||||
$table->addColumn("sepa_date", "integer", ["null" => true, "default" => null, "after" => "bank_account_bic"]);
|
||||
$table->save();
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$this->table("Address")->removeColumn("sepa_date")->save();
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
61
db/migrations/20240130120101_contract_add_reseller_id.php
Normal file
61
db/migrations/20240130120101_contract_add_reseller_id.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class ContractAddResellerId extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$table = $this->table("Contract");
|
||||
$table->addColumn("crediting_partner_id", "integer", ["null" => true, "default" => null, "after" => "orderproduct_id"]);
|
||||
$table->addColumn("crediting_partner_rate", "decimal", ["null" => true, "default" => null, "precision" => 10, "scale" => 4, "after" => "crediting_partner_id"]);
|
||||
$table->addColumn("reseller_id", "integer", ["null" => true, "default" => null, "after" => "crediting_partner_rate"]);
|
||||
$table->addColumn("reseller_rate", "decimal", ["null" => true, "default" => null, "precision" => 10, "scale" => 4, "after" => "reseller_id"]);
|
||||
$table->addIndex("orderproduct_id");
|
||||
$table->update();
|
||||
|
||||
$table = $this->table("Contractqueue");
|
||||
$table->addColumn("approved_credit", "integer", ["null" => false, "default" => 0, "after" => "approved"]);
|
||||
$table->addColumn("crediting_partner_id", "integer", ["null" => true, "default" => null, "after" => "orderproduct_id"]);
|
||||
$table->addColumn("crediting_partner_rate", "decimal", ["null" => true, "default" => null, "precision" => 10, "scale" => 4, "after" => "crediting_partner_id"]);
|
||||
$table->addColumn("reseller_id", "integer", ["null" => true, "default" => null, "after" => "crediting_partner_rate"]);
|
||||
$table->addColumn("reseller_rate", "decimal", ["null" => true, "default" => null, "precision" => 10, "scale" => 4, "after" => "reseller_id"]);
|
||||
$table->addIndex("order_id");
|
||||
$table->addIndex("orderproduct_id");
|
||||
$table->update();
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$table = $this->table("Contractqueue");
|
||||
$table->removeIndex("orderproduct_id");
|
||||
$table->removeIndex("order_id");
|
||||
$table->removeColumn("reseller_rate");
|
||||
$table->removeColumn("reseller_id");
|
||||
$table->removeColumn("crediting_partner_rate");
|
||||
$table->removeColumn("crediting_partner_id");
|
||||
$table->update();
|
||||
|
||||
$table = $this->table("Contract");
|
||||
$table->removeIndex("orderproduct_id");
|
||||
$table->removeColumn("reseller_rate");
|
||||
$table->removeColumn("reseller_id");
|
||||
$table->removeColumn("crediting_partner_rate");
|
||||
$table->removeColumn("crediting_partner_id");
|
||||
$table->save();
|
||||
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class ContractLinkAddTypeCredit extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$table = $this->table("ContractLink");
|
||||
$table->changeColumn("type", "enum", ["null" => false, "values" => "link,upgrade,downgrade,relocation,productchange,credit"]);
|
||||
$table->update();
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$table = $this->table("ContractLink");
|
||||
$table->changeColumn("type", "enum", ["null" => false, "values" => "link,upgrade,downgrade,relocation,productchange"]);
|
||||
$table->update();
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class ProducttechAttributeAddType extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$table = $this->table("ProducttechAttribute");
|
||||
$table->addColumn("type", "string", ["null" => false, "default" => "text", "limit" => 64, "after" => "name"]);
|
||||
$table->save();
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$this->table("ProducttechAttribute")->removeColumn("type")->save();
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
34
db/migrations/20240202152709_hausnummer_add_subcd.php
Normal file
34
db/migrations/20240202152709_hausnummer_add_subcd.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class HausnummerAddSubcd extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
$table = $this->table("Hausnummer");
|
||||
$table->addColumn("subcd", "integer", ["null" => true, "default" => null, "after" => "adrcd"]);
|
||||
$table->addIndex(["adrcd", "subcd"]);
|
||||
$table->update();
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
$table = $this->table("Hausnummer");
|
||||
$table->removeIndex(["adrcd", "subcd"]);
|
||||
$table("Hausnummer")->removeColumn("subcd");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class OrderChangeOrderdateDefaultNull extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$table = $this->table("Order");
|
||||
$table->changeColumn("order_date", "integer", ["null" => true, "default" => null]);
|
||||
$table->update();
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class ProductOrderContractAddContractTerm extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$table = $this->table("Product");
|
||||
$table->addColumn("contract_term", "integer", ["null" => false, "default" => 12, "after" => "billing_period"]);
|
||||
$table->update();
|
||||
|
||||
$table = $this->table("OrderProduct");
|
||||
$table->addColumn("contract_term", "integer", ["null" => false, "default" => 12, "after" => "billing_period"]);
|
||||
$table->update();
|
||||
|
||||
$table = $this->table("Contract");
|
||||
$table->addColumn("contract_term", "integer", ["null" => false, "default" => 12, "after" => "billing_period"]);
|
||||
$table->update();
|
||||
|
||||
$table = $this->table("Contractqueue");
|
||||
$table->addColumn("contract_term", "integer", ["null" => false, "default" => 12, "after" => "billing_period"]);
|
||||
$table->update();
|
||||
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$this->table("Contractqueue")->removeColumn("contract_term")->update();
|
||||
$this->table("Contract")->removeColumn("contract_term")->update();
|
||||
$this->table("OrderProduct")->removeColumn("contract_term")->update();
|
||||
$this->table("Product")->removeColumn("contract_term")->update();
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,9 +45,9 @@ class FronkDB {
|
||||
}
|
||||
mysqli_select_db($this->link,$this->db) or die("Error connecting to database...".mysqli_error($this->link));
|
||||
if(function_exists("mysqli_set_charset")) {
|
||||
mysqli_set_charset($this->link,'utf8');
|
||||
mysqli_set_charset($this->link,'utf8mb4');
|
||||
} else {
|
||||
$this->query("SET NAMES utf8");
|
||||
$this->query("SET NAMES utf8mb4");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ class mfConfig {
|
||||
private $me;
|
||||
|
||||
public function __construct($name) {
|
||||
$this->db = new FronkDB();
|
||||
$this->db = FronkDB::singleton();
|
||||
|
||||
$name = $this->db->escape($name);
|
||||
$this->name = $name;
|
||||
|
||||
@@ -118,7 +118,7 @@ class mfLoginController extends mfBaseController
|
||||
|
||||
public static function isLoggedIn()
|
||||
{
|
||||
$db = new FronkDB();
|
||||
$db = FronkDB::singleton();
|
||||
if (!defined("MFAPPNAME")) define("MFAPPNAME", "mvcfronk");
|
||||
if (!defined("MFUSERTABLE")) define("MFUSERTABLE", "mfWorker");
|
||||
|
||||
|
||||
@@ -6,11 +6,12 @@ class mfRequest {
|
||||
protected $request = [];
|
||||
|
||||
public function __construct(Array $request = []) {
|
||||
$_request = [];
|
||||
if(count($request)) {
|
||||
$this->request = $request;
|
||||
// get request from argument
|
||||
$_request = $request;
|
||||
} else {
|
||||
// get request from POST/GET
|
||||
$_request = [];
|
||||
if(isset($_GET)) {
|
||||
$_request = array_merge($_request, $_GET);
|
||||
}
|
||||
@@ -20,10 +21,16 @@ class mfRequest {
|
||||
if(!count($_request)) {
|
||||
return true;
|
||||
}
|
||||
foreach($_request as $key => $name) {
|
||||
$this->original_request[$key] = $name;
|
||||
$this->request[$key] = trim($name);
|
||||
}
|
||||
//var_dump($_request);exit;
|
||||
foreach($_request as $key => $val) {
|
||||
$this->original_request[$key] = $val;
|
||||
if(is_array($val)) {
|
||||
$this->request[$key] = $val;
|
||||
} else {
|
||||
$this->request[$key] = trim($val);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +51,6 @@ class mfRequest {
|
||||
public function get($name = null) {
|
||||
if($name) {
|
||||
if(array_key_exists($name, $this->request)) {
|
||||
//var_dump($this->request);exit;
|
||||
return $this->request[$name];
|
||||
} else {
|
||||
return null;
|
||||
@@ -56,7 +62,6 @@ class mfRequest {
|
||||
public function getUnmodified($name = null) {
|
||||
if($name) {
|
||||
if(array_key_exists($name, $this->original_request)) {
|
||||
//var_dump($this->request);exit;
|
||||
return $this->original_request[$name];
|
||||
} else {
|
||||
return null;
|
||||
@@ -65,6 +70,11 @@ class mfRequest {
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
public function isset($name) {
|
||||
if(!$name) return false;
|
||||
return array_key_exists($name, $this->request);
|
||||
}
|
||||
|
||||
public function __get($name) {
|
||||
return $this->get($name);
|
||||
}
|
||||
|
||||
@@ -210,6 +210,22 @@ class mfRouter {
|
||||
session_name(MFAPPNAME."_session");
|
||||
session_start();
|
||||
}
|
||||
|
||||
// check for enabled 2FA if authentication is enabled and 2FA is forced
|
||||
if(defined("MFUSELOGIN") && MFUSELOGIN && defined("TT_WORKER_FORCE_2FA") && TT_WORKER_FORCE_2FA && mfLoginController::isLoggedIn()) {
|
||||
$user = new User();
|
||||
$user->loadMe();
|
||||
|
||||
if($user->twofactor < 1 && $classname != "mfLoginController" && $classname != "UserProfileController" && $this->action != "logout" && $this->action != "Logout") {
|
||||
// redirect to UserProfile
|
||||
if(MFUSEFANCYURLS) {
|
||||
header("Location: $baseurl/UserProfile");
|
||||
} else {
|
||||
header("Location: $baseurl?Mod=UserProfile");
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$request['mod'] = ucfirst($this->mod);
|
||||
|
||||
@@ -14,7 +14,7 @@ class Network_60670_1 {
|
||||
*/
|
||||
|
||||
// dererence input array keys into copies
|
||||
foreach(["strasse_name", "hausnummer_name", "addresszusatz", "gem_kz", "gem_name", "ort_name", "plz_name"] as $var) {
|
||||
foreach(["name", "strasse_name", "hausnummer_name", "addresszusatz", "gem_kz", "gem_name", "ort_name", "plz_name"] as $var) {
|
||||
$$var = $data[$var];
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class Network_60670_1 {
|
||||
|
||||
|
||||
// put new values back into original pointer
|
||||
foreach(["strasse_name", "hausnummer_name", "addresszusatz", "gem_kz", "gem_name", "ort_name", "plz_name"] as $var) {
|
||||
foreach(["name", "strasse_name", "hausnummer_name", "addresszusatz", "gem_kz", "gem_name", "ort_name", "plz_name"] as $var) {
|
||||
$data[$var] = $$var;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace ADBRimoImport\ADBAddressHelper\Network;
|
||||
|
||||
/*
|
||||
* Netzgebiet
|
||||
* Premstätten Süd
|
||||
*/
|
||||
class Network_60670_2 {
|
||||
|
||||
public function checkAddress($data) {
|
||||
/*
|
||||
* array keys are a reference their original variables and must be manipulated directly
|
||||
*/
|
||||
|
||||
// dererence input array keys into copies
|
||||
foreach(["name", "strasse_name", "hausnummer_name", "addresszusatz", "gem_kz", "gem_name", "ort_name", "plz_name"] as $var) {
|
||||
$$var = $data[$var];
|
||||
}
|
||||
|
||||
if($name == "25158424") $name = "25010770";
|
||||
if($name == "25013230") return false; // ziegelstraße 32 doppelt
|
||||
if($name == "25012523") return false; // Hauptstrasse 134 doppelt
|
||||
|
||||
//if($strasse_name == "Schweizerweg") continue;
|
||||
if($strasse_name == "Am Seegrund Parz.") return false;
|
||||
if($strasse_name == "Seering Parz.") {
|
||||
$strasse_name = "Seering";
|
||||
$hausnummer_name = "Parz. $hausnummer_name";
|
||||
}
|
||||
|
||||
if($strasse_name == "Dr.Karl-Renner-Weg") $strasse_name = "Dr.-Karl-Renner-Weg";
|
||||
if($strasse_name == "Doktor-Karl-Renner-Weg") $strasse_name = "Dr.-Karl-Renner-Weg";
|
||||
if($strasse_name == "Bierbaumer Strasse") $strasse_name = "Bierbaumerstrasse";
|
||||
|
||||
if($ort_name == "Oberpremstaetten") $ort_name = "Oberpremstätten";
|
||||
|
||||
// put new values back into original pointer
|
||||
foreach(["name", "strasse_name", "hausnummer_name", "addresszusatz", "gem_kz", "gem_name", "ort_name", "plz_name"] as $var) {
|
||||
$data[$var] = $$var;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace ADBRimoImport\ADBAddressHelper\Network;
|
||||
|
||||
/*
|
||||
* Netzgebiet
|
||||
* Premstätten Süd
|
||||
*/
|
||||
class Network_61105 {
|
||||
|
||||
public function checkAddress($data) {
|
||||
/*
|
||||
* array keys are a reference their original variables and must be manipulated directly
|
||||
*
|
||||
*/
|
||||
|
||||
// dererence input array keys into copies
|
||||
foreach(["name", "strasse_name", "hausnummer_name", "addresszusatz", "gem_kz", "gem_name", "ort_name", "plz_name"] as $var) {
|
||||
$$var = $data[$var];
|
||||
}
|
||||
|
||||
//if($strasse_name == "Bierbaumerstrasse") $strasse_name = "Bierbaumer Strasse";
|
||||
//if($ort_name == "Oberpremstaetten") $ort_name = "Oberpremstätten";
|
||||
|
||||
if($gem_name == "Leoben") $gem_name = "Kalwang";
|
||||
if($ort_name == "Leoben") $ort_name = "Kalwang";
|
||||
|
||||
//if($strasse_hausnummer == "Brudergarten") continue;
|
||||
if($strasse_name == "Brudergarten Kohlbacher") $strasse_name = "Brudergarten";
|
||||
if($strasse_name == "Brudergarten" && !trim($hausnummer_name)) return false;
|
||||
|
||||
/*if(strpos($strasse_hausnummer, '"') !== false) {
|
||||
$m = [];
|
||||
if(preg_match('/^"Sonnenweg (\d+)(?:\s+([^"]+))?/', $strasse_hausnummer, $m)) {
|
||||
$strasse_name = "Sonnenweg";
|
||||
$hausnummer_name = $m[1];
|
||||
if(array_key_exists(2, $m)) {
|
||||
$addresszusatz = $m[2];
|
||||
}
|
||||
echo "$strasse_name $hausnummer_name $addresszusatz\n";
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
// put new values back into original pointer
|
||||
foreach(["name", "strasse_name", "hausnummer_name", "addresszusatz", "gem_kz", "gem_name", "ort_name", "plz_name"] as $var) {
|
||||
$data[$var] = $$var;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace ADBRimoImport\ADBAddressHelper\Network;
|
||||
|
||||
/*
|
||||
* Netzgebiet
|
||||
* St. Stefan ob Stainz
|
||||
*/
|
||||
class Network_C03030 {
|
||||
|
||||
public function checkAddress($data) {
|
||||
/*
|
||||
* array keys are a reference to their original variables and can be manipulated directly
|
||||
*
|
||||
*/
|
||||
|
||||
// dererence input array keys into copies - makes variables available in scope
|
||||
foreach(["name", "strasse_name", "hausnummer_name", "addresszusatz", "gem_kz", "gem_name", "ort_name", "plz_name"] as $var) {
|
||||
$$var = $data[$var];
|
||||
}
|
||||
|
||||
//if($strasse_name == "Radlpass Straße") $strasse_name = "Radlpaßstraße";
|
||||
if($strasse_name == "Wettmannstätten") $strasse_name = "Wettmannstätten";
|
||||
if($strasse_name == "Schönaich GST") return false;
|
||||
|
||||
if($strasse_name == "Schönaich" && $ort_name == "Deutschlandsberg") {
|
||||
$ort_name = "Wettmannstätten";
|
||||
}
|
||||
if($strasse_name == "Wettmannstätten" && $ort_name == "Deutschlandsberg") {
|
||||
$ort_name = "Wettmannstätten";
|
||||
}
|
||||
if($strasse_name == "Zehndorf" && $ort_name == "Deutschlandsberg") {
|
||||
$ort_name = "Wettmannstätten";
|
||||
}
|
||||
|
||||
if($strasse_name == "Wohlsdorfer Straße" && $ort_name == "Preding") {
|
||||
$gem_kz = 60324;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// put new values back into original pointer
|
||||
foreach(["name", "strasse_name", "hausnummer_name", "addresszusatz", "gem_kz", "gem_name", "ort_name", "plz_name"] as $var) {
|
||||
$data[$var] = $$var;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace ADBRimoImport\ADBAddressHelper\Network;
|
||||
|
||||
/*
|
||||
* Netzgebiet
|
||||
* St. Stefan ob Stainz
|
||||
*/
|
||||
class Network_C03070 {
|
||||
|
||||
public function checkAddress($data) {
|
||||
/*
|
||||
* array keys are a reference to their original variables and can be manipulated directly
|
||||
*
|
||||
*/
|
||||
|
||||
// dererence input array keys into copies - makes variables available in scope
|
||||
foreach(["name", "strasse_name", "hausnummer_name", "addresszusatz", "gem_kz", "gem_name", "ort_name", "plz_name"] as $var) {
|
||||
$$var = $data[$var];
|
||||
}
|
||||
|
||||
if($strasse_name == "Radlpass Straße") $strasse_name = "Radlpaßstraße";
|
||||
if($strasse_name == "Sankt Stefan Ob Stainz") $strasse_name = "St. Stefan Ob Stainz";
|
||||
if($strasse_name == "Schilcherlandsiedlung") $strasse_name = "Schilcherland Siedlung";
|
||||
if($strasse_name == "Reichenfeldweg") return false;
|
||||
|
||||
if($strasse_name == "Lemsitz GNR") {
|
||||
$strasse_name = "Lemsitz";
|
||||
$hausnummer_name = "GNR $hausnummer_name";
|
||||
}
|
||||
|
||||
if($strasse_name == "Rossegg" && $gem_kz == "60348") {
|
||||
$gem_kz = "60350";
|
||||
}
|
||||
|
||||
if(strtolower($strasse_name) == "st. stefan ob stainz" && $ort_name == "Deutschlandsberg") {
|
||||
//echo "Changing ort_name to 'Sankt Stefan ob Stainz'\n";
|
||||
$ort_name = "Sankt Stefan ob Stainz";
|
||||
}
|
||||
|
||||
|
||||
// put new values back into original pointer
|
||||
foreach(["name", "strasse_name", "hausnummer_name", "addresszusatz", "gem_kz", "gem_name", "ort_name", "plz_name"] as $var) {
|
||||
$data[$var] = $$var;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace ADBRimoImport\ADBAddressHelper\Network;
|
||||
|
||||
/*
|
||||
* Netzgebiet
|
||||
* Premstätten Süd
|
||||
*/
|
||||
class Network_P_J5B3Q {
|
||||
|
||||
public function checkAddress($data) {
|
||||
/*
|
||||
* array keys are a reference their original variables and must be manipulated directly
|
||||
*/
|
||||
|
||||
// dereference input array keys into copies
|
||||
foreach(["name", "strasse_name", "hausnummer_name", "addresszusatz", "gem_kz", "gem_name", "ort_name", "plz_name"] as $var) {
|
||||
$$var = $data[$var];
|
||||
}
|
||||
|
||||
|
||||
// put new values back into original pointer
|
||||
foreach(["name", "strasse_name", "hausnummer_name", "addresszusatz", "gem_kz", "gem_name", "ort_name", "plz_name"] as $var) {
|
||||
$data[$var] = $$var;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,15 @@ class AddressHelper {
|
||||
$addresszusatz = "";
|
||||
|
||||
$m = [];
|
||||
if(preg_match('/^(\D+)\s+(\d+[a-z0-9\/&#._-]*)(?:\s+((?:gesch(?:ae|ä)ft|werkstatt|betrieb und wohnungen|stg|paketlogistik|cafe|pavillon|pfarrheim|[^ ]*haus|[^ ]*geb(?:ae|ä)ude|[^ ]*halle|[^ ]*schule|Öhlmühle)(?:\s+[a-z0-9]+)?))?/i', $strasse_hausnummer, $m)) {
|
||||
// Lantschern GST 1/5
|
||||
|
||||
if(preg_match('/^(.+)\s+((?:GNR|GST)\s+\.?\d+[a-z0-9\/&#._-]*)(.+)?/i', $strasse_hausnummer, $m)) {
|
||||
$strasse_name = trim($m[1]);
|
||||
$hausnummer_name = trim($m[2]);
|
||||
if(array_key_exists(3, $m)) {
|
||||
$addresszusatz = trim($m[3]);
|
||||
}
|
||||
} elseif(preg_match('/^(\D+)\s+(\d+[a-z0-9\/&#._-]*)(?:\s+((?:gesch(?:ae|ä)ft|werkstatt|betrieb und wohnungen|stg|paketlogistik|cafe|pavillon|pfarrheim|[^ ]*haus|[^ ]*geb(?:ae|ä)ude|[^ ]*halle|[^ ]*schule|Öhlmühle)(?:\s+[a-z0-9]+)?))?/i', $strasse_hausnummer, $m)) {
|
||||
$strasse_name = trim($m[1]);
|
||||
$hausnummer_name = trim($m[2]);
|
||||
if(array_key_exists(3, $m)) {
|
||||
@@ -60,19 +68,21 @@ class AddressHelper {
|
||||
if(array_key_exists(3, $m)) {
|
||||
$addresszusatz = trim($m[3]);
|
||||
}
|
||||
} elseif(preg_match('/^(.+)/i', $strasse_hausnummer, $m)) {
|
||||
} else {
|
||||
return false;
|
||||
} /* elseif(preg_match('/^(.+)/i', $strasse_hausnummer, $m)) {
|
||||
// ignore GST objects
|
||||
return false;
|
||||
$strasse_name = trim($m[1]);
|
||||
}
|
||||
}*/
|
||||
|
||||
return [$strasse_name, $hausnummer_name, $addresszusatz];
|
||||
}
|
||||
|
||||
public function findAddressFromRimoBuilding($building) {
|
||||
public function findUpdateAddressFromRimoBuilding($building) {
|
||||
$hausnummer = false;
|
||||
|
||||
echo "===================================\n";
|
||||
//echo "===================================\n";
|
||||
|
||||
$rimo_id = trim($building->id);
|
||||
|
||||
@@ -81,12 +91,17 @@ class AddressHelper {
|
||||
}
|
||||
|
||||
$name = trim($building->name);
|
||||
|
||||
$strasse_hausnummer = trim($building->address->name);
|
||||
[$strasse_name, $hausnummer_name, $addresszusatz] = $this->splitStreetHausnummer($strasse_hausnummer);
|
||||
$strasse_name = $this->db->escape($strasse_name);
|
||||
$hausnummer_name = $this->db->escape($hausnummer_name);
|
||||
$addresszusatz = $this->db->escape($addresszusatz);
|
||||
$split_result = $this->splitStreetHausnummer($strasse_hausnummer);
|
||||
|
||||
if(!$split_result) {
|
||||
echo "[EE] Hausnummer nicht gefunden in '$strasse_hausnummer' ($rimo_id)\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
$strasse_name = $this->db->escape($split_result[0]);
|
||||
$hausnummer_name = $this->db->escape( $split_result[1]);
|
||||
$addresszusatz = $this->db->escape($split_result[2]);
|
||||
|
||||
$gem_kz = $this->db->escape(trim($building->municipality->name));
|
||||
$gem_name = $this->db->escape(trim($building->municipality->userLabel));
|
||||
@@ -100,11 +115,27 @@ class AddressHelper {
|
||||
$lot_num = $building->address->lotNumber;
|
||||
$fcp_name = false;
|
||||
|
||||
$addr_dbg_str = "strasse: $strasse_name | hausnummer: $hausnummer_name | zusatz: $addresszusatz | gemkz: $gem_kz | gem_name: $gem_name | ort_name: $ort_name | plz_name: $plz_name";
|
||||
echo "$addr_dbg_str\n";
|
||||
$adrcd = false;
|
||||
$subcd = false;
|
||||
$adr = trim($building->foreignId2);
|
||||
$adr_parts = explode("-", $adr);
|
||||
if(count($adr_parts)) {
|
||||
$adrcd = $adr_parts[0];
|
||||
if(array_key_exists(1, $adr_parts)) {
|
||||
$subcd = $adr_parts[1];
|
||||
}
|
||||
}
|
||||
|
||||
$addr_dbg_str = "strasse_hausnummer: $strasse_hausnummer | zusatz: $addresszusatz | gemkz: $gem_kz | gem_name: $gem_name | ort_name: $ort_name | plz_name: $plz_name | adrcd: $adr | $rimo_id";
|
||||
|
||||
if(!$hausnummer_name || !$gem_name || !$plz_name || !$ort_name || !$strasse_name) {
|
||||
echo "[WW] Adressbestandteil fehlt ($addr_dbg_str)\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
// pass variables by ref, so they can be manipulated directly
|
||||
$this->NetworkHelper->checkAddress([
|
||||
$continue = $this->NetworkHelper->checkAddress([
|
||||
"name" => &$name,
|
||||
"strasse_name" => &$strasse_name,
|
||||
"hausnummer_name" => &$hausnummer_name,
|
||||
"addresszusatz" => &$addresszusatz,
|
||||
@@ -114,37 +145,44 @@ class AddressHelper {
|
||||
"plz_name" => &$plz_name
|
||||
]);
|
||||
|
||||
if(!$continue) {
|
||||
echo "[II] ($addr_dbg_str) Wurde aussortiert\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$gemeinde = \ADBGemeindeModel::getFirst(["kennziffer" => $gem_kz]);
|
||||
if(!$gemeinde) {
|
||||
$this->log->warning("[WW] ($addr_dbg_str) Gemeinde nicht gefunden");
|
||||
echo "Gemeinde $gem_name $gem_kz nicht gefunden\n";
|
||||
//$this->log->warning("[EE] Gemeinde $gem_name $gem_kz nicht gefunden ($addr_dbg_str)");
|
||||
echo "[EE] Gemeinde '$gem_name' / '$gem_kz' nicht gefunden ($addr_dbg_str)\n";
|
||||
return false;
|
||||
}
|
||||
$gemeinde_id = $gemeinde->id;
|
||||
|
||||
$adrcd = false;
|
||||
$adr = trim($building->foreignId2);
|
||||
$adr_parts = explode("-", $adr);
|
||||
if(count($adr_parts)) {
|
||||
$adrcd = $adr_parts[0];
|
||||
}
|
||||
|
||||
|
||||
$hausnummer = \ADBHausnummerModel::getFirst(["rimo_id" => $rimo_id]);
|
||||
|
||||
if($hausnummer) {
|
||||
/*if($hausnummer) {
|
||||
echo "found hausnummer from rimo_id $rimo_id\n";
|
||||
}
|
||||
}*/
|
||||
|
||||
if($adrcd && !$hausnummer) {
|
||||
// get Hausnummer to update
|
||||
$hausnummer = \ADBHausnummerModel::getFirst(['adrcd' => $adrcd]);
|
||||
if(!$hausnummer) {
|
||||
if($subcd > 1) {
|
||||
$hausnummer = \ADBHausnummerModel::getFirst(['adrcd' => $adrcd, "subcd" => $subcd]);
|
||||
} else {
|
||||
$hausnummer = \ADBHausnummerModel::getFirst(['adrcd' => $adrcd, "subcd" => "1"]);
|
||||
if(!$hausnummer) {
|
||||
$hausnummer = \ADBHausnummerModel::getFirst(['adrcd' => $adrcd, "subcd" => null]);
|
||||
}
|
||||
}
|
||||
/*if(!$hausnummer) {
|
||||
//echo "Hausnummer adrcd $adrcd not found\n";
|
||||
} else {
|
||||
echo "found hausnummer from adrcd $adrcd\n";
|
||||
//echo "Hausnummer adrcd $adrcd gefunden!\n";
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
if(!$hausnummer) {
|
||||
@@ -152,23 +190,61 @@ class AddressHelper {
|
||||
if(!$hausnummer) {
|
||||
// hausnummer anlegen
|
||||
|
||||
$strasse = \ADBStrasseModel::getFirst(["gemeinde_id" => $gemeinde_id, "name" => $strasse_name]);
|
||||
//if(!$strasse) die("Strasse $strasse_name (gemeinde_id $gemeinde_id; gem_kz $gem_kz) nicht gefunden\n");
|
||||
if(!$strasse) {
|
||||
$strasse = $this->createStreet($gemeinde_id, $strasse_name);
|
||||
echo "[EE] Konnte Strasse $strasse_name in Gemeinde $gemeinde_id nicht anlegen\n";
|
||||
if(!$strasse) return false;
|
||||
$plz = \ADBPlzModel::getFirst(["gemeinde_id" => $gemeinde_id, "plz" => $plz_name]);
|
||||
if(!$plz) {
|
||||
echo "[EE] PLZ '$plz_name' nicht gefunden ($addr_dbg_str)\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
$plz = \ADBPlzModel::getFirst(["gemeinde_id" => $gemeinde_id, "plz" => $plz_name]);
|
||||
if(!$plz) die("PLZ $plz_name nicht gefunden\n");
|
||||
|
||||
$ortschaft = \ADBOrtschaftModel::getFirst(["gemeinde_id" => $gemeinde_id, "name" => $ort_name]);
|
||||
if(!$ortschaft) die("$strasse_hausnummer: ortschaft $ort_name nicht gefunden\n");
|
||||
if(!$ortschaft) {
|
||||
echo "[EE] Ortschaft '$ort_name' nicht gefunden ($addr_dbg_str) \n";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$strasse = \ADBStrasseModel::getFirst(["gemeinde_id" => $gemeinde_id, "name" => $strasse_name]);
|
||||
if(!$strasse) {
|
||||
// try finding strasse with ortschaft prefix
|
||||
$prefix = ($ortschaft->name) ? $ortschaft->name : $gemeinde->name;
|
||||
|
||||
/*if(!$prefix) {
|
||||
echo "[EE] ----------- Kein Prefix\n"; // should not happen
|
||||
return false;
|
||||
}*/
|
||||
|
||||
if($prefix && strpos($strasse_name, "$prefix ") === 0) {
|
||||
$strasse_name_sansprefix = substr($strasse_name, strlen($prefix)+1);
|
||||
if(!$strasse_name_sansprefix) {
|
||||
echo "[EE] Fehler beim prefix entfernen von strasse_name $strasse_name\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
$strasse = \ADBStrasseModel::getFirst(["gemeinde_id" => $gemeinde_id, "name" => "$strasse_name_sansprefix"]);
|
||||
/*if($strasse) {
|
||||
echo "Found strasse '$strasse_name' without prefix '$prefix' (gemeinde_id => $gemeinde_id, name => $strasse_name_sansprefix) ($rimo_id)\n";
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
if(!$strasse) {
|
||||
echo "[EE] Straße '$strasse_name' nicht gefunden ($addr_dbg_str)\n";
|
||||
return false;
|
||||
|
||||
echo "[II] Erstelle Strasse '$strasse_name' ($addr_dbg_str)\n";
|
||||
$strasse = $this->createStreet($gemeinde_id, $strasse_name);
|
||||
if(!$strasse) {
|
||||
echo "[EE] Konnte Strasse '$strasse_name' in Gemeinde '$gemeinde_id' nicht anlegen ($addr_dbg_str)\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$hausnummer_data = [
|
||||
"netzgebiet_id" => $this->netzgebiet->id,
|
||||
"adrcd" => ($adrcd) ? $adrcd : null,
|
||||
"subcd" => ($subcd) ? $subcd : null,
|
||||
"extref" => $name,
|
||||
"ortschaft_id" => $ortschaft->id,
|
||||
"plz_id" => $plz->id,
|
||||
@@ -179,7 +255,7 @@ class AddressHelper {
|
||||
"gps_lat" => $lat,
|
||||
"gps_long" => $long,
|
||||
"unit_count" => ($unit_count) ? $unit_count : 1,
|
||||
"freigabe" => $this->netzgebiet->default_freigabe,
|
||||
"freigabe" => $this->netzgebiet->freigabe,
|
||||
"rimo_id" => $rimo_id,
|
||||
"rimo_fcp_name" => ($fcp_name) ? $fcp_name : null
|
||||
];
|
||||
@@ -188,26 +264,37 @@ class AddressHelper {
|
||||
//echo "----------------------\ncreating hausnummer:\n";
|
||||
//print_r($hausnummer);
|
||||
$hausnummer->save();
|
||||
echo "[CC] Neues Gebäude erstellt ($addr_dbg_str)\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// update hausnummer
|
||||
if($hausnummer->netzgebiet_id != $this->netzgebiet->id) {
|
||||
$hausnummer->netzgebiet_id = $this->netzgebiet->id;
|
||||
//$hausnummer->save();
|
||||
$hausnummer->save();
|
||||
}
|
||||
if($hausnummer->extref != $name) {
|
||||
$hausnummer->extref = $name;
|
||||
//$hausnummer->save();
|
||||
$hausnummer->save();
|
||||
}
|
||||
if($lat && $long) {
|
||||
$hausnummer->gps_lat = (float)$lat;
|
||||
$hausnummer->gps_long = (float)$long;
|
||||
$hausnummer->save();
|
||||
}
|
||||
if($hausnummer->rimo_id != $rimo_id) {
|
||||
$hausnummer->rimo_id = $rimo_id;
|
||||
$hausnummer->save();
|
||||
}
|
||||
|
||||
if($hausnummer->rimo_fcp_name != $fcp_name) {
|
||||
$hausnummer->rimo_fcp_name = $fcp_name;
|
||||
$hausnummer->save();
|
||||
}
|
||||
if($rimo_id) $hausnummer->rimo_id = $rimo_id;
|
||||
if($fcp_name) $hausnummer->rimo_fcp_name = $fcp_name;
|
||||
//$hausnummer->freigabe = $this->netzgebiet->default_freigabe;
|
||||
$hausnummer->save();
|
||||
|
||||
//echo ">>>>>>>>>>>>>>>>>>>\nupdating hausnummer:";
|
||||
//print_r($hausnummer);exit;
|
||||
return $hausnummer;
|
||||
@@ -250,6 +337,7 @@ class AddressHelper {
|
||||
// get Hausnummer to update
|
||||
//echo "Hausnummer per Suche gefunden\n";
|
||||
$data = $this->db->fetch_object($res);
|
||||
//echo "found by strasse/hausnummer/gemeinde\n";
|
||||
return new \ADBHausnummer($data->hausnummer_id);
|
||||
}
|
||||
return false;
|
||||
|
||||
2
scripts/adb-rimo-import/output/.gitignore
vendored
Normal file
2
scripts/adb-rimo-import/output/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
@@ -24,122 +24,157 @@ $mainlog = \mfLoghandler::singleton();
|
||||
$log = new \mfLog_File();
|
||||
$log->init(BASEDIR."/var/log/rimo-import.log");
|
||||
|
||||
$apiOwner = "estmk";
|
||||
$apiEdition = "prod";
|
||||
$apiData = TT_RIMO_API_CREDS[$apiOwner][$apiEdition];
|
||||
$usage = "Usage: ".$argv[0]." [argument]\n\nAvailable arguments:\n\t--list-rimo-clusters\tLists Clusters returned by Rimo API, then exits\n\t--help\t\t\tLists available arguments\n\nRuns import when no argument is given\n\n";
|
||||
$command = false;
|
||||
|
||||
$apiUrl = $apiData["url"];
|
||||
$apiToken = $apiData["key"];
|
||||
|
||||
$epGetClusters = $apiUrl.RIMO_API_JSON_EP_GET_CLUSTERS;
|
||||
$epGetBuildings = $apiUrl.RIMO_API_JSON_EP_GET_BUILDINGS;
|
||||
|
||||
/*
|
||||
if(!defined("RIMO_API_JSON_APIKEY_PROD")) {
|
||||
die("rimo api token not defined!");
|
||||
}*/
|
||||
|
||||
$import_count = 0;
|
||||
|
||||
$baseParams = ['apiKey' => $apiToken];
|
||||
|
||||
$ctxOptsPost = [
|
||||
'http' => [
|
||||
'method' => 'POST',
|
||||
'header' => 'accept: application/json'
|
||||
]
|
||||
];
|
||||
|
||||
$ctxOptsGet = [
|
||||
'http' => [
|
||||
'method' => 'GET',
|
||||
'header' => 'accept: application/json'
|
||||
]
|
||||
];
|
||||
|
||||
$adb = \FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
|
||||
|
||||
/*
|
||||
* Get RIMO Sales Clusters
|
||||
*/
|
||||
|
||||
$params = $baseParams;
|
||||
$qs = http_build_query($params);
|
||||
|
||||
$req_url = $epGetClusters."?".$qs;
|
||||
$req_ctx = stream_context_create($ctxOptsGet);
|
||||
|
||||
echo $req_url."\n";
|
||||
$responseText = file_get_contents($req_url, false, $req_ctx);
|
||||
if($responseText === false) {
|
||||
echo "Error fetching clusters\n";
|
||||
exit;
|
||||
if($argc > 1) {
|
||||
if($argv[1] == "--list-rimo-clusters") {
|
||||
$command = "list-rimo-clusters";
|
||||
} elseif($argv[1] == "--help") {
|
||||
echo $usage;
|
||||
exit(0);
|
||||
} else {
|
||||
die("Invalid argument.\n\n$usage");
|
||||
}
|
||||
}
|
||||
|
||||
$clustersResponse = json_decode($responseText);
|
||||
//var_dump($clustersResponse);
|
||||
//exit;
|
||||
if(!is_object($clustersResponse) || !property_exists($clustersResponse, "item") || !is_array($clustersResponse->item) || !count($clustersResponse->item)) {
|
||||
die("Invalid GetClusters Response\n");
|
||||
}
|
||||
|
||||
foreach($clustersResponse->item as $cluster) {
|
||||
$cluster_rimo_id = $cluster->id;
|
||||
echo "$cluster_rimo_id | name: ".$cluster->name."; label: ".$cluster->userLabel."\n";
|
||||
//continue;
|
||||
$adb_netzgebiet = \ADBNetzgebietModel::getFirst(['rimo_id' => $cluster_rimo_id]);
|
||||
if(!$adb_netzgebiet) {
|
||||
echo "Kein Netzgebiet für Salescluster $cluster_rimo_id (".$cluster->name.")\n";
|
||||
continue;
|
||||
foreach(["estmk", "rml"] as $apiOwner) {
|
||||
$apiEdition = "prod";
|
||||
$apiData = TT_RIMO_API_CREDS[$apiOwner][$apiEdition];
|
||||
|
||||
$apiUrl = $apiData["url"];
|
||||
$apiToken = $apiData["key"];
|
||||
|
||||
if(!$apiUrl || !$apiToken) {
|
||||
echo "Api Daten für $apiOwner unvollständig\n";
|
||||
}
|
||||
|
||||
$AddressHelper = new ADBAddressHelper\AddressHelper(["log" => $log, "db" => $adb, "netzgebiet" => $adb_netzgebiet]);
|
||||
|
||||
$epGetClusters = $apiUrl.RIMO_API_JSON_EP_GET_CLUSTERS;
|
||||
$epGetBuildings = $apiUrl.RIMO_API_JSON_EP_GET_BUILDINGS;
|
||||
$epGetWorkorders = $apiUrl.RIMO_API_JSON_EP_QUERY_WORKORDERS;
|
||||
$epGetService = $apiUrl.RIMO_API_JSON_EP_QUERY_SERVICE;
|
||||
|
||||
$import_count = 0;
|
||||
|
||||
$baseParams = ['apiKey' => $apiToken];
|
||||
$ctxOptsPost = [
|
||||
'http' => [
|
||||
'method' => 'POST',
|
||||
'header' => 'accept: application/json'
|
||||
]
|
||||
];
|
||||
$ctxOptsGet = [
|
||||
'http' => [
|
||||
'method' => 'GET',
|
||||
'header' => 'accept: application/json'
|
||||
]
|
||||
];
|
||||
|
||||
$adb = \FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
|
||||
/*
|
||||
* Get Buildings per SalesCluster
|
||||
* Get RIMO Sales Clusters
|
||||
*/
|
||||
|
||||
$params = $baseParams;
|
||||
$params["clusterId"] = $cluster_rimo_id;
|
||||
$qs = http_build_query($params);
|
||||
|
||||
$req_url = $epGetBuildings."?".$qs;
|
||||
|
||||
$req_url = $epGetClusters."?".$qs;
|
||||
$req_ctx = stream_context_create($ctxOptsGet);
|
||||
|
||||
echo $req_url."\n";
|
||||
|
||||
//echo $req_url."\n";
|
||||
$responseText = file_get_contents($req_url, false, $req_ctx);
|
||||
|
||||
if($responseText === false) {
|
||||
echo "Error fetching Buildings in cluster $cluster_rimo_id (".$cluster->name.")\n";
|
||||
echo "($apiOwner) Error fetching clusters\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
$buildingsResponse = json_decode($responseText);
|
||||
|
||||
if(is_object($buildingsResponse) && property_exists($buildingsResponse, "item") && is_array($buildingsResponse->item) && count($buildingsResponse->item)) {
|
||||
foreach($buildingsResponse->item as $building) {
|
||||
//var_dump($building);
|
||||
if($building->buildingType && $building->buildingType->userLabel != "Greenfield") {
|
||||
|
||||
$clustersResponse = json_decode($responseText);
|
||||
//var_dump($clustersResponse);
|
||||
//exit;
|
||||
if(!is_object($clustersResponse) || !property_exists($clustersResponse, "item") || !is_array($clustersResponse->item) || !count($clustersResponse->item)) {
|
||||
die("($apiOwner) Invalid GetClusters Response\n");
|
||||
}
|
||||
|
||||
foreach($clustersResponse->item as $cluster) {
|
||||
$cluster_rimo_id = $cluster->id;
|
||||
$cluster_name = $cluster->name;
|
||||
//echo "##################################################\n";
|
||||
|
||||
if($command == "list-rimo-clusters") {
|
||||
echo "($apiOwner) $cluster_rimo_id | name: ".$cluster->name."; label: ".$cluster->userLabel."\n";
|
||||
continue;
|
||||
}
|
||||
$adb_netzgebiet = \ADBNetzgebietModel::getFirst(['rimo_id' => $cluster_rimo_id]);
|
||||
if(!$adb_netzgebiet) {
|
||||
//echo "Kein Netzgebiet für Salescluster $cluster_rimo_id (".$cluster->name.")\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
/*if($cluster_rimo_id != "SDISalesCluster_126657212929_1678961358") {
|
||||
// prem sued
|
||||
continue;
|
||||
}*/
|
||||
|
||||
$AddressHelper = new ADBAddressHelper\AddressHelper(["log" => $log, "db" => $adb, "netzgebiet" => $adb_netzgebiet]);
|
||||
|
||||
/*
|
||||
* Get Buildings per SalesCluster
|
||||
*/
|
||||
$params = $baseParams;
|
||||
$params["clusterId"] = $cluster_rimo_id;
|
||||
$qs = http_build_query($params);
|
||||
|
||||
$req_url = $epGetBuildings."?".$qs;
|
||||
$req_ctx = stream_context_create($ctxOptsGet);
|
||||
|
||||
//echo $req_url."\n";
|
||||
$responseText = file_get_contents($req_url, false, $req_ctx);
|
||||
|
||||
if($responseText === false) {
|
||||
echo "Error fetching Buildings in cluster $cluster_rimo_id (".$cluster->name.")\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
$buildingsResponse = json_decode($responseText);
|
||||
|
||||
$hausnummer_count = 0;
|
||||
$hausnummer_found_count = 0;
|
||||
$homes_count = 0;
|
||||
|
||||
if(is_object($buildingsResponse) && property_exists($buildingsResponse, "item") && is_array($buildingsResponse->item) && count($buildingsResponse->item)) {
|
||||
foreach($buildingsResponse->item as $building) {
|
||||
//var_dump($building);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
// ignore buildings without units
|
||||
if(!$building->plannedTU) {
|
||||
continue;
|
||||
}
|
||||
if($building->buildingType && $building->buildingType->userLabel != "Greenfield" && $building->homesCount > 0 && property_exists($building->homes, "item") && is_array($building->homes->item) && count($building->homes->item)) {
|
||||
//print_r($building);exit;
|
||||
|
||||
$rimo_building_id = $building->id;
|
||||
$hausnummer = $AddressHelper->findAddressFromRimoBuilding($building);
|
||||
if(!$hausnummer) {
|
||||
echo "Adresse nicht gefunden: $rimo_building_id\n";
|
||||
if($building->buildingType && $building->buildingType->userLabel == "Greenfield") {
|
||||
//echo $building->id.": ignoring Greenfield\n";
|
||||
continue;
|
||||
}
|
||||
$hausnummer_count++;
|
||||
|
||||
/*
|
||||
// ignore buildings without units
|
||||
if(!$building->plannedTU) {
|
||||
echo $building->id.": no planned TUs\n";
|
||||
continue;
|
||||
}*/
|
||||
|
||||
|
||||
$rimo_building_id = $building->id;
|
||||
$hausnummer = $AddressHelper->findUpdateAddressFromRimoBuilding($building);
|
||||
if(!$hausnummer) {
|
||||
//echo "Adresse nicht gefunden: $rimo_building_id\n";
|
||||
continue;
|
||||
}
|
||||
$hausnummer_found_count++;
|
||||
|
||||
if(!property_exists($building->homes, "item") || !is_array($building->homes->item) | !count($building->homes->item)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$rimo_home_count = count($building->homes->item);
|
||||
|
||||
|
||||
$last_unit_num = 0;
|
||||
$existing_units = [];
|
||||
foreach(\ADBWohneinheitModel::search(["hausnummer_id" => $hausnummer->id]) as $unit) {
|
||||
@@ -148,19 +183,23 @@ foreach($clustersResponse->item as $cluster) {
|
||||
$last_unit_num++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach($building->homes->item as $home) {
|
||||
print_r($home);//exit;
|
||||
//print_r($home);//exit;
|
||||
$homes_count++;
|
||||
$home_rimo_id = $home->id;
|
||||
$home_name = $home->name;
|
||||
|
||||
|
||||
//echo "$home_rimo_id\n";
|
||||
|
||||
if(array_key_exists($home_rimo_id, $existing_units)) {
|
||||
$unit = $existing_units[$home_rimo_id];
|
||||
} else {
|
||||
// find free home without rimo_id
|
||||
$unit = \ADBWohneinheitModel::getFirst(["hausnummer_id" => $hausnummer->id, "extref" => null]);
|
||||
//echo "-- Using free unit\n";
|
||||
}
|
||||
|
||||
|
||||
if(!$unit) {
|
||||
// create unit
|
||||
$unit = \ADBWohneinheitModel::create([
|
||||
@@ -172,25 +211,32 @@ foreach($clustersResponse->item as $cluster) {
|
||||
die("Error saving new unit\n".print_r($home, true));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($unit->extref != $home_rimo_id) {
|
||||
$unit->extref = $home_rimo_id;
|
||||
if(!$unit->save()) {
|
||||
die("Error saving new extref on unit\n".print_r($home, true));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: Status based on execution-/operational-state
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* update FTU data
|
||||
*/
|
||||
$unit_extdata = new \StdClass();
|
||||
if($unit->external_data) {
|
||||
$extdata = json_decode($unit->external_data);
|
||||
|
||||
|
||||
if(is_object($extdata)) {
|
||||
$unit_extdata = $extdata;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(is_array($home->ftus->item) && $home->ftus->item[0]) {
|
||||
echo "in ftu update\n";
|
||||
//echo "in ftu update\n";
|
||||
$ftu_data = new \StdClass();
|
||||
$ftu_data->id = $home->ftus->item[0]->id;
|
||||
$ftu_data->name = $home->ftus->item[0]->name;
|
||||
@@ -198,25 +244,25 @@ foreach($clustersResponse->item as $cluster) {
|
||||
if(!isset($unit_extdata->rimo)) {
|
||||
$unit_extdata->rimo = new \StdClass();
|
||||
}
|
||||
|
||||
|
||||
$unit_extdata->rimo->ftu = $ftu_data;
|
||||
$unit->external_data = json_encode($unit_extdata);
|
||||
if(!$unit->save()) {
|
||||
die("Error saving unit extdata\n".print_f($unit));
|
||||
die("!!! Error saving unit extdata\n".print_f($unit));
|
||||
}
|
||||
|
||||
|
||||
// check OAID
|
||||
if($home->ftus->item[0]->oaidObject->name) {
|
||||
if(property_exists($home->ftus->item[0], "oaidObject") && is_object($home->ftus->item[0]->oaidObject) && $home->ftus->item[0]->oaidObject->name) {
|
||||
if($home->ftus->item[0]->oaidObject->name != $unit->oaid) {
|
||||
if(!$unit->oaid) {
|
||||
// assign oad to home
|
||||
// assign oaid to home
|
||||
$rimo_oaid = $home->ftus->item[0]->oaidObject->name;
|
||||
$oaid = \OpenAccessIdModel::getFirst(["oaid" => $rimo_oaid]);
|
||||
if(!$oaid) {
|
||||
echo "Home hat fremde OAID: $rimo_oaid (Home ".$unit->id."\n";
|
||||
echo "!!! Home hat fremde OAID: $rimo_oaid (Home ".$unit->id."\n";
|
||||
} else {
|
||||
$unit->oaid = $rimo_oaid;
|
||||
|
||||
|
||||
$oaid->assigned = date("U");
|
||||
$oaid->adb_wohneinheit_id = $unit->id;
|
||||
$oaid->termination_id = null;
|
||||
@@ -225,7 +271,7 @@ foreach($clustersResponse->item as $cluster) {
|
||||
if(!$oaid->exported) {
|
||||
$oaid->exported = date("U");
|
||||
}
|
||||
|
||||
|
||||
if($oaid->export_data) {
|
||||
$exp_data = json_decode($oaid->export_data);
|
||||
} else {
|
||||
@@ -239,28 +285,198 @@ foreach($clustersResponse->item as $cluster) {
|
||||
$exp_data->rimo->ftu_id = $ftu_data->id;
|
||||
$exp_data->rimo->ftu_name = $ftu_data->name;
|
||||
$exp_data->rimo->ftu_assigned_date = date("U");
|
||||
|
||||
|
||||
$oaid->exported_to = "rmio";
|
||||
$oaid->export_data = json_encode($exp_data);
|
||||
|
||||
$oaid->save();
|
||||
|
||||
$unit->save();
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
exit;
|
||||
|
||||
// get ports from service
|
||||
$params = $baseParams;
|
||||
$params["homeId"] = $home_rimo_id;
|
||||
$qs = http_build_query($params);
|
||||
|
||||
$req_url = $epGetService."?".$qs;
|
||||
$req_ctx = stream_context_create($ctxOptsGet);
|
||||
|
||||
//echo $req_url."\n";
|
||||
$responseText = file_get_contents($req_url, false, $req_ctx);
|
||||
|
||||
if($responseText === false) {
|
||||
//echo "Error fetching Service for Home $home_rimo_id\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
$serviceResponse = json_decode($responseText);
|
||||
|
||||
if(is_object($serviceResponse) && property_exists($serviceResponse, "item") && is_array($serviceResponse->item) && count($serviceResponse->item)) {
|
||||
foreach($serviceResponse->item as $service) {
|
||||
if($service->masterItem->name != "FTTx Service (red)") continue;
|
||||
if(!is_object($service->portA) || !$service->portA) continue;
|
||||
|
||||
$fixedDN = $service->portA->fixEndDN;
|
||||
|
||||
if($fixedDN) {
|
||||
//echo "fixedDn found: $fixedDN\n";
|
||||
$dn = getServiceDnValues($fixedDN);
|
||||
if(array_key_exists("Shelf", $dn) && array_key_exists("PatchPanel", $dn) && array_key_exists("Port", $dn)) {
|
||||
$sdicluster = null;
|
||||
if(array_key_exists("SDICluster", $dn)) {
|
||||
$sdicluster = $dn['SDICluster'];
|
||||
}
|
||||
$shelf = $dn['Shelf'];
|
||||
$patchpanel = $dn['PatchPanel'];
|
||||
$port = $dn['Port'];
|
||||
|
||||
if($sdicluster) {
|
||||
$unit->patch_cluster = $sdicluster;
|
||||
$unit->save();
|
||||
}
|
||||
if($shelf) {
|
||||
$unit->patch_shelf = $shelf;
|
||||
$unit->save();
|
||||
}
|
||||
if($patchpanel) {
|
||||
$unit->patch_module = $patchpanel;
|
||||
$unit->save();
|
||||
}
|
||||
if($port) {
|
||||
$unit->patch_port = $port;
|
||||
$unit->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//exit;
|
||||
|
||||
// get workorders
|
||||
$params = $baseParams;
|
||||
$params["buildingId"] = $rimo_building_id;
|
||||
$qs = http_build_query($params);
|
||||
|
||||
$req_url = $epGetWorkorders."?".$qs;
|
||||
$req_ctx = stream_context_create($ctxOptsGet);
|
||||
|
||||
//echo $req_url."\n";
|
||||
$responseText = file_get_contents($req_url, false, $req_ctx);
|
||||
|
||||
if($responseText === false) {
|
||||
//echo "Error fetching Workorders for building $rimo_building_id\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
$workordersResponse = json_decode($responseText);
|
||||
|
||||
//print_r($workordersResponse);exit;
|
||||
|
||||
if(is_object($workordersResponse) && property_exists($workordersResponse, "item") && is_array($workordersResponse->item) && count($workordersResponse->item)) {
|
||||
foreach($workordersResponse->item as $workorder) {
|
||||
$rimo_workorder_id = $workorder->id;
|
||||
$rimo_workorder_name = $workorder->name;
|
||||
$workorder_status = $workorder->state->userLabel;
|
||||
$workorder_home_id = $workorder->home->id;
|
||||
|
||||
$wo = \RimoWorkorderModel::getFirst(["rimo_id" => $rimo_workorder_id]);
|
||||
|
||||
if($wo && $workorder_status != $wo->rimo_status) {
|
||||
//echo "Updating Workorder $rimo_workorder_id ($workorder_home_id)\n";
|
||||
$wo->rimo_status = $workorder_status;
|
||||
$wo->save();
|
||||
}
|
||||
|
||||
if(!$wo) {
|
||||
$wo_home = \ADBWohneinheitModel::getFirst(["extref" => $workorder_home_id]);
|
||||
|
||||
if(!$wo_home) {
|
||||
//echo "Home zu Workorder $rimo_workorder_id ($workorder_home_id) nicht gefunden\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
//echo "Creating Workorder $rimo_workorder_id ($workorder_home_id)\n";
|
||||
$wo = \RimoWorkorderModel::create([
|
||||
"adb_wohneinheit_id" => $wo_home->id,
|
||||
"rimo_id" => $rimo_workorder_id,
|
||||
"rimo_name" => $rimo_workorder_name,
|
||||
"rimo_status" => $workorder_status
|
||||
]);
|
||||
if(!$wo->save()) {
|
||||
echo "Fehler beim Erstellen der RimoWorkorder $rimo_workorder_id ($workorder_home_id)\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo "Cluster $cluster_rimo_id ($cluster_name): $hausnummer_count Buildings; $hausnummer_found_count Buildings verarbeitet; $homes_count Homes verarbeitet.\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//echo $response;
|
||||
echo "\n";
|
||||
echo "\n";
|
||||
|
||||
function getServiceDnValues($dn) {
|
||||
$dn = explode(":", $dn);
|
||||
$fields = [];
|
||||
|
||||
foreach($dn as $d) {
|
||||
$m = [];
|
||||
if(preg_match('/^([^{]+)\{([^}]+)\}$/',$d, $m)) {
|
||||
if(!$m[1] || !$m[2]) {
|
||||
continue;
|
||||
}
|
||||
$value = $m[1];
|
||||
$key = $m[2];
|
||||
|
||||
if(array_key_exists($key, $fields)) {
|
||||
if(is_array($fields[$key])) {
|
||||
$fields[$key][] = $value;
|
||||
} else {
|
||||
$tmp = $fields[$key];
|
||||
$fields[$key] = [];
|
||||
$fields[$key][] = $tmp;
|
||||
$fields[$key][] = $value;
|
||||
}
|
||||
} else {
|
||||
$fields[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("Shelf", $fields) && is_array($fields['Shelf'])) {
|
||||
$shelf = implode(" ", $fields['Shelf']);
|
||||
$fields['Shelf'] = $shelf;
|
||||
}
|
||||
|
||||
if(!array_key_exists("PatchPanel", $fields) && array_key_exists("Shelf", $fields)) {
|
||||
$m = [];
|
||||
if(preg_match('/^([MB]\d[^ ]*)\s+([MB]\d[^ ]*)/i', $fields['Shelf'], $m)) {
|
||||
foreach([1,2] as $i) {
|
||||
if(strlen($m[$i])) {
|
||||
$letter = substr(strtoupper($m[$i]), 0, 1);
|
||||
if($letter == "B") {
|
||||
$fields['Shelf'] = $m[$i];
|
||||
}
|
||||
if($letter == "M") {
|
||||
$fields['PatchPanel'] = $m[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
@@ -1,356 +0,0 @@
|
||||
https://rimo-saas.com/CRM2RIMO/prod/getBuildings?apiKey=323D33323DC0F8D96BB3C403324D1B7B2F7294FEF981ACF2059BE2B3ACB80EA389D079918FFBAD831861C1850F4046AB&clusterId=SDISalesCluster_126657212929_1678961358
|
||||
===================================
|
||||
strasse: Bierbaum | hausnummer: 62 | zusatz: | gemkz: 60670 | gem_name: Premstätten | ort_name: Bierbaum | plz_name: 8141
|
||||
found hausnummer from rimo_id SDIBuilding_689339860481_1617191662
|
||||
stdClass Object
|
||||
(
|
||||
[id] => SDIHome_63149132801_1664900169
|
||||
[name] => 25011048.01
|
||||
[userLabel] =>
|
||||
[lastHistoryEntry] =>
|
||||
[className] =>
|
||||
[executionState] => stdClass Object
|
||||
(
|
||||
[name] => 3
|
||||
[userLabel] => Plan released
|
||||
)
|
||||
|
||||
[operationalState] => stdClass Object
|
||||
(
|
||||
[name] => 10
|
||||
[userLabel] => Planned
|
||||
)
|
||||
|
||||
[subAddress] =>
|
||||
[ftus] => stdClass Object
|
||||
(
|
||||
[item] => Array
|
||||
(
|
||||
[0] => stdClass Object
|
||||
(
|
||||
[id] => SDMMaterial_63149135105_0
|
||||
[name] => G241.01
|
||||
[userLabel] =>
|
||||
[lastHistoryEntry] =>
|
||||
[className] =>
|
||||
[oaidObject] => stdClass Object
|
||||
(
|
||||
[id] => SDIOAIDObject_277465606401_1698935360
|
||||
[name] => KWD7M4L0
|
||||
[userLabel] =>
|
||||
[lastHistoryEntry] => 1698935360
|
||||
[className] => SDIOAIDObject
|
||||
[terminiationUnit] =>
|
||||
[linkObjects] => stdClass Object
|
||||
(
|
||||
[id] =>
|
||||
[name] =>
|
||||
[userLabel] =>
|
||||
[lastHistoryEntry] =>
|
||||
[className] =>
|
||||
[item] => Array
|
||||
(
|
||||
[0] => stdClass Object
|
||||
(
|
||||
[id] =>
|
||||
[name] => KWD7M4L0.001
|
||||
[userLabel] =>
|
||||
[lastHistoryEntry] =>
|
||||
[className] =>
|
||||
[terminiationUnit] => stdClass Object
|
||||
(
|
||||
[id] => SDMPort_63149135617_1698935360
|
||||
[name] => 1
|
||||
[userLabel] =>
|
||||
[lastHistoryEntry] =>
|
||||
[className] =>
|
||||
[oaidObject] =>
|
||||
)
|
||||
|
||||
[linkObjects] =>
|
||||
[oaidObject] =>
|
||||
[portZ] => stdClass Object
|
||||
(
|
||||
[id] =>
|
||||
[name] => 1
|
||||
[userLabel] =>
|
||||
[lastHistoryEntry] =>
|
||||
[className] =>
|
||||
[functionalState] => stdClass Object
|
||||
(
|
||||
[name] => 1
|
||||
[userLabel] => Good
|
||||
)
|
||||
|
||||
[masterItem] => stdClass Object
|
||||
(
|
||||
[id] =>
|
||||
[name] => SC/APC
|
||||
[userLabel] =>
|
||||
[lastHistoryEntry] =>
|
||||
[className] =>
|
||||
)
|
||||
|
||||
[fixEndDN] => root{SDMRoot}:Locations{SDILocationRoot}:Austria{SDICountry}:ST{SDIState}:GU{SDIPoliticalDistrict}:60670{SDIMunicipality}:63206{SDICadastralMunicipality}:1168927{SDIBuilding}:25011048.01{SDIHome}:G241.01{TerminationDevice}:1{Port}
|
||||
[home] =>
|
||||
[parent] =>
|
||||
)
|
||||
|
||||
[services] => stdClass Object
|
||||
(
|
||||
[item] => Array
|
||||
(
|
||||
[0] => stdClass Object
|
||||
(
|
||||
[id] => SDIService_63157655297_1664900174
|
||||
[name] => 108SL1
|
||||
[userLabel] =>
|
||||
[lastHistoryEntry] => 1664900174
|
||||
[className] => SDIService
|
||||
[operationalState] => stdClass Object
|
||||
(
|
||||
[name] => 10
|
||||
[userLabel] => Planned
|
||||
)
|
||||
|
||||
[masterItem] => stdClass Object
|
||||
(
|
||||
[id] => SDMServiceMasterItem_1025929847553_0
|
||||
[name] => FTTx Service (red)
|
||||
[userLabel] =>
|
||||
[lastHistoryEntry] => 1664892065
|
||||
[className] => SDMServiceMasterItem
|
||||
)
|
||||
|
||||
[active] =>
|
||||
[state] => stdClass Object
|
||||
(
|
||||
[name] => 1
|
||||
[userLabel] => undefined
|
||||
)
|
||||
|
||||
[customerId] =>
|
||||
[customerState] =>
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[1] => stdClass Object
|
||||
(
|
||||
[id] =>
|
||||
[name] => KWD7M4L0.002
|
||||
[userLabel] =>
|
||||
[lastHistoryEntry] =>
|
||||
[className] =>
|
||||
[terminiationUnit] => stdClass Object
|
||||
(
|
||||
[id] => SDMPort_63149136641_1698935360
|
||||
[name] => 2
|
||||
[userLabel] =>
|
||||
[lastHistoryEntry] =>
|
||||
[className] =>
|
||||
[oaidObject] =>
|
||||
)
|
||||
|
||||
[linkObjects] =>
|
||||
[oaidObject] =>
|
||||
[portZ] => stdClass Object
|
||||
(
|
||||
[id] =>
|
||||
[name] => 2
|
||||
[userLabel] =>
|
||||
[lastHistoryEntry] =>
|
||||
[className] =>
|
||||
[functionalState] => stdClass Object
|
||||
(
|
||||
[name] => 1
|
||||
[userLabel] => Good
|
||||
)
|
||||
|
||||
[masterItem] => stdClass Object
|
||||
(
|
||||
[id] =>
|
||||
[name] => SC/APC
|
||||
[userLabel] =>
|
||||
[lastHistoryEntry] =>
|
||||
[className] =>
|
||||
)
|
||||
|
||||
[fixEndDN] => root{SDMRoot}:Locations{SDILocationRoot}:Austria{SDICountry}:ST{SDIState}:GU{SDIPoliticalDistrict}:60670{SDIMunicipality}:63206{SDICadastralMunicipality}:1168927{SDIBuilding}:25011048.01{SDIHome}:G241.01{TerminationDevice}:2{Port}
|
||||
[home] =>
|
||||
[parent] =>
|
||||
)
|
||||
|
||||
[services] => stdClass Object
|
||||
(
|
||||
[item] => Array
|
||||
(
|
||||
[0] => stdClass Object
|
||||
(
|
||||
[id] => SDIService_63157653249_1664900174
|
||||
[name] => 108SL2
|
||||
[userLabel] =>
|
||||
[lastHistoryEntry] => 1664900174
|
||||
[className] => SDIService
|
||||
[operationalState] => stdClass Object
|
||||
(
|
||||
[name] => 10
|
||||
[userLabel] => Planned
|
||||
)
|
||||
|
||||
[masterItem] => stdClass Object
|
||||
(
|
||||
[id] => SDMServiceMasterItem_1025929848833_0
|
||||
[name] => FTTx Service (blue)
|
||||
[userLabel] =>
|
||||
[lastHistoryEntry] => 1664892070
|
||||
[className] => SDMServiceMasterItem
|
||||
)
|
||||
|
||||
[active] =>
|
||||
[state] => stdClass Object
|
||||
(
|
||||
[name] => 1
|
||||
[userLabel] => undefined
|
||||
)
|
||||
|
||||
[customerId] =>
|
||||
[customerState] =>
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[2] => stdClass Object
|
||||
(
|
||||
[id] =>
|
||||
[name] => KWD7M4L0.003
|
||||
[userLabel] =>
|
||||
[lastHistoryEntry] =>
|
||||
[className] =>
|
||||
[terminiationUnit] => stdClass Object
|
||||
(
|
||||
[id] => SDMPort_63149136897_1698935360
|
||||
[name] => 3
|
||||
[userLabel] =>
|
||||
[lastHistoryEntry] =>
|
||||
[className] =>
|
||||
[oaidObject] =>
|
||||
)
|
||||
|
||||
[linkObjects] =>
|
||||
[oaidObject] =>
|
||||
[portZ] => stdClass Object
|
||||
(
|
||||
[id] =>
|
||||
[name] => 3
|
||||
[userLabel] =>
|
||||
[lastHistoryEntry] =>
|
||||
[className] =>
|
||||
[functionalState] => stdClass Object
|
||||
(
|
||||
[name] => 1
|
||||
[userLabel] => Good
|
||||
)
|
||||
|
||||
[masterItem] => stdClass Object
|
||||
(
|
||||
[id] =>
|
||||
[name] => SC/APC
|
||||
[userLabel] =>
|
||||
[lastHistoryEntry] =>
|
||||
[className] =>
|
||||
)
|
||||
|
||||
[fixEndDN] => root{SDMRoot}:Locations{SDILocationRoot}:Austria{SDICountry}:ST{SDIState}:GU{SDIPoliticalDistrict}:60670{SDIMunicipality}:63206{SDICadastralMunicipality}:1168927{SDIBuilding}:25011048.01{SDIHome}:G241.01{TerminationDevice}:3{Port}
|
||||
[home] =>
|
||||
[parent] =>
|
||||
)
|
||||
|
||||
[services] => stdClass Object
|
||||
(
|
||||
[item] => Array
|
||||
(
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[3] => stdClass Object
|
||||
(
|
||||
[id] =>
|
||||
[name] => KWD7M4L0.004
|
||||
[userLabel] =>
|
||||
[lastHistoryEntry] =>
|
||||
[className] =>
|
||||
[terminiationUnit] => stdClass Object
|
||||
(
|
||||
[id] => SDMPort_63149157889_1698935360
|
||||
[name] => 4
|
||||
[userLabel] =>
|
||||
[lastHistoryEntry] =>
|
||||
[className] =>
|
||||
[oaidObject] =>
|
||||
)
|
||||
|
||||
[linkObjects] =>
|
||||
[oaidObject] =>
|
||||
[portZ] => stdClass Object
|
||||
(
|
||||
[id] =>
|
||||
[name] => 4
|
||||
[userLabel] =>
|
||||
[lastHistoryEntry] =>
|
||||
[className] =>
|
||||
[functionalState] => stdClass Object
|
||||
(
|
||||
[name] => 1
|
||||
[userLabel] => Good
|
||||
)
|
||||
|
||||
[masterItem] => stdClass Object
|
||||
(
|
||||
[id] =>
|
||||
[name] => SC/APC
|
||||
[userLabel] =>
|
||||
[lastHistoryEntry] =>
|
||||
[className] =>
|
||||
)
|
||||
|
||||
[fixEndDN] => root{SDMRoot}:Locations{SDILocationRoot}:Austria{SDICountry}:ST{SDIState}:GU{SDIPoliticalDistrict}:60670{SDIMunicipality}:63206{SDICadastralMunicipality}:1168927{SDIBuilding}:25011048.01{SDIHome}:G241.01{TerminationDevice}:4{Port}
|
||||
[home] =>
|
||||
[parent] =>
|
||||
)
|
||||
|
||||
[services] => stdClass Object
|
||||
(
|
||||
[item] => Array
|
||||
(
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
151
scripts/fibu-check/compare-addresses-from-fibu.php
Normal file
151
scripts/fibu-check/compare-addresses-from-fibu.php
Normal file
@@ -0,0 +1,151 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
//require 'vendor/autoload.php';
|
||||
require("../../config/config.php");
|
||||
|
||||
define('FRONKDB_SQLDEBUG',false);
|
||||
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
|
||||
|
||||
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
|
||||
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
|
||||
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
|
||||
|
||||
$me = new User(1);
|
||||
|
||||
$folder = __DIR__."/files/";
|
||||
$csvname = "Kontaktliste.csv";
|
||||
$filename = $folder.$csvname;
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
$log = mfLoghandler::singleton();
|
||||
|
||||
$input = fopen($filename, "r");
|
||||
|
||||
$l = 0;
|
||||
while($csv = fgetcsv($input)) {
|
||||
$l++;
|
||||
if($l == 1) continue;
|
||||
|
||||
if(!trim($csv[0])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//var_dump($csv);exit;
|
||||
|
||||
$fibu_account_number = trim($csv[1]);
|
||||
$fibu_supplier_number = trim($csv[3]);
|
||||
|
||||
$lastname = trim($csv[4]);
|
||||
$firstname = trim($csv[5]);
|
||||
$company = trim($csv[6]);
|
||||
|
||||
$street = trim($csv[7]);
|
||||
$zip = trim($csv[8]);
|
||||
$city = trim($csv[9]);
|
||||
$country = trim($csv[10]);
|
||||
|
||||
$uid = strtoupper(trim($csv[11]));
|
||||
$email = trim($csv[12]);
|
||||
|
||||
$iban = strtoupper(trim($csv[13]));
|
||||
$bic = strtoupper(trim($csv[14]));
|
||||
|
||||
|
||||
if(!$fibu_account_number && !$fibu_supplier_number) {
|
||||
echo "invalid line: ".implode(", ", $csv)."\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
$address = false;
|
||||
$supplier = false;
|
||||
|
||||
if($fibu_account_number) {
|
||||
$address = AddressModel::getFirst(["fibu_account_number" => $fibu_account_number]);
|
||||
if(!$address) {
|
||||
echo "Kunde $fibu_account_number ($company $firstname $lastname) missing in thetool\n";
|
||||
}
|
||||
if(!$address->fibu_primary_account) {
|
||||
$primary = AddressModel::getFirst(["fibu_account_number" => $fibu_account_number, "fibu_primary_account" => 1]);
|
||||
if($primary) $address = $primary;
|
||||
}
|
||||
}
|
||||
|
||||
if($fibu_supplier_number) {
|
||||
$supplier = AddressModel::getFirst(["fibu_supplier_number" => $fibu_supplier_number]);
|
||||
if(!$supplier) {
|
||||
echo "Lieferant $fibu_supplier_number ($company $firstname $lastname) missing in thetool\n";
|
||||
|
||||
$supplier = AddressModel::create([
|
||||
"fibu_supplier_number" => $fibu_supplier_number,
|
||||
"company" => $company,
|
||||
"lastname" => $lastname,
|
||||
"firstname" => $firstname,
|
||||
"street" => $street,
|
||||
"zip" => $zip,
|
||||
"city" => $city,
|
||||
"country" => $country,
|
||||
"uid" => $uid,
|
||||
"email" => $email,
|
||||
"phone" => "",
|
||||
"fax" => "",
|
||||
"mobile" => "",
|
||||
"create_by" => 1,
|
||||
"edit_by" => 1
|
||||
]);
|
||||
if(!$supplier->save()) {
|
||||
die("Error saving supplier $fibu_supplier_number\n");
|
||||
}
|
||||
//var_dump($supplier);exit;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if($supplier) $address = $supplier;
|
||||
if(!$address) continue;
|
||||
|
||||
// check UID
|
||||
if($uid && $address->uid != $uid) {
|
||||
echo "UID weicht ab: ".$address->uid." vs. $uid ($fibu_account_number $fibu_supplier_number)\n";
|
||||
$address->uid = $uid;
|
||||
if($fibu_supplier_number != 330189) {
|
||||
$address->save();
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
// check bankdata
|
||||
|
||||
$a_iban = strtoupper(trim($address->bank_account_iban));
|
||||
$a_bic = strtoupper(trim($address->bank_account_bic));
|
||||
|
||||
if($supplier) {
|
||||
if(!$iban || !$bic) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!$a_iban && !$a_bic) {
|
||||
echo "Bankdaten im tool fehlen\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
$ibans = explode("\n", $iban);
|
||||
$bics = explode("\n", $bic);
|
||||
|
||||
if($ibans) {
|
||||
foreach($ibans as $c => $ib) {
|
||||
if(!array_key_exists($c, $bics)) continue;
|
||||
if($ib == $a_iban && $bics[$c] == $a_bic) {
|
||||
echo "Bankdaten in array gefunden\n";
|
||||
continue 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(($iban && $bic) && ($iban != $a_iban || $bic != $a_bic)) {
|
||||
echo "Bankdaten weichen ab (account: $fibu_account_number, supplier: $fibu_supplier_number) thetool iban/bic: $a_iban/$a_bic vs. $iban/$bic\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
74
scripts/fibu-check/compare-bankdata.php
Normal file
74
scripts/fibu-check/compare-bankdata.php
Normal file
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
//require 'vendor/autoload.php';
|
||||
require("../../config/config.php");
|
||||
|
||||
define('FRONKDB_SQLDEBUG',false);
|
||||
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
|
||||
|
||||
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
|
||||
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
|
||||
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
|
||||
|
||||
$me = new User(1);
|
||||
|
||||
$folder = __DIR__."/files/";
|
||||
$csvname = "bankdaten-liste.csv";
|
||||
$filename = $folder.$csvname;
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
$log = mfLoghandler::singleton();
|
||||
|
||||
$input = fopen($filename, "r");
|
||||
|
||||
$l = 0;
|
||||
while($csv = fgetcsv($input, 0, ";")) {
|
||||
$l++;
|
||||
if($l == 1) continue;
|
||||
|
||||
if(!trim($csv[0])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//var_dump($csv);exit;
|
||||
|
||||
$fibu_supplier_number = trim($csv[0]);
|
||||
$iban = trim($csv[1]);
|
||||
|
||||
$supplier = AddressModel::getFirst(["fibu_supplier_number" => $fibu_supplier_number]);
|
||||
if(!$supplier) {
|
||||
echo "Supplier not found $fibu_supplier_number\n";
|
||||
}
|
||||
|
||||
echo $supplier->getCompanyOrName()."\n";
|
||||
|
||||
$result = IbanValidator::validate($iban);
|
||||
if(is_array($result) && $result) {
|
||||
var_dump($result);
|
||||
|
||||
if(!$result["iban_correct"]) {
|
||||
echo "IBAN incorrect: $iban\n";
|
||||
continue;
|
||||
}
|
||||
if($result["iban_sus"] && $result["iban_sus"] != "www") {
|
||||
echo "IBAN suspicious: $iban\n";
|
||||
}
|
||||
|
||||
if(is_array($result["bic"]) && count($result["bic"])) {
|
||||
$bic = array_shift($result["bic"]);
|
||||
|
||||
if($supplier->bank_account_iban != $iban || $supplier->bank_account_bic != $bic) {
|
||||
$supplier->bank_account_iban = $iban;
|
||||
$supplier->bank_account_bic = $bic;
|
||||
$supplier->save();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
echo "Bic nicht gefunden: $iban\n";
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
6269
scripts/fibu-check/files/Kontaktliste.csv
Normal file
6269
scripts/fibu-check/files/Kontaktliste.csv
Normal file
File diff suppressed because it is too large
Load Diff
36
scripts/fibu-check/files/bankdaten-liste.csv
Normal file
36
scripts/fibu-check/files/bankdaten-liste.csv
Normal file
@@ -0,0 +1,36 @@
|
||||
Worxx Fibukonto Lieferant;IBAN
|
||||
330083;AT153846000010360287
|
||||
330025;AT126000000007501818
|
||||
330139;AT253800000000018036
|
||||
330197;AT422081507000000500
|
||||
330012;AT682081500041151259
|
||||
330028;AT173807100000001917
|
||||
330022;DE46100400000592222400
|
||||
330051;AT503620000000258707
|
||||
330091;AT963400000000026864
|
||||
330042;CZ2803000000000206315868
|
||||
330085;AT033800000000836239
|
||||
330086;AT653800000000050005
|
||||
330029;AT141500000711137802
|
||||
330211;
|
||||
330071;AT911100002883352300
|
||||
330011;AT331200010002969961
|
||||
330102;AT451100002883040400
|
||||
330075;AT023818700000047100
|
||||
330077;AT453818700000024307
|
||||
330004;AT391200050660059006
|
||||
330027;AT373837400000000042
|
||||
330176;AT692081527300008888
|
||||
330062;AT883805600000072785
|
||||
330260;AT313807500005505037
|
||||
330064;AT191200052496481505
|
||||
330038;DE08741400480351857800
|
||||
330237;AT055600021253030655
|
||||
330271;AT173800000005190996
|
||||
330100;AT402081500001852698
|
||||
330063;AT724501000004101051
|
||||
330110;
|
||||
330060;AT263818700000196048
|
||||
330296;
|
||||
330268;AT871952000200553030
|
||||
330093;AT704232030054360002
|
||||
|
45
scripts/import-sepa-date-from-ivt.php
Executable file
45
scripts/import-sepa-date-from-ivt.php
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
//require 'vendor/autoload.php';
|
||||
require("../config/config.php");
|
||||
|
||||
define('FRONKDB_SQLDEBUG',false);
|
||||
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
|
||||
|
||||
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
|
||||
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
|
||||
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
|
||||
|
||||
$me = new User(1);
|
||||
define("INTERNAL_USER_ID", $me->id);
|
||||
define("INTERNAL_USER_USERNAME", $me->username);
|
||||
|
||||
$i = 0;
|
||||
foreach(AddressModel::search(["customer_number" => true, "billing_type" => "sepa"]) as $address) {
|
||||
if($address->sepa_date) continue;
|
||||
|
||||
$bill = IvtBillModel::getFirst(["cid" => $address->customer_number]);
|
||||
if(!$bill) continue;
|
||||
|
||||
if(!trim($bill->IBAN) || !trim($bill->BIC)) continue;
|
||||
|
||||
if(!$bill->date_outgoing) {
|
||||
echo "date outgoing fehlt im ivt: ".$address->customer_number."\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
$out_date = new DateTime($bill->date_outgoing);
|
||||
$sepa_date = $out_date->getTimestamp();
|
||||
echo "$sepa_date - ".$bill->date_outgoing."\n";
|
||||
|
||||
if(!$sepa_date){
|
||||
echo "Konnte Datum nicht umwandeln\n";
|
||||
}
|
||||
|
||||
$address->sepa_date = $sepa_date;
|
||||
$address->save();
|
||||
$i++;
|
||||
}
|
||||
|
||||
echo "Updated $i addresses\n\n";
|
||||
@@ -17,17 +17,42 @@ define("INTERNAL_USER_USERNAME", $me->username);
|
||||
|
||||
$ignore_preorders = [];
|
||||
|
||||
$campaign_prem_nord = 5;
|
||||
$campaign_prem_sued = 6;
|
||||
$campaign_gross_st_florian = 7;
|
||||
$same_unit_count = 0;
|
||||
$campaign_ids = [];
|
||||
$campaign_ids["premnord"] = 5;
|
||||
$campaign_ids["premsued"] = 6;
|
||||
$campaign_ids["gsf"] = 7;
|
||||
$campaign_ids["kalwang"] = 41;
|
||||
$campaign_ids["st_stefan_stainz"] = 36;
|
||||
$campaign_ids["wettmannst"] = 37;
|
||||
|
||||
if(!array_key_exists(1,$argv)) {
|
||||
|
||||
echo "Bitte eines der folgenden Netzgebiete angeben:\n\n";
|
||||
echo implode("\n", array_keys($campaign_ids));
|
||||
echo "\n\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(!array_key_exists($argv[1], $campaign_ids)) {
|
||||
die("Ungültige Kampagne\n");
|
||||
}
|
||||
|
||||
$selected_campaign = $campaign_ids[$argv[1]];
|
||||
|
||||
if(!$selected_campaign) {
|
||||
echo "Keine Kampagne ausgewählt.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
echo "selected campaign: $selected_campaign - ".$argv[1]."\n";
|
||||
|
||||
$same_unit_count = 0;
|
||||
$missing_units = [];
|
||||
$missing_doors = [];
|
||||
|
||||
$total = 0;
|
||||
$c = 0;
|
||||
foreach(PreorderModel::search(["deleted" => 0, "preordercampaign_id" => $campaign_prem_nord, "connection_count" => 2]) as $preorder) {
|
||||
foreach(PreorderModel::search(["deleted" => 0, "preordercampaign_id" => $selected_campaign, "connection_count" => 2]) as $preorder) {
|
||||
// check if we have enough units with extref
|
||||
$wohneinheiten = ADBWohneinheitModel::search(["hausnummer_id" => $preorder->adb_hausnummer_id]);
|
||||
$unit_count = count($wohneinheiten);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<?php
|
||||
|
||||
//require 'vendor/autoload.php';
|
||||
require("../config/config.php");
|
||||
require("../../config/config.php");
|
||||
|
||||
define('FRONKDB_SQLDEBUG',false);
|
||||
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
|
||||
@@ -17,11 +17,39 @@ define("INTERNAL_USER_USERNAME", $me->username);
|
||||
|
||||
$ignore_preorders = [];
|
||||
|
||||
$campaign_prem_nord = 5;
|
||||
$campaign_ids = [];
|
||||
$campaign_ids["premnord"] = 5;
|
||||
$campaign_ids["premsued"] = 6;
|
||||
$campaign_ids["gsf"] = 7;
|
||||
$campaign_ids["kalwang"] = 41;
|
||||
$campaign_ids["st_stefan_stainz"] = 36;
|
||||
$campaign_ids["wettmannst"] = 37;
|
||||
|
||||
if(!array_key_exists(1,$argv)) {
|
||||
|
||||
echo "Bitte eines der folgenden Netzgebiete angeben:\n\n";
|
||||
echo implode("\n", array_keys($campaign_ids));
|
||||
echo "\n\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(!array_key_exists($argv[1], $campaign_ids)) {
|
||||
die("Ungültige Kampagne\n");
|
||||
}
|
||||
|
||||
$selected_campaign = $campaign_ids[$argv[1]];
|
||||
|
||||
if(!$selected_campaign) {
|
||||
echo "Keine Kampagne ausgewählt.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
echo "selected campaign: $selected_campaign - ".$argv[1]."\n";
|
||||
|
||||
$same_unit_count = 0;
|
||||
|
||||
$i = 0;
|
||||
foreach(PreorderModel::search(['preordercampaign_id' => $campaign_prem_nord, 'adb_wohneinheit_id' => null, 'connection_count' => 1, "connection_type" => "single-dwelling", "deleted" => 0]) as $preorder) {
|
||||
foreach(PreorderModel::search(['preordercampaign_id' => $selected_campaign, 'adb_wohneinheit_id' => null, 'connection_count' => 1, "connection_type" => "single-dwelling", "deleted" => 0]) as $preorder) {
|
||||
if(in_array($preorder->id, $ignore_preorders)) continue;
|
||||
//if($preorder->connection_type != "single-dwelling") continue;
|
||||
|
||||
@@ -49,8 +77,9 @@ foreach(PreorderModel::search(['preordercampaign_id' => $campaign_prem_nord, 'ad
|
||||
}
|
||||
|
||||
|
||||
if($unit_count > 1 && $unit_count <= 4) {
|
||||
// assume its single-dwelling with erroneously high door count
|
||||
if($unit_count > 1) {
|
||||
// legacy comment: assume its single-dwelling with erroneously high door count
|
||||
// current comment: Just use any unit
|
||||
$unit_candidates = [];
|
||||
|
||||
foreach($wohneinheiten as $unit) {
|
||||
@@ -60,19 +89,19 @@ foreach(PreorderModel::search(['preordercampaign_id' => $campaign_prem_nord, 'ad
|
||||
}
|
||||
}
|
||||
|
||||
/*if(!count($unit_candidates)) {
|
||||
// no candidates with door number -> use any
|
||||
|
||||
if(!count($unit_candidates)) {
|
||||
foreach($wohneinheiten as $unit) {
|
||||
if(!$unit->zusatz) continue;
|
||||
if(preg_match('/Top\s+\d+/i',$unit->zusatz)) {
|
||||
$unit_candidates[$unit->zusatz] = $unit;
|
||||
}
|
||||
$unit_candidates[] = $unit;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
if(count($unit_candidates)) {
|
||||
ksort($unit_candidates, SORT_NUMERIC);
|
||||
$new_unit = array_shift($unit_candidates);
|
||||
$preorder->adb_wohneinheit_id = $new_unit->id;
|
||||
//var_dump($preorder, $new_unit);exit;
|
||||
$preorder->save();
|
||||
|
||||
echo "$i Wohneinheit saved\n";
|
||||
@@ -84,5 +113,5 @@ foreach(PreorderModel::search(['preordercampaign_id' => $campaign_prem_nord, 'ad
|
||||
}
|
||||
|
||||
|
||||
echo "Same unit count: $same_unit_count (".$i - $same_unit_count." with different unit count)\n";
|
||||
echo "Same unit count: $same_unit_count (".($i - $same_unit_count)." with different unit count)\n";
|
||||
echo "Processed $i Preorders\n";
|
||||
|
||||
39
scripts/run-bmd-export.php
Executable file
39
scripts/run-bmd-export.php
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
//require 'vendor/autoload.php';
|
||||
require("../config/config.php");
|
||||
|
||||
define('FRONKDB_SQLDEBUG',false);
|
||||
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
|
||||
|
||||
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
|
||||
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
|
||||
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
|
||||
|
||||
$layout = \Layout::singleton();
|
||||
|
||||
$me = new User(1);
|
||||
define("INTERNAL_USER_ID", $me->id);
|
||||
define("INTERNAL_USER_USERNAME", $me->username);
|
||||
|
||||
|
||||
$return = Address::runBmdExport("inc");
|
||||
|
||||
|
||||
if($return === 10) {
|
||||
echo "Export Pfad (".TT_ADDRESS_BMD_EXPORT_PATH.") nicht gefunden!\n";
|
||||
}
|
||||
|
||||
if($return === 11) {
|
||||
echo "Keine geänderten Adressdatensätze gefunden. Export abgebrochen.\n";
|
||||
}
|
||||
|
||||
if($return === 19) {
|
||||
echo "Datei ".TT_ADDRESS_BMD_EXPORT_PATH."/".TT_ADDRESS_BMD_EXPORT_FILENAME." konnte nicht gespeichert werden!\n";
|
||||
}
|
||||
|
||||
if($return === true) {
|
||||
echo "Adressen erfolgreich exportiert\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user