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