<?php
/**
 * @package BILLETS
 * @link 	http://www.dioscouri.com
 * @license GNU/GPLv2
 */

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

class modBilletsOpenHelper {

    /**
     * Retrieves the open Billets
     *
     * @access public
     */    
    function getBilletsOpen( ) {
		global $mainframe;
		
		$database = &JFactory::getDBO();
		$user 	= &JFactory::getUser();
		
		// open tix
		$status_query = " AND ( #__billets_tickets.status = '0' OR #__billets_tickets.status = '3' ) ";
			  
		$query = "SELECT * FROM #__billets_tickets "
			. " WHERE 1 "
			. $status_query
			. " AND #__billets_tickets.sender_userid = '$user->id' "
			;	
		$database->setQuery( $query );
		$total = $database->loadObjectList();
		
		return $total;
    }

    /**
     * Retrieves the Itemid
     *
     * @access public
     */
	function getItemid() {
		global $Itemid;
		$id = $Itemid;
		$database = JFactory::getDBO();
		$link = "index.php?option=com_billets";
		$query = " SELECT * FROM #__menu "
		. " WHERE `link` LIKE '%".$link."%' "
		. " ORDER BY `link` ASC "
		;
		$database->setQuery($query);
		if ( $item = $database->loadObject() ) {
			$id = $item->id;		
		}
		return $id;		
	}
}