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