Browse Source

Created transform service for product code

Manuel Gall 3 years ago
parent
commit
4bd8270cd5
1 changed files with 38 additions and 0 deletions
  1. 38 0
      ui/TransformProductCode.php

+ 38 - 0
ui/TransformProductCode.php

@@ -0,0 +1,38 @@
+<?php
+  ini_set('display_errors', 1);
+  ini_set('display_startup_errors', 1);
+  error_reporting(E_ALL);
+  
+  header('Content-Type: application/json');
+  
+  $url = realpath("./json/ProductCode.json");
+  $json = file_get_contents($url);
+  $json = json_decode($json);
+  
+  $productcode = str_replace("/", ".", $_GET["ProductCode"]);
+  $productarray = explode(".", $productcode);
+  
+  //Fixwerte übernehmen:
+  $fixwerte = 6;
+  for($i = 0; $i < $fixwerte; ++$i){
+    if(isset($productarray[$i])){
+      $asocarray[$json->pattern[$i]->abk] = $productarray[$i];
+    }
+    else{
+      $asocarray[$json->pattern[$i]->abk] = "";
+    }
+  }
+  
+  //Search which abk can be linked to the patternpart
+  for($i = $fixwerte; $i < count($productarray); ++$i){
+    foreach($json->pattern as $node){
+      foreach($node->types as $type){
+        if($productarray[$i] == $type){
+            $asocarray[$node->abk] = $productarray[$i];
+        }
+      }
+    }
+  }
+  
+  echo json_encode($asocarray);
+?>