PageRenderTime 48ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/include/ListView/ListViewDisplay.php

https://github.com/vincentamari/SuperSweetAdmin
PHP | 615 lines | 505 code | 30 blank | 80 comment | 57 complexity | a814a93190a4442eeb8c78278608a218 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, AGPL-3.0, LGPL-2.1
  1. <?php
  2. if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
  3. /*********************************************************************************
  4. * SugarCRM is a customer relationship management program developed by
  5. * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
  6. *
  7. * This program is free software; you can redistribute it and/or modify it under
  8. * the terms of the GNU Affero General Public License version 3 as published by the
  9. * Free Software Foundation with the addition of the following permission added
  10. * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
  11. * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
  12. * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
  13. *
  14. * This program is distributed in the hope that it will be useful, but WITHOUT
  15. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  16. * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  17. * details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License along with
  20. * this program; if not, see http://www.gnu.org/licenses or write to the Free
  21. * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  22. * 02110-1301 USA.
  23. *
  24. * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
  25. * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
  26. *
  27. * The interactive user interfaces in modified source and object code versions
  28. * of this program must display Appropriate Legal Notices, as required under
  29. * Section 5 of the GNU Affero General Public License version 3.
  30. *
  31. * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
  32. * these Appropriate Legal Notices must retain the display of the "Powered by
  33. * SugarCRM" logo. If the display of the logo is not reasonably feasible for
  34. * technical reasons, the Appropriate Legal Notices must display the words
  35. * "Powered by SugarCRM".
  36. ********************************************************************************/
  37. require_once('include/ListView/ListViewData.php');
  38. require_once('include/MassUpdate.php');
  39. class ListViewDisplay {
  40. var $show_mass_update_form = false;
  41. var $show_action_dropdown = true;
  42. var $rowCount;
  43. var $mass = null;
  44. var $seed;
  45. var $multi_select_popup;
  46. var $lvd;
  47. var $moduleString;
  48. var $export = true;
  49. var $multiSelect = true;
  50. var $mailMerge = true;
  51. var $should_process = true;
  52. /*
  53. * Used in view.popup.php. Sometimes there are fields on the search form that are not referenced in the listviewdefs. If this
  54. * is the case, then the filterFields will be set and the related fields will not be referenced when calling create_new_list_query.
  55. */
  56. var $mergeDisplayColumns = false;
  57. public $actionsMenuExtraItems = array();
  58. /**
  59. * Constructor
  60. * @return null
  61. */
  62. function ListViewDisplay() {
  63. $this->lvd = new ListViewData();
  64. $this->searchColumns = array () ;
  65. }
  66. function shouldProcess($moduleDir){
  67. if(!empty($GLOBALS['sugar_config']['save_query']) && $GLOBALS['sugar_config']['save_query'] == 'populate_only'){
  68. if(empty($GLOBALS['displayListView'])
  69. && (!empty($_REQUEST['clear_query'])
  70. || $_REQUEST['module'] == $moduleDir
  71. && ((empty($_REQUEST['query']) || $_REQUEST['query'] == 'MSI' )
  72. && (empty($_SESSION['last_search_mod']) || $_SESSION['last_search_mod'] != $moduleDir ) ))){
  73. $_SESSION['last_search_mod'] = $_REQUEST['module'] ;
  74. $this->should_process = false;
  75. return false;
  76. }
  77. }
  78. $this->should_process = true;
  79. return true;
  80. }
  81. /**
  82. * Setup the class
  83. * @param seed SugarBean Seed SugarBean to use
  84. * @param file File Template file to use
  85. * @param string $where
  86. * @param offset:0 int offset to start at
  87. * @param int:-1 $limit
  88. * @param string[]:array() $filter_fields
  89. * @param array:array() $params
  90. * Potential $params are
  91. $params['distinct'] = use distinct key word
  92. $params['include_custom_fields'] = (on by default)
  93. $params['massupdate'] = true by default;
  94. $params['handleMassupdate'] = true by default, have massupdate.php handle massupdates?
  95. * @param string:'id' $id_field
  96. */
  97. function setup($seed, $file, $where, $params = array(), $offset = 0, $limit = -1, $filter_fields = array(), $id_field = 'id') {
  98. $this->should_process = true;
  99. if(isset($seed->module_dir) && !$this->shouldProcess($seed->module_dir)){
  100. return false;
  101. }
  102. if(isset($params['export'])) {
  103. $this->export = $params['export'];
  104. }
  105. if(!empty($params['multiSelectPopup'])) {
  106. $this->multi_select_popup = $params['multiSelectPopup'];
  107. }
  108. if(!empty($params['massupdate']) && $params['massupdate'] != false) {
  109. $this->show_mass_update_form = true;
  110. $this->mass = new MassUpdate();
  111. $this->mass->setSugarBean($seed);
  112. if(!empty($params['handleMassupdate']) || !isset($params['handleMassupdate'])) {
  113. $this->mass->handleMassUpdate();
  114. }
  115. }
  116. $this->seed = $seed;
  117. $filter_fields = $this->setupFilterFields($filter_fields);
  118. $data = $this->lvd->getListViewData($seed, $where, $offset, $limit, $filter_fields, $params, $id_field);
  119. foreach($this->displayColumns as $columnName => $def)
  120. {
  121. $seedName = strtolower($columnName);
  122. if(!empty($this->lvd->seed->field_defs[$seedName])){
  123. $seedDef = $this->lvd->seed->field_defs[$seedName];
  124. }
  125. if(empty($this->displayColumns[$columnName]['type'])){
  126. if(!empty($seedDef['type'])){
  127. $this->displayColumns[$columnName]['type'] = (!empty($seedDef['custom_type']))?$seedDef['custom_type']:$seedDef['type'];
  128. }else{
  129. $this->displayColumns[$columnName]['type'] = '';
  130. }
  131. }//fi empty(...)
  132. if(!empty($seedDef['options'])){
  133. $this->displayColumns[$columnName]['options'] = $seedDef['options'];
  134. }
  135. //C.L. Fix for 11177
  136. if($this->displayColumns[$columnName]['type'] == 'html') {
  137. $cField = $this->seed->custom_fields;
  138. if(isset($cField) && isset($cField->bean->$seedName)) {
  139. $seedName2 = strtoupper($columnName);
  140. $htmlDisplay = html_entity_decode($cField->bean->$seedName);
  141. $count = 0;
  142. while($count < count($data['data'])) {
  143. $data['data'][$count][$seedName2] = &$htmlDisplay;
  144. $count++;
  145. }
  146. }
  147. }//fi == 'html'
  148. //Bug 40511, make sure relate fields have the correct module defined
  149. if ($this->displayColumns[$columnName]['type'] == "relate" && !empty($seedDef['link']) && empty( $this->displayColumns[$columnName]['module']))
  150. {
  151. $link = $seedDef['link'];
  152. if (!empty($this->lvd->seed->field_defs[$link]) && !empty($this->lvd->seed->field_defs[$seedDef['link']]['module']))
  153. {
  154. $this->displayColumns[$columnName]['module'] = $this->lvd->seed->field_defs[$seedDef['link']]['module'];
  155. }
  156. }
  157. if (!empty($seedDef['sort_on'])) {
  158. $this->displayColumns[$columnName]['orderBy'] = $seedDef['sort_on'];
  159. }
  160. if(isset($seedDef)){
  161. // Merge the two arrays together, making sure the seedDef doesn't override anything explicitly set in the displayColumns array.
  162. $this->displayColumns[$columnName] = $this->displayColumns[$columnName] + $seedDef;
  163. }
  164. //C.L. Bug 38388 - ensure that ['id'] is set for related fields
  165. if(!isset($this->displayColumns[$columnName]['id']) && isset($this->displayColumns[$columnName]['id_name'])) {
  166. $this->displayColumns[$columnName]['id'] = strtoupper($this->displayColumns[$columnName]['id_name']);
  167. }
  168. }
  169. $this->process($file, $data, $seed->object_name);
  170. return true;
  171. }
  172. function setupFilterFields($filter_fields = array())
  173. {
  174. // create filter fields based off of display columns
  175. if(empty($filter_fields) || $this->mergeDisplayColumns) {
  176. foreach($this->displayColumns as $columnName => $def) {
  177. $filter_fields[strtolower($columnName)] = true;
  178. if(isset($this->seed->field_defs[strtolower($columnName)]['type']) &&
  179. strtolower($this->seed->field_defs[strtolower($columnName)]['type']) == 'currency' &&
  180. isset($this->seed->field_defs['currency_id'])) {
  181. $filter_fields['currency_id'] = true;
  182. }
  183. if(!empty($def['related_fields'])) {
  184. foreach($def['related_fields'] as $field) {
  185. //id column is added by query construction function. This addition creates duplicates
  186. //and causes issues in oracle. #10165
  187. if ($field != 'id') {
  188. $filter_fields[$field] = true;
  189. }
  190. }
  191. }
  192. if (!empty($this->seed->field_defs[strtolower($columnName)]['db_concat_fields'])) {
  193. foreach($this->seed->field_defs[strtolower($columnName)]['db_concat_fields'] as $index=>$field){
  194. if(!isset($filter_fields[strtolower($field)]) || !$filter_fields[strtolower($field)])
  195. {
  196. $filter_fields[strtolower($field)] = true;
  197. }
  198. }
  199. }
  200. }
  201. foreach ($this->searchColumns as $columnName => $def )
  202. {
  203. $filter_fields[strtolower($columnName)] = true;
  204. }
  205. }
  206. return $filter_fields;
  207. }
  208. /**
  209. * Any additional processing
  210. * @param file File template file to use
  211. * @param data array row data
  212. * @param html_var string html string to be passed back and forth
  213. */
  214. function process($file, $data, $htmlVar) {
  215. $this->rowCount = count($data['data']);
  216. $this->moduleString = $data['pageData']['bean']['moduleDir'] . '2_' . strtoupper($htmlVar) . '_offset';
  217. }
  218. /**
  219. * Display the listview
  220. * @return string ListView contents
  221. */
  222. public function display()
  223. {
  224. if (!$this->should_process) {
  225. return '';
  226. }
  227. $str = '';
  228. if ($this->multiSelect == true && $this->show_mass_update_form) {
  229. $str = $this->mass->getDisplayMassUpdateForm(true, $this->multi_select_popup).$this->mass->getMassUpdateFormHeader($this->multi_select_popup);
  230. }
  231. return $str;
  232. }
  233. /**
  234. * Display the select link
  235. * @return string select link html
  236. * @param echo Bool set true if you want it echo'd, set false to have contents returned
  237. */
  238. function buildSelectLink($id = 'select_link', $total=0, $pageTotal=0) {
  239. global $app_strings;
  240. if ($pageTotal < 0)
  241. $pageTotal = $total;
  242. $script = "<script>
  243. function select_overlib() {
  244. return overlib('<a style=\'width: 150px\' name=\"thispage\" class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'if (document.MassUpdate.select_entire_list.value==1){document.MassUpdate.select_entire_list.value=0;sListView.check_all(document.MassUpdate, \"mass[]\", true, $pageTotal)}else {sListView.check_all(document.MassUpdate, \"mass[]\", true)};\' href=\'#\'>{$app_strings['LBL_LISTVIEW_OPTION_CURRENT']}&nbsp;&#x28;{$pageTotal}&#x29;&#x200E;</a>"
  245. . "<a style=\'width: 150px\' name=\"selectall\" class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'sListView.check_entire_list(document.MassUpdate, \"mass[]\",true,{$total});\' href=\'#\'>{$app_strings['LBL_LISTVIEW_OPTION_ENTIRE']}&nbsp;&#x28;{$total}&#x29;&#x200E;</a>"
  246. . "<a style=\'width: 150px\' name=\"deselect\" class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'sListView.clear_all(document.MassUpdate, \"mass[]\", false);\' href=\'#\'>{$app_strings['LBL_LISTVIEW_NONE']}</a>"
  247. . "', CENTER, '"
  248. . "', STICKY, MOUSEOFF, 3000, CLOSETEXT, '<img border=0 src=" . SugarThemeRegistry::current()->getImageURL('close_inline.gif')
  249. . ">', WIDTH, 150, CLOSETITLE, '" . $app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE'] . "', CLOSECLICK, FGCLASS, 'olOptionsFgClass', "
  250. . "CGCLASS, 'olOptionsCgClass', BGCLASS, 'olBgClass', TEXTFONTCLASS, 'olFontClass', CAPTIONFONTCLASS, 'olOptionsCapFontClass', CLOSEFONTCLASS, 'olOptionsCloseFontClass',TIMEOUT,1000);
  251. }
  252. </script>";
  253. $script .= "<a id='$id' onclick='return select_overlib();' href=\"#\"><img src='".SugarThemeRegistry::current()->getImageURL('MoreDetail.png')."' border='0''>"."</a>";
  254. return $script;
  255. }
  256. /**
  257. * Display the actions link
  258. *
  259. * @param string $id link id attribute, defaults to 'actions_link'
  260. * @return string HTML source
  261. */
  262. protected function buildActionsLink(
  263. $id = 'actions_link'
  264. )
  265. {
  266. global $app_strings;
  267. $closeText = "<img border=0 src=" . SugarThemeRegistry::current()->getImageURL('close_inline.gif') . " />";
  268. $moreDetailImage = SugarThemeRegistry::current()->getImageURL('MoreDetail.png');
  269. $menuItems = '';
  270. // delete
  271. if ( ACLController::checkAccess($this->seed->module_dir,'delete',true) && $this->delete )
  272. $menuItems .= $this->buildDeleteLink();
  273. // compose email
  274. if ( $this->email )
  275. $menuItems .= $this->buildComposeEmailLink($this->data['pageData']['offsets']['total']);
  276. // mass update
  277. $mass = new MassUpdate();
  278. $mass->setSugarBean($this->seed);
  279. if ( ACLController::checkAccess($this->seed->module_dir,'edit',true) && $this->showMassupdateFields && $mass->doMassUpdateFieldsExistForFocus() )
  280. $menuItems .= $this->buildMassUpdateLink();
  281. // merge
  282. if ( $this->mailMerge )
  283. $menuItems .= $this->buildMergeLink();
  284. if ( $this->mergeduplicates )
  285. $menuItems .= $this->buildMergeDuplicatesLink();
  286. // add to target list
  287. if ( $this->targetList && ACLController::checkAccess('ProspectLists','edit',true) )
  288. $menuItems .= $this->buildTargetList();
  289. // export
  290. if ( ACLController::checkAccess($this->seed->module_dir,'export',true) && $this->export )
  291. $menuItems .= $this->buildExportLink();
  292. foreach ( $this->actionsMenuExtraItems as $item )
  293. $menuItems .= $item;
  294. $menuItems = str_replace('"','\"',$menuItems);
  295. $menuItems = str_replace(array("\r","\n"),'',$menuItems);
  296. if ( empty($menuItems) )
  297. return '';
  298. return <<<EOHTML
  299. <script type="text/javascript">
  300. <!--
  301. function actions_overlib()
  302. {
  303. return overlib("{$menuItems}", CENTER, '', STICKY, MOUSEOFF, 3000, CLOSETEXT, "{$closeText}", WIDTH, 150,
  304. CLOSETITLE, "{$app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE']}", CLOSECLICK,
  305. FGCLASS, 'olOptionsFgClass', CGCLASS, 'olOptionsCgClass', BGCLASS, 'olBgClass',
  306. TEXTFONTCLASS, 'olFontClass', CAPTIONFONTCLASS, 'olOptionsCapFontClass',
  307. CLOSEFONTCLASS, 'olOptionsCloseFontClass');
  308. }
  309. -->
  310. </script>
  311. <a id='$id' onclick='return actions_overlib();' href="#">
  312. {$app_strings['LBL_LINK_ACTIONS']}&nbsp;<img src='{$moreDetailImage}' border='0' />
  313. </a>
  314. EOHTML;
  315. }
  316. /**
  317. * Builds the export link
  318. *
  319. * @return string HTML
  320. */
  321. protected function buildExportLink()
  322. {
  323. global $app_strings;
  324. return "<a href='#' style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' onclick=\"return sListView.send_form(true, '{$this->seed->module_dir}', 'index.php?entryPoint=export','{$app_strings['LBL_LISTVIEW_NO_SELECTED']}')\">{$app_strings['LBL_EXPORT']}</a>";
  325. }
  326. /**
  327. * Builds the massupdate link
  328. *
  329. * @return string HTML
  330. */
  331. protected function buildMassUpdateLink()
  332. {
  333. global $app_strings;
  334. return "<a href='#massupdate_form' style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' onclick=\"document.getElementById('massupdate_form').style.display = '';\">{$app_strings['LBL_MASS_UPDATE']}</a>";
  335. }
  336. /**
  337. * Builds the compose email link
  338. *
  339. * @return string HTML
  340. */
  341. protected function buildComposeEmailLink(
  342. $totalCount
  343. )
  344. {
  345. global $app_strings,$dictionary;
  346. if (!is_array($this->seed->field_defs)) {
  347. return '';
  348. }
  349. $foundEmailField = false;
  350. // Search for fields that look like an email address
  351. foreach ($this->seed->field_defs as $field) {
  352. if(isset($field['type'])&&$field['type']=='link'
  353. &&isset($field['relationship'])&&isset($dictionary[$this->seed->object_name]['relationships'][$field['relationship']])
  354. &&$dictionary[$this->seed->object_name]['relationships'][$field['relationship']]['rhs_module']=='EmailAddresses') {
  355. $foundEmailField = true;
  356. break;
  357. }
  358. }
  359. if (!$foundEmailField) {
  360. return '';
  361. }
  362. $userPref = $GLOBALS['current_user']->getPreference('email_link_type');
  363. $defaultPref = $GLOBALS['sugar_config']['email_default_client'];
  364. if($userPref != '')
  365. $client = $userPref;
  366. else
  367. $client = $defaultPref;
  368. if($client == 'sugar')
  369. $script = "<a href='#' style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' " .
  370. 'onclick="return sListView.send_form_for_emails(true, \''."Emails".'\', \'index.php?module=Emails&action=Compose&ListView=true\',\''.$app_strings['LBL_LISTVIEW_NO_SELECTED'].'\', \''.$this->seed->module_dir.'\', \''.$totalCount.'\', \''.$app_strings['LBL_LISTVIEW_LESS_THAN_TEN_SELECT'].'\')">' .
  371. $app_strings['LBL_EMAIL_COMPOSE'] . '</a>';
  372. else
  373. $script = "<a href='#' style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' " .
  374. "onclick=\"return sListView.use_external_mail_client('{$app_strings['LBL_LISTVIEW_NO_SELECTED']}', '{$_REQUEST['module']}');\">" .
  375. $app_strings['LBL_EMAIL_COMPOSE'] . '</a>';
  376. return $script;
  377. } // fn
  378. /**
  379. * Builds the delete link
  380. *
  381. * @return string HTML
  382. */
  383. protected function buildDeleteLink()
  384. {
  385. global $app_strings;
  386. return "<a href='#' style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' onclick=\"return sListView.send_mass_update('selected', '{$app_strings['LBL_LISTVIEW_NO_SELECTED']}', 1)\">{$app_strings['LBL_DELETE_BUTTON_LABEL']}</a>";
  387. }
  388. /**
  389. * Display the selected object span object
  390. *
  391. * @return string select object span
  392. */
  393. function buildSelectedObjectsSpan($echo = true, $total=0) {
  394. global $app_strings;
  395. $selectedObjectSpan = "<div style='display: inline-block;'>{$app_strings['LBL_LISTVIEW_SELECTED_OBJECTS']}<input style='border: 0px; background: transparent; font-size: inherit; color: inherit' type='text' id='selectCountTop' readonly name='selectCount[]' value='{$total}' /></div>";
  396. return $selectedObjectSpan;
  397. }
  398. /**
  399. * Builds the mail merge link
  400. * The link can be disabled by setting module level duplicate_merge property to false
  401. * in the moudle's vardef file.
  402. *
  403. * @return string HTML
  404. */
  405. protected function buildMergeDuplicatesLink()
  406. {
  407. global $app_strings, $dictionary;
  408. $return_string='';
  409. $return_string.= isset($_REQUEST['module']) ? "&return_module={$_REQUEST['module']}" : "";
  410. $return_string.= isset($_REQUEST['action']) ? "&return_action={$_REQUEST['action']}" : "";
  411. $return_string.= isset($_REQUEST['record']) ? "&return_id={$_REQUEST['record']}" : "";
  412. //need delete and edit access.
  413. if (!(ACLController::checkAccess($this->seed->module_dir, 'edit', true)) or !(ACLController::checkAccess($this->seed->module_dir, 'delete', true))) {
  414. return '';
  415. }
  416. if (isset($dictionary[$this->seed->object_name]['duplicate_merge']) && $dictionary[$this->seed->object_name]['duplicate_merge']==true ) {
  417. return "<a href='#' style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' ".
  418. "onclick='if (sugarListView.get_checks_count()> 1) {sListView.send_form(true, \"MergeRecords\", \"index.php\", \"{$app_strings['LBL_LISTVIEW_NO_SELECTED']}\", \"{$this->seed->module_dir}\",\"$return_string\");} else {alert(\"{$app_strings['LBL_LISTVIEW_TWO_REQUIRED']}\");return false;}'>".
  419. $app_strings['LBL_MERGE_DUPLICATES'].'</a>';
  420. }
  421. return '';
  422. }
  423. /**
  424. * Builds the mail merge link
  425. *
  426. * @return string HTML
  427. */
  428. protected function buildMergeLink(array $modules_array = null)
  429. {
  430. if ( empty($modules_array) ) {
  431. require('modules/MailMerge/modules_array.php');
  432. }
  433. global $current_user, $app_strings;
  434. $admin = new Administration();
  435. $admin->retrieveSettings('system');
  436. $user_merge = $current_user->getPreference('mailmerge_on');
  437. $module_dir = (!empty($this->seed->module_dir) ? $this->seed->module_dir : '');
  438. $str = '';
  439. if ($user_merge == 'on' && isset($admin->settings['system_mailmerge_on']) && $admin->settings['system_mailmerge_on'] && !empty($modules_array[$module_dir])) {
  440. $str = "<a href='#' style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' " .
  441. 'onclick="if (document.MassUpdate.select_entire_list.value==1){document.location.href=\'index.php?action=index&module=MailMerge&entire=true\'} else {return sListView.send_form(true, \'MailMerge\',\'index.php\',\''.$app_strings['LBL_LISTVIEW_NO_SELECTED'].'\');}">' .
  442. $app_strings['LBL_MAILMERGE'].'</a>';
  443. }
  444. return $str;
  445. }
  446. /**
  447. * Builds the add to target list link
  448. *
  449. * @return string HTML
  450. */
  451. protected function buildTargetList()
  452. {
  453. global $app_strings;
  454. $current_query_by_page = base64_encode(serialize(array_merge($_POST, $_GET)));
  455. $js = <<<EOF
  456. if(sugarListView.get_checks_count() < 1) {
  457. alert('{$app_strings['LBL_LISTVIEW_NO_SELECTED']}');
  458. return false;
  459. }
  460. if ( document.forms['targetlist_form'] ) {
  461. var form = document.forms['targetlist_form'];
  462. form.reset;
  463. } else
  464. var form = document.createElement ( 'form' ) ;
  465. form.setAttribute ( 'name' , 'targetlist_form' );
  466. form.setAttribute ( 'method' , 'post' ) ;
  467. form.setAttribute ( 'action' , 'index.php' );
  468. document.body.appendChild ( form ) ;
  469. if ( !form.module ) {
  470. var input = document.createElement('input');
  471. input.setAttribute ( 'name' , 'module' );
  472. input.setAttribute ( 'value' , '{$this->seed->module_dir}' );
  473. input.setAttribute ( 'type' , 'hidden' );
  474. form.appendChild ( input ) ;
  475. var input = document.createElement('input');
  476. input.setAttribute ( 'name' , 'action' );
  477. input.setAttribute ( 'value' , 'TargetListUpdate' );
  478. input.setAttribute ( 'type' , 'hidden' );
  479. form.appendChild ( input ) ;
  480. }
  481. if ( !form.uids ) {
  482. var input = document.createElement('input');
  483. input.setAttribute ( 'name' , 'uids' );
  484. input.setAttribute ( 'type' , 'hidden' );
  485. form.appendChild ( input ) ;
  486. }
  487. if ( !form.prospect_list ) {
  488. var input = document.createElement('input');
  489. input.setAttribute ( 'name' , 'prospect_list' );
  490. input.setAttribute ( 'type' , 'hidden' );
  491. form.appendChild ( input ) ;
  492. }
  493. if ( !form.return_module ) {
  494. var input = document.createElement('input');
  495. input.setAttribute ( 'name' , 'return_module' );
  496. input.setAttribute ( 'type' , 'hidden' );
  497. form.appendChild ( input ) ;
  498. }
  499. if ( !form.return_action ) {
  500. var input = document.createElement('input');
  501. input.setAttribute ( 'name' , 'return_action' );
  502. input.setAttribute ( 'type' , 'hidden' );
  503. form.appendChild ( input ) ;
  504. }
  505. if ( !form.select_entire_list ) {
  506. var input = document.createElement('input');
  507. input.setAttribute ( 'name' , 'select_entire_list' );
  508. input.setAttribute ( 'value', document.MassUpdate.select_entire_list.value);
  509. input.setAttribute ( 'type' , 'hidden' );
  510. form.appendChild ( input ) ;
  511. }
  512. if ( !form.current_query_by_page ) {
  513. var input = document.createElement('input');
  514. input.setAttribute ( 'name' , 'current_query_by_page' );
  515. input.setAttribute ( 'value', '{$current_query_by_page}' );
  516. input.setAttribute ( 'type' , 'hidden' );
  517. form.appendChild ( input ) ;
  518. }
  519. open_popup('ProspectLists','600','400','',true,false,{ 'call_back_function':'set_return_and_save_targetlist','form_name':'targetlist_form','field_to_name_array':{'id':'prospect_list'} } );
  520. EOF;
  521. $js = str_replace(array("\r","\n"),'',$js);
  522. return "<a href='#' style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' onclick=\"$js\">{$app_strings['LBL_ADD_TO_PROSPECT_LIST_BUTTON_LABEL']}</a>";
  523. }
  524. /**
  525. * Display the bottom of the ListView (ie MassUpdate
  526. * @return string contents
  527. */
  528. public function displayEnd()
  529. {
  530. $str = '';
  531. if($this->show_mass_update_form) {
  532. $str .= $this->mass->getMassUpdateForm(true);
  533. $str .= $this->mass->endMassUpdateForm();
  534. }
  535. return $str;
  536. }
  537. /**
  538. * Display the multi select data box etc.
  539. * @return string contents
  540. */
  541. public function getMultiSelectData()
  542. {
  543. $str = "<script>YAHOO.util.Event.addListener(window, \"load\", sListView.check_boxes);</script>\n";
  544. $massUpdateRun = isset($_REQUEST['massupdate']) && $_REQUEST['massupdate'] == 'true';
  545. $uids = empty($_REQUEST['uid']) || $massUpdateRun ? '' : $_REQUEST['uid'];
  546. $select_entire_list = isset($_REQUEST['select_entire_list']) && !$massUpdateRun ? $_REQUEST['select_entire_list'] : 0;
  547. $str .= "<textarea style='display: none' name='uid'>{$uids}</textarea>\n" .
  548. "<input type='hidden' name='select_entire_list' value='{$select_entire_list}'>\n".
  549. "<input type='hidden' name='{$this->moduleString}' value='0'>\n";
  550. return $str;
  551. }
  552. }
  553. ?>