Welcome to the nuBuilder Forums!

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

Conditional picture display

Questions related to nuBuilder Forte Reports and the Report Builder.
Post Reply
treed
Posts: 205
Joined: Mon May 18, 2020 12:02 am
Been thanked: 2 times
Contact:

Conditional picture display

Unread post by treed »

Hello all, I have an invoice report and If the paid date is not null I'd like to display an image that says "Paid in Full". So I have 2 questions.
1. Where is the best place to store the image so it won't get overwritten by updates?
2. How would one create and implement the conditional logic in the report?
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Conditional picture display

Unread post by kev1n »

Hi,

Use Setup -> Files to store images.
Do you want to display just one image on the report or several (for each row?)
treed
Posts: 205
Joined: Mon May 18, 2020 12:02 am
Been thanked: 2 times
Contact:

Re: Conditional picture display

Unread post by treed »

Thanks, good to know pictures can be stored that way. What I need to know is how to display that picture based on conditional logic. Kind of like MS Access had a visible property. If a field is null I want to not see the image and if there is an entry the image is visible. Any idea how to approach that?
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Conditional picture display

Unread post by kev1n »

If there was just one picture to be displayed (or not), one could try using a hash cookie. But if you need to show pictures per row based on a condition, it might get more tricky. I have to think about how to tackle this. Maybe someone else will have a bright idea.
treed
Posts: 205
Joined: Mon May 18, 2020 12:02 am
Been thanked: 2 times
Contact:

Re: Conditional picture display

Unread post by treed »

I just want to display one image in the footer, so the hash cookie might work. However I have no idea on how to get from hash cookie to what I need within the constraints of the report writer. If you could point me in the right direction it would be much appreciated.
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Conditional picture display

Unread post by kev1n »

1. Upload your image under Setup -> Files. (In this example I use the image code image_paid). The image has to be in jpg format.
2. Upload a 1x1 pixel jpg image with code paid_image_blank.

3. Create a Procedure under Builders -> Procedure.
Replace FR0 with your report code.

Code: Select all


// To-do:
// Run a db query and based on the result set $showImage = '1' to show the image or $showImage = '0' to "hide" it.

$js = " 
  if ($showImage == '1') {
      nuSetProperty('paid_image', 'Image:paid_image');
   } else { 
      nuSetProperty('paid_image', 'Image:paid_image_blank');
   }

   nuRunReport('FR0'); 
";

nuJavascriptCallback($js);
4. In your report, add an image object. In its Source field, use this Hash Cookie:

Code: Select all

#paid_image#
report_image.jpg
5. To run the report, add this JS in a button's onclick event:

Code: Select all

nuRunPHPHidden('run_report', 0);
You do not have the required permissions to view the files attached to this post.
treed
Posts: 205
Joined: Mon May 18, 2020 12:02 am
Been thanked: 2 times
Contact:

Re: Conditional picture display

Unread post by treed »

One question, how is the invoice_id passed to the PHP code for use in the query?
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Conditional picture display

Unread post by kev1n »

invoice_id can be retrieved as Hash Cookie in PHP: #invoice_id#

E.g. assign it to a variable

Code: Select all

$invoice_id = "#invoice_id#";
treed
Posts: 205
Joined: Mon May 18, 2020 12:02 am
Been thanked: 2 times
Contact:

Re: Conditional picture display

Unread post by treed »

Thanks so much for your help with this kev1n. I used to be pretty good at PHP and now I see more clearly how things tie together.
Post Reply