fix import

This commit is contained in:
yuri
2016-07-08 11:00:19 +03:00
parent a7267bc920
commit 4addc48339
3 changed files with 22 additions and 14 deletions

View File

@@ -43,12 +43,12 @@ class Import extends \Espo\Core\Controllers\Record
}
}
public function actionPatch($params, $data)
public function actionPatch($params, $data, $request)
{
throw new BadRequest();
}
public function actionUpdate($params, $data)
public function actionUpdate($params, $data, $request)
{
throw new BadRequest();
}
@@ -58,12 +58,12 @@ class Import extends \Espo\Core\Controllers\Record
throw new BadRequest();
}
public function actionCreateLink($params, $data)
public function actionCreateLink($params, $data, $request)
{
throw new BadRequest();
}
public function actionRemoveLink($params, $data)
public function actionRemoveLink($params, $data, $request)
{
throw new BadRequest();
}

View File

@@ -33,13 +33,16 @@ use Espo\ORM\Entity;
class Import extends \Espo\Core\ORM\Repositories\RDB
{
public function findRelated(Entity $entity, $link, $selectParams = array())
public function findRelated(Entity $entity, $relationName, array $params = array())
{
$entityType = $entity->get('entityType');
$selectParams['customJoin'] .= $this->getRelatedJoin($entity, $link);
if (empty($params['customJoin'])) {
$params['customJoin'] = '';
}
$params['customJoin'] .= $this->getRelatedJoin($entity, $relationName);
return $this->getEntityManager()->getRepository($entityType)->find($selectParams);
return $this->getEntityManager()->getRepository($entityType)->find($params);
}
protected function getRelatedJoin(Entity $entity, $link)
@@ -73,13 +76,16 @@ class Import extends \Espo\Core\ORM\Repositories\RDB
return $sql;
}
public function countRelated(Entity $entity, $link, $selectParams = array())
public function countRelated(Entity $entity, $relationName, array $params = array())
{
$entityType = $entity->get('entityType');
$selectParams['customJoin'] .= $this->getRelatedJoin($entity, $link);
if (empty($params['customJoin'])) {
$params['customJoin'] = '';
}
$params['customJoin'] .= $this->getRelatedJoin($entity, $relationName);
return $this->getEntityManager()->getRepository($entityType)->count($selectParams);
return $this->getEntityManager()->getRepository($entityType)->count($params);
}
protected function afterRemove(Entity $entity, array $options = array())

View File

@@ -186,12 +186,14 @@ class Import extends \Espo\Services\Record
}
}
else {
if (!array_key_exists($num, $o)) {
$o[$num] = '';
}
if ($escesc) {
$o[$num].= $CSV_ENCLOSURE;
$o[$num] .= $CSV_ENCLOSURE;
$escesc = false;
}
$o[$num].= $s;
$o[$num] .= $s;
}
$i++;
@@ -406,7 +408,7 @@ class Import extends \Espo\Services\Record
if (!empty($fieldsDefs['phoneNumber']) && !empty($fieldsDefs['phoneNumber']['type']) && $fieldsDefs['phoneNumber']['type'] == 'phone') {
$typeList = $this->getMetadata()->get('entityDefs.' . $scope . '.fields.phoneNumber.typeList', []);
foreach ($typeList as $type) {
$attr = $field . str_replace(' ', '_', ucfirst($type));
$attr = str_replace(' ', '_', ucfirst($type));
$phoneFieldList[] = 'phoneNumber' . $attr;
}
}