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-2012 SugarCRM Inc.
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.
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
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
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.
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.
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 ********************************************************************************/
39 require_once('include/EditView/EditView2.php');
42 * MassUpdate class for updating multiple records at once
48 * internal sugarbean reference
50 var $sugarbean = null;
53 * where clauses used to filter rows that have to be updated
55 var $where_clauses = '';
58 * set the sugar bean to its internal member
59 * @param sugar bean reference
61 function setSugarBean($sugar)
63 $this->sugarbean = $sugar;
67 * get the massupdate form
68 * @param bool boolean need to execute the massupdate form or not
69 * @param multi_select_popup booleanif it is a multi-select value
71 function getDisplayMassUpdateForm($bool, $multi_select_popup = false)
74 require_once('include/formbase.php');
76 if(!$multi_select_popup)
77 $form = '<form action="index.php" method="post" name="displayMassUpdate" id="displayMassUpdate">' . "\n";
79 $form = '<form action="index.php" method="post" name="MassUpdate" id="MassUpdate">' . "\n";
83 $form .= '<input type="hidden" name="mu" value="false" />' . "\n";
87 $form .= '<input type="hidden" name="mu" value="true" />' . "\n";
90 $form .= getAnyToForm('mu', true);
91 if(!$multi_select_popup) $form .= "</form>\n";
96 * returns the mass update's html form header
97 * @param multi_select_popup boolean if it is a mult-select or not
99 function getMassUpdateFormHeader($multi_select_popup = false)
101 global $sugar_version;
102 global $sugar_config;
103 global $current_user;
105 unset($_REQUEST['current_query_by_page']);
106 unset($_REQUEST[session_name()]);
107 unset($_REQUEST['PHPSESSID']);
108 $query = base64_encode(serialize($_REQUEST));
110 $bean = loadBean($_REQUEST['module']);
111 $order_by_name = $bean->module_dir.'2_'.strtoupper($bean->object_name).'_ORDER_BY' ;
112 $lvso = isset($_REQUEST['lvso'])?$_REQUEST['lvso']:"";
113 $request_order_by_name = isset($_REQUEST[$order_by_name])?$_REQUEST[$order_by_name]:"";
114 $action = isset($_REQUEST['action'])?$_REQUEST['action']:"";
115 $module = isset($_REQUEST['module'])?$_REQUEST['module']:"";
116 if($multi_select_popup)
119 $tempString = "<form action='index.php' method='post' name='MassUpdate' id='MassUpdate' onsubmit=\"return check_form('MassUpdate');\">\n"
120 . "<input type='hidden' name='return_action' value='{$action}' />\n"
121 . "<input type='hidden' name='return_module' value='{$module}' />\n"
122 . "<input type='hidden' name='massupdate' value='true' />\n"
123 . "<input type='hidden' name='delete' value='false' />\n"
124 . "<input type='hidden' name='merge' value='false' />\n"
125 . "<input type='hidden' name='current_query_by_page' value='{$query}' />\n"
126 . "<input type='hidden' name='module' value='{$module}' />\n"
127 . "<input type='hidden' name='action' value='MassUpdate' />\n"
128 . "<input type='hidden' name='lvso' value='{$lvso}' />\n"
129 . "<input type='hidden' name='{$order_by_name}' value='{$request_order_by_name}' />\n";
131 // cn: bug 9103 - MU navigation in emails is broken
132 if($_REQUEST['module'] == 'Emails') {
134 // determine "type" - inbound, archive, etc.
135 if (isset($_REQUEST['type'])) {
136 $type = $_REQUEST['type'];
140 <input type='hidden' name='type' value="{$type}" />
141 <input type='hidden' name='ie_assigned_user_id' value="{$current_user->id}" />
149 * Executes the massupdate form
150 * @param displayname Name to display in the popup window
151 * @param varname name of the variable
153 function handleMassUpdate(){
155 require_once('include/formbase.php');
156 global $current_user, $db, $disable_date_format, $timedate;
158 foreach($_POST as $post=>$value){
159 if(is_array($value)){
161 unset($_POST[$post]);
163 }elseif(strlen($value) == 0){
164 if( isset($this->sugarbean->field_defs[$post]) && $this->sugarbean->field_defs[$post]['type'] == 'radioenum' && isset($_POST[$post]) ){
167 unset($_POST[$post]);
171 if(is_string($value) && isset($this->sugarbean->field_defs[$post])) {
172 if(($this->sugarbean->field_defs[$post]['type'] == 'bool'
173 || (!empty($this->sugarbean->field_defs[$post]['custom_type']) && $this->sugarbean->field_defs[$post]['custom_type'] == 'bool'
175 if(strcmp($value, '2') == 0)$_POST[$post] = 0;
176 if(!empty($this->sugarbean->field_defs[$post]['dbType']) && strcmp($this->sugarbean->field_defs[$post]['dbType'], 'varchar') == 0 ){
177 if(strcmp($value, '1') == 0 )$_POST[$post] = 'on';
178 if(strcmp($value, '2') == 0)$_POST[$post] = 'off';
182 if( ($this->sugarbean->field_defs[$post]['type'] == 'radioenum' && isset($_POST[$post]) && strlen($value) == 0)
183 || ($this->sugarbean->field_defs[$post]['type'] == 'enum' && $value == '__SugarMassUpdateClearField__') // Set to '' if it's an explicit clear
187 if ($this->sugarbean->field_defs[$post]['type'] == 'bool') {
188 $this->checkClearField($post, $value);
190 if($this->sugarbean->field_defs[$post]['type'] == 'date' && !empty($_POST[$post])){
191 $_POST[$post] = $timedate->to_db_date($_POST[$post], false);
193 if($this->sugarbean->field_defs[$post]['type'] == 'datetime' && !empty($_POST[$post])){
194 $_POST[$post] = $timedate->to_db($this->date_to_dateTime($post, $value));
196 if($this->sugarbean->field_defs[$post]['type'] == 'datetimecombo' && !empty($_POST[$post])){
197 $_POST[$post] = $timedate->to_db($_POST[$post]);
202 //We need to disable_date_format so that date values for the beans remain in database format
203 //notice we make this call after the above section since the calls to TimeDate class there could wind up
204 //making it's way to the UserPreferences objects in which case we want to enable the global date formatting
205 //to correctly retrieve the user's date format preferences
206 $old_value = $disable_date_format;
207 $disable_date_format = true;
209 if(!empty($_REQUEST['uid'])) $_POST['mass'] = explode(',', $_REQUEST['uid']); // coming from listview
210 elseif(isset($_REQUEST['entire']) && empty($_POST['mass'])) {
211 if(empty($order_by))$order_by = '';
212 $ret_array = create_export_query_relate_link_patch($_REQUEST['module'], $this->searchFields, $this->where_clauses);
213 if(!isset($ret_array['join'])) {
214 $ret_array['join'] = '';
216 $query = $this->sugarbean->create_export_query($order_by, $ret_array['where'], $ret_array['join']);
217 $result = $db->query($query,true);
219 while($val = $db->fetchByAssoc($result,false))
221 array_push($new_arr, $val['id']);
223 $_POST['mass'] = $new_arr;
226 if(isset($_POST['mass']) && is_array($_POST['mass']) && $_REQUEST['massupdate'] == 'true'){
230 foreach($_POST['mass'] as $id){
234 if(isset($_POST['Delete'])){
235 $this->sugarbean->retrieve($id);
236 if($this->sugarbean->ACLAccess('Delete')){
237 //Martin Hu Bug #20872
238 if($this->sugarbean->object_name == 'EmailMan'){
239 $query = "DELETE FROM emailman WHERE id = '" . $this->sugarbean->id . "'";
243 $this->sugarbean->mark_deleted($id);
248 if($this->sugarbean->object_name == 'Contact' && isset($_POST['Sync'])){ // special for contacts module
249 if($_POST['Sync'] == 'true') {
250 $this->sugarbean->retrieve($id);
251 if($this->sugarbean->ACLAccess('Save')){
252 if($this->sugarbean->object_name == 'Contact'){
254 $this->sugarbean->contacts_users_id = $current_user->id;
255 $this->sugarbean->save(false);
259 elseif($_POST['Sync'] == 'false') {
260 $this->sugarbean->retrieve($id);
261 if($this->sugarbean->ACLAccess('Save')){
262 if($this->sugarbean->object_name == 'Contact'){
263 if (!isset($this->sugarbean->users))
265 $this->sugarbean->load_relationship('user_sync');
267 $this->sugarbean->contacts_users_id = null;
268 $this->sugarbean->user_sync->delete($this->sugarbean->id, $current_user->id);
272 } //end if for special Contact handling
275 //Create a new instance to clear values and handle additional updates to bean's 2,3,4...
276 $className = get_class($this->sugarbean);
277 $this->sugarbean = new $className();
280 $this->sugarbean->retrieve($id);
283 if($this->sugarbean->ACLAccess('Save')){
284 $_POST['record'] = $id;
285 $_GET['record'] = $id;
286 $_REQUEST['record'] = $id;
287 $newbean=$this->sugarbean;
289 $old_reports_to_id = null;
290 if(!empty($_POST['reports_to_id']) && $newbean->reports_to_id != $_POST['reports_to_id']) {
291 $old_reports_to_id = empty($newbean->reports_to_id) ? 'null' : $newbean->reports_to_id;
294 $check_notify = FALSE;
296 if (isset( $this->sugarbean->assigned_user_id)) {
297 $old_assigned_user_id = $this->sugarbean->assigned_user_id;
298 if (!empty($_POST['assigned_user_id'])
299 && ($old_assigned_user_id != $_POST['assigned_user_id'])
300 && ($_POST['assigned_user_id'] != $current_user->id)) {
301 $check_notify = TRUE;
305 //Call include/formbase.php, but do not call retrieve again
306 populateFromPost('', $newbean, true);
307 $newbean->save_from_post = false;
309 if (!isset($_POST['parent_id'])) {
310 $newbean->parent_type = null;
313 $email_address_id = '';
314 if (!empty($_POST['optout_primary'])) {
315 $optout_flag_value = 0;
316 if ($_POST['optout_primary'] == 'true') {
317 $optout_flag_value = 1;
319 if (isset($this->sugarbean->emailAddress)) {
320 if (!empty($this->sugarbean->emailAddress->addresses)) {
321 foreach($this->sugarbean->emailAddress->addresses as $key =>$emailAddressRow) {
322 if ($emailAddressRow['primary_address'] == '1') {
323 $email_address_id = $emailAddressRow['email_address_id'];
333 $newbean->save($check_notify);
334 if (!empty($email_address_id)) {
335 $query = "UPDATE email_addresses SET opt_out = {$optout_flag_value} where id = '{$emailAddressRow['email_address_id']}'";
336 $GLOBALS['db']->query($query);
340 if(!empty($old_reports_to_id) && method_exists($newbean, 'update_team_memberships')) {
341 $old_id = $old_reports_to_id == 'null' ? '' : $old_reports_to_id;
348 $disable_date_format = $old_value;
351 * Displays the massupdate form
353 function getMassUpdateForm(
354 $hideDeleteIfNoFieldsAvailable = false
358 global $current_user;
360 if($this->sugarbean->bean_implements('ACL') && ( !ACLController::checkAccess($this->sugarbean->module_dir, 'edit', true) || !ACLController::checkAccess($this->sugarbean->module_dir, 'massupdate', true) ) ){
364 $lang_delete = translate('LBL_DELETE');
365 $lang_update = translate('LBL_UPDATE');
366 $lang_confirm= translate('NTC_DELETE_CONFIRMATION_MULTIPLE');
367 $lang_sync = translate('LBL_SYNC_CONTACT');
368 $lang_oc_status = translate('LBL_OC_STATUS');
369 $lang_unsync = translate('LBL_UNSYNC');
370 $lang_archive = translate('LBL_ARCHIVE');
371 $lang_optout_primaryemail = $app_strings['LBL_OPT_OUT_FLAG_PRIMARY'];
375 $html = "<div id='massupdate_form' style='display:none;'><table width='100%' cellpadding='0' cellspacing='0' border='0' class='formHeader h3Row'><tr><td nowrap><h3><span>" . $app_strings['LBL_MASS_UPDATE']."</h3></td></tr></table>";
376 $html .= "<div id='mass_update_div'><table cellpadding='0' cellspacing='1' border='0' width='100%' class='edit view' id='mass_update_table'>";
380 if($this->sugarbean->object_name == 'Contact')
382 $html .= "<tr><td width='15%' scope='row'>$lang_sync</td><td width='35%' class='dataField'><select name='Sync'><option value=''>{$GLOBALS['app_strings']['LBL_NONE']}</option><option value='false'>{$GLOBALS['app_list_strings']['checkbox_dom']['2']}</option><option value='true'>{$GLOBALS['app_list_strings']['checkbox_dom']['1']}</option></select></td>";
384 } else if($this->sugarbean->object_name == 'Employee') {
385 $this->sugarbean->field_defs['employee_status']['type'] = 'enum';
386 $this->sugarbean->field_defs['employee_status']['massupdate'] = true;
387 $this->sugarbean->field_defs['employee_status']['options'] = 'employee_status_dom';
388 } else if($this->sugarbean->object_name == 'InboundEmail'){
389 $this->sugarbean->field_defs['status']['type'] = 'enum';
390 $this->sugarbean->field_defs['status']['options'] = 'user_status_dom';
393 //These fields should never appear on mass update form
394 static $banned = array('date_modified'=>1, 'date_entered'=>1, 'created_by'=>1, 'modified_user_id'=>1, 'deleted'=>1,'modified_by_name'=>1,);
396 foreach($this->sugarbean->field_defs as $field)
398 if(!isset($banned[$field['name']]) && (!isset($field['massupdate']) || !empty($field['massupdate'])))
407 if(isset($field['vname']))
409 $displayname = translate($field['vname']);
414 if(isset($field['type']) && $field['type'] == 'relate' && isset($field['id_name']) && $field['id_name'] == 'assigned_user_id')
416 $field['type'] = 'assigned_user_name';
419 if(isset($field['custom_type']))
421 $field['type'] = $field['custom_type'];
424 if(isset($field['type']))
426 switch($field["type"])
429 // bug 14691: avoid laying out an empty cell in the <table>
430 $handleRelationship = $this->handleRelationship($displayname, $field);
431 if ($handleRelationship != '')
434 $newhtml .= $handleRelationship;
437 case "parent":$even = !$even; $newhtml .=$this->addParent($displayname, $field); break;
439 if(!empty($field['massupdate']) && empty($field['auto_increment']))
441 $even = !$even; $newhtml .=$this->addInputType($displayname, $field);
444 case "contact_id":$even = !$even; $newhtml .=$this->addContactID($displayname, $field["name"]); break;
445 case "assigned_user_name":$even = !$even; $newhtml .= $this->addAssignedUserID($displayname, $field["name"]); break;
446 case "account_id":$even = !$even; $newhtml .= $this->addAccountID($displayname, $field["name"]); break;
447 case "account_name":$even = !$even; $newhtml .= $this->addAccountID($displayname, $field["id_name"]); break;
448 case "bool": $even = !$even; $newhtml .= $this->addBool($displayname, $field["name"]); break;
451 if(!empty($field['isMultiSelect']))
453 $even = !$even; $newhtml .= $this->addStatusMulti($displayname, $field["name"], translate($field["options"])); break;
454 }else if(!empty($field['options'])) {
455 $even = !$even; $newhtml .= $this->addStatus($displayname, $field["name"], translate($field["options"])); break;
456 }else if(!empty($field['function'])){
457 $functionValue = $this->getFunctionValue($this->sugarbean, $field);
458 $even = !$even; $newhtml .= $this->addStatus($displayname, $field["name"], $functionValue); break;
462 $even = !$even; $newhtml .= $this->addRadioenum($displayname, $field["name"] , translate($field["options"])); break;
463 case "datetimecombo":
464 $even = !$even; $newhtml .= $this->addDatetime($displayname, $field["name"]); break;
466 case "date":$even = !$even; $newhtml .= $this->addDate($displayname, $field["name"]); break;
468 $newhtml .= $this->addDefault($displayname, $field, $even); break;
480 if(!in_array($newhtml, array('<tr>', '</tr>', '<tr></tr>', '<tr><td></td></tr>'))){
487 if ($this->sugarbean->object_name == 'Contact' ||
488 $this->sugarbean->object_name == 'Account' ||
489 $this->sugarbean->object_name == 'Lead' ||
490 $this->sugarbean->object_name == 'Prospect') {
492 $html .= "<tr><td width='15%' scope='row' class='dataLabel'>$lang_optout_primaryemail</td><td width='35%' class='dataField'><select name='optout_primary'><option value=''>{$GLOBALS['app_strings']['LBL_NONE']}</option><option value='false'>{$GLOBALS['app_list_strings']['checkbox_dom']['2']}</option><option value='true'>{$GLOBALS['app_list_strings']['checkbox_dom']['1']}</option></select></td></tr>";
497 $html .= "<table cellpadding='0' cellspacing='0' border='0' width='100%'><tr><td class='buttons'><input onclick='return sListView.send_mass_update(\"selected\", \"{$app_strings['LBL_LISTVIEW_NO_SELECTED']}\")' type='submit' id='update_button' name='Update' value='{$lang_update}' class='button'> <input onclick='javascript:toggleMassUpdateForm();' type='button' id='cancel_button' name='Cancel' value='{$GLOBALS['app_strings']['LBL_CANCEL_BUTTON_LABEL']}' class='button'>";
498 // TODO: allow ACL access for Delete to be set false always for users
499 // if($this->sugarbean->ACLAccess('Delete', true) && $this->sugarbean->object_name != 'User') {
500 // global $app_list_strings;
501 // $html .=" <input id='delete_button' type='submit' name='Delete' value='{$lang_delete}' onclick='return confirm(\"{$lang_confirm}\") && sListView.send_mass_update(\"selected\", \"{$app_strings['LBL_LISTVIEW_NO_SELECTED']}\", 1)' class='button'>";
504 // only for My Inbox views - to allow CSRs to have an "Archive" emails feature to get the email "out" of their inbox.
505 if($this->sugarbean->object_name == 'Email'
506 && (isset($_REQUEST['assigned_user_id']) && !empty($_REQUEST['assigned_user_id']))
507 && (isset($_REQUEST['type']) && !empty($_REQUEST['type']) && $_REQUEST['type'] == 'inbound')) {
509 <input type='button' name='archive' value="{$lang_archive}" class='button' onClick='setArchived();'>
510 <input type='hidden' name='ie_assigned_user_id' value="{$current_user->id}">
511 <input type='hidden' name='ie_type' value="inbound">
515 $html .= "</td></tr></table></div></div>";
519 function toggleMassUpdateForm(){
520 document.getElementById('massupdate_form').style.display = 'none';
529 //If no fields are found, render either a form that still permits Mass Update deletes or just display a message that no fields are available
530 $html = "<div id='massupdate_form' style='display:none;'><table width='100%' cellpadding='0' cellspacing='0' border='0' class='formHeader h3Row'><tr><td nowrap><h3><span>" . $app_strings['LBL_MASS_UPDATE']."</h3></td></tr></table>";
531 if($this->sugarbean->ACLAccess('Delete', true) && !$hideDeleteIfNoFieldsAvailable){
532 $html .= "<table cellpadding='0' cellspacing='0' border='0' width='100%'><tr><td><input type='submit' name='Delete' value='$lang_delete' onclick=\"return confirm('{$lang_confirm}')\" class='button'></td></tr></table></div>";
534 $html .= $app_strings['LBL_NO_MASS_UPDATE_FIELDS_AVAILABLE'] . "</div>";
540 function getFunctionValue($focus, $vardef){
541 $function = $vardef['function'];
542 if(is_array($function) && isset($function['name'])){
543 $function = $vardef['function']['name'];
545 $function = $vardef['function'];
547 if(!empty($vardef['function']['returns']) && $vardef['function']['returns'] == 'html'){
548 if(!empty($vardef['function']['include'])){
549 require_once($vardef['function']['include']);
551 return $function($focus, $vardef['name'], '', 'MassUpdate');
553 return $function($focus, $vardef['name'], '', 'MassUpdate');
558 * Returns end of the massupdate form
560 function endMassUpdateForm(){
565 * Decides which popup HTML code is needed for mass updating
566 * @param displayname Name to display in the popup window
567 * @param field name of the field to update
569 function handleRelationship($displayname, $field)
572 if(isset($field['module']))
574 if ($field['name'] == 'reports_to_name' && ($field['module'] == 'Users' || $field['module'] == 'Employee') )
575 return $this->addUserName($displayname, $field['name'], $field['id_name'], $field['module']);
577 switch($field['module'])
580 $ret_val = $this->addAccountID($displayname, $field['name'], $field['id_name']);
583 $ret_val = $this->addGenericModuleID($displayname, $field['name'], $field['id_name'], "Contacts");
586 $ret_val = $this->addGenericModuleID($displayname, $field['name'], $field['id_name'], "Users");
589 $ret_val = $this->addGenericModuleID($displayname, $field['name'], $field['id_name'], "Employee");
592 $ret_val = $this->addGenericModuleID($displayname, $field['name'], $field['id_name'], "Releases");
595 if(!empty($field['massupdate'])){
596 $ret_val = $this->addGenericModuleID($displayname, $field['name'], $field['id_name'], $field['module']);
605 * Add a parent selection popup window
606 * @param displayname Name to display in the popup window
607 * @param field_name name of the field
609 function addParent($displayname, $field){
610 global $app_strings, $app_list_strings;
612 ///////////////////////////////////////
616 $popup_request_data = array(
617 'call_back_function' => 'set_return',
618 'form_name' => 'MassUpdate',
619 'field_to_name_array' => array(
621 'name' => "parent_name",
625 $json = getJSONobj();
626 $encoded_popup_request_data = $json->encode($popup_request_data);
629 'form' => 'MassUpdate',
631 'modules' => array("Accounts"),
633 'field_list' => array('name', 'id'),
634 'populate_list' => array("mass_parent_name", "mass_parent_id"),
635 'conditions' => array(array('name'=>'name','op'=>'like_custom','end'=>'%','value'=>'')),
636 'limit' => '30','no_match_text' => $app_strings['ERR_SQS_NO_MATCH']);
637 $qsName = $json->encode($qsName);
640 ///////////////////////////////////////
642 $change_parent_button = "<span class='id-ff'><button title='".$app_strings['LBL_SELECT_BUTTON_TITLE']."' type='button' class='button' value='".$app_strings['LBL_SELECT_BUTTON_LABEL']
643 ."' name='button_parent_name' onclick='open_popup(document.MassUpdate.{$field['type_name']}.value, 600, 400, \"\", true, false, {$encoded_popup_request_data});'>
644 ".SugarThemeRegistry::current()->getImage("id-ff-select", '', null, null, ".png", $app_strings['LBL_ID_FF_SELECT'])."
646 $parent_type = $field['parent_type'];
647 $parent_types = $app_list_strings[$parent_type];
648 $disabled_parent_types = ACLController::disabledModuleList($parent_types,false, 'list');
649 foreach($disabled_parent_types as $disabled_parent_type) {
650 unset($parent_types[$disabled_parent_type]);
652 $types = get_select_options_with_id($parent_types, '');
654 $pattern = "/\n<OPTION.*".$app_strings['LBL_NONE']."<\/OPTION>/";
655 $types = preg_replace($pattern, "", $types);
658 $json = getJSONobj();
659 $disabled_parent_types = $json->encode($disabled_parent_types);
662 <td width="15%" scope="row">{$displayname} </td>
664 <table width='100%' border='0' cellspacing='0' cellpadding='0'>
667 <select name='{$field['type_name']}' id='mass_{$field['type_name']}'>
672 <input name='{$field['id_name']}' id='mass_{$field['id_name']}' type='hidden' value=''>
673 <input name='parent_name' id='mass_parent_name' class='sqsEnabled' autocomplete='off'
674 type='text' value=''>
675 $change_parent_button
680 <script type="text/javascript">
682 var disabledModules='{$disabled_parent_types}';
683 if(typeof sqs_objects == 'undefined'){
684 var sqs_objects = new Array;
686 sqs_objects['MassUpdate_parent_name'] = $qsName;
687 registerSingleSmartInputListener(document.getElementById('mass_parent_name'));
688 addToValidateBinaryDependency('MassUpdate', 'parent_name', 'alpha', false, '{$app_strings['ERR_SQS_NO_MATCH_FIELD']} {$app_strings['LBL_ASSIGNED_TO']}','parent_id');
690 document.getElementById('mass_{$field['type_name']}').onchange = function()
692 document.MassUpdate.parent_name.value="";
693 document.MassUpdate.parent_id.value="";
695 new_module = document.forms["MassUpdate"].elements["parent_type"].value;
697 if(typeof(disabledModules[new_module]) != 'undefined') {
698 sqs_objects["MassUpdate_parent_name"]["disable"] = true;
699 document.forms["MassUpdate"].elements["parent_name"].readOnly = true;
701 sqs_objects["MassUpdate_parent_name"]["disable"] = false;
702 document.forms["MassUpdate"].elements["parent_name"].readOnly = false;
704 sqs_objects["MassUpdate_parent_name"]["modules"] = new Array(new_module);
707 checkParentType(document.MassUpdate.parent_type.value, document.MassUpdate.button_parent_name);
715 * Add a generic input type='text' field
716 * @param displayname Name to display in the popup window
717 * @param field_name name of the field
719 function addInputType($displayname, $varname){
721 $displayname = addslashes($displayname);
723 <td scope="row" width="20%">$displayname</td>
724 <td class='dataField' width="30%"><input type="text" name='$varname' size="12" id='{$varname}' maxlength='10' value=""></td>
725 <script> addToValidate('MassUpdate','$varname','int',false,'$displayname');</script>
732 * Add a generic widget to lookup Users.
733 * @param displayname Name to display in the popup window
734 * @param varname name of the variable
735 * @param id_name name of the id in vardef
736 * @param mod_type name of the module, either "Contact" or "Releases" currently
738 function addUserName($displayname, $varname, $id_name='', $mod_type){
742 $id_name = strtolower($mod_type)."_id";
744 ///////////////////////////////////////
747 $reportsDisplayName = showFullName() ? 'name' : 'user_name';
748 $popup_request_data = array(
749 'call_back_function' => 'set_return',
750 'form_name' => 'MassUpdate',
751 'field_to_name_array' => array(
752 'id' => "{$id_name}",
753 "$reportsDisplayName" => "{$varname}",
757 $json = getJSONobj();
758 $encoded_popup_request_data = $json->encode($popup_request_data);
761 'form' => 'MassUpdate',
762 'method' => 'get_user_array',
763 'modules' => array("{$mod_type}"),
765 'field_list' => array('user_name', 'id'),
766 'populate_list' => array("mass_{$varname}", "mass_{$id_name}"),
767 'conditions' => array(array('name'=>'name','op'=>'like_custom','end'=>'%','value'=>'')),
768 'limit' => '30','no_match_text' => $app_strings['ERR_SQS_NO_MATCH']);
769 $qsName = $json->encode($qsName);
771 ///////////////////////////////////////
774 <td width='15%' scope='row' class='dataLabel'>$displayname</td>
775 <td width='35%' class='dataField'>
776 <input name='{$varname}' id='mass_{$varname}' class='sqsEnabled' autocomplete='off' type='text' value=''>
777 <input name='{$id_name}' id='mass_{$id_name}' type='hidden' value=''>
778 <input title='{$app_strings['LBL_SELECT_BUTTON_TITLE']}'
779 type='button' class='button' value='{$app_strings['LBL_SELECT_BUTTON_LABEL']}' name='button'
780 onclick='open_popup("$mod_type", 600, 400, "", true, false, {$encoded_popup_request_data});'
783 <script type="text/javascript">
785 if(typeof sqs_objects == 'undefined'){
786 var sqs_objects = new Array;
788 sqs_objects['MassUpdate_{$varname}'] = $qsName;
789 registerSingleSmartInputListener(document.getElementById('mass_{$varname}'));
790 addToValidateBinaryDependency('MassUpdate', '{$varname}', 'alpha', false, '{$app_strings['ERR_SQS_NO_MATCH_FIELD']} {$app_strings['LBL_ASSIGNED_TO']}','{$id_name}');
798 * Add a generic module popup selection popup window HTML code.
799 * Currently supports Contact and Releases
800 * @param displayname Name to display in the popup window
801 * @param varname name of the variable
802 * @param id_name name of the id in vardef
803 * @param mod_type name of the module, either "Contact" or "Releases" currently
805 function addGenericModuleID($displayname, $varname, $id_name='', $mod_type){
809 $id_name = strtolower($mod_type)."_id";
811 ///////////////////////////////////////
815 $popup_request_data = array(
816 'call_back_function' => 'set_return',
817 'form_name' => 'MassUpdate',
818 'field_to_name_array' => array(
819 'id' => "{$id_name}",
820 'name' => "{$varname}",
824 $json = getJSONobj();
825 $encoded_popup_request_data = $json->encode($popup_request_data);
828 'form' => 'MassUpdate',
830 'modules' => array("{$mod_type}"),
832 'field_list' => array('name', 'id'),
833 'populate_list' => array("mass_{$varname}", "mass_{$id_name}"),
834 'conditions' => array(array('name'=>'name','op'=>'like_custom','end'=>'%','value'=>'')),
835 'limit' => '30','no_match_text' => $app_strings['ERR_SQS_NO_MATCH']);
836 $qsName = $json->encode($qsName);
837 $img = SugarThemeRegistry::current()->getImageURL("id-ff-select.png");
839 ///////////////////////////////////////
842 <td width='15%' scope='row' class='dataLabel'>$displayname</td>
843 <td width='35%' class='dataField'>
844 <input name='{$varname}' id='mass_{$varname}' class='sqsEnabled' autocomplete='off' type='text' value=''>
845 <input name='{$id_name}' id='mass_{$id_name}' type='hidden' value=''>
846 <span class="id-ff multiple">
847 <button title='{$app_strings['LBL_SELECT_BUTTON_TITLE']}'
848 type='button' class='button' value='{$app_strings['LBL_SELECT_BUTTON_LABEL']}' name='button'
849 onclick='open_popup("$mod_type", 600, 400, "", true, false, {$encoded_popup_request_data});'
850 /><img alt="$img" src="$img"></button></span>
852 <script type="text/javascript">
854 if(typeof sqs_objects == 'undefined'){
855 var sqs_objects = new Array;
857 sqs_objects['MassUpdate_{$varname}'] = $qsName;
858 registerSingleSmartInputListener(document.getElementById('mass_{$varname}'));
859 addToValidateBinaryDependency('MassUpdate', '{$varname}', 'alpha', false, '{$app_strings['ERR_SQS_NO_MATCH_FIELD']} {$app_strings['LBL_ASSIGNED_TO']}','{$id_name}');
865 * Add Account selection popup window HTML code
866 * @param displayname Name to display in the popup window
867 * @param varname name of the variable
868 * @param id_name name of the id in vardef
870 function addAccountID($displayname, $varname, $id_name=''){
873 $json = getJSONobj();
876 $id_name = "account_id";
878 ///////////////////////////////////////
882 $popup_request_data = array(
883 'call_back_function' => 'set_return',
884 'form_name' => 'MassUpdate',
885 'field_to_name_array' => array(
886 'id' => "{$id_name}",
887 'name' => "{$varname}",
891 $encoded_popup_request_data = $json->encode($popup_request_data);
894 ///////////////////////////////////////
897 'form' => 'MassUpdate',
899 'modules' => array('Accounts'),
901 'field_list' => array('name', 'id'),
902 'populate_list' => array('parent_name', 'parent_id'),
903 'conditions' => array(array('name'=>'name','op'=>'like_custom','end'=>'%','value'=>'')),
906 'no_match_text' => $app_strings['ERR_SQS_NO_MATCH']
908 $qsParent['populate_list'] = array('mass_'. $varname, 'mass_' . $id_name);
909 $img = SugarThemeRegistry::current()->getImageURL("id-ff-select.png");
910 $html = '<td scope="row">' . $displayname . " </td>\n"
911 . '<td><input class="sqsEnabled" type="text" autocomplete="off" id="mass_' . $varname .'" name="' . $varname . '" value="" /><input id="mass_' . $id_name . '" type="hidden" name="'
912 . $id_name . '" value="" /> <span class="id-ff multiple"><button type="button" name="btn1" class="button" title="'
913 . $app_strings['LBL_SELECT_BUTTON_LABEL'] . '" value="' . $app_strings['LBL_SELECT_BUTTON_LABEL'] . '" onclick='
914 . "'open_popup(\"Accounts\",600,400,\"\",true,false,{$encoded_popup_request_data});' /><img alt=\"$img\" src=\"$img\"></button></span></td>\n";
915 $html .= '<script type="text/javascript" language="javascript">if(typeof sqs_objects == \'undefined\'){var sqs_objects = new Array;}sqs_objects[\'MassUpdate_' . $varname . '\'] = ' .
916 $json->encode($qsParent) . '; registerSingleSmartInputListener(document.getElementById(\'mass_' . $varname . '\'));
917 addToValidateBinaryDependency(\'MassUpdate\', \''.$varname.'\', \'alpha\', false, \'' . $app_strings['ERR_SQS_NO_MATCH_FIELD'] . $app_strings['LBL_ACCOUNT'] . '\',\''.$id_name.'\');
924 * Add AssignedUser popup window HTML code
925 * @param displayname Name to display in the popup window
926 * @param varname name of the variable
928 function addAssignedUserID($displayname, $varname){
931 $json = getJSONobj();
933 $popup_request_data = array(
934 'call_back_function' => 'set_return',
935 'form_name' => 'MassUpdate',
936 'field_to_name_array' => array(
937 'id' => 'assigned_user_id',
938 'user_name' => 'assigned_user_name',
941 $encoded_popup_request_data = $json->encode($popup_request_data);
943 'form' => 'MassUpdate',
944 'method' => 'get_user_array', // special method
945 'field_list' => array('user_name', 'id'),
946 'populate_list' => array('assigned_user_name', 'assigned_user_id'),
947 'conditions' => array(array('name'=>'user_name','op'=>'like_custom','end'=>'%','value'=>'')),
948 'limit' => '30','no_match_text' => $app_strings['ERR_SQS_NO_MATCH']);
950 $qsUser['populate_list'] = array('mass_assigned_user_name', 'mass_assigned_user_id');
951 $img = SugarThemeRegistry::current()->getImageURL("id-ff-select.png");
953 <td width="15%" scope="row">$displayname</td>
954 <td ><input class="sqsEnabled" autocomplete="off" id="mass_assigned_user_name" name='assigned_user_name' type="text" value=""><input id='mass_assigned_user_id' name='assigned_user_id' type="hidden" value="" />
955 <span class="id-ff multiple"><button id="mass_assigned_user_name_btn" title="{$app_strings['LBL_SELECT_BUTTON_TITLE']}" type="button" class="button" value='{$app_strings['LBL_SELECT_BUTTON_LABEL']}' name=btn1
956 onclick='open_popup("Users", 600, 400, "", true, false, $encoded_popup_request_data);' /><img src="$img"></button></span>
959 $html .= '<script type="text/javascript" language="javascript">if(typeof sqs_objects == \'undefined\'){var sqs_objects = new Array;}sqs_objects[\'MassUpdate_assigned_user_name\'] = ' .
960 $json->encode($qsUser) . '; registerSingleSmartInputListener(document.getElementById(\'mass_assigned_user_name\'));
961 addToValidateBinaryDependency(\'MassUpdate\', \'assigned_user_name\', \'alpha\', false, \'' . $app_strings['ERR_SQS_NO_MATCH_FIELD'] . $app_strings['LBL_ASSIGNED_TO'] . '\',\'assigned_user_id\');
967 * Add Status selection popup window HTML code
968 * @param displayname Name to display in the popup window
969 * @param varname name of the variable
970 * @param options array of options for status
972 function addStatus($displayname, $varname, $options){
973 global $app_strings, $app_list_strings;
975 // cn: added "mass_" to the id tag to diffentieate from the status id in StoreQuery
976 $html = '<td scope="row" width="15%">'.$displayname.'</td><td>';
977 if(is_array($options)){
978 if(!isset($options['']) && !isset($options['0'])){
979 $new_options = array();
980 $new_options[''] = '';
981 foreach($options as $key=>$value) {
982 $new_options[$key] = $value;
984 $options = $new_options;
986 $options = get_select_options_with_id_separate_key($options, $options, '', true);;
987 $html .= '<select id="mass_'.$varname.'" name="'.$varname.'">'.$options.'</select>';
996 * Add Status selection popup window HTML code
997 * @param displayname Name to display in the popup window
998 * @param varname name of the variable
999 * @param options array of options for status
1001 function addBool($displayname, $varname){
1002 global $app_strings, $app_list_strings;
1003 return $this->addStatus($displayname, $varname, $app_list_strings['checkbox_dom']);
1005 function addStatusMulti($displayname, $varname, $options){
1006 global $app_strings, $app_list_strings;
1008 if(!isset($options['']) && !isset($options['0'])){
1009 $new_options = array();
1010 $new_options[''] = '';
1011 foreach($options as $key=>$value) {
1012 $new_options[$key] = $value;
1014 $options = $new_options;
1016 $options = get_select_options_with_id_separate_key($options, $options, '', true);;
1018 // cn: added "mass_" to the id tag to diffentieate from the status id in StoreQuery
1019 $html = '<td scope="row" width="15%">'.$displayname.'</td>
1020 <td><select id="mass_'.$varname.'" name="'.$varname.'[]" size="5" MULTIPLE>'.$options.'</select></td>';
1024 * Add Date selection popup window HTML code
1025 * @param displayname Name to display in the popup window
1026 * @param varname name of the variable
1028 function addDate($displayname, $varname){
1031 $displayname = addslashes($displayname);
1032 $userformat = '('. $timedate->get_user_date_format().')';
1033 $cal_dateformat = $timedate->get_cal_date_format();
1034 global $app_strings, $app_list_strings, $theme;
1036 $javascriptend = <<<EOQ
1037 <script type="text/javascript">
1039 inputField : "${varname}jscal_field", daFormat : "$cal_dateformat", ifFormat : "$cal_dateformat", showsTime : false, button : "${varname}jscal_trigger", singleClick : true, step : 1, weekNumbers:false
1043 $jscalendarImage = SugarThemeRegistry::current()->getImageURL('jscalendar.gif');
1045 <td scope="row" width="20%">$displayname</td>
1046 <td class='dataField' width="30%"><input onblur="parseDate(this, '$cal_dateformat')" type="text" name='$varname' size="12" id='{$varname}jscal_field' maxlength='10' value="">
1047 <img src="$jscalendarImage" id="{$varname}jscal_trigger" align="absmiddle" title="{$app_strings['LBL_MASSUPDATE_DATE']}" alt='{$app_strings['LBL_MASSUPDATE_DATE']}'> <span class="dateFormat">$userformat</span>
1049 <script> addToValidate('MassUpdate','$varname','date',false,'$displayname');</script>
1055 function addRadioenumItem($name, $value, $output) {
1057 $_output .= '<label>';
1058 $_output .= '<input type="radio" name="'
1059 . $name . '" value="'
1062 $_output .= ' />' . ($output == '' ? $GLOBALS['app_strings']['LBL_LINK_NONE'] : $output);
1063 $_output .= '</label><br />';
1067 function addRadioenum($displayname, $varname, $options){
1068 foreach ($options as $_key=>$_val){
1069 $_html_result[] = $this->addRadioenumItem($varname, $_key, $_val);
1072 $html = '<td scope="row" width="15%">'.$displayname.'</td>
1073 <td>'.implode("\n",$_html_result).'</td>';
1077 * Add Datetime selection popup window HTML code
1078 * @param displayname Name to display in the popup window
1079 * @param varname name of the variable
1081 function addDatetime($displayname, $varname){
1083 $userformat = $timedate->get_user_time_format();
1084 $cal_dateformat = $timedate->get_cal_date_format();
1085 global $app_strings, $app_list_strings, $theme;
1086 $jscalendarImage = SugarThemeRegistry::current()->getImageURL('jscalendar.gif');
1088 $javascriptend = <<<EOQ
1089 <script type="text/javascript">
1091 inputField : "{$varname}_date",
1092 daFormat : "$cal_dateformat",
1093 ifFormat : "$cal_dateformat",
1095 button : "{$varname}_trigger",
1102 $dtscript = getVersionedScript('include/SugarFields/Fields/Datetimecombo/Datetimecombo.js');
1104 <td scope="row" width="20%">$displayname</td>
1105 <td class='dataField' width="30%"><input onblur="parseDate(this, '$cal_dateformat')" type="text" name='$varname' size="12" id='{$varname}_date' maxlength='10' value="">
1106 <img border="0" src="$jscalendarImage" alt='{$app_strings['LBL_MASSUPDATE_DATE']}' id="{$varname}_trigger" title="{$app_strings['LBL_MASSUPDATE_DATE']}" align="absmiddle"> $javascriptend
1108 <span id="{$varname}_time_section"></span>
1110 <input type="hidden" id="{$varname}" name="{$varname}">
1112 <script type="text/javascript">
1113 var combo_{$varname} = new Datetimecombo(" ", "$varname", "$userformat", '','','',1);
1114 //Render the remaining widget fields
1115 text = combo_{$varname}.html('');
1116 document.getElementById('{$varname}_time_section').innerHTML = text;
1118 //Call eval on the update function to handle updates to calendar picker object
1119 eval(combo_{$varname}.jsscript(''));
1121 function update_{$varname}_available() {
1122 YAHOO.util.Event.onAvailable("{$varname}_date", this.handleOnAvailable, this);
1125 update_{$varname}_available.prototype.handleOnAvailable = function(me) {
1127 onClose : update_{$varname},
1128 inputField : "{$varname}_date",
1129 daFormat : "$cal_dateformat",
1130 ifFormat : "$cal_dateformat",
1131 button : "{$varname}_trigger",
1137 //Call update for first time to round hours and minute values
1138 combo_{$varname}.update(false);
1141 var obj_{$varname} = new update_{$varname}_available();
1144 <script> addToValidate('MassUpdate','{$varname}_date','date',false,'$displayname');
1145 addToValidateBinaryDependency('MassUpdate', '{$varname}_hours', 'alpha', false, "{$app_strings['ERR_MISSING_REQUIRED_FIELDS']}", '{$varname}_date');
1146 addToValidateBinaryDependency('MassUpdate', '{$varname}_minutes', 'alpha', false, "{$app_strings['ERR_MISSING_REQUIRED_FIELDS']}", '{$varname}_date');
1147 addToValidateBinaryDependency('MassUpdate', '{$varname}_meridiem', 'alpha', false, "{$app_strings['ERR_MISSING_REQUIRED_FIELDS']}", '{$varname}_date');
1154 function date_to_dateTime($field, $value) {
1156 //Check if none was set
1157 if (isset($this->sugarbean->field_defs[$field]['group'])) {
1158 $group = $this->sugarbean->field_defs[$field]['group'];
1159 if (isset($this->sugarbean->field_defs[$group."_flag"]) && isset($_POST[$group."_flag"])
1160 && $_POST[$group."_flag"] == 1) {
1165 $oldDateTime = $this->sugarbean->$field;
1166 $oldTime = explode(" ", $oldDateTime);
1167 if (isset($oldTime[1])) {
1168 $oldTime = $oldTime[1];
1170 $oldTime = $timedate->now();
1172 $oldTime = explode(" ", $oldTime);
1173 if (isset($oldTime[1])) {
1174 $oldTime = $oldTime[1];
1176 $oldTime = $oldTime[0];
1178 $value = explode(" ", $value);
1180 return $value." ".$oldTime;
1183 function checkClearField($field, $value) {
1184 if ($value == 1 && strpos($field, '_flag')) {
1185 $fName = substr($field, -5);
1186 if (isset($this->sugarbean->field_defs[$field]['group'])) {
1187 $group = $this->sugarbean->field_defs[$field]['group'];
1188 if (isset($this->sugarbean->field_defs[$group])) {
1189 $_POST[$group] = "";
1195 function generateSearchWhere($module, $query) {//this function is similar with function prepareSearchForm() in view.list.php
1196 $seed = loadBean($module);
1197 $this->use_old_search = true;
1198 if(file_exists('modules/'.$module.'/SearchForm.html')){
1199 if(file_exists('modules/' . $module . '/metadata/SearchFields.php')) {
1200 require_once('include/SearchForm/SearchForm.php');
1201 $searchForm = new SearchForm($module, $seed);
1203 elseif(!empty($_SESSION['export_where'])) { //bug 26026, sometimes some module doesn't have a metadata/SearchFields.php, the searchfrom is generated in the ListView.php.
1204 //So currently massupdate will not gernerate the where sql. It will use the sql stored in the SESSION. But this will cause bug 24722, and it cannot be avoided now.
1205 $where = $_SESSION['export_where'];
1206 $whereArr = explode (" ", trim($where));
1207 if ($whereArr[0] == trim('where')) {
1208 $whereClean = array_shift($whereArr);
1210 $this->where_clauses = implode(" ", $whereArr);
1214 $this->where_clauses = '';
1219 $this->use_old_search = false;
1220 require_once('include/SearchForm/SearchForm2.php');
1222 if(file_exists('custom/modules/'.$module.'/metadata/metafiles.php')){
1223 require('custom/modules/'.$module.'/metadata/metafiles.php');
1224 }elseif(file_exists('modules/'.$module.'/metadata/metafiles.php')){
1225 require('modules/'.$module.'/metadata/metafiles.php');
1228 $searchFields = $this->getSearchFields($module);
1229 $searchdefs = $this->getSearchDefs($module);
1231 if(empty($searchdefs) || empty($searchFields)) {
1232 $this->where_clauses = ''; //for some modules, such as iframe, it has massupdate, but it doesn't have search function, the where sql should be empty.
1236 $searchForm = new SearchForm($seed, $module);
1237 $searchForm->setup($searchdefs, $searchFields, 'SearchFormGeneric.tpl');
1239 /* bug 31271: using false to not add all bean fields since some beans - like SavedReports
1240 can have fields named 'module' etc. which may break the query */
1241 $searchForm->populateFromArray(unserialize(base64_decode($query)), null, true); // see bug 31271
1242 $this->searchFields = $searchForm->searchFields;
1243 $where_clauses = $searchForm->generateSearchWhere(true, $module);
1244 if (count($where_clauses) > 0 ) {
1245 $this->where_clauses = '('. implode(' ) AND ( ', $where_clauses) . ')';
1246 $GLOBALS['log']->info("MassUpdate Where Clause: {$this->where_clauses}");
1248 $this->where_clauses = '';
1252 protected function getSearchDefs($module, $metafiles = array())
1254 if (file_exists('custom/modules/'.$module.'/metadata/searchdefs.php'))
1256 require_once('custom/modules/'.$module.'/metadata/searchdefs.php');
1258 elseif (!empty($metafiles[$module]['searchdefs']))
1260 require_once($metafiles[$module]['searchdefs']);
1262 elseif (file_exists('modules/'.$module.'/metadata/searchdefs.php'))
1264 require_once('modules/'.$module.'/metadata/searchdefs.php');
1267 return isset($searchdefs) ? $searchdefs : array();
1270 protected function getSearchFields($module, $metafiles = array())
1272 if (file_exists('custom/modules/' . $module . '/metadata/SearchFields.php'))
1274 require_once('custom/modules/' . $module . '/metadata/SearchFields.php');
1276 elseif(!empty($metafiles[$module]['searchfields']))
1278 require_once($metafiles[$module]['searchfields']);
1280 elseif(file_exists('modules/'.$module.'/metadata/SearchFields.php'))
1282 require_once('modules/'.$module.'/metadata/SearchFields.php');
1285 return isset($searchFields) ? $searchFields : array();
1288 * This is kinda a hack how it is implimented, but will tell us whether or not a focus has
1289 * fields for Mass Update
1293 public function doMassUpdateFieldsExistForFocus()
1295 static $banned = array('date_modified'=>1, 'date_entered'=>1, 'created_by'=>1, 'modified_user_id'=>1, 'deleted'=>1,'modified_by_name'=>1,);
1296 foreach($this->sugarbean->field_defs as $field) {
1297 if(!isset($banned[$field['name']]) && (!isset($field['massupdate']) || !empty($field['massupdate']))){
1298 if(isset($field['type']) && $field['type'] == 'relate' && isset($field['id_name']) && $field['id_name'] == 'assigned_user_id')
1299 $field['type'] = 'assigned_user_name';
1300 if(isset($field['custom_type']))$field['type'] = $field['custom_type'];
1301 if(isset($field['type']))
1303 switch($field["type"]){
1308 case "assigned_user_name":
1310 case "account_name":
1315 case "datetimecombo":
1329 * Have to be overridden in children
1330 * @param string $displayname field label
1331 * @param string $field field name
1332 * @param bool $even even or odd
1333 * @return string html field data
1335 protected function addDefault($displayname, $field, & $even)