• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Help in adding php to show remaining tickets

Help in adding php to show remaining tickets 11 years 2 days ago #22581

  • larryp
  • larryp's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
  • Thank you received: 1
I an not well-versed in php and I need what seemed to me a basic function of an events program which is to show the number of tickets remaining. I cannot believe this is not a part of the program, especially as in going through the forum this appears to be a common request (surpise, surprise!). The feature request page goes back for over a year, and no update has been made
so if anyone else has solved this problem please share with me the code needed in the show.php override.
Thanks
The administrator has disabled public write access.
The following user(s) said Thank You: pepperstreet

Help in adding php to show remaining tickets 11 years 2 days ago #22583

  • alexp
  • alexp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 2253
  • Thank you received: 180
You can use the following code snippet:
<?php
$db = &JFactory::getDBO();
$db->setQuery("SELECT SUM(`seats`) FROM #__rseventspro_tickets WHERE `ide` = '".$event->id."'");
$seats = $db->loadResult();
 
$db->setQuery("SELECT SUM(ut.quantity) FROM #__rseventspro_user_tickets ut LEFT JOIN #__rseventspro_tickets t ON ut.idt = t.id WHERE t.ide = '".$event->id."'");
$subs = $db->loadResult();
 
echo 'Tickets left: '.($seats-$subs);
 
?>
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
The administrator has disabled public write access.
The following user(s) said Thank You: pepperstreet

Help in adding php to show remaining tickets 11 years 2 days ago #22594

  • larryp
  • larryp's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
  • Thank you received: 1
Many, many thanks! That is exactly what I needed.
Thanks again
The administrator has disabled public write access.

Help in adding php to show remaining tickets 10 years 10 months ago #23284

Can you please indicate where 'exactly' this code snippet should go.

Regards, David
The administrator has disabled public write access.

Help in adding php to show remaining tickets 10 years 10 months ago #23463

What if my event doesn't have tickets and we're only using "Allow maximum attendance"? Is there a code to replace the "tickets code" provided in the string?
The administrator has disabled public write access.

Help in adding php to show remaining tickets 10 years 9 months ago #23850

Thank yo is very useful.

The only problem it is that is affected by Joomla cache, so you should refresh your joomla cache often in order to have updated infos.
The administrator has disabled public write access.

Help in adding php to show remaining tickets 10 years 8 months ago #24293

  • info1926
  • info1926's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
This worked well. I have an event with 4 types of ticket can this show many of each ticket type is remaining?
The administrator has disabled public write access.

Help in adding php to show remaining tickets 10 years 3 months ago #26097

Where go's the code???
The administrator has disabled public write access.

Help in adding php to show remaining tickets 10 years 2 months ago #26344

  • redchair
  • redchair's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
  • Thank you received: 1
Hi, my knowledge of PHP is also very limited. Is someone able to indicate where the code is to be placed? Remaining ticket info should be a standard feature on any events management software I would think?

Thanks
The administrator has disabled public write access.

Help in adding php to show remaining tickets 10 years 2 months ago #26345

  • alexp
  • alexp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 2253
  • Thank you received: 180
redchair wrote:
Hi, my knowledge of PHP is also very limited. Is someone able to indicate where the code is to be placed? Remaining ticket info should be a standard feature on any events management software I would think?

Thanks

... the first post message explains: ...show.php override. Basically you will have to create a template override for the show.php file. More details on template overrides here:

http://www.rsjoomla.com/support/documentation/view-article/692-adjusting-the-components-look-and-feel.html
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
The administrator has disabled public write access.

Help in adding php to show remaining tickets 9 years 11 months ago #27371

  • praes
  • praes's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
  • Thank you received: 2
You can also add this plugin to your system and expand the details so you can use the parameters in all your views.
<?php
/**
* @version 1.3.0
* @package RSform!Pro 1.3.0
* @copyright (C) 2007-2010 www.rsjoomla.com
* @license GPL, http://www.gnu.org/copyleft/gpl.html
*/
 
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
 
jimport( 'joomla.plugin.plugin' );
 
/**
 * RSForm! Pro system plugin
 */
 
