query($query); $i=-1; while(($row=$db->fetchByAssoc($result)) != null) { $i++; $rows[$i] = $row; } if ($i==-1) return null; return $rows; } return null; } function buildTableForm($rows, $mod='Accounts'){ if(!ACLController::checkAccess('Accounts', 'edit', true)){ return ''; } global $action; if(!empty($mod)){ global $current_language; $mod_strings = return_module_language($current_language, $mod); }else global $mod_strings; global $app_strings; $cols = sizeof($rows[0]) * 2 + 1; if ($action != 'ShowDuplicates') { $form = "
"; $form .= '
'.$mod_strings['MSG_DUPLICATE']. '
'; unset($_POST['selectedAccount']); } else { $form = '
'.$mod_strings['MSG_SHOW_DUPLICATES']. '
'; } if(isset($_POST['return_action']) && $_POST['return_action'] == 'SubPanelViewer') { $_POST['return_action'] = 'DetailView'; } if(isset($_POST['return_action']) && $_POST['return_action'] == 'DetailView' && empty($_REQUEST['return_id'])) { unset($_POST['return_action']); } $form .= ""; if ($action != 'ShowDuplicates') { $form .= ""; } require_once('include/formbase.php'); $form .= getPostToForm(); if(isset($rows[0])){ foreach ($rows[0] as $key=>$value){ if($key != 'id'){ $form .= ""; }} $form .= ""; } $rowColor = 'oddListRowS1'; foreach($rows as $row){ $form .= ""; if ($action != 'ShowDuplicates') { $form .= "\n"; } foreach ($row as $key=>$value){ if($key != 'id'){ if(isset($_POST['popup']) && $_POST['popup']==true){ $form .= "\n"; } else $form .= "\n"; }} if($rowColor == 'evenListRowS1'){ $rowColor = 'oddListRowS1'; }else{ $rowColor = 'evenListRowS1'; } $form .= ""; } $form .= "
"; // handle buttons if ($action == 'ShowDuplicates') { $return_action = 'ListView'; // cn: bug 6658 - hardcoded return action break popup -> create -> duplicate -> cancel $return_action = (isset($_REQUEST['return_action']) && !empty($_REQUEST['return_action'])) ? $_REQUEST['return_action'] : $return_action; $form .= "\n"; if (!empty($_REQUEST['return_module']) && !empty($_REQUEST['return_action']) && !empty($_REQUEST['return_id'])) $form .= ""; else if (!empty($_POST['return_module']) && !empty($_POST['return_action'])) $form .= ""; else $form .= ""; } else { $form .= "\n"; } $form .= "
 ". $mod_strings[$mod_strings['db_'.$key]]. "
[${app_strings['LBL_SELECT_BUTTON_LABEL']}]  $value$value
"; // handle buttons if ($action == 'ShowDuplicates') { $return_action = 'ListView'; // cn: bug 6658 - hardcoded return action break popup -> create -> duplicate -> cancel $return_action = (isset($_REQUEST['return_action']) && !empty($_REQUEST['return_action'])) ? $_REQUEST['return_action'] : $return_action; $form .= "\n"; if (!empty($_REQUEST['return_module']) && !empty($_REQUEST['return_action']) && !empty($_REQUEST['return_id'])) $form .= ""; else if (!empty($_POST['return_module']) && !empty($_POST['return_action'])) $form .= ""; else $form .= ""; } else { $form .= "\n"; } $form .= "
"; return $form; } function getForm($prefix, $mod='', $form=''){ if(!ACLController::checkAccess('Accounts', 'edit', true)){ return ''; } if(!empty($mod)){ global $current_language; $mod_strings = return_module_language($current_language, $mod); }else global $mod_strings; global $app_strings; $lbl_save_button_title = $app_strings['LBL_SAVE_BUTTON_TITLE']; $lbl_save_button_key = $app_strings['LBL_SAVE_BUTTON_KEY']; $lbl_save_button_label = $app_strings['LBL_SAVE_BUTTON_LABEL']; $the_form = get_left_form_header($mod_strings['LBL_NEW_FORM_TITLE']); $the_form .= << EOQ; $the_form .= $this->getFormBody($prefix, $mod, $prefix."AccountSave"); $the_form .= <<

EOQ; $the_form .= get_left_form_footer(); $the_form .= get_validate_record_js(); return $the_form; } function getFormBody($prefix,$mod='', $formname=''){ if(!ACLController::checkAccess('Accounts', 'edit', true)){ return ''; } global $mod_strings; $temp_strings = $mod_strings; if(!empty($mod)){ global $current_language; $mod_strings = return_module_language($current_language, $mod); } global $app_strings; global $current_user; $lbl_required_symbol = $app_strings['LBL_REQUIRED_SYMBOL']; $lbl_account_name = $mod_strings['LBL_ACCOUNT_NAME']; $lbl_phone = $mod_strings['LBL_PHONE']; $lbl_website = $mod_strings['LBL_WEBSITE']; $lbl_save_button_title = $app_strings['LBL_SAVE_BUTTON_TITLE']; $lbl_save_button_key = $app_strings['LBL_SAVE_BUTTON_KEY']; $lbl_save_button_label = $app_strings['LBL_SAVE_BUTTON_LABEL']; $user_id = $current_user->id; $form = << EOQ; $form .= "$lbl_account_name $lbl_required_symbol

"; $form .= "$lbl_phone

"; $form .= "$lbl_website

"; $form .='

'; $javascript = new javascript(); $javascript->setFormName($formname); $javascript->setSugarBean(new Account()); $javascript->addRequiredFields($prefix); $form .=$javascript->getScript(); $mod_strings = $temp_strings; return $form; } function getWideFormBody($prefix, $mod='',$formname='', $contact=''){ if(!ACLController::checkAccess('Accounts', 'edit', true)){ return ''; } if(empty($contact)){ $contact = new Contact(); } global $mod_strings; $temp_strings = $mod_strings; if(!empty($mod)){ global $current_language; $mod_strings = return_module_language($current_language, $mod); } global $app_strings; global $current_user; $account = new Account(); $lbl_required_symbol = $app_strings['LBL_REQUIRED_SYMBOL']; $lbl_account_name = $mod_strings['LBL_ACCOUNT_NAME']; $lbl_phone = $mod_strings['LBL_PHONE']; $lbl_website = $mod_strings['LBL_WEBSITE']; if (isset($contact->assigned_user_id)) { $user_id=$contact->assigned_user_id; } else { $user_id = $current_user->id; } //Retrieve Email address and set email1, email2 $sugarEmailAddress = new SugarEmailAddress(); $sugarEmailAddress->handleLegacyRetrieve($contact); if(!isset($contact->email1)){ $contact->email1 = ''; } if(!isset($contact->email2)){ $contact->email2 = ''; } if(!isset($contact->email_opt_out)){ $contact->email_opt_out = ''; } $form=""; $default_desc=""; if (!empty($contact->description)) { $default_desc=$contact->description; } $form .= << EOQ; //carry forward custom lead fields common to accounts during Lead Conversion $tempAccount = new Account(); if (method_exists($contact, 'convertCustomFieldsForm')) $contact->convertCustomFieldsForm($form, $tempAccount, $prefix); unset($tempAccount); $form .= << EOQ; $javascript = new javascript(); $javascript->setFormName($formname); $javascript->setSugarBean(new Account()); $javascript->addRequiredFields($prefix); $form .=$javascript->getScript(); $mod_strings = $temp_strings; return $form; } function handleSave($prefix,$redirect=true, $useRequired=false){ require_once('include/formbase.php'); $focus = new Account(); if($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))){ return null; } $focus = populateFromPost($prefix, $focus); if (isset($GLOBALS['check_notify'])) { $check_notify = $GLOBALS['check_notify']; } else { $check_notify = FALSE; } if (empty($_POST['record']) && empty($_POST['dup_checked'])) { $duplicateAccounts = $this->checkForDuplicates($prefix); if(isset($duplicateAccounts)){ $location='module=Accounts&action=ShowDuplicates'; $get = ''; // Bug 25311 - Add special handling for when the form specifies many-to-many relationships if(isset($_POST['relate_to']) && !empty($_POST['relate_to'])) { $get .= '&Accountsrelate_to='.$_POST['relate_to']; } if(isset($_POST['relate_id']) && !empty($_POST['relate_id'])) { $get .= '&Accountsrelate_id='.$_POST['relate_id']; } //add all of the post fields to redirect get string foreach ($focus->column_fields as $field) { if (!empty($focus->$field) && !is_object($focus->$field)) { $get .= "&Accounts$field=".urlencode($focus->$field); } } foreach ($focus->additional_column_fields as $field) { if (!empty($focus->$field)) { $get .= "&Accounts$field=".urlencode($focus->$field); } } if($focus->hasCustomFields()) { foreach($focus->field_defs as $name=>$field) { if (!empty($field['source']) && $field['source'] == 'custom_fields') { $get .= "&Accounts$name=".urlencode($focus->$name); } } } $emailAddress = new SugarEmailAddress(); $get .= $emailAddress->getFormBaseURL($focus); //create list of suspected duplicate account id's in redirect get string $i=0; foreach ($duplicateAccounts as $account) { $get .= "&duplicate[$i]=".$account['id']; $i++; } //add return_module, return_action, and return_id to redirect get string $get .= '&return_module='; if(!empty($_POST['return_module'])) $get .= $_POST['return_module']; else $get .= 'Accounts'; $get .= '&return_action='; if(!empty($_POST['return_action'])) $get .= $_POST['return_action']; //else $get .= 'DetailView'; if(!empty($_POST['return_id'])) $get .= '&return_id='.$_POST['return_id']; if(!empty($_POST['popup'])) $get .= '&popup='.$_POST['popup']; if(!empty($_POST['create'])) $get .= '&create='.$_POST['create']; $_SESSION['SHOW_DUPLICATES'] = $get; //now redirect the post to modules/Accounts/ShowDuplicates.php if (!empty($_POST['is_ajax_call']) && $_POST['is_ajax_call'] == '1') { ob_clean(); $json = getJSONobj(); echo $json->encode(array('status' => 'dupe', 'get' => $location)); } else if(!empty($_REQUEST['ajax_load'])) { echo ""; } else { if(!empty($_POST['to_pdf'])) $location .= '&to_pdf='.$_POST['to_pdf']; header("Location: index.php?$location"); } return null; } } if(!$focus->ACLAccess('Save')){ ACLController::displayNoAccess(true); sugar_cleanup(true); } $focus->save($check_notify); $return_id = $focus->id; $GLOBALS['log']->debug("Saved record with id of ".$return_id); if (!empty($_POST['is_ajax_call']) && $_POST['is_ajax_call'] == '1') { $json = getJSONobj(); echo $json->encode(array('status' => 'success', 'get' => '')); $trackerManager = TrackerManager::getInstance(); $timeStamp = TimeDate::getInstance()->nowDb(); if($monitor = $trackerManager->getMonitor('tracker')){ $monitor->setValue('action', 'detailview'); $monitor->setValue('user_id', $GLOBALS['current_user']->id); $monitor->setValue('module_name', 'Accounts'); $monitor->setValue('date_modified', $timeStamp); $monitor->setValue('visible', 1); if (!empty($this->bean->id)) { $monitor->setValue('item_id', $return_id); $monitor->setValue('item_summary', $focus->get_summary_text()); } $trackerManager->saveMonitor($monitor, true, true); } return null; } if(isset($_POST['popup']) && $_POST['popup'] == 'true') { $get = '&module='; if(!empty($_POST['return_module'])) $get .= $_POST['return_module']; else $get .= 'Accounts'; $get .= '&action='; if(!empty($_POST['return_action'])) $get .= $_POST['return_action']; else $get .= 'Popup'; if(!empty($_POST['return_id'])) $get .= '&return_id='.$_POST['return_id']; if(!empty($_POST['popup'])) $get .= '&popup='.$_POST['popup']; if(!empty($_POST['create'])) $get .= '&create='.$_POST['create']; if(!empty($_POST['to_pdf'])) $get .= '&to_pdf='.$_POST['to_pdf']; $get .= '&name=' . $focus->name; $get .= '&query=true'; header("Location: index.php?$get"); return; } if($redirect){ handleRedirect($return_id,'Accounts'); }else{ return $focus; } } } ?>
$lbl_account_name $lbl_required_symbol {$mod_strings['LBL_DESCRIPTION']}
$lbl_phone
$lbl_website