From 5241a30061a8f7e53ed902eddd8f2f48a3d8b858 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Mon, 17 Mar 2014 11:39:31 +0200 Subject: [PATCH] export --- application/Espo/Services/Record.php | 39 +++++++++++++++++-- .../Custom/Resources/layouts/Task/detail.json | 1 + 2 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 custom/Espo/Custom/Resources/layouts/Task/detail.json diff --git a/application/Espo/Services/Record.php b/application/Espo/Services/Record.php index 08a20fd1bc..4cda00fcdf 100644 --- a/application/Espo/Services/Record.php +++ b/application/Espo/Services/Record.php @@ -419,6 +419,11 @@ class Record extends \Espo\Core\Services\Base return $this->getStreamService()->unfollowEntity($entity, $userId); } + public function checkEntityIsDuplicate(Entity $entity) + { + + } + public function export($ids, $where) { if (!empty($ids)) { @@ -429,10 +434,38 @@ class Record extends \Espo\Core\Services\Base 'value' => $ids ) ); + } + + $selectParams = $this->getSelectManager($this->entityName)->getSelectParams(array('where' => $where), true); + $collection = $this->getRepository()->find($selectParams); + + $arr = array(); + + $collection->toArray(); + + $fields = null; + foreach ($collection as $entity) { + if (empty($fields)) { + $fields = array(); + foreach ($entity->getFields() as $field => $defs) { + if (empty($defs['notStorable'])) { + $fields[] = $field; + } else { + if ($defs['type'] == 'email') { + $fields[] = $field; + } else if ($defs['name'] == 'name') { + $fields[] = $field; + } + } + } + } + + $row = array(); + foreach ($fields as $field) { + $row[$field] = $entity->get($field); + } + $arr[] = $row; } - - $result = $this->findEntities(array('where' => $where)); - $arr = $result['collection']->toArray(); $fp = fopen('php://temp', 'w'); fputcsv($fp, array_keys($arr[0])); diff --git a/custom/Espo/Custom/Resources/layouts/Task/detail.json b/custom/Espo/Custom/Resources/layouts/Task/detail.json new file mode 100644 index 0000000000..86a76f09eb --- /dev/null +++ b/custom/Espo/Custom/Resources/layouts/Task/detail.json @@ -0,0 +1 @@ +[{"label":"Overview","rows":[[{"name":"name"},{"name":"parent"}],[{"name":"status"},{"name":"priority"}],[{"name":"dateStart"},false],[{"name":"dateEnd"},false],[{"name":"description"},false]]}] \ No newline at end of file