This topic is locked

Edit Mode with lookups

9/1/2005 11:26:43 AM
PHPRunner General questions
K
kellyho67 author

I have a main table and 3 lookup tables. When I add a record to the main table I want details from the lookup table to populate based off of one dropdown in the new record.

Example:

If I add a new record the master record (not normalized)

Takes

Company (Dropdown)

From that the form needs to auto populate (Contact Name, Address, etc)

That way the user doesn't have to do anything but select a company and they will get the rest of the fields in the master record form filled out for them in a read only.
I realize this is better by using joins etc but it's quick and dirty and I figured the product could do this but it seems to be limitd in that I can't populate form fields based off of a lookup table drop down for one column. (Am I wrong)
I tried lookup wizard but It always make dropdowns and I really only want read fields to populate the master record.

Admin 9/1/2005

This can be done manually editing generated PHP files.
Basically speaking you need to load contact names, addresses etc into Javascript arrays when page loads and populate those fields using onchange event of Company drop-down box.

K
kellyho67 author 9/1/2005

This can be done manually editing generated PHP files.

Basically speaking you need to load contact names, addresses etc into Javascript arrays when page loads and populate those fields using onchange event of Company drop-down box.



Thanks, if I were to write the code from ground up that may be more forward. looking into the add pages it's very conveluded (sp?) and would like to know if anyone could give me a pointer.
I did end up doing a manual sql edit to bring it all together in a list but at that point the program become more or less pointless because I have to go in and write code for just about everything.
I would seem there should be an easy way to just have a callback to post the data to the form or even a javascript but product may be new and limited. I'm thinking if it can even do simple joins it's a bit expesive for single table manipulations.

Corinne 9/12/2005

kellyho67,
Have you had any luck with this? I'm trying to do something similar. I have items and prices associated with each item in a table. When the user selects an item from the dropdown list I want the price feld to be automatically filled with the cooesponding price. Can anyone tell me how I can do this?? Any help is appreciated.
Thanks,

Corinne

501238 9/13/2005

kellyho67,

Have you had any luck with this?  I'm trying to do something similar.  I have items and prices associated with each item in a table.  When the user selects an item from the dropdown list I want the price feld to be automatically filled with the cooesponding price.  Can anyone tell me how I can do this??  Any help is appreciated.
Thanks,

Corinne



Yeah, to some degree.

$database ->setQuery("select what you want to get here");

$data = $database->loadObjectList();  //get a list

//if you have something weird with child parent you'd have to put it into an array and create a loop on $data as $row

//something like this perhaps ( I don't in my case)

$subitems = array();

foreach($data as $row) {

if($row->parent) {

 if(!array_key_exists ($row->parent,$subitems)) {

   $subs[$row->parent]=array();

   }

  $sub[$row-parent][] = $row;

 }

}

....bla bla bla
You'll hav to create another varliable like $mydatat_content and then populate that variable with the returns of the data from the select. then put it in with the $row->name combo
$item = addslashes ($row->items);

$price = addslashes ($row->prices);
Corinne 9/13/2005

Thanks for responding. I'll try to adapt this for my needs. Where would I put this code?
Does anyone else have any other solutions in case I can't get this to work. It may be a little above my skill set right now.
Thanks,

Corinne

M
markdorminy 9/18/2006

Has anyone attempted this since this was first posted?
Thanks!

MD

D
Dale 9/19/2006

I solved this issue using Ajax. When creating a new invoice, I needed to populate the prices, tax rates and also update a schedule of actions for the purchase.
I found a nice snippet of how Ajax works on www.dhtmgoodies.com - Client lookup sample and went from there.
If you want to have a look at the result, I have created a username phprunner with password phprunner that you can access at www.vintbrew.com
When you get to the site, top right corner you will see, Select Project. Select Vintbrew Management Software and then select GO.
You will be taken to the customer list. Open the first one, and create a new purchase.

Select Beer as the group.

Select American Steam Lager Barons as the type.

Then select the Accept ... Update button and you will see the pricing update.

Select the Schedule tab at the top, select Display schedule and you will see the updated schedule for this purchase.
All this was updated using Ajax.
Unfortunately I am deep into my other project right now, so I dont have a lot of spare time.

I hope this may get you started.
It was the only way I could get records updating without having long and complicated picklists generated on the pages.
Oh, all this is done with PHPRunner 3.0 (build 98), not the new beta. I have way to many template mods to move to the beta as yet.

kujox 9/21/2006

