Hide element in pdf

Status
Not open for further replies.
if I use
$element = $this->groups['group1']->elements['element1_raw'];
<?php echo $element->label_raw;?> --> BLANK
<?php echo $element->element;?> --> BLANK

I am frustrated
 
Did you var_dump($element) and/or $this->groups['group1'] and/or $this->groups and/or ... to see what you really have in your data?

I assume group1, element1 are not your real group/element names.
 
<?php var_dump($this->groups['manutenzioni macchina']->elements['intervento1']); ?>

return

object(stdClass)#1491 (24) { ["startRow"]=> int(1) ["endRow"]=> int(0) ["error"]=> string(0) "" ["plugin"]=> string(8) "dropdown" ["hidden"]=> bool(false) ["id"]=> string(50) "piani_di_manutenzione_54_repeat___intervento1_ro_0" ["className"]=> string(56) "fb_el_piani_di_manutenzione_54_repeat___intervento1_ro_0" ["containerClass"]=> string(159) "fabrikElementContainer plg-dropdown fb_el_piani_di_manutenzione_54_repeat___intervento1_ro_0 fabrikRepeatGroup___piani_di_manutenzione_54_repeat___intervento1 " ["element"]=> string(184) "
Controllo corretto funzionamento delle alette di distribuzione dell’aria ove presenti
" ["label_raw"]=> string(10) "Intervento" ["label"]=> string(129) "Intervento" ["errorTag"]=> string(48) " " ["element_ro"]=> string(87) "Controllo corretto funzionamento delle alette di distribuzione dell’aria ove presenti" ["value"]=> array(1) { [0]=> string(1) "9" } ["element_raw"]=> array(1) { [0]=> string(1) "9" } ["dataEmpty"]=> bool(false) ["labels"]=> int(1) ["dlabels"]=> int(1) ["tipAbove"]=> string(0) "" ["tipBelow"]=> string(0) "" ["tipSide"]=> string(0) "" ["offset"]=> int(0) ["column"]=> string(42) " style="float:left;width:10%;clear:both;" " ["span"]=> string(6) " span2" }
 
Try this one:

Code:
$element_data = $this->groups['group1']->elements['intervento1']->element_raw;
$element = $this->groups['group1']->elements['intervento1'];

if ($element_data == 9) { ?>
   <div class="control-group <?php echo $element->containerClass; ?>">
           <div class="fabrikLabel myLabel">
                   <?php echo $element->label_raw; ?>
             </div>

              <div class="fabrikElement myElement">
                        <?php echo $element->element; ?>
              </div>
      </div>
<?php }

or bit shorter (add css for new classes in custom_css.php file)

Code:
$element_data = $this->groups['group1']->elements['intervento1']->element_raw;
                              
if ($element_data == 9) { ?>
    <div class="myRow">
             <div class="myLabel">Intervento</div>
             <div class="myData"><?php echo $element_data; ?></div>
       </div>
<?php }
?>
 
$element_data1 = $this->groups['manutenzioni macchina']->elements['intervento1']->element_raw;
$element_data2 = $this->groups['manutenzioni macchina']->elements['intervento2']->element_raw;
$element_data3 = $this->groups['manutenzioni macchina']->elements['intervento3']->element_raw;


$element1 = $this->groups['manutenzioni macchina']->elements['intervento1'];
$element2 = $this->groups['manutenzioni macchina']->elements['intervento2'];
$element3 = $this->groups['manutenzioni macchina']->elements['intervento3'];

<div style="<?php if ($element_data1 == 0) { echo "display:none;"; } else { echo "ciao"; }?>">
<div class="fabrikLabel myLabel">
<?php echo $element1->label_raw;?>
</div>
<div class="fabrikElement myElement">
<?php echo $element1->element;?>
</div>
</div>
<div style="<?php if ($element_data2 == 0) { echo "display:none;"; } else { echo "ciao"; }?>">
<div class="fabrikLabel myLabel">
<?php echo $element2->label_raw;?>
</div>
<div class="fabrikElement myElement">
<?php echo $element2->element;?>
</div>
</div>
<div style="<?php if ($element_data3 == 0) { echo "display:none;"; } else { echo "ciao"; }?>">
<div class="fabrikLabel myLabel">
<?php echo $element3->label_raw;?>
</div>
<div class="fabrikElement myElement">
<?php echo $element3->element;?>
</div>
</div>

