/**
  * Lists all Category models.
  * @return mixed
  */
 public function actionIndex()
 {
     //if(!Yii::$app->user->can('viewYourAuth')) throw new ForbiddenHttpException(Yii::t('app', 'No Auth'));
     $searchModel = new CategorySearch();
     $dataProvider = Category::get(0, Category::find()->asArray()->all());
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Example #2
0
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\News */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="news-form">

    <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
?>

    <?php 
echo $form->field($model, 'category_id')->dropDownList(ArrayHelper::map(Category::get(0, Category::find()->asArray()->all()), 'id', 'label'));
?>

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

    <?php 
echo $form->field($model, 'imageFile')->fileInput();
?>

    <?php 
//$form->field($model, 'keyword')->textInput(['maxlength' => true])
?>

    <?php 
Example #3
0
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <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']]]);
?>
Example #4
0
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use common\models\Category;
/* @var $this yii\web\View */
/* @var $model common\models\Category */
/* @var $form yii\widgets\ActiveForm */
$parentCategory = ArrayHelper::merge([0 => Yii::t('blog', 'Root Catalog')], ArrayHelper::map(Category::get(0, Category::find()->asArray()->all()), 'id', 'label'));
unset($parentCategory[$model->id]);
?>

<div class="category-form">

    <?php 
$form = ActiveForm::begin(['id' => 'mend-form', 'options' => ['class' => 'form-horizontal'], 'fieldConfig' => ['template' => "{label}\n<div class=\"col-lg-3\">{input}{hint}</div>\n<div class=\"col-lg-5\">{error}</div>", 'labelOptions' => ['class' => 'col-lg-2 control-label']]]);
?>

    <?php 
echo $form->field($model, 'parent_id')->dropDownList($parentCategory);
?>

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

    <?php 
echo $form->field($model, 'brief')->textInput(['maxlength' => 255]);
?>
Example #5
0
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use common\models\Category;
/* @var $this yii\web\View */
/* @var $model common\models\Category */
/* @var $form yii\widgets\ActiveForm */
$parentCategory = ArrayHelper::merge([0 => Yii::t('app', '顶级目录')], ArrayHelper::map(Category::get(0, Category::find()->asArray()->all()), 'id', 'label'));
unset($parentCategory[$model->id]);
?>

<div class="category-form">

    <?php 
$form = ActiveForm::begin(['id' => 'mend-form', 'options' => ['class' => 'form-horizontal'], 'fieldConfig' => ['template' => "{label}\n<div class=\"col-lg-3\">{input}{hint}</div>\n<div class=\"col-lg-5\">{error}</div>", 'labelOptions' => ['class' => 'col-lg-2 control-label']]]);
?>

    <?php 
echo $form->field($model, 'parent_id')->dropDownList($parentCategory);
?>

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

    <?php 
echo $form->field($model, 'brief')->textInput(['maxlength' => 255]);
?>
Example #6
0
<?php

use frontend\components\Nav;
$query = new \yii\db\Query();
$result = $query->select('sum(number) as number')->from('cart')->where(['or', 'session_id = "' . Yii::$app->session->id . '"', 'user_id = ' . (Yii::$app->user->id ? Yii::$app->user->id : -1)])->createCommand()->queryOne();
$totalNumber = $result['number'];
?>
<div class="hd_nav">
    <div class="hd_nav_bd cle">
        <div class="main_nav" id="main_nav">
            <div class="main_nav_link">
                <a href="javascript:;">全部商品分类</a>
            </div>
            <div class="main_cata" id="J_mainCata">
                <?php 
$allCategory = \common\models\Category::get(0, \common\models\Category::find()->asArray()->all());
foreach ($allCategory as $category) {
    if ($category["parent_id"] == 0) {
        $menuItems[$category['id']] = ['label' => $category['name'], 'url' => ['/category/view', 'id' => $category['id']]];
    } else {
        $menuItems[$category['parent_id']]['items'][$category['id']] = ['label' => $category['name'], 'url' => ['/category/view', 'id' => $category['id']]];
    }
}
echo Nav::widget(['options' => ['class' => ''], 'items' => $menuItems]);
?>

            </div>
            <div class="J_subCata" id="J_subCata">
            </div>
        </div>
        <ul class="sub_nav cle" id="sub_nav">