Help with building a quote calculator

JackGoa

Member
hi, i need some assistance with building a quote calculator for medical aids. i have a fairly good understanding of how the basics work in fabrik, but i feel this one is a bit over my head.
can anyone please point me in the right direction? if i had to sign up for professional support, would i be able to get someone to help me out a bit?
i've got the table in the database with the elements and so forth, but i need help with setting up the formulas.
 
Well, I have a table consisting of fields, medical aid name, plan name, member rate, adult dependent rate, child dependent rate, maximum number of children, the type of plan and then whether it is a hospital plan or a network plan.
The calculator form has 3 fields. 1 is for salary (one of the plans, the same for each medical aid, has additional fields based on income level... just to make my job that extra bit more complicated), number of adult dependents, number of children dependents (some plans allow for up to three children and some up to 99).

The lists of results should kick out a row of rates for each medical aid. So i.e., medical aid 1 - plan 1, plan 2, plan 3, plan 4, plan 5, plan 6, etc. One more little difficulty is, as you can see by the fields above, there are two different kinds of plans, hospital and network, basically the rates will fall under two different table headings, whether it is the rate for a hospital plan or the rate for a network plan.

I hope this all makes sense. It took me quite some time to wrap my own head around how all these plans work!!

Thanks so much for replying!! I'm not 100% sure if that calc field is going to work in this instance??
 
Hmm, that is quite a task! So you need to perform some calculation (versus a simple filter) on the information a customer enters in a search form. The results of that are used to filter your list of available plans. Hmm, not sure what to recommend off the top of my head but it sounds doable. I would agree that this sounds beyond the capability of the Calc element.
 
yeah, it's quite daunting from where I'm sitting looking at it at the moment. I kind of have an idea of the formula I would need to setup, even though my PHP is quite rusty. The thing is, I just don't know how to go about it. I know I need to display a list, but I do not know what the settings are for that search form.

Please could you point me in the right direction if you can?

Some of the tutorials don't work and some of the links in the tutorials are broken. Do you think subscribing for professional support would get me the help I need?

I'm not really too scared to thrash things out a bit, I built a very neat search form for this same client about 2 weeks ago that searches by diagnosis (or medical scheme code), giving you certain medial aid codes that the medical aids use. It's over 11 000 records. It did take me about a week to figure it out, but I did get it done... eventually. ;)
 
I haven't made a search form myself so it's hard to say exactly how to do it or if that is your best option. I'd hate to send you on a wild goose chase. But you said you've made one before so you are aware of it's possibilities.

If you can your narrow options based on a set of fields, checkboxes, dropdowns, radiobuttons, etc. presented to your user, then the search form basically applies those values just like a normal list filter would. But instead of the user looking at the full list from the start, they see your search form.

Using an algorithm is similar. Each of your plans would have a value. The results of the user's selections would be some calculated value that would filter the list of plans.

It's hard to say without knowing how you intend or what the best way would be to narrow the list of choices.

I think the switch to the new forum and Fabrik site not too long ago broke some of the links. I totally agree they are quite useful for learning new ways to use Fabrik even though the content is somewhat dated. What tutorial links are broken that you need? I think the Fabrik folks did the best they could but many of these links just got missed. Bringing it to their attention usually gets them fixed quickly though. They are very aware of the value that content provides.

Getting a professional subscription would definitely move you up in terms of support priority from the developers.
 
I've posted before about something being broken but received no reply.

I've also noticed post in the professional support section of the forum that don't receive replies either, so I'm wary of paying for something I'm not going to benefit from...
 
so played around a bit and noticed there is a plugin you can add to a form which gives you an option to add a php script file. I tried adding that and upon submission ended up with a blank page. Then I thought, maybe I should add a redirect to the list that I'm getting the data from like you do with a search form, which just took me to a list of all the data in that db table that I need to run my formulas on. I decided to delete the redirect plugin, but now it just keeps redirecting anyway!

I'm so lost right now... :(
 
