/var/www/vhosts/nabawater/common/helpers
Edit: /var/www/vhosts/nabawater/common/helpers/QrHelper.php (2456B)
*/
class QrHelper
{
/**
* @var self
*/
private static $instance;
private $qrCode;
private $fileName;
/**
* @return FBHelper
* @throws \Facebook\Exceptions\FacebookSDKException
*/
public static function getInstance()
{
if (self::$instance === null) {
self::$instance = new self();
}
return self::$instance;
}
/**
* @param $error
* @return $this
*/
public function setQrCode($qrCode)
{
$this->qrCode = $qrCode;
return $this;
}
/**
* @param $error
* @return $this
*/
public function setFileName($fileName)
{
$this->fileName = $fileName;
return $this;
}
public function generate($orderDateTime, $order_total, $tax)
{
$generatedString = GenerateQrCode::fromArray([
new Seller(Configuration::get(Configuration::QR_SELLER_NAME)), // seller name
new TaxNumber(Configuration::get(Configuration::QR_VAT_NUMBER)), // seller tax number
new InvoiceDate( date("Y-m-d\TH:i:s.000\Z", strtotime($orderDateTime))), // invoice date as Zulu ISO8601 @see https://en.wikipedia.org/wiki/ISO_8601
new InvoiceTotalAmount($order_total), // invoice total amount
new InvoiceTaxAmount($tax) // invoice tax amount
// TODO :: Support others tags
])->toBase64();
$qrCode = (new QrCode($generatedString))
->setSize(250)
->setMargin(1);
$this->fileName = date('y-m-d-h-i-s');
$dir = UploadHelper::getInstance()->setPath(UploadHelper::USER_QR_PATH);
$qrCode->writeFile(Yii::getAlias('@uploads').'/'.UploadHelper::USER_QR_PATH.'/'.$this->fileName.'.png');
// header('Content-Type: '.$qrCode->getContentType());
// $qrCode->writeString();
return '/uploads/'.UploadHelper::USER_QR_PATH.'/'.$this->fileName.'.png';
die();
}
}