Guys, me again o.O
How can I select all products according to the same model? I'm using modal to show the products (When I click on Magnifying Glass)
Follow my code:
Controller:
def table_stock():
somar = db.products.unit_price.sum()
count = db.products.id.count()
results = db(query).select(db.products.ALL, db.stock.ALL,count,somar, groupby=db.products.model)
view = db(
db.stock.id == db.products.stock).select(db.products.ALL)
return locals()
View:
<table id="data-table-simple" class="responsive-table display" cellspacing="2">
<thead>
<tr>
<th data-field="id">Product Code</th>
<th data-field="name_model">Product Model</th>
<th data-field="name_manufacturer">Product Manufacturer</th>
<th data-field="minimum_qtd">Minimum Qtd</th>
<th data-field="current_qtd">Current Qtd</th>
<th data-field="max_qtd">Max Qtd</th>
<th data-field="somar">Total Price</th>
<th style="background-image: none;"></th>
</tr>
</thead>
<tfoot>
<tr>
<th data-field="id">Product Code</th>
<th data-field="name_model">Product Model</th>
<th data-field="name_manufacturer">Product Manufacturer</th>
<th data-field="minimum_qtd">Minimum Qtd</th>
<th data-field="current_qtd">Current Qtd</th>
<th data-field="max_qtd">Max Qtd</th>
<th data-field="somar">Total Price</th>
<th style="background-image: none;"></th>
</tr>
</tfoot>
<tbody>
{{for row in results:}}
<tr>
<td>{{=row.products.model.name_model}}</td>
<td>{{=row.products.manufacturer.name_manufacturer}}</td>
<td>{{=row.stock.minimum_qtd}}</td>
<td>{{=row[count]}}</td>
<td>{{=row.stock.max_qtd}}</td>
<td>$ {{=row[somar]}}</td>
<td style="width: 10%;">
<a id="products" class="modal-trigger" href="#view_products" title="products" style=" position: absolute; margin: -19px 37px;font-size: 26px;"><i class="mdi-action-find-in-page" style="color: #000;"></i></a>
</td>
</tr>
{{pass}}
</tbody>
</table>