Main menu

Forum


A toy VW combi with a Christmas tree on the roof.

The developer takes a few days off for Holidays...
...and will be back with charged battery!

From 23 December to 2 January included
During this period,
assistance from developer will not be provided.

× Help Forum English

Number of tickets remaining displayed on event list

  • Drdaz123
  • Avatar di Drdaz123 Autore della discussione
  • New Member
  • New Member
Di più
4 Anni 4 Mesi fa - 4 Anni 4 Mesi fa #17132 da 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
Ultima Modifica 4 Anni 4 Mesi fa da Lyr!C. Motivo: [IN DEV.]

Si prega Accedi o Crea un account a partecipare alla conversazione.

  • Lyr!C
  • Avatar di Lyr!C
  • Administrator
  • Administrator
  • Lead Developer
Di più
4 Anni 4 Mesi fa #17137 da 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.7
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 allegato:

Ringraziano per il messaggio: Drdaz123

Si prega Accedi o Crea un account a partecipare alla conversazione.

  • PhilKloppers
  • New Member
  • New Member
Di più
3 Anni 4 Mesi fa - 3 Anni 4 Mesi fa #17412 da PhilKloppers
Risposta da PhilKloppers al 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.";
                                }
                        ?>

 
Ultima Modifica 3 Anni 4 Mesi fa da PhilKloppers. Motivo: Updated code to handle repeat events
Ringraziano per il messaggio: Lyr!C

Si prega Accedi o Crea un account a partecipare alla conversazione.

Moderatori: Lyr!C
Tempo creazione pagina: 0.225 secondi

 

Follow Us

Create your Joomla templates with Template Creator CK

acymailing logo new