<?php
/**
* BILLETS - A Joomla Support Ticket System Component
* @file mod_billets_open_admin.php
* @description Displays open billets
* @author Dioscouri Design, info@dioscouri.com
* @package BILLETS
* @copyright Copyright (C) 2008 Dioscouri Design. All rights reserved.
* @license Released under the terms of the GNU General Public License (see LICENSE.php in the Joomla! root directory)
* @installinfo
	<name>Open Billets</name>
    <author>Dioscouri.com</author>
    <authorEmail>info@dioscouri.com</authorEmail>
    <authorUrl>http://www.dioscouri.com</authorUrl>
    <version>0.1</version>
    <creationDate>2008-02-01</creationDate>
    <description>Displays the number of open Billets</description>
**/

/** ensure this file is being included by a parent file */
defined('_JEXEC') or die('Restricted access');

global $mainframe;

/**
* mod_openTickets
*/
// ************************************************************************
function mod_openTickets () {

	$database = &JFactory::getDBO();

	
	// open tix
	$status_query = " AND ( #__billets_tickets.status = '0' ) ";
		  
	$query = "SELECT * FROM #__billets_tickets "
		. " WHERE 1 "
		. $status_query
		;	
	$database->setQuery( $query );
	$total = $database->loadObjectList();
	$total = count($total);
	
	return $total;
} // end mod_openTickets
// ************************************************************************

/**
* display the module
*/
// ************************************************************************
	$num = mod_openTickets();
	
	if ($num == 1) { $text = _BILLETS_OPENSUPPORTTICKET; } else { $text = _BILLETS_OPENSUPPORTTICKETS; }
	
	if ($num > 0) {
		$link = $mainframe->getCfg('live_site')."/administrator/index.php?option=com_billets&controller=tickets&task=list&status=open";
		?>
		<div class='notepi'>
			<?php /*?><h4><?php echo _BILLETS_SUPPORTTICKETS; ?></h4><?php */?>
			 
			<table class='invisible'>
			  <tr>
				<td>
					<?php 
					?>
				</td>
				<td>
					<?php echo "<a href='".$link."'>$num $text</a>"; ?>
				</td>
			  </tr>
			</table>
		</div>
	<?php }
// ************************************************************************