I have table on page which list all orders which user has. Each order can have 1 or more attached documents and a button for download. Basically if the user has 2 orders he will have 2 buttons on his page
<a href="#files-{{ $download->order_id }}">Download</a> // order 1
<a href="#files-{{ $download->order_id }}">Download</a> // order 2
Clicking on the button is open modal window with files listed and link to download.
This is the modal window
<span id="start" class="target"></span>
<span id="files-{{ $download->order_id }}" class="target"></span>
<div class="modal">
<div class="content vertical-align-middle">
<h2>Click on the button to download it</h2>
<table class="table table-striped">
<thead id="tblHead">
<tr>
<th align="center">File</th>
<th align="center">Action</th>
</tr>
</thead>
<tbody>
@foreach($downloadableOrders as $files)
@if($files->status == 1)
{{--*/ $ids = explode(",", $files->docname); /*--}}
@foreach ($ids as $id)
<tr>
<td></td>
<td><a href="{{ URL::to('/files/download/' . $id . '?_token=' . csrf_token()) }}">Download</a></td>
</tr>
@endforeach
@endif
@endforeach
</tbody>
</table>
<a class="close-btn" href="#start">X</a>
</div>
</div>
This is the query which is used
$downloadableOrders = Order::where('user_id', getCurrentUser()->user_id)
->select("orders.*",\DB::raw("GROUP_CONCAT(documents.id ) as docname"))
->leftjoin("documents",\DB::raw("FIND_IN_SET(documents.id,orders.order_downloadable)"),">",\DB::raw("'0'"))
->groupBy("orders.order_id")
->paginate(10);
The problem is that when modal is open it's lists all orders and all files. Should list files only for the clicked order.
You will have to open the modal box using ajax. So what you need to do is when you click on the Download link ajax will execute, get the data and show it in the modal box.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments