<?php
/**
 * ###############################################
 *
 * SWIFT Framework
 * _______________________________________________
 *
 * @author		Varun Shoor
 *
 * @package		SWIFT
 * @copyright	Copyright (c) 2001-2012, Kayako
 * @license		http://www.kayako.com/license
 * @link		http://www.kayako.com
 *
 * ###############################################
 */

/**
 * The Holiday Manager View Class
 *
 * @author Varun Shoor
 */
class View_HolidayManager extends SWIFT_View
{
	/**
	 * Constructor
	 *
	 * @author Varun Shoor
	 * @return bool "true" on Success, "false" otherwise
	 */
	public function __construct()
	{
		parent::__construct();

		return true;
	}

	/**
	 * Destructor
	 *
	 * @author Varun Shoor
	 * @return bool "true" on Success, "false" otherwise
	 */
	public function __destruct()
	{
		parent::__destruct();

		return true;
	}

	/**
	 * Render the SLA Holiday ImpEx Form
	 *
	 * @author Varun Shoor
	 * @param bool $_isImportTabActivated Whether Import Tab is Activated by Default
	 * @return bool "true" on Success, "false" otherwise
	 * @throws SWIFT_Exception If the Class is not Loaded
	 */
	public function Render($_isImportTabActivated = false)
	{
		$_SWIFT = SWIFT::GetInstance();

		if (!$this->GetIsClassLoaded())
		{
			throw new SWIFT_Exception(SWIFT_CLASSNOTLOADED);

			return false;
		}

		$_isImportTabActivated = intval($_isImportTabActivated);

		$this->UserInterface->Start(get_class($this), '/Tickets/HolidayManager/Import', SWIFT_UserInterface::MODE_EDIT, false, true);

		$_ExportTabObject = $this->UserInterface->AddTab($this->Language->Get('tabexport'), 'icon_export.gif', 'export',
				IIF(!$_isImportTabActivated, true, false));
		$_ImportTabObject = $this->UserInterface->AddTab($this->Language->Get('tabimport'), 'icon_import.gif', 'import', $_isImportTabActivated);


		$_ExportTabObject->LoadToolbar();
		$_ExportTabObject->Toolbar->AddButton($this->Language->Get('export'), 'icon_check.gif', 'PopupSmallWindow(\''. SWIFT::Get('basename') .'/Tickets/HolidayManager/Export/_exportFileName=\'+escape($(\'#filename\').val()));', SWIFT_UserInterfaceToolbar::LINK_JAVASCRIPT, '', '', false);
		$_ExportTabObject->Toolbar->AddButton($this->Language->Get('help'), 'icon_help.gif', SWIFT_Help::RetrieveHelpLink('slaholidayimpex'), SWIFT_UserInterfaceToolbar::LINK_NEWWINDOW);

		$_holidayPackFileName = SWIFT_SLAHolidayManager::GenerateFileName('sla');
		$_ExportTabObject->Text('filename', $this->Language->Get('exportfilename'), $this->Language->Get('desc_exportfilename'), $_holidayPackFileName);

		$_ImportTabObject->LoadToolbar();
		$_ImportTabObject->Toolbar->AddButton($this->Language->Get('import'), 'icon_check.gif', 'TabLoading(\''. get_class($this) .'\', \''. 'import' .'\'); $(\'#'. get_class($this) . SWIFT_UserInterface::FORM_SUFFIX .'\').submit();', SWIFT_UserInterfaceToolbar::LINK_JAVASCRIPT, '', '', false);
		$_ImportTabObject->Toolbar->AddButton($this->Language->Get('help'), 'icon_help.gif', SWIFT_Help::RetrieveHelpLink('slaholidayimpex'), SWIFT_UserInterfaceToolbar::LINK_NEWWINDOW);

		$_ImportTabObject->File('slaholidayfile', $this->Language->Get('slaholidayfile'), $this->Language->Get('desc_slaholidayfile'));

		$this->UserInterface->Hidden('isajax', '1');

		$this->UserInterface->End();

		return true;
	}
}
?>