本文整理汇总了PHP中VTEntityData::fromCRMEntity方法的典型用法代码示例。如果您正苦于以下问题:PHP VTEntityData::fromCRMEntity方法的具体用法?PHP VTEntityData::fromCRMEntity怎么用?PHP VTEntityData::fromCRMEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VTEntityData
的用法示例。
在下文中一共展示了VTEntityData::fromCRMEntity方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleEvent
function handleEvent($eventName, $data)
{
if ($eventName == 'vtiger.entity.beforesave') {
// Entity is about to be saved, take required action
}
if ($eventName == 'vtiger.entity.aftersave') {
$db = PearDatabase::getInstance();
$relatedToId = $data->get('related_to');
if ($relatedToId) {
$moduleName = getSalesEntityType($relatedToId);
$focus = CRMEntity::getInstance($moduleName);
$focus->retrieve_entity_info($relatedToId, $moduleName);
$focus->id = $relatedToId;
$fromPortal = $data->get('from_portal');
if ($fromPortal) {
$focus->column_fields['from_portal'] = $fromPortal;
}
$entityData = VTEntityData::fromCRMEntity($focus);
$wfs = new VTWorkflowManager($db);
$relatedToEventHandler = new VTWorkflowEventHandler();
$relatedToEventHandler->workflows = $wfs->getWorkflowsForModuleSupportingComments($entityData->getModuleName());
$wsId = vtws_getWebserviceEntityId($entityData->getModuleName(), $entityData->getId());
$fromPortal = $entityData->get('from_portal');
$util = new VTWorkflowUtils();
$entityCache = new VTEntityCache($util->adminUser());
$entityCacheData = $entityCache->forId($wsId);
$entityCacheData->set('from_portal', $fromPortal);
$entityCache->cache[$wsId] = $entityCacheData;
$relatedToEventHandler->handleEvent($eventName, $entityData, $entityCache);
$util->revertUser();
}
}
}
示例2: restore
/** Function to restore a deleted record of specified module with given crmid
* @param $module -- module name:: Type varchar
* @param $entity_ids -- list of crmids :: Array
*/
function restore($module, $id)
{
global $current_user, $adb;
$this->db->println("TRANS restore starts {$module}");
$this->db->startTransaction();
$date_var = date("Y-m-d H:i:s");
$query = 'UPDATE vtiger_crmentity SET deleted=0,modifiedtime=?,modifiedby=? WHERE crmid = ?';
$this->db->pquery($query, array($this->db->formatDate($date_var, true), $current_user->id, $id), true, "Error restoring records :");
//Restore related entities/records
$this->restoreRelatedRecords($module, $id);
//Event triggering code
require_once "include/events/include.inc";
global $adb;
$em = new VTEventsManager($adb);
// Initialize Event trigger cache
$em->initTriggerCache();
$this->id = $id;
$entityData = VTEntityData::fromCRMEntity($this);
//Event triggering code
$em->triggerEvent("vtiger.entity.afterrestore", $entityData);
//Event triggering code ends
$this->db->completeTransaction();
$this->db->println("TRANS restore ends");
}
示例3: triggerAfterSaveEventHandlers
public function triggerAfterSaveEventHandlers()
{
$adb = PearDatabase::getInstance();
require_once "include/events/include.inc";
//In Bulk mode stop triggering events
if (!self::isBulkSaveMode()) {
$em = new VTEventsManager($adb);
// Initialize Event trigger cache
$em->initTriggerCache();
$entityData = VTEntityData::fromCRMEntity($this);
}
//Event triggering code ends
if ($em) {
//Event triggering code
$em->triggerEvent("vtiger.entity.aftersave", $entityData);
$em->triggerEvent("vtiger.entity.aftersave.final", $entityData);
}
}
示例4: trigger
/**
* Trigger event based on CRM Record
* @param String Name of the Event to trigger
* @param Integer CRM record id on which event needs to be triggered.
*/
static function trigger($eventname, $crmid)
{
if (!self::hasSupport()) {
return;
}
$adb = PearDatabase::getInstance();
$checkres = $adb->pquery("SELECT setype, crmid, deleted FROM vtiger_crmentity WHERE crmid=?", array($crmid));
if ($adb->num_rows($checkres)) {
$result = $adb->fetch_array($checkres, 0);
if ($result['deleted'] == '0') {
$module = $result['setype'];
$moduleInstance = CRMEntity::getInstance($module);
$moduleInstance->retrieve_entity_info($result['crmid'], $module);
$moduleInstance->id = $result['crmid'];
$current_user = vglobal('current_user');
if (!$current_user) {
$current_user = new Users();
$current_user->id = $moduleInstance->column_fields['assigned_user_id'];
}
// Trigger the event
$em = new VTEventsManager($adb);
$em->triggerEvent($eventname, VTEntityData::fromCRMEntity($moduleInstance));
}
}
}
示例5: createEntityRecord
public function createEntityRecord($moduleName, $entityLabel)
{
$moduleHandler = vtws_getModuleHandlerFromName($moduleName, $this->user);
$moduleMeta = $moduleHandler->getMeta();
$moduleFields = $moduleMeta->getModuleFields();
$mandatoryFields = $moduleMeta->getMandatoryFields();
$entityNameFieldsString = $moduleMeta->getNameFields();
$entityNameFields = explode(',', $entityNameFieldsString);
$fieldData = array();
foreach ($entityNameFields as $entityNameField) {
$entityNameField = trim($entityNameField);
if (in_array($entityNameField, $mandatoryFields)) {
$fieldData[$entityNameField] = $entityLabel;
}
}
foreach ($mandatoryFields as $mandatoryField) {
if (empty($fieldData[$mandatoryField])) {
$fieldInstance = $moduleFields[$mandatoryField];
if ($fieldInstance->getFieldDataType() == 'owner') {
$fieldData[$mandatoryField] = $this->user->id;
} else {
if (!in_array($mandatoryField, $entityNameFields) && $fieldInstance->getFieldDataType() != 'reference') {
$fieldData[$mandatoryField] = '????';
}
}
}
}
$fieldData = DataTransform::sanitizeData($fieldData, $moduleMeta);
$entityIdInfo = vtws_create($moduleName, $fieldData, $this->user);
$adb = PearDatabase::getInstance();
$entityIdComponents = vtws_getIdComponents($entityIdInfo['id']);
$recordId = $entityIdComponents[1];
$entityfields = getEntityFieldNames($moduleName);
switch ($moduleName) {
case 'HelpDesk':
$entityfields['fieldname'] = array('ticket_title');
break;
case 'Documents':
$entityfields['fieldname'] = array('notes_title');
break;
case 'Documents':
$entityfields['fieldname'] = array('notes_title');
break;
}
$label = '';
if (is_array($entityfields['fieldname'])) {
foreach ($entityfields['fieldname'] as $field) {
$label .= $fieldData[$field] . " ";
}
} else {
$label = $fieldData[$entityfields['fieldname']];
}
$label = trim($label);
$adb->pquery('UPDATE vtiger_crmentity SET label=? WHERE crmid=?', array($label, $recordId));
$recordModel = Vtiger_Record_Model::getCleanInstance($moduleName);
$focus = $recordModel->getEntity();
$focus->id = $recordId;
$focus->column_fields = $fieldData;
$this->entityData[] = VTEntityData::fromCRMEntity($focus);
$focus->updateMissingSeqNumber($moduleName);
return $entityIdInfo;
}
示例6: save
/** Function to saves the values in all the tables mentioned in the class variable $tab_name for the specified module
* @param $module -- module:: Type varchar
*/
function save($module_name, $fileid = '')
{
global $log;
$log->debug("module name is " . $module_name);
//Event triggering code
require_once "include/events/include.inc";
global $adb;
$em = new VTEventsManager($adb);
// Initialize Event trigger cache
$em->initTriggerCache();
$entityData = VTEntityData::fromCRMEntity($this);
$em->triggerEvent("vtiger.entity.beforesave.modifiable", $entityData);
$em->triggerEvent("vtiger.entity.beforesave", $entityData);
$em->triggerEvent("vtiger.entity.beforesave.final", $entityData);
//Event triggering code ends
//GS Save entity being called with the modulename as parameter
$this->saveentity($module_name, $fileid);
//Event triggering code
$em->triggerEvent("vtiger.entity.aftersave", $entityData);
//Event triggering code ends
}
示例7: undoImport
function undoImport(Vtiger_Request $request)
{
$viewer = new Vtiger_Viewer();
$db = PearDatabase::getInstance();
$moduleName = $request->getModule();
$ownerId = $request->get('foruser');
$user = Users_Record_Model::getCurrentUserModel();
$dbTableName = Import_Utils_Helper::getDbTableName($user);
if (!$user->isAdminUser() && $user->id != $ownerId) {
$viewer->assign('MESSAGE', 'LBL_PERMISSION_DENIED');
$viewer->view('OperationNotPermitted.tpl', 'Vtiger');
exit;
}
$previousBulkSaveMode = $VTIGER_BULK_SAVE_MODE;
$VTIGER_BULK_SAVE_MODE = true;
$query = "SELECT recordid FROM {$dbTableName} WHERE temp_status = ? AND recordid IS NOT NULL";
//For inventory modules
$inventoryModules = getInventoryModules();
if (in_array($moduleName, $inventoryModules)) {
$query .= ' GROUP BY subject';
}
//End
$result = $db->pquery($query, array(Import_Data_Action::$IMPORT_RECORD_CREATED));
$noOfRecords = $db->num_rows($result);
$noOfRecordsDeleted = 0;
$entityData = array();
for ($i = 0; $i < $noOfRecords; $i++) {
$recordId = $db->query_result($result, $i, 'recordid');
if (isRecordExists($recordId) && isPermitted($moduleName, 'Delete', $recordId) == 'yes') {
$recordModel = Vtiger_Record_Model::getCleanInstance($moduleName);
$recordModel->setId($recordId);
$recordModel->delete();
$focus = $recordModel->getEntity();
$focus->id = $recordId;
$entityData[] = VTEntityData::fromCRMEntity($focus);
$noOfRecordsDeleted++;
}
}
$entity = new VTEventsManager($db);
$entity->triggerEvent('vtiger.batchevent.delete', $entityData);
$VTIGER_BULK_SAVE_MODE = $previousBulkSaveMode;
$viewer->assign('FOR_MODULE', $moduleName);
$viewer->assign('MODULE', 'Import');
$viewer->assign('TOTAL_RECORDS', $noOfRecords);
$viewer->assign('DELETED_RECORDS_COUNT', $noOfRecordsDeleted);
$viewer->view('ImportUndoResult.tpl', 'Import');
}
示例8: restore
/** Function to restore a deleted record of specified module with given crmid
* @param $module -- module name:: Type varchar
* @param $entity_ids -- list of crmids :: Array
*/
function restore($module, $id)
{
$db = PearDatabase::getInstance();
$currentUser = vglobal('current_user');
$db->startTransaction();
$db->update('vtiger_crmentity', ['deleted' => 0, 'modifiedtime' => date('Y-m-d H:i:s'), 'modifiedby' => $currentUser->id], 'crmid = ?', [$id]);
//Restore related entities/records
$this->restoreRelatedRecords($module, $id);
//Event triggering code
require_once 'include/events/include.inc';
$em = new VTEventsManager($db);
// Initialize Event trigger cache
$em->initTriggerCache();
$this->id = $id;
$entityData = VTEntityData::fromCRMEntity($this);
//Event triggering code
$em->triggerEvent('vtiger.entity.afterrestore', $entityData);
//Event triggering code ends
$db->completeTransaction();
}
示例9: Project
require_once "data/Tracker.php";
require_once "modules/com_vtiger_workflow/VTWorkflowManager.inc";
require_once "modules/com_vtiger_workflow/VTTaskManager.inc";
require_once "modules/com_vtiger_workflow/VTWorkflowApplication.inc";
require_once "modules/com_vtiger_workflow/VTEntityMethodManager.inc";
require_once "include/utils/CommonUtils.php";
require_once "include/events/SqlResultIterator.inc";
require_once "modules/com_vtiger_workflow/VTWorkflowUtils.php";
require_once "modules/Project/Project.php";
$focus1 = new Project();
$focus1->retrieve_entity_info($pcdetailsproject, "Project");
$focus1->id = $pcdetailsproject;
$em = new VTEventsManager($adb);
// Initialize Event trigger cache
$em->initTriggerCache();
$entityData = VTEntityData::fromCRMEntity($focus1);
$em->triggerEvent("vtiger.entity.beforesave.modifiable", $entityData);
$em->triggerEvent("vtiger.entity.beforesave", $entityData);
$em->triggerEvent("vtiger.entity.beforesave.final", $entityData);
$em->triggerEvent("vtiger.entity.aftersave", $entityData);
//}
$projectQuery1 = $adb->query("select * from vtiger_project where projectid={$pcdetailsproject}");
if ($adb->query_result($projectQuery1, 0, "substatusproj") == "CAT_parts sent by Teknema" && $adb->query_result($projectQuery1, 0, "statopartech") == 'SHIPPED') {
$logpart .= "Movimento frecce avvenuto con successo </span><br><br>";
$logs[$i - 1] .= "Movimento frecce avvenuto con successo";
} elseif ($subs != "CAT_parts request" && strstr($subs, "attesa parti") != '' && $adb->query_result($projectQuery1, 0, "statopartech") == 'SHIPPED') {
$logpart .= "<span style='color:blue'> Substatus errato {$d['2']} </span></span><br><br>";
$logs[$i - 1] .= "Substatus errato {$d['2']}";
} else {
$logpart .= "Substatus non modificato </span><br><br>";
$logs[$i - 1] .= "Substatus non modificato";