本文整理汇总了PHP中Purchase::format_decimal方法的典型用法代码示例。如果您正苦于以下问题:PHP Purchase::format_decimal方法的具体用法?PHP Purchase::format_decimal怎么用?PHP Purchase::format_decimal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Purchase
的用法示例。
在下文中一共展示了Purchase::format_decimal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
<caption><h2>Purchase Table</h2></caption>
<thead>
<tr>
<th width="20px">#</th>
<th>Name</th>
<th>Product</th>
<th>Price</th>
<th>Quantity</th>
<th>Total</th>
<th>Balance</th>
<th>Date Ordered</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
if (count($Purcahses)) {
foreach ($Purcahses as $k => $v) {
$k++;
$total = $Purchase->format_decimal($v->quantity * $v->price);
$color = array('danger', 'success', 'warning');
$paynow = $v->status != 1 ? "<a class='btn btn-primary' href='" . BASE_URL . "/custpayment/{$v->id}'>Pay Now</a>" : "<span class='btn disabled'>Paid</span>";
echo "\n\t\t\t\t\t<tr class='{$color[$v->status]}'>\n\t\t\t\t\t\t<td>{$k}</td>\n\t\t\t\t\t\t<td>{$v->first_name} {$v->first_name}</td>\n\t\t\t\t\t\t<td>{$v->product}</td>\n\t\t\t\t\t\t<td>{$v->price}</td>\n\t\t\t\t\t\t<td>{$v->quantity}</td>\n\t\t\t\t\t\t<td>{$total}</td>\n\t\t\t\t\t\t<td>{$v->balance}</td>\n\t\t\t\t\t\t<td>{$v->date}</td>\n\t\t\t\t\t\t<td>{$paynow}</td>\n\t\t\t\t\t</tr>\n\t\t\t\t";
}
} else {
echo "<tr><td colspan='9' class='center'>No record yet<td></tr>";
}
?>
</tbody>
</table>
</div>
示例2: foreach
<th >Date</th>
<th>Price</th>
<th>Quantity</th>
<th>Total</th>
<th>Balance</th>
<th>Action</th>
</tr>
</thead>
<?php
if (count($getPurchases)) {
echo "<tbody>";
$total_balance = 0;
foreach ($getPurchases as $key => $val) {
$key++;
$total = $Purchase->format_decimal($val->quantity * $val->price);
$paid_amount = $Purchase->format_decimal($val->paid_amount);
$balance = $Purchase->format_decimal($total - $paid_amount);
$total_balance += $balance;
$color = array('danger', 'success', 'warning');
$paynow = $val->status != 1 ? "<a class='btn btn-primary' href='" . BASE_URL . "/custpayment/{$val->id}'>Pay Now</a>" : "<span class='btn disabled'>Paid</span>";
echo "<tr class='{$color[$val->status]}'>\n\t\t\t\t\t\t\t\t\t\t<td >{$key}</td>\n\t\t\t\t\t\t\t\t\t\t<td>{$val->product}</td>\n\t\t\t\t\t\t\t\t\t\t<td>{$val->date}</td>\n\t\t\t\t\t\t\t\t\t\t<td>{$val->price}</td>\n\t\t\t\t\t\t\t\t\t\t<td>{$val->quantity}</td>\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t<td>{$total}</td>\n\t\t\t\t\t\t\t\t\t\t<td>{$balance}</td>\n\t\t\t\t\t\t\t\t\t\t<td>{$paynow}</td>\n\t\t\t\t\t\t\t\t\t</tr>";
}
echo "</tbody>\n\t\t\t\t\t\t\t\t<tfoot style='padding:0px'>\n\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t<td colspan='6' align='right'>Total Balance</td>\n\t\t\t\t\t\t\t\t\t\t\t<td colspan='2'>{$total_balance}</td>\n\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t</tfoot>";
} else {
echo "<tbody><tr><td colspan='8' align='center'>No transaction's yet</td></tr></tbody>";
}
?>
</table>
</div>
</div>