Revision 9dda820f
Von Holger Lindemann vor mehr als 16 Jahren hinzugefügt
lxo-import/addressB.php | ||
---|---|---|
12 | 12 |
|
13 | 13 |
*/ |
14 | 14 |
|
15 |
if ($_GET["login"]) { |
|
16 |
$login=$_GET["login"]; |
|
17 |
} else { |
|
18 |
$login=$_POST["login"]; |
|
15 |
require ("import_lib.php"); |
|
16 |
|
|
17 |
if (!$_SESSION["db"]) { |
|
18 |
$conffile="../config/authentication.pl"; |
|
19 |
if (!is_file($conffile)) { |
|
20 |
ende(4); |
|
21 |
} |
|
22 |
} |
|
23 |
|
|
24 |
if (!anmelden()) ende(5); |
|
25 |
|
|
26 |
if ($_POST["ok"]=="Hilfe") { |
|
27 |
echo "Importfelder:<br>"; |
|
28 |
echo "Feldname => Bedeutung<br>"; |
|
29 |
foreach($address as $key=>$val) { |
|
30 |
echo "$key => $val<br>"; |
|
31 |
} |
|
32 |
exit(0); |
|
19 | 33 |
}; |
34 |
|
|
20 | 35 |
if ($_POST["ok"]) { |
21 | 36 |
|
22 | 37 |
$nun=time(); |
23 | 38 |
|
24 |
require ("import_lib.php"); |
|
25 |
$db=new myDB($login); |
|
39 |
|
|
40 |
/* get DB instance */ |
|
41 |
$db=$_SESSION["db"]; //new myDB($login); |
|
42 |
|
|
26 | 43 |
$crm=checkCRM(); |
27 | 44 |
|
28 | 45 |
function ende($nr) { |
... | ... | |
31 | 48 |
exit(1); |
32 | 49 |
} |
33 | 50 |
|
34 |
if ($_POST["ok"]=="Hilfe") { |
|
35 |
echo "Importfelder:<br>"; |
|
36 |
echo "Feldname => Bedeutung<br>"; |
|
37 |
foreach($address as $key=>$val) { |
|
38 |
echo "$key => $val<br>"; |
|
39 |
} |
|
40 |
exit(0); |
|
41 |
}; |
|
42 | 51 |
clearstatcache (); |
43 | 52 |
//print_r($_FILES); |
44 | 53 |
$test=$_POST["test"]; |
... | ... | |
57 | 66 |
if (!$file) ende (2); |
58 | 67 |
|
59 | 68 |
$trenner=($_POST["trenner"])?$_POST["trenner"]:","; |
60 |
//echo "../users/$login.conf"; |
|
61 |
if (!file_exists("../users/$login.conf")) ende(3); |
|
62 | 69 |
|
63 | 70 |
if (!file_exists("$file.csv")) ende(5); |
64 | 71 |
|
65 |
$db=new myDB($login); |
|
66 | 72 |
|
67 | 73 |
if (!$db->chkcol($file)) ende(6); |
68 | 74 |
|
69 |
$employee=chkUsr($login);
|
|
75 |
$employee=chkUsr($_SESSION["employee"]);
|
|
70 | 76 |
if (!$employee) ende(4); |
71 | 77 |
|
72 | 78 |
$kunde_fld = array_keys($address); |
... | ... | |
184 | 190 |
<p class="listtop">Adressimport für die ERP<p> |
185 | 191 |
<br> |
186 | 192 |
<form name="import" method="post" enctype="multipart/form-data" action="addressB.php"> |
193 |
<!--form name="import" method="post" action="addressB.php"--> |
|
187 | 194 |
<input type="hidden" name="MAX_FILE_SIZE" value="2000000"> |
188 | 195 |
<input type="hidden" name="login" value="<?= $login ?>"> |
189 | 196 |
<table> |
lxo-import/contactB.php | ||
---|---|---|
11 | 11 |
Web: http://lx-system.de |
12 | 12 |
|
13 | 13 |
*/ |
14 |
if ($_GET["login"]) {
|
|
15 |
$login=$_GET["login"];
|
|
16 |
} else {
|
|
17 |
$login=$_POST["login"];
|
|
18 |
};
|
|
19 |
|
|
14 |
if (!$_SESSION["db"]) {
|
|
15 |
$conffile="../config/authentication.pl";
|
|
16 |
if (!is_file($conffile)) {
|
|
17 |
ende(4);
|
|
18 |
}
|
|
19 |
} |
|
20 | 20 |
require ("import_lib.php"); |
21 |
$db=new myDB($login); |
|
21 |
|
|
22 |
if (!anmelden()) ende(5); |
|
23 |
|
|
24 |
/* get DB instance */ |
|
25 |
$db=$_SESSION["db"]; //new myDB($login); |
|
26 |
|
|
27 |
|
|
22 | 28 |
$crm=checkCRM(); |
23 | 29 |
|
24 | 30 |
if ($_POST["ok"]) { |
25 |
$login=$_POST["login"]; |
|
26 | 31 |
$test=$_POST["test"]; |
27 | 32 |
|
28 | 33 |
if ($crm) { |
... | ... | |
36 | 41 |
|
37 | 42 |
function ende($nr) { |
38 | 43 |
echo "Abbruch: $nr\n"; |
39 |
echo "Aufruf: addressS.php [login customer|vendor] [test] | [felder]\n"; |
|
40 | 44 |
exit($nr); |
41 | 45 |
} |
42 | 46 |
if ($_POST["ok"]=="Hilfe") { |
... | ... | |
68 | 72 |
|
69 | 73 |
if (!file_exists($file."_contact.csv")) ende(5); |
70 | 74 |
|
71 |
if (!file_exists("../users/$login.conf")) ende(3); |
|
72 |
|
|
75 |
$prenumber=$_POST["prenumber"]; |
|
73 | 76 |
|
74 |
$employee=chkUsr($login);
|
|
77 |
$employee=chkUsr($_SESSION["employee"]);
|
|
75 | 78 |
if (!$employee) ende(4); |
76 | 79 |
|
77 | 80 |
if (!$db->chkcol($file)) ende(6); |
78 | 81 |
|
79 | 82 |
$f=fopen($file."_contact.csv","r"); |
80 |
$zeile=fgets($f,1200); |
|
81 |
$infld=split($trenner,strtolower($zeile)); |
|
82 |
$first=true; |
|
83 |
$zeile=fgetcsv($f,2000,$trenner); |
|
83 | 84 |
|
85 |
$first=true; |
|
84 | 86 |
|
85 |
foreach ($infld as $fld) {
|
|
86 |
$fld = trim(strtr($fld,array("\""=>"","'"=>"")));
|
|
87 |
foreach ($zeile as $fld) {
|
|
88 |
$fld = strtolower(trim(strtr($fld,array("\""=>"","'"=>""))));
|
|
87 | 89 |
$in_fld[]=$fld; |
88 | 90 |
} |
89 | 91 |
$j=0; |
90 |
$zeile=fgetcsv($f,1200,$trenner);
|
|
92 |
$zeile=fgetcsv($f,2000,$trenner);
|
|
91 | 93 |
while (!feof($f)){ |
92 | 94 |
$i=-1; |
93 | 95 |
$firma=""; |
... | ... | |
98 | 100 |
$vals=" values ("; |
99 | 101 |
foreach($zeile as $data) { |
100 | 102 |
$i++; |
101 |
if ($in_fld[$i]=="firma") { |
|
102 |
$firma=addslashes(trim($data)); |
|
103 |
continue; |
|
104 |
}; |
|
105 | 103 |
if (!in_array($in_fld[$i],$kunde_fld)) { |
106 | 104 |
continue; |
107 | 105 |
} |
108 | 106 |
$data=addslashes(trim($data)); |
107 |
if ($in_fld[$i]=="firma" && $data) { |
|
108 |
$data=suchFirma($file,$data); |
|
109 |
if ($data) { |
|
110 |
$id=$data["cp_cv_id"]; |
|
111 |
} |
|
112 |
continue; |
|
113 |
} else if ($in_fld[$i]=="firma") { |
|
114 |
continue; |
|
115 |
} ; |
|
109 | 116 |
if ($in_fld[$i]=="cp_cv_id" && $data) { |
110 | 117 |
$data=chkKdId($data); |
111 |
if ($data) $firma=""; |
|
112 |
if (!$id) $id = $data; |
|
118 |
if ($data) { |
|
119 |
$id = $data; |
|
120 |
}; |
|
113 | 121 |
continue; |
114 |
} |
|
122 |
} else if($in_fld[$i]=="cp_cv_id") { |
|
123 |
continue; |
|
124 |
} |
|
115 | 125 |
if ($in_fld[$i]==$file."number" && $data) { |
116 |
$tmp=getFirma($data,$file); |
|
117 |
if ($tmp) $firma=""; |
|
118 |
if ($id<>$tmp) $id=$tmp; |
|
126 |
if (!$id) { |
|
127 |
$tmp=getFirma($data,$file); |
|
128 |
if ($tmp) { |
|
129 |
$id=$tmp; |
|
130 |
} |
|
131 |
} |
|
132 |
continue; |
|
133 |
} else if ($in_fld[$i]==$file."number") { |
|
119 | 134 |
continue; |
120 |
} |
|
135 |
} |
|
136 |
if ($in_fld[$i]=="cp_id" && $data) { |
|
137 |
$tmp=chkContact($data); |
|
138 |
if ($tmp) { |
|
139 |
$keys.="cp_id,"; |
|
140 |
$vals.="$tmp,"; |
|
141 |
} |
|
142 |
continue; |
|
143 |
} else if ($in_fld[$i]=="cp_id") { |
|
144 |
continue; |
|
145 |
} |
|
146 |
|
|
121 | 147 |
$keys.=$in_fld[$i].","; |
122 | 148 |
|
123 | 149 |
if ($data==false or empty($data) or !$data) { |
124 | 150 |
$vals.="null,"; |
125 | 151 |
} else { |
126 | 152 |
if (in_array($in_fld[$i],array("cp_fax","cp_phone1","cp_phone2"))) { |
127 |
$data="0".$data;
|
|
153 |
$data=$prenumber.$data;
|
|
128 | 154 |
} else if ($in_fld[$i]=="cp_country" && $data) { |
129 | 155 |
$data=mkland($data); |
130 | 156 |
} |
... | ... | |
138 | 164 |
$zeile=fgetcsv($f,1200,$trenner); |
139 | 165 |
continue; |
140 | 166 |
} |
141 |
if ($firma) { |
|
142 |
$data=suchFirma($file,$firma); |
|
143 |
if ($data) { |
|
144 |
$vals.=$data["cp_cv_id"].","; |
|
145 |
$keys.="cp_cv_id,"; |
|
146 |
} |
|
147 |
} else if ($id) { |
|
167 |
if ($id) { |
|
148 | 168 |
$vals.=$id.","; |
149 | 169 |
$keys.="cp_cv_id,"; |
150 | 170 |
} |
... | ... | |
174 | 194 |
<p class="listtop">Kontakt-Adressimport für die ERP</p> |
175 | 195 |
<form name="import" method="post" enctype="multipart/form-data" action="contactB.php"> |
176 | 196 |
<input type="hidden" name="MAX_FILE_SIZE" value="300000"> |
177 |
<input type="hidden" name="login" value="<?= $login ?>"> |
|
178 | 197 |
<table> |
179 | 198 |
<tr><td></td><td><input type="submit" name="ok" value="Hilfe"></td></tr> |
180 | 199 |
<tr><td>Zieltabelle</td><td><input type="radio" name="ziel" value="customer" checked>customer <input type="radio" name="ziel" value="vendor">vendor</td></tr> |
181 | 200 |
<tr><td>Trennzeichen</td><td><input type="text" size="2" maxlength="1" name="trenner" value=";"></td></tr> |
201 |
<tr><td>Telefonvorwahl</td><td><input type="text" size="4" maxlength="1" name="prenumber" value=""></td></tr> |
|
182 | 202 |
<tr><td>Test</td><td><input type="checkbox" name="test" value="1">ja</td></tr> |
183 | 203 |
<tr><td>Daten</td><td><input type="file" name="Datei"></td></tr> |
184 | 204 |
<tr><td></td><td><input type="submit" name="ok" value="Import"></td></tr> |
lxo-import/import_lib.php | ||
---|---|---|
123 | 123 |
"cp_privatemail" => "private eMail", |
124 | 124 |
"cp_notes" => "Bemerkungen", |
125 | 125 |
"cp_stichwort1" => "Stichwort(e)", |
126 |
"katalog" => "Katalog", |
|
127 |
"inhaber" => "Inhaber", |
|
128 |
"contact_id" => "Kontakt ID" |
|
126 |
"cp_id" => "Kontakt ID" |
|
129 | 127 |
); |
130 | 128 |
|
131 | 129 |
$contacts = array( |
... | ... | |
146 | 144 |
"cp_privatphone" => "Privattelefon", |
147 | 145 |
"cp_privatemail" => "private eMail", |
148 | 146 |
"cp_homepage" => "Homepage", |
149 |
"katalog" => "Katalog", |
|
150 |
"inhaber" => "Inhaber", |
|
151 |
"contact_id" => "Kontakt ID" |
|
147 |
"cp_id" => "Kontakt ID" |
|
152 | 148 |
); |
153 | 149 |
|
154 | 150 |
function checkCRM() { |
... | ... | |
205 | 201 |
return $data; |
206 | 202 |
} |
207 | 203 |
} |
208 |
|
|
204 |
function chkContact($id) { |
|
205 |
global $db; |
|
206 |
$sql="select * from contact where cp_id = $id"; |
|
207 |
$rs=$db->getAll($sql); |
|
208 |
if ($rs[0]["cp_id"]==$id) { |
|
209 |
return true; |
|
210 |
} else { |
|
211 |
return false; |
|
212 |
} |
|
213 |
} |
|
209 | 214 |
function getKdRefId($data) { |
210 | 215 |
// gibt es die Nummer schon? |
211 | 216 |
global $db,$file,$test; |
Auch abrufbar als: Unified diff
Neue Anmeldung berücksichtigt