<?php
/**
 * @package BILLETS
 * @link 	http://www.dioscouri.com
 * @license GNU/GPLv2
 */
 
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

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

/**
* 	BilletsController
*/
// ************************************************************************
class BilletsController extends JController {

	var $_modules = null;

	/**
	* 	display the view
	*/
	// ************************************************************************
    function display() {
		$this->getModules();
		// no matter what, the left column shows
		echo "<table class='invisible'><tr><td id='left_column'>";
		
		$this->leftColumn ( $option, $section, $task, $lists, $search, $pageNav );
		
		echo "</td><td id='main_column'>";
        
		parent::display();
		
		echo "</td></tr></table>";
    }
	
	/**
	* 	get modules for left column
	*/
	// ************************************************************************
	function getModules() {
		$database = &JFactory::getDBO();
		// grab the published modules
		$query = "SELECT * FROM #__billets_addons as m "
		. " WHERE m.type = 'mod' "
		. " AND m.published = '1' "
		. " ORDER BY m.order ASC "
		;
		$database->setQuery( $query ); 
		$this->_modules = $database->loadObjectList();	
	}
	
	/**
	* 	display leftColumn [always]
	*/
	// ************************************************************************
	function leftColumn( ) {
			?>        
			<div class="module_sidemenu">
	
				<h1><?php echo _BILLETS_MENU; ?></h1>
	
				<table class="invisible">
				<tr>
					<td>
					<a href="index.php?option=com_billets"><?php echo _BILLETS_DASHBOARD; ?></a>
					</td>
				</tr>
				<tr>
					<td>
					- - - - - - -
					</td>
				</tr>
				<tr>
					<td>
					<a href="index.php?option=com_billets&controller=tickets&task=list&status=open"><?php echo _BILLETS_OPENTICKETS; ?></a>
					</td>
				</tr>
				<tr>
					<td>
					<a href="index.php?option=com_billets&controller=tickets&task=list&status=followup"><?php echo _BILLETS_TICKETSFORFOLLOWUP; ?></a>
					</td>
				</tr>
				<tr>
					<td>
					- - - - - - -
					</td>
				</tr>
				<tr>
					<td>
					<a href="index.php?option=com_billets&controller=tickets&task=list&status=feedback"><?php echo _BILLETS_TICKETSREQUIRINGFEEDBACK; ?></a>
					</td>
				</tr>
				<tr>
					<td>
					<a href="index.php?option=com_billets&controller=tickets&task=list&status=closed"><?php echo _BILLETS_CLOSEDTICKETS; ?></a>
					</td>
				</tr>
				<tr>
					<td>
					<a href="index.php?option=com_billets&controller=tickets&task=list&status=all"><?php echo _BILLETS_ALLTICKETS; ?></a>
					</td>
				</tr>
				<tr>
					<td>
					- - - - - - -
					</td>
				</tr>
				<tr>
					<td>
					<a href="index.php?option=com_billets&controller=users&task=selectuser"><?php echo _BILLETS_NEWTICKET; ?></a>
					</td>
				</tr>
	
				<tr>
					<td>
					- - - - - - -
					</td>
				</tr>
				<tr>
					<td>
					<a href="index.php?option=com_billets&controller=addons&type=lang"><?php echo _BILLETS_LANGUAGES; ?></a>
					</td>
				</tr>
				<tr>
					<td>
					<a href="index.php?option=com_billets&controller=addons&type=mod"><?php echo _BILLETS_MODULES; ?></a>
					</td>
				</tr>
	
	<?php /*?>            
				<tr>
					<td>
					- - - - - - -
					</td>
				</tr>
				<tr>
					<td>
					<a href="index.php?option=com_billets&section=config"><?php echo _BILLETS_CONFIG; ?></a>
					</td>
				</tr>
	<?php */?>            
				</table>
				
				<p></p>
	
			<?php 
				// include each published module
				if ($this->_modules) { foreach ( $this->_modules as $mod ) { 
					$file = JPATH_COMPONENT_ADMINISTRATOR.'/modules/'.$mod->filename.'.php';
					if ( file_exists( $file ) ) {
						include( $file );
					} // end if module file exists
				} } // end foreach module
			?>
			
			</div>
						
			<?php	
		} // end leftColumn
	// ************************************************************************
    
}
// ************************************************************************

?>