<?php
namespace App\Dashboard\Templates\Home;

class CEO extends \App\Dashboard\Templates\BaseAbstract
{
	public function configureDashboard()
	{
		// add container to dashboard
		$t1c = new \Engine\Dashboard\Containers\Table1Col();
		$t1c->setTitle($this->getName());
		$this->dashboard->appendElement($t1c);

		// Sales overview
 		$salesOverview = new \App\Dashboard\Widget\QuickReports_SalesOverview();

 		// Acquisitions Overview
 		$acquisitionsOverview = new \App\Dashboard\Widget\QuickReports_AcquisitionsOverview();

 		// Monthly Sales Comparison
 		$monthlySalesComparison = new \App\Dashboard\Widget\Charts_MonthlySalesComparison();

 		// Income vs balance profit
 		$incomeProfitComparison = new \App\Dashboard\Widget\Charts_IncomeProfitComparison();

 		// Daily balance and cash flow
 		$estimatedDailyBalance = new \App\Dashboard\Widget\Charts_EstimatedDailyBalance();

 		// Monthly cancelled services
 		$cancelledServicesCountMonthly = new \App\Dashboard\Widget\Charts_CancelledServicesCountMonthly();

 		// Top corporations
 		$topCorporatesSales = new \App\Dashboard\Widget\QuickReports_TopCorporatesSales();

 		// Top agents
 		$topAgentsPerf = new \App\Dashboard\Widget\QuickReports_TopAgentsPerf();

		// attach widgets to container
		$t1c->appendElement($salesOverview, 0);
		$t1c->appendElement($acquisitionsOverview, 0);
		$t1c->appendElement($monthlySalesComparison, 0);
		$t1c->appendElement($incomeProfitComparison, 0);
		$t1c->appendElement($estimatedDailyBalance, 0);
		$t1c->appendElement($cancelledServicesCountMonthly, 0);
		$t1c->appendElement($topCorporatesSales, 0);
		$t1c->appendElement($topAgentsPerf, 0);
	}

	public function getDescription()
	{
		\App\Loader_Lang::getInstance()->loadAppFile("_customLoad/dashboard/dashboard/_general.lang.php");
		$_LANG = \App\Loader_Lang::getInstance()->getGlobal();

		$widgetNames = [];
		foreach ($this->dashboard->getContentLinear()[0]->getContentLinear() as $widget) {
			$widgetNames[] = $widget->getTitle();
		}
		$widgetNamesStr = implode(", ", $widgetNames);

		$link = \Engine\Mvc\Dispatcher::getInstance()->getAppUrl('Modules/Home', 'selectFirstTemplate', [
			'template' => addslashes('\\'.__CLASS__),
		]);

		$description = <<<HTML
			<div class="tplRow">
				<div class="tplCol">
					<img src="Modules/Home/View/_img/CEO.png" onclick="requestChangeTemplate('{$link}');" style="cursor:pointer;" tooltip="{$_LANG['dashboard']['tooltips']['selectTemplate']}" />
				</div>
				<div class="tplCol">
					<a onclick="requestChangeTemplate('{$link}');" class="tplLink" href="javascript:;" tooltip="{$_LANG['dashboard']['tooltips']['selectTemplate']}">{$this->getName()}</a>

					<div class="text"><b>{$_LANG['dashboard']['templates']['general']['who']}</b></div>
					<div class="text"><b>{$_LANG['dashboard']['templates']['\\'.__CLASS__]['who']}</b></div>
					<div class="text">{$_LANG['dashboard']['templates']['\\'.__CLASS__]['description']}</div>
				</div>
			</div>
			<div class="tplRow">
				<div class="tplCol">
					<div class="text"><b>{$_LANG['dashboard']['templates']['general']['widgets']}</b></div>
					<div class="text">{$widgetNamesStr}.</div>
				</div>
			</div>
HTML;

		return $description;
	}

}
