当前位置: 首页>>代码示例>>PHP>>正文


PHP Vtiger_Relation_Model类代码示例

本文整理汇总了PHP中Vtiger_Relation_Model的典型用法代码示例。如果您正苦于以下问题:PHP Vtiger_Relation_Model类的具体用法?PHP Vtiger_Relation_Model怎么用?PHP Vtiger_Relation_Model使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Vtiger_Relation_Model类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setRelatedList

 /**
  * Set related list information between other module
  * @param Vtiger_Module Instance of target module with which relation should be setup
  * @param String Label to display in related list (default is target module name)
  * @param Array List of action button to show ('ADD', 'SELECT')
  * @param String Callback function name of this module to use as handler
  *
  * @internal Creates table vtiger_crmentityrel if it does not exists
  */
 function setRelatedList($moduleInstance, $label = '', $actions = false, $functionName = 'get_related_list')
 {
     $adb = PearDatabase::getInstance();
     if (empty($moduleInstance)) {
         return;
     }
     if (empty($label)) {
         $label = $moduleInstance->name;
     }
     $result = $adb->pquery('SELECT relation_id FROM vtiger_relatedlists WHERE tabid=? AND related_tabid = ? AND name = ? AND label = ?;', [$this->id, $moduleInstance->id, $functionName, $label]);
     if ($result->rowCount() > 0) {
         self::log("Setting relation with {$moduleInstance->name} [{$useactions_text}] ... Error, the related module already exists");
         return;
     }
     $sequence = $this->__getNextRelatedListSequence();
     $presence = 0;
     // 0 - Enabled, 1 - Disabled
     // Allow ADD action of other module records (default)
     if ($actions === false) {
         $actions = ['ADD'];
     }
     $useactionsText = $actions;
     if (is_array($actions)) {
         $useactionsText = implode(',', $actions);
     }
     $useactionsText = strtoupper($useactionsText);
     $adb->insert('vtiger_relatedlists', ['relation_id' => $adb->getUniqueID('vtiger_relatedlists'), 'tabid' => $this->id, 'related_tabid' => $moduleInstance->id, 'name' => $functionName, 'sequence' => $sequence, 'label' => $label, 'presence' => $presence, 'actions' => $useactionsText]);
     if ($functionName == 'get_many_to_many') {
         $refTableName = Vtiger_Relation_Model::getReferenceTableInfo($moduleInstance->name, $this->name);
         if (!Vtiger_Utils::CheckTable($refTableName['table'])) {
             Vtiger_Utils::CreateTable($refTableName['table'], '(crmid INT(19) ,relcrmid INT(19),KEY crmid (crmid),KEY relcrmid (relcrmid))', true);
         }
     }
     self::log("Setting relation with {$moduleInstance->name} [{$useactions_text}] ... DONE");
 }
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:44,代码来源:Module.php

示例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;
 }
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:32,代码来源:Module.php

示例3: 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;
 }
开发者ID:awflu,项目名称:YetiForceCRM,代码行数:58,代码来源:TransferOwnership.php

示例4: 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;
 }
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:61,代码来源:Save.php

示例5: removeRelation

 public function removeRelation(Vtiger_Request $request)
 {
     $relationId = $request->get('relationId');
     $response = new Vtiger_Response();
     try {
         Vtiger_Relation_Model::removeRelationById($relationId);
         $response->setResult(['success' => true]);
     } catch (Exception $e) {
         $response->setError($e->getCode(), $e->getMessage());
     }
     $response->emit();
 }
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:12,代码来源:Relation.php

示例6: 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);
     }
 }
开发者ID:cannking,项目名称:vtigercrm-debug,代码行数:13,代码来源:RelationAjax.php

示例7: updateSelectedFields

 public function updateSelectedFields(Vtiger_Request $request)
 {
     $fields = $request->get('fields');
     $relationId = $request->get('relationId');
     $response = new Vtiger_Response();
     try {
         Vtiger_Relation_Model::updateModuleRelatedFields($relationId, $fields);
         $response->setResult(array('success' => true));
     } catch (Exception $e) {
         $response->setError($e->getCode(), $e->getMessage());
     }
     $response->emit();
 }
开发者ID:rcrrich,项目名称:UpdatePackages,代码行数:13,代码来源:Relation.php

示例8: 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);
     }
 }
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:18,代码来源:RelationAjax.php

示例9: 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;
 }
开发者ID:cannking,项目名称:vtigercrm-debug,代码行数:20,代码来源:SaveAjax.php

示例10: 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;
 }
开发者ID:cannking,项目名称:vtigercrm-debug,代码行数:25,代码来源:RelationAjax.php

示例11: 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();
 }
开发者ID:yozhi,项目名称:YetiForceCRM,代码行数:21,代码来源:RelationAjax.php

示例12: 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();
 }
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:19,代码来源:RelationAjax.php

示例13: 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;
 }
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:25,代码来源:Save.php

示例14: 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'));
             }
         }
     }
 }
开发者ID:nouphet,项目名称:vtigercrm-6.0.0-ja,代码行数:20,代码来源:RelationAjax.php

示例15: 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;
 }
开发者ID:cannking,项目名称:vtigercrm-debug,代码行数:26,代码来源:Save.php


注:本文中的Vtiger_Relation_Model类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。