Inheritance: extends yii\db\ActiveRecord
 public function actionDetail($id)
 {
     /* @var $model Store */
     $model = Store::findOne($id);
     if (!$model) {
         throw new BadRequestHttpException('未找到该营业点!');
     }
     if ($model->status === Store::STATUS_DISABLED) {
         throw new BadRequestHttpException('该店铺已被禁用,请重新选择!');
     }
     $data['store'] = $model->toArray(['id', 'name', 'school_id', 'address', 'cellphone', 'telephone', 'notice', 'status', 'hours', 'has_book', 'has_down', 'has_gift', 'has_least', 'down_upper', 'down_val', 'gift_upper', 'gift_val', 'least_val', 'created_at']);
     $data['store']['downMsg'] = $model->downMsg;
     $data['store']['giftMsg'] = $model->giftMsg;
     $data['categories'] = Category::getKeyValuePairs();
     foreach ($data['categories'] as $key => $name) {
         $goodsList = $model->getGoods($key)->all();
         if ($goodsList) {
             foreach ($goodsList as $goods) {
                 $goodsArr = $goods->toArray();
                 $data['goodsList'][$key][] = $goodsArr;
             }
         } else {
             $data['goodsList'][$key] = [];
         }
     }
     return $data;
 }
示例#2
0
 public function actionLoadGoods($id, $category = 'all', $q = '')
 {
     $offset = (int) Yii::$app->request->post('offset');
     Yii::$app->response->format = Response::FORMAT_JSON;
     /* @var $model Store */
     $model = Store::findOne(['id' => $id, 'status' => [Store::STATUS_ACTIVE, Store::STATUS_REST]]);
     if (!$model) {
         throw new NotFoundHttpException('未找到该营业点!');
     }
     if ($q !== '') {
         $query = $model->getGoods()->andWhere(['or', ['like', 'name', $q], ['like', 'description', $q]]);
     } else {
         $modelCate = $category === 'all' ? null : Category::findOne(['slug' => $category]);
         if ($modelCate) {
             $query = $model->getGoods($modelCate->id);
         } else {
             $query = $model->getGoods();
         }
     }
     $limit = 8;
     $goodsList = $query->offset($offset)->limit($limit)->all();
     $output = ['status' => 'ok', 'html' => '', 'length' => count($goodsList)];
     $output['end'] = $output['length'] < $limit;
     foreach ($goodsList as $goods) {
         $output['html'] .= $this->renderPartial('_item', ['goods' => $goods, 'lazy' => false]);
     }
     return $output;
 }
示例#3
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     $schoolId = Yii::$app->request->cookies['schoolId'];
     $storeId = Yii::$app->request->cookies['storeId'];
     if ($schoolId) {
         Yii::$app->params['schoolModel'] = School::findOne($schoolId);
     }
     if ($storeId) {
         Yii::$app->params['storeModel'] = Store::findOne($storeId);
     }
 }
 public function __construct($id, $config = [])
 {
     $this->_store = Store::findOne($id);
     if (!$this->_store) {
         throw new InvalidParamException('未找到该店铺!');
     }
     if ($this->_store->status === Store::STATUS_DISABLED) {
         throw new InvalidParamException('该店铺已禁用!');
     }
     parent::__construct($config);
 }
示例#5
0
 public function search($params)
 {
     $query = Store::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]], 'pagination' => ['pageSize' => 20]]);
     // load the seach form data and validate
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $dateBegin = strtotime($this->date);
     $dateEnd = $dateBegin + 86400;
     // adjust the query by adding the filters
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['school_id' => $this->school_id])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['status' => $this->status])->andFilterWhere(['>=', 'created_at', $this->date ? $dateBegin : null])->andFilterWhere(['<', 'created_at', $this->date ? $dateEnd : null]);
     return $dataProvider;
 }
