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?
Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Conditional picture display
-
- 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
Hi,
Use Setup -> Files to store images.
Do you want to display just one image on the report or several (for each row?)
Use Setup -> Files to store images.
Do you want to display just one image on the report or several (for each row?)
Re: Conditional picture display
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?
-
- 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
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.
Re: Conditional picture display
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.
-
- 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
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.
4. In your report, add an image object. In its Source field, use this Hash Cookie:
5. To run the report, add this JS in a button's onclick event:
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);
Code: Select all
#paid_image#
Code: Select all
nuRunPHPHidden('run_report', 0);
You do not have the required permissions to view the files attached to this post.
Re: Conditional picture display
One question, how is the invoice_id passed to the PHP code for use in the query?
-
- 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
invoice_id can be retrieved as Hash Cookie in PHP: #invoice_id#
E.g. assign it to a variable
E.g. assign it to a variable
Code: Select all
$invoice_id = "#invoice_id#";
Re: Conditional picture display
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.