that's all of 'em

This commit is contained in:
spencerrlongg 2024-01-25 20:04:02 -06:00
parent 3574ef5bb9
commit 2deba17d91
4 changed files with 12 additions and 6 deletions

View file

@ -45,10 +45,10 @@ class ConsumableImporter extends ItemImporter
$this->item['item_no'] = trim($this->findCsvMatch($row, 'item_number')); $this->item['item_no'] = trim($this->findCsvMatch($row, 'item_number'));
$this->item['min_amt'] = trim($this->findCsvMatch($row, "min_amt")); $this->item['min_amt'] = trim($this->findCsvMatch($row, "min_amt"));
$consumable->fill($this->sanitizeItemForStoring($consumable)); $consumable->fill($this->sanitizeItemForStoring($consumable));
//FIXME: this disables model validation. Need to find a way to avoid double-logs without breaking everything.
$consumable->unsetEventDispatcher(); // This sets an attribute on the Loggable trait for the action log
$consumable->setImported(true);
if ($consumable->save()) { if ($consumable->save()) {
$consumable->logCreate('Imported using CSV Importer');
$this->log('Consumable '.$this->item['name'].' was created'); $this->log('Consumable '.$this->item['name'].' was created');
return; return;

View file

@ -85,10 +85,10 @@ class LicenseImporter extends ItemImporter
} else { } else {
$license->fill($this->sanitizeItemForStoring($license)); $license->fill($this->sanitizeItemForStoring($license));
} }
//FIXME: this disables model validation. Need to find a way to avoid double-logs without breaking everything.
// $license->unsetEventDispatcher(); // This sets an attribute on the Loggable trait for the action log
$license->setImported(true);
if ($license->save()) { if ($license->save()) {
$license->logCreate('Imported using csv importer');
$this->log('License '.$this->item['name'].' with serial number '.$this->item['serial'].' was created'); $this->log('License '.$this->item['name'].' with serial number '.$this->item['serial'].' was created');
// Lets try to checkout seats if the fields exist and we have seats. // Lets try to checkout seats if the fields exist and we have seats.

View file

@ -38,6 +38,9 @@ class ConsumableObserver
$logAction->item_id = $consumable->id; $logAction->item_id = $consumable->id;
$logAction->created_at = date('Y-m-d H:i:s'); $logAction->created_at = date('Y-m-d H:i:s');
$logAction->user_id = Auth::id(); $logAction->user_id = Auth::id();
if($consumable->imported) {
$logAction->note = trans('general.importer.import_note');
}
$logAction->logaction('create'); $logAction->logaction('create');
} }

View file

@ -38,6 +38,9 @@ class LicenseObserver
$logAction->item_id = $license->id; $logAction->item_id = $license->id;
$logAction->created_at = date('Y-m-d H:i:s'); $logAction->created_at = date('Y-m-d H:i:s');
$logAction->user_id = Auth::id(); $logAction->user_id = Auth::id();
if($license->imported) {
$logAction->note = trans('general.importer.import_note');
}
$logAction->logaction('create'); $logAction->logaction('create');
} }