Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 9dda820f

Von Holger Lindemann vor mehr als 16 Jahren hinzugefügt

  • ID 9dda820f45ce31c9c42902d61949d7679d2de94a
  • Vorgänger e2903b0d
  • Nachfolger e2edfbac

Neue Anmeldung berücksichtigt

Unterschiede anzeigen:

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&uuml;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>

Auch abrufbar als: Unified diff