[SOLUTION] Buttom Element in Repeat Group | PHP | Get the id of repeat group

marcq

Member
Hi,

Can't find a solution here.

I have added a button element into one of my repeated group tab.

This button triggers a javascript function which is generating a PDF output. Output should fit to the content of the repeat group row.

In my PDF template I should able to get the id of the concerned repeat group row.

By using
Code:
$memberid = $this->rowid;
I get the parent_id value of the repeat group which contains the form ID which is a good thing, but I'm unable to get the id of the repeat group
Code:
gprh_fabrik_user_registration_333_repeat___id
which I need into a query of the pdf template.

Would appreciate your support, cheers, marc
 
Last edited:
In your button JS you'll need to figure out the repeat count and pass that, something like ...

Code:
var repeatNum = this.getRepeatNum();
var url = '....&repeatNum=' + repeat Num;

... and get the repeatNum query string value on the server side.

-- hugh
 
Hi Hugh,

Thanks a lot, it is working fine ! Thanks also to the Active Member startpoint which lead me in the right direction.

Solution is :

JavaScript:
function printInvoiceco(el) {

  var repeat = el.getRepeatNum();

  // GET FORM REFERENCE
  var form = Fabrik.getBlock('form_59');

  // GET VAR
  var form_nr = 59;
  var idRepeat = el.form.formElements.get('gprh_fabrik_user_registration_333_repeat___id_' + repeat).getValue();
  var memberid = el.form.formElements.get('gprh_fabrik_user_registration_333_repeat___parent_id_' + repeat).getValue();

  // GENERATE THE INVOICE
  window.open('http://www.webamazingapps.com/projects/gprh.ch/index.php/gestion-membres-2/gestion-membres/membres-actifs-2/membres-actifs-attente-paiement/details/' + form_nr + '/' + memberid  + '?format=pdf&layout=bootstrap_printinvoice_co&repeatNum=' + idRepeat);
  };

I get the value into my PDF template with the following code :

PHP:
<? php $repeatNum = $_GET['repeatNum']; ?>

And in my query :

PHP:
            <?php $repeatNum = $_GET['repeatNum']; /* echo $repeatNum; echo $memberid; */ ?>
            <?php
                $db = JFactory::getDbo();
                $query = $db->getQuery(true);
                $query
                    ->select (array('gprh_fabrik_user_registration.id', 'gprh_fabrik_user_registration_333_repeat.id', 'gprh_fabrik_user_registration_333_repeat.annee_cotisation', 'gprh_fabrik_user_membership.nom_cotisation', 'gprh_fabrik_user_membership.montant_cotisation'))
                    ->from('gprh_fabrik_user_registration')
                    ->leftJoin('gprh_fabrik_user_registration_333_repeat ON gprh_fabrik_user_registration.id = gprh_fabrik_user_registration_333_repeat.parent_id')
                    ->leftJoin('gprh_fabrik_user_membership ON gprh_fabrik_user_registration_333_repeat.type_cotisation = gprh_fabrik_user_membership.id')
                    ->having('gprh_fabrik_user_registration.id = ' . $db->quote($memberid))
                    ->having('gprh_fabrik_user_registration_333_repeat.id = ' . $db->quote($repeatNum));
                $db->setQuery($query);
                $row = $db->loadObjectList();
                echo "<div class='courrier_div_2'>";
                foreach ($row as $item)
                {
                    echo "$item->nom_cotisation";
                    echo " - ";
                    echo "REF ";
                    echo $this->groups['Membres actifs - En attente paiement finance d'entr?e - Cotisation']->elements['annee_cotisation']->element_ro;
                    echo "-";
                }
                    echo "</div>";
            ?>
 
Best not to use the $_GET array directly, use J!'s input processing ...

$repeatNum = $this->app->input->getInt('repeatNum', 0);

I think at that point we have created $this->app, if not ...

$repeatNum = JFactory::getApplication()->input->getInt('repeatNum', 0);

-- hugh
 
Thanks Hugh

Following works indeed fine :

Code:
<?php $repeatNum = JFactory::getApplication()->input->getInt('repeatNum', 0); ?>

cheers, marc
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top