Help understanding calc plugin

aplima

New Member
Hello.

I'm trying to understand the use of calc plugin, hope somenone can help me :)

I have two groups of elements.
Use one form "Insert Client" with some data:

Client Number
Name
Address
Phonenumber
(...)
Accumulated Purchase Value

Second Form is:

"Register Client Purchase"
Client Number (selected with databasejoin plugin)
Invoice Number
Purchase Value

My need:
Everytime some Purchase Value is added using "Register Client Purchase", I would like it accumulate on
Accumulated Purchase Value.

Any help is much appreciated.
Thank you
 
Thank you Troester

I tried that. On the list, but it is not working :)
On bottom of that list I can see all values inserted on Purchase Value (sorted from min to max:D) but total is = 0. Tried to tick the option: sum collumn, didn't work either...

And I can't find what I'm doing wrong :)
I'll try and dig in a bit on php, to see if I can make it work...
 
Although it's somewhat unclear; I'm assuming that "accumulated purchase value" on the "insert client" form is the calc element you're trying to figure out. Although I can say from experience that using the wiki's and searching the forum in order to figure out what to do will reap you huge rewards over the long haul; if you could share what you are using in the "calculation", I'm happy to try to give feedback/help.
 
Ok I'll try with something simple to see if I can understand this.
Have forms like this:
Form1:
Insert Client

With elements:
insertclient_clientnumber as field
insertclient_clientname as field
insertclient_total as calc (I'm not sure if I need this here)

Form2:
Client Purchase

With elements:
purchase_invoicenumber as field
purchase_client as dbjoin (dropdown from insertclient_clientnumber)
purchase_ammount as field

So, every time I insert some ammount using Form 2 I would like that insertclient_total would add it every time.
Or, in a list that would sum values to insertclient_total split by purchase_client

Hope I can make you understand my needs, and thank you for your help :)
 
Ok, I found what I was doing wrong with calculations on list settings.
I have to go to purchase_ammount and in list settings I can sum splitted by purchase_client.
That will return something like this:
Client Purchase Total
00001 12
00002 13
00001 14

Sum
00001: 26
00002: 13
Total: 39

But this is only a view. What I would like is that with the insertion the new purchase would be stored in database on a table whatever_total :(
 
I'm sure there may be a better way to put this; but in broad strokes, if you want it saved to the DB, you'll need it to be "processed" and placed there. Opening a Form and Saving it is the most straight-forward way to do that (but not the only way). If the "insertclient_total" calc element was part of Form 2, then each time Form 2 was used to add a new transaction, it could also update the accumulated total (what is already in the DB plus the new transaction for the client), saving it would give you a new accumulated total.
 
I understand the concept/idea :)
I guess I need to dig into some programming :)
To apply it. I want that A = A + B
Where A is the stored value on the table :)
Need to search how do it. I thought calculation on Fabrik would do this kind of things :)
 
An element, utilizing the calc plugin' will do what you have layed out; and honestly lot's, lot's more. That being said, you'll need to read about the plugin and look at the examples provided on the wiki in order to "tell it" what you are wanting it to calculate. You should also be able to find examples similar to your question by searching for "calc" on the forum.

If you are unable to determine the "right" calculation, if you'll post a screen capture of what you're using in the "Calculation" box on the calc element, that may help in pointing you in a better direction.
 
Hello again.
I'm pretty close to complete my task. Followed your wise advice and used php code to do my calc.
The best way to show you how it is would probably provide access to it...
I have it now doing the sum as I wanted. Next step is to subtract when a client uses the accumulated discount value...
I'm stuck again :)
So if you willing to give it a look, let me know how to provide access to it.

And thank you all for pointing me the right way to do this so far.
 
I'm glad you had success on your calculation. Although there may be details about your follow up questions that would make the resolution more complex than I'm thinking, it should be fairly straight-forward. As a start point, and in order for this thread to act as a future resource for someone else, could you post the php you used in the "calculation box" of the calc element.

Is the "accumulated discount value" an element in one of the tables you communicated in your first post? Is it a static value or is it likewise a calculation of some sort?
 
I'm suggesting for the benefit of the community as a whole; you probably want to post the php you are using it the Calc Element that gave you the result you were looking for.
 
$valores = '{pontos___numcliente}';
$db =& JFactory::getDBO();
$db->setQuery("SELECT SUM(`valorcompra`) FROM `pontos` WHERE (`numcliente`) = '{clientes___numcliente}'");
$total = $db->loadResult();
$disponivel = ($total*5)/100;
return $disponivel;

This is what I use for calculation on my calc element.
I have 2 calc elements. One SUMS valorcompra into clientes___comprasvaloracumulado
The other one, this one I posted, is a recalc returning 5% of the amount accumulated.
So clients that buy things, will accumulate 5% of their spending for future buyings.

What I would need now is to apply discount. Total or parcial. And update client balance.
Lets say someone bought 100?, then would have 5? to discount.
Buys something worth 2?.
I would discount 2? on clientes___valordisponivel
But as this element is a calc of the sum of pontos___valorcompra of that client, I'm afraid that I would need another element to do it.

Another thing is:
When I save a new purchase from client nr 00001 I was also trying to show on form the name of client.
Client nr is a dbjoin element (autocomplete) and it works. But I would like to show clientes___clientname where clientes___numerocliente when it is selected in that autocomplete element.
But I'm still looking, searching, reading...
And until I figure out what I'm doing wrong with updating Fabrik I will not have it complete without validations...
I have a lot to read :)
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top