Hi,

I would like to show event's capacity and how many slots remaining values to anonymous user.

How could I display these values to anonymous user:

@slots_remaining slots remaining (if Allow multiple registrations checkbox is not checked)
or
!count of !capacity slots are filled.

Comments

littledynamo’s picture

I would also like to have access to the slots remaining so that i can display it in a view. Currently only capacity and slots booked are available.

retrodans’s picture

StatusFileSize
new3.54 KB

Had the same issue, not sure anyone has already patched this, but I added this functionality using the code from 2 of the similar views fields, and a bit of variable viewing. Appears to work for me so far, but if there are issues, it will likely be with my choice if variables. they looked like the right ones, but I am not accustomed to some of the naming choices in there.

Anyway, hope this helps. If I find any issues, I will repatch and post them here too.

Dan

retrodans’s picture

Seconds after I post that and I find a bug, looking into it now, will report in a few minutes once it has been further tested.

retrodans’s picture

Status: Active » Needs review
StatusFileSize
new3.54 KB

There we are, bug fixed. Also worth noting that for closed to appear (rather than availability) you will need to be anonymous, as if not, the permissions kick in and give you the admin results.

Hope this helps others, I am working on a project with this, so will update as bugs are found still.

Dan

retrodans’s picture

StatusFileSize
new5.68 KB

Last few tweaks for today

kmadel’s picture

This is already possible with Views. Just add a Global field of type'Math expression' - then you can use tokens to get slots left over (of course those fields would have to be included first, but can be set not to display if you don't want to show them):

[capacity_total] - [capacity_used]

luhala’s picture

Hi,
I'm trying to display total capacity field in the calendar display view, but the capacity field is not available in field list. I can see only "Spaces used" and "Slots consumed"...
I tried adding various relationships (Registration, Registration Settings, etc.) and nothing helps. I'm playing with this for two days, with no success :(
Any idea, what I'm doing wrong? What setting is required to see capacity in fields?

Using Entity Registration 7.x-1.2

Thanks!

ptmkenny’s picture

#6 is correct. If you have already added the Registration Settings as a relationship, you can add the relevant fields in Views and then perform a math operation.

twod’s picture

Issue summary: View changes

Note that this is easiest to do with a Content View (Nodes), then add a required Registration Settings relationship to that. Making it required will perform an inner join and thus won't show nodes of types which aren't Registration Types.
Then add two fields: "(node being the Registration) Registration Settings: Slots Total (Slots Total)", and "Registration Settings: Spaces used (Spaces used)".

That will get you a list of all registration types along with their used/total slots.

The View I do this on has a Content Pane display (from CTools) which takes a nid contextual filter (set to get its value from context), I then add this to my node/%nid overriding Panel in Page Manager.
The result is a sidebar/header/footer/whatever on all my registration-enabled nodes with the info for that Registration instance.

rattusrattus’s picture

#6 is not correct as total capacity field will return 'unlimitied' if set accordingly which will not work in your expression.

ekes’s picture

StatusFileSize
new2.71 KB

I'm assuming it is desirable for this 'field' to return 'unlimited', and as the patch 'closed'.

The patch uses the same assumption that the already existing field 'registration_handler_field_entity_capacity_used' which is that the table name will be the same as the entity name. This is usually, but not always, the case. ECK for example prefixes all its entities tables with eck_.

It seems easiest to ensure the entity type is available by moving the 'field' to be on the settings table, along with the capacity field itself. So if you want how much of the capacity is left you have to add a relationship on the table, or work on the settings table directly.

Anonymous’s picture

Thanks #6 is working perfectly for me, great! However your 2 variables must not include any html (like rewrited labels) otherwise of course the mathematical expression doesn't work and always return 0.

ekes’s picture

Yes #6 works for node but will break as soon as the entity name is not the same as the table name. I can't see any way round that except making the join on the settings table.

jochen wendebaum’s picture

I added a nasy views-php-field showing the remaining spots. Works as a charm :)

deanw’s picture

I found this post helpful - http://renaudjoubert.com/en/article/how-count-or-add-all-values-integer-...

Create a new field-based view sorted by Unsorted (i.e. NO SORT) to which you'll add a block display (no need for a page display here).
Add the Available spaces field. Remove all other fields.
In the Advanced section, check Use aggregation. Save.
Back in the FIELDS section, click Aggregation settings and set the type to SUM. Save. The field should now look like so: SUM(Content : Available spaces) | Aggregation settings.
Click SUM(Content : Available spaces), click on Rewrite results and check Rewrite the output of this field using the available replacement tokens.
E.g. Total number of available spaces: [field_daycare_available_spaces]. where [field_daycare_available_spaces] is the token available for the field that holds the number of available spaces in my content type. Of course, this token will change based on the name of the field that holds the values that you want to add.

Also you'll need to remove any Sort Criteria to get it to work.

chris matthews’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
Status: Needs review » Closed (works as designed)
oranges13’s picture

Is this actually fixed? Why was this issue closed with no information?

chris matthews’s picture

Hi oranges13, this issue was a Support request and there are a lot of good suggestions in this thread that can be utilized. Did you need any additional support?