本文整理汇总了PHP中Vtiger_Field_Model::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Vtiger_Field_Model::getInstance方法的具体用法?PHP Vtiger_Field_Model::getInstance怎么用?PHP Vtiger_Field_Model::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vtiger_Field_Model
的用法示例。
在下文中一共展示了Vtiger_Field_Model::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
public function process(Vtiger_Request $request)
{
$moduleSettingsName = $request->getModule(false);
$moduleName = $request->getModule();
$baseModule = $request->get('module_name');
$idTpl = $request->get('tpl_id');
$viewer = $this->getViewer($request);
if ($idTpl) {
$docInfo = Settings_OSSDocumentControl_Module_Model::getDocInfo($idTpl);
$viewer->assign('BASE_INFO', $docInfo['basic_info']);
//var_dump($docInfo['required_conditions']);
for ($i = 0; $i < count($docInfo['required_conditions']); $i++) {
$fieldModel = Vtiger_Field_Model::getInstance($docInfo['required_conditions'][$i]['fieldname'], Vtiger_Module_Model::getInstance($baseModule));
$docInfo['required_conditions'][$i]['info'] = $fieldModel->getFieldInfo();
}
$viewer->assign('REQUIRED_CONDITIONS', $docInfo['required_conditions']);
for ($i = 0; $i < count($docInfo['optional_conditions']); $i++) {
$fieldModel = Vtiger_Field_Model::getInstance($docInfo['optional_conditions'][$i]['fieldname'], Vtiger_Module_Model::getInstance($baseModule));
$docInfo['optional_conditions'][$i]['info'] = $fieldModel->getFieldInfo();
}
$viewer->assign('OPTIONAL_CONDITIONS', $docInfo['optional_conditions']);
$viewer->assign('TPL_ID', $idTpl);
//$fieldModel = Vtiger_Field_Model::getInstance($value->get('name'), $baseModuleModel);
}
$viewer->assign('MODULE_NAME', $moduleName);
$viewer->assign('SUMMARY', $request->get('summary'));
$viewer->assign('BASE_MODULE', $baseModule);
$viewer->assign('QUALIFIED_MODULE', $moduleSettingsName);
$viewer->assign('FIELD_LIST', Settings_OSSDocumentControl_Module_Model::getListBaseModuleField($baseModule));
//$viewer->assign('FOLDER_LIST', Documents_Module_Model::getAllFolders());
$viewer->assign('CONDITION_BY_TYPE', Settings_OSSDocumentControl_Module_Model::getConditionByType());
echo $viewer->view('Edit2.tpl', $moduleSettingsName, true);
}
示例2: getPopupViewFieldsList
/**
* Funtion that returns fields that will be showed in the record selection popup
* @return <Array of fields>
*/
public function getPopupViewFieldsList($sourceModule = false)
{
if (!empty($sourceModule)) {
$parentRecordModel = Vtiger_Module_Model::getInstance($sourceModule);
$relationModel = Vtiger_Relation_Model::getInstance($parentRecordModel, $this);
}
$popupFields = array();
if ($relationModel) {
$popupFields = $relationModel->getRelationFields(true);
}
if (count($popupFields) == 0) {
$popupFileds = $this->getSummaryViewFieldsList();
foreach ($popupFileds as $fieldName => $fieldModel) {
if ($fieldName === 'folderid' || $fieldName === 'modifiedtime') {
unset($popupFileds[$fieldName]);
}
}
$reqPopUpFields = array('File Status' => 'filestatus', 'File Size' => 'filesize', 'File Location Type' => 'filelocationtype');
foreach ($reqPopUpFields as $fieldLabel => $fieldName) {
$fieldModel = Vtiger_Field_Model::getInstance($fieldName, $this);
if ($fieldModel->getPermissions('readwrite')) {
$popupFileds[$fieldName] = $fieldModel;
}
}
$popupFields = array_keys($popupFileds);
}
return $popupFields;
}
示例3: process
public function process(Vtiger_Request $request)
{
$qualifiedModuleName = $request->getModule(false);
$moduleName = $request->getModule();
$baseModule = $request->get('base_module');
$idTpl = $request->get('tpl_id');
$viewer = $this->getViewer($request);
if ($idTpl && $baseModule != 'All') {
$docInfo = Settings_DataAccess_Module_Model::getDataAccessInfo($idTpl);
$viewer->assign('BASE_INFO', $docInfo['basic_info']);
for ($i = 0; $i < count($docInfo['required_conditions']); $i++) {
$fieldModel = Vtiger_Field_Model::getInstance($docInfo['required_conditions'][$i]['fieldname'], Vtiger_Module_Model::getInstance($baseModule));
$docInfo['required_conditions'][$i]['info'] = $fieldModel->getFieldInfo();
}
$viewer->assign('REQUIRED_CONDITIONS', $docInfo['required_conditions']);
for ($i = 0; $i < count($docInfo['optional_conditions']); $i++) {
$fieldModel = Vtiger_Field_Model::getInstance($docInfo['optional_conditions'][$i]['fieldname'], Vtiger_Module_Model::getInstance($baseModule));
$docInfo['optional_conditions'][$i]['info'] = $fieldModel->getFieldInfo();
}
$viewer->assign('OPTIONAL_CONDITIONS', $docInfo['optional_conditions']);
$viewer->assign('TPL_ID', $idTpl);
}
$viewer->assign('STEP', 2);
$viewer->assign('MODULE_NAME', $moduleName);
$viewer->assign('REQUEST', $request);
$viewer->assign('SUMMARY', $request->get('summary'));
$viewer->assign('BASE_MODULE', $baseModule);
$viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName);
$viewer->assign('FIELD_LIST', Settings_DataAccess_Module_Model::getListBaseModuleField($baseModule));
$viewer->assign('CONDITION_BY_TYPE', Settings_DataAccess_Module_Model::getConditionByType());
echo $viewer->view('Step2.tpl', $qualifiedModuleName, true);
}
示例4: getListViewEntries
/**
* Function to get the list view entries
* @param Vtiger_Paging_Model $pagingModel
* @return <Array> - Associative array of record id mapped to Vtiger_Record_Model instance.
*/
public function getListViewEntries($pagingModel)
{
$db = PearDatabase::getInstance();
$module = $this->getModule();
$moduleName = $module->getName();
$parentModuleName = $module->getParentName();
$qualifiedModuleName = $moduleName;
if (!empty($parentModuleName)) {
$qualifiedModuleName = $parentModuleName . ':' . $qualifiedModuleName;
}
$recordModelClass = Vtiger_Loader::getComponentClassName('Model', 'Record', $qualifiedModuleName);
$listQuery = $this->getBasicListQuery();
$startIndex = $pagingModel->getStartIndex();
$pageLimit = $pagingModel->getPageLimit();
$orderBy = $this->getForSql('orderby');
if (!empty($orderBy) && $orderBy === 'smownerid') {
$fieldModel = Vtiger_Field_Model::getInstance('assigned_user_id', $moduleModel);
if ($fieldModel->getFieldDataType() == 'owner') {
$orderBy = 'COALESCE(' . getSqlForNameInDisplayFormat(['first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'], 'Users') . ',vtiger_groups.groupname)';
}
}
if (!empty($orderBy)) {
$listQuery .= ' ORDER BY ' . $orderBy . ' ' . $this->getForSql('sortorder');
}
if ($module->isPagingSupported()) {
$nextListQuery = $listQuery . ' LIMIT ' . ($startIndex + $pageLimit) . ',1';
$listQuery .= " LIMIT $startIndex, $pageLimit";
}
$listResult = $db->pquery($listQuery, array());
$noOfRecords = $db->num_rows($listResult);
$listViewRecordModels = array();
for ($i = 0; $i < $noOfRecords; ++$i) {
$row = $db->query_result_rowdata($listResult, $i);
$record = new $recordModelClass();
$record->setData($row);
if (method_exists($record, 'getModule') && method_exists($record, 'setModule')) {
$moduleModel = Settings_Vtiger_Module_Model::getInstance($qualifiedModuleName);
$record->setModule($moduleModel);
}
$listViewRecordModels[$record->getId()] = $record;
}
if ($module->isPagingSupported()) {
$pagingModel->calculatePageRange($listViewRecordModels);
$nextPageResult = $db->pquery($nextListQuery, array());
$nextPageNumRows = $db->num_rows($nextPageResult);
if ($nextPageNumRows <= 0) {
$pagingModel->set('nextPageExists', false);
}
}
return $listViewRecordModels;
}
示例5: process
function process(Vtiger_Request $request)
{
$currentUserPriviligeModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
$viewer = $this->getViewer($request);
$recordId = $request->get('record');
$moduleName = $request->getModule();
$recordModel = Vtiger_Record_Model::getInstanceById($recordId);
$moduleModel = $recordModel->getModule();
$viewer->assign('MODULE', $moduleName);
$viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel());
$viewer->assign('CURRENT_USER_PRIVILEGE', $currentUserPriviligeModel);
$viewer->assign('RECORD', $recordModel);
$viewer->assign('CONVERT_LEAD_FIELDS', $recordModel->getConvertLeadFields());
$assignedToFieldModel = $moduleModel->getField('assigned_user_id');
$assignedToFieldModel->set('fieldvalue', $recordModel->get('assigned_user_id'));
$viewer->assign('ASSIGN_TO', $assignedToFieldModel);
$potentialModuleModel = Vtiger_Module_Model::getInstance('Potentials');
$accountField = Vtiger_Field_Model::getInstance('related_to', $potentialModuleModel);
$contactField = Vtiger_Field_Model::getInstance('contact_id', $potentialModuleModel);
$viewer->assign('ACCOUNT_FIELD_MODEL', $accountField);
$viewer->assign('CONTACT_FIELD_MODEL', $contactField);
$contactsModuleModel = Vtiger_Module_Model::getInstance('Contacts');
$accountField = Vtiger_Field_Model::getInstance('parent_id', $contactsModuleModel);
$viewer->assign('CONTACT_ACCOUNT_FIELD_MODEL', $accountField);
$state = Settings_Leads_ConvertToAccount_Model::getState();
$viewer->assign('STATE', $state);
$viewer->view('ConvertLead.tpl', $moduleName);
}
示例6: save
public function save(Vtiger_Request $request)
{
$fieldId = $request->get('fieldid');
$fieldInstance = Vtiger_Field_Model::getInstance($fieldId);
$fields = ['presence', 'quickcreate', 'summaryfield', 'helpinfo', 'generatedtype', 'masseditable', 'displaytype'];
foreach ($request->getAll() as $key => $value) {
if ($key == 'mandatory') {
$fieldInstance->updateTypeofDataFromMandatory($value);
}
if (in_array($key, $fields)) {
$fieldInstance->set($key, $value);
}
}
$defaultValue = $request->get('fieldDefaultValue');
if ($fieldInstance->getFieldDataType() == 'date') {
$dateInstance = new Vtiger_Date_UIType();
$defaultValue = $dateInstance->getDBInsertedValue($defaultValue);
}
if ($request->has('fieldMask')) {
$fieldInstance->set('fieldparams', $request->get('fieldMask'));
}
if (is_array($defaultValue)) {
$defaultValue = implode(' |##| ', $defaultValue);
}
$fieldInstance->set('defaultvalue', $defaultValue);
$response = new Vtiger_Response();
try {
$fieldInstance->save();
$response->setResult(array('success' => true, 'presence' => $request->get('presence'), 'mandatory' => $fieldInstance->isMandatory(), 'label' => vtranslate($fieldInstance->get('label'), $request->get('sourceModule'))));
} catch (Exception $e) {
$response->setError($e->getCode(), $e->getMessage());
}
$response->emit();
}
示例7: process
public function process(Vtiger_Request $request)
{
$moduleName = $request->getModule();
$recordId = $request->get('record');
$recordModel = $this->record;
if (!$recordModel) {
if (!empty($recordId)) {
$recordModel = Vtiger_Record_Model::getInstanceById($recordId, $moduleName);
} else {
$recordModel = Vtiger_Record_Model::getCleanInstance($moduleName);
}
$this->record = $recordModel;
}
$viewer = $this->getViewer($request);
$viewer->assign('IMAGE_DETAILS', $recordModel->getImageDetails());
$salutationFieldModel = Vtiger_Field_Model::getInstance('salutationtype', $recordModel->getModule());
// Fix for http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/7851
$salutationType = $request->get('salutationtype');
if (!empty($salutationType)) {
$salutationFieldModel->set('fieldvalue', $request->get('salutationtype'));
} else {
$salutationFieldModel->set('fieldvalue', $recordModel->get('salutationtype'));
}
$viewer->assign('SALUTATION_FIELD_MODEL', $salutationFieldModel);
parent::process($request);
}
示例8: getInstance
/**
* Function to get instance
* @param <String> $value - fieldname or fieldid
* @param <type> $module - optional - module instance
* @return <Vtiger_Field_Model>
*/
public static function getInstance($value, $module = false)
{
$fieldObject = parent::getInstance($value, $module);
if ($fieldObject) {
return self::getInstanceFromFieldObject($fieldObject);
}
return false;
}
示例9: process
public function process(Vtiger_Request $request)
{
$viewer = $this->getViewer($request);
$moduleName = $request->getModule();
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
$salutationFieldModel = Vtiger_Field_Model::getInstance('salutationtype', $moduleModel);
$viewer->assign('SALUTATION_FIELD_MODEL', $salutationFieldModel);
parent::process($request);
}
示例10: searchEmails
/**
* Function to search emails for send email
* @param <String> $searchValue
* @return <Array> Result of searched emails
*/
public function searchEmails($searchValue)
{
$emailsResult = array();
$db = PearDatabase::getInstance();
$currentUserModel = Users_Record_Model::getCurrentUserModel();
$emailSupportedModulesList = $this->getEmailRelatedModules();
foreach ($emailSupportedModulesList as $moduleName) {
$searchFields = array();
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
$emailFieldModels = $moduleModel->getFieldsByType('email');
foreach ($emailFieldModels as $fieldName => $fieldModel) {
if ($fieldModel->isViewable()) {
$searchFields[] = $fieldName;
}
}
$emailFields = $searchFields;
$nameFields = $moduleModel->getNameFields();
foreach ($nameFields as $fieldName) {
$fieldModel = Vtiger_Field_Model::getInstance($fieldName, $moduleModel);
if ($fieldModel->isViewable()) {
$searchFields[] = $fieldName;
}
}
if ($emailFields) {
$moduleInstance = CRMEntity::getInstance($moduleName);
$queryGenerator = new QueryGenerator($moduleName, $currentUserModel);
$listFields = $searchFields;
$listFields[] = 'id';
$queryGenerator->setFields($listFields);
//Opensource fix for showing up deleted records on email search
$queryGenerator->startGroup("");
foreach ($searchFields as $key => $emailField) {
$queryGenerator->addCondition($emailField, trim($searchValue), 'c', 'OR');
}
$queryGenerator->endGroup();
$result = $db->pquery($queryGenerator->getQuery(), array());
$numOfRows = $db->num_rows($result);
for ($i = 0; $i < $numOfRows; $i++) {
$row = $db->query_result_rowdata($result, $i);
foreach ($emailFields as $emailField) {
$emailFieldValue = $row[$emailField];
if ($emailFieldValue) {
//SalesPlatform.ru begin
$recordLabel = decode_html(getEntityFieldNameDisplay($moduleName, $nameFields, $row));
//$recordLabel = getEntityFieldNameDisplay($moduleName, $nameFields, $row);
//SalesPlatform.ru end
if (strpos($emailFieldValue, $searchValue) !== false || strpos($recordLabel, $searchValue) !== false) {
$emailsResult[vtranslate($moduleName, $moduleName)][$row[$moduleInstance->table_index]][] = array('value' => $emailFieldValue, 'label' => $recordLabel . ' <b>(' . $emailFieldValue . ')</b>');
}
}
}
}
}
}
return $emailsResult;
}
示例11: getInstance
/**
* Function to get instance
* @param <String/Integer> $value
* @param <String> $module
* @return <Settings_Leads_Field_Model> field model
*/
public static function getInstance($value, $module)
{
$fieldModel = parent::getInstance($value, $module);
$objectProperties = get_object_vars($fieldModel);
$fieldModel = new self();
foreach ($objectProperties as $properName => $propertyValue) {
$fieldModel->{$properName} = $propertyValue;
}
return $fieldModel;
}
示例12: checkLimits
public function checkLimits(Vtiger_Request $request)
{
$moduleName = $request->getModule();
$record = $request->get('record');
$currency = $request->get('currency');
$price = $request->get('price');
$limitConfig = $request->get('limitConfig');
$limitFieldName = 'creditlimit';
$balanceFieldName = 'inventorybalance';
$moduleInstance = Vtiger_Module_Model::getInstance('Accounts');
$limitField = Vtiger_Field_Model::getInstance($limitFieldName, $moduleInstance);
$balanceField = Vtiger_Field_Model::getInstance($balanceFieldName, $moduleInstance);
if (!$limitField->isActiveField() || !$balanceField->isActiveField()) {
$response = new Vtiger_Response();
$response->setResult(['status' => true]);
$response->emit();
return;
}
$recordModel = Vtiger_Record_Model::getInstanceById($record, 'Accounts');
$limitID = $recordModel->get($limitFieldName);
$balance = $recordModel->get($balanceFieldName);
$limit = reset(Vtiger_InventoryLimit_UIType::getValues($limitID))['value'];
$baseCurrency = Vtiger_Util_Helper::getBaseCurrency();
$symbol = $baseCurrency['currency_symbol'];
if ($baseCurrency['id'] != $currency) {
$selectedCurrency = Vtiger_Functions::getCurrencySymbolandRate($currency);
$price = floatval($price) * $selectedCurrency['rate'];
$symbol = $selectedCurrency['symbol'];
}
$totalPrice = $price + $balance;
$status = $totalPrice > $limit ? false : true;
if (!$status) {
$viewer = new Vtiger_Viewer();
$viewer->assign('PRICE', $price);
$viewer->assign('BALANCE', $balance);
$viewer->assign('SYMBOL', $symbol);
$viewer->assign('LIMIT', $limit);
$viewer->assign('TOTALS', $totalPrice);
$viewer->assign('LIMIT_CONFIG', $limitConfig);
$html = $viewer->view('InventoryLimitAlert.tpl', $moduleName, true);
}
$response = new Vtiger_Response();
$response->setResult([
'status' => $status,
'html' => $html
]);
$response->emit();
}
示例13: getPopupViewFieldsList
/**
* Funtion that returns fields that will be showed in the record selection popup
* @return <Array of fields>
*/
public function getPopupViewFieldsList()
{
$popupFileds = $this->getSummaryViewFieldsList();
foreach ($popupFileds as $fieldName => $fieldModel) {
if ($fieldName === 'folderid' || $fieldName === 'modifiedtime') {
unset($popupFileds[$fieldName]);
}
}
$reqPopUpFields = array('File Status' => 'filestatus', 'File Size' => 'filesize', 'File Location Type' => 'filelocationtype');
foreach ($reqPopUpFields as $fieldLabel => $fieldName) {
$fieldModel = Vtiger_Field_Model::getInstance($fieldName, $this);
if ($fieldModel->getPermissions('readwrite')) {
$popupFileds[$fieldName] = $fieldModel;
}
}
return array_keys($popupFileds);
}
示例14: process
public function process(Vtiger_Request $request)
{
$moduleName = $request->getModule();
$recordId = $request->get('record');
$recordModel = $this->record;
if (!$recordModel) {
if (!empty($recordId)) {
$recordModel = Vtiger_Record_Model::getInstanceById($recordId, $moduleName);
} else {
$recordModel = Vtiger_Record_Model::getCleanInstance($moduleName);
}
}
$viewer = $this->getViewer($request);
$salutationFieldModel = Vtiger_Field_Model::getInstance('salutationtype', $recordModel->getModule());
$salutationFieldModel->set('fieldvalue', $recordModel->get('salutationtype'));
$viewer->assign('SALUTATION_FIELD_MODEL', $salutationFieldModel);
parent::process($request);
}
示例15: setParentRecordData
/**
* Function to set data of parent record model to this record
* @param Vtiger_Record_Model $parentRecordModel
* @return Inventory_Record_Model
*/
public function setParentRecordData(Vtiger_Record_Model $parentRecordModel)
{
$userModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
$moduleName = $parentRecordModel->getModuleName();
$data = array();
$fieldMappingList = $parentRecordModel->getInventoryMappingFields();
foreach ($fieldMappingList as $fieldMapping) {
$parentField = $fieldMapping['parentField'];
$inventoryField = $fieldMapping['inventoryField'];
$fieldModel = Vtiger_Field_Model::getInstance($parentField, Vtiger_Module_Model::getInstance($moduleName));
if ($fieldModel->getPermissions()) {
$data[$inventoryField] = $parentRecordModel->get($parentField);
} else {
$data[$inventoryField] = $fieldMapping['defaultValue'];
}
}
return $this->setData($data);
}