Your IP : 216.73.217.142


Current Path : /var/www/consult-e-syn/public_html/components/com_ats/Controller/
Upload File :
Current File : /var/www/consult-e-syn/public_html/components/com_ats/Controller/Attempt.php

<?php
/**
 * @package   ats
 * @copyright Copyright (c)2011-2022 Nicholas K. Dionysopoulos / Akeeba Ltd
 * @license   GNU General Public License version 3, or later
 */

namespace Akeeba\TicketSystem\Site\Controller;

defined('_JEXEC') or die;

use Akeeba\TicketSystem\Site\Model\Attempts;
use FOF40\Container\Container;
use FOF40\Controller\DataController;

class Attempt extends DataController
{
    public function __construct(Container $container, array $config = array())
    {
        $this->cacheableTasks = [];

        parent::__construct($container, $config);
    }

	/**
	 * ACL checks are defered to the main save task
	 *
	 * @return bool
	 */
    public function onBeforeSave()
    {
	    /** @var Attempts $model */
	    $model        = $this->getModel();
	    $updateClicks = $this->input->getCmd('update_clicks');

	    $this->getIDsFromRequest($model);

	    if ($model->getId() && $updateClicks)
	    {
		    if ($updateClicks == 'docimport')
		    {
			    $model->docimport_clicks += 1;
		    }
		    elseif ($updateClicks == 'ats')
		    {
			    $model->ticket_clicks += 1;
		    }
	    }

	    return true;
    }

    public function onAfterSave()
    {
	    if ($this->input->getCmd('format') == 'json')
	    {
	    	$model = $this->getModel();

		    echo json_encode($model->getData());

		    $this->container->platform->closeApplication();
	    }
    }
}