Hi to all, i have a request, is there a way to add another button in the subpanel of events delegates? cause i need a button to export all the delegates of a selected events.
Thanks for the help
Hi to all, i have a request, is there a way to add another button in the subpanel of events delegates? cause i need a button to export all the delegates of a selected events.
Thanks for the help
Here is a sample:
http://urdhva-tech.blogspot.com/2014/06/how-to-add-subpanel-top-button-on.html
Thanks,
AlxGr
Thanks for the suggest but i found a way more “deeper” to fix this.
i’ll post now how i made it:
first of all in
FP_Events\metadata\supbaneldefs.php
i added my own button in the top_buttons array
'top_buttons' => array(
array('widget_class' => 'SubPanelDelegatesSelectButton'),
array('widget_class' => 'SubPanelManageDelegatesButton'),
array('widget_class' => 'SubPanelDelegatesExportButton'), // this one
array('widget_class' => 'SubPanelManageAcceptancesButton'),
array('widget_class' => 'SubPanelSendInvitesButton'),
array('widget_class' => 'SubPanelCheck'),
array('widget_class' => 'SubPanelTopFilterButton'),
),
then i dig where this class where, so i those classes in include\generic\SugarWidget and i made my SubPanelDelegatesExportButton
<?php
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
/**
*
* SugarCRM Community Edition is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
*
* SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd.
* Copyright (C) 2011 - 2018 SalesAgility Ltd.
*
* 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 with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* 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 SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
* reasonably feasible for technical reasons, the Appropriate Legal Notices must
* display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM".
*/
require_once('include/generic/SugarWidgets/SugarWidgetSubPanelTopButton.php');
class SugarWidgetSubPanelDelegatesExportButton extends SugarWidgetSubPanelTopButton
{
public function display($defines, $additionalFormFields = null, $nonbutton = false)
{
global $mod_strings;
$button = "<script src='include/javascript/checkbox.js' type='text/javascript'></script>";
$button .= "<form id='CustExportForm' name='CustExportForm' method='post' action=''>";
// $button .= "<input id='custom_hidden_5' type='hidden' name='custom_hidden_5' value=''/>";
$button .= "<input id='Custom_Export' class='button' type='button' name='Custom_Export' onclick='export_targets()' value='export Delegati'/>\n</form>";
return $button;
}
}
and i create the funcion export_targets() in the checkbox.js:
function export_targets() {
var eventid = $("[name='record']").val();
var data = 'event_id=' + eventid;
$.ajax({
type: "POST",
url: "index.php?module=FP_events&action=exportinvited",
data: data,
success: function () {
// showSubPanel('delegates', null, true, 'FP_events');
}
});
}
this functions call with post method an action made on the FP_Event controller that allow me to export all the leads linked to the event:
function action_exportinvited(){
$db = DBManagerFactory::getInstance();
$event_id = $_GET['event_id'];
$query1 = "SELECT name FROM fp_events WHERE id='".$event_id."'";
$res = $db->query($query1);
$row = $db->fetchByAssoc($res);
$event_name = $row['name'];
$query2 = "SELECT fp_events_leads_1leads_idb FROM fp_events_leads_1_c WHERE fp_events_leads_1fp_events_ida='".$event_id."' ";
$res = $db->query($query2);
$csv = '';
$first_row = "Nome;Cognome;Email;Nazione;Data accettazione;" . chr(10);
$csv .= $first_row;
while ($row = $db->fetchByAssoc($res)) {
$recordId = $row['fp_events_leads_1leads_idb'];
$bean = SugarModule::get('Leads')->loadBean();
$bean->retrieve($recordId);
$csv .= $bean->first_name.';';
$csv .= $bean->last_name.';';
$csv .= $bean->email1.';';
$csv .= $bean->primary_address_country.';';
$csv .= $bean->data_accettazione_privacy_c .';'.chr(10);
}
$a = str_replace("'","'",($csv));
$csv =html_entity_decode($a);
$destination_dir= "E:\\Siti\\CRM\\modules\\FP_events\\".$event_name.".csv";
file_put_contents($destination_dir, $csv);
header('Content-Description: File Transfer');
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="'.basename($destination_dir).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($destination_dir));
readfile($destination_dir);
exit;
}
i hope helps someone