Skip to content

Commit 4b59a6c

Browse files
committed
License importer, small tweaks to asset importer
1 parent 4fcf708 commit 4b59a6c

File tree

3 files changed

+394
-8
lines changed

3 files changed

+394
-8
lines changed

app/commands/ImportCommand.php renamed to app/commands/AssetImportCommand.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@
55
use Symfony\Component\Console\Input\InputArgument;
66
use League\Csv\Reader;
77

8-
class ImportCommand extends Command {
8+
class AssetImportCommand extends Command {
99

1010
/**
1111
* The console command name.
1212
*
1313
* @var string
1414
*/
15-
protected $name = 'import:csv';
15+
protected $name = 'asset-import:csv';
1616

1717
/**
1818
* The console command description.
1919
*
2020
* @var string
2121
*/
22-
protected $description = 'Import from CSV';
22+
protected $description = 'Import Assets from CSV';
2323

2424
/**
2525
* Create a new command instance.
@@ -42,9 +42,9 @@ public function fire()
4242

4343

4444
if (!$this->option('testrun')=='true') {
45-
$this->comment('======= Importing '.$filename.' =========');
45+
$this->comment('======= Importing Assets from '.$filename.' =========');
4646
} else {
47-
$this->comment('====== TEST ONLY Import for '.$filename.' ====');
47+
$this->comment('====== TEST ONLY Asset Import for '.$filename.' ====');
4848
$this->comment('============== NO DATA WILL BE WRITTEN ==============');
4949
}
5050

@@ -63,66 +63,77 @@ public function fire()
6363

6464
// Let's just map some of these entries to more user friendly words
6565

66+
// User's name
6667
if (array_key_exists('0',$row)) {
6768
$user_name = trim($row[0]);
6869
} else {
6970
$user_name = '';
7071
}
7172

73+
// User's email
7274
if (array_key_exists('1',$row)) {
7375
$user_email = trim($row[1]);
7476
} else {
7577
$user_email = '';
7678
}
7779

80+
// Asset Category
7881
if (array_key_exists('2',$row)) {
7982
$user_asset_category = trim($row[2]);
8083
} else {
8184
$user_asset_category = '';
8285
}
8386

87+
// Asset Name
8488
if (array_key_exists('3',$row)) {
8589
$user_asset_name = trim($row[3]);
8690
} else {
8791
$user_asset_name = '';
8892
}
8993

94+
// Asset Manufacturer
9095
if (array_key_exists('4',$row)) {
9196
$user_asset_mfgr = trim($row[4]);
9297
} else {
9398
$user_asset_mfgr = '';
9499
}
95100

101+
// Asset model number
96102
if (array_key_exists('5',$row)) {
97103
$user_asset_modelno = trim($row[5]);
98104
} else {
99105
$user_asset_modelno = '';
100106
}
101107

108+
// Asset serial number
102109
if (array_key_exists('6',$row)) {
103110
$user_asset_serial = trim($row[6]);
104111
} else {
105112
$user_asset_serial = '';
106113
}
107114

115+
// Asset tag
108116
if (array_key_exists('7',$row)) {
109117
$user_asset_tag = trim($row[7]);
110118
} else {
111119
$user_asset_tag = '';
112120
}
113121

122+
// Asset location
114123
if (array_key_exists('8',$row)) {
115124
$user_asset_location = trim($row[8]);
116125
} else {
117126
$user_asset_location = '';
118127
}
119128

129+
// Asset notes
120130
if (array_key_exists('9',$row)) {
121131
$user_asset_notes = trim($row[9]);
122132
} else {
123133
$user_asset_notes = '';
124134
}
125135

136+
// Asset purchase date
126137
if (array_key_exists('10',$row)) {
127138
if ($row[10]!='') {
128139
$user_asset_purchase_date = date("Y-m-d 00:00:01", strtotime($row[10]));
@@ -137,8 +148,8 @@ public function fire()
137148
if (is_numeric($user_name)) {
138149
$this->comment('User '.$user_name.' is not a name - assume this user already exists');
139150
$user_username = '';
140-
// No name was given
141151

152+
// No name was given
142153
} elseif ($user_name=='') {
143154
$this->comment('No user data provided - skipping user creation, just adding asset');
144155
$first_name = '';
@@ -221,7 +232,7 @@ public function fire()
221232
'admin' => 0,
222233
'user' => 1,
223234
),
224-
'notes' => 'Imported user'
235+
'notes' => 'User imported through asset importer'
225236
));
226237

227238
// Find the group using the group id

0 commit comments

Comments
 (0)