<?php
namespace Modules\Orders\Apollo\Collector;

class Controller extends \ModulesAbstract\ImportedOrdersFileManager\Controller
{
	protected $fileDetailsTabs = ["displayHumanReadableFile", "displayOriginalFile", "displayFileParsedData", "displayStructureParserData", ];

	protected function getBasePath()
	{
		return cleanPath(sprintf("%s/%s", APP_REAL_PATH, $this->globalCfg['paths']['apollo']));
	}

	public function displayFileParsedData_highlighter($key, $parents)
	{
		if ($key == "A29" && count($parents) == 0) {
			return [
					'navLabel' => "A29",
					'navTarget' => [$key],
					'style' => 	"style-2",
					'navStyle' => "style-2"
			];
		}

		if (!in_array($key, ["A02","A04"]) && count($parents) == 0) {
			$navLabel = $key;
			return [
					'navLabel' => $navLabel,
					'navTarget' => [$key]
			];
		}

		/**************** A02 LINE *****************/
		if ($key == "A02" && count($parents) == 0) {
			return [
					'style' => 	"style-0",
			];
		}

		if ($key == "A04" && count($parents) == 0) {
			return [
					'style' => 	"style-1",
			];
		}

		if (in_array("A02", $parents) && count($parents) == 1) {
			return [
				'navLabel' => 	'A02-'.($key + 1),
				'navTarget' => 	['A02', $key],
				'style' => 		"style-0 substyle-".($key%2),
				'navStyle' =>	"style-0",
			];
		}


		if (in_array("A04", $parents) && count($parents) == 1) {

			return [
					'navLabel' => 	'A04-'.($key + 1),
					'navTarget' => 	['A04', $key],
					'style' => 		"style-1 substyle-".($key%2),
					'navStyle' =>	"style-1",
			];
		}

		if (in_array("A07", $parents) && count($parents) == 1) {
			$navLabel = $key;
			return [
					'style' => 	"style-2",
					'navLabel' => $navLabel,
					'navTarget'=> [$key],
					'navStyle' => "style-2",
			];
		}

		$A16Lines = ['A16A', 'A167', 'A16B', 'A168', 'A166', 'A165', 'A16UZ', 'A169', ];
		foreach ($A16Lines as $idx=>$A16) {
			if (in_array($A16, $parents) && count($parents) == 1) {
				return [
					'navLabel' => 	$A16.'-'.($key + 1),
					'navTarget' => 	[$A16, $key],
					'style' => 		sprintf("style-%d substyle-%d", $idx%4, ($key%2)),
					'navStyle' =>	sprintf("style-%d", $idx%4),
				];
			}
		}

		return [];
	}

	protected function getFileParsedObject($input)
	{
		$filterFileParsed = new \Modules\Orders\Apollo\Collector\Model\Filters\FileParsed();
		$filterFileParsed->setInput($input);

		return $filterFileParsed;

	}
}