@@ -176,6 +236,7 @@
{{ trans('general.delete') }}
+
@endforeach
@@ -254,6 +315,19 @@
@endif
+ @if ($consumable->notes)
+
+
+
+ {{ trans('general.notes') }}:
+
+
+
+ {!! nl2br(Helper::parseEscapedMarkedownInline($consumable->notes)) !!}
+
+
+ @endif
+
@can('checkout', \App\Models\Consumable::class)
@@ -268,22 +342,24 @@
@endif
+ @can('update', \App\Models\Consumable::class)
+
+ @endcan
+
+ @can('delete', $consumable)
+
+ @if ($consumable->deleted_at=='')
+
+ {{ trans('general.delete') }}
+ @endif
+
+ @endcan
@endcan
- @if ($consumable->notes)
-
-
-
- {{ trans('general.notes') }}:
-
-
-
- {!! nl2br(Helper::parseEscapedMarkedownInline($consumable->notes)) !!}
-
-
- @endif
-
@@ -297,5 +373,16 @@
@stop
@section('moar_scripts')
+
+
@include ('partials.bootstrap-table', ['exportFile' => 'consumable' . $consumable->name . '-export', 'search' => false])
@stop
diff --git a/resources/views/layouts/default.blade.php b/resources/views/layouts/default.blade.php
index 74e9d5be6..63c5bca44 100644
--- a/resources/views/layouts/default.blade.php
+++ b/resources/views/layouts/default.blade.php
@@ -976,7 +976,7 @@ dir="{{ in_array(app()->getLocale(),['ar-SA','fa-IR', 'he-IL']) ? 'rtl' : 'ltr'
// Reference: https://jqueryvalidation.org/validate/
$('#create-form').validate({
ignore: 'input[type=hidden]',
- errorClass: 'help-block form-error',
+ errorClass: 'alert-msg',
errorElement: 'span',
errorPlacement: function(error, element) {
$(element).hasClass('select2') || $(element).hasClass('js-data-ajax')
diff --git a/resources/views/partials/forms/edit/category-select.blade.php b/resources/views/partials/forms/edit/category-select.blade.php
index f555c6240..66800deed 100644
--- a/resources/views/partials/forms/edit/category-select.blade.php
+++ b/resources/views/partials/forms/edit/category-select.blade.php
@@ -25,4 +25,6 @@
{!! $errors->first($fieldname, '
-
+
{!! $errors->first('min_amt', '
:message') !!}
diff --git a/resources/views/partials/forms/edit/quantity.blade.php b/resources/views/partials/forms/edit/quantity.blade.php
index f8a421adc..b41d13f65 100644
--- a/resources/views/partials/forms/edit/quantity.blade.php
+++ b/resources/views/partials/forms/edit/quantity.blade.php
@@ -4,8 +4,10 @@
diff --git a/resources/views/users/print.blade.php b/resources/views/users/print.blade.php
index bdea19ab7..acadf16a0 100644
--- a/resources/views/users/print.blade.php
+++ b/resources/views/users/print.blade.php
@@ -151,20 +151,25 @@
{{ $counter }}.{{ $assignedCounter }} |
-
+ |
@if ($asset->getImageUrl())
@endif
|
{{ $asset->asset_tag }} |
{{ $asset->name }} |
- {{ $asset->model->category->name }} |
+ {{ (($asset->model) && ($asset->model->category)) ? $asset->model->category->name : trans('general.invalid_category') }} |
+ {{ ($asset->model) ? $asset->model->name : trans('general.invalid_model') }} |
{{ ($asset->defaultLoc) ? $asset->defaultLoc->name : '' }} |
{{ ($asset->location) ? $asset->location->name : '' }} |
- {{ $asset->model->name }} |
{{ $asset->serial }} |
- {{ $asset->last_checkout }} |
-  }}display-sig/{{ $asset->assetlog->first()->accept_signature }}) |
+
+ {{ Helper::getFormattedDateObject($asset->last_checkout, 'datetime', false) }} |
+
+ @if (($asset->assetlog->first()) && ($asset->assetlog->first()->accept_signature!=''))
+
+ @endif
+ |
@php
$assignedCounter++
diff --git a/tests/Feature/Categories/Api/IndexCategoriesTest.php b/tests/Feature/Categories/Api/IndexCategoriesTest.php
index fc48fdc54..d27bfbb06 100644
--- a/tests/Feature/Categories/Api/IndexCategoriesTest.php
+++ b/tests/Feature/Categories/Api/IndexCategoriesTest.php
@@ -32,7 +32,6 @@ class IndexCategoriesTest extends TestCase
'limit' => '20',
]))
->assertOk()
- ->assertOk()
->assertJsonStructure([
'total',
'rows',
diff --git a/tests/Feature/Consumables/Api/ConsumableIndexTest.php b/tests/Feature/Consumables/Api/ConsumableIndexTest.php
index b16dfdfa5..f1d3ad7f0 100644
--- a/tests/Feature/Consumables/Api/ConsumableIndexTest.php
+++ b/tests/Feature/Consumables/Api/ConsumableIndexTest.php
@@ -54,4 +54,29 @@ class ConsumableIndexTest extends TestCase
->assertResponseDoesNotContainInRows($consumableA)
->assertResponseContainsInRows($consumableB);
}
+
+ public function testConsumableIndexReturnsExpectedSearchResults()
+ {
+ Consumable::factory()->count(10)->create();
+ Consumable::factory()->count(1)->create(['name' => 'My Test Consumable']);
+
+ $this->actingAsForApi(User::factory()->superuser()->create())
+ ->getJson(
+ route('api.consumables.index', [
+ 'search' => 'My Test Consumable',
+ 'sort' => 'name',
+ 'order' => 'asc',
+ 'offset' => '0',
+ 'limit' => '20',
+ ]))
+ ->assertOk()
+ ->assertJsonStructure([
+ 'total',
+ 'rows',
+ ])
+ ->assertJson([
+ 'total' => 1,
+ ]);
+
+ }
}
diff --git a/tests/Feature/Consumables/Api/ConsumableUpdateTest.php b/tests/Feature/Consumables/Api/ConsumableUpdateTest.php
new file mode 100644
index 000000000..1c1e05d4d
--- /dev/null
+++ b/tests/Feature/Consumables/Api/ConsumableUpdateTest.php
@@ -0,0 +1,52 @@
+create();
+
+ $this->actingAsForApi(User::factory()->superuser()->create())
+ ->patchJson(route('api.consumables.update', $consumable), [
+ 'name' => 'Test Consumable',
+ ])
+ ->assertOk()
+ ->assertStatusMessageIs('success')
+ ->assertStatus(200)
+ ->json();
+
+ $consumable->refresh();
+ $this->assertEquals('Test Consumable', $consumable->name, 'Name was not updated');
+
+ }
+
+ public function testCannotUpdateConsumableViaPatchWithInvalidCategoryType()
+ {
+ $category = Category::factory()->create(['category_type' => 'asset']);
+ $consumable = Consumable::factory()->create();
+
+ $this->actingAsForApi(User::factory()->superuser()->create())
+ ->patchJson(route('api.consumables.update', $consumable), [
+ 'name' => 'Test Consumable',
+ 'category_id' => $category->id,
+ ])
+ ->assertOk()
+ ->assertStatusMessageIs('error')
+ ->assertStatus(200)
+ ->json();
+
+ $category->refresh();
+ $this->assertNotEquals('Test Consumable', $consumable->name, 'Name was not updated');
+ $this->assertNotEquals('consumable', $consumable->category_id, 'Category was not updated');
+
+ }
+
+}
diff --git a/tests/Feature/Consumables/Api/ConsumableViewTest.php b/tests/Feature/Consumables/Api/ConsumableViewTest.php
new file mode 100644
index 000000000..c6410216e
--- /dev/null
+++ b/tests/Feature/Consumables/Api/ConsumableViewTest.php
@@ -0,0 +1,51 @@
+count(2)->create();
+
+ $consumableA = Consumable::factory()->for($companyA)->create();
+ $consumableB = Consumable::factory()->for($companyB)->create();
+
+ $superUser = $companyA->users()->save(User::factory()->superuser()->make());
+ $userInCompanyA = $companyA->users()->save(User::factory()->viewConsumables()->make());
+ $userInCompanyB = $companyB->users()->save(User::factory()->viewConsumables()->make());
+
+ $this->settings->disableMultipleFullCompanySupport();
+
+ $this->actingAsForApi($superUser)
+ ->getJson(route('api.consumables.show', $consumableA))
+ ->assertOk();
+
+ $this->actingAsForApi($userInCompanyA)
+ ->getJson(route('api.consumables.show', $consumableA))
+ ->assertOk();
+
+ $this->actingAsForApi($userInCompanyB)
+ ->getJson(route('api.consumables.show', $consumableB))
+ ->assertOk();
+
+ $this->settings->enableMultipleFullCompanySupport();
+
+ $this->actingAsForApi($superUser)
+ ->getJson(route('api.consumables.show', $consumableA))
+ ->assertOk();
+
+ $this->actingAsForApi($userInCompanyA)
+ ->getJson(route('api.consumables.index'))
+ ->assertOk();
+
+ $this->actingAsForApi($userInCompanyB)
+ ->getJson(route('api.consumables.index'))
+ ->assertOk();
+ }
+}
diff --git a/tests/Feature/Consumables/Ui/ConsumableViewTest.php b/tests/Feature/Consumables/Ui/ConsumableViewTest.php
new file mode 100644
index 000000000..9633896c2
--- /dev/null
+++ b/tests/Feature/Consumables/Ui/ConsumableViewTest.php
@@ -0,0 +1,26 @@
+create();
+ $this->actingAs(User::factory()->create())
+ ->get(route('consumables.show', $consumable))
+ ->assertForbidden();
+ }
+
+ public function testUserCanListConsumables()
+ {
+ $consumable = Consumable::factory()->create();
+ $this->actingAs(User::factory()->superuser()->create())
+ ->get(route('consumables.show', $consumable))
+ ->assertOk();
+ }
+}