Welcome to the nuBuilder Forums!

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

nuRunPHP in nuAddActionButton Topic is solved

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
vario
Posts: 154
Joined: Mon Dec 05, 2011 12:23 pm
Location: Newton Abbot, UK
Has thanked: 2 times
Been thanked: 1 time

nuRunPHP in nuAddActionButton

Unread post by vario »

I have several "reports" that are little more than lists (i.e no grouping, subtotals etc) and I achieve a two-column layout for longer lists by an unpleasant piece of code which creates report table #TABLE_ID# with duplicate columns and then shuffles data about.

Anyway, I have been fiddling around with CSS flex & grid layouts which provide an easy way to output a list into two columns. I have a PHP procedure which generates an HTML page but if I call it from nuAddActionButton then it doesn't work. It should output a page to a new tab like it does from the onclick event of a button (or as nuRunReport does from nuAddActionButton).

Would I be right in assuming this Behaviour of the RUN button is also my answer?

Neil.
Last edited by vario on Thu Apr 25, 2024 9:34 am, edited 1 time in total.
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: nuRunPHP in nuAddActionButton

Unread post by kev1n »

Hello Neil,

Are you calling nuRunReport() in nuAddActionButton() ?
vario
Posts: 154
Joined: Mon Dec 05, 2011 12:23 pm
Location: Newton Abbot, UK
Has thanked: 2 times
Been thanked: 1 time

Re: nuRunPHP in nuAddActionButton

Unread post by vario »

Yes, nuRunReport() working OK when called from nuAddActionButton(). i.e

Code: Select all

if (nuFormType() == 'browse') {
 nuAddActionButton('VehCheckRpt', 'Checklist', 'nuRunPHP("php_checklist")');
 nuAddActionButton('VehInspections', 'Inspections', 'nuRunReport("rpt_inspections")');
}
So the nuRunReport produces its PDF output in a new window, and the nuRunPHP produces no output (the button remains "down" for a moment).
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: nuRunPHP in nuAddActionButton

Unread post by kev1n »

In a test form, I added this line of code.

Code: Select all

 nuAddActionButton('VehCheckRpt', 'Checklist', 'nuRunPHP("php_checklist")');
And I created a procedure "php_checklist" with the code

Code: Select all

echo "123";
When the action button is clicked, a new tab is opened and 123 is written to the document.

Do you do anything differently? Please provide step-by-step instructions on how to replicate it.
vario
Posts: 154
Joined: Mon Dec 05, 2011 12:23 pm
Location: Newton Abbot, UK
Has thanked: 2 times
Been thanked: 1 time

Re: nuRunPHP in nuAddActionButton

Unread post by vario »

I'm always too slow to delve into the console and debugger...

1) the console error is

Code: Select all

Uncaught TypeError: $(...).val() is undefined
2) This is from the nuBeforeSave() function which is being called:

Code: Select all

function nuBeforeSave() {
 if ($('#veh_reg').val().indexOf(" ") > 0) {
  nuMessage("No spaces allowed in registration number");
  return false;
 }
return true;
}
3) nuajax.js has this:

Code: Select all

function nuRunPHP(code, iFrame, runBeforeSave) {

	if (runBeforeSave == undefined) {
		if (window.nuBeforeSave) {
			if (nuBeforeSave() === false) { return; }
		}
	}
...
I should read the docs more often - the third parameter has fixed this. Sorry for wasting time!
Post Reply