Jos_users, another table and fabrik?

Discussion in 'Standard Support' started by deepakdhingra, Apr 19, 2012.

Thread Status:
Not open for further replies.
  1. deepakdhingra Member

    Level: Community
    Hi,

    Had a query regarding jos_users and fabrik. Hope someone helps me out on this.

    1. Will it be possible for the signed/logged in Joomla user (who has signed up through a standard Joomla Registration process) to fill up a Fabrik form and have that Fabrik form auto-populate the username and email field (I have done this earlier only when Fabrik has handled the sign up process).

    2. if the above answer is yes, then wont it also be possible to take some data from another table (I am using another component called OSE Excellence) to capture additional data like address, telephone number and gender and again have it pre-populate / auto-populate a field in a Fabrik form?

    3. If the answer to Point No. 1 is yes, is it possible for the logged in user to only see his records through the "{$my->id}" condition ?

    Hope I have been clear on my query.

    Thanks for reading this.

    Deepak
  2. deepakdhingra Member

    Level: Community
    Can someone point me in the right direction? Just give me a few tips for me to get started.

    Thanks.

    Deepak
  3. cheesegrits Support Gopher

    Level: Community
    Well, it kind of depends what you mean by "pre populate".

    Do you want to copy the values from those other tables in to corresponding fields on your Fabrik form, such that they are "separated" from the original tables once you save your Fabrik form? In other words, if you then changed the original values in the other tables, those changes would not show in the Fabrik form.

    Or do you want to do this with joins, such that the values you are seeing in the Fabrik form are the actual fields from the other tables, and if you change the values in your Fabrik form, it'll change the values in the other tables?

    -- hugh
  4. deepakdhingra Member

    Level: Community
    Hi Hugh,

    Thanks for your interest.

    The 2nd option is what I am looking at. I am making a website for a concierge or handyman service. However, in the Fabrik form, users should not be able to edit those fields that have their values pre-filled. Such as First Name, Last Name, Email ID.

    Let me explain exactly what I am looking for.

    1. There is a membership component called OSE. I am using that to register the user. So then jos_users is filled up with the member's details.

    2. Now this member wants to request a certain service - like, getting flowers delivered. For this he fills up a Fabrik form in which his First name, Last Name, Email ID, Address and Phone nos are taken from jos_users (and are non-editable in the Fabrik form) and/or the other table (jos_something) and he fills in the required fields. For example, deliver flowers. And enters some instructions into a "Remarks" text box. Hits "Submit"

    3. This entry should be visible in a Fabrik table to him only any time he logs in.

    4. Then the website admin guy gets an email (email form plugin) regarding this request. When the flowers are delivered he updates the entry (update table plugin). The customer gets an email informing him that his work has been done plus he sees the status of this entry is his member section.

    This way everyone is happy. :)

    Now if you could guide me a little I'll be a very happy as well. :)

    Thanks.

    Deepak
  5. cheesegrits Support Gopher

    Level: Community
    Are you using Fabrik 2.x or 3.x?

    -- hugh
  6. deepakdhingra Member

    Level: Community
    Using Fabrik 2.x on Joomla 1.5.26
  7. deepakdhingra Member

    Level: Community
    Hi Hugh,

    Waiting for you to shed light on this.

    Deepak
  8. cheesegrits Support Gopher

    Level: Community
    Your best bet is probably the autofill plugin. Table joins don't quite do what you need.

    -- hugh
  9. deepakdhingra Member

    Level: Community
    Allright Hugh. Let me see what I can do.

    Thanks for your help.

    Deepak
  10. deepakdhingra Member

    Level: Community
    Hi again Hugh,

    Got the autofill Plugin working. But I have one problem.

    The situation - The autofill plugin has a field to observe which when selected states "Do you want to search for an existing record thatmatches the data you just entered?" and then the correct data of the selected ID is entered.

    My need - The autofill should not show all id's in the database. I only need the logged in user to see his details. Can I have that done in some way? And since we are not using the "{$my->id}" condition, how do I achieve this?

    have attached a screenshot of the autofill.

    Thanks.

    Deepak

    Attached Files:

  11. deepakdhingra Member

    Level: Community
    I was going through various threads on autofill in the forum and I saw this thread - http://fabrikar.com/forums/showthread.php?t=23683&highlight=autofill

    The member in this thread has posted an image of is autofill plugin in use and it has 2 more fields - "autofill confirmation" and "autofill on load". And I am using rhe latest version 2.1.1

    Am I missing something?

    Deepak
  12. deepakdhingra Member

    Level: Community
    I was experimenting and I did this -
    In the name field element, on eval I used this - $user =& JFactory::getUser();
    return $user->get('name'); and it show sthe logged in users name.

    In the email field element, on eval, I used this - $user =& JFactory::getUser();
    return $user->get('email'); and it shows the logged in users email.

    I am wondering why do I need the autofill plugin. This is all I needed. To show the logged in users name, email, address and mobile number. I got name and email by the PHP code above.

    How do I get the mobile number and address? Both these are on a different table called jos_osemsc_billinginfo and I did a database join element. So on the form it shows the mobile numbers of all the users. How do i show only the logged in user's mobile number? Or shoul I remove the database join element an put in some PHP code to retrieve the data from the database table called telephone under jos_osemsc_billinginfo. If yes, what is that code?

    I tried creating a new table called ose, connected it to jos_osemsc_billinginfo and left-joined that to jos_users with a join. Then, added a prefilter with user id equals {$my->id}, type Eval (tried text as well) beneath Super Admin (Tried Admin as well). Then, in Related Data, Linked it to Table and Form and Gave the Label "Mobile". No luck. It still shows all mobile numbers.

    Dont know what to do.

    Any suggestions?

    Deepak
  13. cheesegrits Support Gopher

    Level: Community
    Does your jos_osemsc_billinginfo table include the J! user ID? If so, you could do a simple lookup as an eval's default:

    PHP:
    $user = JFactory::getUser();
    $userid = $user->get('id');
    $db = JFactory::getDBO();
    $db->setQuery("SELECT mobile_number FROM jos_osemsc_billinginfo WHERE userid = '$userid'");
    return $db->loadResult();
    Obviously, tweak that query to use your field names for mobile_number and userid.

    -- hugh
  14. deepakdhingra Member

    Level: Community
    The jos_osemsc_billinginfo table calls it user_id.

    For the mobile_number, should I be using the Fabrik element name or the actual database name. Like this-

    $user = JFactory::getUser();
    $userid = $user->get('id');
    $db = JFactory::getDBO();
    $db->setQuery("SELECT mobile_number FROM jos_osemsc_billinginfo WHERE id = '$userid'");
    return $db->loadResult();

    And the elements in Fabrik dont show user_id but when viewing in table view id shows up. And in the actual MySQL table, it shows user_id in jos_osemsc_billinginfo

    What should I use?

    Deepak
  15. deepakdhingra Member

    Level: Community
    This finally worked -

    $user = JFactory::getUser();
    $userid = $user->get('id');
    $db = JFactory::getDBO();
    $db->setQuery("SELECT mobile_number FROM jos_osemsc_billinginfo WHERE user_id = '$userid'");
    return $db->loadResult();

    Thanks for your help, Hugh. And I did not need the autofill plugin at all, in this case.

    Closing the thread.

    Deepak
Thread Status:
Not open for further replies.

Share This Page