mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Rename and move some files.
This commit is contained in:
parent
bc879a3872
commit
5866300ac1
@ -78,7 +78,9 @@ class ConfigurationController extends Controller
|
|||||||
|
|
||||||
return redirect(route('import.status', [$job->key]));
|
return redirect(route('import.status', [$job->key]));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->repository->updateStatus($job, 'configuring');
|
$this->repository->updateStatus($job, 'configuring');
|
||||||
|
|
||||||
$view = $configurator->getNextView();
|
$view = $configurator->getNextView();
|
||||||
$data = $configurator->getNextData();
|
$data = $configurator->getNextData();
|
||||||
$subTitle = trans('firefly.import_config_bread_crumb');
|
$subTitle = trans('firefly.import_config_bread_crumb');
|
||||||
|
@ -24,11 +24,12 @@ namespace FireflyIII\Import\Configuration;
|
|||||||
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Models\ImportJob;
|
use FireflyIII\Models\ImportJob;
|
||||||
|
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||||
use FireflyIII\Support\Import\Configuration\ConfigurationInterface;
|
use FireflyIII\Support\Import\Configuration\ConfigurationInterface;
|
||||||
use FireflyIII\Support\Import\Configuration\File\Initial;
|
use FireflyIII\Support\Import\Configuration\File\Initial;
|
||||||
use FireflyIII\Support\Import\Configuration\File\Map;
|
use FireflyIII\Support\Import\Configuration\File\Map;
|
||||||
use FireflyIII\Support\Import\Configuration\File\Roles;
|
use FireflyIII\Support\Import\Configuration\File\Roles;
|
||||||
use FireflyIII\Support\Import\Configuration\File\Upload;
|
use FireflyIII\Support\Import\Configuration\File\UploadConfig;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,9 +37,31 @@ use Log;
|
|||||||
*/
|
*/
|
||||||
class FileConfigurator implements ConfiguratorInterface
|
class FileConfigurator implements ConfiguratorInterface
|
||||||
{
|
{
|
||||||
|
/** @var array */
|
||||||
|
private $defaultConfig
|
||||||
|
= [
|
||||||
|
'stage' => 'initial',
|
||||||
|
'has-headers' => false, // assume
|
||||||
|
'date-format' => 'Ymd', // assume
|
||||||
|
'delimiter' => ',', // assume
|
||||||
|
'import-account' => 0, // none,
|
||||||
|
'specifics' => [], // none
|
||||||
|
'column-count' => 0, // unknown
|
||||||
|
'column-roles' => [], // unknown
|
||||||
|
'column-do-mapping' => [], // not yet set which columns must be mapped
|
||||||
|
'column-mapping-config' => [], // no mapping made yet.
|
||||||
|
'has-config-file' => true,
|
||||||
|
'apply-rules' => true,
|
||||||
|
'match-bills' => false,
|
||||||
|
'auto-start' => false,
|
||||||
|
];
|
||||||
/** @var ImportJob */
|
/** @var ImportJob */
|
||||||
private $job;
|
private $job;
|
||||||
|
/** @var ImportJobRepositoryInterface */
|
||||||
|
private $repository;
|
||||||
|
|
||||||
|
|
||||||
|
// give job default config:
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $warning = '';
|
private $warning = '';
|
||||||
|
|
||||||
@ -61,6 +84,9 @@ class FileConfigurator implements ConfiguratorInterface
|
|||||||
*/
|
*/
|
||||||
public function configureJob(array $data): bool
|
public function configureJob(array $data): bool
|
||||||
{
|
{
|
||||||
|
if (is_null($this->job)) {
|
||||||
|
throw new FireflyException('Cannot call configureJob() without a job.');
|
||||||
|
}
|
||||||
$class = $this->getConfigurationClass();
|
$class = $this->getConfigurationClass();
|
||||||
$job = $this->job;
|
$job = $this->job;
|
||||||
/** @var ConfigurationInterface $object */
|
/** @var ConfigurationInterface $object */
|
||||||
@ -81,6 +107,10 @@ class FileConfigurator implements ConfiguratorInterface
|
|||||||
*/
|
*/
|
||||||
public function getNextData(): array
|
public function getNextData(): array
|
||||||
{
|
{
|
||||||
|
if (is_null($this->job)) {
|
||||||
|
throw new FireflyException('Cannot call getNextData() without a job.');
|
||||||
|
}
|
||||||
|
|
||||||
$class = $this->getConfigurationClass();
|
$class = $this->getConfigurationClass();
|
||||||
$job = $this->job;
|
$job = $this->job;
|
||||||
/** @var ConfigurationInterface $object */
|
/** @var ConfigurationInterface $object */
|
||||||
@ -97,50 +127,51 @@ class FileConfigurator implements ConfiguratorInterface
|
|||||||
*/
|
*/
|
||||||
public function getNextView(): string
|
public function getNextView(): string
|
||||||
{
|
{
|
||||||
if (!$this->job->configuration['has-file-upload']) {
|
if (is_null($this->job)) {
|
||||||
return 'import.file.upload';
|
throw new FireflyException('Cannot call getNextView() without a job.');
|
||||||
}
|
}
|
||||||
if (!$this->job->configuration['initial-config-complete']) {
|
$config = $this->getConfig();
|
||||||
return 'import.file.initial';
|
$stage = $config['stage'] ?? 'initial';
|
||||||
|
switch($stage) {
|
||||||
|
case 'initial': // has nothing, no file upload or anything.
|
||||||
|
return 'import.file.initial';
|
||||||
|
case 'upload-config': // has file, needs file config.
|
||||||
|
return 'import.file.upload-config';
|
||||||
|
case 'roles': // has configured file, needs roles.
|
||||||
|
return 'import.file.roles';
|
||||||
|
case 'map': // has roles, needs mapping.
|
||||||
|
return 'import.file.map';
|
||||||
}
|
}
|
||||||
if (!$this->job->configuration['column-roles-complete']) {
|
throw new FireflyException(sprintf('No view for stage "%s"', $stage));
|
||||||
return 'import.file.roles';
|
|
||||||
}
|
|
||||||
if (!$this->job->configuration['column-mapping-complete']) {
|
|
||||||
return 'import.file.map';
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new FireflyException('No view for state');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return possible warning to user.
|
* Return possible warning to user.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function getWarningMessage(): string
|
public function getWarningMessage(): string
|
||||||
{
|
{
|
||||||
|
if (is_null($this->job)) {
|
||||||
|
throw new FireflyException('Cannot call getWarningMessage() without a job.');
|
||||||
|
}
|
||||||
|
|
||||||
return $this->warning;
|
return $this->warning;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function isJobConfigured(): bool
|
public function isJobConfigured(): bool
|
||||||
{
|
{
|
||||||
$config = $this->job->configuration;
|
if (is_null($this->job)) {
|
||||||
$config['has-file-upload'] = $config['has-file-upload'] ?? false;
|
throw new FireflyException('Cannot call isJobConfigured() without a job.');
|
||||||
$config['initial-config-complete'] = $config['initial-config-complete'] ?? false;
|
}
|
||||||
$config['column-roles-complete'] = $config['column-roles-complete'] ?? false;
|
$config = $this->getConfig();
|
||||||
$config['column-mapping-complete'] = $config['column-mapping-complete'] ?? false;
|
$stage = $config['stage'] ?? 'initial';
|
||||||
$this->job->configuration = $config;
|
if ($stage === 'ready') {
|
||||||
$this->job->save();
|
|
||||||
|
|
||||||
if ($config['initial-config-complete']
|
|
||||||
&& $config['column-roles-complete']
|
|
||||||
&& $config['column-mapping-complete']
|
|
||||||
&& $config['has-file-upload']
|
|
||||||
) {
|
|
||||||
Log::debug('isJobConfigured returns true');
|
Log::debug('isJobConfigured returns true');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -155,30 +186,20 @@ class FileConfigurator implements ConfiguratorInterface
|
|||||||
*/
|
*/
|
||||||
public function setJob(ImportJob $job)
|
public function setJob(ImportJob $job)
|
||||||
{
|
{
|
||||||
$this->job = $job;
|
$this->job = $job;
|
||||||
// give job default config:
|
$this->repository = app(ImportJobRepositoryInterface::class);
|
||||||
$defaultConfig = [
|
$this->repository->setUser($job->user);
|
||||||
'initial-config-complete' => false,
|
$this->repository->setConfiguration($job, $this->defaultConfig);
|
||||||
'has-headers' => false, // assume
|
}
|
||||||
'date-format' => 'Ymd', // assume
|
|
||||||
'delimiter' => ',', // assume
|
/**
|
||||||
'import-account' => 0, // none,
|
* Short hand method.
|
||||||
'specifics' => [], // none
|
*
|
||||||
'column-count' => 0, // unknown
|
* @return array
|
||||||
'column-roles' => [], // unknown
|
*/
|
||||||
'column-do-mapping' => [], // not yet set which columns must be mapped
|
private function getConfig(): array
|
||||||
'column-roles-complete' => false, // not yet configured roles for columns
|
{
|
||||||
'column-mapping-config' => [], // no mapping made yet.
|
return $this->repository->getConfiguration($this->job);
|
||||||
'column-mapping-complete' => false, // so mapping is not complete.
|
|
||||||
'has-config-file' => true,
|
|
||||||
'apply-rules' => true,
|
|
||||||
'match-bills' => false,
|
|
||||||
'auto-start' => false,
|
|
||||||
];
|
|
||||||
$config = $this->job->configuration ?? [];
|
|
||||||
$finalConfig = array_merge($defaultConfig, $config);
|
|
||||||
$this->job->configuration = $finalConfig;
|
|
||||||
$this->job->save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -188,21 +209,22 @@ class FileConfigurator implements ConfiguratorInterface
|
|||||||
*/
|
*/
|
||||||
private function getConfigurationClass(): string
|
private function getConfigurationClass(): string
|
||||||
{
|
{
|
||||||
|
$config = $this->getConfig();
|
||||||
|
$stage = $config['stage'] ?? 'initial';
|
||||||
|
$class = false;
|
||||||
|
Log::debug(sprintf('Now in getConfigurationClass() for stage "%s"', $stage));
|
||||||
|
|
||||||
$class = false;
|
switch ($stage) {
|
||||||
switch (true) {
|
case 'initial': // has nothing, no file upload or anything.
|
||||||
case !$this->job->configuration['has-file-upload']:
|
|
||||||
$class = Upload::class;
|
|
||||||
break;
|
|
||||||
case !$this->job->configuration['initial-config-complete']:
|
|
||||||
Log::debug(sprintf('Class is %s', Initial::class));
|
|
||||||
Log::debug(sprintf('initial-config-complete is %s', var_export($this->job->configuration['initial-config-complete'], true)));
|
|
||||||
$class = Initial::class;
|
$class = Initial::class;
|
||||||
break;
|
break;
|
||||||
case !$this->job->configuration['column-roles-complete']:
|
case 'upload-config': // has file, needs file config.
|
||||||
|
$class = UploadConfig::class;
|
||||||
|
break;
|
||||||
|
case 'roles': // has configured file, needs roles.
|
||||||
$class = Roles::class;
|
$class = Roles::class;
|
||||||
break;
|
break;
|
||||||
case !$this->job->configuration['column-mapping-complete']:
|
case 'map': // has roles, needs mapping.
|
||||||
$class = Map::class;
|
$class = Map::class;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -86,6 +86,7 @@ class ImportJobRepository implements ImportJobRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function findByKey(string $key): ImportJob
|
public function findByKey(string $key): ImportJob
|
||||||
{
|
{
|
||||||
|
/** @var ImportJob $result */
|
||||||
$result = $this->user->importJobs()->where('key', $key)->first(['import_jobs.*']);
|
$result = $this->user->importJobs()->where('key', $key)->first(['import_jobs.*']);
|
||||||
if (null === $result) {
|
if (null === $result) {
|
||||||
return new ImportJob;
|
return new ImportJob;
|
||||||
@ -94,6 +95,23 @@ class ImportJobRepository implements ImportJobRepositoryInterface
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return configuration of job.
|
||||||
|
*
|
||||||
|
* @param ImportJob $job
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getConfiguration(ImportJob $job): array
|
||||||
|
{
|
||||||
|
$config = $job->configuration;
|
||||||
|
if (is_array($config)) {
|
||||||
|
return $config;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ImportJob $job
|
* @param ImportJob $job
|
||||||
* @param UploadedFile $file
|
* @param UploadedFile $file
|
||||||
|
@ -45,6 +45,15 @@ interface ImportJobRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function findByKey(string $key): ImportJob;
|
public function findByKey(string $key): ImportJob;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return configuration of job.
|
||||||
|
*
|
||||||
|
* @param ImportJob $job
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getConfiguration(ImportJob $job): array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ImportJob $job
|
* @param ImportJob $job
|
||||||
* @param UploadedFile $file
|
* @param UploadedFile $file
|
||||||
|
@ -22,62 +22,40 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Support\Import\Configuration\File;
|
namespace FireflyIII\Support\Import\Configuration\File;
|
||||||
|
|
||||||
use ExpandedForm;
|
|
||||||
use FireflyIII\Models\AccountType;
|
|
||||||
use FireflyIII\Models\ImportJob;
|
use FireflyIII\Models\ImportJob;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||||
use FireflyIII\Support\Import\Configuration\ConfigurationInterface;
|
use FireflyIII\Support\Import\Configuration\ConfigurationInterface;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class CsvInitial.
|
* Class Initial.
|
||||||
*/
|
*/
|
||||||
class Initial implements ConfigurationInterface
|
class Initial implements ConfigurationInterface
|
||||||
{
|
{
|
||||||
/**
|
/** @var ImportJob */
|
||||||
* @var ImportJob
|
|
||||||
*/
|
|
||||||
private $job;
|
private $job;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
private $warning = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Get the data necessary to show the configuration screen.
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getData(): array
|
public function getData(): array
|
||||||
{
|
{
|
||||||
/** @var AccountRepositoryInterface $accountRepository */
|
$importFileTypes = [];
|
||||||
$accountRepository = app(AccountRepositoryInterface::class);
|
$defaultImportType = config('import.options.file.default_import_format');
|
||||||
$accounts = $accountRepository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
|
||||||
$delimiters = [
|
|
||||||
',' => trans('form.csv_comma'),
|
|
||||||
';' => trans('form.csv_semicolon'),
|
|
||||||
'tab' => trans('form.csv_tab'),
|
|
||||||
];
|
|
||||||
|
|
||||||
// update job with default date format:
|
foreach (config('import.options.file.import_formats') as $type) {
|
||||||
$config = $this->job->configuration;
|
$importFileTypes[$type] = trans('import.import_file_type_' . $type);
|
||||||
if (!isset($config['date-format'])) {
|
|
||||||
$config['date-format'] = 'Ymd';
|
|
||||||
$this->job->configuration = $config;
|
|
||||||
$this->job->save();
|
|
||||||
}
|
|
||||||
$specifics = [];
|
|
||||||
|
|
||||||
// collect specifics.
|
|
||||||
foreach (config('csv.import_specifics') as $name => $className) {
|
|
||||||
$specifics[$name] = [
|
|
||||||
'name' => $className::getName(),
|
|
||||||
'description' => $className::getDescription(),
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = [
|
return [
|
||||||
'accounts' => ExpandedForm::makeSelectList($accounts),
|
'default_type' => $defaultImportType,
|
||||||
'specifix' => [],
|
'file_types' => $importFileTypes,
|
||||||
'delimiters' => $delimiters,
|
|
||||||
'specifics' => $specifics,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -87,7 +65,7 @@ class Initial implements ConfigurationInterface
|
|||||||
*/
|
*/
|
||||||
public function getWarningMessage(): string
|
public function getWarningMessage(): string
|
||||||
{
|
{
|
||||||
return '';
|
return $this->warning;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -111,67 +89,28 @@ class Initial implements ConfigurationInterface
|
|||||||
*/
|
*/
|
||||||
public function storeConfiguration(array $data): bool
|
public function storeConfiguration(array $data): bool
|
||||||
{
|
{
|
||||||
Log::debug('Now in Initial::storeConfiguration()');
|
Log::debug('Now in storeConfiguration for file Upload.');
|
||||||
|
/** @var ImportJobRepositoryInterface $repository */
|
||||||
// get config from job:
|
$repository = app(ImportJobRepositoryInterface::class);
|
||||||
$config = $this->job->configuration;
|
$type = $data['import_file_type'] ?? 'unknown';
|
||||||
|
$config = $this->job->configuration;
|
||||||
// find import account:
|
$config['file-type'] = in_array($type, config('import.options.file.import_formats')) ? $type : 'unknown';
|
||||||
/** @var AccountRepositoryInterface $repository */
|
$repository->setConfiguration($this->job, $config);
|
||||||
$repository = app(AccountRepositoryInterface::class);
|
$uploaded = $repository->processFile($this->job, $data['import_file'] ?? null);
|
||||||
$importId = intval($data['csv_import_account'] ?? 0);
|
|
||||||
$account = $repository->find($importId);
|
|
||||||
|
|
||||||
// set "headers":
|
|
||||||
$config['initial-config-complete'] = true;
|
|
||||||
$config['has-headers'] = intval($data['has_headers'] ?? 0) === 1;
|
|
||||||
$config['date-format'] = $data['date_format'];
|
|
||||||
$config['delimiter'] = $data['csv_delimiter'];
|
|
||||||
$config['delimiter'] = 'tab' === $config['delimiter'] ? "\t" : $config['delimiter'];
|
|
||||||
$config['apply-rules'] = intval($data['apply_rules'] ?? 0) === 1;
|
|
||||||
$config['match-bills'] = intval($data['match_bills'] ?? 0) === 1;
|
|
||||||
|
|
||||||
Log::debug('Entered import account.', ['id' => $importId]);
|
|
||||||
|
|
||||||
|
|
||||||
if (null !== $account->id) {
|
|
||||||
Log::debug('Found account.', ['id' => $account->id, 'name' => $account->name]);
|
|
||||||
$config['import-account'] = $account->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null === $account->id) {
|
|
||||||
Log::error('Could not find anything for csv_import_account.', ['id' => $importId]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$config = $this->storeSpecifics($data, $config);
|
|
||||||
Log::debug('Final config is ', $config);
|
|
||||||
|
|
||||||
$this->job->configuration = $config;
|
|
||||||
$this->job->save();
|
$this->job->save();
|
||||||
|
Log::debug(sprintf('Result of upload is %s', var_export($uploaded, true)));
|
||||||
|
// process config, if present:
|
||||||
|
if (isset($data['configuration_file'])) {
|
||||||
|
$repository->processConfiguration($this->job, $data['configuration_file']);
|
||||||
|
}
|
||||||
|
$config = $this->job->configuration;
|
||||||
|
$config['has-file-upload'] = $uploaded;
|
||||||
|
$repository->setConfiguration($this->job, $config);
|
||||||
|
|
||||||
|
if (false === $uploaded) {
|
||||||
|
$this->warning = 'No valid upload.';
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $data
|
|
||||||
* @param array $config
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function storeSpecifics(array $data, array $config): array
|
|
||||||
{
|
|
||||||
// loop specifics.
|
|
||||||
if (isset($data['specifics']) && is_array($data['specifics'])) {
|
|
||||||
$names = array_keys($data['specifics']);
|
|
||||||
foreach ($names as $name) {
|
|
||||||
// verify their content.
|
|
||||||
$className = sprintf('FireflyIII\Import\Specifics\%s', $name);
|
|
||||||
if (class_exists($className)) {
|
|
||||||
$config['specifics'][$name] = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $config;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,116 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Upload.php
|
|
||||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
|
||||||
*
|
|
||||||
* This file is part of Firefly III.
|
|
||||||
*
|
|
||||||
* Firefly III is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Firefly III is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace FireflyIII\Support\Import\Configuration\File;
|
|
||||||
|
|
||||||
use FireflyIII\Models\ImportJob;
|
|
||||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
|
||||||
use FireflyIII\Support\Import\Configuration\ConfigurationInterface;
|
|
||||||
use Log;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class Upload.
|
|
||||||
*/
|
|
||||||
class Upload implements ConfigurationInterface
|
|
||||||
{
|
|
||||||
/** @var ImportJob */
|
|
||||||
private $job;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $warning = '';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the data necessary to show the configuration screen.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getData(): array
|
|
||||||
{
|
|
||||||
$importFileTypes = [];
|
|
||||||
$defaultImportType = config('import.options.file.default_import_format');
|
|
||||||
|
|
||||||
foreach (config('import.options.file.import_formats') as $type) {
|
|
||||||
$importFileTypes[$type] = trans('import.import_file_type_' . $type);
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
'default_type' => $defaultImportType,
|
|
||||||
'file_types' => $importFileTypes,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return possible warning to user.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getWarningMessage(): string
|
|
||||||
{
|
|
||||||
return $this->warning;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ImportJob $job
|
|
||||||
*
|
|
||||||
* @return ConfigurationInterface
|
|
||||||
*/
|
|
||||||
public function setJob(ImportJob $job): ConfigurationInterface
|
|
||||||
{
|
|
||||||
$this->job = $job;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store the result.
|
|
||||||
*
|
|
||||||
* @param array $data
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function storeConfiguration(array $data): bool
|
|
||||||
{
|
|
||||||
Log::debug('Now in storeConfiguration for file Upload.');
|
|
||||||
/** @var ImportJobRepositoryInterface $repository */
|
|
||||||
$repository = app(ImportJobRepositoryInterface::class);
|
|
||||||
$type = $data['import_file_type'] ?? 'unknown';
|
|
||||||
$config = $this->job->configuration;
|
|
||||||
$config['file-type'] = in_array($type, config('import.options.file.import_formats')) ? $type : 'unknown';
|
|
||||||
$repository->setConfiguration($this->job, $config);
|
|
||||||
$uploaded = $repository->processFile($this->job, $data['import_file'] ?? null);
|
|
||||||
$this->job->save();
|
|
||||||
Log::debug(sprintf('Result of upload is %s', var_export($uploaded, true)));
|
|
||||||
// process config, if present:
|
|
||||||
if (isset($data['configuration_file'])) {
|
|
||||||
$repository->processConfiguration($this->job, $data['configuration_file']);
|
|
||||||
}
|
|
||||||
$config = $this->job->configuration;
|
|
||||||
$config['has-file-upload'] = $uploaded;
|
|
||||||
$repository->setConfiguration($this->job, $config);
|
|
||||||
|
|
||||||
if (false === $uploaded) {
|
|
||||||
$this->warning = 'No valid upload.';
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
177
app/Support/Import/Configuration/File/UploadConfig.php
Normal file
177
app/Support/Import/Configuration/File/UploadConfig.php
Normal file
@ -0,0 +1,177 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* UploadConfig.php
|
||||||
|
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This file is part of Firefly III.
|
||||||
|
*
|
||||||
|
* Firefly III is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Firefly III is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace FireflyIII\Support\Import\Configuration\File;
|
||||||
|
|
||||||
|
use ExpandedForm;
|
||||||
|
use FireflyIII\Models\AccountType;
|
||||||
|
use FireflyIII\Models\ImportJob;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
|
use FireflyIII\Support\Import\Configuration\ConfigurationInterface;
|
||||||
|
use Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class UploadConfig.
|
||||||
|
*/
|
||||||
|
class UploadConfig implements ConfigurationInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var ImportJob
|
||||||
|
*/
|
||||||
|
private $job;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getData(): array
|
||||||
|
{
|
||||||
|
/** @var AccountRepositoryInterface $accountRepository */
|
||||||
|
$accountRepository = app(AccountRepositoryInterface::class);
|
||||||
|
$accounts = $accountRepository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
||||||
|
$delimiters = [
|
||||||
|
',' => trans('form.csv_comma'),
|
||||||
|
';' => trans('form.csv_semicolon'),
|
||||||
|
'tab' => trans('form.csv_tab'),
|
||||||
|
];
|
||||||
|
|
||||||
|
// update job with default date format:
|
||||||
|
$config = $this->job->configuration;
|
||||||
|
if (!isset($config['date-format'])) {
|
||||||
|
$config['date-format'] = 'Ymd';
|
||||||
|
$this->job->configuration = $config;
|
||||||
|
$this->job->save();
|
||||||
|
}
|
||||||
|
$specifics = [];
|
||||||
|
|
||||||
|
// collect specifics.
|
||||||
|
foreach (config('csv.import_specifics') as $name => $className) {
|
||||||
|
$specifics[$name] = [
|
||||||
|
'name' => $className::getName(),
|
||||||
|
'description' => $className::getDescription(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'accounts' => ExpandedForm::makeSelectList($accounts),
|
||||||
|
'specifix' => [],
|
||||||
|
'delimiters' => $delimiters,
|
||||||
|
'specifics' => $specifics,
|
||||||
|
];
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return possible warning to user.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getWarningMessage(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ImportJob $job
|
||||||
|
*
|
||||||
|
* @return ConfigurationInterface
|
||||||
|
*/
|
||||||
|
public function setJob(ImportJob $job): ConfigurationInterface
|
||||||
|
{
|
||||||
|
$this->job = $job;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store the result.
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function storeConfiguration(array $data): bool
|
||||||
|
{
|
||||||
|
Log::debug('Now in Initial::storeConfiguration()');
|
||||||
|
|
||||||
|
// get config from job:
|
||||||
|
$config = $this->job->configuration;
|
||||||
|
|
||||||
|
// find import account:
|
||||||
|
/** @var AccountRepositoryInterface $repository */
|
||||||
|
$repository = app(AccountRepositoryInterface::class);
|
||||||
|
$importId = intval($data['csv_import_account'] ?? 0);
|
||||||
|
$account = $repository->find($importId);
|
||||||
|
|
||||||
|
// set "headers":
|
||||||
|
$config['initial-config-complete'] = true;
|
||||||
|
$config['has-headers'] = intval($data['has_headers'] ?? 0) === 1;
|
||||||
|
$config['date-format'] = $data['date_format'];
|
||||||
|
$config['delimiter'] = $data['csv_delimiter'];
|
||||||
|
$config['delimiter'] = 'tab' === $config['delimiter'] ? "\t" : $config['delimiter'];
|
||||||
|
$config['apply-rules'] = intval($data['apply_rules'] ?? 0) === 1;
|
||||||
|
$config['match-bills'] = intval($data['match_bills'] ?? 0) === 1;
|
||||||
|
|
||||||
|
Log::debug('Entered import account.', ['id' => $importId]);
|
||||||
|
|
||||||
|
|
||||||
|
if (null !== $account->id) {
|
||||||
|
Log::debug('Found account.', ['id' => $account->id, 'name' => $account->name]);
|
||||||
|
$config['import-account'] = $account->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null === $account->id) {
|
||||||
|
Log::error('Could not find anything for csv_import_account.', ['id' => $importId]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$config = $this->storeSpecifics($data, $config);
|
||||||
|
Log::debug('Final config is ', $config);
|
||||||
|
|
||||||
|
$this->job->configuration = $config;
|
||||||
|
$this->job->save();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
* @param array $config
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function storeSpecifics(array $data, array $config): array
|
||||||
|
{
|
||||||
|
// loop specifics.
|
||||||
|
if (isset($data['specifics']) && is_array($data['specifics'])) {
|
||||||
|
$names = array_keys($data['specifics']);
|
||||||
|
foreach ($names as $name) {
|
||||||
|
// verify their content.
|
||||||
|
$className = sprintf('FireflyIII\Import\Specifics\%s', $name);
|
||||||
|
if (class_exists($className)) {
|
||||||
|
$config['specifics'][$name] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $config;
|
||||||
|
}
|
||||||
|
}
|
@ -1,20 +1,18 @@
|
|||||||
{% extends "./layout/default" %}
|
{% extends "./layout/default" %}
|
||||||
|
|
||||||
{% block breadcrumbs %}
|
{% block breadcrumbs %}
|
||||||
{{ Breadcrumbs.render(Route.getCurrentRoute.getName, job) }}
|
{{ Breadcrumbs.render }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="box-header with-border">
|
<div class="box-header with-border">
|
||||||
<h3 class="box-title">{{ trans('import.csv_initial_title') }}</h3>
|
<h3 class="box-title">{{ trans('import.file_upload_title') }}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-body">
|
<div class="box-body">
|
||||||
<p>
|
<p>
|
||||||
{{ trans('import.csv_initial_text') }}
|
{{ trans('import.file_upload_text') }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -22,72 +20,20 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form class="form-horizontal" action="{{ route('import.configure.post', job.key) }}" method="post" enctype="multipart/form-data">
|
<form method="POST" action="{{ route('import.configure.post', job.key) }}" accept-charset="UTF-8" class="form-horizontal" enctype="multipart/form-data">
|
||||||
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
<input name="_token" type="hidden" value="{{ csrf_token() }}">
|
||||||
|
<input type="hidden" name="settings" value="upload"/>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="box-header with-border">
|
<div class="box-header with-border">
|
||||||
<h3 class="box-title">{{ trans('import.csv_initial_box_title') }}</h3>
|
<h3 class="box-title">{{ trans('import.file_upload_fields') }}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-body">
|
<div class="box-body">
|
||||||
<div class="row">
|
{{ ExpandedForm.file('import_file', {helpText: trans('import.file_upload_help')}) }}
|
||||||
<div class="col-lg-6">
|
{{ ExpandedForm.file('configuration_file', {helpText: trans('import.file_upload_config_help')|raw}) }}
|
||||||
<h4>{{ 'mandatoryFields'|_ }}</h4>
|
{{ ExpandedForm.select('import_file_type', data.file_types, data.default_type, {'helpText' : trans('import.file_upload_type_help')}) }}
|
||||||
{{ ExpandedForm.checkbox('has_headers',1,job.configuration['has-headers'],{helpText: trans('import.csv_initial_header_help')}) }}
|
|
||||||
{{ ExpandedForm.text('date_format',job.configuration['date-format'],{helpText: trans('import.csv_initial_date_help', {dateExample: phpdate('Ymd')}) }) }}
|
|
||||||
{{ ExpandedForm.select('csv_delimiter', data.delimiters, job.configuration['delimiter'], {helpText: trans('import.csv_initial_delimiter_help') } ) }}
|
|
||||||
{{ ExpandedForm.select('csv_import_account', data.accounts, job.configuration['import-account'], {helpText: trans('import.csv_initial_import_account_help')} ) }}
|
|
||||||
|
|
||||||
<h4>{{ 'optionalFields'|_ }}</h4>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="apply_rules_label" class="col-sm-4 control-label">
|
|
||||||
{{ trans('import.file_apply_rules_title') }}
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<div class="checkbox"><label>
|
|
||||||
{{ Form.checkbox('apply_rules', '1',
|
|
||||||
job.configuration.apply_rules == '1', {'id': 'apply_rules_label'}) }}
|
|
||||||
{{ trans('import.file_apply_rules_description') }}
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="match_bills_label" class="col-sm-4 control-label">
|
|
||||||
{{ trans('import.file_match_bills_title') }}
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<div class="checkbox"><label>
|
|
||||||
{{ Form.checkbox('match_bills', '1',
|
|
||||||
job.configuration.match_bills == '1', {'id': 'match_bills_label'}) }}
|
|
||||||
{{ trans('import.file_match_bills_description') }}
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% for type, specific in data.specifics %}
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="{{ type }}_label" class="col-sm-4 control-label">
|
|
||||||
{{ specific.name }}
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<div class="checkbox"><label>
|
|
||||||
{{ Form.checkbox('specifics['~type~']', '1',
|
|
||||||
job.configuration.specifics[type] == '1', {'id': type ~ '_label'}) }}
|
|
||||||
{{ specific.description }}
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -96,16 +42,16 @@
|
|||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="box-body">
|
<div class="box-body">
|
||||||
<button type="submit" class="pull-right btn btn-success">
|
<button type="submit" class="btn btn-success pull-right">
|
||||||
{{ trans('import.csv_initial_submit') }}
|
{{ trans('import.file_upload_submit') }} <i class="fa fa-arrow-right"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
{% endblock %}
|
||||||
|
{% block scripts %}
|
||||||
|
{% endblock %}
|
||||||
|
{% block styles %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
111
resources/views/import/file/upload-config.twig
Normal file
111
resources/views/import/file/upload-config.twig
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
{% extends "./layout/default" %}
|
||||||
|
|
||||||
|
{% block breadcrumbs %}
|
||||||
|
{{ Breadcrumbs.render(Route.getCurrentRoute.getName, job) }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<div class="box">
|
||||||
|
<div class="box-header with-border">
|
||||||
|
<h3 class="box-title">{{ trans('import.csv_initial_title') }}</h3>
|
||||||
|
</div>
|
||||||
|
<div class="box-body">
|
||||||
|
<p>
|
||||||
|
{{ trans('import.csv_initial_text') }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form class="form-horizontal" action="{{ route('import.configure.post', job.key) }}" method="post" enctype="multipart/form-data">
|
||||||
|
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<div class="box">
|
||||||
|
<div class="box-header with-border">
|
||||||
|
<h3 class="box-title">{{ trans('import.csv_initial_box_title') }}</h3>
|
||||||
|
</div>
|
||||||
|
<div class="box-body">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<h4>{{ 'mandatoryFields'|_ }}</h4>
|
||||||
|
{{ ExpandedForm.checkbox('has_headers',1,job.configuration['has-headers'],{helpText: trans('import.csv_initial_header_help')}) }}
|
||||||
|
{{ ExpandedForm.text('date_format',job.configuration['date-format'],{helpText: trans('import.csv_initial_date_help', {dateExample: phpdate('Ymd')}) }) }}
|
||||||
|
{{ ExpandedForm.select('csv_delimiter', data.delimiters, job.configuration['delimiter'], {helpText: trans('import.csv_initial_delimiter_help') } ) }}
|
||||||
|
{{ ExpandedForm.select('csv_import_account', data.accounts, job.configuration['import-account'], {helpText: trans('import.csv_initial_import_account_help')} ) }}
|
||||||
|
|
||||||
|
<h4>{{ 'optionalFields'|_ }}</h4>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="apply_rules_label" class="col-sm-4 control-label">
|
||||||
|
{{ trans('import.file_apply_rules_title') }}
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<div class="checkbox"><label>
|
||||||
|
{{ Form.checkbox('apply_rules', '1',
|
||||||
|
job.configuration.apply_rules == '1', {'id': 'apply_rules_label'}) }}
|
||||||
|
{{ trans('import.file_apply_rules_description') }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="match_bills_label" class="col-sm-4 control-label">
|
||||||
|
{{ trans('import.file_match_bills_title') }}
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<div class="checkbox"><label>
|
||||||
|
{{ Form.checkbox('match_bills', '1',
|
||||||
|
job.configuration.match_bills == '1', {'id': 'match_bills_label'}) }}
|
||||||
|
{{ trans('import.file_match_bills_description') }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% for type, specific in data.specifics %}
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="{{ type }}_label" class="col-sm-4 control-label">
|
||||||
|
{{ specific.name }}
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<div class="checkbox"><label>
|
||||||
|
{{ Form.checkbox('specifics['~type~']', '1',
|
||||||
|
job.configuration.specifics[type] == '1', {'id': type ~ '_label'}) }}
|
||||||
|
{{ specific.description }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<div class="box">
|
||||||
|
<div class="box-body">
|
||||||
|
<button type="submit" class="pull-right btn btn-success">
|
||||||
|
{{ trans('import.csv_initial_submit') }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
@ -1,57 +0,0 @@
|
|||||||
{% extends "./layout/default" %}
|
|
||||||
|
|
||||||
{% block breadcrumbs %}
|
|
||||||
{{ Breadcrumbs.render }}
|
|
||||||
{% endblock %}
|
|
||||||
{% block content %}
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-12">
|
|
||||||
<div class="box">
|
|
||||||
<div class="box-header with-border">
|
|
||||||
<h3 class="box-title">{{ trans('import.file_upload_title') }}</h3>
|
|
||||||
</div>
|
|
||||||
<div class="box-body">
|
|
||||||
<p>
|
|
||||||
{{ trans('import.file_upload_text') }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<form method="POST" action="{{ route('import.configure.post', job.key) }}" accept-charset="UTF-8" class="form-horizontal" enctype="multipart/form-data">
|
|
||||||
<input name="_token" type="hidden" value="{{ csrf_token() }}">
|
|
||||||
<input type="hidden" name="settings" value="upload"/>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-12">
|
|
||||||
<div class="box">
|
|
||||||
<div class="box-header with-border">
|
|
||||||
<h3 class="box-title">{{ trans('import.file_upload_fields') }}</h3>
|
|
||||||
</div>
|
|
||||||
<div class="box-body">
|
|
||||||
{{ ExpandedForm.file('import_file', {helpText: trans('import.file_upload_help')}) }}
|
|
||||||
{{ ExpandedForm.file('configuration_file', {helpText: trans('import.file_upload_config_help')|raw}) }}
|
|
||||||
{{ ExpandedForm.select('import_file_type', data.file_types, data.default_type, {'helpText' : trans('import.file_upload_type_help')}) }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-12">
|
|
||||||
<div class="box">
|
|
||||||
<div class="box-body">
|
|
||||||
<button type="submit" class="btn btn-success pull-right">
|
|
||||||
{{ trans('import.file_upload_submit') }} <i class="fa fa-arrow-right"></i>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
{% endblock %}
|
|
||||||
{% block scripts %}
|
|
||||||
{% endblock %}
|
|
||||||
{% block styles %}
|
|
||||||
{% endblock %}
|
|
Loading…
Reference in New Issue
Block a user