示例#6
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $stores = [];
     if (\Yii::$app->user->identity->id != 1) {
         $stores = UserStore::find()->select('store_id')->where(['user_id' => Yii::$app->user->identity->id])->all();
         $stores = ArrayHelper::getColumn($stores, 'store_id');
     }
     $query = Store::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['store_id' => $this->store_id]);
     $query->andFilterWhere(['like', 'store_name', $this->store_name])->andFilterWhere(['like', 'store_desc', $this->store_desc])->andFilterWhere(['like', 'store_picture', $this->store_picture])->andFilterWhere(['in', 'store_id', $stores]);
     return $dataProvider;
 }
示例#7
0
 /**
  * Creates a new Product model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     // echo Yii::getAlias('@common'); exit;
     $model = new Product();
     $modelProdMeta = new ProductMeta();
     $stores = [];
     if (\Yii::$app->user->identity->id == 1) {
         $stores = \common\models\UserStore::find()->select('store_id')->where(['user_id' => Yii::$app->user->identity->id])->all();
         $stores = \yii\helpers\ArrayHelper::getColumn($stores, 'store_id');
         $storeList = \common\models\Store::find()->where(['IN', 'store_id', $stores])->all();
     } else {
         $storeList = \common\models\Store::find()->all();
     }
     if ($postData = Yii::$app->request->post()) {
         if ($model->load($postData) && $model->save()) {
             $prod_id = $model->prod_id;
             foreach ($model->cat_id as $cat) {
                 $catModel = new ProdCat();
                 $catModel->cat_id = $cat;
                 $catModel->prod_id = $prod_id;
                 $catModel->save();
             }
             $file = UploadedFile::getInstances($model, 'images');
             $model->file = $file[0];
             $image_path = Yii::getAlias('@frontend') . '/web/uploads/product/' . $model->file->baseName . '_' . $prod_id . '.' . $model->file->extension;
             $model->file->saveAs($image_path);
             $this->updateProductMeta($id, 'prod_img', $model->file->baseName . '_' . $prod_id . '.' . $model->file->extension);
             foreach ($postData['PMeta'] as $key => $meta_value) {
                 $this->updateProductMeta($id, $key, $meta_value);
             }
             return $this->redirect(['view', 'id' => $model->prod_id]);
         }
     } else {
         return $this->render('create', ['model' => $model, 'modelProdMeta' => $modelProdMeta, 'storeList' => $storeList]);
     }
 }
 public function actionRealFee()
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $storeId = Yii::$app->request->post('storeId', 0);
     $preferential = Yii::$app->request->post('preferential');
     $newDown = Yii::$app->request->post('newdown');
     $payment = Yii::$app->request->post('payment');
     /* @var $model Store */
     $model = Store::findOne($storeId);
     if (!$model) {
         return ['status' => 'no'];
     }
     $realFee = $fee = Yii::$app->user->identity->getCartGoodsRealVolume($storeId);
     switch ($preferential) {
         case Order::PREFERENTIAL_DOWN:
             if ($model->has_down && $fee >= $model->down_upper) {
                 $realFee = bcsub($realFee, $model->down_val, 2);
             }
             break;
         default:
             break;
     }
     if (Yii::$app->params['enableNewDown'] && $newDown && $fee >= Yii::$app->params['newDownUpper'] && Yii::$app->user->identity->has_new_down) {
         $realFee = bcsub($realFee, Yii::$app->params['newDownVal'], 2);
         if ($realFee < 0) {
             $realFee = '0.00';
         }
     }
     return ['status' => 'ok', 'realFee' => $realFee];
 }
