Show discount column in quotation template when discount column is filled, otherwise, not shown in template

I’m creating a template new quotation template. Is there a way to show discount column, only when the field is populated? Otherwise, it is not shown in the template output?

I have an similar topic in the german forum.

I would be very happy about a solution.

Yes, same here. Invisible. People tend to ask why there’s no discount.

Absolutely. That’s exactly my opinion.

Hope we get help from the professionals.

Best regards

1 Like

Hope you are fine.
Have you already found a solution for this topic?
Very best regards

We haven’t. No one replied.

I got a little bit further, with this topic.

But I miss the percent symbols, when a discount is entered.
Important is, no percent symbols should be displayed, if no discount is entered.

Here is the file I’m working on:
suitecrm \ htdocs \ modules \ AOS_PDF_Templates \ templateParser.php

Blockquote

    foreach ($repl_arr as $name => $value) {
        if (strpos($name, 'product_discount') !== false || strpos($name, 'quotes_discount') !== false) {
            if ($value !== '0,00') {
                if ($isValidator->isPercentageField($repl_arr['aos_products_quotes_discount'])) {
                    $sep = get_number_separators();
                    $value = rtrim(
                        rtrim(format_number($value), ''),
                        $sep[1]
                    ) . $app_strings['LBL_PERCENTAGE_SYMBOL'];
                }
            } 
                            
            else {
                $value = '';
            }
        }

        if ($name === 'aos_products_product_image' && !empty($value)) {
            $value = '<img src="' . $value . '" class="img-responsive"/>';
        }

        if ($name === 'aos_products_quotes_product_qty') {
            $sep = get_number_separators();
            $value = rtrim(rtrim(format_number($value), '0'), $sep[1]);
        }

        if ($isValidator->isPercentageField($name)) {
            $sep = get_number_separators();
            $value = rtrim(rtrim(format_number($value), ''), $sep[1]) . $app_strings['LBL_PERCENTAGE_SYMBOL'];
        }

        if (
            $focus->field_defs[$name]['dbType'] == 'datetime' &&
            (strpos($name, 'date') > 0 || strpos($name, 'expiration') > 0)
        ) {
            if ($value != '') {
                $dt = explode(' ', $value);
                $value = $dt[0];
                if (isset($dt[1]) && $dt[1] != '') {
                    if (strpos($dt[1], 'am') > 0 || strpos($dt[1], 'pm') > 0) {
                        $value = $dt[0] . ' ' . $dt[1];
                    }
                }
            }
        }

        if ($value != '' && is_string($value)) {
            $string = str_replace("\$$name", $value, $string);
        } else {
            if (strpos($name, 'address') > 0) {
                $string = str_replace("\$$name<br />", '', $string);
                $string = str_replace("\$$name <br />", '', $string);
                $string = str_replace("\$$name", '', $string);
            } else {
                $string = str_replace("\$$name", '&nbsp;', $string);
            }
        }
    }

Blockquote

Hope someone can help.
Many thanks in forward and best wishes.

I think an “if-then” command is still missing, something like this:

if($name == "aos_products_quotes_product_discount" && $value == "0.00"){
             then hide the % symbol ;
            }

But how can I integrated this, with the right program code here?:

       foreach ($repl_arr as $name => $value) {
            if (strpos($name, 'product_discount') !== false || strpos($name, 'quotes_discount') !== false) {
                if ($value !== '0,00') {
                    if ($isValidator->isPercentageField($repl_arr['aos_products_quotes_discount'])) {
                        $sep = get_number_separators();
                        $value = rtrim(
                            rtrim(format_number($value), ''),
                            $sep[1]
                        ) . $app_strings['LBL_PERCENTAGE_SYMBOL'];
                    }
                } 
                else {
                    $value = '';
                }
            }

“aos_products_quotes_discount” is the % symbol

Can someone help, please.

Best regards