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/Bucket.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\Admin\Helper\Permissions;
use FOF40\Container\Container;

class Bucket extends \Akeeba\TicketSystem\Admin\Controller\Bucket
{
	public function __construct(Container $container, array $config = array())
	{
		$config['cacheableTasks'] = [];

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

	public function execute($task)
    {
        if(!Permissions::isManager())
        {
            return false;
        }

        if ($task == 'default')
        {
            $task = $this->getCrudTask();
        }

        // There aren't such actions on frontend
        if(in_array($task, array('new', 'edit', 'read', 'add')))
        {
            $task = 'read';
        }

        return parent::execute($task);
    }

    public function addtickets()
    {
        if(!Permissions::isManager())
        {
            echo json_encode('###false###');

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

        $tickets = $this->input->getInt('ats_ticket_id');
        $bucket  = $this->input->getInt('cid');

        if(!$bucket)
        {
            echo json_encode('###false###');

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

        if(!$tickets)
        {
            echo json_encode('###false###');
        }
        else
        {
            /** @var \Akeeba\TicketSystem\Admin\Model\Tickets $ticketModel */
            $ticketModel = $this->container->factory->model('Tickets')->tmpInstance();
            $result      = $ticketModel->addTicketsToBucket($tickets, $bucket);

            if(!$result)
            {
                echo json_encode('###false###');
            }
            else
            {
                echo json_encode('###true###');
            }
        }

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