<?php
/**
 * @package     JGive
 * @subpackage  com_jgive
 *
 * @author      Techjoomla <extensions@techjoomla.com>
 * @copyright   Copyright (C) 2009 - 2020 Techjoomla. All rights reserved.
 * @license     http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 */

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

use Joomla\CMS\Factory;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\HTML\HTMLHelper;

// Creating Object of FrontendHelper class
$jgiveFrontendHelper = new jgiveFrontendHelper;
$campaignHelper = new campaignHelper;

// Set Title by campaign name
$document = Factory::getDocument();

// Load Chart Javascript Files.
HTMLHelper::_('script', 'media/com_jgive/vendors/js/Chart.min.js');
?>
<div id="jgiveWrapper" class="<?php echo COM_JGIVE_WRAPPAER_CLASS;?> container">
	<div class="row af-pt-20 campaignMain border-b af-bg-faded">
		<div class="col-md-12">
			<h1 class="af-mt-0 af-font-bold fs-title"><?php echo Text::_('COM_JGIVE_VENDOR_CAMPAIGNS_OVERVIEW');?></h1>
			<div class="row">
			<?php
				echo $this->loadTemplate("graph");
				echo $this->loadTemplate("donors");

				if ($this->promoterDashboardData['params']['campaign_activity'] != '0')
				{
					echo $this->loadTemplate("activity");
				}
			?>
			</div>
		</div>
	</div>
	<div class="row af-mt-25">
		<div class="col-xs-12 col-sm-4">
			<h4><strong><?php echo strtoupper(Text::_('COM_JGIVE_MY_CAMPAIGNS'));?></strong></h4>
		</div>
		<div class="col-xs-12 col-sm-8">
			<form action="" name="dashboardform" method="post" id="dashboardform">
				<ul class="pull-right list-inline campaignsform">
					<?php
					$launch_camp_url = Uri::root() . substr(Route::_('index.php?option=com_jgive&view=campaignform&Itemid=' . $this->promoterDashboardData['otherData']->createCampaignItemid), strlen(Uri::base(true)) + 1);
					?>
					<li class="campaign__launch list__separation">
						<a href="<?php echo $launch_camp_url;?>" title="<?php echo Text::_('COM_JGIVE_CREATE_NEW_CAMPAIGN')?>">
						<i class="fa fa-paper-plane-o" aria-hidden="true"></i>
						<span class="hidden-xs"><?php echo Text::_('COM_JGIVE_VENDOR_CAMPAIGNS_LAUNCH_CAMPAIGN');?></span>
						</a>
					</li>
					<li class="list__separation">
						<a id="dashboardFilterList" href="javascript:void(0)" onclick="jgive.dashboard.toggleDiv('dashboardFilterOptions');"title="<?php echo Text::_('COM_JGIVE_FILTER_CAMPAIGN');?>">
						<i class="fa fa-filter"></i>
						</a>
					</li>
					<li class="campaign__search">
						<a id="searchCampBtn" href="javascript:void(0)" class="btn btn-sm" onclick="jgive.toggleSearch('SearchFilterInputBox');" title="<?php echo Text::_('COM_JGIVE_ENTER_CAMPAIGN_NAME')?>">
							<i class="fa fa-search" ></i>
						</a>
						<span class="pull-left search__campaign af-d-none search__campaign--wrapper" id="SearchFilterInputBox">
							<input type="text"
								placeholder="<?php echo Text::_('COM_JGIVE_ENTER_CAMPAIGN_NAME'); ?>"
								name="filter_search"
								id="filter_search"
								value="<?php echo $this->lists['filter_search'];?>"
								class="form-control col-xs-5"
								onchange="jgiveCommon.filters.submitFilters('adminForm4');"
								onkeypress="return jgive.searchCampaigns(event);"
								/>
							<button
								onclick="jgive.campaigns.campaignSearchClear()"
								type="button" class="btn btn-sm"
								id="searchCampClear"
								data-original-title="Clear"
								title="<?php echo Text::_('COM_JGIVE_CLEAR_TOOLTIP');?>">
								<i class="fa fa-close"></i>
							</button>
						</span>
					</li>
				</ul>
				<div class="clearfix">&nbsp;</div>
				<ul class="af-d-flex pull-right">
					<?php echo HTMLHelper::_('select.genericlist', $this->promoterDashboardData['dashboardFilterOption'], "dashboard_filters", 'class="form-select" size="1" onchange="this.form.submit();" name="dashboard_filters"',"value", "text",$this->promoterDashboardData['filterData']->dashboard_filters); ?>
				</ul>
				<?php echo HTMLHelper::_('form.token'); ?>
			</form>
		</div>
	</div>
	<div class="row">
		<div class="col-xs-12 campaigns__filter af-pt-10 hide" id="dashboardFilterOptions">
			<?php
				echo $this->loadTemplate("filters");
			?>
		</div>
		<div class="col-xs-12 af-mt-15">
			<div class="tab-content">
				<div role="tabpanel" class="tab-pane active" id="home">
					<div class="row">
						<?php
						if (empty($this->promoterDashboardData['myCampData']))
						{
						?>
							<div class="alert alert-warning">
								<?php echo Text::_('COM_JGIVE_NO_CAMPAIGN_FOUND');?>
							</div>
						<?php
						}
						else
						{?>

								<?php
									echo $this->loadTemplate("pin_" . JGIVE_LOAD_BOOTSTRAP_VERSION);
								?>

						<?php
						}
						?>
					</div>
				</div>
				<div role="tabpanel" class="tab-pane" id="profile">...</div>
			</div>
		</div>
	</div>
</div>

<input type="hidden" id="user_id" name="user_id" value="<?php echo $this->promoterDashboardData['otherData']->logged_userid; ?>" />
<script type="text/javascript">
	var jgive_baseurl = "<?php echo Uri::root(); ?>";
	jgive.dashboard.init();
</script>