示例#9
0
 /**
  * Finds the Store model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Store the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Store::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#10
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getStore()
 {
     return $this->hasOne(Store::className(), ['id' => 'store_id']);
 }
示例#11
0
$this->title = '营业点用户列表';
?>
<p>
    <?php 
echo Html::a('<i class="fa fa-plus"></i> 添加营业点用户', ['member/add'], ['class' => 'btn btn-primary']);
?>
</p>
<div class="row">
    <div class="col-lg-12">
        <?php 
Pjax::begin();
?>
        <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'tableOptions' => ['class' => 'table table-striped table-bordered table-center'], 'summaryOptions' => ['tag' => 'p', 'class' => 'text-right text-info'], 'columns' => [['class' => 'yii\\grid\\SerialColumn', 'headerOptions' => ['class' => '']], ['attribute' => 'store_id', 'headerOptions' => ['class' => 'col-md-4'], 'filterInputOptions' => ['class' => 'form-control input-sm'], 'value' => function ($model, $key, $index, $column) {
    return $model->store->school->name . '-' . $model->store->name;
}, 'filter' => Select2::widget(['model' => $searchModel, 'initValueText' => ($store = Store::findOne($searchModel->store_id)) ? $store->name : '', 'attribute' => 'store_id', 'size' => Select2::SMALL, 'theme' => Select2::THEME_KRAJEE, 'options' => ['placeholder' => '搜索店铺名称...'], 'pluginOptions' => ['allowClear' => true, 'minimumInputLength' => 3, 'ajax' => ['url' => Url::to(['/store/name-filter']), 'dataType' => 'json', 'data' => new JsExpression('function(params) { return {q:params.term}; }')], 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), 'templateResult' => new JsExpression('function (store) { return store.text; }'), 'templateSelection' => new JsExpression('function (store) { return store.text; }')]])], ['attribute' => 'username', 'headerOptions' => ['class' => 'col-md-1'], 'filterInputOptions' => ['class' => 'form-control input-sm']], ['attribute' => 'real_name', 'headerOptions' => ['class' => 'col-md-1'], 'filterInputOptions' => ['class' => 'form-control input-sm']], ['attribute' => 'gender', 'filter' => Member::getGenderList(), 'filterInputOptions' => ['class' => 'form-control input-sm'], 'headerOptions' => ['class' => 'col-md-1'], 'value' => function ($model, $key, $index, $column) {
    return $model->genderMsg;
}], ['attribute' => 'mobile', 'headerOptions' => ['class' => 'col-md-1'], 'filterInputOptions' => ['class' => 'form-control input-sm']], ['attribute' => 'status', 'format' => 'raw', 'filter' => Member::getStatusList(), 'filterInputOptions' => ['class' => 'form-control input-sm'], 'headerOptions' => ['class' => 'col-md-1'], 'value' => function ($model, $key, $index, $column) {
    return Html::dropDownList('status', $model->status, Member::getStatusList(), ['data-id' => $model->id]);
}], ['attribute' => 'created_at', 'format' => ['date', 'php:Y-m-d H:i'], 'filter' => DatePicker::widget(['model' => $searchModel, 'type' => DatePicker::TYPE_COMPONENT_APPEND, 'attribute' => 'date', 'options' => ['class' => 'input-sm'], 'pluginOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd']]), 'headerOptions' => ['class' => 'col-md-2']], ['class' => 'yii\\grid\\ActionColumn', 'header' => '操作', 'headerOptions' => ['class' => 'col-md-1'], 'template' => '{update}']]]);
?>
        <?php 
Pjax::end();
?>
    </div>
</div>
<?php 
$url = Url::to(['/member/status']);
$js = <<<JS
var handle = function () {
    var id = \$(this).attr('data-id');
示例#12
0
 public function actionNameFilter($q = null, $id = null)
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $output = ['results' => ['id' => '', 'text' => '']];
     if (!is_null($q)) {
         $sql = 'SELECT t0.id, CONCAT(t1.name, \'-\', t0.name) AS text FROM ' . Store::tableName() . ' AS t0 LEFT JOIN ' . School::tableName() . ' AS t1 ON t0.school_id = t1.id WHERE t0.name LIKE :like ORDER BY t0.school_id ASC LIMIT 25';
         $output['results'] = Yii::$app->db->createCommand($sql, [':like' => "%{$q}%"])->queryAll();
     } elseif ($id > 0 && ($store = Store::findOne($id))) {
         $output['results'] = ['id' => $id, 'text' => $store->school->name . '-' . $store->name];
     }
     return $output;
 }
示例#13
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getStores()
 {
     return $this->hasMany(Store::className(), ['school_id' => 'id'])->where(['<>', 'status', Store::STATUS_DISABLED])->orderBy('name ASC');
 }
示例#14
0
 public function actionRegisterStore()
 {
     $this->layout = 't2/main';
     $userModel = new SignupForm();
     $storeModel = new Store();
     $user_id = 0;
     if ($userModel->load(Yii::$app->request->post()) && $storeModel->load(Yii::$app->request->post())) {
         // print_r($storeModel->validate()); exit;
         if (Yii::$app->user->isGuest) {
             if ($userModel->validate() && ($user = $userModel->signup())) {
                 $user_id = $user->id;
             } else {
                 return $this->render('registerStore', ['userModel' => $userModel, 'storeModel' => $storeModel]);
             }
         } else {
             $user_id = \Yii::$app->user->identity->id;
         }
         $store_img = UploadedFile::getInstances($storeModel, 'file');
         if ($storeModel->validate()) {
             if (!empty($store_img)) {
                 $storeModel->file = $store_img[0];
                 $image_name = '/store/' . $storeModel->file->baseName . '_' . time() . '.' . $storeModel->file->extension;
                 $image_path = Yii::getAlias('@frontend') . '/web/uploads' . $image_name;
                 $storeModel->file->saveAs($image_path);
                 $storeModel->store_picture = $image_name;
             }
             if ($storeModel->save()) {
                 $store_id = $storeModel->store_id;
                 $userStore = new UserStore();
                 $userStore->user_id = $user_id;
                 $userStore->store_id = $store_id;
                 $userStore->save();
                 return $this->redirect(Yii::$app->urlManager->getBaseUrl() . '/backend/web/');
             } else {
                 print_r($storeModel->error);
                 exit;
             }
             // }
         } else {
             print_r($storeModel->errors);
             exit;
             return $this->render('registerStore', ['userModel' => $userModel, 'storeModel' => $storeModel]);
         }
         echo '<pre>';
         print_r($storeModel);
         print_r($store_img);
         exit;
     }
     // $store_img = UploadedFile::getInstances($storeModel, 'file');
     // $storeModel->file = $store_img[0];
     // if($storeModel->validate()) {
     //     if(!empty($store_img)){
     //         $image_name = '/store/' . $storeModel->file->baseName . '_' . time() . '.' . $storeModel->file->extension;
     //         $image_path = Yii::getAlias('@frontend'). '/web/uploads' . $image_name;
     //         $storeModel->file->saveAs( $image_path);
     //         $storeModel->store_picture = $image_name;
     //         if($storeModel->save()) {
     //             $store_id = $storeModel->store_id;
     //             $user_id = \Yii::$app->user->identity->id;
     //             echo $store_id;
     //             echo $user_id;
     //             exit;
     //         }
     //     }
     //    // return $this->redirect(['view', 'id' => $model->store_id]);
     // } else {
     //     // return $this->render('update', [
     //     //     'model' => $model,
     //     // ]);
     // }
     return $this->render('registerStore', ['userModel' => $userModel, 'storeModel' => $storeModel]);
 }
示例#15
0
<?php

use yii\helpers\Url;
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\web\JsExpression;
use kartik\select2\Select2;
use common\models\Store;
$this->title = $model->isNewRecord ? '添加标签' : '更新标签';
?>
<div class="row">
    <div class="col-lg-6">
    <?php 
$form = ActiveForm::begin();
?>
        <?php 
echo $form->field($model, 'store_id')->widget(Select2::className(), ['initValueText' => ($store = Store::findOne($model->store_id)) ? $store->name : '', 'theme' => Select2::THEME_KRAJEE, 'options' => ['placeholder' => '搜索店铺名称...'], 'pluginOptions' => ['allowClear' => true, 'minimumInputLength' => 3, 'ajax' => ['url' => Url::to(['/store/name-filter']), 'dataType' => 'json', 'data' => new JsExpression('function(params) { return {q:params.term}; }')], 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), 'templateResult' => new JsExpression('function (store) { return store.text; }'), 'templateSelection' => new JsExpression('function (store) { return store.text; }')]]);
?>
        <?php 
echo $form->field($model, 'name');
?>
        <div class="form-group">
            <?php 
echo Html::submitButton('<i class="fa fa-floppy-o"></i> 保存', ['class' => 'btn btn-primary']);
?>
        </div>
    <?php 
ActiveForm::end();
?>
    </div>
</div>
示例#16
0
 /**
  * 将商品从一个店铺克隆到另一个店铺
  * 
  * @param string $from     源商品所在店铺ID
  * @param string $to       目标店铺ID
  * @param string $category 过滤商品类型
  * @param string $status   过滤商品状态
  * @return string
  */
 public function actionCloneAll($from, $to, $category = 'all', $status = 'all')
 {
     $modelFrom = Store::findOne($from);
     $modelTo = Store::findOne($to);
     if (!$modelFrom || !$modelTo) {
         echo "The parameter error.\n";
         return static::EXIT_CODE_ERROR;
     }
     if ($modelFrom->type !== $modelTo->type) {
         if (!static::confirm("The types of two stores are not the same, continue?")) {
             echo "Cancelled.\n";
             return static::EXIT_CODE_NORMAL;
         }
     }
     unset($modelFrom, $modelTo);
     $query = Goods::find()->where(['store_id' => $from]);
     if ($category !== 'all') {
         $modelCate = Category::findOne(['slug' => $category]);
         if ($modelCate) {
             $query->andWhere(['category_id' => $modelCate->id]);
             unset($modelCate);
         } else {
             echo "The category \"{$category}\" can not be exists.\n";
             return static::EXIT_CODE_ERROR;
         }
     }
     if ($status !== 'all') {
         if (in_array($status, [Goods::STATUS_NORMAL, Goods::STATUS_OFF_SHELVES, Goods::STATUS_DELETED])) {
             $query->andWhere(['status' => $status]);
         } else {
             echo "The status was error.\n";
             return static::EXIT_CODE_ERROR;
         }
     }
     if (($count = $query->count()) > 0) {
         if (!static::confirm("Next we will clone {$count} goods, are you sure?")) {
             echo "Cancelled.\n";
             return static::EXIT_CODE_NORMAL;
         }
     } else {
         echo "The goods count is 0.\n";
         return static::EXIT_CODE_NORMAL;
     }
     $goodsList = $query->asArray()->all();
     $time = time();
     $sql = "INSERT INTO {{%goods}} (name, store_id, category_id, cover, price, price_original, cost, description, status, surplus, sales, unit, is_new, is_hot, is_promotion, created_at, updated_at) VALUES (:name, :store_id, :category_id, :cover, :price, :price_original, :cost, :description, :status, :surplus, :sales, :unit, :is_new, :is_hot, :is_promotion, :created_at, :updated_at)";
     $sql2 = "INSERT INTO {{%goods_img}} (name, goods_id) VALUES (:name, :goods_id)";
     $sql3 = "INSERT INTO {{%goods_surplus}} (goods_id, surplus_before, amount, surplus_after, remark, created_at, updated_at) VALUES (:goods_id, :surplus_before, :amount, :surplus_after, :remark, :created_at, :updated_at)";
     $transaction = Yii::$app->db->beginTransaction();
     try {
         foreach ($goodsList as $goods) {
             Yii::$app->db->createCommand($sql, [':name' => $goods['name'], ':store_id' => $to, ':category_id' => $goods['category_id'], ':cover' => $goods['cover'], ':price' => $goods['price'], ':price_original' => $goods['price_original'], ':cost' => $goods['cost'], ':description' => $goods['description'], ':status' => $goods['status'], ':surplus' => $goods['surplus'], ':sales' => '0', ':unit' => $goods['unit'], ':is_new' => $goods['is_new'], ':is_hot' => $goods['is_hot'], ':is_promotion' => $goods['is_promotion'], ':created_at' => $time, ':updated_at' => $time])->execute();
             $goodsId = Yii::$app->db->getLastInsertID();
             $goodsImgList = GoodsImg::find()->where(['goods_id' => $goods['id']])->asArray()->all();
             foreach ($goodsImgList as $goodsImg) {
                 Yii::$app->db->createCommand($sql2, [':name' => $goodsImg['name'], ':goods_id' => $goodsId])->execute();
             }
             Yii::$app->db->createCommand($sql3, [':goods_id' => $goodsId, ':surplus_before' => 0, ':amount' => $goods['surplus'], ':surplus_after' => $goods['surplus'], ':remark' => '初始化库存。', ':created_at' => $time, ':updated_at' => $time])->execute();
         }
         $transaction->commit();
         echo "Success!\n";
         return static::EXIT_CODE_NORMAL;
     } catch (\Exception $e) {
         $transaction->rollBack();
         echo $e->getMessage();
         return static::EXIT_CODE_ERROR;
     }
 }
