Removing phone item from the invoice

I already remove the mobile phone number from the invoice with the following CSS code in the file path invoiceplane/assets/core/css/custom-pdf.css. Invoiceplane version is 1.6.1.

#client-phone {
  display: none;
}

But this somehow does not remove the Phone number in the invoice. Unfortunately, I was unable to locate the corresponding CSS class or ID of it.

Reference Pictures:

Web UI:

Invoice PDF export:

1 Like

modules/clients/views/form.php:

<div class="form-group">
                            <label for="client_phone"><?php _trans('phone_number'); ?></label>

                            <div class="controls">
                                <input type="text" name="client_phone" id="client_phone" class="form-control"
                                       value="<?php echo $this->mdl_clients->form_value('client_phone', true); ?>">
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="client_fax"><?php _trans('fax_number'); ?></label>

                            <div class="controls">
                                <input type="text" name="client_fax" id="client_fax" class="form-control"
                                       value="<?php echo $this->mdl_clients->form_value('client_fax', true); ?>">
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="client_mobile"><?php _trans('mobile_number'); ?></label>

                            <div class="controls">
                                <input type="text" name="client_mobile" id="client_mobile" class="form-control"
                                       value="<?php echo $this->mdl_clients->form_value('client_mobile', true); ?>">
                            </div>
                        </div>

(I included client_fax as well, to be complete)
Did you include the .css file somewhere?
I don’t think the field or css id is called “Phone”

1 Like

Hello @UnderDog :wave:,

Thank you for your detailed post.

Unfortunately, I do not get exactly what I need to do. :thinking:

From the PHP code you send, I saw the CSS ID’s client_phone and client_mobile which is then “converted” to CSS ID client-phone and client-mobile.

So far, my understanding of the code base. Keep in mind, this is based only on assumptions and experiences with the trial and error method. :man_shrugging:

I did not include the custom-pdf.css file in any special way. For my understanding, this file overrides the default values, so we can customize the invoice as we like. At least it works on my side like this, and it’s also mentioned in the header of the file.

Header of custom-pdf.css:

/* =============================================================================
   InvoicePlane
   Custom Stylesheet

   All changes made in this file will override the default styles in PDFs.
   ========================================================================== */

I don’t really know for sure what the CSS ID is for the phone numbers, I tried different names as mentioned above.

In general, for my research and CSS rules in my custom-pdf.css file, I used the file InvoicePlane.php in /usr/share/nginx/invoiceplane/application/views/invoice_templates/pdf. I think I stumbled across that file when I was searching through the forum for other situations from other users.

BTW:
In the mentioned file InvoicePlane.php there is another CSS ID which his called user_phone but this also didn’t change the PDF output.

Also, I saw that my client-phone rule does not have any effect on my PDF output. So either I have set this in another file which I don’t believe or the mobile number of a customer does not get used for the PDF export. :thinking:

1 Like

I might have misunderstood you.
This is the piece of code about client_phone:

        if ($invoice->client_phone) {
            echo '<div>' . trans('phone_abbr') . ': ' . htmlsc($invoice->client_phone) . '</div>';
        } ?>

It doesn’t have a CSS Id, so i don’t think you can hide it at the moment.
How about if you add the client_phone as CSS Id in that InvoicePlane.php template and then hide it using CSS?

If that works you can PR it, if you want

1 Like

I misinterpreted the code. My CSS and HTML are not the best, not to speak about PHP. :face_with_spiral_eyes:

But with trial and error, we can learn again from time to time, right? :wink:

I would test your Idea, probably over the weekend. Will give the feedback here. For the possible PR I would write you on Discord if that’s okay. :blush:

1 Like

Yes, perfect.

1 Like

I was able to test your suggestion and, as anticipated, it worked without any problems. Thank you (again)! :blush::handshake:

The updated code in the file InvoicePlane.php in the directory application/views/invoice_templates/pdf looks like the following now:

<div id="client">
(...)
        if ($invoice->client_phone) {
            echo '<div id="client-phone">' . trans('phone_abbr') . ': ' . htmlsc($invoice->client_phone) . '</div>';
        } ?>
(...)
 </div>

Note just for documentation:
Keep in mind that the code snippet will be in the div section client not company which is in the same file.

Then I added the CSS ID client-phone to the custom-pdf.css file, which resides in the assets/core/css folder like the following:

#client-phone {
  display: none;
}

Now, the Phone number of the client does not appear on the exported invoice PDF file.

Reference picture:

Note:
I have simply written this here as documentation so that others can better understand my question and our change to solve this issue.

1 Like