<?php
namespace Modules\Bsp\Listing;

class View_DumpTicketData extends \App\Mvc\View_Popup_GeneralAbstract
{
	/**
	 * The rendering Smarty template file.
	 * @var String
	 */
	protected $renderingTemplate=null;

	/**
	 * (non-PHPdoc)
	 * @see \App\Mvc\ViewAbstract::render()
	 */
	public function render()
	{
		// draw the form
		$form = null;
		if (!$this->closePopup) {
			$form = $this->getForm();
		}
		if ($form) {
			$form->getMessagesObj()->addFromMessageCollector($this->messagesCollector);
			$this->setOutputVar('form', $form);
		}
		else {
			\MessageStack::GetObject()->addFromMessageCollector($this->messagesCollector);
		}

		// sets the closePopup flag
		$this->setOutputVar('closePopup', $this->closePopup);

		return $this->render_smarty($this->renderingTemplate);
	}

	public function getForm()
	{
		// create form and his fieldsets
		$form = \Engine\Form\General::create();
		$fieldset = \Engine\Form\Container\Fieldset::create("Tickets");
		$form->addContainer($fieldset);

		// tickets
		$file = new \Engine\Form\Input\Cloned_Text("Ticket numbers", 'ticketNumbers', $this->input['formData']['ticketNumbers']);
		$file->setMandatory(true);
		$form->addElement($file);

		$form->addElement(new \Engine\Form\Input\Hidden('', 'stepSubmitted', 1));

		return $form;
	}
}