示例#17
0
        <?php 
echo $form->field($model, 'cellphone');
?>
        <?php 
echo $form->field($model, 'telephone');
?>
        <?php 
echo $form->field($model, 'hours');
?>
        <?php 
echo $form->field($model, 'layout')->dropDownList(Store::getLayoutList());
?>
        <?php 
echo $form->field($model, 'enable_sms')->checkbox();
?>
        <?php 
echo $form->field($model, 'auto_toggle', ['checkboxTemplate' => "<div class=\"checkbox form-inline\">\n{beginLabel}\n{input}\n{labelTitle}\n{endLabel}\n{detail}\n{error}\n{hint}\n</div>", 'parts' => ['{detail}' => '类型 ' . Html::activeDropDownList($model, 'toggle_type', Store::getToggleTypeList(), ['class' => 'form-control'])]])->checkbox();
?>
        <?php 
echo $form->field($model, 'notice');
?>
        <div class="form-group">
            <?php 
echo Html::submitButton('<i class="fa fa-floppy-o"></i> 保存', ['class' => 'btn btn-primary']);
?>
        </div>
    <?php 
ActiveForm::end();
?>
    </div>
</div>
示例#18
0
?>
<p>
    <?php 
echo Html::a('<i class="fa fa-plus"></i> 添加营业点', ['store/add'], ['class' => 'btn btn-primary']);
?>
</p>
<div class="row">
    <div class="col-lg-12">
        <?php 
