ordering store item add

Adding new feature in store owner page.
*ordering item
This commit is contained in:
franknstayn
2019-11-06 20:23:57 +08:00
parent 1dd7578508
commit 460cf315a0
7 changed files with 192 additions and 18 deletions

View File

@@ -44,11 +44,11 @@
<a href="{{ url('user/store-items/add-item') }}" type="button" class="btn btn-primary">
<i class="fa fa-plus"></i> Add new Item
</a>
<button class="btn btn-primary"><i class="fa fa-exchange"></i> Re-arrange item</button>
<a href="{{ url('user/store-items/re-arrange') }}" class="btn btn-primary"><i class="fa fa-exchange"></i> Re-arrange item</a>
</div>
</div>
<!-- BEGIN PRODUCTS -->
<div id="item_list_sort">
@foreach($product_array as $i => $product)
@foreach($thumbnails as $t => $thumb)
@if($thumb['product_id'] == $product->Id)
@@ -56,7 +56,7 @@
@define $filename = $thumb['thumb']
@endif
@endforeach
<div class="col-md-3 col-sm-6" id="{{ 'order_number_' . $product->Ordering }}">
<div class="col-md-3 col-sm-6">
<div class="thumbnail" >
<a href="{{ url('user/store-items/item') }}/{{ $product->ProductURL }}">
<img style="height:200px" src="{{ config('site_config.prod_private_server_ip') }}/images/{{ $filename . '?t=' . time() }}" alt="{{ $product->ProductName }}" >
@@ -71,7 +71,6 @@
</div>
</div>
@endforeach
</div>
</div>
</div>

View File

@@ -0,0 +1,84 @@
@extends('user-layouts.user_template')
@section('content')
<style>
.badge-error {
background-color: #b94a48;
}
.product-name-holder{
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#item_list_sort{
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-gap: 10px;
}
</style>
<div class="content-wrapper" style="min-height: 916px;">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Store Item Arrangement
<!-- <small>Control panel</small> -->
</h1>
<ol class="breadcrumb">
<li><a href="{{ url ('user') }}"><i class="fa fa-home"></i> Home</a></li>
<!-- <li><a href="{{ url ('user/profile') }}"><i class="fa fa-user"></i> My Profile</a></li> -->
<li class="active">Store Item Arrangement</li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<div class="row">
<div class="col-md-12">
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">
Item List
</h3>
</div>
<div class="box-body">
<div class="row">
<div class="col-md-12">
<div class="well">
<button type="button" id="btn_save_item_sorting" class="btn btn-primary">
Save Changes
</button>
<a href="{{ url('user/store-items') }}" class="btn btn-default"> Cancel</a>
</div>
</div>
</div>
<div id="item_list_sort">
@foreach($product_array as $i => $product)
@foreach($thumbnails as $t => $thumb)
@if($thumb['product_id'] == $product->Id)
@define $storeFolder = $thumb['folder']
@define $filename = $thumb['thumb']
@endif
@endforeach
<div id="{{ 'order_number_' . $product->Id }}">
<div class="thumbnail" >
<a href="#">
<img style="height:200px" src="{{ config('site_config.prod_private_server_ip') }}/images/{{ $filename . '?t=' . time() }}" alt="{{ $product->ProductName }}" >
</a>
<hr class="line">
<div class="pull-right">
<div style="text-transform: uppercase;" class="badge @if($product->PrivacyStatus== 'private') badge-error @endif">{{ $product->PrivacyStatus }}</div>
</div>
<h4 class="product-name-holder">{{ $product->ProductName }}<br><small>$ {{ $product->ProductPrice }}</small></h4>
</div>
</div>
@endforeach
</div>
</div>
<div>
</div>
</div>
</section>
<!-- /.content -->
</div>
@endsection

View File

@@ -783,8 +783,6 @@
$('#btn_save_thumbnail_sorting').on('click', function(e) {
e.preventDefault();
var sortable_data = tr_sortable.sortable('serialize');
// div_response . text ( 'Save' );
// console.log(sortable_data);
$.ajax({
data: sortable_data,
type: 'POST',
@@ -808,6 +806,32 @@
});
});
$('#btn_save_item_sorting').on('click', function(e) {
e.preventDefault();
var sorted_data = item_list_sort.sortable('serialize');
$.ajax({
data: sorted_data,
type: 'POST',
url : "{{ url('user/post/save-item-ordering') }}",
beforeSend:function(xhr){
var token = $('meta[name="csrf_token"]').attr('content');
if (token) {
return xhr.setRequestHeader('X-CSRF-TOKEN', token);
}
xhr.setRequestHeader( 'X-Requested-With', 'XMLHttpRequest');
},
success:function(result) {
// div_response.html(result);
console.log(result);
if(result.success){
alert('Item ordering is succcessfully updated!');
}
}
});
});
$('#myModal').on('hidden.bs.modal', function () {
location.reload();
});