Results 1 to 7 of 7

Thread: Conditionally Add Custom Buttons in Opportunity DetailView

  1. #1
    Join Date
    Jan 2009
    Posts
    18

    Default Conditionally Add Custom Buttons in Opportunity DetailView

    Hey,

    i need to add some buttons to the detail view of the module opportunity.

    but the button shall only be displayed if the user belongs to a special role or if he is an administrator.
    see attatched image for more information.

    i don't have a clue how to solve this. do you have any ideas how it could be solved or do you actually have a solution for this??

    thx for your help!!!
    Attached Images Attached Images  

  2. #2
    mikesolomon is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    UK
    Posts
    1,467

    Default Re: Conditionally Add Custom Buttons in Opportunity DetailView

    You can do it by editing custom/modules/Opportunities/metadata/detailviewdefs.php

    Below is some code I'm using as an example

    Code:
     'form' => 
            array (
              'buttons' => 
              array (
                0 => 'EDIT',
                1 => 'DUPLICATE',
                2 => 'DELETE',
                
                 3 => 
              array (
                'customCode' => '{if $fields.status.value == "Closed"}<input id="COMP" title="ReOpen [Alt+C]" accessKey="C" class="button" onclick="this.form.action.value=\'Save\'; return check_form(\'EditView\');" type="submit" name="button" value="ReOpen" style="display:none">{/if}
                {if $fields.status.value == "Open"}<input id="COMP" title="Close [Alt+C]" accessKey="C" class="button" onclick="this.form.action.value=\'Save\'; return check_form(\'EditView\');" type="submit" name="button" value="Close" >{/if}',
              ),
            
                
                4 =>
                array (
                  'customCode' => '<input title="Case Time Report" accesskey="P" class="button" onclick="var w=window.open(\'index.php?module=ZuckerReports&action=ReportOnDemand&run=true&is_scheduler=false&record=590ef31f-bec5-fe1d-7bb8-486b6ae7f478&format=PDF&casenumber={$fields.case_number.value}\');  w.setTimeout(\'window.close()\',7000); " name="button" value="Time Rep" type="button">',
    
                ),
    			
                
                
                
              ),
            ),
    Mike Solomon
    Development Manager
    Ivy Ltd
    www.ivy.ltd.uk]www.ivy.ltd.uk

    php version 5.2.6
    MySql 5.1.59

  3. #3
    Join Date
    Jan 2009
    Posts
    18

    Default Re: Conditionally Add Custom Buttons in Opportunity DetailView

    hmm okay.. but how do i check if the user belongs to the role 'showextrabutton'??

  4. #4
    mikesolomon is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    UK
    Posts
    1,467

    Default Re: Conditionally Add Custom Buttons in Opportunity DetailView

    Quote Originally Posted by stefan.theissen View Post
    hmm okay.. but how do i check if the user belongs to the role 'showextrabutton'??

    Sorry didnt read your post properly

    What I do in that situation is add the button in detailviewdefs and set it as hidden

    then in view.detail.php I test for the role & unhide it

    Code:
    require_once('modules/Users/User.php');
    $check_role = new User();
    		if ( $check_role->check_role_membership('Admin User', $user_id='')){
    			print '<script type="text/javascript" >document.getElementById(\'COMP\').style.display = \'inline\';</script>';
    
    		}
    Mike Solomon
    Development Manager
    Ivy Ltd
    www.ivy.ltd.uk]www.ivy.ltd.uk

    php version 5.2.6
    MySql 5.1.59

  5. #5
    Join Date
    Jan 2009
    Posts
    18

    Default Re: Conditionally Add Custom Buttons in Opportunity DetailView

    ah okay i see..

    well that's a way how to do it.. thank you.

    but i would prefer a non javascript solution. suggestions??

  6. #6
    SugarDev.net is offline Sugar Community Member
    Join Date
    Feb 2008
    Posts
    1,401

    Default Re: Conditionally Add Custom Buttons in Opportunity DetailView

    Combine post #2 with #4.
    Developers go here
    Businesses go there (Dutch)

    Modules:
    SugarDev.net Developer Tools | Config | Dutch Language Pack
    "Nothing gets fixed unless there is a bug"

  7. #7
    Join Date
    Jan 2009
    Posts
    18

    Default Re: Conditionally Add Custom Buttons in Opportunity DetailView

    seems to work.. thanx
    Last edited by stefan.theissen; 2009-01-22 at 10:04 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Custom Buttons on ListViews
    By cnielsenlev in forum Developer Help
    Replies: 8
    Last Post: 2009-09-16, 03:05 PM
  2. Conditionally Disable delete
    By piccirm in forum Developer Help
    Replies: 13
    Last Post: 2009-01-21, 05:30 PM
  3. Simple way to add buttons on ListView under /custom
    By arisjr in forum Developer Help
    Replies: 4
    Last Post: 2008-07-01, 11:15 AM
  4. Using conditionally required field
    By thibaultullink in forum Help
    Replies: 0
    Last Post: 2007-03-08, 03:05 PM
  5. Opportunity DetailView
    By diegofliess in forum General Discussion
    Replies: 0
    Last Post: 2006-03-21, 05:36 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
  •