Pjax::begin();
?>
        <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'tableOptions' => ['class' => 'table table-striped table-bordered table-center'], 'summaryOptions' => ['tag' => 'p', 'class' => 'text-right text-info'], 'columns' => [['class' => 'yii\\grid\\SerialColumn', 'headerOptions' => ['class' => 'col-md-1']], ['attribute' => 'name', 'headerOptions' => ['class' => 'col-md-2'], 'filterInputOptions' => ['class' => 'form-control input-sm']], ['attribute' => 'school_id', 'headerOptions' => ['class' => 'col-md-3'], 'filterInputOptions' => ['class' => 'form-control input-sm'], 'value' => function ($model, $key, $index, $column) {
    return $model->school->name;
}, 'filter' => Select2::widget(['model' => $searchModel, 'initValueText' => ($school = School::findOne($searchModel->school_id)) ? $school->name : '', 'attribute' => 'school_id', 'size' => Select2::SMALL, 'theme' => Select2::THEME_KRAJEE, 'options' => ['placeholder' => '搜索学校名称...'], 'pluginOptions' => ['allowClear' => true, 'minimumInputLength' => 3, 'ajax' => ['url' => Url::to(['/school/name-filter']), 'dataType' => 'json', 'data' => new JsExpression('function(params) { return {q:params.term}; }')], 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), 'templateResult' => new JsExpression('function (store) { return store.text; }'), 'templateSelection' => new JsExpression('function (store) { return store.text; }')]])], ['attribute' => 'address', 'headerOptions' => ['class' => 'col-md-2'], 'filterInputOptions' => ['class' => 'form-control input-sm']], ['attribute' => 'status', 'format' => 'raw', 'filter' => Store::getStatusList(), 'filterInputOptions' => ['class' => 'form-control input-sm'], 'headerOptions' => ['class' => 'col-md-1'], 'value' => function ($model, $key, $index, $column) {
    return Html::dropDownList('status', $model->status, Store::getStatusList(), ['data-id' => $model->id]);
}], ['attribute' => 'created_at', 'format' => ['date', 'php:Y-m-d H:i'], 'filter' => DatePicker::widget(['model' => $searchModel, 'type' => DatePicker::TYPE_COMPONENT_APPEND, 'attribute' => 'date', 'options' => ['class' => 'input-sm'], 'pluginOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd']]), 'headerOptions' => ['class' => 'col-md-2']], ['class' => 'yii\\grid\\ActionColumn', 'header' => '操作', 'headerOptions' => ['class' => 'col-md-1'], 'template' => '{update} {view}']]]);
?>
        <?php 
