Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Can I open a browse form from php

Locked
martbarr
Posts: 60
Joined: Fri Oct 26, 2012 8:09 pm

Can I open a browse form from php

Unread post by martbarr »

Is there a way I can open a browse form but build the select statement externally?

I'd like to run a procedure activity to collect various field values and make a select from those values, and then go to a browse form with the selected records, if any.

I can see how to open an edit form using javascript, but not from php (or I could not be looking hard enough!)

This would be quite awesome for my users if I can crack this!

Thanks
Martin
martbarr
Posts: 60
Joined: Fri Oct 26, 2012 8:09 pm

Re: Can I open a browse form from php

Unread post by martbarr »

oo so near but so far !
I didn't realise that a procedure was an eval, so starts with a blank page and no context.
In my procedure code I've tried requiring custom.php and browse.php, and even browse/form.php and doing a new browse object, but am not cracking it. I am very far off the beaten track here?

The Report crieria functionality is what I'm after - but instead of running the report I want to populate a browse form dynamically.

I blame this cold British weather!
Thanks as always
Martin
martbarr
Posts: 60
Joined: Fri Oct 26, 2012 8:09 pm

Re: Can I open a browse form from php

Unread post by martbarr »

nearly there - JavaScript not php .....
I have a button object that runs JavaScript openForm(formid, -1) when clicked - so takes me to the edit screen of my new Criteria form.

On the criteria form I've removed all the action buttons and added my own "search" button that gets the session id, and calls openBrowse() so I get to browse my selected records and then it points to the normal edit form for any clicked on.
(and all the hash vars are available at that point for the sql)

So far so good.

Now if I can only intercept the sql before browse and write my own logic I'm all the way there.
Then I could build my sql on the basis of the vars types in at the criteria form.

Sorry if all this is noddy to you experts, but it's got me excited.

Cheers
Martin
martbarr
Posts: 60
Joined: Fri Oct 26, 2012 8:09 pm

Re: Can I open a browse form from php

Unread post by martbarr »

Ok solved my problem.
I've found a way to rewrite the sql string manually in "before browse" based on the various hash fields I pick up from my criteria form.
Happy and loving the potential of this product!

Martin
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Can I open a browse form from php

Unread post by admin »

Sounds interesting!

Steven
martbarr
Posts: 60
Joined: Fri Oct 26, 2012 8:09 pm

Re: Can I open a browse form from php

Unread post by martbarr »

nuBuilder is brilliant at opening editform and browse form and the "before browse" is so cool.

I use a button to do editForm('xxx',-1) to get a new (temporary) record with various fields (maybe criteria 1, criteria 2 etc) but with no buttons, except a new search which runs js to open itself but now as a browser window.
And on the browse settings I specify the "normal" form I would use to edit.

And on the browse form I use 'before browse' to rewrite the sql select string based on critera 1 (etc),
which gives me a browse result based on my new sql.
And when the user clicks on a record in that browse set they get the "normal" editform.

The only quirk is that I rewrite the sql select by overwriting $this->form->sfo_sql in "before browse" which does work.
It may break in future release - but will worry about that then.

I am doing this sort of thing:-

Code: Select all

if ('#nam_Code#' > '48') { 
   $this->form->sfo_sql="SELECT * FROM Names where nam_Value > 380"; 
}
else
{
   $this->form->sfo_sql="SELECT * FROM Names where nam_Value > 3"; 
}
which seems to open up the interesting possiblity of just doing:-

Code: Select all

$this->form->sfo_sql="SELECT #nam_Code#';
thus getting my users a sql query window - clearly would need some security parsing.

Great fun!

Martin
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Can I open a browse form from php

Unread post by admin »

.
Locked