Skip to content

Commit

Permalink
Merge pull request #10511 from inietov/features/audit_date_in_importer
Browse files Browse the repository at this point in the history
Adds audit dates in the asset importer
  • Loading branch information
snipe authored Jan 27, 2022
2 parents 0eab249 + 949fe2a commit a65fb63
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/Importer/AssetImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ public function createAssetIfNotExists(array $row)
$item['rtd_location_id'] = $this->item['location_id'];
}

if (isset($this->item['last_audit_date'])) {
$item['last_audit_date'] = $this->item['last_audit_date'];
}

if (isset($this->item['next_audit_date'])) {
$item['next_audit_date'] = $this->item['next_audit_date'];
}

if ($editingAsset) {
$asset->update($item);
} else {
Expand Down
11 changes: 11 additions & 0 deletions app/Importer/ItemImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ protected function handle($row)
if ($this->findCsvMatch($row, 'purchase_date') != '') {
$this->item['purchase_date'] = date('Y-m-d 00:00:01', strtotime($this->findCsvMatch($row, 'purchase_date')));
}

$this->item['last_audit_date'] = null;
if ($this->findCsvMatch($row, 'last_audit_date') != '') {
$this->item['last_audit_date'] = date('Y-m-d', strtotime($this->findCsvMatch($row, 'last_audit_date')));
}

$this->item['next_audit_date'] = null;
if ($this->findCsvMatch($row, 'next_audit_date') != '') {
$this->item['next_audit_date'] = date('Y-m-d', strtotime($this->findCsvMatch($row, 'next_audit_date')));
}

$this->item['qty'] = $this->findCsvMatch($row, 'quantity');
$this->item['requestable'] = $this->findCsvMatch($row, 'requestable');
$this->item['user_id'] = $this->user_id;
Expand Down
2 changes: 2 additions & 0 deletions resources/assets/js/components/importer/importer-file.vue
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@
{id: 'full_name', text: 'Full Name' },
{id: 'status', text: 'Status' },
{id: 'warranty_months', text: 'Warranty Months' },
{id: 'last_audit_date', text: 'Last Audit Date' },
{id: 'next_audit_date', text: 'Audit Date' },
],
consumables: [
{id: 'item_no', text: "Item Number"},
Expand Down

0 comments on commit a65fb63

Please sign in to comment.