Exemplo n.º 1
0
?>

    <?php 
echo $form->field($model, 'content')->widget(CKEditor::className(), ['editorOptions' => ['preset' => 'full', 'inline' => false]]);
?>

    <?php 
echo $form->field($model, 'keywords')->textInput(['maxlength' => 255]);
?>

    <?php 
echo $form->field($model, 'description')->textarea(['rows' => 6]);
?>

    <?php 
echo $form->field($model, 'type')->checkboxList(\common\models\ProductType::labels());
?>

    <?php 
echo $form->field($model, 'brand_id')->dropDownList(ArrayHelper::map(\common\models\Brand::find()->all(), 'id', 'name'), ['prompt' => Yii::t('app', 'Please Select')]);
?>

    <?php 
echo $form->field($model, 'status')->dropDownList(\common\models\Status::labels());
?>

    <?php 
if (!$model->isNewRecord) {
    ?>
        <div class="form-group">
            <?php 
Exemplo n.º 2
0
?>

    <p>
        <?php 
echo Html::a(Yii::t('app', 'Create ') . Yii::t('app', 'Product'), ['create'], ['class' => 'btn btn-success']);
?>
        <?php 
echo Html::a(Yii::t('app', 'Batch ') . Yii::t('app', 'Delete'), '#', ['class' => 'btn btn-danger', 'id' => 'batchDelete']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\CheckboxColumn'], 'id', ['attribute' => 'category_id', 'value' => function ($model) {
    return $model->category->name;
}, 'filter' => Html::activeDropDownList($searchModel, 'category_id', ArrayHelper::map(Category::get(0, Category::find()->asArray()->all()), 'id', 'label'), ['class' => 'form-control', 'prompt' => Yii::t('app', 'Please Filter')])], 'name', 'sku', 'stock', 'market_price', 'price', ['attribute' => 'type', 'format' => 'html', 'value' => function ($model) {
    return \common\models\ProductType::labels($model->type);
}], ['attribute' => 'brand_id', 'value' => function ($model) {
    return $model->brand ? $model->brand->name : '-';
}, 'filter' => Html::activeDropDownList($searchModel, 'type', ArrayHelper::map(\common\models\Brand::find()->all(), 'id', 'name'), ['class' => 'form-control', 'prompt' => Yii::t('app', 'Please Filter')])], ['attribute' => 'status', 'format' => 'html', 'value' => function ($model) {
    if ($model->status === Status::STATUS_ACTIVE) {
        $class = 'label-success';
    } elseif ($model->status === Status::STATUS_INACTIVE) {
        $class = 'label-warning';
    } else {
        $class = 'label-danger';
    }
    return '<span class="label ' . $class . '">' . Status::labels($model->status) . '</span>';
}, 'filter' => Html::activeDropDownList($searchModel, 'status', Status::labels(), ['class' => 'form-control', 'prompt' => Yii::t('app', 'PROMPT_STATUS')])], 'created_at:date', ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
Exemplo n.º 3
0
<style>
td img{width:100px;}
</style>
<div class="product-view">

    <p>
        <?php 
echo Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), 'method' => 'post']]);
?>
    </p>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['id', ['attribute' => 'category_id', 'value' => $model->category ? $model->category->name : '-'], 'name', 'sku', 'stock', 'weight', 'market_price', 'price', 'brief', 'content:ntext', ['attribute' => 'thumb', 'format' => 'image', 'value' => isset($data) ? "data:" . $fileType . ";base64," . $data . "" : ($model->thumb ? $model->thumb : ''), 'options' => ['style' => 'width:100px'], 'visible' => isset($model->thumb)], 'image', 'keywords', 'description:ntext', ['attribute' => 'type', 'value' => \common\models\ProductType::labels($model->type)], ['attribute' => 'brand_id', 'value' => $model->brand ? $model->brand->name : '-'], ['attribute' => 'status', 'value' => \common\models\Status::labels($model->status)], 'created_at:datetime', 'updated_at:datetime', ['attribute' => 'created_by', 'value' => $model->createdBy->username], ['attribute' => 'updated_by', 'value' => $model->updatedBy->username]]]);
?>

</div>

<?php 
foreach ($model->productImagesSort as $item) {
    if (strpos($model->thumb, 'http://') === null) {
        $file = Yii::getAlias('@frontend/web' . $item->thumb);
        $fileType = \yii\helpers\FileHelper::getMimeType($file);
        $data = base64_encode(file_get_contents($file));
        echo "<img src='data:" . $fileType . ";base64," . $data . "' width=100>";
    } else {
        echo "<img src='{$item->thumb}' width=100>";
    }
}