Dale
That does look very good, I have a similar problem with the amount of products and have been trying to find a way round a large dropdown of over 2000 products which will get larger, I can't break them into groups and have thought about using a popup box to pick from, It looks like this might be the answer.
I also like the loading page, where did you get that from?

D
Dale 9/21/2006

Thanks for the positive comment.
Im assuming when you say the loading page, you are talking about the progress bar I load when pages change.

This script can be found at dhtmlgoodies, XP progress bar. I just replaced the standard Please wait... message in the phprunner template. I think it is always important for the browser to be showing some type of action is happening when a user selects a new page.
You are spot on with your point about large picklists generated by PHPRunner. Just to much information that a user can get access to by looking at the page source. Ajax was the answer.
PS. If you need access again to the site again, just drop me an email from the forum. I have disabled access for the phprunner signon as I am updating constantly.

jwoker 10/18/2006

I need to do this as well. I went to dhtmlgoodies.com and read through the Ajax solution. It seems I need to create and upload 2 new files. 1 - .php file to get info from MySQL and 2 - .js file (Ajax file) that seems to be storing some procedures. I think I can handle that ok. Then there is some code to go into the head section, that should be no problem as I can see that section on the visual editor page. The part where I know I will have a problem is integrating the Ajax/java code into the into my Add page body. Here is a piece where when a user selects Client ID the client details are filled in:
<form name="clientForm" action="ajax-client_lookup.html" method="post">

<fieldset>

<legend>Client information</legend>

<table>

<tr>

<td><label for="clientID">Client ID:</label></td>

<td><input name="clientID" id="clientID" size="5" maxlength="4"></td>

</tr>

<tr>

<td><label for="firstname">First name:</label></td>

<td><input name="firstname" id="firstname" size="20" maxlength="255"></td>

</tr>
This is from my visual editor (i am after customer details):

{build_edit_control field="customerID" value=$value_customerID mode="add"}

  1. I don't get what the triger is?
  2. How do I translate what's going in <> as opposed to {}
  3. With the PHPR I am using a lookup to display customer details using "custom expression" and concat() so I don't know whether $value_customerID contains the Customer's ID or contains the display text
    Any help would be appreciated <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=11941&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />

D
Dale 10/19/2006

Hi jwoker
The method I used was grab and try until it works. The solution has been very successful for me using the Ajax method, and once I got my head around on what it was doing, I could quickly modify it for another record. Generally there are not that many records out of a complete database that need this kind of interaction.
I havent had time to go back and optimize the method, but hey, if it works, dont fix it.
But, what I read in your last post, I get the impression you are up on the new version. I have not upgraded to the new version. Like many, this upgrade was so severe, with no backward compatibility that I cannot take the time to redo everything in the new version. I would like to, PHPRunner is a fantastic tool, and I think the new version has more great features, but we have had to customize the templates and such, so much for previous versions that I have put off the upgrade. Let the issues settle down too.
Anyway my rambling point is, I have no familiarity with the new smarty code, or the template layouts and syntax they are using in the new version so I dont think I can be of much help there.
I am actually going to implement the Ajax method on fetching records for the next few days. I have a name and address list of 29000 valued customers, using the built in phprunner lookupwizard is not usable. I tried, and to actually have the 29000 names in an array at the bottom of the source is just too time consuming.

So I will be trying a rather nice snippet of building picklists on the fly with Ajax. Maybe I can optimize the functionality this time around.
Finally, if you want to see it in action, you can drop me an email and I will set you up to view my app.

A
andyjames 6/10/2007

Trying to implement Dale's ajax dynamic client lookup from dhtmlgoodies.com in PHPRunner ver 4.0 build 265...
I think the problem I am having is down to the fact that I haven't worked out how to create the field id tab in SMARTY templating.
An example of a form field input tag in SMARTY is as follows:
{build_edit_control field="ClassRef" mode="add" value=$valueclientID}
If you view the html output using View|Source in a browser the above translates to (note name is preceded by "value
"):
<input type="text" name="value_clientID" value="">
To get the above code working I think (not 100% sure) you need to create a field id tag, which in normal html code would just mean including the following inside a form field

<input name="clientID" id="clientID" size="20" maxlength="255">
My question is: HOW DO YOU CREATE AN ID TAG FOR A FORM FIELD IN SMARTY??

Or better still, has anyone worked out how to implement the ajax dynamic client lookup from dhtmlgoodies.com in Version 4 of PHPRunner?
Thanks for any pointers