Skip to content

Commit

Permalink
Merge branch 'extension/user-shops' of https://github.com/Ne-wt/lorek…
Browse files Browse the repository at this point in the history
…eeper into extension/user-shops

# Conflicts:
#	resources/views/home/user_shops/search_items.blade.php
  • Loading branch information
ScuffedNewt committed Oct 9, 2023
2 parents 87aede1 + dabf316 commit edfde12
Show file tree
Hide file tree
Showing 22 changed files with 438 additions and 408 deletions.
8 changes: 6 additions & 2 deletions resources/views/home/_inventory_stack.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,13 @@
</div>
</li>
@endif
@if(!isset($item->category) && $item->allow_transfer || isset($item->category) && $item->category->can_user_sell == 1 && $item->allow_transfer || Auth::user()->hasPower('edit_inventories'))
@if ((!isset($item->category) && $item->allow_transfer) || (isset($item->category) && $item->category->can_user_sell == 1 && $item->allow_transfer) || Auth::user()->hasPower('edit_inventories'))
<li class="list-group-item">
<a class="card-title h5 collapse-title" data-toggle="collapse" href="#shoptransferForm">@if($stack->first()->user_id != $user->id) [ADMIN] @endif Transfer Item to Shop</a>
<a class="card-title h5 collapse-title" data-toggle="collapse" href="#shoptransferForm">
@if ($stack->first()->user_id != $user->id)
[ADMIN]
@endif Transfer Item to Shop
</a>
<div id="shoptransferForm" class="collapse">
<p>This will transfer this stack or stacks to the selected user shop.</p>
<div class="form-group">
Expand Down
11 changes: 6 additions & 5 deletions resources/views/home/account_search.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

<h1>Account Search</h1>

<p>Select an item to search for all occurrences of it in your and your characters' inventories, as well as your shops. If a stack is currently "held" in a trade, design update, or submission, this will be stated and all held locations will be linked.</p>
<p>Select an item to search for all occurrences of it in your and your characters' inventories, as well as your shops. If a stack is currently "held" in a trade, design update, or submission, this will be stated and all held locations will be linked.
</p>

