mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-11 13:57:41 -08:00
Two things. One, try to make the import uploads directory if it doesn't exist. Two, call the object importer instead of the old asset importer. TODO: Feed output from object importer back to import page.
This commit is contained in:
parent
891c37b2ed
commit
715e385925
|
@ -744,6 +744,9 @@ class AssetsController extends Controller
|
|||
return redirect()->to('hardware')->with('error', trans('general.insufficient_permissions'));
|
||||
}
|
||||
|
||||
// Check if the uploads directory exists. If not, try to create it.
|
||||
if(!file_exists($path))
|
||||
mkdir($path, 0755);
|
||||
if ($handle = opendir($path)) {
|
||||
|
||||
/* This is the correct way to loop over the directory. */
|
||||
|
@ -841,7 +844,7 @@ class AssetsController extends Controller
|
|||
}
|
||||
|
||||
$output = new BufferedOutput;
|
||||
Artisan::call('asset-import:csv', ['filename'=> config('app.private_uploads').'/imports/assets/'.$filename, '--email_format'=>'firstname.lastname', '--username_format'=>'firstname.lastname'], $output);
|
||||
Artisan::call('snipeit:import', ['filename'=> config('app.private_uploads').'/imports/assets/'.$filename, '--email_format'=>'firstname.lastname', '--username_format'=>'firstname.lastname'], $output);
|
||||
$display_output = $output->fetch();
|
||||
$file = config('app.private_uploads').'/imports/assets/'.str_replace('.csv', '', $filename).'-output-'.date("Y-m-d-his").'.txt';
|
||||
file_put_contents($file, $display_output);
|
||||
|
|
Loading…
Reference in a new issue