mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
Add shopping location for price tracking (#658)
This commit is contained in:
20
views/components/shoppinglocationpicker.blade.php
Normal file
20
views/components/shoppinglocationpicker.blade.php
Normal file
@@ -0,0 +1,20 @@
|
||||
@push('componentScripts')
|
||||
<script src="{{ $U('/viewjs/components/shoppinglocationpicker.js', true) }}?v={{ $version }}"></script>
|
||||
@endpush
|
||||
|
||||
@php if(empty($prefillByName)) { $prefillByName = ''; } @endphp
|
||||
@php if(empty($prefillById)) { $prefillById = ''; } @endphp
|
||||
@php if(!isset($isRequired)) { $isRequired = false; } @endphp
|
||||
@php if(empty($hint)) { $hint = ''; } @endphp
|
||||
@php if(empty($nextInputSelector)) { $nextInputSelector = ''; } @endphp
|
||||
|
||||
<div class="form-group" data-next-input-selector="{{ $nextInputSelector }}" data-prefill-by-name="{{ $prefillByName }}" data-prefill-by-id="{{ $prefillById }}">
|
||||
<label for="shopping_location_id">{{ $__t('Shopping location') }} <span id="{{ $hintId }}" class="small text-muted">{{ $hint }}</span></label>
|
||||
<select class="form-control shopping-location-combobox" id="shopping_location_id" name="shopping_location_id" @if($isRequired) required @endif>
|
||||
<option value=""></option>
|
||||
@foreach($shoppinglocations as $shoppinglocation)
|
||||
<option value="{{ $shoppinglocation->id }}">{{ $shoppinglocation->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<div class="invalid-feedback">{{ $__t('You have to select a shopping location') }}</div>
|
||||
</div>
|
@@ -66,6 +66,10 @@
|
||||
'invalidFeedback' => $__t('The price cannot be lower than %s', '0'),
|
||||
'isRequired' => false
|
||||
))
|
||||
|
||||
@include('components.shoppinglocationpicker', array(
|
||||
'shoppinglocations' => $shoppinglocations,
|
||||
))
|
||||
@else
|
||||
<input type="hidden" name="price" id="price" value="0">
|
||||
@endif
|
||||
|
@@ -243,6 +243,14 @@
|
||||
</a>
|
||||
</li>
|
||||
@endif
|
||||
@if(GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
|
||||
<li data-nav-for-page="shoppinglocations" data-sub-menu-of="#top-nav-manager-master-data">
|
||||
<a class="nav-link discrete-link" href="{{ $U('/shoppinglocations') }}">
|
||||
<i class="fas fa-shopping-cart"></i>
|
||||
<span class="nav-link-text">{{ $__t('Shopping locations') }}</span>
|
||||
</a>
|
||||
</li>
|
||||
@endif
|
||||
<li data-nav-for-page="quantityunits" data-sub-menu-of="#top-nav-manager-master-data">
|
||||
<a class="nav-link discrete-link" href="{{ $U('/quantityunits') }}">
|
||||
<i class="fas fa-balance-scale"></i>
|
||||
|
@@ -30,6 +30,7 @@
|
||||
'nextInputSelector' => '#best_before_date .datetimepicker-input'
|
||||
))
|
||||
|
||||
|
||||
@php
|
||||
$additionalGroupCssClasses = '';
|
||||
if (!GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)
|
||||
@@ -84,6 +85,9 @@
|
||||
<input class="form-check-input" type="radio" name="price-type" id="price-type-total-price" value="total-price">
|
||||
<label class="form-check-label" for="price-type-total-price">{{ $__t('Total price') }}</label>
|
||||
</div>
|
||||
@include('components.shoppinglocationpicker', array(
|
||||
'shoppinglocations' => $shoppinglocations,
|
||||
))
|
||||
@else
|
||||
<input type="hidden" name="price" id="price" value="0">
|
||||
@endif
|
||||
|
45
views/shoppinglocationform.blade.php
Normal file
45
views/shoppinglocationform.blade.php
Normal file
@@ -0,0 +1,45 @@
|
||||
@extends('layout.default')
|
||||
|
||||
@if($mode == 'edit')
|
||||
@section('title', $__t('Edit shopping location'))
|
||||
@else
|
||||
@section('title', $__t('Create shopping location'))
|
||||
@endif
|
||||
|
||||
@section('viewJsName', 'shoppinglocationform')
|
||||
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-xs-12">
|
||||
<h1>@yield('title')</h1>
|
||||
|
||||
<script>Grocy.EditMode = '{{ $mode }}';</script>
|
||||
|
||||
@if($mode == 'edit')
|
||||
<script>Grocy.EditObjectId = {{ $shoppinglocation->id }};</script>
|
||||
@endif
|
||||
|
||||
<form id="shoppinglocation-form" novalidate>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="name">{{ $__t('Name') }}</label>
|
||||
<input type="text" class="form-control" required id="name" name="name" value="@if($mode == 'edit'){{ $shoppinglocation->name }}@endif">
|
||||
<div class="invalid-feedback">{{ $__t('A name is required') }}</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="description">{{ $__t('Description') }}</label>
|
||||
<textarea class="form-control" rows="2" id="description" name="description">@if($mode == 'edit'){{ $shoppinglocation->description }}@endif</textarea>
|
||||
</div>
|
||||
|
||||
@include('components.userfieldsform', array(
|
||||
'userfields' => $userfields,
|
||||
'entity' => 'shopping_locations'
|
||||
))
|
||||
|
||||
<button id="save-shopping-location-button" class="btn btn-success">{{ $__t('Save') }}</button>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@stop
|
73
views/shoppinglocations.blade.php
Normal file
73
views/shoppinglocations.blade.php
Normal file
@@ -0,0 +1,73 @@
|
||||
@extends('layout.default')
|
||||
|
||||
@section('title', $__t('Shopping locations'))
|
||||
@section('activeNav', 'shoppinglocations')
|
||||
@section('viewJsName', 'shoppinglocations')
|
||||
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h1>
|
||||
@yield('title')
|
||||
<a class="btn btn-outline-dark" href="{{ $U('/shoppinglocation/new') }}">
|
||||
<i class="fas fa-plus"></i> {{ $__t('Add') }}
|
||||
</a>
|
||||
<a class="btn btn-outline-secondary" href="{{ $U('/userfields?entity=shoppinglocations') }}">
|
||||
<i class="fas fa-sliders-h"></i> {{ $__t('Configure userfields') }}
|
||||
</a>
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mt-3">
|
||||
<div class="col-xs-12 col-md-6 col-xl-3">
|
||||
<label for="search">{{ $__t('Search') }}</label> <i class="fas fa-search"></i>
|
||||
<input type="text" class="form-control" id="search">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<table id="shoppinglocations-table" class="table table-sm table-striped dt-responsive">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="border-right"></th>
|
||||
<th>{{ $__t('Name') }}</th>
|
||||
<th>{{ $__t('Description') }}</th>
|
||||
|
||||
@include('components.userfields_thead', array(
|
||||
'userfields' => $userfields
|
||||
))
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="d-none">
|
||||
@foreach($shoppinglocations as $shoppinglocation)
|
||||
<tr>
|
||||
<td class="fit-content border-right">
|
||||
<a class="btn btn-info btn-sm" href="{{ $U('/shoppinglocation/') }}{{ $shoppinglocation->id }}">
|
||||
<i class="fas fa-edit"></i>
|
||||
</a>
|
||||
<a class="btn btn-danger btn-sm shoppinglocation-delete-button" href="#" data-shoppinglocation-id="{{ $shoppinglocation->id }}" data-shoppinglocation-name="{{ $shoppinglocation->name }}">
|
||||
<i class="fas fa-trash"></i>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
{{ $shoppinglocation->name }}
|
||||
</td>
|
||||
<td>
|
||||
{{ $shoppinglocation->description }}
|
||||
</td>
|
||||
|
||||
@include('components.userfields_tbody', array(
|
||||
'userfields' => $userfields,
|
||||
'userfieldValues' => FindAllObjectsInArrayByPropertyValue($userfieldValues, 'object_id', $shoppinglocation->id)
|
||||
))
|
||||
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@stop
|
@@ -35,6 +35,7 @@
|
||||
<th>{{ $__t('Amount') }}</th>
|
||||
<th>{{ $__t('Best before date') }}</th>
|
||||
@if(GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING)<th>{{ $__t('Location') }}</th>@endif
|
||||
<th>{{ $__t('Shopping location') }}</th>
|
||||
@if(GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)<th>{{ $__t('Price') }}</th>@endif
|
||||
<th>{{ $__t('Purchased date') }}</th>
|
||||
|
||||
@@ -145,6 +146,9 @@
|
||||
<td id="stock-{{ $stockEntry->id }}-price" class="locale-number locale-number-currency" data-price-id="{{ $stockEntry->price }}">
|
||||
{{ $stockEntry->price }}
|
||||
</td>
|
||||
<td id="stock-{{ $stockEntry->id }}-shopping-location" data-shopping-location-id="{{ $stockEntry->shopping_location_id }}">
|
||||
{{ FindObjectInArrayByPropertyValue($shoppinglocations, 'id', $stockEntry->shopping_location_id)->name }}
|
||||
</td>
|
||||
@endif
|
||||
<td>
|
||||
<span id="stock-{{ $stockEntry->id }}-purchased-date">{{ $stockEntry->purchased_date }}</span>
|
||||
|
@@ -65,6 +65,10 @@
|
||||
'invalidFeedback' => $__t('The price cannot be lower than %s', '0'),
|
||||
'isRequired' => false
|
||||
))
|
||||
@include('components.shoppinglocationpicker', array(
|
||||
'shoppinglocations' => $shoppinglocations,
|
||||
'prefillById' => $stockEntry->shopping_location_id
|
||||
))
|
||||
@else
|
||||
<input type="hidden" name="price" id="price" value="0">
|
||||
@endif
|
||||
|
Reference in New Issue
Block a user