<?php
/**
 * @version		$Id: version.php 71 2009-05-30 10:16:47Z eddieajau $
 * @copyright	Copyright (C) 2009 New Life in IT Pty Ltd. All rights reserved.
 * @license		GNU General Public License <http://www.gnu.org/copyleft/gpl.html>
 * @link		http://www.theartofjoomla.com
 */

// no direct access
defined('_JEXEC') or die;

jimport('joomla.application.component.view');

/**
 * @package		TAOJ.Quanta
 * @subpackage	com_quanta
 */
class QuantaViewHistory extends JView
{
	/**
	 * Display the view
	 *
	 * @access	public
	 */
	function display($tpl = null)
	{
		$state	= $this->get('State');
		$item	= $this->get('Item');
		$form 	= $this->get('Form');

		// Check for errors.
		if (count($errors = $this->get('Errors'))) {
			JError::raiseError(500, implode("\n", $errors));
			return false;
		}

		// Correct UTC dates
		$item->record_time = JHtml::date($item->record_time, '%Y-%m-%d %H:%M:%S');

		$form->setName('adminForm');
		$form->setAction(JRoute::_('index.php?option=com_quanta'));
		$form->loadObject($item);

		$this->assignRef('state',	$state);
		$this->assignRef('item',	$item);
		$this->assignRef('form',	$form);

		$this->_addToolbar();
		parent::display($tpl);
		JRequest::setVar('hidemainmenu', true);
	}

	/**
	 * Display the toolbar
	 *
	 * @access	private
	 */
	function _addToolbar()
	{
		$user = &JFactory::getUser();
		if (is_object($this->item)) {
			$isNew			= ($this->item->id == 0);
		}
		else {
			$isNew			= true;
		}

		JToolBarHelper::title(JText::_('Quanta_'.($isNew ? 'Add_History_Title' : 'Edit_History_Title')), 'logo');
		if (!$isNew) {
			JToolBarHelper::custom('history.save2copy', 'copy.png', 'copy_f2.png', 'Quanta_Toolbar_Save_To_Copy', false);
		}
		JToolBarHelper::custom('history.save2new', 'new.png', 'new_f2.png', 'Quanta_Toolbar_Save_And_New', false);
		JToolBarHelper::save('history.save');
		JToolBarHelper::apply('history.apply');
		JToolBarHelper::cancel('history.cancel');
	}
}