Merge branch 'fronkdev' into 'master'
Updated st. stefan preorder import script See merge request fronk/thetool!25
This commit is contained in:
@@ -84,6 +84,7 @@
|
|||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="float-left">
|
<div class="float-left">
|
||||||
<h4 class="header-title">Rufnummernblöcke</h4>
|
<h4 class="header-title">Rufnummernblöcke</h4>
|
||||||
|
<a class="btn btn-outline-info" href="<?=self::getUrl("Voicenumber", "", ["filter" => ["voicenumberblock_id" => "null"]])?>"><i class="far fa-right-long"></i> Zu Rufnummern ohne Block</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="float-right">
|
<div class="float-right">
|
||||||
<a class="btn btn-primary mb-2" href="<?=self::getUrl("Voicenumberblock", "add")?>"><i class="fas fa-plus"></i> Neuen Rufnummernblock anlegen</a>
|
<a class="btn btn-primary mb-2" href="<?=self::getUrl("Voicenumberblock", "add")?>"><i class="fas fa-plus"></i> Neuen Rufnummernblock anlegen</a>
|
||||||
@@ -144,9 +145,11 @@
|
|||||||
if($('#block-detail-' + id).is(":hidden")) {
|
if($('#block-detail-' + id).is(":hidden")) {
|
||||||
$('#block-' + id).removeClass("table-info");
|
$('#block-' + id).removeClass("table-info");
|
||||||
$('#block-' + id).removeClass("text-info");
|
$('#block-' + id).removeClass("text-info");
|
||||||
|
window.location.hash = "";
|
||||||
} else {
|
} else {
|
||||||
$('#block-' + id).addClass("text-info");
|
$('#block-' + id).addClass("text-info");
|
||||||
$('#block-' + id).addClass("table-info");
|
$('#block-' + id).addClass("table-info");
|
||||||
|
window.location.hash = "#block=" + id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,10 @@ class Contractconfig_Hook_Voicenumberblock extends Contractconfig_Hook {
|
|||||||
$voicenumber = VoicenumberModel::getFirst(['number' => $number]);
|
$voicenumber = VoicenumberModel::getFirst(['number' => $number]);
|
||||||
|
|
||||||
if(!$voicenumber) {
|
if(!$voicenumber) {
|
||||||
$this->log->debug("creating voicenumber $number in block ".$voicenumberblock->prefix);
|
if($voicenumberblock_id == "none") {
|
||||||
|
$voicenumberblock_id = null;
|
||||||
|
}
|
||||||
|
$this->log->debug("creating voicenumber $number in block $voicenumberblock_id");
|
||||||
$voicenumber = VoicenumberModel::create([
|
$voicenumber = VoicenumberModel::create([
|
||||||
'voicenumberblock_id' => $voicenumberblock_id,
|
'voicenumberblock_id' => $voicenumberblock_id,
|
||||||
"contract_id" => $this->contract->id,
|
"contract_id" => $this->contract->id,
|
||||||
@@ -124,42 +127,47 @@ class Contractconfig_Hook_Voicenumberblock extends Contractconfig_Hook {
|
|||||||
|
|
||||||
// check if Voicenumber exists
|
// check if Voicenumber exists
|
||||||
$voicenumberblock = Voicenumberblock::findBlock($number);
|
$voicenumberblock = Voicenumberblock::findBlock($number);
|
||||||
if(!$voicenumberblock) {
|
if(!$voicenumberblock) { // XXX: Create without block!
|
||||||
$this->errors["voicenumberblock_voicenumber"][] = "Ungültige Rufnummer $number: Kein aktiver Rufnummernblock gefunden";
|
//$this->errors["voicenumberblock_voicenumber"][] = "Ungültige Rufnummer $number: Kein aktiver Rufnummernblock gefunden";
|
||||||
continue;
|
//continue;
|
||||||
}
|
if(!array_key_exists("none", $this->create_numbers)) {
|
||||||
|
$this->create_numbers["none"] = [];
|
||||||
|
}
|
||||||
|
$this->create_numbers["none"][] = $number;
|
||||||
|
|
||||||
if(!$voicenumberblock->isNumberInBlock($number)) {
|
} else {
|
||||||
$this->errors["voicenumberblock_voicenumber"][] = "Ungültige Rufnummer $number: Bitte Rufnummernlänge kontrollieren! Block erlaubt ".$voicenumberblock->first ." bis ".$voicenumberblock->last;
|
if(!$voicenumberblock->isNumberInBlock($number)) {
|
||||||
continue;
|
$this->errors["voicenumberblock_voicenumber"][] = "Ungültige Rufnummer $number: Bitte Rufnummernlänge kontrollieren! Block erlaubt ".$voicenumberblock->first ." bis ".$voicenumberblock->last;
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$voicenumber = VoicenumberModel::getFirst(['number' => $number]);
|
$voicenumber = VoicenumberModel::getFirst(['number' => $number]);
|
||||||
if($voicenumber) {
|
if($voicenumber) {
|
||||||
// check if number belongs to another contract
|
// check if number belongs to another contract
|
||||||
if($voicenumber->contract_id) {
|
if($voicenumber->contract_id) {
|
||||||
if($voicenumber->contract_id == $this->contract->id) {
|
if($voicenumber->contract_id == $this->contract->id) {
|
||||||
// belongs to our contract already => no changes needed
|
// belongs to our contract already => no changes needed
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$this->errors["voicenumberblock_voicenumber"][] = "Ungültige Rufnummer $number: Rufnummer gehört zu bestehendem contract ".$voicenumber->contract_id;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$this->errors["voicenumberblock_voicenumber"][] = "Ungültige Rufnummer $number: Rufnummer gehört zu bestehendem contract ".$voicenumber->contract_id;
|
// check if number is locked
|
||||||
continue;
|
if($voicenumber->disabled) {
|
||||||
|
$this->errors["voicenumberblock_voicenumber"][] = "Ungültige Rufnummer $number: Rufnummer ist gesperrt ".$voicenumber->contract_id;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// check if number was ported out
|
||||||
|
if($voicenumber->ported_out) {
|
||||||
|
$this->errors["voicenumberblock_voicenumber"][] = "Ungültige Rufnummer $number: Rufnummer wurde rausportiert ".$voicenumber->contract_id;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(!array_key_exists($voicenumberblock->id, $this->create_numbers)) {
|
||||||
|
$this->create_numbers[$voicenumberblock->id] = [];
|
||||||
|
}
|
||||||
|
$this->create_numbers[$voicenumberblock->id][] = $number;
|
||||||
}
|
}
|
||||||
// check if number is locked
|
|
||||||
if($voicenumber->disabled) {
|
|
||||||
$this->errors["voicenumberblock_voicenumber"][] = "Ungültige Rufnummer $number: Rufnummer ist gesperrt ".$voicenumber->contract_id;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// check if number was ported out
|
|
||||||
if($voicenumber->ported_out) {
|
|
||||||
$this->errors["voicenumberblock_voicenumber"][] = "Ungültige Rufnummer $number: Rufnummer wurde rausportiert ".$voicenumber->contract_id;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(!array_key_exists($voicenumberblock->id, $this->create_numbers)) {
|
|
||||||
$this->create_numbers[$voicenumberblock->id] = [];
|
|
||||||
}
|
|
||||||
$this->create_numbers[$voicenumberblock->id][] = $number;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ class Voicenumber extends mfBaseModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function afterSave() {
|
public function afterSave() {
|
||||||
|
// XXX Move to some ContractConfig add number function
|
||||||
|
|
||||||
// if contract_id is given, add number to contract
|
// if contract_id is given, add number to contract
|
||||||
if($this->contract_id) {
|
if($this->contract_id) {
|
||||||
if(is_array($this->contract->configvalues) && array_key_exists("voicenumberblock_voicenumber", $this->contract->configvalues)) {
|
if(is_array($this->contract->configvalues) && array_key_exists("voicenumberblock_voicenumber", $this->contract->configvalues)) {
|
||||||
|
|||||||
@@ -58,34 +58,27 @@ class VoicenumberController extends mfBaseController {
|
|||||||
$r = $this->request;
|
$r = $this->request;
|
||||||
//var_dump($r);exit;
|
//var_dump($r);exit;
|
||||||
$block_id = $r->block_id;
|
$block_id = $r->block_id;
|
||||||
if(!is_numeric($block_id) || !$block_id) {
|
|
||||||
$this->layout()->setFlash("Rufnummer nicht gefunden1", "error");
|
$num = (string)$r->number;
|
||||||
|
if(!strlen($num)) {
|
||||||
|
$this->layout()->setFlash("Rufnummer nicht gefunden", "error");
|
||||||
$this->redirect("Voicenumberblock");
|
$this->redirect("Voicenumberblock");
|
||||||
}
|
}
|
||||||
|
|
||||||
$block = new Voicenumberblock($block_id);
|
$block = new Voicenumberblock($block_id);
|
||||||
if(!$block->id) {
|
|
||||||
$this->layout()->setFlash("Rufnummer nicht gefunden2", "error");
|
|
||||||
$this->redirect("Voicenumberblock");
|
|
||||||
}
|
|
||||||
|
|
||||||
$num = (string)$r->number;
|
if($block->id && !$block->isNumberInBlock($num)) {
|
||||||
if(!strlen($num)) {
|
|
||||||
$this->layout()->setFlash("Rufnummer nicht gefunden3", "error");
|
|
||||||
$this->redirect("Voicenumberblock", "Index", null, ["block" => $block->id]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!$block->isNumberInBlock($num)) {
|
|
||||||
$this->layout()->setFlash("Rufnummer nicht gefunden4", "error");
|
$this->layout()->setFlash("Rufnummer nicht gefunden4", "error");
|
||||||
$this->redirect("Voicenumberblock", "Index", null, ["block" => $block->id]);
|
$this->redirect("Voicenumberblock", "Index", null, ["block" => $block->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$number = VoicenumberModel::getFirst(["block_id" => $block_id, "number" => (string)$num]);
|
$number = VoicenumberModel::getFirst(["number" => (string)$num]);
|
||||||
$mode = "edit";
|
$mode = "edit";
|
||||||
|
|
||||||
if(!$number) {
|
if(!$number) {
|
||||||
$number = new Voicenumber();
|
$number = new Voicenumber();
|
||||||
$number->loadFromBlock($block);
|
|
||||||
|
if($block->id) $number->voicenumberblock_id = $block->id;
|
||||||
$number->number = $num;
|
$number->number = $num;
|
||||||
$number->create_by = $this->me->id;
|
$number->create_by = $this->me->id;
|
||||||
$mode = "add";
|
$mode = "add";
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ while($csv = fgetcsv($input, 0)) {
|
|||||||
|
|
||||||
if(!$adb->num_rows($res)) {
|
if(!$adb->num_rows($res)) {
|
||||||
if(preg_match('/^(schilcherland.+|Neuberg|Kastaniensiedlung|rosenhof|am kluggrund|Reicherfeldweg)$/i', $strasse_name)) continue;
|
if(preg_match('/^(schilcherland.+|Neuberg|Kastaniensiedlung|rosenhof|am kluggrund|Reicherfeldweg)$/i', $strasse_name)) continue;
|
||||||
//echo "Adresse '$strasse_name $hausnummer_name' nicht gefunden!\n";
|
echo "=== Adresse '$strasse_name $hausnummer_name' nicht gefunden!\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,7 +189,7 @@ while($csv = fgetcsv($input, 0)) {
|
|||||||
$hausnummer_id = $data->hausnummer_id;
|
$hausnummer_id = $data->hausnummer_id;
|
||||||
|
|
||||||
if(!$netzgebiet_id || !$hausnummer_id) {
|
if(!$netzgebiet_id || !$hausnummer_id) {
|
||||||
echo "Netzgebiet oder Hausnummer leer\n";
|
echo "=== Netzgebiet oder Hausnummer leer\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,12 +273,12 @@ while($csv = fgetcsv($input, 0)) {
|
|||||||
|
|
||||||
if($connection_count == 1) {
|
if($connection_count == 1) {
|
||||||
if($unit_count === 1) {
|
if($unit_count === 1) {
|
||||||
continue;
|
//continue;
|
||||||
$unit = $wohneinheiten[0];
|
$unit = $wohneinheiten[0];
|
||||||
|
|
||||||
// check if wohneinheit in existing preorder
|
// check if wohneinheit in existing preorder
|
||||||
if(PreorderModel::getFirst(["adb_wohneinheit_id" => $unit->id])) {
|
if(PreorderModel::getFirst(["adb_wohneinheit_id" => $unit->id])) {
|
||||||
echo "1 Wohneinheit schon vergeben $strasse_name $hausnummer_name (unit id ".$unit->id."\n";
|
echo "=== 1 Wohneinheit schon vergeben $strasse_name $hausnummer_name (unit id ".$unit->id."\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,7 +310,7 @@ while($csv = fgetcsv($input, 0)) {
|
|||||||
|
|
||||||
foreach($wohneinheiten as $unit) {
|
foreach($wohneinheiten as $unit) {
|
||||||
if(!$unit->tuer) continue;
|
if(!$unit->tuer) continue;
|
||||||
if($unit->tuer > 1) {
|
if($unit->tuer > 0) {
|
||||||
$unit_candidates[$unit->tuer] = $unit;
|
$unit_candidates[$unit->tuer] = $unit;
|
||||||
if($tuer && $unit->tuer == $tuer) {
|
if($tuer && $unit->tuer == $tuer) {
|
||||||
$fixed_candidate = $unit;
|
$fixed_candidate = $unit;
|
||||||
@@ -340,7 +340,7 @@ while($csv = fgetcsv($input, 0)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(PreorderModel::getFirst(["adb_wohneinheit_id" => $unit->id])) {
|
if(PreorderModel::getFirst(["adb_wohneinheit_id" => $unit->id])) {
|
||||||
//echo "2 Wohneinheit schon vergeben $strasse_name $hausnummer_name (unit id ".$unit->id."\n";
|
echo "=== 2 Wohneinheit schon vergeben $strasse_name $hausnummer_name (unit id ".$unit->id.")\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,7 +371,7 @@ while($csv = fgetcsv($input, 0)) {
|
|||||||
$mu['preorder'] = $preorder;
|
$mu['preorder'] = $preorder;
|
||||||
$mu['unit_count'] = $unit_count;
|
$mu['unit_count'] = $unit_count;
|
||||||
$missing_units[] = $mu;*/
|
$missing_units[] = $mu;*/
|
||||||
echo "$strasse_name $hausnummer_name: Nicht genug Wohneinheiten ".count($wohneinheiten)." - need ".$connection_count."\n";
|
echo "=== $strasse_name $hausnummer_name: Nicht genug Wohneinheiten ".count($wohneinheiten)." - need ".$connection_count."\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//continue;
|
//continue;
|
||||||
@@ -393,8 +393,8 @@ while($csv = fgetcsv($input, 0)) {
|
|||||||
$md["door_count"] = count($available_units);
|
$md["door_count"] = count($available_units);
|
||||||
$md["preorder"] = $preorder;
|
$md["preorder"] = $preorder;
|
||||||
$missing_doors[] = $md;*/
|
$missing_doors[] = $md;*/
|
||||||
/*echo "$strasse_name $hausnummer_name: Not enough units with tuer - units total: $unit_count; units with tuer: ".count($available_units)."; need: ".$connection_count."\n";
|
echo "=== $strasse_name $hausnummer_name: Not enough units with tuer - units total: $unit_count; units with tuer: ".count($available_units)."; need: ".$connection_count."\n";
|
||||||
foreach($available_units as $u) {
|
/*foreach($available_units as $u) {
|
||||||
echo $u->oaid. " tuer ".$u->tuer."\n";
|
echo $u->oaid. " tuer ".$u->tuer."\n";
|
||||||
}*/
|
}*/
|
||||||
continue;
|
continue;
|
||||||
@@ -411,7 +411,7 @@ while($csv = fgetcsv($input, 0)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(count($topnumbers) < $connection_count) {
|
if(count($topnumbers) < $connection_count) {
|
||||||
echo "$strasse_name $hausnummer_name: Nicht genug Topnummern für $connection_count Anschlüsse\n";
|
echo "=== $strasse_name $hausnummer_name: Nicht genug Topnummern für $connection_count Anschlüsse\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -432,7 +432,7 @@ while($csv = fgetcsv($input, 0)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!$unit) {
|
if(!$unit) {
|
||||||
echo "$strasse_name $hausnummer_name: Unit mit Topnummer ".$topnumbers[$i]." nicht gefunden.\n";
|
echo "=== $strasse_name $hausnummer_name: Unit mit Topnummer ".$topnumbers[$i]." nicht gefunden.\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//var_dump($unit);
|
//var_dump($unit);
|
||||||
@@ -444,7 +444,7 @@ while($csv = fgetcsv($input, 0)) {
|
|||||||
|
|
||||||
|
|
||||||
if(PreorderModel::getFirst(["adb_wohneinheit_id" => $unit->id])) {
|
if(PreorderModel::getFirst(["adb_wohneinheit_id" => $unit->id])) {
|
||||||
//echo "3 Wohneinheit schon vergeben $strasse_name $hausnummer_name (unit id ".$unit->id."\n";
|
echo "=== 3 Wohneinheit schon vergeben $strasse_name $hausnummer_name (unit id ".$unit->id."\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -464,7 +464,7 @@ while($csv = fgetcsv($input, 0)) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "Not processed: $strasse_name $hausnummer_name -> need $connection_count but have $unit_count units \n";
|
echo "=== Not processed: $strasse_name $hausnummer_name -> need $connection_count but have $unit_count units \n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user