further tuning of address parser
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sat, 1 Jan 2011 16:23:23 +0000 (16:23 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sat, 1 Jan 2011 16:23:23 +0000 (16:23 +0000)
git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@702 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

www/inc/db/dbupgrade.php

index 5bb0013..1747628 100644 (file)
@@ -147,14 +147,16 @@ class DBUpgrade
                                "title"=>"","name"=>$c["name"],"firstname"=>"");
                        //parse name
                        $ns=explode(" ",$c["name"]);
-                       while(in_array($ns[0],$titles))
+                       while(in_array($ns[0],$titles)){
+                               if($ci["title"]!="")$ci["title"].=" ";
                                $ci["title"].=array_shift($ns);
+                       }
                        $nm=implode(" ",$ns);
                        $ns=explode(",",$nm);
                        if(count($ns)==2){
-                               $ci["name"]=$ns[0];
-                               $ci["firstname"]=$ns[1];
-                       }else $ci["name"]=$nm;
+                               $ci["name"]=trim($ns[0]);
+                               $ci["firstname"]=trim($ns[1]);
+                       }else $ci["name"]=trim($nm);
                        self::insert("customer",$ci);
                        //copy/parse address
                        self::mkaddress($c["customerid"],$c["address"]);