Revision 2b996153
Von Holger Lindemann vor mehr als 12 Jahren hinzugefügt
pepper/shopimport_db.php | ||
---|---|---|
71 | 71 |
} |
72 | 72 |
|
73 | 73 |
// Ab hier Import der Daten in den Shop |
74 |
function createCategory($name,$maingroup,$tab) { |
|
74 |
function createCategory($name,$maingroup,$tab,$PID) {
|
|
75 | 75 |
global $db,$langs; |
76 | 76 |
$newID=uniqid(rand()); |
77 | 77 |
$sql="insert into kategorien (Bild_gross,Bild_last_modified) values ('$newID',now())"; |
... | ... | |
84 | 84 |
$sql="select max(Positions_Nr) as Max from kategorien where Unterkategorie_von $u"; |
85 | 85 |
$rs=$db->getAll($sql,DB_FETCHMODE_ASSOC); |
86 | 86 |
$pos=$rs[0]["Max"]+1; |
87 |
$sql="update kategorien set Unterkategorie_von=%s, Name='%s', Positions_Nr=%d,MwSt_Satz=%0.2f, Details_anzeigen='N', Bild_gross = Null where kategorie_ID=%d"; |
|
87 |
//$sql="update kategorien set Unterkategorie_von=%s, Name='%s', Positions_Nr=%d,MwSt_Satz=%0.2f, Details_anzeigen='N', Bild_gross = Null where kategorie_ID=%d"; |
|
88 |
$sql="update kategorien set Unterkategorie_von=%s, Name='%s', Tab_text='%s', ist_sichtbar='Y',"; |
|
89 |
$sql.="Positions_Nr=%d,MwSt_Satz=%0.2f, Details_anzeigen='N', Bild_gross = Null, Parent_ID=%d where kategorie_ID=%d"; |
|
88 | 90 |
echo "($name) "; |
89 |
$rc=$db->query(sprintf($sql,$maingroup,$name,$pos,$mwst,$id)); |
|
91 |
//$rc=$db->query(sprintf($sql,$maingroup,$name,$pos,$mwst,$id)); |
|
92 |
$rc=$db->query(sprintf($sql,$maingroup,$name,$tab,$pos,$mwst,$PID,$id)); |
|
90 | 93 |
return ($rc)?$id:false; |
91 | 94 |
} else { |
92 | 95 |
return false; |
... | ... | |
95 | 98 |
function getCategory($name) { |
96 | 99 |
global $db; |
97 | 100 |
if (empty($name)) $name="Default"; |
101 |
$name = utf8_decode($name); |
|
98 | 102 |
preg_match("/^(\[(.*)\])?([^!]+)!?(.*)/",$name,$ref); |
99 | 103 |
if ($ref[1]<>""){ |
100 | 104 |
$tab=$ref[2]; |
... | ... | |
128 | 132 |
if ($rs[0]["Kategorie_ID"]) { // gefunden |
129 | 133 |
$maingroup=$rs[0]["Kategorie_ID"]; |
130 | 134 |
} else { // nicht gefunden, anlegen |
131 |
$maingroup=createCategory($main,"Null","$tab"); |
|
135 |
$maingroup=createCategory($main,"Null","$tab",0);
|
|
132 | 136 |
} |
133 | 137 |
echo $maingroup.":".$main." "; |
134 | 138 |
if ($sub && $maingroup) { |
... | ... | |
138 | 142 |
if ($rs[0]["Kategorie_ID"]) { // gefunden |
139 | 143 |
$maingroup=$rs[0]["Kategorie_ID"]; |
140 | 144 |
} else { // nicht gefunden, anlegen |
141 |
$maingroup=createCategory($sub,"'$main'",""); |
|
145 |
$maingroup=createCategory($sub,"'$main'","",$maingroup);
|
|
142 | 146 |
} |
143 | 147 |
}; |
144 | 148 |
echo $sub." "; |
145 | 149 |
return $maingroup; |
146 | 150 |
} |
147 | 151 |
function bilder($width,$height,$dest) { |
148 |
if (!function_exists("imagick_readimage")) { echo "Imagick-Extention nicht installiert"; return false; }; |
|
149 |
$handle=imagick_readimage("./tmp/tmp.file_org"); |
|
150 |
if (!$handle) { |
|
151 |
$reason = imagick_failedreason( $handle ) ; |
|
152 |
print "Lesen: $reason<BR>\n" ; flush(); |
|
153 |
return false; |
|
154 |
} |
|
155 |
if (!imagick_resize( $handle, $width, $height, IMAGICK_FILTER_UNKNOWN, 0)) { |
|
156 |
$reason = imagick_failedreason( $handle ) ; |
|
157 |
print "Resize: $reason<BR>\n" ; flush(); |
|
158 |
return false; |
|
159 |
} |
|
160 |
if (!imagick_writeimage( $handle,"./tmp/tmp.file_$dest")) { |
|
161 |
$reason = imagick_failedreason( $handle ) ; |
|
162 |
print "Schreiben: $reason<BR>\n" ; flush(); |
|
163 |
return false; |
|
164 |
} |
|
165 |
return true; |
|
152 |
if (!class_exists("Imagick")) { echo "Imagick-Extention nicht installiert"; return false; }; |
|
153 |
$handle= new Imagick(); |
|
154 |
if (!$handle->readImage("./tmp/tmp.file_org")) return false; |
|
155 |
$d = $handle->getImageGeometry(); |
|
156 |
if ($d["width"]<$d["height"]) { |
|
157 |
$f = $d["width"]/$d["height"]; |
|
158 |
$w = floor($width*$f); |
|
159 |
$h = $height; |
|
160 |
} else { |
|
161 |
$f = $d["height"]/$d["width"]; |
|
162 |
$w = $width; |
|
163 |
$h = floor($height*$f); |
|
164 |
} |
|
165 |
$handle->thumbnailImage( $w, $h); |
|
166 |
return $handle->writeImage( "./tmp/tmp.file_$dest"); |
|
166 | 167 |
} |
167 | 168 |
function uploadImage($image,$ArtNr) { |
168 | 169 |
global $db,$ERPftphost,$ERPftpuser,$ERPftppwd,$ERPimgdir, |
169 | 170 |
$SHOPftphost,$SHOPftpuser,$SHOPftppwd,$SHOPimgdir,$iconsize; |
170 | 171 |
if ($ERPftphost=="localhost") { |
171 |
exec("cp $ERPimgdir/$image ./tmp/tmp.file_org",$aus,$rc2); |
|
172 |
echo exec("cp $ERPimgdir/$image ./tmp/tmp.file_org",$aus,$rc2);
|
|
172 | 173 |
if ($rc2>0) { echo "[Downloadfehler: $image]<br>"; return false; }; |
173 | 174 |
} else { |
174 | 175 |
$conn_id = ftp_connect($ERPftphost); |
... | ... | |
179 | 180 |
ftp_quit($conn_id); |
180 | 181 |
}; |
181 | 182 |
bilder($iconsize,$iconsize,"smal"); |
183 |
bilder(550,550,"big"); |
|
182 | 184 |
$rc=preg_match("#(.+/)?([^\.]+)\.(.+)$#",$image,$treffer); |
183 | 185 |
$gr=$treffer[2]."_gr.".$treffer[3]; |
184 | 186 |
$kl=$treffer[2]."_kl.".$treffer[3]; |
185 | 187 |
if ($SHOPftphost=="localhost") { |
186 | 188 |
$dst=$SHOPimgdir."/".$gr; |
187 |
exec("cp ./tmp/tmp.file_org $dst",$aus,$rc2);
|
|
189 |
exec("cp ./tmp/tmp.file_big $dst",$aus,$rc2);
|
|
188 | 190 |
if ($rc2>0) { echo "[Uploadfehler: $dst]<br>"; return false; }; |
189 | 191 |
$dst=$SHOPimgdir."/".$kl; |
190 | 192 |
exec("cp ./tmp/tmp.file_smal $dst",$aus,$rc2); |
... | ... | |
193 | 195 |
$conn_id = ftp_connect($SHOPftphost); |
194 | 196 |
ftp_login($conn_id,$SHOPftpuser,$SHOPftppwd); |
195 | 197 |
ftp_chdir($conn_id,$SHOPimgdir); |
196 |
$upload=ftp_put($conn_id,$SHOPimgdir."/$gr","tmp/tmp.file_org",FTP_BINARY);
|
|
198 |
$upload=ftp_put($conn_id,$SHOPimgdir."/$gr","tmp/tmp.file_big",FTP_BINARY);
|
|
197 | 199 |
if (!$upload) { echo "[Ftp Uploadfehler! $gr]<br>"; return false; }; |
198 | 200 |
$upload=ftp_put($conn_id,$SHOPimgdir."/$kl","tmp/tmp.file_smal",FTP_BINARY); |
199 | 201 |
if (!$upload) { echo "[Ftp Uploadfehler! $kl]<br>"; return false; }; |
... | ... | |
222 | 224 |
$sql.="Name='%s',Beschreibung='%s',Lagerbestand=%d where Artikel_ID=%d"; |
223 | 225 |
$preis=($data["sellprice"]>0)?$data["sellprice"]:$data["stdprice"]; |
224 | 226 |
if ($mwst) $preis+=$preis/100*$bugru[$data["bugru"]]; |
225 |
$sql=sprintf($sql,$preis,$data["weight"],$bugru[$data["bugru"]],$data["description"],$data["notes"],$data["onhand"],$id);
|
|
227 |
$sql=sprintf($sql,$preis,$data["weight"],$bugru[$data["bugru"]],utf8_decode($data["description"]),utf8_decode($data["notes"]),$data["onhand"],$id);
|
|
226 | 228 |
$rc=$db->query($sql); |
227 | 229 |
$sql="update artikel_kategorie set FK_Kategorie_ID=".$data["categories_id"]." where FK_Artikel_ID=$id"; |
228 | 230 |
$rc=$db->query($sql); |
... | ... | |
263 | 265 |
|
264 | 266 |
$artikel=shopartikel(); |
265 | 267 |
echo "Artikelexport ERP -> PHPepper :".count($artikel)." Artikel markiert.<br>"; |
268 |
flush(); |
|
266 | 269 |
if ($artikel) { |
267 | 270 |
$bugru=getBugru(); |
268 | 271 |
$sql="select Thumbnail_Breite from shop_settings"; |
Auch abrufbar als: Unified diff
Vendor_id darf nicht mehr gefüllt werden