[SOLVED] Picklist Element Plugin | Enable logged in user to enroll to something

marcq

Member
Hi,

Hereafter, the explanation of my current issues with the picklist element plugin

I have created two joomla user groups :

1. Patron (skipper)
2. Bacouni (crew member)

Each group can among other forms, access to forms called

1. For the skipper : ?Cahier de service ? Patron?
2. For the crew member : ?Cahier de service ? Bacouni?

which are sharing the same database table.

In each of the form, I?ve got 2 Picklist Elements (in two different groups) :

1. Enable the skippers to enroll to a boat trip as a skipper (list of the registered ?Patrons?)

To enroll they need to login to access to their ?Cahier de service ? Patron?

Only available option of the picklist is the logged in skipper (see the following query/code)


Eval populate skipper Picklist (book_crewchief)
Code:
$dbchief = JFactory::getDbo();
$userid = '{$my->id}';
//Retrieving the id of the logged in skipper
$dbchief->setQuery("SELECT id FROM fab_crew_chief WHERE userid = '$userid'");
$loggedincrewchief = $dbchief->loadResult();

$dbchief->setQuery("SELECT id, nom FROM fab_crew_chief WHERE id = '$loggedincrewchief'");
$myrows = $dbchief->loadObjectList();
foreach ($myrows as $row) {
 $options[] = JHTML::_('select.option', $row->id, $row->nom);
}
return $options;

See video : http://www.screencast.com/t/OwNmPrAv

2. Enable the crew members to enroll to a boat trip as a crew member (list of the registered ?Bacounis?)

To enroll they also need to login to access to their ?Cahier de service ? Bacouni?

Only available option of the picklist is the logged in crew member (see the following query/code)

Eval populate crew member Picklist (book_crewmember)
Code:
$dbcrew = JFactory::getDbo();
$userid = '{$my->id}';
//Retrieving the id of the logged in crew member
$dbcrew->setQuery("SELECT id FROM fab_crew WHERE userid = '$userid'");
$loggedincrewmember = $dbcrew->loadResult();

$dbcrew->setQuery("SELECT id, nom FROM fab_crew WHERE id = '$loggedincrewmember'");
$myrows = $dbcrew->loadObjectList();
foreach ($myrows as $row) {
 $options[] = JHTML::_('select.option', $row->id, $row->nom);
}
return $options;

See video : http://www.screencast.com/t/AVM9bgmc2


ISSUE SKIPPER PICKLIST :

See video of the following steps : http://www.screencast.com/t/qJtrabsHfzu

1. ?PATRON 1? enroll as a skipper for a specific boat trip.

2. ?PATRON 2? is looking at the available boat trips and he?s visiting the same boat trip page (form detail view).
He normally should see that the skipper position is already taken by PATRON 1 (in the selected option area of the picklist).

3. ?PATRON 1? should appear in the selected options area of the Picklist, instead of this we can see that it is populated with an empty option :

upload_2016-5-28_16-8-54.png

-> firebug :

<li class="1" id="fab_booking___book_crewchief_value_1"> </li>

The Picklist is not returning the value saved even if the value is stored accordingly in the database.

4. By visiting the same form, with ?PATRON 1? user we can see that his name (option) appears in the selected option area of the picklist, since he enrolled as skipper for this specific boat trip.


ISSUE CREW MEMBER PICKLIST :

Same issue on the crew member?s perspective.

See video : http://www.screencast.com/t/kFys5rCrB

I hope I was clear enough, thank you in advance for your support.

Cheers,

Marc
 
The skipper isn't showing because you are populating the skipper picklist with eval'ed code that only fetches the logged on user's record. The values you select with your code are what we then build the selected / available picklists from, using any pre-existing selections to place the options in the right column (available / selected). Which means that when a different user loads the form, the options you build do not contain the value already saved by another user. So we can't render it.

-- hugh
 
Thank you Hugh for your explanation.

Is there a way how I could hide those 'empty' options ?

Or how I could I manage to enable the logged in user to be able to slide on the left side only is own option and not the other ?

Thank you for your time.

Marc
 
I really can't think of a way. The options have to include any value which is already saved in the table.

-- hugh
 
I really can't think of a way. The options have to include any value which is already saved in the table.

-- hugh

Thank you for your time,
Is there another way (other fabrik plugin) I could use to enable the crew members or skippers to enroll to a boat trip ?
marc
 
So there can only be one skipper, and it's "first come, first served", so once someone selects themselves as skipper, nobody else can select themselves?

There's obviously only one skipper. But can there be multiple crew members?

-- hugh
 
So there can only be one skipper, and it's "first come, first served", so once someone selects themselves as skipper, nobody else can select themselves?

There's obviously only one skipper. But can there be multiple crew members?

-- hugh

Thank you for your reply. Yes first come first served for the skipper. But there can be multiple crew members. Cheers, marc
 
