1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
| <?php
$this->db->join('indochine_products_options','indochine_products_options.product_option_id=indochine_order.options');
$uid = $this->session->userdata('uid');
$all_order = $this->db->order_by('id_commande', 'DESC')->get_where('indochine_order' , array('user_id' => $uid))->result_array();
// génération des lignes de détail du tableau
$rows = [];
$i = 0;
$id_cde = '';
$sums = [];
// calcul des totaux pour affichage des totaux avant les produits
foreach ($all_order as $k => $v) {
if ($v['id_commande'] == 0) {
continue;
}
if ( ! isset($sums[$v['id_commande']])) {
$sums[$v['id_commande']] = 0;
}
$total = $v['qnty'] * ($v['product_option_price'] + $v['product_option_extra']);
$sums[$v['id_commande']] += $total;
}
// rendu des lignes du tableau
foreach ($all_order as $k => $v) {
if ($v['id_commande'] == 0) {
continue;
}
if ($id_cde !== $v['id_commande']) {
if ($id_cde !== '') {
$rows[] = '</tbody></table></td>';
}
// ligne total
$total = ($sums[$v['id_commande']] > 0) ? "{$sums[$v['id_commande']]} €" : ' ';
$rows[] = <<<html
<td>
<table class="tbl-accordeon-recap">
<thead>
<tr>
<td>{$v['id_commande']}</td>
<td>{$v['order_date']}</td>
<td>{$total}</td>
</tr>
</thead>
<tbody style="display: table-row-group">
html;
$id_cde = $v['id_commande'];
}
// ligne produit
++$i;
$sum = $v['qnty'] * ($v['product_option_price'] + $v['product_option_extra']);
$total = ($sum > 0) ? "{$sum} €" : ' ';
$rows[] = <<<html
<tr>
<td style="font-size: 18px;">{$i}</td>
<td style="font-size: 18px;">{$v['proname']}</td>
<td style="font-size: 18px;">{$v['qnty']}</td>
<td style="font-size: 18px;">{$total}</td>
</tr>
html;
}
if ( ! empty($all_order)) {
$rows[] = '</tbody></table></td>';
}
?>
<table class="table table-bordered">
<thead>
<tr>
<th>Id</th>
<th><?= $this->lang->line('Orderdate') ?></th>
<th>Total</th>
</tr>
</thead>
<tbody>
<tr><?= implode('</tr><tr>', $rows) ?></tr>
</tbody>
</table> |