<?php var_dump($element_data1); ?>
<br>
<?php var_dump($element_data2); ?>
<br>
<?php var_dump($element_data3); ?>


OUTPUT


Intervento
Controllo assorbimento motore elettrico e verifica delle connessioni
Intervento
Controllo carica antigelo
Intervento
-
array(1) { [0]=> string(1) "2" }
array(1) { [0]=> string(1) "5" }
array(1) { [0]=> string(1) "0" }

so, the last should be hidden but it doesn't work
in the source, I see style="ciao" for every DIV
 
array(1) { [0]=> string(1) "0"
As you can see (that's what var_dump is for) these are arrays containing strings.

You must use the data you get to build your condition
if ($element_data3[0] == '0')
 
This is not Fabrik but CSS, something like
#groupX {page-break-after:always}

Inspect your pagesource to get the group's HTML id
 
everyting works
can you tell me how can I add a print (pdf) button in the list? now I have to show details to be able to generate the pdf
 

Attachments

  • list.jpg
    list.jpg
    12.9 KB · Views: 104
You can add a hidden element creating the button and the link (and/or with a custom "link to details" in the element's and/or "Icon" settings "List view" settings) and show it in the list view.
Can be display, field, button, calc...
 
I can't understand...
Create an element called "pdf"
-> plug-in "button"
-> "javascript window.location.href = 'URL';"
-> show in list
result - > blank

:-(
 
Thanks for everything!
Now I have my own custom template for pdf output but I don't know how to call an element when the group is a "repeat" group.
So, in which way can I get the element from the second repeat group?
Can you help me Troester?
 
Repeat data are usualy in table. So create table something like below:

PHP:
<table class="myTable">
    <tr>
        <th>Item No. </th>
        <th>Elem1 </th>
        <th>Elem2 </th>
        <th>Elem3 </th>
        <th>Elem4 </th>
    </tr>

    <?php
//seting group and elements
    $this->group = next($this->groups);
    $this->elements = $this->group->elements;

    //echo "<pre>";print_r( $this->groups);exit;  /* check group  */

    $group = $this->group;
    $this->i = 0;

// iretate through  group elements to get data and create rows and cells for each repeat item
    foreach ($group->subgroups as $subgroup) :
        $this->elements = $subgroup;

        $c = $this->i;  /* counter for #items */

        /*      Elements        */
        $elem1  = $this->elements['elem1']->element_raw;
        $elem2  = $this->elements['elem2']->element;
        $elem3  = $this->elements['elem3']->element_ro;
        $elem4  = $this->elements['elem4']->element_ro;

    ?>
        <tr>
            <td style="text-align: center;"><?php echo $c + 1, '.'; ?></td>
            <td style="text-align: left;"><?php echo $elem1; ?> </td>
            <td style="text-align: center;"><?php echo $elem2; ?> </td>
            <td style="text-align: center;"><?php echo $elem3; ?> </td>
            <td style="text-align: center;"><?php echo $elem4; ?> </td>
        </tr>

    <?php
        $this->i++;
    endforeach;
?></table>

This is my way for pdf reports. I'm sure it can be done the other way too.
 
Last edited:
great... but
This is my code:

<div style="<?php if ($element_data1[0] == '0') { echo "display:none;"; } ?>" class="fabrikElement myElement">
<?php echo $intervento1;?>
</div>
there are 18 elements

this hide the DIV but if in the first group have 5 elements shows the second group stop at the 5th line

example:
1st group
element1 = ok
element2 = ok
element3 = ok
element4 = ok
element5 = ok
element6 = 0
result correct (element6 hide)

2nd group
element1 = ok
element2 = ok
element3 = ok
element4 = ok
element5 = ok
element6 = OK
the element6 not show

the same thing happened for the next group

it seems that the cycle stops at the fifth element also for the following groups
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top