public function getItemUnit() { $model = ItemUnit::model()->findAll(); $list = CHtml::listData($model, 'id', 'ItemUnitInfo'); return $list; }
<?php foreach (array_reverse($items, true) as $id => $item) { ?> <?php if (substr($item['discount'], 0, 1) == '$') { $total_item = number_format($item['price'] * $item['quantity'] - substr($item['discount'], 1), Yii::app()->shoppingCart->getDecimalPlace()); } else { $total_item = number_format($item['price'] * $item['quantity'] - $item['price'] * $item['quantity'] * $item['discount'] / 100, Yii::app()->shoppingCart->getDecimalPlace()); } $item_id = $item['item_id']; $cur_item_info = Item::model()->findbyPk($item_id); $qty_in_stock = $cur_item_info->quantity; $cur_item_unit = ItemUnitQuantity::model()->findbyPk($item_id); $unit_name = ''; if ($cur_item_unit) { $item_unit = ItemUnit::model()->findbyPk($cur_item_unit->unit_id); $unit_name = $item_unit->unit_name; } ?> <tr> <td> <?php echo $item['name']; ?> <br/> <span class="text-info"><?php echo $qty_in_stock . ' ' . $unit_name . ' ' . Yii::t('app', 'in stock'); ?> </span> </td> <td><?php
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return ItemUnit the loaded model * @throws CHttpException */ public function loadModel($id) { $model = ItemUnit::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }