]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/ListView/ListViewDisplay.php
Release 6.1.5
[Github/sugarcrm.git] / include / ListView / ListViewDisplay.php
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
38
39
40
41 require_once('include/ListView/ListViewData.php');
42 require_once('include/MassUpdate.php');
43
44 class ListViewDisplay {
45
46         var $show_mass_update_form = false;
47         var $show_action_dropdown = true;
48         var $rowCount;
49         var $mass = null;
50         var $seed;
51         var $multi_select_popup;
52         var $lvd;
53         var $moduleString;
54         var $export = true;
55         var $multiSelect = true;
56         var $mailMerge = true;
57         var $should_process = true;
58         var $show_plus = false;
59         /*
60          * Used in view.popup.php. Sometimes there are fields on the search form that are not referenced in the listviewdefs. If this
61          * is the case, then the filterFields will be set and the related fields will not be referenced when calling create_new_list_query.
62          */
63         var $mergeDisplayColumns = false;
64     public $actionsMenuExtraItems = array();
65
66         /**
67          * Constructor
68          * @return null
69          */
70         function ListViewDisplay() {
71                 $this->lvd = new ListViewData();
72                 $this->searchColumns = array () ;
73         }
74         function shouldProcess($moduleDir){
75                 if(!empty($GLOBALS['sugar_config']['save_query']) && $GLOBALS['sugar_config']['save_query'] == 'populate_only'){
76                     if(empty($GLOBALS['displayListView']) && (!empty($_REQUEST['clear_query']) || $_REQUEST['module'] == $moduleDir && ((empty($_REQUEST['query']) || $_REQUEST['query'] == 'MSI' )&& (empty($_SESSION['last_search_mod']) || $_SESSION['last_search_mod'] != $moduleDir ) ))){
77                                 $_SESSION['last_search_mod'] = $_REQUEST['module'] ;
78                                 $this->should_process = false;
79                                 return false;
80                         }
81                 }
82                 $this->should_process = true;
83                 return true;
84         }
85
86         /**
87          * Setup the class
88          * @param seed SugarBean Seed SugarBean to use
89          * @param file File Template file to use
90          * @param string $where
91          * @param offset:0 int offset to start at
92          * @param int:-1 $limit
93          * @param string[]:array() $filter_fields
94          * @param array:array() $params
95          *      Potential $params are
96                 $params['distinct'] = use distinct key word
97                 $params['include_custom_fields'] = (on by default)
98                 $params['massupdate'] = true by default;
99         $params['handleMassupdate'] = true by default, have massupdate.php handle massupdates?
100          * @param string:'id' $id_field
101          */
102         function setup($seed, $file, $where, $params = array(), $offset = 0, $limit = -1,  $filter_fields = array(), $id_field = 'id') {
103         $this->should_process = true;
104         if(isset($seed->module_dir) && !$this->shouldProcess($seed->module_dir)){
105                         return false;
106         }
107         if(isset($params['export'])) {
108           $this->export = $params['export'];
109         }
110         if(!empty($params['multiSelectPopup'])) {
111                   $this->multi_select_popup = $params['multiSelectPopup'];
112         }
113                 if(!empty($params['massupdate']) && $params['massupdate'] != false) {
114                         $this->show_mass_update_form = true;
115                         $this->mass = new MassUpdate();
116                         $this->mass->setSugarBean($seed);
117                         if(!empty($params['handleMassupdate']) || !isset($params['handleMassupdate'])) {
118                 $this->mass->handleMassUpdate();
119             }
120                 }
121                 $this->seed = $seed;
122
123         // create filter fields based off of display columns
124         if(empty($filter_fields) || $this->mergeDisplayColumns) {
125             foreach($this->displayColumns as $columnName => $def) {
126
127                $filter_fields[strtolower($columnName)] = true;
128
129             if(isset($this->seed->field_defs[strtolower($columnName)]['type']) &&
130                strtolower($this->seed->field_defs[strtolower($columnName)]['type']) == 'currency' &&
131                isset($this->seed->field_defs['currency_id'])) {
132                         $filter_fields['currency_id'] = true;
133             }
134
135                if(!empty($def['related_fields'])) {
136                     foreach($def['related_fields'] as $field) {
137                         //id column is added by query construction function. This addition creates duplicates
138                         //and causes issues in oracle. #10165
139                         if ($field != 'id') {
140                             $filter_fields[$field] = true;
141                         }
142                     }
143                 }
144                 if (!empty($this->seed->field_defs[strtolower($columnName)]['db_concat_fields'])) {
145                         foreach($this->seed->field_defs[strtolower($columnName)]['db_concat_fields'] as $index=>$field){
146                             if(!isset($filter_fields[strtolower($field)]) || !$filter_fields[strtolower($field)])
147                             {
148                                 $filter_fields[strtolower($field)] = true;
149                             }
150                         }
151                 }
152             }
153             foreach ($this->searchColumns as $columnName => $def )
154             {
155                 $filter_fields[strtolower($columnName)] = true;
156             }
157         }
158
159
160         $data = $this->lvd->getListViewData($seed, $where, $offset, $limit, $filter_fields, $params, $id_field);
161
162                 foreach($this->displayColumns as $columnName => $def)
163                 {
164                         $seedName =  strtolower($columnName);
165             if(!empty($this->lvd->seed->field_defs[$seedName])){
166                 $seedDef = $this->lvd->seed->field_defs[$seedName];
167             }
168
169                         if(empty($this->displayColumns[$columnName]['type'])){
170                                 if(!empty($seedDef['type'])){
171                             $this->displayColumns[$columnName]['type'] = (!empty($seedDef['custom_type']))?$seedDef['custom_type']:$seedDef['type'];
172                         }else{
173                                 $this->displayColumns[$columnName]['type'] = '';
174                         }
175                         }//fi empty(...)
176
177                         if(!empty($seedDef['options'])){
178                                         $this->displayColumns[$columnName]['options'] = $seedDef['options'];
179                         }
180
181                 //C.L. Fix for 11177
182                 if($this->displayColumns[$columnName]['type'] == 'html') {
183                     $cField = $this->seed->custom_fields;
184                        if(isset($cField) && isset($cField->bean->$seedName)) {
185                                 $seedName2 = strtoupper($columnName);
186                                 $htmlDisplay = html_entity_decode($cField->bean->$seedName);
187                                 $count = 0;
188                                 while($count < count($data['data'])) {
189                                         $data['data'][$count][$seedName2] = &$htmlDisplay;
190                                     $count++;
191                                 }
192                         }
193                 }//fi == 'html'
194
195             //Bug 40511, make sure relate fields have the correct module defined
196             if ($this->displayColumns[$columnName]['type'] == "relate" && !empty($seedDef['link']) && empty( $this->displayColumns[$columnName]['module']))
197             {
198                 $link = $seedDef['link'];
199                 if (!empty($this->lvd->seed->field_defs[$link]) && !empty($this->lvd->seed->field_defs[$seedDef['link']]['module']))
200                 {
201                     $this->displayColumns[$columnName]['module'] = $this->lvd->seed->field_defs[$seedDef['link']]['module'];
202                 }
203             }
204
205                         if (!empty($seedDef['sort_on'])) {
206                         $this->displayColumns[$columnName]['orderBy'] = $seedDef['sort_on'];
207                     }
208
209             if(isset($seedDef)){
210                 // Merge the two arrays together, making sure the seedDef doesn't override anything explicitly set in the displayColumns array.
211                 $this->displayColumns[$columnName] = $this->displayColumns[$columnName] + $seedDef;
212             }
213
214                     //C.L. Bug 38388 - ensure that ['id'] is set for related fields
215             if(!isset($this->displayColumns[$columnName]['id']) && isset($this->displayColumns[$columnName]['id_name'])) {
216                $this->displayColumns[$columnName]['id'] = strtoupper($this->displayColumns[$columnName]['id_name']);
217             }
218                 }
219
220                 $this->process($file, $data, $seed->object_name);
221                 return true;
222         }
223
224         /**
225          * Any additional processing
226          * @param file File template file to use
227          * @param data array row data
228          * @param html_var string html string to be passed back and forth
229          */
230         function process($file, $data, $htmlVar) {
231                 $this->rowCount = count($data['data']);
232                 $this->moduleString = $data['pageData']['bean']['moduleDir'] . '2_' . strtoupper($htmlVar) . '_offset';
233         }
234
235         /**
236          * Display the listview
237          * @return string ListView contents
238          */
239         function display() {
240                 if(!$this->should_process) return '';
241                 $str = '';
242                 if($this->multiSelect == true && $this->show_mass_update_form)
243                         $str = $this->mass->getDisplayMassUpdateForm(true, $this->multi_select_popup).$this->mass->getMassUpdateFormHeader($this->multi_select_popup);
244
245         return $str;
246         }
247         /**
248          * Display the select link
249      * @return string select link html
250          * @param echo Bool set true if you want it echo'd, set false to have contents returned
251          */
252         function buildSelectLink($id = 'select_link', $total=0, $pageTotal=0) {
253                 global $app_strings;
254                 if ($pageTotal < 0)
255                         $pageTotal = $total;
256                 $plus = '';
257                 if (!empty($GLOBALS['sugar_config']['disable_count_query']) && $total > $pageTotal) {
258                         $plus = '+';
259                         $this->show_plus = true;
260                 }
261                 $script = "<script>
262                         function select_overlib() {
263                                 return overlib('<a style=\'width: 150px\' 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;({$pageTotal})</a>"
264                         . "<a style=\'width: 150px\' 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;({$total}{$plus})</a>"
265                         . "<a style=\'width: 150px\' class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'sListView.clear_all(document.MassUpdate, \"mass[]\", false);\' href=\'#\'>{$app_strings['LBL_LISTVIEW_NONE']}</a>"
266                         . "', CENTER, '"
267                         . "', STICKY, MOUSEOFF, 3000, CLOSETEXT, '<img border=0 src=" . SugarThemeRegistry::current()->getImageURL('close_inline.gif')
268                         . ">', WIDTH, 150, CLOSETITLE, '" . $app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE'] . "', CLOSECLICK, FGCLASS, 'olOptionsFgClass', "
269                         . "CGCLASS, 'olOptionsCgClass', BGCLASS, 'olBgClass', TEXTFONTCLASS, 'olFontClass', CAPTIONFONTCLASS, 'olOptionsCapFontClass', CLOSEFONTCLASS, 'olOptionsCloseFontClass',TIMEOUT,1000);
270                         }
271                         </script>";
272             $script .= "<a id='$id' onclick='return select_overlib();' href=\"#\"><img src='".SugarThemeRegistry::current()->getImageURL('MoreDetail.png')."' border='0''>"."</a>";
273
274                 return $script;
275         }
276
277         /**
278          * Display the actions link
279          *
280          * @param  string $id link id attribute, defaults to 'actions_link'
281          * @return string HTML source
282          */
283         protected function buildActionsLink(
284             $id = 'actions_link'
285             )
286         {
287             global $app_strings;
288                 $closeText = "<img border=0 src=" . SugarThemeRegistry::current()->getImageURL('close_inline.gif') . " />";
289                 $moreDetailImage = SugarThemeRegistry::current()->getImageURL('MoreDetail.png');
290                 $menuItems = '';
291
292                 // delete
293                 if ( ACLController::checkAccess($this->seed->module_dir,'delete',true) && $this->delete )
294                         $menuItems .= $this->buildDeleteLink();
295                 // compose email
296         if ( isset($_REQUEST['module']) && $_REQUEST['module'] != 'Users' && $_REQUEST['module'] != 'Employees' &&
297             ( SugarModule::get($_REQUEST['module'])->moduleImplements('Company')
298                 || SugarModule::get($_REQUEST['module'])->moduleImplements('Person') ) )
299                         $menuItems .= $this->buildComposeEmailLink($this->data['pageData']['offsets']['total']);
300                 // mass update
301                 $mass = new MassUpdate();
302                 $mass->setSugarBean($this->seed);
303                 if ( ACLController::checkAccess($this->seed->module_dir,'edit',true) && $this->showMassupdateFields && $mass->doMassUpdateFieldsExistForFocus() )
304             $menuItems .= $this->buildMassUpdateLink();
305                 // merge
306                 if ( $this->mailMerge )
307                     $menuItems .= $this->buildMergeLink();
308                 if ( $this->mergeduplicates )
309                     $menuItems .= $this->buildMergeDuplicatesLink();
310                 // add to target list
311                 if ( isset($_REQUEST['module']) && in_array($_REQUEST['module'],array('Contacts','Prospects','Leads','Accounts')))
312                     $menuItems .= $this->buildTargetList();
313                 // export
314                 if ( ACLController::checkAccess($this->seed->module_dir,'export',true) && $this->export )
315                         $menuItems .= $this->buildExportLink();
316
317                 foreach ( $this->actionsMenuExtraItems as $item )
318                     $menuItems .= $item;
319
320                 $menuItems = str_replace('"','\"',$menuItems);
321
322                 if ( empty($menuItems) )
323                     return '';
324
325                 return <<<EOHTML
326 <script type="text/javascript">
327 <!--
328 function actions_overlib()
329 {
330     return overlib("{$menuItems}", CENTER, '', STICKY, MOUSEOFF, 3000, CLOSETEXT, "{$closeText}", WIDTH, 150,
331         CLOSETITLE, "{$app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE']}", CLOSECLICK,
332         FGCLASS, 'olOptionsFgClass', CGCLASS, 'olOptionsCgClass', BGCLASS, 'olBgClass',
333         TEXTFONTCLASS, 'olFontClass', CAPTIONFONTCLASS, 'olOptionsCapFontClass',
334         CLOSEFONTCLASS, 'olOptionsCloseFontClass');
335 }
336 -->
337 </script>
338 <a id='$id' onclick='return actions_overlib();' href="#">
339     {$app_strings['LBL_LINK_ACTIONS']}&nbsp;<img src='{$moreDetailImage}' border='0' />
340 </a>
341 EOHTML;
342         }
343
344         /**
345          * Builds the export link
346          *
347          * @return string HTML
348          */
349         protected function buildExportLink()
350         {
351                 global $app_strings;
352
353                 return "<a href='#' style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' onclick=\"return sListView.send_form(true, '{$_REQUEST['module']}', 'index.php?entryPoint=export','{$app_strings['LBL_LISTVIEW_NO_SELECTED']}')\">{$app_strings['LBL_EXPORT']}</a>";
354         }
355
356         /**
357          * Builds the massupdate link
358          *
359          * @return string HTML
360          */
361         protected function buildMassUpdateLink()
362         {
363                 global $app_strings;
364
365                 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>";
366         }
367
368         /**
369          * Builds the compose email link
370          *
371          * @return string HTML
372          */
373         protected function buildComposeEmailLink(
374             $totalCount
375             )
376         {
377                 global $app_strings,$dictionary;
378
379         if (!is_array($this->seed->field_defs)) {
380             return '';
381         }
382         $foundEmailField = false;
383         // Search for fields that look like an email address
384         foreach ($this->seed->field_defs as $field) {
385             if(isset($field['type'])&&$field['type']=='link'
386                &&isset($field['relationship'])&&isset($dictionary[$this->seed->object_name]['relationships'][$field['relationship']])
387                &&$dictionary[$this->seed->object_name]['relationships'][$field['relationship']]['rhs_module']=='EmailAddresses') {
388                 $foundEmailField = true;
389                 break;
390             }
391         }
392         if (!$foundEmailField) {
393             return '';
394         }
395
396
397                 $userPref = $GLOBALS['current_user']->getPreference('email_link_type');
398                 $defaultPref = $GLOBALS['sugar_config']['email_default_client'];
399                 if($userPref != '')
400                         $client = $userPref;
401                 else
402                         $client = $defaultPref;
403
404                 if($client == 'sugar')
405                         $script = "<a href='#' style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' " .
406                                         'onclick="return sListView.send_form_for_emails(true, \''."Emails".'\', \'index.php?module=Emails&action=Compose&ListView=true\',\''.$app_strings['LBL_LISTVIEW_NO_SELECTED'].'\', \''.$_REQUEST['module'].'\', \''.$totalCount.'\', \''.$app_strings['LBL_LISTVIEW_LESS_THAN_TEN_SELECT'].'\')">' .
407                                         $app_strings['LBL_EMAIL_COMPOSE'] . '</a>';
408                 else
409                         $script = "<a href='#' style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' " .
410                                         "onclick=\"return sListView.use_external_mail_client('{$app_strings['LBL_LISTVIEW_NO_SELECTED']}', '{$_REQUEST['module']}');\">" .
411                                         $app_strings['LBL_EMAIL_COMPOSE'] . '</a>';
412
413                 return $script;
414         } // fn
415         /**
416          * Builds the delete link
417          *
418          * @return string HTML
419          */
420         protected function buildDeleteLink()
421         {
422                 global $app_strings;
423
424                 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>";
425         }
426         /**
427          * Display the selected object span object
428          *
429      * @return string select object span
430          */
431         function buildSelectedObjectsSpan($echo = true, $total=0) {
432                 global $app_strings;
433
434                 $selectedObjectSpan = "{$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}' />";
435
436         return $selectedObjectSpan;
437         }
438     /**
439          * Builds the mail merge link
440          * The link can be disabled by setting module level duplicate_merge property to false
441          * in the moudle's vardef file.
442          *
443          * @return string HTML
444          */
445         protected function buildMergeDuplicatesLink()
446         {
447         global $app_strings, $dictionary;
448
449         $return_string='';
450         $return_string.= isset($_REQUEST['module']) ? "&return_module={$_REQUEST['module']}" : "";
451         $return_string.= isset($_REQUEST['action']) ? "&return_action={$_REQUEST['action']}" : "";
452         $return_string.= isset($_REQUEST['record']) ? "&return_id={$_REQUEST['record']}" : "";
453         //need delete and edit access.
454                 if (!(ACLController::checkAccess( $_REQUEST['module'], 'edit', true)) or !(ACLController::checkAccess( $_REQUEST['module'], 'delete', true))) {
455                         return '';
456                 }
457
458         if (isset($dictionary[$this->seed->object_name]['duplicate_merge']) && $dictionary[$this->seed->object_name]['duplicate_merge']==true ) {
459             return "<a href='#' style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' ".
460                 "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;}'>".
461                 $app_strings['LBL_MERGE_DUPLICATES'].'</a>';
462         }
463
464         return '';
465      }
466     /**
467          * Builds the mail merge link
468          *
469          * @return string HTML
470          */
471         protected function buildMergeLink()
472         {
473         require_once('modules/MailMerge/modules_array.php');
474         global $current_user, $app_strings;
475
476         $admin = new Administration();
477         $admin->retrieveSettings('system');
478         $user_merge = $current_user->getPreference('mailmerge_on');
479         $module_dir = (!empty($this->seed->module_dir) ? $this->seed->module_dir : '');
480         $str = '';
481
482         if ($user_merge == 'on' && isset($admin->settings['system_mailmerge_on']) && $admin->settings['system_mailmerge_on'] && !empty($modules_array[$module_dir])) {
483             $str = "<a href='#' style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' " .
484                                         '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'].'\');}">' .
485                                         $app_strings['LBL_MAILMERGE'].'</a>';
486         }
487         return $str;
488         }
489
490         /**
491          * Builds the add to target list link
492          *
493      * @return string HTML
494          */
495         protected function buildTargetList()
496         {
497         global $app_strings;
498         $temp = array_merge($_GET, $_POST);
499         unset($temp['current_query_by_page']);
500                 $current_query_by_page = base64_encode(serialize($temp));
501
502                 $js = <<<EOF
503             if(sugarListView.get_checks_count() < 1) {
504                 alert('{$app_strings['LBL_LISTVIEW_NO_SELECTED']}');
505                 return false;
506             }
507                         if ( document.forms['targetlist_form'] ) {
508                                 var form = document.forms['targetlist_form'];
509                                 form.reset;
510                         } else
511                                 var form = document.createElement ( 'form' ) ;
512                         form.setAttribute ( 'name' , 'targetlist_form' );
513                         form.setAttribute ( 'method' , 'post' ) ;
514                         form.setAttribute ( 'action' , 'index.php' );
515                         document.body.appendChild ( form ) ;
516                         if ( !form.module ) {
517                             var input = document.createElement('input');
518                             input.setAttribute ( 'name' , 'module' );
519                             input.setAttribute ( 'value' , '{$_REQUEST['module']}' );
520                             input.setAttribute ( 'type' , 'hidden' );
521                             form.appendChild ( input ) ;
522                             var input = document.createElement('input');
523                             input.setAttribute ( 'name' , 'action' );
524                             input.setAttribute ( 'value' , 'TargetListUpdate' );
525                             input.setAttribute ( 'type' , 'hidden' );
526                             form.appendChild ( input ) ;
527                         }
528                         if ( !form.uids ) {
529                             var input = document.createElement('input');
530                             input.setAttribute ( 'name' , 'uids' );
531                             input.setAttribute ( 'type' , 'hidden' );
532                             form.appendChild ( input ) ;
533                         }
534                         if ( !form.prospect_list ) {
535                             var input = document.createElement('input');
536                             input.setAttribute ( 'name' , 'prospect_list' );
537                             input.setAttribute ( 'type' , 'hidden' );
538                             form.appendChild ( input ) ;
539                         }
540                         if ( !form.return_module ) {
541                             var input = document.createElement('input');
542                             input.setAttribute ( 'name' , 'return_module' );
543                             input.setAttribute ( 'type' , 'hidden' );
544                             form.appendChild ( input ) ;
545                         }
546                         if ( !form.return_action ) {
547                             var input = document.createElement('input');
548                             input.setAttribute ( 'name' , 'return_action' );
549                             input.setAttribute ( 'type' , 'hidden' );
550                             form.appendChild ( input ) ;
551                         }
552                         if ( !form.select_entire_list ) {
553                             var input = document.createElement('input');
554                             input.setAttribute ( 'name' , 'select_entire_list' );
555                             input.setAttribute ( 'value', document.MassUpdate.select_entire_list.value);
556                             input.setAttribute ( 'type' , 'hidden' );
557                             form.appendChild ( input ) ;
558                         }
559                         if ( !form.current_query_by_page ) {
560                             var input = document.createElement('input');
561                             input.setAttribute ( 'name' , 'current_query_by_page' );
562                             input.setAttribute ( 'value', '{$current_query_by_page}' );
563                             input.setAttribute ( 'type' , 'hidden' );
564                             form.appendChild ( input ) ;
565                         }
566                         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'} } );
567 EOF;
568         $js = str_replace(array("\r","\n"),'',$js);
569         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>";
570         }
571         /**
572          * Display the bottom of the ListView (ie MassUpdate
573          * @return string contents
574          */
575         function displayEnd() {
576                 $str = '';
577                 if($this->show_mass_update_form) {
578                         $str .= $this->mass->getMassUpdateForm(true);
579                         $str .= $this->mass->endMassUpdateForm();
580                 }
581
582                 return $str;
583         }
584
585     /**
586      * Display the multi select data box etc.
587      * @return string contents
588      */
589         function getMultiSelectData() {
590                 $str = "<script>YAHOO.util.Event.addListener(window, \"load\", sListView.check_boxes);</script>\n";
591
592                 $massUpdateRun = isset($_REQUEST['massupdate']) && $_REQUEST['massupdate'] == 'true';
593                 $uids = empty($_REQUEST['uid']) || $massUpdateRun ? '' : $_REQUEST['uid'];
594                 $select_entire_list = isset($_REQUEST['select_entire_list']) && !$massUpdateRun ? $_REQUEST['select_entire_list'] : 0;
595
596                 $str .= "<textarea style='display: none' name='uid'>{$uids}</textarea>\n" .
597                                 "<input type='hidden' name='select_entire_list' value='{$select_entire_list}'>\n".
598                                 "<input type='hidden' name='{$this->moduleString}' value='0'>\n".
599                         "<input type='hidden' name='show_plus' value='{$this->show_plus}'>\n";
600                 return $str;
601         }
602
603 }
604 ?>