Please help to improve

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Frank
    Member
    • Aug 2015
    • 64

    Please help to improve

    Hello to everyone!

    I just start to use this nice crm. System is really good, but I want to improve some mechanisms.
    For example we have a standard document section, that has opportunity to download the document from crm.

    But i want have a possibility to read pdf without downloading - just from the system page.

    to do this i need to add php code something like this:

    function pdf_viewer($attr, $url) { return '<iframe src="http://docs.google.com/viewer?url=' . $url . '&embedded=true" style="width: 600px; height: 500px;" frameborder="0">no frame eror</iframe>'; } add_shortcode('pdfview', 'pdf_viewer');
    and write a shortcode with link like this:

    [pdfview]http://mywww.url/link/to/uploads/documents/document.pdf[/pdfview] Could you help me explain, how can i do this? Thanks!
  • yuri
    Member
    • Mar 2014
    • 8467

    #2
    Hi

    You can create custom field in entityDefs with custom view class

    Document's entityDefs

    PHP Code:
    {
       "fields": {
          "fields": {
             "pdf": {
                 "type": "base",
                  "view": "Custom:Document.Fields.Pdf"  
             }
         }
       }
    } 
    
    create client/custom/src/views/document/fields/pdf.js

    PHP Code:
    Espo.define('custom:views/document/fields/pdf', 'views/fields/base', function (Dep) {
    
     return Dep.extend({
    
        detailTemplate: 'custom:document/fields/pdf/detail',
      
        readOnly: true,
    
        getValueForDisplay: function () {
           return "your IFRAME IS HERE";
        }
    
      });    
        
    }); 
    
    create client/custom/res/templates/document/fields/pdf/detail.tpl

    with only single line:
    {{{value}}}
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • Frank
      Member
      • Aug 2015
      • 64

      #3
      thank you it works, Yuriy - you are the best!
      one more little question: i have 1 attached pdf file to any contact in crm, for viewing this file I need a get link to it.
      How can i write dynamic link in my getValueForDisplay: function () like this

      getValueForDisplay: function () {
      return
      "[pdfview]http://mywww.url/link/to/uploads/documents/document.pdf[/pdfview]";
      }

      like


      getValueForDisplay: function () {
      return
      "[pdfview]dynamic-link-to-pdf-file-of-this-contact[/pdfview]";
      }

      Thank you!

      Comment

      • yuri
        Member
        • Mar 2014
        • 8467

        #4
        You can display anything you like.

        var html = 'something';
        html += 'something';
        html += this.model.get('someField');
        html = '<a href="hello">' + html + '</a>';
        return html;
        If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

        Comment

        • Frank
          Member
          • Aug 2015
          • 64

          #5
          All fields are working, but the one - is not.
          My pdf files attached to contacts such a field type file.

          And i cant access to its name or url in any way...

          this.model.get('name'); -works fine
          this.model.get('description'); -works fine

          this.model.get('file'); -doesnt works

          please help!

          Comment

          • yuri
            Member
            • Mar 2014
            • 8467

            #6
            If File is standard espocrm File-type there are attributes fieldId and fieldName
            If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

            Comment

            • Frank
              Member
              • Aug 2015
              • 64

              #7
              Thank you it works!

              Comment

              Working...