如何在 sugarcrm 中弹出 window?
how to make a pop-up window in sugarcrm?
我是 SugarCRM 的新手,所以请多多包涵。我正在尝试在 SugarCRM 中添加弹出窗口 window。我需要这个弹出窗口 window 在用户点击状态设置为 'Inactive'.
的帐户时显示
现在,我正在尝试按照 link 中提到的说明进行操作,只是我使用的更花哨一些?基于 YUI 2 SimpleDialog 组件的弹出窗口 window。
SugarCRM- How to get POPUP when click on Save button?
目前,当我点击编辑按钮编辑帐户时,会出现一个弹出窗口-window。但是,我希望它出现在 DetailView 中,当帐户处于非活动状态时,应该显示一个弹出窗口。
到目前为止,我的代码如下所示:
manifest.php:
<?php
$manifest = array(
array(
'acceptable_sugar_versions' => array()
),
array(
'acceptable_sugar_flavors' => array()
),
'readme' => 'Please consult the operating manual for detailed installation instructions.',
'key' => 'customSugarMod1',
'author' => 'Abhay Hans',
'description' => 'Adds pop-up Message when an account is inactive.',
'icon' => '',
'is_uninstallable' => true,
'name' => 'Pop-Up Dialog if inactive account',
'published_date' => '2015-07-08 12:00:00',
'type' => 'module',
'version' => 'v1.7',
'remove_tables' => 'prompt'
);
$installdefs = array(
'id' => 'customSugarMod1',
'copy' => array(
array(
'from' => '<basepath>/custom/',
'to' => 'custom/'
)
),
'logic_hooks' => array(
array(
'module' => 'Accounts',
'hook' => 'after_ui_frame',
'order' => 1,
'description' => 'Creates pop-up message on load if user inactive',
'file' => 'custom/include/customPopUps/custom_popup_js_include.php',
'class' => 'CustomPopJs',
'function' => 'getAccountJs'
)
)
);
Custom_popup_js_include.php:
<?php
// prevent people from accessing this file directly
/*if (! defined('sugarEntry') || ! sugarEntry) {
die('Not a valid entry point.');
}*/
class CustomPopJs {
function getAccountJs($event, $arguments) {
// Prevent this script from being injected anywhere but the EditView.
/*if ($_REQUEST['action'] != 'DetailView' ) {
// we are not in the EditView, so simply return without injecting
// the Javascript
return;
}*/
echo '<script type="text/javascript" src="custom/include/customPopUps/customPopUpAccounts.js"></script>';
echo '<script type="text/javascript" src="custom/include/javascript/sugarwidgets/SugarYUIWidgets.js"></script>';
}
}
customPopUpAccounts.js
document.addEventListener('DOMContentLoaded', function() {
checkUserStatus();
}, false);
function checkUserStatus()
{
if($("#aq_account_status_c").val() != "Active" )
{
YAHOO.SUGAR.MessageBox.show({msg: 'This account is inactive ', title: 'Inactive Account'} );
}
}
对评论进行总结,并加以阐述:
- EditView 有几个带有 id 属性的输入字段,可以作为 Javascript 值获取的良好标识符。
- 但是,详细视图没有。它生成一个 table,并根据定义将值放在它所属的位置。
因此,您需要调用数据库来确定帐户值。我的详细视图中有以下内容:
function getAccountJs($event, $arguments) {
//This is in case the DB connection file isn't included by default
require_once 'include/database/DBManagerFactory.php';
echo '<script type="text/javascript" src="custom/include/javascript/sugarwidgets/SugarYUIWidgets.js"></script>';
// Check if the view is Detail View, if so, check the DB if account is inactive
if ($_REQUEST['action'] == 'DetailView' ) {
$accountID = $_REQUEST["record"];
$db = DBManagerFactory::getInstance();
$query = "select aq_account_status_c from accounts_cstm
where id_c = '". $accountID . "'";
$result = $db->query($query);
$row = $db->fetchByAssoc($result);
//If the returned row is not "Active" show
if ($row['aq_account_status_c'] != "Active") {
echo "<script>YAHOO.SUGAR.MessageBox.show({msg: 'This account is inactive ', title: 'Inactive Account'} );</script>";
}
}
//If it is Edit view, use the same javascript as before
if ($_REQUEST['action'] == 'EditView' ) {
echo '<script type="text/javascript" src="custom/include/customPopUps/customPopUpAccounts.js"></script>';
}
}
我是 SugarCRM 的新手,所以请多多包涵。我正在尝试在 SugarCRM 中添加弹出窗口 window。我需要这个弹出窗口 window 在用户点击状态设置为 'Inactive'.
的帐户时显示现在,我正在尝试按照 link 中提到的说明进行操作,只是我使用的更花哨一些?基于 YUI 2 SimpleDialog 组件的弹出窗口 window。
SugarCRM- How to get POPUP when click on Save button?
目前,当我点击编辑按钮编辑帐户时,会出现一个弹出窗口-window。但是,我希望它出现在 DetailView 中,当帐户处于非活动状态时,应该显示一个弹出窗口。
到目前为止,我的代码如下所示:
manifest.php:
<?php
$manifest = array(
array(
'acceptable_sugar_versions' => array()
),
array(
'acceptable_sugar_flavors' => array()
),
'readme' => 'Please consult the operating manual for detailed installation instructions.',
'key' => 'customSugarMod1',
'author' => 'Abhay Hans',
'description' => 'Adds pop-up Message when an account is inactive.',
'icon' => '',
'is_uninstallable' => true,
'name' => 'Pop-Up Dialog if inactive account',
'published_date' => '2015-07-08 12:00:00',
'type' => 'module',
'version' => 'v1.7',
'remove_tables' => 'prompt'
);
$installdefs = array(
'id' => 'customSugarMod1',
'copy' => array(
array(
'from' => '<basepath>/custom/',
'to' => 'custom/'
)
),
'logic_hooks' => array(
array(
'module' => 'Accounts',
'hook' => 'after_ui_frame',
'order' => 1,
'description' => 'Creates pop-up message on load if user inactive',
'file' => 'custom/include/customPopUps/custom_popup_js_include.php',
'class' => 'CustomPopJs',
'function' => 'getAccountJs'
)
)
);
Custom_popup_js_include.php:
<?php
// prevent people from accessing this file directly
/*if (! defined('sugarEntry') || ! sugarEntry) {
die('Not a valid entry point.');
}*/
class CustomPopJs {
function getAccountJs($event, $arguments) {
// Prevent this script from being injected anywhere but the EditView.
/*if ($_REQUEST['action'] != 'DetailView' ) {
// we are not in the EditView, so simply return without injecting
// the Javascript
return;
}*/
echo '<script type="text/javascript" src="custom/include/customPopUps/customPopUpAccounts.js"></script>';
echo '<script type="text/javascript" src="custom/include/javascript/sugarwidgets/SugarYUIWidgets.js"></script>';
}
}
customPopUpAccounts.js
document.addEventListener('DOMContentLoaded', function() {
checkUserStatus();
}, false);
function checkUserStatus()
{
if($("#aq_account_status_c").val() != "Active" )
{
YAHOO.SUGAR.MessageBox.show({msg: 'This account is inactive ', title: 'Inactive Account'} );
}
}
对评论进行总结,并加以阐述:
- EditView 有几个带有 id 属性的输入字段,可以作为 Javascript 值获取的良好标识符。
- 但是,详细视图没有。它生成一个 table,并根据定义将值放在它所属的位置。
因此,您需要调用数据库来确定帐户值。我的详细视图中有以下内容:
function getAccountJs($event, $arguments) {
//This is in case the DB connection file isn't included by default
require_once 'include/database/DBManagerFactory.php';
echo '<script type="text/javascript" src="custom/include/javascript/sugarwidgets/SugarYUIWidgets.js"></script>';
// Check if the view is Detail View, if so, check the DB if account is inactive
if ($_REQUEST['action'] == 'DetailView' ) {
$accountID = $_REQUEST["record"];
$db = DBManagerFactory::getInstance();
$query = "select aq_account_status_c from accounts_cstm
where id_c = '". $accountID . "'";
$result = $db->query($query);
$row = $db->fetchByAssoc($result);
//If the returned row is not "Active" show
if ($row['aq_account_status_c'] != "Active") {
echo "<script>YAHOO.SUGAR.MessageBox.show({msg: 'This account is inactive ', title: 'Inactive Account'} );</script>";
}
}
//If it is Edit view, use the same javascript as before
if ($_REQUEST['action'] == 'EditView' ) {
echo '<script type="text/javascript" src="custom/include/customPopUps/customPopUpAccounts.js"></script>';
}
}