Last active
December 30, 2015 20:19
-
-
Save dmulvi/e877804c398a9dd94953 to your computer and use it in GitHub Desktop.
SugarCRM 6.x - Replace remove action with a delete action on subpanel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// you need to add a new entry to this file located in custom/include/MVC/Controller/entry_point_registry.php | |
$entry_point_registry['subpanel-delete'] = array('file' => 'custom/ninjacode/subpanel-delete.php', 'auth' => true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* In this example we'll swap out the remove button from the subpanel for a delete button. | |
* This will happen in a custom module that is displayed as a subpanel on the Contacts DetailView. | |
* | |
* First, you need to find the definition file for the subpanel. It will be located in: | |
* /custom/modules/SUBPANEL_MODULE/metadata/subpanels/ | |
* It will have a long ugly name, but it should be somewhat obvious which one you want as it will | |
* contain the name of the parent or DetailView module in the filename. In this case that is the | |
* Contacts module. On the specific example I did this for the file name was: | |
* Contact_subpanel_contacts_smm_status_module_1.php | |
*/ | |
$subpanel_layout['list_fields'] = array ( | |
// removed other metadata for brevity | |
'remove_button' => | |
array ( | |
'vname' => 'LBL_REMOVE', | |
//'widget_class' => 'SubPanelRemoveButton', | |
'widget_class' => 'SubPanelDeleteButton', | |
'module' => 'SMM_Status_Module', | |
'width' => '5%', | |
'default' => true, | |
), | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(typeof subpanel_delete_record != 'function'){ | |
window.subpanel_delete_record = function(sp,lf,li,rp) { | |
$.post( "/index.php?entryPoint=subpanel-delete", | |
{ | |
id: li | |
}, | |
function(data) { | |
showSubPanel('contacts_smm_status_module_1', null, true); | |
}); | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); | |
global $current_user, $db; | |
$id = $_POST['id']; | |
$sql = "UPDATE smm_status_module | |
SET deleted = 1, | |
date_modified = NOW(), | |
modified_user_id = '$current_user->id' | |
WHERE id = '$id'"; | |
$db->query($sql); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment