mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fix product list filter
This commit is contained in:
parent
ffaea75c01
commit
89088e5517
@ -71,7 +71,7 @@ class ProductController extends BaseController
|
||||
*/
|
||||
public function getDatatable()
|
||||
{
|
||||
return $this->productService->getDatatable(Auth::user()->account_id);
|
||||
return $this->productService->getDatatable(Auth::user()->account_id, Input::get('sSearch'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,7 @@ class ProductRepository extends BaseRepository
|
||||
->get();
|
||||
}
|
||||
|
||||
public function find($accountId)
|
||||
public function find($accountId, $filter = null)
|
||||
{
|
||||
$query = DB::table('products')
|
||||
->leftJoin('tax_rates', function($join) {
|
||||
@ -35,6 +35,13 @@ class ProductRepository extends BaseRepository
|
||||
'products.deleted_at'
|
||||
);
|
||||
|
||||
if ($filter) {
|
||||
$query->where(function ($query) use ($filter) {
|
||||
$query->where('products.product_key', 'like', '%'.$filter.'%')
|
||||
->orWhere('products.notes', 'like', '%'.$filter.'%');
|
||||
});
|
||||
}
|
||||
|
||||
if (!\Session::get('show_trash:product')) {
|
||||
$query->where('products.deleted_at', '=', null);
|
||||
}
|
||||
|
@ -41,10 +41,10 @@ class ProductService extends BaseService
|
||||
* @param $accountId
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function getDatatable($accountId)
|
||||
public function getDatatable($accountId, $search)
|
||||
{
|
||||
$datatable = new ProductDatatable(true);
|
||||
$query = $this->productRepo->find($accountId);
|
||||
$query = $this->productRepo->find($accountId, $search);
|
||||
|
||||
if(!Utils::hasPermission('view_all')){
|
||||
$query->where('products.user_id', '=', Auth::user()->id);
|
||||
|
@ -83,6 +83,10 @@
|
||||
if (window.onDatatableReady) {
|
||||
window.onDatatableReady();
|
||||
}
|
||||
},
|
||||
"stateLoadParams": function (settings, data) {
|
||||
// don't save filter to local storage
|
||||
data.search.search = "";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user