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