<?php
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Router\Route;
/**
 * @version        5.7.0
 * @package        Joomla
 * @subpackage     Joom Donation
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2009 - 2023 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */
// no direct access
defined('_JEXEC') or die();

class DonationViewUserdonorsHtml extends OSFViewList
{
	protected function prepareView()
	{
		parent::prepareView();
		$document                   = Factory::getDocument();
		$document->setTitle(Text::_('JD_DONORS'));
		$this->config               = DonationHelper::getConfig();
        if (!Factory::getUser()->get('id'))
        {
            // Allow users to login
            $return = base64_encode(Uri::getInstance()->toString());
            Factory::getApplication()->redirect('index.php?option=com_users&view=login&return=' . $return);
        }
        $this->campaigns            = DonationHelper::getUserCampaigns();
        if(count($this->campaigns) == 0)
        {
            Factory::getApplication()->enqueueMessage(Text::_('JD_NO_DONORS_FOUND'));
            Factory::getApplication()->redirect(Route::_('index.php?option=com_jdonation'));
        }
        $id                         = Factory::getApplication()->input->getString('id',0);
        $this->state                = $this->model->getState();
        $this->state->set('id', $id);
        $this->Itemid               = Factory::getApplication()->input->getInt('Itemid', 0);
        $this->items                = $this->model->getData();
        $this->pagination           = $this->model->getPagination();
        $this->campaign_id          = $id;
        $this->bootstrapHelper      = new DonationHelperBootstrap($this->config->twitter_bootstrap_version);
	}
}
