本文整理汇总了PHP中Vtiger_Relation_Model::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Vtiger_Relation_Model::getInstance方法的具体用法?PHP Vtiger_Relation_Model::getInstance怎么用?PHP Vtiger_Relation_Model::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vtiger_Relation_Model
的用法示例。
在下文中一共展示了Vtiger_Relation_Model::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: getRelatedModuleRecordIds
public function getRelatedModuleRecordIds(Vtiger_Request $request, $recordIds = [])
{
$db = PearDatabase::getInstance();
$basicModule = $request->getModule();
$relatedModules = $request->get('related_modules');
$parentModuleModel = Vtiger_Module_Model::getInstance($basicModule);
$relatedIds = [];
if (!empty($relatedModules)) {
foreach ($relatedModules as $relModData) {
$relModData = explode('::', $relModData);
$relatedModule = $relModData[0];
$type = $relModData[1];
switch ($type) {
case 0:
$field = $relModData[2];
foreach ($recordIds as $recordId) {
$recordModel = Vtiger_Record_Model::getInstanceById($recordId, $basicModule);
if ($recordModel->get($field) != 0 && Vtiger_Functions::getCRMRecordType($recordModel->get($field)) == $relatedModule) {
$relatedIds[] = $recordModel->get($field);
}
}
break;
case 1:
$relatedModuleModel = Vtiger_Module_Model::getInstance($relatedModule);
$instance = CRMEntity::getInstance($relatedModule);
$relationModel = Vtiger_Relation_Model::getInstance($parentModuleModel, $relatedModuleModel);
$fieldModel = $relationModel->getRelationField();
$tablename = $fieldModel->get('table');
$tabIndex = $instance->table_index;
$relIndex = $this->getRelatedFieldName($relatedModule, $basicModule);
if (!$relIndex) {
break;
}
$sql = "SELECT vtiger_crmentity.crmid FROM vtiger_crmentity INNER JOIN {$tablename} ON {$tablename}.{$tabIndex} = vtiger_crmentity.crmid\n\t\t\t\t\t\tWHERE {$tablename}.{$relIndex} IN (" . $db->generateQuestionMarks($recordIds) . ")";
$result = $db->pquery($sql, $recordIds);
while ($crmid = $db->getSingleValue($result)) {
$relatedIds[] = $crmid;
}
break;
case 2:
foreach ($recordIds as $recordId) {
$recordModel = Vtiger_Record_Model::getInstanceById($recordId, $basicModule);
$relationListView = Vtiger_RelationListView_Model::getInstance($recordModel, $relatedModule);
$query = $relationListView->getRelationQuery();
$queryEx = explode('FROM', $query, 2);
$query = 'SELECT DISTINCT vtiger_crmentity.crmid FROM' . $queryEx[1];
$result = $db->query($query);
while ($crmid = $db->getSingleValue($result)) {
$relatedIds[] = $crmid;
}
}
break;
}
$relatedIds = array_unique($relatedIds);
}
}
return $relatedIds;
}
示例3: saveRecord
/**
* Function to save record
* @param <Vtiger_Request> $request - values of the record
* @return <RecordModel> - record Model of saved record
*/
public function saveRecord($request)
{
$adb = PearDatabase::getInstance();
$recordModel = $this->getRecordModelFromRequest($request);
$recordModel->save();
$originalRecordId = $recordModel->getId();
if ($request->get('relationOperation')) {
$parentModuleName = $request->get('sourceModule');
$parentModuleModel = Vtiger_Module_Model::getInstance($parentModuleName);
$parentRecordId = $request->get('sourceRecord');
$relatedModule = $recordModel->getModule();
if ($relatedModule->getName() == 'Events') {
$relatedModule = Vtiger_Module_Model::getInstance('Calendar');
}
$relatedRecordId = $recordModel->getId();
$relationModel = Vtiger_Relation_Model::getInstance($parentModuleModel, $relatedModule);
$relationModel->addRelation($parentRecordId, $relatedRecordId);
}
// Handled to save follow up event
$followupMode = $request->get('followup');
//Start Date and Time values
$startTime = Vtiger_Time_UIType::getTimeValueWithSeconds($request->get('followup_time_start'));
$startDateTime = Vtiger_Datetime_UIType::getDBDateTimeValue($request->get('followup_date_start') . " " . $startTime);
list($startDate, $startTime) = explode(' ', $startDateTime);
$subject = $request->get('subject');
if ($followupMode == 'on' && $startTime != '' && $startDate != '') {
$recordModel->set('eventstatus', 'Planned');
$recordModel->set('subject', '[Followup] ' . $subject);
$recordModel->set('date_start', $startDate);
$recordModel->set('time_start', $startTime);
$currentUser = Users_Record_Model::getCurrentUserModel();
$activityType = $recordModel->get('activitytype');
if ($activityType == 'Call') {
$minutes = $currentUser->get('callduration');
} else {
$minutes = $currentUser->get('othereventduration');
}
$dueDateTime = date('Y-m-d H:i:s', strtotime("{$startDateTime}+{$minutes} minutes"));
list($startDate, $startTime) = explode(' ', $dueDateTime);
$recordModel->set('due_date', $startDate);
$recordModel->set('time_end', $startTime);
$recordModel->set('recurringtype', '');
$recordModel->set('mode', 'create');
$recordModel->save();
$heldevent = true;
}
//TODO: remove the dependency on $_REQUEST
if ($_REQUEST['recurringtype'] != '' && $_REQUEST['recurringtype'] != '--None--') {
vimport('~modules/Calendar/RepeatEvents.php');
$focus = new Activity();
//get all the stored data to this object
$focus->column_fields = $recordModel->getData();
Calendar_RepeatEvents::repeatFromRequest($focus);
}
return $recordModel;
}
示例4: addRelation
function addRelation($request)
{
$sourceModule = $request->getModule();
$sourceRecordId = $request->get('src_record');
$relatedModule = $request->get('related_module');
$relatedRecordIdList = $request->get('related_record_list');
$sourceModuleModel = Vtiger_Module_Model::getInstance($sourceModule);
$relatedModuleModel = Vtiger_Module_Model::getInstance($relatedModule);
$relationModel = Vtiger_Relation_Model::getInstance($sourceModuleModel, $relatedModuleModel);
foreach ($relatedRecordIdList as $relatedRecordId) {
$relationModel->addRelation($sourceRecordId, $relatedRecordId, $listPrice);
}
}
示例5: addListPrice
/**
* Function adds Products/Services-PriceBooks Relation
* @param type $request
*/
function addListPrice($request)
{
$sourceModule = $request->getModule();
$sourceRecordId = $request->get('src_record');
$relatedModule = $request->get('related_module');
$relInfos = $request->get('relinfo');
$sourceModuleModel = Vtiger_Module_Model::getInstance($sourceModule);
$relatedModuleModel = Vtiger_Module_Model::getInstance($relatedModule);
$relationModel = Vtiger_Relation_Model::getInstance($sourceModuleModel, $relatedModuleModel);
foreach ($relInfos as $relInfo) {
$price = CurrencyField::convertToDBFormat($relInfo['price'], null, true);
$relationModel->addListPrice($sourceRecordId, $relInfo['id'], $price);
}
}
示例6: saveRecord
/**
* Function to save record
* @param <Vtiger_Request> $request - values of the record
* @return <RecordModel> - record Model of saved record
*/
public function saveRecord($request)
{
$recordModel = $this->getRecordModelFromRequest($request);
$recordModel->save();
if ($request->get('relationOperation')) {
$parentModuleName = $request->get('sourceModule');
$parentModuleModel = Vtiger_Module_Model::getInstance($parentModuleName);
$parentRecordId = $request->get('sourceRecord');
$relatedModule = $recordModel->getModule();
$relatedRecordId = $recordModel->getId();
$relationModel = Vtiger_Relation_Model::getInstance($parentModuleModel, $relatedModule);
$relationModel->addRelation($parentRecordId, $relatedRecordId);
}
return $recordModel;
}
示例7: deleteRelation
/**
* Function to delete the relation for specified source record id and related record id list
* @param <array> $request
* keys Content
* src_module source module name
* src_record source record id
* related_module related module name
* related_record_list json encoded of list of related record ids
*/
function deleteRelation($request)
{
$sourceModule = $request->getModule();
$sourceRecordId = $request->get('src_record');
$relatedModule = $request->get('related_module');
$relatedRecordIdList = $request->get('related_record_list');
//Setting related module as current module to delete the relation
vglobal('currentModule', $relatedModule);
$sourceModuleModel = Vtiger_Module_Model::getInstance($sourceModule);
$relatedModuleModel = Vtiger_Module_Model::getInstance($relatedModule);
$relationModel = Vtiger_Relation_Model::getInstance($sourceModuleModel, $relatedModuleModel);
foreach ($relatedRecordIdList as $relatedRecordId) {
$response = $relationModel->deleteRelation($sourceRecordId, $relatedRecordId);
}
echo $response;
}
示例8: updateStatus
/**
* Function to update Relation status
* @param Vtiger_Request $request
*/
public function updateStatus(Vtiger_Request $request)
{
$relatedModuleName = $request->get('relatedModule');
$relatedRecordId = $request->get('relatedRecord');
$status = $request->get('status');
$response = new Vtiger_Response();
if ($relatedRecordId && $status && $status < 5) {
$sourceModuleModel = Vtiger_Module_Model::getInstance($request->getModule());
$relatedModuleModel = Vtiger_Module_Model::getInstance($relatedModuleName);
$relationModel = Vtiger_Relation_Model::getInstance($sourceModuleModel, $relatedModuleModel);
$relationModel->updateStatus($request->get('sourceRecord'), array($relatedRecordId => $status));
$response->setResult(array(true));
} else {
$response->setError($code);
}
$response->emit();
}
示例9: addRelation
function addRelation($request)
{
$sourceModule = $request->getModule();
$sourceRecordId = $request->get('src_record');
$relatedModule = $request->get('related_module');
if (is_numeric($relatedModule)) {
$relatedModule = Vtiger_Functions::getModuleName($relatedModule);
}
$relatedRecordIdList = $request->get('related_record_list');
$sourceModuleModel = Vtiger_Module_Model::getInstance($sourceModule);
$relatedModuleModel = Vtiger_Module_Model::getInstance($relatedModule);
$relationModel = Vtiger_Relation_Model::getInstance($sourceModuleModel, $relatedModuleModel);
foreach ($relatedRecordIdList as $relatedRecordId) {
$relationModel->addRelation($sourceRecordId, $relatedRecordId, $listPrice);
}
$response = new Vtiger_Response();
$response->setResult(true);
$response->emit();
}
示例10: saveRecord
/**
* Function to save record
* @param <Vtiger_Request> $request - values of the record
* @return <RecordModel> - record Model of saved record
*/
public function saveRecord($request)
{
$recordModel = $this->getRecordModelFromRequest($request);
$recordModel->save();
if ($request->get('relationOperation')) {
$parentModuleName = $request->get('sourceModule');
$parentModuleModel = Vtiger_Module_Model::getInstance($parentModuleName);
$parentRecordId = $request->get('sourceRecord');
$relatedModule = $recordModel->getModule();
$relatedRecordId = $recordModel->getId();
$relationModel = Vtiger_Relation_Model::getInstance($parentModuleModel, $relatedModule);
$relationModel->addRelation($parentRecordId, $relatedRecordId);
//To store the relationship between Products/Services and PriceBooks
if ($parentRecordId && ($parentModuleName === 'Products' || $parentModuleName === 'Services')) {
$parentRecordModel = Vtiger_Record_Model::getInstanceById($parentRecordId, $parentModuleName);
$recordModel->updateListPrice($parentRecordId, $parentRecordModel->get('unit_price'));
}
}
return $recordModel;
}
示例11: addRelation
function addRelation($request)
{
$sourceModule = $request->getModule();
$sourceRecordId = $request->get('src_record');
$relatedModule = $request->get('related_module');
$relatedRecordIdList = $request->get('related_record_list');
$sourceModuleModel = Vtiger_Module_Model::getInstance($sourceModule);
$relatedModuleModel = Vtiger_Module_Model::getInstance($relatedModule);
$relationModel = Vtiger_Relation_Model::getInstance($sourceModuleModel, $relatedModuleModel);
foreach ($relatedRecordIdList as $relatedRecordId) {
$relationModel->addRelation($sourceRecordId, $relatedRecordId, $listPrice);
if ($relatedModule == 'PriceBooks') {
$recordModel = Vtiger_Record_Model::getInstanceById($relatedRecordId);
if ($sourceRecordId && ($sourceModule === 'Products' || $sourceModule === 'Services')) {
$parentRecordModel = Vtiger_Record_Model::getInstanceById($sourceRecordId, $sourceModule);
$recordModel->updateListPrice($sourceRecordId, $parentRecordModel->get('unit_price'));
}
}
}
}
示例12: saveRecord
/**
* Function to save record
* @param <Vtiger_Request> $request - values of the record
* @return <RecordModel> - record Model of saved record
*/
public function saveRecord($request)
{
$recordModel = $this->getRecordModelFromRequest($request);
$recordModel->save();
if ($request->get('relationOperation')) {
$parentModuleName = $request->get('sourceModule');
$parentModuleModel = Vtiger_Module_Model::getInstance($parentModuleName);
$parentRecordId = $request->get('sourceRecord');
$relatedModule = $recordModel->getModule();
$relatedRecordId = $recordModel->getId();
$relationModel = Vtiger_Relation_Model::getInstance($parentModuleModel, $relatedModule);
$relationModel->addRelation($parentRecordId, $relatedRecordId);
}
if ($request->get('imgDeleted')) {
$imageIds = $request->get('imageid');
foreach ($imageIds as $imageId) {
$status = $recordModel->deleteImage($imageId);
}
}
return $recordModel;
}
示例13: 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();
$reqPopUpFields = array('Currency' => 'currency_id');
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;
}
示例14: getInstance
public static function getInstance($parentRecordModel, $relationModuleName, $label = false)
{
$parentModuleName = $parentRecordModel->getModule()->get('name');
$className = Vtiger_Loader::getComponentClassName('Model', 'RelationListView', $parentModuleName);
$instance = new $className();
$parentModuleModel = $parentRecordModel->getModule();
$relationModuleModel = Vtiger_Module_Model::getInstance($relationModuleName);
$relationModel = Vtiger_Relation_Model::getInstance($parentModuleModel, $relationModuleModel, $label);
$instance->setRelationModel($relationModel)->setParentRecordModel($parentRecordModel);
return $instance;
}
示例15: getInstance
public static function getInstance($parentRecordModel, $relationModuleName, $label = false)
{
$parentModuleName = $parentRecordModel->getModule()->get('name');
$className = Vtiger_Loader::getComponentClassName('Model', 'RelationListView', $parentModuleName);
$instance = new $className();
$parentModuleModel = $parentRecordModel->getModule();
$relatedModuleModel = Vtiger_Module_Model::getInstance($relationModuleName);
$instance->setRelatedModuleModel($relatedModuleModel);
$relationModel = Vtiger_Relation_Model::getInstance($parentModuleModel, $relatedModuleModel, $label);
$instance->setParentRecordModel($parentRecordModel);
if (!$relationModel) {
$relatedModuleName = $relatedModuleModel->getName();
$parentModuleModel = $instance->getParentRecordModel()->getModule();
$referenceFieldOfParentModule = $parentModuleModel->getFieldsByType('reference');
foreach ($referenceFieldOfParentModule as $fieldName => $fieldModel) {
$refredModulesOfReferenceField = $fieldModel->getReferenceList();
if (in_array($relatedModuleName, $refredModulesOfReferenceField)) {
$relationModelClassName = Vtiger_Loader::getComponentClassName('Model', 'Relation', $parentModuleModel->getName());
$relationModel = new $relationModelClassName();
$relationModel->setParentModuleModel($parentModuleModel)->setRelationModuleModel($relatedModuleModel);
$parentModuleModel->set('directRelatedFieldName', $fieldModel->get('column'));
}
}
}
if (!$relationModel) {
$relationModel = false;
}
$instance->setRelationModel($relationModel);
return $instance;
}