• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

calcoli su tabella collegata

meclus

New Member
Hello,
I try to translate with translate; With Fabrik Vers 3.9.2, I would like to create a billing form, besides the header the body of the invoice has repeated fields(Img001)Img001.png
---
I inserted these in the invoice table but then I set in a group (002_RigheFatt) and I said that it must be repeated. and that's a beautiful feature.
Img002.png
---
in each row there are the calculations q.ta * Row, but I can't make the sum of the different rows. the fields are as follows (Img004)
Img004.png
---
after the body group, in which the lines are repeated, I inserted the totals cell, and I made a calculation which, however, does not work, (Img005)
Img005.png
---
I would be very grateful if you could help me. Early thanks not only for the help but also for any suggestions. Regards Gaetano
 
Last edited:
Hi, Italian is a beautiful language, but in this forum please post in English only. Otherwise it will be difficult for you to get the support you need.
 
Good morning,
I tried to do the translation with google traslator, unfortunately the images I have in Italian, I hope you can help me, and thank you in advance.
Best regards
Gaetano
 
Thanks, seems clear now. This can be done with Javascript in "form_XX.js" file. But first you could try a new "total" element instead of your "calc" element. Haven't tested it myself , but having a quick look at the description, it might do the trick.
 
Thanks, seems clear now. This can be done with Javascript in "form_XX.js" file. But first you could try a new "total" element instead of your "calc" element. Haven't tested it myself , but having a quick look at the description, it might do the trick.

Thanks for the tip, I had tried to sum the field in the table element window, but it didn't work, it doesn't produce anything.
 

Attachments

  • Schermata 2020-07-31 alle 08.09.23.png
    Schermata 2020-07-31 alle 08.09.23.png
    92.4 KB · Views: 137
OK, your field elements probably should need to trigger the change event for the total element, otherwise it's not updating on the fly.

For the form_XX,js method, here is one useful thread:
http://fabrikar.com/forums/index.ph...ation-from-subtotals-on-repeated-group.40319/

Also read the wiki article, if you already haven't:
http://fabrikar.com/forums/index.php?wiki/form-javascript-objects/

And here is a sample code for calculating the total some of repeat elements:

Code:
requirejs(['fab/fabrik'], function() {
    function total_revenue() {
// use form_X where X is your numeric form ID
        var form = Fabrik.getBlock('form_61');

// replace 177 with your numeric group ID for the repat group
        var repeats = form.repeatGroupMarkers[177]
        var revenuesTotal = 0;

        for (c = 0; c < repeats; c++) {
            // replace foo_repeat___whatever_ with the relevant element names in the repeat group, but keep the appended _
            //get repetable object
            var elObjectName = '1_et_projects_177_repeat___revenue_amount_' + c;
            //get repetable object value
            var elObjectVal = form.formElements.get(elObjectName).getValue();


            if (elObjectVal != '') {
                var elRevenueVal = elObjectVal;
                revenuesTotal += elRevenueVal.toFloat();
            }
        }

    // replace foo___total_price with the element name
        form.formElements.get('1_et_projects___revenue_sum').update(revenuesTotal.toString());
    }
    //function total end
  
  
  
    function total_expenses() {
// use form_X where X is your numeric form ID
        var form = Fabrik.getBlock('form_61');

// replace 17 with your numeric group ID for the repat group
        var repeats = form.repeatGroupMarkers[178]
        var expensesTotal = 0;

        for (c = 0; c < repeats; c++) {
            // replace foo_repeat___whatever_ with the relevant element names in the repeat group, but keep the appended _
            //get repetable object
            var elObjectName = '1_et_projects_178_repeat___expense_amount_' + c;
            //get repetable object value
            var elObjectVal = form.formElements.get(elObjectName).getValue();


            if (elObjectVal != '') {
                var elExpensesVal = elObjectVal;
                expensesTotal += elExpensesVal.toFloat();
            }
        }

    // replace foo___total_price with the element name
        form.formElements.get('1_et_projects___expenses_amount').update(expensesTotal.toString());
    }
    //function total end
  
      
    function total_overall() {
// use form_X where X is your numeric form ID
        var form = Fabrik.getBlock('form_61');


            // replace foo_repeat___whatever_ with the relevant element names in the repeat group, but keep the appended _
            //get repetable object
            var elObjectName1 = '1_et_projects___revenue_sum';
            var elObjectName2 = '1_et_projects___expenses_amount';
            //get repetable object value
            var elObjectVal1 = form.formElements.get(elObjectName1).getValue();
            var elObjectVal2 = form.formElements.get(elObjectName2).getValue();

            if (elObjectVal1 != '') {
 
               OverallRevenue = elObjectVal1 - elObjectVal2;
            }
 
    // replace foo___total_price with the element name
        form.formElements.get('1_et_projects___total_amount').update(OverallRevenue.toString()+".-");
    }
    //function total overall end
  


    // Add events when adding/deleting groups
    Fabrik.addEvent('fabrik.form.group.duplicate.end', function(form, event) {
        total_revenue();
        total_expenses();
        total_overall()
    });

    Fabrik.addEvent('fabrik.form.group.delete.end', function(form, event) {
       // total_revenue();
    });

    document.addEvent('blur:relay(input[name^=1_et_projects_177_repeat___revenue_amount])', function() {
        total_revenue();
        total_overall()
    })
       document.addEvent('blur:relay(input[name^=1_et_projects_178_repeat___expense_amount])', function() {
        total_expenses();
        total_overall()
    })
  
})

I hope this gets you started!
 
Many thanks, I hope I can understand where I need to insert and customize this block of code. I tell you as soon as I do .. thanks again.
Regards
Gaetano
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top