Merge branch 'develop' of github.com:snipe/snipe-it into develop

This commit is contained in:
snipe 2017-05-08 20:07:03 -07:00
commit b7843ea565
5 changed files with 13 additions and 10 deletions

View file

@ -72,6 +72,7 @@ class PaveIt extends Command
Statuslabel::getQuery()->delete();
Supplier::getQuery()->delete();
Group::getQuery()->delete();
Import::getQuery()->delete();
DB::statement('delete from accessories_users');
DB::statement('delete from asset_logs');
@ -131,6 +132,7 @@ class PaveIt extends Command
\DB::statement('drop table IF EXISTS throttle');
\DB::statement('drop table IF EXISTS users_groups');
\DB::statement('drop table IF EXISTS users');
\DB::statement('drop table IF EXISTS imports');
}
}
}

View file

@ -45,7 +45,6 @@ class ImportController extends Controller
$results = [];
$import = new Import;
foreach ($files as $file) {
if (!in_array($file->getMimeType(), array(
'application/vnd.ms-excel',
'text/csv',
@ -53,7 +52,7 @@ class ImportController extends Controller
'text/comma-separated-values',
'text/tsv'))) {
$results['error']='File type must be CSV';
return $results;
return response()->json(Helper::formatStandardApiResponse('error', null, $results['error']), 500);
}
$date = date('Y-m-d-his');
@ -132,7 +131,7 @@ class ImportController extends Controller
try {
unlink(config('app.private_uploads').'/imports/'.$import->file_path);
$import->delete();
return response()->json(Helper::formatStandardApiResponse('success', null, trans('message.import.file_delete_success')));
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/hardware/message.import.file_delete_success')));
} catch (\Exception $e) {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/hardware/message.import.file_delete_error')), 500);
}

View file

@ -24,8 +24,10 @@ class AssetImporter extends ItemImporter
parent::handle($row);
foreach ($this->customFields as $customField) {
if ($this->item['custom_fields'][$customField->db_column_name()] = $this->array_smart_custom_field_fetch($row, $customField)) {
$this->log('Custom Field '. $customField->name.': '.$this->array_smart_custom_field_fetch($row, $customField));
$customFieldValue = $this->array_smart_custom_field_fetch($row, $customField);
if ($customFieldValue) {
$this->item['custom_fields'][$customField->db_column_name()] = $customFieldValue;
$this->log('Custom Field '. $customField->name.': '.$customFieldValue);
}
}
@ -87,7 +89,6 @@ class AssetImporter extends ItemImporter
$asset->{$custom_field} = $val;
}
}
if (!$this->testRun) {
if ($asset->save()) {
$asset->logCreate('Imported using csv importer');

View file

@ -55,7 +55,7 @@ abstract class Importer
* ObjectImporter constructor.
* @param string $filename
*/
public function __construct(string $filename)
public function __construct($filename)
{
$this->filename = $filename;
@ -91,7 +91,7 @@ abstract class Importer
* @param $results
* @return array
*/
public function normalizeInputArray($results): array
public function normalizeInputArray($results)
{
$newArray = [];
@ -133,7 +133,7 @@ abstract class Importer
public function array_smart_custom_field_fetch(array $array, $key)
{
$index_name = strtolower($key->name);
return array_key_exists($index_name, $array) ? e(trim($array[$index_name])) : '';
return array_key_exists($index_name, $array) ? e(trim($array[$index_name])) : false;
}
protected function log($string)

View file

@ -101,7 +101,8 @@ class CustomField extends Model
public function db_column_name()
{
return self::convertUnicodeDbSlug();
return $this->db_column;
// return self::convertUnicodeDbSlug();
}
//mutators for 'format' attribute