Files
thetool/application/Preorderlogistics/Preorderlogistics.php
2023-11-23 13:51:53 +01:00

84 lines
2.0 KiB
PHP

<?php
//use \chillerlan\QRCode;
use chillerlan\QRCode\QRCode;
use chillerlan\QRCode\QROptions;
use chillerlan\QRCode\Output\QROutputInterface;
class Preorderlogistics extends mfBaseModel {
private $qrfilename;
private $preorder;
public function getCifQrPng($content) {
/*$filename = $this->getProperty("qrfilename");
if(!$filename) {
return false;
}
$qrpath = MFUPLOAD_FILE_SAVE_PATH."/".TT_PREORDER_CIF_QR_SUBFOLDER."/$filename";
var_dump($qrpath);*/
$img = $this->generateCifQrFile($content);
return $img;
}
public function generateCifQrFile($content) {
$qr_opts = new QROptions();
$qr_opts->outputType = QROutputInterface::GDIMAGE_PNG;
$qr = new QRCode($qr_opts);
try {
$png_data = $qr->render($content);
} catch (Exception $ex) {
throw $ex;
}
if(!$png_data) {
echo "Kein png data!";exit;
}
/*
$filename = $this->getProperty("qrfilename");
$qrpath = MFUPLOAD_FILE_SAVE_PATH."/".TT_PREORDER_CIF_QR_SUBFOLDER."/$filename";
$data_parts = explode(",", $png_data);
file_put_contents($qrpath, base64_decode($data_parts[1]));
*/
return $png_data;
}
public function getProperty($name) {
if($this->$name == null) {
if($name == "qrfilename") {
$preorder = $this->getProperty("preorder");
if(!$this->preorder_id || !$preorder || !$preorder->ucode) {
return false;
}
$filename = "preorder-cif-".$preorder->ucode.".png";
$this->qrfilename = $filename;
return $this->qrfilename;
}
if($name == "sender") {
$this->sender = new User($this->sent_by);
return $this->sender;
}
$classname = ucfirst($name);
$idfield = $name."_id";
$this->$name = new $classname($this->$idfield);
if($this->$name->id) {
return $this->$name;
} else {
return null;
}
}
return $this->$name;
}
}