2017-11-30 11:47:56 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Common;
|
|
|
|
|
2019-11-16 10:21:14 +03:00
|
|
|
use App\Abstracts\Http\Controller;
|
2021-05-19 09:12:01 +03:00
|
|
|
use Akaunting\Module\Module;
|
2017-11-30 11:47:56 +03:00
|
|
|
|
|
|
|
class Import extends Controller
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Show the form for creating a new resource.
|
|
|
|
*
|
|
|
|
* @param $group
|
|
|
|
* @param $type
|
2021-05-19 09:12:01 +03:00
|
|
|
* @param $route
|
|
|
|
*
|
2017-11-30 11:47:56 +03:00
|
|
|
* @return Response
|
|
|
|
*/
|
2021-01-08 17:02:27 +03:00
|
|
|
public function create($group, $type, $route = null)
|
2017-11-30 11:47:56 +03:00
|
|
|
{
|
2021-04-16 00:59:43 +03:00
|
|
|
$path = company_id() . '/' . $group . '/' . $type;
|
2017-11-30 11:47:56 +03:00
|
|
|
|
2021-05-19 09:20:36 +03:00
|
|
|
$module = module($group);
|
|
|
|
|
|
|
|
if ($module instanceof Module) {
|
2021-05-19 09:12:01 +03:00
|
|
|
$title_type = trans_choice($group . '::general.' . str_replace('-', '_', $type), 2);
|
2021-05-19 09:20:36 +03:00
|
|
|
$sample_file = url('modules/' . $module->getStudlyName() . '/Resources/assets/' . $type . '.xlsx');
|
2021-05-19 09:12:01 +03:00
|
|
|
} else {
|
|
|
|
$title_type = trans_choice('general.' . str_replace('-', '_', $type), 2);
|
|
|
|
$sample_file = url('public/files/import/' . $type . '.xlsx');
|
|
|
|
}
|
|
|
|
|
|
|
|
$form_params = [
|
|
|
|
'id' => 'import',
|
|
|
|
'@submit.prevent' => 'onSubmit',
|
|
|
|
'@keydown' => 'form.errors.clear($event.target.name)',
|
|
|
|
'files' => true,
|
|
|
|
'role' => 'form',
|
|
|
|
'class' => 'form-loading-button',
|
|
|
|
'novalidate' => true,
|
2022-06-01 10:15:55 +03:00
|
|
|
'route' => '',
|
|
|
|
'url' => '',
|
2021-05-19 09:12:01 +03:00
|
|
|
];
|
|
|
|
|
2022-06-01 10:15:55 +03:00
|
|
|
if (! empty($route)) {
|
2021-05-19 09:12:01 +03:00
|
|
|
$form_params['route'] = $route;
|
2019-04-04 17:54:03 +03:00
|
|
|
} else {
|
2021-05-19 09:12:01 +03:00
|
|
|
$form_params['url'] = $path . '/import';
|
2019-04-04 17:54:03 +03:00
|
|
|
}
|
|
|
|
|
2021-05-19 09:12:01 +03:00
|
|
|
return view('common.import.create', compact('group', 'type', 'path', 'route', 'form_params', 'title_type', 'sample_file'));
|
2017-11-30 11:47:56 +03:00
|
|
|
}
|
|
|
|
}
|