$xtpl->assign("DOMAIN_NAME", $focus->domain_name); if (empty($focus->list_type) or $focus->list_type != 'exempt_domain') { $xtpl->assign("DOMAIN_HIDDEN", "display:none"); } if (empty($focus->assigned_user_id) && empty($focus->id)) { $focus->assigned_user_id = $current_user->id; } if (empty($focus->list_type)) { $focus->list_type = 'default'; } $xtpl->assign("LIST_OPTIONS", get_select_options_with_id($app_list_strings['prospect_list_type_dom'], $focus->list_type)); global $current_user; if (is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])) { $record = ''; if (!empty($_REQUEST['record'])) { $record = $_REQUEST['record']; } $xtpl->assign("ADMIN_EDIT", "<a href='index.php?action=index&module=DynamicLayout&from_action=" . $_REQUEST['action'] . "&from_module=" . $_REQUEST['module'] . "&record=" . $record . "'>" . get_image($image_path . "EditLayout", "border='0' alt='Edit Layout' align='bottom'") . "</a>"); } //Add Custom Fields require_once 'modules/DynamicFields/templates/Files/EditView.php'; $xtpl->parse("main.open_source"); $xtpl->parse("main"); $xtpl->out("main"); require_once 'include/javascript/javascript.php'; $javascript = new javascript(); $javascript->setFormName('EditView'); $javascript->setSugarBean($focus); $javascript->addAllFields(''); $javascript->addToValidateBinaryDependency('assigned_user_name', 'alpha', $app_strings['ERR_SQS_NO_MATCH_FIELD'] . $app_strings['LBL_ASSIGNED_TO'], 'false', '', 'assigned_user_id'); echo $javascript->getScript();
$sugar_smarty->assign("RETURN_MODULE", $_REQUEST['return_module']); } if (isset($_REQUEST['return_action'])) { $sugar_smarty->assign("RETURN_ACTION", $_REQUEST['return_action']); } if (isset($_REQUEST['return_id'])) { $sugar_smarty->assign("RETURN_ID", $_REQUEST['return_id']); } $sugar_smarty->assign("PRINT_URL", "index.php?" . $GLOBALS['request_string']); $sugar_smarty->assign("JAVASCRIPT", get_set_focus_js()); $sugar_smarty->assign("THEME", SugarThemeRegistry::current()->__toString()); $sugar_smarty->assign("ID", $focus->id); $sugar_smarty->assign('NAME', $focus->name); $sugar_smarty->assign('STATUS', $focus->status); $sugar_smarty->assign('ISO4217', $focus->iso4217); $sugar_smarty->assign('CONVERSION_RATE', $focus->conversion_rate); $sugar_smarty->assign('SYMBOL', $focus->symbol); $sugar_smarty->assign('STATUS_OPTIONS', get_select_options_with_id($mod_strings['currency_status_dom'], $focus->status)); //if (empty($focus->list_order)) $xtpl->assign('LIST_ORDER', count($focus->get_manufacturers(false,'All'))+1); //else $xtpl->assign('LIST_ORDER', $focus->list_order); $sugar_smarty->assign('REFRESHMETADATA', $refreshMetadata); $sugar_smarty->display("modules/Currencies/EditView.tpl"); $javascript = new javascript(); $javascript->setFormName('EditView'); $javascript->setSugarBean($focus); $javascript->addAllFields('', array('iso4217' => 'iso4217')); echo $javascript->getScript(); echo "<script type='text/javascript'>addToValidateMoreThan('EditView','conversion_rate','float',true,'" . $mod_strings['LBL_BELOW_MIN'] . "',0.000001);</script>"; } else { echo $mod_strings['LBL_ADMIN_ONLY']; }
/** * Builds a template * This is a private function that should be called only from checkTemplate method * * @param module string module name * @param view string view need (eg DetailView, EditView, etc) * @param tpl string generic tpl to use * @param ajaxSave boolean parameter indicating whether or not this is coming from an Ajax call * @param metaDataDefs metadata definition as Array **/ function buildTemplate($module, $view, $tpl, $ajaxSave, $metaDataDefs) { $this->loadSmarty(); $cacheDir = create_cache_directory($this->templateDir . $module . '/'); $file = $cacheDir . $view . '.tpl'; $string = '{* Create Date: ' . date('Y-m-d H:i:s') . "*}\n"; $this->ss->left_delimiter = '{{'; $this->ss->right_delimiter = '}}'; $this->ss->assign('module', $module); $this->ss->assign('built_in_buttons', array('CANCEL', 'DELETE', 'DUPLICATE', 'EDIT', 'FIND_DUPLICATES', 'SAVE', 'CONNECTOR')); $contents = $this->ss->fetch($tpl); //Insert validation and quicksearch stuff here if ($view == 'EditView' || strpos($view, 'QuickCreate') || $ajaxSave || $view == "ConvertLead") { global $dictionary, $beanList, $app_strings, $mod_strings; $mod = $beanList[$module]; if ($mod == 'aCase') { $mod = 'Case'; } $defs = $dictionary[$mod]['fields']; $defs2 = array(); //Retrieve all panel field definitions with displayParams Array field set $panelFields = array(); foreach ($metaDataDefs['panels'] as $panel) { foreach ($panel as $row) { foreach ($row as $entry) { if (empty($entry)) { continue; } if (is_array($entry) && isset($entry['name']) && isset($entry['displayParams']) && isset($entry['displayParams']['required']) && $entry['displayParams']['required']) { $panelFields[$entry['name']] = $entry; } if (is_array($entry)) { $defs2[$entry['name']] = $entry; } else { $defs2[$entry] = array('name' => $entry); } } //foreach } //foreach } //foreach foreach ($panelFields as $field => $value) { $nameList = array(); if (!is_array($value['displayParams']['required'])) { $nameList[] = $field; } else { foreach ($value['displayParams']['required'] as $groupedField) { $nameList[] = $groupedField; } } foreach ($nameList as $x) { if (isset($defs[$x]) && isset($defs[$x]['type']) && !isset($defs[$x]['required'])) { $defs[$x]['required'] = true; } } } //foreach //Create a base class with field_name_map property $sugarbean = new stdClass(); $sugarbean->field_name_map = $defs; $sugarbean->module_dir = $module; $javascript = new javascript(); $view = $view == 'QuickCreate' ? "QuickCreate_{$module}" : $view; $javascript->setFormName($view); $javascript->setSugarBean($sugarbean); if ($view != "ConvertLead") { $javascript->addAllFields('', null, true); } $validatedFields = array(); $javascript->addToValidateBinaryDependency('assigned_user_name', 'alpha', $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD') . ': ' . $javascript->buildStringToTranslateInSmarty('LBL_ASSIGNED_TO'), 'false', '', 'assigned_user_id'); $validatedFields[] = 'assigned_user_name'; //Add remaining validation dependency for related fields //1) a relate type as defined in vardefs //2) set in metadata layout //3) not have validateDepedency set to false in metadata //4) have id_name in vardef entry //5) not already been added to Array foreach ($sugarbean->field_name_map as $name => $def) { if ($def['type'] == 'relate' && isset($defs2[$name]) && (!isset($defs2[$name]['validateDependency']) || $defs2[$name]['validateDependency'] === true) && isset($def['id_name']) && !in_array($name, $validatedFields)) { if (isset($mod_strings[$def['vname']]) || isset($app_strings[$def['vname']]) || translate($def['vname'], $sugarbean->module_dir) != $def['vname']) { $vname = $def['vname']; } else { $vname = "undefined"; } $javascript->addToValidateBinaryDependency($name, 'alpha', $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD') . ': ' . $javascript->buildStringToTranslateInSmarty($vname), !empty($def['required']) ? 'true' : 'false', '', $def['id_name']); $validatedFields[] = $name; } } //foreach $contents .= "{literal}\n"; $contents .= $javascript->getScript(); $contents .= $this->createQuickSearchCode($defs, $defs2, $view, $module); $contents .= "{/literal}\n"; } else { if (preg_match('/^SearchForm_.+/', $view)) { global $dictionary, $beanList, $app_strings, $mod_strings; $mod = $beanList[$module]; if ($mod == 'aCase') { $mod = 'Case'; } $defs = $dictionary[$mod]['fields']; $contents .= '{literal}'; $contents .= $this->createQuickSearchCode($defs, array(), $view); $contents .= '{/literal}'; } } //if //Remove all the copyright comments $contents = preg_replace('/\\{\\*[^\\}]*?\\*\\}/', '', $contents); if ($fh = @sugar_fopen($file, 'w')) { fputs($fh, $contents); fclose($fh); } $this->ss->left_delimiter = '{'; $this->ss->right_delimiter = '}'; }
} $xtpl->assign('ASSIGNED_USER_ID', $current_user->id); $xtpl->assign('MYINBOX', 'this.form.type.value=\'inbound\';'); } //// END SPECIAL INBOUND LANDING SCREEN ASSIGNS /////////////////////////////////////// echo '<script>var disabledModules=' . $json->encode($disabled_parent_types) . ';</script>'; $jsVars = 'var lbl_send_anyways = "' . $mod_strings['LBL_SEND_ANYWAYS'] . '";'; $xtpl->assign('JS_VARS', $jsVars); $xtpl->parse("main"); $xtpl->out("main"); echo '<script>checkParentType(document.EditView.parent_type.value, document.EditView.change_parent);</script>'; //// END XTEMPLATE ASSIGNMENT /////////////////////////////////////////////////////////////////////////////// $javascript = new javascript(); $javascript->setFormName('EditView'); $javascript->setSugarBean($focus); $skip_fields = array(); if ($email_type == 'out') { $skip_fields['name'] = 1; $skip_fields['date_start'] = 1; } $javascript->addAllFields('', $skip_fields); $javascript->addToValidateBinaryDependency('parent_name', 'alpha', $app_strings['ERR_SQS_NO_MATCH_FIELD'] . $mod_strings['LBL_MEMBER_OF'], 'false', '', 'parent_id'); $javascript->addToValidateBinaryDependency('parent_type', 'alpha', $app_strings['ERR_SQS_NO_MATCH_FIELD'] . $mod_strings['LBL_MEMBER_OF'], 'false', '', 'parent_id'); $javascript->addToValidateBinaryDependency('user_name', 'alpha', $app_strings['ERR_SQS_NO_MATCH_FIELD'] . $app_strings['LBL_ASSIGNED_TO'], 'false', '', 'assigned_user_id'); if ($email_type == 'archived') { $javascript->addFieldIsValidDate('date_start', 'date', $mod_strings['LBL_DATE'], $mod_strings['ERR_DATE_START'], true); $javascript->addFieldIsValidTime('time_start', 'time', $mod_strings['LBL_TIME'], $mod_strings['ERR_TIME_SENT'], true); } echo $javascript->getScript();