<?php
/*
 * @component UserPoints
 * @copyright Copyright (C) 2015-2022 Bernard Gilly - Adrien Roussel - Martin Brampton
 * extension menu created by Mike Gusev (migus)
 * @license : GNU/GPL
 * @Website : https://remository.com
 */
namespace BlackSheepResearch\Component\UserPoints\Site\Controllers;

// no direct access
defined('_JEXEC') or die('Restricted access');

use Joomla\CMS\Factory;
use BlackSheepResearch\Component\UserPoints\Site\UserController;

/**
 * @package UserPoints
 */
class RegisterqrcodeControl extends UserController
{
	/**
	 * Custom Constructor
	 */
 	public function __construct()	{
		parent::__construct( );
	}

	//function registerQRcode()
	public function display($cachable = false, $urlparams = false)
	{

		$model      = $this->getModel ( 'registerqrcode' );
		$view       = $this->getView  ( 'registerqrcode','html' );

		$couponCode = Factory::getApplication()->input->get('QRcode', '', 'string');
		$trackIDNew = uniqid('', true);
		$trackID = Factory::getApplication()->input->get('trackID', $trackIDNew, 'string');
		$model->trackQRcode($trackID, $couponCode);

		$this->viewdata['couponCode'] = $couponCode;
		$this->viewdata['trackID'] = $trackID;

		$view->display();
	}

	public function attribqrcode()
	{

		$model      = $this->getModel ( 'registerqrcode' );
		$view       = $this->getView  ( 'registerqrcode','html' );

		$points = $model->attribPoints();

		$this->viewdata['points'] = $points;

		$view->displayResult();
	}


}
