示例#1
0
文件: _item.php 项目: vetoni/toko
use yii\helpers\Url;
/** @var ProductObject $product */
$url = Url::to(['product/view', 'slug' => $product->model->slug]);
?>

<div class="col-md-3">
    <div class="thumbnail">
        <a class="image" href="<?php 
echo $url;
?>
">
            <?php 
echo Html::img($product->thumb(300, 300));
?>
        </a>
        <p class="caption">
            <?php 
echo Html::a($product->model->name, $url);
?>
        </p>
        <p class="price"><?php 
echo CurrencyHelper::format($product->model->price);
?>
</p>
        <div class="rating">
            <?php 
echo Rating::widget(['name' => "Product[{$product->model->id}]rating", 'value' => $product->model->rating, 'readonly' => true]);
?>
        </div>
    </div>
</div>
示例#2
0
文件: _comments.php 项目: vetoni/toko
?>
<div class="row">
    <div class="col-md-12">
        <?php 
foreach ($comments as $comment) {
    ?>
            <div class="comment-item">
                <strong><?php 
    echo $comment->user->name;
    ?>
</strong> <em><?php 
    echo Yii::$app->formatter->asDatetime($comment->created_at);
    ?>
</em>
                <p><?php 
    echo Rating::widget(['name' => "Comments[{$comment->id}]", 'value' => $comment->rating, 'readonly' => true]);
    ?>
</p>
                <p><?php 
    echo nl2br(Html::encode($comment->body));
    ?>
</p>
            </div>
        <?php 
}
?>
        <div align="right">
            <?php 
echo $product->pager();
?>
        </div>
示例#3
0
文件: list.php 项目: vetoni/toko
use app\models\Product;
use app\modules\admin\models\CommentSearch;
use app\modules\user\models\User;
use app\widgets\EntityDropDown;
use app\widgets\Rating;
use yii\bootstrap\Html;
use yii\data\ActiveDataProvider;
use yii\helpers\ArrayHelper;
use yii\web\View;
/**
 * @var CommentSearch $searchModel
 * @var ActiveDataProvider $dataProvider
 * @var View $this
 */
$this->title = Yii::t('app', 'Comments');
?>

<?php 
echo \yii\grid\GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'product_id', 'filter' => false, 'format' => 'text'], ['label' => Yii::t('app', 'Product name'), 'filter' => false, 'format' => 'html', 'value' => function ($comment) {
    /** @var Product $product */
    $product = Product::findOne($comment->product_id);
    return Html::a($product->name, ['/admin/product/update', 'id' => $product->id]);
}], ['attribute' => 'user_id', 'format' => 'html', 'filter' => EntityDropDown::widget(['model' => $searchModel, 'attribute' => 'user_id', 'items' => ArrayHelper::map(User::find()->all(), 'id', 'name')]), 'value' => function ($comment) {
    return User::findOne($comment->user_id)->name;
}], ['attribute' => 'body', 'format' => 'text', 'value' => function ($comment) {
    return \yii\helpers\StringHelper::truncateWords($comment->body, 10);
}], 'created_at:datetime', ['attribute' => 'rating', 'format' => 'raw', 'filter' => false, 'value' => function ($comment) {
    return Rating::widget(['readonly' => true, 'name' => "rating[{$comment->id}]", 'value' => $comment->rating]);
}], ['attribute' => 'status', 'format' => 'html', 'filter' => EntityDropDown::widget(['model' => $searchModel, 'attribute' => 'user_id', 'items' => [Yii::t('app', 'Inactive'), Yii::t('app', 'Active')]]), 'value' => function ($comment) {
    return $comment->status == Comment::STATUS_ACTIVE ? Yii::t('app', 'Active') : Yii::t('app', 'Inactive');
}], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {delete}']]]);
示例#4
0
文件: view.php 项目: vetoni/toko
    ?>
                    <span><?php 
    echo CurrencyHelper::format($product->model->old_price);
    ?>
</span>
                <?php 
}
?>
                <strong><?php 
echo CurrencyHelper::format($product->model->price);
?>
</strong>
            </div>
            <?php 
Pjax::begin(['id' => 'product_avg_rating', 'options' => ['class' => 'avg-rating']]);
echo Rating::widget(['name' => 'Product[rating]', 'value' => $product->model->rating, 'readonly' => true]);
Pjax::end();
?>
            <?php 
if ($product->model->inventory > Settings::value('stock', 'outofstock')) {
    ?>
            <div class="bordered">
                <?php 
    $form = ActiveForm::begin(['action' => ['/checkout/cart/add'], 'options' => ['class' => 'form-add-to-cart form-inline']]);
    ?>
                    <?php 
    echo $form->field($formModel, 'quantity');
    ?>
                    <?php 
    echo $form->field($formModel, 'productId')->hiddenInput()->label(false);
    ?>