{!! Form::open(['method' => 'GET', 'class' => '']) !!}
<div class="form-inline justify-content-end">
Expand Down Expand Up @@ -39,7 +40,7 @@
<?php
$tradesSent = $trades->where('sender_id', Auth::user()->id);
$tradesReceived = $trades->where('recipient_id', Auth::user()->id);
// Collect hold location IDs and quantities
$holdLocations = [];
if (isset($item->trade_count) && $item->trade_count > 0) {
Expand Down Expand Up @@ -68,7 +69,7 @@
}
}
}
// Format a string with all the places a stack is held
$held = [];
if (isset($holdLocations['trade'])) {
Expand Down Expand Up @@ -108,10 +109,10 @@
@endforeach
</ul>
@endif
@if($shopItems->count())
@if ($shopItems->count())
<h5>In your shops:</h5>
<ul>
@foreach($shopItems as $item)
@foreach ($shopItems as $item)
<li>
{!! $item->shop->displayName !!} has {{ $item->quantity }}
</li>
Expand Down
4 changes: 2 additions & 2 deletions resources/views/home/user_shops/_delete_shop.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@if($shop)
{!! Form::open(['url' => 'user-shops/delete/'.$shop->id]) !!}
@if ($shop)
{!! Form::open(['url' => 'user-shops/delete/' . $shop->id]) !!}

<p>You are about to delete the shop <strong>{{ $shop->name }}</strong>. This is not reversible. If you would like to hide the shop from users, you can set it as inactive from the shop settings page.</p>
<p>Are you sure you want to delete <strong>{{ $shop->name }}</strong>?</p>
Expand Down
44 changes: 21 additions & 23 deletions resources/views/home/user_shops/_delete_stock.blade.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
@if($stock)
{!! Form::open(['url' => 'user-shops/stock/remove/'.$stock->id]) !!}
@if ($stock)
{!! Form::open(['url' => 'user-shops/stock/remove/' . $stock->id]) !!}
{{ Form::hidden('user_shop_id', $shop->id) }}
<table class="table table-sm">
<thead class="thead">
<tr>
<th>Remove?</th>
<th>Quantity</th>
</tr>
</thead>
<tbody>
<tr id ="stock{{ $stock->id }}">
<td>{!! Form::checkbox('ids[]', $stock->id, false, ['class' => 'item-check', 'onclick' => 'updateQuantities(this)']) !!}</td>
<td>{!! Form::selectRange('', 1, $stock->quantity, 1, ['class' => 'quantity-select', 'type' => 'number', 'style' => 'min-width:40px;']) !!}</td>
</tr>
</tbody>
</table>
<table class="table table-sm">
<thead class="thead">
<tr>
<th>Remove?</th>
<th>Quantity</th>
</tr>
</thead>
<tbody>
<tr id ="stock{{ $stock->id }}">
<td>{!! Form::checkbox('ids[]', $stock->id, false, ['class' => 'item-check', 'onclick' => 'updateQuantities(this)']) !!}</td>
<td>{!! Form::selectRange('', 1, $stock->quantity, 1, ['class' => 'quantity-select', 'type' => 'number', 'style' => 'min-width:40px;']) !!}</td>
</tr>
</tbody>
</table>
<p>You are about to remove the stock <strong>{{ $stock->item->name }}</strong>.</p>
<p>Are you sure you want to remove <strong>{{ $stock->item->name }}</strong>? This item will be returned to your inventory.</p>

Expand All @@ -25,13 +25,11 @@
{!! Form::close() !!}

<script>
function updateQuantities($checkbox) {
var $rowId = "#stock" + $checkbox.value
$($rowId).find('.quantity-select').prop('name', $checkbox.checked ? 'quantities[]' : '')
}
</script>
function updateQuantities($checkbox) {
var $rowId = "#stock" + $checkbox.value
$($rowId).find('.quantity-select').prop('name', $checkbox.checked ? 'quantities[]' : '')
}
</script>
@else
Invalid stock selected.
@endif


16 changes: 8 additions & 8 deletions resources/views/home/user_shops/_edit_stock_modal.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="p-2">
{!! Form::open(['url' => 'user-shops/stock/edit/'.$stock->id]) !!}
{!! Form::open(['url' => 'user-shops/stock/edit/' . $stock->id]) !!}

<div class="form-group">
{!! Form::label('cost', 'Cost') !!}
Expand All @@ -20,12 +20,12 @@
</div>


<div class="text-right mt-1">
{!! Form::submit('Edit', ['class' => 'btn btn-primary']) !!}
<div class="btn btn-danger" onClick="{{ $remove }}">
{{--trash icon --}}
<i class="fas fa-trash"></i>
<div class="text-right mt-1">
{!! Form::submit('Edit', ['class' => 'btn btn-primary']) !!}
<div class="btn btn-danger" onClick="{{ $remove }}">
{{-- trash icon --}}
<i class="fas fa-trash"></i>
</div>
</div>
</div>
{!! Form::close() !!}
{!! Form::close() !!}
</div>
10 changes: 5 additions & 5 deletions resources/views/home/user_shops/_purchase_history_row.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="d-flex row flex-wrap col-12 mt-1 pt-1 px-0 ubt-top">
<div class="col-12 col-md-2">{!! $log->item ? $log->item->displayName : '(Deleted Item)' !!}</div>
<div class="col-12 col-md-2">{!! $log->quantity !!}</div>
<div class="col-12 col-md-2">{!! $log->shop ? $log->shop->displayName : '(Deleted Shop)' !!}</div>
<div class="col-12 col-md-2">{!! $log->currency ? $log->currency->display($log->cost) : $log->cost . ' (Deleted Currency)' !!}</div>
<div class="col-12 col-md-2">{!! pretty_date($log->created_at) !!}</div>
<div class="col-12 col-md-2">{!! $log->item ? $log->item->displayName : '(Deleted Item)' !!}</div>
<div class="col-12 col-md-2">{!! $log->quantity !!}</div>
<div class="col-12 col-md-2">{!! $log->shop ? $log->shop->displayName : '(Deleted Shop)' !!}</div>
<div class="col-12 col-md-2">{!! $log->currency ? $log->currency->display($log->cost) : $log->cost . ' (Deleted Currency)' !!}</div>
<div class="col-12 col-md-2">{!! pretty_date($log->created_at) !!}</div>
</div>
4 changes: 2 additions & 2 deletions resources/views/home/user_shops/_sidebar.blade.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<ul>
@if(Auth::check())
@if (Auth::check())
<li class="sidebar-section">
<div class="sidebar-section-header">History</div>
<div class="sidebar-item"><a href="{{ url('user-shops/history') }}" class="{{ set_active('user-shops/history*') }}">Purchase History</a></div>
<div class="sidebar-section-header">My Currencies</div>
@foreach(Auth::user()->getCurrencies(true) as $currency)
@foreach (Auth::user()->getCurrencies(true) as $currency)
<div class="sidebar-item pr-3">{!! $currency->display($currency->quantity) !!}</div>
@endforeach
</li>
Expand Down
20 changes: 13 additions & 7 deletions resources/views/home/user_shops/_stock_item.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="p-2">
{!! Form::open(['url' => 'user-shops/stock/edit/'.$stock->id]) !!}
{!! Form::open(['url' => 'user-shops/stock/edit/' . $stock->id]) !!}

<div class="form-group">
{!! Form::label('cost', 'Cost') !!}
Expand All @@ -12,11 +12,11 @@
</div>
</div>
</div>
<div class="form-group">
{!! Form::checkbox('is_visible', 1, $stock->is_visible ?? 1, ['class' => 'form-check-input stock-limited stock-toggle stock-field']) !!}
{!! Form::label('is_visible', 'Set Visibility', ['class' => 'form-check-label ml-3']) !!} {!! add_help('If turned off it will not appear in the store.') !!}
</div>
<div class="form-group">
{!! Form::checkbox('is_visible', 1, $stock->is_visible ?? 1, ['class' => 'form-check-input stock-limited stock-toggle stock-field']) !!}
{!! Form::label('is_visible', 'Set Visibility', ['class' => 'form-check-label ml-3']) !!} {!! add_help('If turned off it will not appear in the store.') !!}
</div>
</div>


<div class="text-right mt-1">
Expand All @@ -29,8 +29,14 @@
$('#type').change(function() {
var type = $(this).val();
$.ajax({
type: "GET", url: "{{ url('user-shops/stock/stock-type') }}?type="+type, dataType: "text"
}).done(function (res) { $("#stock").html(res); }).fail(function (jqXHR, textStatus, errorThrown) { alert("AJAX call failed: " + textStatus + ", " + errorThrown); });
type: "GET",
url: "{{ url('user-shops/stock/stock-type') }}?type=" + type,
dataType: "text"
}).done(function(res) {
$("#stock").html(res);
}).fail(function(jqXHR, textStatus, errorThrown) {
alert("AJAX call failed: " + textStatus + ", " + errorThrown);
});
});
});
</script>
29 changes: 14 additions & 15 deletions resources/views/home/user_shops/_stock_modal.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@if(!$stock)
@if (!$stock)
<div class="text-center">Invalid item selected.</div>
@else
<div class="text-center mb-3">
Expand All @@ -8,7 +8,7 @@
<div>Stock: {{ $stock->quantity }}</div>
</div>

