Merge branch 'fronkdev' into 'master'
rimo import update / Added Productattrib type salespartner See merge request fronk/thetool!201
This commit is contained in:
@@ -222,7 +222,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 +272,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>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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']);
|
||||
|
||||
@@ -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") {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ class Network_61105 {
|
||||
|
||||
//if($strasse_hausnummer == "Brudergarten") continue;
|
||||
if($strasse_name == "Brudergarten Kohlbacher") $strasse_name = "Brudergarten";
|
||||
if($strasse_name == "Brudergarten" && !$hausnummer_name) return false;
|
||||
if($strasse_name == "Brudergarten" && !trim($hausnummer_name)) return false;
|
||||
|
||||
/*if(strpos($strasse_hausnummer, '"') !== false) {
|
||||
$m = [];
|
||||
|
||||
@@ -100,6 +100,10 @@ class AddressHelper {
|
||||
$lot_num = $building->address->lotNumber;
|
||||
$fcp_name = false;
|
||||
|
||||
if(!$hausnummer_name || !$gem_name || !$plz_name || !$ort_name || !$strasse_name) {
|
||||
return 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 | $rimo_id";
|
||||
|
||||
// pass variables by ref, so they can be manipulated directly
|
||||
|
||||
@@ -33,6 +33,8 @@ $apiToken = $apiData["key"];
|
||||
|
||||
$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;
|
||||
|
||||
/*
|
||||
if(!defined("RIMO_API_JSON_APIKEY_PROD")) {
|
||||
@@ -168,11 +170,14 @@ foreach($clustersResponse->item as $cluster) {
|
||||
$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) {
|
||||
@@ -186,6 +191,7 @@ 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()) {
|
||||
@@ -222,18 +228,18 @@ foreach($clustersResponse->item as $cluster) {
|
||||
$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(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;
|
||||
|
||||
@@ -260,9 +266,10 @@ foreach($clustersResponse->item as $cluster) {
|
||||
$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();
|
||||
|
||||
$oaid->save();
|
||||
$unit->save();
|
||||
}
|
||||
|
||||
@@ -271,10 +278,128 @@ foreach($clustersResponse->item as $cluster) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//sleep(1);
|
||||
}
|
||||
|
||||
// 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";
|
||||
exit;
|
||||
}
|
||||
|
||||
$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)) {
|
||||
$cluster = null;
|
||||
if(array_key_exists("SDICluster", $dn)) {
|
||||
$cluster = $dn['SDICluster'];
|
||||
}
|
||||
$shelf = $dn['Shelf'];
|
||||
$patchpanel = $dn['PatchPanel'];
|
||||
$port = $dn['Port'];
|
||||
|
||||
if($cluster) {
|
||||
$unit->patch_cluster = $cluster;
|
||||
$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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 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";
|
||||
exit;
|
||||
}
|
||||
|
||||
$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";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//exit;
|
||||
}
|
||||
|
||||
@@ -284,4 +409,57 @@ foreach($clustersResponse->item as $cluster) {
|
||||
}
|
||||
|
||||
//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;
|
||||
}
|
||||
@@ -96,5 +96,5 @@ foreach(PreorderModel::search(['preordercampaign_id' => $selected_campaign, 'adb
|
||||
}
|
||||
|
||||
|
||||
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";
|
||||
|
||||
Reference in New Issue
Block a user