Sugarcrm 自定义模块在多个页面中选择全部 [英] sugarcrm custom module select all across multiple page
问题描述
我在自定义潜在客户的列表视图中创建了打印地址,列表视图代码如下所示.
总共有 25 条记录,首先我选择了 20 条记录(选择此页面),它执行 20 条记录的操作,如果我只看到 20 条记录的所有执行操作是正确的,所以它没有选择 25 条记录...
受保护的函数 buildMyMenuItem(){全局 $app_strings;返回<<<EOHTML<a class="menuItem" style="width: 150px;"href="#" onmouseover='hiliteItem(this,"yes");'onmouseout='unhiliteItem(this);'onclick="sugarListView.get_checks();if(sugarListView.get_checks_count() <1) {alert('{$app_strings['LBL_LISTVIEW_NO_SELECTED']}');返回假;}document.MassUpdate.action.value='print';document.MassUpdate.submit();">打印标签</a>EOHTML;}
我在下面的控制器类中调用它是代码
class CustomLeadsController 扩展 SugarController{公共函数 action_print() {如果(!空($_REQUEST['uid'])){$recordIds = expand(',',$_REQUEST['uid']);print_r($recordIds);?><表格><div align="right"><input name="button" type="button" onclick="window.print()" value="print"/>
</表单><table width="1024px" border="1" cellspacing="1" cellpadding="1" style="border-collapse:collapse;"><?php$i = 0;foreach ($recordIds 作为 $recordId ){$bean = SugarModule::get($_REQUEST['module'])->loadBean();//print_r($bean);$bean->retrieve($recordId);如果 ($i % 4 == 0){echo '
";echo nl2br($bean->primary_address_city);}?><br><?php echo nl2br($bean->primary_address_state);?><br><?php echo nl2br($bean->primary_address_postalcode);?></td><?php如果 ($i % 4 == 3){回声'</tr>';}$i++;}//这里是一个检查,以防你没有 3 行的倍数如果 ($i % 4 != 0){回声'</tr>';}?><?php}糖_死('');}}
我前段时间遇到了类似的问题,$_REQUEST['uid']
只显示页面上选择的项目,不显示完整的过滤列表.
检查整个列表是否被选中,$_REQUEST['select_entire_list'] == 1
获取已创建过滤列表的查询 - $_REQUEST['current_query_by_page']
然后您可以使用批量更新类来获取所有选定记录的列表
$mass = new MassUpdate();$mass->setSugarBean($bean);$mass->generateSearchWhere($module, $_REQUEST['current_query_by_page']);$seed = BeanFactory::getBean($module);$query = $seed->create_new_list_query('name ASC', $mass->where_clauses);$result = $db->query($query, true);
I created print the address in list view of custom leads the list view code is as given below.
There are 25 records totally first i select 20 records(select this page) ,its performing the action for 20 records which is correct if i seelct all its performing action for only 20 records ,so its not selecting the 25 records ...
protected function buildMyMenuItem()
{
global $app_strings;
return <<<EOHTML
<a class="menuItem" style="width: 150px;" href="#" onmouseover='hiliteItem(this,"yes");'
onmouseout='unhiliteItem(this);'
onclick="sugarListView.get_checks();
if(sugarListView.get_checks_count() < 1) {
alert('{$app_strings['LBL_LISTVIEW_NO_SELECTED']}');
return false;
}
document.MassUpdate.action.value='print';
document.MassUpdate.submit();">Print Label</a>
EOHTML;
}
Im calling it in the controller class below is the code
class CustomLeadsController extends SugarController
{
public function action_print() {
if ( !empty($_REQUEST['uid']) ) {
$recordIds = explode(',',$_REQUEST['uid']);
print_r($recordIds);
?>
<form>
<div align="right">
<input name="button" type="button" onclick="window.print()" value="print" />
</div>
</form>
<table width="1024px" border="1" cellspacing="1" cellpadding="1" style="border-collapse:collapse;">
<?php
$i = 0;
foreach ($recordIds as $recordId )
{
$bean = SugarModule::get($_REQUEST['module'])->loadBean();
// print_r($bean);
$bean->retrieve($recordId);
if ($i % 4 == 0)
{
echo '<tr>';
}
?>
<td align="left" width="25%" height="100px" STYLE="font-family: 'comic sans ms', fantasy; padding:10px; font-size:12px;">
<?php echo $bean->get_summary_text(); ?>
<br>
<?php echo nl2br($bean->primary_address_street); ?>
<?php
if($bean->primary_address_city != "")
{
echo "<br>";
echo nl2br($bean->primary_address_city);
}
?>
<br>
<?php echo nl2br($bean->primary_address_state); ?>
<br>
<?php echo nl2br($bean->primary_address_postalcode); ?>
</td>
<?php
if ($i % 4 == 3)
{
echo '</tr>';
}
$i++;
}
//here is a check in case you don't have multiple of 3 rows
if ($i % 4 != 0)
{
echo '</tr>';
}
?>
</table>
<?php
}
sugar_die('');
}
}
I ran into a similar issue a while ago, $_REQUEST['uid']
only shows items selected on the page, not the full filtered list.
Check if the entire list has been selected, $_REQUEST['select_entire_list'] == 1
Get the query that that has created the filtered list - $_REQUEST['current_query_by_page']
You can then use the Mass Update class to get a list of all the selected records
$mass = new MassUpdate();
$mass->setSugarBean($bean);
$mass->generateSearchWhere($module, $_REQUEST['current_query_by_page']);
$seed = BeanFactory::getBean($module);
$query = $seed->create_new_list_query('name ASC', $mass->where_clauses);
$result = $db->query($query, true);
这篇关于Sugarcrm 自定义模块在多个页面中选择全部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!