ok just updating this thread on where i am now. i deleted the form to get rid of that redirect, then i added it again, added the same group of elements, then added the php script file that i would like to load (for now it just echo's "hello world"), but when i click submit, i get taken back to the form with a message saying Record Added (record in database is set to "no").

what would be great is if i can get the form displayed again with the results of the php script below it.
 
I assume you've seen the wiki for the Form PHP plugin?
http://fabrikar.com/forums/index.php?wiki/php-form-plugin/

Looks like it can do what you ask to put a message in the form with the proper setup. I haven't tried it myself that way.

I use this plugin primarily onAfterProcess. Echo on its own won't work as the form is automatically redirected after processing to the previous page. Your message gets echo'd but then the redirect occurs. For debugging I use jDump or just put

PHP:
echo '<pre>';print_r($my_variable);echo '</pre>';exit;

into the code. The white page probably means there was an error in your code that stopped the PHP processing.
 
ah ok cool. thanks so much for getting back to me.

i changed the "process script" to onAfterProcess and this is what I put in the my script for now just to see if it's actually working:


PHP:
<?php
 
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die();
 
$formModel->formData // for onAfterProcess - use short element names: 'element' - no table name
 
// echo "<pre>";print_r($formModel->_formData);exit;
echo '<pre>';print_r($formModel);echo '</pre>';exit;
?>


I still get a blank page though :/
 
oops, I left out the semi-colon after formData.

I get a page with results right, but it looks like thousands of lines of arrays with all kinds of info on my database, and forms, etc. it's just in plain text too, not displayed in the joomla template/contentarea.
 
wow, i am rusty. ok i only want the form elements displayed in the top code obviously.

so is this the right way to do it: (the commented out bits are just different things i've been copying and pasting, just want to get this baby working now.)


PHP:
<?php
 
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die();
 
$form = $formModel->formData['___nr_child_dependents']['___nr_adult_dependents']['___gross_salary']; // for onAfterProcess - use short element names: 'element' - no table name
 
// echo "<pre>";print_r($formModel->_formData);exit;
echo '<pre>';print_r($form);echo '</pre>';exit;
?>

If above is correct, I still get a blank page. When i look at the source for the page, I get the <pre></pre> tags... at least.
How do I get the form results to display on a regular Joomla page too? and hopefully with the form displayed above it again? If I can't have the form displayed again, then at least a back button or something to get back to the form...
 
Yes, that is correct.
PHP:
echo '<pre>';print_r($my_variable);echo '</pre>';exit;
will echo out that infomation and exit the PHP which will stop the rest of the page processing as well.

I'm not sure if this plugin will do as you ask right now. Looking at the wiki, it looks like you can set Process Script to "getBottomContent"

It says that will insert anything that has been return'ed from your PHP script into the bottom of the form.

So try that with this code.

Code:
return "Hello World";

Although it isn't clear when that is run. Perhaps it only runs that code on load instead of on submit
 
If all you are trying to do right now is work out your code, you could use the Calc element to display information in your form. You can set it to AJAX mode so you don't need to submit form information just for troubleshooting.

I have done that in the past. Once I get the code worked out, then it can be transferred and adapted to the PHP Plugin.
 
Thanks again for your assistance rackem!

the problem is, with that piece of code, I don't get any results returned. I literally just get the "pre" tags in the source of the page.

Will removing "exit" from that code let the page displayed properly?

when I use getBottomContent, then that "hello world" text prints below the form before it is even submitted...

I am feeling a lot more positive now about this plugin, I think you are steering me in the right direction. with my "rusty" knowledge I think I'll be able to get the results I need. my php script will obviously consist of a table displaying the results from all the calculations and formulas I need to run (i hope i can get the info from the database too in a fairly simple manner too!)

thanks for the tip on the calc element, i have to say though, i looked for that option under elements and i cannot find it anywhere? how do I get to the calc element? it's not in the dropdown?

i think there's quite a bit of a time difference between us so i might miss your posts a bit later.
 
Will removing "exit" from that code let the page displayed properly?
No, I don't think so. With the onAfterProcess or similar setting, the code runs when the form is submitted. The page is then redirected automatically to the previous page. So anything you might echo is never actually displayed. The exit stops everything which is why the page has no formatting.

the problem is, with that piece of code, I don't get any results returned. I literally just get the "pre" tags in the source of the page.
I remember getting stuck trying to use the $formModel->formData approach described in the tooltips and wiki. However, the placeholders functionality was added recently which makes things much IMO.
http://fabrikar.com/forums/index.php?wiki/placeholders/


Just to note, if you are typing in the code box, you don't need
Code:
<?php
defined('_JEXEC') or die();
?>
as Fabrik includes it automatically. It is needed if you are using the script file.

when I use getBottomContent, then that "hello world" text prints below the form before it is even submitted...
Ah, bummer. Well then that approach won't be helpful here.



thanks for the tip on the calc element, i have to say though, i looked for that option under elements and i cannot find it anywhere? how do I get to the calc element? it's not in the dropdown?
Follow the section installing and enabling plugins
http://fabrikar.com/forums/index.php?wiki/installation-instructions/


I am feeling a lot more positive now about this plugin, I think you are steering me in the right direction. with my "rusty" knowledge I think I'll be able to get the results I need.
Glad to hear the info helps!


i hope i can get the info from the database too in a fairly simple manner too!
Here is some info for retrieving info from the db
http://fabrikar.com/forums/index.php?wiki/common-php-tasks/

my php script will obviously consist of a table displaying the results from all the calculations and formulas I need to run
Not sure what you mean by this.
 
ok i'm still stuck with this thing man. i've tried using placeholders (updated from github this afternoon).
this is my code:

PHP:
$childdependents = '{___nr_child_dependents_raw}';
$adultdependents = '{___nr_adult_dependents_raw}';
$gross_salary = '{___gross_salary_raw}';
 
echo $childdependents . '<br />';
echo $adultdependents . '<br />';
echo $gross_salary;
exit;

when I submit my form, I get the strings printed out as in, $childdependents, instead of the value that was entered in that field in the form.
also, if I remove the exit; part, then the form redirects to my home page after I submit it. if I leave the exit part, then I end up on a page without any formatting, how do I get it to display like the rest of the pages on my site?
I also tried using "return" instead of "echo" and that also redirects to my home page.
I also tried without the '_raw' part and get the same thing.

I'm using a script file by the way, hence the reason I have the php tags and the <?php defined('_JEXEC') or die(); ?> part.

wow, this is so complicated!! :p
i really hope i am going in the right direction here and not wasting my time one something that is not even the right way to do it.
 
As noted in the tooltips and wiki, placeholders only work in the plugin code. They won't work in the script file. But the plugin code is run before the script is called so you can pass in that info. So if you put

PHP:
$childdependents = '{___nr_child_dependents_raw}';
$adultdependents = '{___nr_adult_dependents_raw}';
$gross_salary = '{___gross_salary_raw}';

in the plugin PHP code area and then

PHP:
echo $childdependents . '<br />';
echo $adultdependents . '<br />';
echo $gross_salary;
exit;

in your script, the variable data *should* be as you expect.

what would be great is if i can get the form displayed again with the results of the php script below it.
Just to reiterate, while there is probably a way to do this with the PHP Form plugin, I'm not sure what it would be. So yes, if that is the route you want to take, then you may want to pause until someone can answer that question.

The Calc element WILL display the results in your form. With the Ajax mode on, it will recalculate whenever any of the input elements are changed.

Which approach is the best way to proceed for your situation sounds to me like your biggest unknown right now. Sorry, I don't have more advice on that.
 
ah man, i don't know what to do anymore. i actually think this thing might be broken.

I have this in the plugin code area:
PHP:
$childdependents = '{___nr_child_dependents_raw}';
$adultdependents = '{___nr_adult_dependents_raw}';
$gross_salary = '{___gross_salary_raw}';

i have this in my script file:

PHP:
<?php
 
echo $childdependents . '<br />';
echo $adultdependents . '<br />';
echo $gross_salary;
exit;
 
?>

And my result is a blank page. If I look at the source of the blank page, the <br /> tags are there but nothing else.

I also still don't understand how to get my result printed out in the site template and not just a blank page.

is there no other tool available for joomla that can do this stuff?

FYI, the tool tip at the place where you insert the plugin code says that the script file will be run first before the code in the plugin code area. so how can it even get those variable to the script file if it only runs afterwards?
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top