Announcement

Collapse
No announcement yet.

Opportunities Template > PDF

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Opportunities Template > PDF

    Hello,

    I created a template for opportunities (from https://url/#Template).
    Now, I want to be able to print an opportunity (or create a PDF) as defined in the template... but I don't know how to do it. There is no button to create a PDF when I list opportunities or edit an opportunity.

    I searched the forum, but I can't find an answer (or I don't understand ).
    Can you help me, please?

    Thank you very much!

  • #2
    Hello
    you need to create this button in the view
    http://forum.espocrm.com/forum/devel...uestion-newbie

    Comment


    • #3
      Good morning. Hello,

      I looked at the link, thank you.

      I understand the principle but I'm looking for the file to modify. Can you tell me what his path is, please?

      Thank you

      Comment


      • #4
        Hello,

        To add my button, I created a file detail.js in the following folder:
        /client/custom/src/views/opportunity/detail.js

        This file contains the following code:

        Code:
        Espo.define('custom:views/opportunity/detail', 'views/detail', function (Dep) {
        
            return Dep.extend({
        
                setup: function () {
                    Dep.prototype.setup.call(this);
                    this.dropdownItemList.push({
                        name: 'printPdf',
                        label: 'Print to PDF'
                    });
        
                    this.dropdownItemList.push({
                        name: 'composeEmail',
                        label: 'Email PDF'
                    });
        
                    if (this.getAcl().checkModel(this.model, 'edit')) {
                        this.dropdownItemList.push({
                            'label': 'Duplicate',
                            'name': 'duplicate'
                        });
                    }
        
                },
        
                actionPrintPdf: function () {
                    this.createView('pdfTemplate', 'Modals.SelectTemplate', {
                        entityType: this.model.name
                    }, function (view) {
                        view.render();
        
                        this.listenToOnce(view, 'select', function (model) {
                            window.open('?entryPoint=pdf&entityType='+this.model.name+'&entityId='+this.model.id+'&templateId=' + model.id, '_blank');
                        }, this);
                    }.bind(this));
                },
        
                actionComposeEmail: function () {
                    this.createView('pdfTemplate', 'views/modals/select-template', {
                        entityType: this.model.name
                    }, function (view) {
                        view.render();
                        this.listenToOnce(view, 'select', function (model) {
                            this.notify('Loading...');
                            this.ajaxPostRequest('Quote/action/getAttributesForEmail', {
                                quoteId: this.model.id,
                                templateId: model.id
                            }).done(function (attributes) {
                                var viewName = this.getMetadata().get('clientDefs.Email.modalViews.compose') || 'views/modals/compose-email';
                                this.createView('composeEmail', viewName, {
                                    attributes: attributes,
                                    keepAttachmentsOnSelectTemplate: true
                                }, function (view) {
                                    view.render();
                                    this.notify(false);
                                }, this);
                            }.bind(this));
                        }, this);
                    }, this);
                }
        
            });
        });
        But the button to export to PDF does not appear.

        I don't know what my error is.

        I consulted all the links given by Tanya , thank you very much, but I'm not good enough to succeed without your help...

        Thank you

        Comment


        • #5
          Hello,
          did you override Opportunity clientDefs?
          Did you rebuild Espo? (Administration > Rebuild)
          Did you refresh the page?

          Comment


          • PGI
            PGI commented
            Editing a comment
            It worked! Thank you
        Working...
        X