@if($stock->item->parsed_description)
@if ($stock->item->parsed_description)
<div class="mb-2">
<a data-toggle="collapse" href="#itemDescription" class="h5">Description <i class="fas fa-caret-down"></i></a>
<div class="card collapse show mt-1" id="itemDescription">
Expand All @@ -19,27 +19,26 @@
</div>
@endif

@if(Auth::check())
@if (Auth::check())
<h5>
Purchase
<span class="float-right">
In Inventory: {{ $userOwned->pluck('count')->sum() }}
</span>
</h5>

{!! Form::open(['url' => 'user-shops/shop/buy']) !!}
{!! Form::hidden('user_shop_id', $shop->id) !!}
{!! Form::hidden('stock_id', $stock->id) !!}
{!! Form::label('quantity', 'Quantity') !!}
{!! Form::selectRange('quantity', 1, $stock->quantity, 1, ['class' => 'form-control mb-3']) !!}
<p>This item will be paid for using your user account bank.</p>
{!! Form::hidden('bank', 'user') !!}
<div class="text-right">
{!! Form::submit('Purchase', ['class' => 'btn btn-primary']) !!}
</div>
{!! Form::close() !!}
{!! Form::open(['url' => 'user-shops/shop/buy']) !!}
{!! Form::hidden('user_shop_id', $shop->id) !!}
{!! Form::hidden('stock_id', $stock->id) !!}
{!! Form::label('quantity', 'Quantity') !!}
{!! Form::selectRange('quantity', 1, $stock->quantity, 1, ['class' => 'form-control mb-3']) !!}
<p>This item will be paid for using your user account bank.</p>
{!! Form::hidden('bank', 'user') !!}
<div class="text-right">
{!! Form::submit('Purchase', ['class' => 'btn btn-primary']) !!}
</div>
{!! Form::close() !!}
@else
<div class="alert alert-danger">You must be logged in to purchase this item.</div>
@endif
@endif

Loading

0 comments on commit edfde12

Please sign in to comment.