bugfix lageretiketten

This commit is contained in:
OpenXE 2024-02-12 19:45:43 +01:00
parent c89c36e596
commit dd713c2286
2 changed files with 211 additions and 206 deletions

View File

@ -10519,15 +10519,19 @@ function SendPaypalFromAuftrag($auftrag, $test = false)
} }
} }
if($variables['datum']=="") $variables['datum']=date('d.m.Y'); if (is_array($variables)) {
if($variables['datum']=="") {
$variables['datum']=date('d.m.Y');
}
if(!empty($variables)) if(!empty($variables))
{ {
foreach($variables as $key=>$value) foreach($variables as $key=>$value)
{ {
$value = $this->UmlauteEntfernen($value); $value = $this->UmlauteEntfernen($value);
$xml = str_replace("{".strtoupper($key)."}",$value,$xml); $xml = str_replace("{".strtoupper($key)."}",$value,$xml);
} }
}
} }
// y to z wenn Kein PDF -> also nur bei EPL Drucker - 09.06.2019 BS heute auf 0 gestellt bei deutschen adapterboxen eventuell // y to z wenn Kein PDF -> also nur bei EPL Drucker - 09.06.2019 BS heute auf 0 gestellt bei deutschen adapterboxen eventuell

View File

@ -1,201 +1,202 @@
<?php <?php
/* /*
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE **** **** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
* *
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019 * Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
* *
* This file is licensed under the Embedded Projects General Public License *Version 3.1. * This file is licensed under the Embedded Projects General Public License *Version 3.1.
* *
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis * You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
* to obtain the text of the corresponding license version. * to obtain the text of the corresponding license version.
* *
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE **** **** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
*/ */
?> ?>
<?php <?php
use Xentral\Components\Barcode\BarcodeFactory; use Xentral\Components\Barcode\BarcodeFactory;
include_once "class.superfpdf.php"; include_once "class.superfpdf.php";
class EtikettenPDF extends SuperFPDF { class EtikettenPDF extends SuperFPDF {
function __construct($app,$projekt="") { function __construct($app,$projekt="") {
$this->app=$app; $this->app=$app;
$this->page_definded=false; $this->page_definded=false;
} $this->images = array();
}
function SetXML($xml)
{ function SetXML($xml)
if(empty($xml))return; {
$xml = str_replace('&','&amp;', $xml); if(empty($xml))return;
try { $xml = str_replace('&','&amp;', $xml);
$label = new SimpleXMLElement($xml); try {
} catch (Exception $e) { $label = new SimpleXMLElement($xml);
return; } catch (Exception $e) {
} return;
}
foreach($label as $key=>$items)
{ foreach($label as $key=>$items)
switch($key) {
{ switch($key)
case "settings": {
if(!$this->page_definded) case "settings":
{ if(!$this->page_definded)
parent::__construct('P','mm',array(trim($items->attributes()->width),trim($items->attributes()->height))); {
$this->page_definded = true; parent::__construct('P','mm',array(trim($items->attributes()->width),trim($items->attributes()->height)));
} $this->page_definded = true;
}
$this->SetAutoPageBreak(false);
$this->SetFont('Arial','B',4); $this->SetAutoPageBreak(false);
$this->SetLeftMargin(0); $this->SetFont('Arial','B',4);
$this->SetMargins(0,0,0); $this->SetLeftMargin(0);
$this->AddPage(); $this->SetMargins(0,0,0);
break; $this->AddPage();
break;
case "line":
$this->SetXY(trim($items->attributes()->x),$items->attributes()->y,$items[0]); case "line":
$this->SetFont('Arial','',$items->attributes()->size*2); $this->SetXY(trim($items->attributes()->x),$items->attributes()->y,$items[0]);
$this->MultiCell(0,$items->attributes()->size,$items[0],0,'L'); $this->SetFont('Arial','',$items->attributes()->size*2);
break; $this->MultiCell(0,$items->attributes()->size,$items[0],0,'L');
break;
case "rectangle":
$attributes = $items->attributes(); case "rectangle":
$borderwidth = 1; $attributes = $items->attributes();
if(isset($attributes->size))$borderwidth = $attributes->size; $borderwidth = 1;
$this->SetLineWidth($borderwidth / 10); if(isset($attributes->size))$borderwidth = $attributes->size;
$this->Rect($items->attributes()->x, $items->attributes()->y,trim($items->attributes()->width),trim($items->attributes()->height),'B'); $this->SetLineWidth($borderwidth / 10);
break; $this->Rect($items->attributes()->x, $items->attributes()->y,trim($items->attributes()->width),trim($items->attributes()->height),'B');
break;
case "image":
$filename = ''; case "image":
if(isset($items->attributes()->src)) $filename = '';
{ if(isset($items->attributes()->src))
$src = str_replace('&amp;','&',$items->attributes()->src); {
if(stripos($src,'http://') === false && stripos($src,'https://') === false) $src = str_replace('&amp;','&',$items->attributes()->src);
{ if(stripos($src,'http://') === false && stripos($src,'https://') === false)
$src = 'http://'.$src; {
} $src = 'http://'.$src;
$content = file_get_contents($src); }
if($content) $content = file_get_contents($src);
{ if($content)
$filename = rtrim($this->app->erp->GetTMP(),'/').'/'.md5(microtime(true).$items[0]); {
file_put_contents($filename.'1.jpg', $content); $filename = rtrim($this->app->erp->GetTMP(),'/').'/'.md5(microtime(true).$items[0]);
file_put_contents($filename.'1.jpg', $content);
$bildbreite = trim($items->attributes()->width);
$bildhoehe = trim($items->attributes()->height); $bildbreite = trim($items->attributes()->width);
if(!class_exists('image'))include_once(__DIR__.'/../class.image.php'); $bildhoehe = trim($items->attributes()->height);
$img = new image($this->app); if(!class_exists('image'))include_once(__DIR__.'/../class.image.php');
if($bildbreite > 0) $img = new image($this->app);
{ if($bildbreite > 0)
$breite = $bildbreite; {
}else{ $breite = $bildbreite;
$breite = 30; }else{
} $breite = 30;
if($bildhoehe > 0) }
{ if($bildhoehe > 0)
$hoehe = $bildhoehe; {
}else{ $hoehe = $bildhoehe;
$hoehe = $breite; }else{
} $hoehe = $breite;
$_breite = $breite; }
$_hoehe = $hoehe; $_breite = $breite;
list($width, $height) = getimagesize($filename.'1.jpg'); $_hoehe = $hoehe;
if($width > 0 && $height > 0) list($width, $height) = getimagesize($filename.'1.jpg');
{ if($width > 0 && $height > 0)
$scalex = $breite / $width; {
$scaley = $hoehe / $height; $scalex = $breite / $width;
if($scalex < $scaley) $scaley = $hoehe / $height;
{ if($scalex < $scaley)
$hoehe /= $scaley / $scalex; {
$hoehe = ceil($hoehe); $hoehe /= $scaley / $scalex;
}else{ $hoehe = ceil($hoehe);
$breite /= $scalex / $scaley; }else{
$breite = ceil($breite); $breite /= $scalex / $scaley;
} $breite = ceil($breite);
$str = $content; }
$manipulator = new ImageManipulator($str); $str = $content;
$manipulator->resample($_breite*10, $_hoehe*10, false,true, true); $manipulator = new ImageManipulator($str);
$typ = IMAGETYPE_JPEG; $manipulator->resample($_breite*10, $_hoehe*10, false,true, true);
$manipulator->save($filename.'2.jpg', $typ); $typ = IMAGETYPE_JPEG;
$items[0] = $filename.'2.jpg'; $manipulator->save($filename.'2.jpg', $typ);
} $items[0] = $filename.'2.jpg';
} }
}
}
$type = exif_imagetype ( trim($items[0]) ); }
$type = exif_imagetype ( trim($items[0]) );
switch($type)
{ switch($type)
case IMAGETYPE_GIF: $type="gif"; break; {
case IMAGETYPE_JPEG: $type="jpg"; break; case IMAGETYPE_GIF: $type="gif"; break;
case IMAGETYPE_PNG: $type="png"; break; case IMAGETYPE_JPEG: $type="jpg"; break;
default: $type=""; case IMAGETYPE_PNG: $type="png"; break;
} default: $type="";
if($type!="") }
{ if($type!="")
$this->Image(trim($items[0]),trim($items->attributes()->x),trim($items->attributes()->y),trim($items->attributes()->width),trim($items->attributes()->height),$type); {
} $this->Image(trim($items[0]),trim($items->attributes()->x),trim($items->attributes()->y),trim($items->attributes()->width),trim($items->attributes()->height),$type);
if($filename != '') }
{ if($filename != '')
unlink($filename.'1.jpg'); {
unlink($filename.'2.jpg'); unlink($filename.'1.jpg');
} unlink($filename.'2.jpg');
break; }
break;
case "barcode":
if((String)($items->attributes()->type)=="E30") { case "barcode":
$this->EAN13($items->attributes()->x,$items->attributes()->y, $items[0],$items->attributes()->size); if((String)($items->attributes()->type)=="E30") {
} $this->EAN13($items->attributes()->x,$items->attributes()->y, $items[0],$items->attributes()->size);
else if((String)($items->attributes()->type)=="Code128" || (String)($items->attributes()->type)=="1") { }
$this->Code128($items->attributes()->x, $items->attributes()->y, $items[0], $items->attributes()->width, $items->attributes()->size); else if((String)($items->attributes()->type)=="Code128" || (String)($items->attributes()->type)=="1") {
} $this->Code128($items->attributes()->x, $items->attributes()->y, $items[0], $items->attributes()->width, $items->attributes()->size);
else if((String)($items->attributes()->type)=="GS1-128" || (String)($items->attributes()->type)=="1") { }
//$items[0] = "!FNC1!0104012345012345!FNC1!081231!FNC1!1012345"; else if((String)($items->attributes()->type)=="GS1-128" || (String)($items->attributes()->type)=="1") {
//$items[0] = "!FNC1!0104012345012345!FNC1!081231!FNC1!1012345";
$tmp =explode("!FNC1!",$items[0]);
$codewithfnc1 = implode(chr(206),$tmp); $tmp =explode("!FNC1!",$items[0]);
$codewithfnc1 = implode(chr(206),$tmp);
//echo chr(206)."0104012345012345".chr(206)."081231".chr(206)."1012345";
//$this->Code128($items->attributes()->x, $items->attributes()->y, chr(206)."0104012345012345".chr(206)."081231".chr(206)."1012345", $items->attributes()->width, $items->attributes()->size); // 206 = FNC1 //echo chr(206)."0104012345012345".chr(206)."081231".chr(206)."1012345";
$this->Code128($items->attributes()->x, $items->attributes()->y, $codewithfnc1, $items->attributes()->width, $items->attributes()->size); // 206 = FNC1 //$this->Code128($items->attributes()->x, $items->attributes()->y, chr(206)."0104012345012345".chr(206)."081231".chr(206)."1012345", $items->attributes()->width, $items->attributes()->size); // 206 = FNC1
//$this->Code128($items->attributes()->x, $items->attributes()->y, chr(206).$items[0], $items->attributes()->width, $items->attributes()->size); // 206 = FNC1 $this->Code128($items->attributes()->x, $items->attributes()->y, $codewithfnc1, $items->attributes()->width, $items->attributes()->size); // 206 = FNC1
} //$this->Code128($items->attributes()->x, $items->attributes()->y, chr(206).$items[0], $items->attributes()->width, $items->attributes()->size); // 206 = FNC1
else { // standard auf 2 bzw default }
$this->Code39($items->attributes()->x,$items->attributes()->y, $items[0], 0.5, $items->attributes()->size);//, $printText=false) else { // standard auf 2 bzw default
} $this->Code39($items->attributes()->x,$items->attributes()->y, $items[0], 0.5, $items->attributes()->size);//, $printText=false)
}
break;
case "qrcode": break;
/** @var BarcodeFactory $factory */ case "qrcode":
$factory = $this->app->Container->get('BarcodeFactory'); /** @var BarcodeFactory $factory */
$ecLevel = 'M'; $factory = $this->app->Container->get('BarcodeFactory');
$type = 'png'; $ecLevel = 'M';
$filename = rtrim($this->app->erp->GetTMP(),'/').'/'.md5(microtime(true).$items[0]).'.' . $type; $type = 'png';
$filename = rtrim($this->app->erp->GetTMP(),'/').'/'.md5(microtime(true).$items[0]).'.' . $type;
$qrText = (string) $items[0];
$qrcode = $factory->createQrCode($qrText, $ecLevel); $qrText = (string) $items[0];
$width = $items->attributes()->width ?? $items->attributes()->size; $qrcode = $factory->createQrCode($qrText, $ecLevel);
$height = $items->attributes()->height ?? $items->attributes()->size; $width = $items->attributes()->width ?? $items->attributes()->size;
$image = $qrcode->toPng(trim($width), trim($height)); $height = $items->attributes()->height ?? $items->attributes()->size;
$image = $qrcode->toPng(trim($width), trim($height));
if(file_put_contents($filename, $image) === false) {
throw new RuntimeException('qrcode image cannot be created. Perhaps due to missing write permission'); if(file_put_contents($filename, $image) === false) {
} throw new RuntimeException('qrcode image cannot be created. Perhaps due to missing write permission');
unset($image); }
$this->Image( unset($image);
trim($filename), $this->Image(
trim((int) $items->attributes()->x), trim($filename),
trim((int) $items->attributes()->y), trim((int) $items->attributes()->x),
trim((int) $width), trim((int) $items->attributes()->y),
trim((int) $height), trim((int) $width),
$type trim((int) $height),
); $type
unlink($filename); );
unlink($filename);
break;
} break;
} }
}
}
}
}
}