#!/usr/bin/php id); define("INTERNAL_USER_USERNAME", $me->username); define("MFBASE_BYPASS_LOGIN", true); $folder = __DIR__."/source"; $filename = "$folder/Leska-fixed.csv"; $db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME); $log = mfLoghandler::singleton(); $input = fopen($filename, "r"); $network_id = 7; $pop_id = 35; $lineworker_id = 1; $zip = 8160; $city = "Mortantsch"; $l = 0; while($csv = fgetcsv($input, 0)) { $l++; if($l == 1) continue; if(!trim($csv[0])) { continue; } //var_dump($csv);exit; $address = trim($csv[0]); $unit_count = trim($csv[1]); $status = trim($csv[2]); $farbe1 = trim($csv[3]); $rohrname = trim($csv[4]); $gps_long = trim($csv[11]); $gps_lat = trim($csv[12]); $farbe2 = trim($csv[18]); $farbe3 = trim($csv[20]); $fcp_name = trim($csv[22]); $street = ""; $housenumber = ""; if($address == "Leska 25 Haus 25a Altbau") continue; $m = []; // if(!preg_match('/(.+)\s+(\.?\d+[a-z0-9\/&#._-]*|Ost)(.+)?/', $address, $m)) { echo "adresse nicht gefunden\n"; continue; } if(isset($m[1])) { $street = $m[1]; if(isset($m[2])) { $housenumber = $m[2]; } } if(preg_match('/(.+) GST/', $street, $m)) { $street = $m[1]; $housenumber = "GST $housenumber"; } echo "$address => $street - $housenumber\n"; $existing_building = BuildingModel::getFirst(["street" => $address ]); if($existing_building) { } $buildingtypes = [ 1 => 1, // Einfamilienhaus 2 => 2 // Zweifamilienhaus ]; $buildingstatus = [ "geplant" => 2, "Rohr am Grundstück" => 4, "Rohr im Haus" => 5, "Kabel eingeblasen" => 5, ]; $terminationstatus = [ "geplant" => 1, "Rohr am Grundstück" => 1, "Rohr im Haus" => 1, "Kabel eingeblasen" => 4, ]; $building_data = [ "network_id" => $network_id, "pop_id" => $pop_id, "type_id" => $buildingtypes[$unit_count], "status_id" => $buildingstatus[$status], "lineworker_id" => $lineworker_id, "street" => $address, "zip" => $zip, "city" => $city, "gps_lat" => $gps_lat, "gps_long" => $gps_long, "oaid" => "", "contact" => "", "phone" => "", "email" => "", "units" => "hallo", "note" => "", ]; $building = BuildingModel::create($building_data); $building_id = $building->save(); if(!$building_id) { //var_dump($building); //var_dump($building_id); die("Error saving building"); } exit; }