Skip to content

Commit

Permalink
feat(Import) support for created by field on import
Browse files Browse the repository at this point in the history
  • Loading branch information
joebordes committed May 3, 2017
1 parent 52d7f1e commit 5242d97
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions data/CRMEntity.php
Expand Up @@ -401,18 +401,19 @@ function insertIntoCrmEntity($module, $fileid = '') {
// Customization
$created_date_var = $adb->formatDate($date_var, true);
$modified_date_var = $adb->formatDate($date_var, true);

$createdbyuser = $current_user->id;
// Preserve the timestamp
if (self::isBulkSaveMode()) {
if (!empty($this->column_fields['createdtime']))
$created_date_var = $adb->formatDate($this->column_fields['createdtime'], true);
if (!empty($this->column_fields['creator']))
$createdbyuser = $this->column_fields['creator'];
//NOTE : modifiedtime ignored to support vtws_sync API track changes.
}
// END

$description_val = empty($this->column_fields['description']) ? '' : from_html($this->column_fields['description']);
$sql = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,modifiedby,createdtime,modifiedtime) values(?,?,?,?,?,?,?,?)";
$params = array($current_id, $current_user->id, $ownerid, $module, $description_val, $current_user->id, $created_date_var, $modified_date_var);
$params = array($current_id, $createdbyuser, $ownerid, $module, $description_val, $current_user->id, $created_date_var, $modified_date_var);
$adb->pquery($sql, $params);
$this->id = $current_id;
}
Expand Down
6 changes: 3 additions & 3 deletions modules/Import/controllers/Import_Index_Controller.php
Expand Up @@ -107,9 +107,9 @@ public function getImportableFields($moduleName) {
$moduleFields = $this->getAccessibleFields($moduleName);
$importableFields = array();
foreach($moduleFields as $fieldName => $fieldInstance) {
if(($this->isEditableField($fieldInstance)
&& ($fieldInstance->getTableName() != 'vtiger_crmentity' || $fieldInstance->getColumnName() != 'modifiedby')
) || ($fieldInstance->getUIType() == '70' && $fieldName != 'modifiedtime') || in_array($fieldName, $mergeFields)) {
if(($this->isEditableField($fieldInstance) && ($fieldInstance->getTableName() != 'vtiger_crmentity' || $fieldInstance->getColumnName() != 'modifiedby'))
|| ($fieldInstance->getUIType() == '70' && $fieldName != 'modifiedtime') || in_array($fieldName, $mergeFields)
|| ($fieldInstance->getUIType() == '52')) {
$importableFields[$fieldName] = $fieldInstance;
}
}
Expand Down

0 comments on commit 5242d97

Please sign in to comment.