Skip to content

Commit

Permalink
QuickEdit button
Browse files Browse the repository at this point in the history
  • Loading branch information
jordiSTIC committed Jan 23, 2024
1 parent ecfb99c commit b437eea
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?php
/**
* This file is part of SinergiaCRM.
* SinergiaCRM is a work developed by SinergiaTIC Association, based on SuiteCRM.
* Copyright (C) 2013 - 2023 SinergiaTIC Association
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SinergiaTIC Association at email address [email protected].
*/

if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}

/**
* This custom class, allows you to create a button in each record of the subpanel
* which open the QuickCreate View to edit the record.
*/
class SugarWidgetSubPanelSticQuickEditButton extends SugarWidgetField
{
function displayList($layout_def)
{
global $app_strings;
global $subpanel_item_count;
$return_module = $_REQUEST['module'];
$return_id = $_REQUEST['record'];
$module_name = $layout_def['module'];
$record_id = $layout_def['fields']['ID'];
$subpanel = $layout_def['subpanel_id'];
$unique_id = $layout_def['subpanel_id']."_form_".$subpanel_item_count; //bug 51512

// @see SugarWidgetSubPanelTopButtonQuickCreate::get_subpanel_relationship_name()
$relationship_name = '';
if (!empty($layout_def['linked_field'])) {
$relationship_name = $layout_def['linked_field'];
$bean = BeanFactory::getBean($layout_def['module']);
if (!empty($bean->field_defs[$relationship_name]['relationship'])) {
$relationship_name = $bean->field_defs[$relationship_name]['relationship'];
}
}


$subpanel = $layout_def['subpanel_id'];
if (isset($layout_def['linked_field_set']) && !empty($layout_def['linked_field_set'])) {
$linked_field= $layout_def['linked_field_set'] ;
} else {
$linked_field = $layout_def['linked_field'];
}

$labelText = "Quick Edit";
$label = null;
if (isset($layout_def['vname'])) {
$label = $layout_def['vname'];
} elseif (isset($layout_def['label'])) {
$label = $layout_def['label'];
}
if ($label != null) {
if (isset($app_strings[$label])) {
$labelText = $app_strings[$label];
} elseif (isset($mod_strings[$label])) {
$labelText = $mod_strings[$label];
}
}

$html = '
<form onsubmit="return SUGAR.subpanelUtils.sendAndRetrieve(this.id, \'subpanel_'.$subpanel.'\', \'Loading ...\');" action="index.php" method="post" name="form" id="'.$unique_id.'">
<input type="hidden" name="record" value="'.$record_id.'">
<input type="hidden" name="target_module" value="'.$module_name.'">
<input type="hidden" name="tpl" value="QuickCreate.tpl">
<input type="hidden" name="return_module" value="'.$return_module.'">
<input type="hidden" name="return_action" value="SubPanelViewer">
<input type="hidden" name="return_id" value="'.$return_id.'">
<input type="hidden" name="return_relationship" value="'.$relationship_name.'">
<input type="hidden" name="action" value="SubpanelCreates">
<input type="hidden" name="module" value="Home">
<input type="hidden" name="target_action" value="QuickCreate">
<input type="hidden" name="return_name" value="XXXX">
<input type="hidden" name="parent_type" value="'.$return_module.'">
<input type="hidden" name="parent_name" value="XXXX">
<input type="hidden" name="parent_id" value="'.$return_id.'">
<input title="'.$labelText.'" accesskey="N" class="button" type="submit" name="'.$module_name.'_edit_button" id="projects_opportunities_create_button" value="'.$labelText.'">
</form>';


return $html;

}


}
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,21 @@
'width' => '45%',
'default' => true,
),
'edit_button' =>
array (
'quick_edit_button' => array(
'vname' => 'LBL_EDIT_BUTTON',
'widget_class' => 'SubPanelEditButton',
'widget_class' => 'SubPanelSticQuickEditButton',
'module' => 'stic_Custom_View_Customizations',
'width' => '4%',
'width' => '5%',
'default' => true,
),
// 'edit_button' =>
// array (
// 'vname' => 'LBL_EDIT_BUTTON',
// 'widget_class' => 'SubPanelEditButton',
// 'module' => 'stic_Custom_View_Customizations',
// 'width' => '5%',
// 'default' => true,
// ),
'remove_button' =>
array (
'vname' => 'LBL_REMOVE',
Expand Down

0 comments on commit b437eea

Please sign in to comment.