class plgSystemRSFPRSEventsprottw extends JPlugin {
 
 
	function rsepro_details ($args) {
 
 
        $id = $args['details']['event']->id;
 
        $db = JFactory::getDbo();
        $query = $db->getQuery(true);
 
 
        // Get max subscriptions from database
        $query->clear()->select($db->qn('max_tickets_amount'))->from($db->qn('#__rseventspro_events'))->where($db->qn('id').' = '.$id);
        $db->setQuery($query);
        $max_subscribers = $db->loadObject();
        //SUM(
        $query->clear()->select('SUM('.$db->qn('a.quantity').')')->from($db->qn('#__rseventspro_user_tickets').' a')->leftJoin('#__rseventspro_tickets b ON (b.id=a.idt)')->where($db->qn('b.ide').' = '.$id);
        $db->setQuery($query);
        $subscribers = $db->loadResult();
 
        $args['details']['subscription']['max_tickets'] = $max_subscribers->max_tickets_amount;
        $args['details']['subscription']['subscribers'] = $subscribers;
 
 
	}
 
 
}
 
 
?>
The administrator has disabled public write access.
The following user(s) said Thank You: paul.lott

Help in adding php to show remaining tickets 9 years 10 months ago #27715

Hello

How do I create this plugin!? :(
The administrator has disabled public write access.

Help in adding php to show remaining tickets 9 years 7 months ago #28558

sounds like something the developer could easily do for their customers
The administrator has disabled public write access.

Help in adding php to show remaining tickets 9 years 7 months ago #28559

  • alexp
  • alexp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 2253
  • Thank you received: 180
The developer, might be busy with creating new cool features - just saying.

I get that there are a few of customers that need this - solution provided. I know that you would also like to have everything out of the box, an extension that would fit each and every possible scenario like a glove, a one button click would be super (definitely free).
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
The administrator has disabled public write access.

Help in adding php to show remaining tickets 9 years 7 months ago #28561

I've been using Event Booking by Ossolution Team and this is a one of their functions and is a great marketing tool because it encourages customers to buy tickets before they sell out. I appreciate every user is different and has different needs but I think this is a feature that would help you sell more licences

Just saying

ps Event Bookings major upgrade doesn't work on my site for reasons the developer cannot work out.
The administrator has disabled public write access.

Help in adding php to show remaining tickets 8 years 9 months ago #31637

  • flexsus
  • flexsus's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 12
  • Thank you received: 2
Hi

Here is what I did in my show.php override file. I have an event without tickets, just a maximum attendance. But still what to show how many that can still subscribe.

Henrik

<?php
$db = &JFactory::getDBO();
// Maximum Attendance amount
$db->setQuery("SELECT (max_tickets_amount) FROM #__rseventspro_events WHERE id = '".$event->id."'");
$max_subscribers = $db->loadResult();
// Amount of Subscriptions
$db->setQuery("SELECT SUM(ut.quantity) FROM #__rseventspro_user_tickets ut LEFT JOIN #__rseventspro_users u ON ut.ids = u.id WHERE u.ide = '".$event->id."'");
$subs = $db->loadResult();
echo 'Max subscribers'.($max_subscribers);
echo '<br>';
echo 'Tickets left: '.($max_subscribers-$subs);
?>
The administrator has disabled public write access.

Help in adding php to show remaining tickets 8 years 6 months ago #32522

This may be of help for viewers of this thread

In order to achieve this you will need to create a template override for the subscribe.php file

The steps performed were:

- Go to the `html` folder of your template and create the following folder tree:

com_rseventspro/rseventspro

- Copy the subscribe.php file from components\com_rseventspro\views\rseventspro\tmpl to templates/template_name/html/com_rseventspro/rseventspro;

- in the override file add :

<?php
$db = &JFactory::getDBO();
$db->setQuery("SELECT SUM(`seats`) FROM #__rseventspro_tickets WHERE `ide` = '".$this->event->id."'");
$seats = $db->loadResult();

$db->setQuery("SELECT SUM(ut.quantity) FROM #__rseventspro_user_tickets ut LEFT JOIN #__rseventspro_tickets t ON ut.idt = t.id WHERE t.ide = '".$this->event->id."'");
$subs = $db->loadResult();

echo 'Remaining tickets left: '.($seats-$subs);
?>

before the following line:

<?php if ($this->event->form != 0 && $this->form) { ?>

This displays the remaining number of tickets on the subscribe page.
Last Edit: 6 years 6 months ago by paul.lott. Reason: spelling mistakes
The administrator has disabled public write access.

Help in adding php to show remaining tickets 8 years 5 months ago #33111

  • massageindy
  • massageindy's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 18
  • Thank you received: 2
Could you tell me how to show the tickets sold count on the category view / list view page for each event? This would let people see which event is popular.
The administrator has disabled public write access.

Help in adding php to show remaining tickets 7 years 10 months ago #35109

  • bioman
  • bioman's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
Here is an improved query with a single query you get also the subscriptions per ticket:
$db = &JFactory::getDBO();
		$db->setQuery("SELECT t.name, t.price, t.seats, t.user_seats, t. description, SUM(u.quantity) AS subsciptions FROM #__rseventspro_tickets AS t LEFT JOIN #__rseventspro_user_tickets AS u ON u.idt = t.id WHERE t.ide = '".$event->id."' GROUP BY t.id");
		$tickets = $db->loadObjectList();

Then you can go through the results with a foreach and display them in a table (like in the faq) or anything you want.
The administrator has disabled public write access.

Help in adding php to show remaining tickets 7 years 10 months ago #35122

  • flexsus
  • flexsus's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 12
  • Thank you received: 2
My full and improved code:
<!--// start / Event price -->
<?php if (isset($details['ticket_info'])) {	// If event has tickets		
 
// Get ticket names, ticket prices and available seats for each ticket
$db = JFactory::getDbo();	
$query = $db->getQuery(true);
 
$query->clear()
 
->select($db->qn('t.name'))->select($db->qn('t.price'))->select($db->qn('t.seats'))->select($db->qn('t.user_seats'))->select($db->qn('t.description'))->select('sum('.$db->qn('u.quantity').') as subscriptions')    
->from($db->qn('#__rseventspro_tickets', 't'))
	->join('LEFT', $db->qn('#__rseventspro_user_tickets', 'u') . ' ON  (' . $db->qn('u.idt') . ' = ' . $db->qn('t.id') . ')')
	->where($db->qn('t.ide') . ' = ' . $event->id)
	->group($db->qn('t.id'));
 
$db->setQuery($query);
$tickets = $db->loadObjectList();
 
?>
<div class="rsep_price">
 
<?php
if($tickets) {
	foreach ($tickets as $ticket) {
		echo "<span>" . JText::_('COM_RSEVENTSPRO_EVENT_PRICE') . " <strong>" . rseventsproHelper::convertprice($ticket->price*1.25) . "</strong> " . rseventsproHelper::getConfig('payment_currency_sign') . " ";
		if (strpos($categories,'somecategory')) { // show available tickets, if Event Category is 'somecategory'
			$available_tickets = $ticket->seats - $ticket->subscriptions;
				if ($available_tickets == 1) {
					echo "<small>(" . $available_tickets . " " . JText::_('COM_RSEVENTSPRO_EVENT_AVAILABLE_SEATS_SINGULAR') . ")</small>";
				} elseif ($available_tickets > 1) {
					echo "<small>(" . $available_tickets . " " . JText::_('COM_RSEVENTSPRO_EVENT_AVAILABLE_SEATS_PLURAL') . ")</small>";
				}
			}
		echo "</span>";				
	}
}
 
?>
</div>
<?php } ?>
<!--// start / Event price -->
The administrator has disabled public write access.

Help in adding php to show remaining tickets 6 years 5 months ago #37549

  • rakeshy
  • rakeshy's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 92
  • Thank you received: 3
Hi Flexus,

I'm using your code in show.php, but when the event has multiple tickets this formula doesn't seem to work anymore.

I get Max subscribers: 0 and Tickets left: -x (minus amount).

Perhaps you have a solution.

Thanks!
The administrator has disabled public write access.

Help in adding php to show remaining tickets 6 years 4 months ago #37550

  • flexsus
  • flexsus's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 12
  • Thank you received: 2
Hi rakeshy

Here is the code I use in my project.

Uncomment:
//var_dump($tickets);
to view what you have in the array from the SQL-query.

For each ticket you need to set 'Number of seats' in RSevents back-end.

In my project I would like to show the price including VAT, that's why I use this: '$ticket->price*1.25'. You need to fit it your project.
And you need to add 'COM_RSEVENTSPRO_EVENT_AVAILABLE_SEATS_SINGULAR' and 'COM_RSEVENTSPRO_EVENT_AVAILABLE_SEATS_PLURAL' to your Joomla language override files.

Regards,
Henrik
<!--// start / Event price -->
<?php if (isset($details['ticket_info'])) {	// If event has tickets		
 
// Get ticket names, ticket prices and available seats for each ticket
$db = JFactory::getDbo();	
$query = $db->getQuery(true);
 
$query->clear()
 
->select($db->qn('t.name'))->select($db->qn('t.price'))->select($db->qn('t.seats'))->select($db->qn('t.user_seats'))->select($db->qn('t.description'))->select('sum('.$db->qn('u.quantity').') AS subscriptions')    
->from($db->qn('#__rseventspro_tickets', 't'))
	->join('LEFT', $db->qn('#__rseventspro_user_tickets', 'u') . ' ON  (' . $db->qn('u.idt') . ' = ' . $db->qn('t.id') . ')')
	->where($db->qn('t.ide') . ' = ' . $event->id)
	->group($db->qn('t.id'))
	->order($db->qn('t.id') . ' ASC');
 
$db->setQuery($query);
$tickets = $db->loadObjectList();
//var_dump($tickets);
 
?>
 
<div class="rsep_price">		
<?php
if($tickets) {
	foreach ($tickets as $ticket) {
		echo "<span><small>" . $ticket->name . " </small>";
		//if (strpos($categories,'somecategory')) { // show available tickets, if Event Category is 'somecategory'
			$available_tickets = $ticket->seats - $ticket->subscriptions;
			if ($available_tickets == 1) {
				echo "<small>(" . $available_tickets . " " . JText::_('COM_RSEVENTSPRO_EVENT_AVAILABLE_SEATS_SINGULAR') . ")</small>";
			} elseif ($available_tickets > 1) {
				echo "<small>(" . $available_tickets . " " . JText::_('COM_RSEVENTSPRO_EVENT_AVAILABLE_SEATS_PLURAL') . ")</small>";
			}
		//}
 
		if ($ticket->price != 0.000) { // Don't show if it's a free ticket
			echo "<br /><strong>" . rseventsproHelper::convertprice($ticket->price*1.25) . "</strong><small> " . rseventsproHelper::getConfig('payment_currency_sign') . "</small>";
		}
		if (!empty($ticket->description)) {
			echo "<br /><small style='display:inline-block;'>" . $ticket->description . " </small>";
		}
		echo "</span>";
	}
}		
?>
</div>
 
<?php } // end - If event has tickets ?> 
<!--// start / Event price -->
Last Edit: 6 years 4 months ago by flexsus.
The administrator has disabled public write access.

Help in adding php to show remaining tickets 6 years 4 months ago #37551

  • rakeshy
  • rakeshy's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 92
  • Thank you received: 3
I'm actually referry to your post for the show.php.

The simple solution

<?php
$db = &JFactory::getDBO();
// Maximum Attendance amount
$db->setQuery("SELECT (max_tickets_amount) FROM #__rseventspro_events WHERE id = '".$event->id."'");
$max_subscribers = $db->loadResult();
// Amount of Subscriptions
$db->setQuery("SELECT SUM(ut.quantity) FROM #__rseventspro_user_tickets ut LEFT JOIN #__rseventspro_users u ON ut.ids = u.id WHERE u.ide = '".$event->id."'");
$subs = $db->loadResult();
echo 'Max subscribers: '.($max_subscribers);
echo '<br>';
echo 'Tickets left: '.($max_subscribers-$subs);
?>
The administrator has disabled public write access.

Help in adding php to show remaining tickets 6 years 4 months ago #37552

  • rakeshy
  • rakeshy's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 92
  • Thank you received: 3
I am only using the total max seats for some of my events.
Not the individual seats of tickets.
The administrator has disabled public write access.

Help in adding php to show remaining tickets 6 years 4 months ago #37563

  • flexsus
  • flexsus's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 12
  • Thank you received: 2
Hi rakeshy

But you need "Number of seats" to be set in order for it to work.
The reason is that subscribtions is recorded in table: 'rseventspro_user_tickets' and 'rseventspro_users '.
Did you try to var_dump '$max_subscribers' and '$subs' to view what your SQL-query returns?

var_dump($max_subscribers);
var_dump($subs);

If you have an event with "Maximum attendance amount" set to e.g. 50. Then add a ticket with "Number of seats" to 50 too.

I have just checked my code and it is still working in my project. So it must be something in your setup.

Regards,
Henrik
The administrator has disabled public write access.
The following user(s) said Thank You: rakeshy

Help in adding php to show remaining tickets 6 years 4 months ago #37570

  • rakeshy
  • rakeshy's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 92
  • Thank you received: 3
It seems the max amount wasn't filled in, that created the problem. Thanks for helping out!
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!