Main menu

Forum


× Help Forum English

Number of tickets remaining displayed on event list

  • Drdaz123
  • Drdaz123's Avatar Topic Author
  • New Member
  • New Member
More
3 years 8 months ago - 3 years 8 months ago #17132 by Drdaz123
Hello again...

Is it possible to show the number of tickets available for and event in the description on the events list page without clicking on that event???

Thanks in advance,
Darren
Last edit: 3 years 8 months ago by Lyr!C. Reason: [IN DEV.]

Please Log in or Create an account to join the conversation.

  • Lyr!C
  • Lyr!C's Avatar
  • Administrator
  • Administrator
  • Lead Developer
More
3 years 8 months ago #17137 by Lyr!C
Hello Darren,

For 3.8 version, the system to display remaining tickets was full recoded to be a new separate layout (easier too for custom design and overrides).

In this refactory, i have worked to allow this function to work in the main list and to be displayed per event (this was not possible with current stable version).
So my goal is to allow this display in main list too, with a show/hide new option (not yet added, but to be added in the 3.8 serie).

Thank you!

Best regards,
Cyril

NB: i think you will wait for 3.8 with attention ;-)

Latest version : iCagenda 3.9.3
We recommend every user to keep iCagenda updated.
Don't forget to have your Joomla!™ up-to-date!

Do you like iCagenda?
I would appreciate if you could take 5 minutes to post a review on JED (Joomla Extensions Directory) .

File Attachment:

The following user(s) said Thank You: Drdaz123

Please Log in or Create an account to join the conversation.

  • PhilKloppers
  • New Member
  • New Member
More
2 years 8 months ago - 2 years 8 months ago #17412 by PhilKloppers
Replied by PhilKloppers on topic Number of tickets remaining displayed on event list
I've been waiting for this, but eventually just rolled my own solution. Here it is if anyone also needs this functionality. I'm using the ic_rounded theme and the file to edit is components/com_icagenda/themes/packs/ic_rounded/ic_rounded_events.php. Insert the following code before the line (around line 150 for me):  <?php // + infos Text ?> 
                        <?php // Show remaining seats for event ?>
                        <?php
                                $tempdb = JFactory::getDbo();
                                $query = $tempdb->getQuery(true);
                                $query
                                        ->select(array('count(*)', 't1.date', 't2.title', 'JSON_UNQUOTE(JSON_EXTRACT(t2.params,"$.maxReg")) AS capacity', '(JSON_UNQUOTE(JSON_EXTRACT(t2.params,"$.maxReg")) - count(*)) AS available'))
                                        ->from($tempdb->quoteName('#__icagenda_registration', 't1'))
                                        ->join('LEFT', $tempdb->quoteName('#__icagenda_events', 't2') . ' ON ' . $tempdb->quoteName('t1.eventid') . ' = ' . $tempdb->quoteName('t2.id'))
                                        ->where($tempdb->quoteName('t1.date') . ' LIKE "%' . $item->next . '%"')
                                        ->where($tempdb->quoteName('t2.title') . ' LIKE "%' . $item->title . '%"')
                                        ->where($tempdb->quoteName('t1.state') . ' = "1"')
                                        ->group($tempdb->quoteName('title'));
                                $tempdb->setQuery($query);
                                $tempResults = $tempdb->loadAssoc();
                                if ($tempResults["available"] > 0) {
                                        echo $tempResults["available"]." seats available.";
                                } else {
                                        echo "There are no seats available.";
                                }
                        ?>
I haven't tested it with events that have multiple dates, but this works for me for now at least.

*** Updated 2021/08/17 ***
I've tweaked the code to work correctly with repeat events and to display the correct seats when no bookings have yet been made.
                        <?php // Show remaining seats for event ?>
                        <?php
                                $tempdb = JFactory::getDbo();

                                $query = $tempdb->getQuery(true);
                                $query
                                        ->select(array('t1.title', 'JSON_UNQUOTE(JSON_EXTRACT(t1.params,"$.maxReg")) AS capacity'))
                                        ->from($tempdb->quoteName('#__icagenda_events', 't1'))
                                        ->where($tempdb->quoteName('t1.period') . ' LIKE "%' . $evt . '%"')
                                        ->where($tempdb->quoteName('t1.title') . ' LIKE "%' . $item->title . '%"');
                                $tempdb->setQuery($query);
                                $tempResults = $tempdb->loadAssoc();
                                $capacity = $tempResults["capacity"];

                                $query = $tempdb->getQuery(true);
                                $query
                                        ->select(array('count(*)', 't1.date', 't2.title', 'JSON_UNQUOTE(JSON_EXTRACT(t2.params,"$.maxReg")) AS capacity', '(JSON_UNQUOTE(JSON_EXTRACT(t2.params,"$.maxReg")) - count(*)) AS available'))
                                        ->from($tempdb->quoteName('#__icagenda_registration', 't1'))
                                        ->join('LEFT', $tempdb->quoteName('#__icagenda_events', 't2') . ' ON ' . $tempdb->quoteName('t1.eventid') . ' = ' . $tempdb->quoteName('t2.id'))
                                        ->where($tempdb->quoteName('t1.date') . ' LIKE "%' . $evt . '%"')
                                        ->where($tempdb->quoteName('t2.title') . ' LIKE "%' . $item->title . '%"')
                                        ->where($tempdb->quoteName('t1.state') . ' = "1"')
                                        ->group($tempdb->quoteName('title'));
                                $tempdb->setQuery($query);
                                $tempResults = $tempdb->loadAssoc();

                                if ($tempResults == NULL) {
                                        echo "$capacity seats available.";
                                } elseif ($tempResults["available"] > 0) {
                                        echo $tempResults["available"]." seats available.";
                                } else {
                                        echo "This venue is fully booked.";
                                }
                        ?>

 
Last edit: 2 years 8 months ago by PhilKloppers. Reason: Updated code to handle repeat events
The following user(s) said Thank You: Lyr!C

Please Log in or Create an account to join the conversation.

Moderators: Lyr!C
Time to create page: 0.202 seconds

Follow Us

Create your Joomla templates with Template Creator CK

acymailing logo new