Last edited:
Hi,

I'm reviving this thread !

Picklist is not an option anymore for me since it is impossible just to display the name of the logged in user in the picklist.

Do someone has an idea how I could enable the logged in user to enroll to a crew and then appear in the crewmember list of a specific event ?

Let me explain how it should work :

1. Crew member is logged in.
2. Crew member is viewing a list that contain different event | eventdate which he can join as a crew member
3. Crew member is opening the form related to a specific event | record (form = 1 event).

Now he should be able (like the other crewmembers) to enroll to the crew for this specific event and appear in the list of the enrolled crewmember.

I would appreciate some advise here, how I could manage to do this.

Thanks a lot in advance for your support.

Cheers, marc
 
Assuming crew members are Joomla users, a join element to the Joomla users table, set to checkbox or multiselect display, should do it. You could add a default of {$my->id} if needed.


Sent from my HTC6545LVW using Tapatalk
 
Assuming crew members are Joomla users, a join element to the Joomla users table, set to checkbox or multiselect display, should do it. You could add a default of {$my->id} if needed.


Sent from my HTC6545LVW using Tapatalk
Thank you Hugh for your suggestion. I'll get back to you when it is done. Cheers, marc
 
Last edited:
UPDATE :

Hi Hugh,

This is not the solution, since the logged in user should only be able to check is own named checkbox.

Similar to the Picklist issue, if I'm restricting the checkbox display to the logged in user, than only the value of the logged in user will be saved and not the possible already saved by other users values (see #2).

Any idea how I could solve this issue ?
 
Hi Hugh,

I'm trying to solve this issue with a radio button Element. I don't know if it is the appropriate way to do it, but I have no other idea.

Here the steps I went through :
  1. I have created a list | form which is a simple booking form (table : fab_inscriptioneve)
  2. I have created a "Title" field Element and a "Int?gration ?quipage" Radio Button Element with 2 options :
    0 = I don't join the crew
    1 = I join the crew
    (see attached picture)
  3. I added a PHP form plugin to the form which generate a query that populates the "fab_inscriptioneve_repeat_membre" table field "parent_id" with the id of the booking and the "membre" field with the userid of the logged in crew member when option = 1 is set.
This works fine, table and fields are populated.

I have two issues now :

  1. I would like to be able to delete the logged in user from the "fab_inscriptioneve_repeat_membre" table when the logged in user is changing the option from 1 to 0 (this is why I would like to create a query with a if elseif statement which insert the user into the table if option 1 is set and delete the user from the table if option 0 is set (please see thread http://fabrikar.com/forums/index.ph...if-else-loop-2-different-mysql-queries.44653/).
  2. Since the radio button Element is creating a field in the "fab_inscriptioneve" a value is saved into the table field "integration_equ", so all the logged in users will get the last saved rendered, example :
    a) user 1 choose option 1 (enroll as a crew member), value saved into the "integration_equ" is 1, booking id and logged in userid are saved in the "fab_inscriptioneve_repeat_membre" which means that user 1 as joined the crew.
    b) At the same time, user 2 is changing is mind and set the option 1 to 0, value saved into the "integration_equ" is 0, user is deleted from the "fab_inscriptioneve_repeat_membre" since the user is not a crew member anymore.
    c) when user 1 is visiting the same form (booking) the radio button is set to 0 (I don't join the crew) even if he's in fact member of the crew. Value of the radio button option should be set to 1 for this specific user.

    Question : is it possible to create a radio button without a database field and to generate a query that set the radio button element to option 1 if the logged in user exists or to 0 if he doesn't exist in the "fab_inscriptioneve_repeat_membre" table ?
Sorry if my method is unorthodox, but I couldn't find another way to do it.

Thank you very much in advance for you advise and suggestions. Cheer, marc
 

Attachments

  • upload_2016-7-22_17-41-38.png
    upload_2016-7-22_17-41-38.png
    12.9 KB · Views: 173
Hi,

Issue 1 is solved (see http://fabrikar.com/forums/index.ph...oop-2-different-mysql-queries-solution.44653/).

Concerning the issue 2, I think it is impossible to create a radio button Element without creating is database table field. So I added in my form PHP plugin some code with reset the value of this field to 0.

Now I would like my radio button being populated | set to
  1. option "0" if the logged in user didn't enroll
    -> logged in userid didn't exist in the "fab_inscriptioneve_repeat_membre" tablefor the specific booking
  2. option 1 if he have enrolled
    -> logged in userid exist in the "fab_inscriptioneve_repeat_membre" table for the specific booking
Is it possible to add some PHP code in the "Advanced" Tab of my radio button Element ? If not, how could I solve this ?

Thank you in advance for you help, since I'm now stuck.

Cheers, marc
 
Last edited:
I've been wracking my brains and digging through code trying to think of a way of doing this. So far no luck.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top