Pjax::end();
?>
    </div>
</div>
<?php 
$url = Url::to(['/store/status']);
$js = <<<JS
var handle = function () {
    var id = \$(this).attr('data-id');
    var status = \$(this).val();
    \$.ajax({
        url: '{$url}?id=' + id ,
示例#19
0
use common\models\School;
$this->title = $model->isNewRecord ? '添加营业点用户' : '更新营业点用户';
?>
<div class="row">
    <div class="col-lg-6">
    <?php 
$form = ActiveForm::begin(['enableAjaxValidation' => true, 'options' => ['autocomplete' => 'off']]);
?>
        <div class="form-group">
            <label class="control-label">学校</label>
            <?php 
echo Html::dropDownList('school', $model->isNewRecord ? '' : $model->store->school_id, School::getKeyValuePairs(), ['class' => 'form-control']);
?>
        </div>
        <?php 
echo $form->field($model, 'store_id')->dropDownList($model->isNewRecord ? [] : Store::getKeyValuePairs($model->store->school_id));
?>
        <?php 
echo $form->field($model, 'username')->textInput(['autocomplete' => 'off']);
?>
        <?php 
echo $form->field($model, 'password')->passwordInput(['autocomplete' => 'off']);
?>
        <?php 
echo $form->field($model, 'email')->input('email');
?>
        <?php 
echo $form->field($model, 'real_name');
?>
        <?php 
echo $form->field($model, 'gender')->dropDownList(Admin::getGenderList());
示例#20
0
        <?php 
echo $form->field($model, 'has_book')->checkbox();
?>
        <?php 
echo $form->field($model, 'has_least', ['checkboxTemplate' => "<div class=\"checkbox form-inline\">\n{beginLabel}\n{input}\n{labelTitle}\n{endLabel}\n{detail}\n{error}\n{hint}\n</div>", 'parts' => ['{detail}' => '起送价 ' . Html::activeTextInput($model, 'least_val', ['class' => 'form-control']) . ' 元']])->checkbox();
?>
        <?php 
echo $form->field($model, 'has_down', ['checkboxTemplate' => "<div class=\"checkbox form-inline\">\n{beginLabel}\n{input}\n{labelTitle}\n{endLabel}\n{detail}\n{error}\n{hint}\n</div>", 'parts' => ['{detail}' => '满 ' . Html::activeTextInput($model, 'down_upper', ['class' => 'form-control']) . ' 元减 ' . Html::activeTextInput($model, 'down_val', ['class' => 'form-control'])]])->checkbox();
?>
        <?php 
echo $form->field($model, 'has_gift', ['checkboxTemplate' => "<div class=\"checkbox form-inline\">\n{beginLabel}\n{input}\n{labelTitle}\n{endLabel}\n{detail}\n{error}\n{hint}\n</div>", 'parts' => ['{detail}' => '满 ' . Html::activeTextInput($model, 'gift_upper', ['class' => 'form-control']) . ' 元送 ' . Html::activeTextInput($model, 'gift_val', ['class' => 'form-control'])]])->checkbox();
?>
        <?php 
echo $form->field($model, 'notice');
?>
        <?php 
echo $form->field($model, 'layout')->dropDownList(Store::getLayoutList());
?>
        <?php 
echo $form->field($model, 'status')->dropDownList(Store::getStatusList());
?>
        <div class="form-group">
            <?php 
echo Html::submitButton('<i class="fa fa-floppy-o"></i> 保存', ['class' => 'btn btn-primary']);
?>
        </div>
    <?php 
ActiveForm::end();
?>
    </div>
</div>
示例#21
0
use yii\helpers\Url;
use yii\helpers\Html;
use yii\widgets\Pjax;
use yii\grid\GridView;
use yii\web\JsExpression;
use kartik\date\DatePicker;
use kartik\select2\Select2;
use common\models\Store;
//use himiklab\sortablegrid\SortableGridView;
$this->title = '标签列表';
?>
<p>
    <?php 
echo Html::a('<i class="fa fa-plus"></i> 添加标签', ['tag/add'], ['class' => 'btn btn-primary']);
?>
</p>
<div class="row">
    <div class="col-lg-12">
        <?php 
Pjax::begin();
?>
        <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'tableOptions' => ['class' => 'table table-striped table-bordered table-center'], 'summaryOptions' => ['tag' => 'p', 'class' => 'text-right text-info'], 'columns' => [['class' => 'yii\\grid\\SerialColumn', 'headerOptions' => ['class' => 'col-md-1']], ['attribute' => 'name', 'headerOptions' => ['class' => 'col-md-2'], 'filterInputOptions' => ['class' => 'form-control input-sm']], ['attribute' => 'store_id', 'headerOptions' => ['class' => 'col-md-5'], 'filterInputOptions' => ['class' => 'form-control input-sm'], 'value' => function ($model, $key, $index, $column) {
    return $model->store->school->name . '-' . $model->store->name;
}, 'filter' => Select2::widget(['model' => $searchModel, 'initValueText' => ($store = Store::findOne($searchModel->store_id)) ? $store->name : '', 'attribute' => 'store_id', 'size' => Select2::SMALL, 'theme' => Select2::THEME_KRAJEE, 'options' => ['placeholder' => '搜索店铺名称...'], 'pluginOptions' => ['allowClear' => true, 'minimumInputLength' => 3, 'ajax' => ['url' => Url::to(['/store/name-filter']), 'dataType' => 'json', 'data' => new JsExpression('function(params) { return {q:params.term}; }')], 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), 'templateResult' => new JsExpression('function (store) { return store.text; }'), 'templateSelection' => new JsExpression('function (store) { return store.text; }')]])], ['attribute' => 'created_at', 'format' => ['date', 'php:Y-m-d H:i'], 'filter' => DatePicker::widget(['model' => $searchModel, 'type' => DatePicker::TYPE_COMPONENT_APPEND, 'attribute' => 'date', 'options' => ['class' => 'input-sm'], 'pluginOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd']]), 'headerOptions' => ['class' => 'col-md-3']], ['class' => 'yii\\grid\\ActionColumn', 'header' => '操作', 'headerOptions' => ['class' => 'col-md-1'], 'template' => '{update} {delete}']]]);
?>
        <?php 
Pjax::end();
?>
    </div>
</div>