Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE » How To » Use a popup from a navigation button
Use a popup from a navigation button [message #1824] Wed, 12 November 2008 10:35 Go to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
I am trying to achieve the following functionality using a popup form:

From a standard LIST2 screen I have a navigation button 'Print Letter'. This activates a popup form detailing the documents that are available to be printed, and I want the user to be able to choose one, and then control will be passed to the appropriate output task for the letter selected.

I was expecting to use _cm_popupReturn to code this. However I am not sure that the popup functionality is working in the way I expected and think this is because I am not associating the popup to a field as would normally be the case. _cm_popupReturn does not seem to be executed (I tried following through with a debugger but couldn't easily find where I am going wrong, so asking for advice instead).

If a popup cannot be used in this way is there another way I could achieve this type of functionality? I thought of just using a LIST1 transaction, but this would not give the CHOOSE option for a user to select.
Re: Use a popup from a navigation button [message #1829 is a reply to message #1824] Wed, 12 November 2008 17:37 Go to previous messageGo to next message
AJM is currently online  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
Popup processing works by a task calling a popup, the task is suspended while the popup is processed, then the popup returns control to the task. Therefore you must activate the "Print Letter" task before calling the popup. For one possible method of achieving this take a look at "Initial Passthru" on http://www.tonymarston.net/php-mysql/menuguide/mnu_task(upd1 ).html

Re: Use a popup from a navigation button [message #1832 is a reply to message #1824] Thu, 13 November 2008 12:17 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
Not managing to get this to work yet. Following your advice I tried creating an upd3 task called 'Print Letter' (used upd3 as this was an available task and gives a SUBMIT button that I thought I could use to execute the print. I set my document_type popup screen as an initial passthrough task.

In practise when I click the 'Print Letter' task button the popup screen is successfully being displayed, and when I select an option and press CHOOSE I am then returned to the UPD3 screen as expected. However, the popupReturn method does not get executed, so I cannot process the results in the way I want.

Following through with a debugger, I see in std.update3.inc line 66 that $return_from contains the name of the popup I am returning from, but $popup_object is NULL, so popupReturn does not get executed.

How is $popup_object determined?

Graham
Re: Use a popup from a navigation button [message #1833 is a reply to message #1832] Thu, 13 November 2008 13:40 Go to previous messageGo to next message
AJM is currently online  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
When the initial passthru option is used the passthru task is activated without going through any preprocessing which depends on the task's pattern_id, therefore it will not perform any popupCall() processing. This in turn means that when the passthru task terminates and the parent task is reactivated the parent task does not know about the popup form and cannot perform any popupReturn() processing. The selection from the popup is made available in the $where string and can be processed in the _cm_initialise() method.

Another point - do not use the UPDATE3 pattern for your parent task as this has a highly specialised purpose. You can use an UPDATE1 pattern if you want a task with a SUBMIT button. If you don't change any database values then no database update will be performed.


Re: Use a popup from a navigation button [message #1834 is a reply to message #1824] Thu, 13 November 2008 14:16 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
Thanks for the help on this. That all makes sense now.

However, regarding the pattern to use, I don't see UPD1 available when I use the Generate PHP task. How do I create a new task based on this pattern?
Re: Use a popup from a navigation button [message #1835 is a reply to message #1824] Thu, 13 November 2008 14:21 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
I think I have answered this question myself by just manually creating a new task!
Re: Use a popup from a navigation button [message #1836 is a reply to message #1824] Thu, 13 November 2008 16:27 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
Still struggling unfortunately. I tried a couple of different patterns but I'm not achieving the result I want. Eventually I thought that the most appropriate pattern would just be an output pattern, calling the popup as initial passthrough. This almost works perfectly except that the selection criteria is not being passed back in the $where string. In the debugger, breaking in the _cm_initialise of the output task I see $selection = NULL and $where is the original where clause with no additional data.

I saw this with a couple of the other patterns too actually - is it pattern dependent and is there a solution?
Re: Use a popup from a navigation button [message #1837 is a reply to message #1836] Thu, 13 November 2008 17:17 Go to previous messageGo to next message
AJM is currently online  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
Yes, the use of the $selection argument in the initialise() and _cm_initialise() methods is pattern dependent.

Try the attached file, a new version of std.update1.inc which should cure your latest problem.


Re: Use a popup from a navigation button [message #1838 is a reply to message #1824] Thu, 13 November 2008 17:54 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
Thank you very much. I actually finally settled on the output2 task so I will duplicate the two changes into this transaction if that will work ok and is ok with you.
Re: Use a popup from a navigation button [message #1867 is a reply to message #1824] Fri, 21 November 2008 12:33 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
Tony,

The general processing is working correctly for this now, but I have a few minor issues that I need to resolve to make it resilient.

I applied the changes you provided in the update task to the output2 task so that $selection was available - this works fine.

However, because the popup form I am using is called as a passthru task it is effectively a list1 , and I can select more thon one item. How can I make 'select_one' = true when popupcall() is not used?

Secondly, when I choose the option from the popup, control then returns to the output2 task, which runs correctly. But the popup task remains displayed on the screen and has to be closed manually. Is there a way to terminate the display of the popup task after an item has been chosen (i.e. (re-)activate the list sceen from which I initially activated my output task?

Thanks in advance for your insight on this.
Re: Use a popup from a navigation button [message #1868 is a reply to message #1867] Fri, 21 November 2008 14:04 Go to previous messageGo to next message
AJM is currently online  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
To answer question 1 please see http://www.tonymarston.net/php-mysql/functions-and-variables .html#global.settings

I do not see how the popup form can remain visible after you press the CHOOSE button the LIST1 script calls function chooseButton() which in turn calls the scriptPrevious() function. This should always terminate the current script before reactivating the previous script.


Re: Use a popup from a navigation button [message #1869 is a reply to message #1824] Fri, 21 November 2008 16:26 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
I'm not able to test at the moment, but I wondered whether the problem is because I am using the popup as a passthru to an output2 task which does not have a screen. I.e. The scriptprevious refers to a task without a screen. I effectively really want to return to the script prior to the output2.
Re: Use a popup from a navigation button [message #1870 is a reply to message #1869] Fri, 21 November 2008 17:56 Go to previous messageGo to next message
AJM is currently online  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
It is possible for a popup to return to a task that does not have a screen, as shown in the ADD3 pattern. When the task has finished processing the selection passed back to it by the popup it simply exits and returns control to its parent task by calling the scriptPrevious() function.

I suggest you step through with your debugger to see exactly what is happening.


Re: Use a popup from a navigation button [message #1873 is a reply to message #1824] Sun, 23 November 2008 16:29 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
Tony,

I've tried stepping through with my debugger, but I'm not confident enough to correctly interpret what I am seeing...

std.output2 seems to be correctly processing the value given to it by the popup screen called as a passthru task. The report runs correctly. From here the prev script and task seem to be correctly set to the list2 transaction I am expecting (lines 88 and 89). Then line 96 executes and unsets the output2 task. The task then exits (but not by calling any other function), but so does the debugger, so I can't figure out where control is going. From an application point of view I am still seeing the popup on the screen.

Is there any other advice you can provide?

Thanks,

Graham
Re: Use a popup from a navigation button [message #1874 is a reply to message #1873] Sun, 23 November 2008 16:46 Go to previous messageGo to next message
AJM is currently online  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
The output2 task ends with the following code:
if (!eregi('(D|I)', $destination) OR !empty($errors)) {
    scriptPrevious($errors, $messages);
} else {
    unset($_SESSION['pages'][getSelf()]);  // delete current script from session array
} // if

which means that the scriptPrevious() function is only executed when the value of $destination is not 'D' or 'I'. What value do you have?


Re: Use a popup from a navigation button [message #1875 is a reply to message #1824] Sun, 23 November 2008 16:52 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
Well, it is 'D' in the report file. I'll run through again with the debugger to see what might be going wrong.

I have used the function getReportSructure to override the values in the default file with one selected by the popup. This could be where the problem is occurring.
Re: Use a popup from a navigation button [message #1876 is a reply to message #1824] Sun, 23 November 2008 17:03 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
The debugger says that $destination = D and yet the if condition evaluates to false and the else statement is executed.
Re: Use a popup from a navigation button [message #1877 is a reply to message #1824] Sun, 23 November 2008 17:14 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
Hmmmm - sorry, I misread your earlier post. I didn't need to recheck with the debugger.

Yes the value of $destination is D, but that is what I expect, as I have run a valid report and asked for it to be downloaded.

I think I understand why scriptPrevious doesn't run for D or I under normal circumstances, but that causes unusual behaviour in this case. Is there a way to solve this?
Re: Use a popup from a navigation button [message #1878 is a reply to message #1877] Sun, 23 November 2008 17:54 Go to previous messageGo to next message
AJM is currently online  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
I think the problem arises because you are not using the popup form in the way it was designed to be used. It it supposed to be called from a popup button, not a navigation button or a passthru task.

If I understand your problem correctly you are starting with a LIST2 task in which you make a selection, then you want to press a button in order to print a letter for that selection.

You are trying to have a single task which prints that letter, but because there are several types of letter you want another mechanism where the user can choose the letter type before it is printed.

Why don't you have a separate task for each type of letter, then a separate navigation button for each of those tasks?


Re: Use a popup from a navigation button [message #1879 is a reply to message #1824] Sun, 23 November 2008 18:38 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
You have summed up the scenario exactly Tony.

I did indeed start by creating separate tasks for each document (it's not just letters actually) and having a separate navigation button for each. However, the number of documents has already grown to 12 and there may be a few more yet, so I was trying to implement a more 'elegant' apprach.

It's nearly there - I get my list of documents, choose one and it prints correctly, but then I am just left with closing the popup manually (plus at the moment I get unexpected results if the user then chooses another selection because the popup is still open).

If it can't be done I'll have to have separate navigation buttons and try and think of another way of reducing the number of buttons.
Re: Use a popup from a navigation button [message #1880 is a reply to message #1879] Sun, 23 November 2008 19:39 Go to previous messageGo to next message
AJM is currently online  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
How about having the LIST2 task pass its selection to an UPDATE1 task (which has a SUBMIT button), and this UPDATE1 task has a dropdown list from which the user can choose a letter type. When the user presses the SUBMT button it does not update the database, but instead passes the LIST2 selection and the letter type from the dropdown list to another task which performs the printing.

Re: Use a popup from a navigation button [message #1881 is a reply to message #1824] Mon, 24 November 2008 05:06 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
That sounds like it should work well. Just one question: I actually want to run the task without having preselections mandatory as in some cases a letter should be produced for all entries in the list2. The upd1 task will not run if I have not made a selection so is there a way to bypass that validation?
Re: Use a popup from a navigation button [message #1882 is a reply to message #1881] Mon, 24 November 2008 05:25 Go to previous messageGo to next message
AJM is currently online  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
What do you mean by "I want to run the task without having preselections mandatory"?
Quote:

The upd1 task will not run if I have not made a selection

In that case change from UPDATE1 to ADD2. If nothing is selected in the LIST2 task then the $where variable in the ADD2 will contain the WHERE string used by the outer/parent entity of the LIST2 task.


Re: Use a popup from a navigation button [message #1883 is a reply to message #1824] Mon, 24 November 2008 05:35 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
Thanks, that answers it. I was referring to the menu process when you add a navigation button and specify whether preselections are required or not. As a point of interest does this yes/no option just determine the positioning of the navigation button or does it affect the processing?
Re: Use a popup from a navigation button [message #1884 is a reply to message #1883] Mon, 24 November 2008 05:56 Go to previous message
AJM is currently online  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
It just affects the positioning, not the processing. This is supposed to give a visual 'hint' as to whether a selection needs to be made (or not) before pressing a navigation button. Selection validation is performed within the task itself.

Previous Topic: std.multi2 locking rows
Next Topic: Search for field in related table
Goto Forum:
  


Current Time: Sat Apr 20 04:19:25 EDT 2024

Total time taken to generate the page: 0.01624 seconds