Results 1 to 4 of 4

Thread: Calling Custom Functionality

  1. #1
    ctigroup is offline Sugar Community Member
    Join Date
    Nov 2007
    Posts
    10

    Default Calling Custom Functionality

    Hi

    This is my first Forum post, so just to set the scene I'm new to developing/customising Sugar, but have a background in developing in PHP, MySQL, Smarty, etc. However my biggest problem is working out how Sugar 'hangs together'

    I've got what is hopefully a simple question. I'm building a customisation to our Quotes module, which in esscence is a new button in the DetailView that when clicked will export the current record to Excel. I have a class that handles all the Excel export stuff (ExcelExport.php) and a script that implements this for the Quotes module (ExportToExcel.php). I've placed these in the ...custom/modules/Quotes folder.

    I've added a button to the ...custom/modules/Quotes/metadata/detailview.php which nicely displays the button (getting the module level labels to display gave me a bit of a headach, but I've sorted that!).

    However, my problem, or more likely it's just a lack of understanding is getting the button to run the script (and maintain security etc)

    I've tried several ways to get the button to work, mainly variations on:

    Code:
    array (
      'customCode' => '<form action="index.php" method="POST" name="XLSExport" id="form">
      <input type="hidden" name="module" value="Quotes">
      <input type="hidden" name="record" value="{$fields.id.value}">
      <input type="hidden" name="action" value="ExportToExcel">
      <input title="{$MOD.LBL_EXCEL_BUTTON_TITLE}" accessKey="{$MOD.LBL_EXCEL_BUTTON_KEY}" class="button" type="submit" name="button" value="{$MOD.LBL_EXCEL_BUTTON_LABEL}">
      </form>'
    which gives me a (badly formated - my code!) XLS with the contaiing the Quotes DetailView page with the data generated by my code kind of stuck in the middle or:

    Code:
    array (
      'customCode' => '<form action="./custom/modules/Quotes/ExportToExcel.php" method="POST" name="XLSExport" id="form">
      <input type="hidden" name="module" value="Quotes">
      <input type="hidden" name="record" value="{$fields.id.value}">
      <input title="{$MOD.LBL_EXCEL_BUTTON_TITLE}" accessKey="{$MOD.LBL_EXCEL_BUTTON_KEY}" class="button" type="submit" name="button" value="{$MOD.LBL_EXCEL_BUTTON_LABEL}">
      </form>'
    which tries to open the script directly and (correctly) tells me it isn't a vaild entry point (standard check in the first line of the script).

    I'm sure that both these approaches are spectatually dumb, but I'm just trying to get a handle on Sugar customisation.

    Any help would be appreciated.

    Thanks

    Steve
    Last edited by ctigroup; 2008-10-07 at 04:02 PM. Reason: Putting line breaks into code samples

  2. #2
    jmertic is offline Sugar Community Manager
    Join Date
    Dec 2007
    Posts
    2,224

    Default Re: Calling Custom Functionality

    Try changing the first set of code to the following:

    Code:
    array (
      'customCode' => '<form action="index.php" method="POST" name="XLSExport" id="form">
      <input type="hidden" name="module" value="Quotes">
      <input type="hidden" name="record" value="{$fields.id.value}">
      <input type="hidden" name="action" value="ExportToExcel">
      <input type="hidden" name="to_pdf" value="1">
      <input title="{$MOD.LBL_EXCEL_BUTTON_TITLE}" accessKey="{$MOD.LBL_EXCEL_BUTTON_KEY}" class="button" type="submit" name="button" value="{$MOD.LBL_EXCEL_BUTTON_LABEL}">
      </form>'

  3. #3
    ctigroup is offline Sugar Community Member
    Join Date
    Nov 2007
    Posts
    10

    Thumbs up Re: Calling Custom Functionality

    Fantastic - that did the trick - now I just have to get my custom code to format the XLS correctly (something I'm more fimilar with!)

    Just so I undersatnd what's going on here, I get the...

    Code:
    <input type="hidden" name="action" value="ExportToExcel">
    bit as this puts the &action=ExportToExcel into the string/URL, but what is the...

    Code:
    <input type="hidden" name="to_pdf" value="1">
    doing?

    Thanks for your assistance, it was really helpful

  4. #4
    jmertic is offline Sugar Community Manager
    Join Date
    Dec 2007
    Posts
    2,224

    Default Re: Calling Custom Functionality

    Quote Originally Posted by ctigroup
    Fantastic - that did the trick - now I just have to get my custom code to format the XLS correctly (something I'm more fimilar with!)

    Just so I undersatnd what's going on here, I get the...

    Code:
    <input type="hidden" name="action" value="ExportToExcel">
    bit as this puts the &action=ExportToExcel into the string/URL, but what is the...

    Code:
    <input type="hidden" name="to_pdf" value="1">
    doing?

    Thanks for your assistance, it was really helpful
    The to_pdf bit basically is there to format the page so that it can be converted to a pdf; which means not to display any header or footer information.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 4
    Last Post: 2008-07-03, 08:42 AM
  2. upgraded to 4.5.1e, received "Metadata for table tracker does not exist"
    By sfgeorge in forum Installation and Upgrade Help
    Replies: 0
    Last Post: 2007-09-03, 02:24 PM
  3. Replies: 0
    Last Post: 2007-05-18, 11:22 AM
  4. Asterisk Patch 1.1.0 Crash on logon
    By skyracer in forum Help
    Replies: 6
    Last Post: 2006-07-08, 06:30 AM
  5. Replies: 7
    Last Post: 2006-06-06, 07:56 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •