diff --git a/.gitignore b/.gitignore index 156439a..d463e49 100644 --- a/.gitignore +++ b/.gitignore @@ -38,4 +38,6 @@ vendor.zip /vagrant /backend/web/uploads /api/web/uploads -dump.rdb \ No newline at end of file +dump.rdb +/console/runtime + diff --git a/api/assets/AppAsset.php b/api/assets/AppAsset.php new file mode 100644 index 0000000..6a7b360 --- /dev/null +++ b/api/assets/AppAsset.php @@ -0,0 +1,26 @@ +[ + 'permissions' => [ "网站基本权限" => [ '首页(销售数据)' => '/site/index', '用户注销' => '/site/logout', '用户登录' => '/site/login', ], - "商品模块" => [ - '商品列表' => '/goods/index', - '商品新增' => '/goods/create', - '商品修改' => '/goods/update', + "商品管理" => [ + '商品列表' => '/antgoods/goods/index', + '商品新增' => '/antgoods/goods/create', + '商品修改' => '/antgoods/goods/update', + '商品查看' => '/antgoods/goods/view', ], + "商城分类" => [ + '列表' => '/antgoods/shop-category/index', + '新增' => '/antgoods/shop-category/create', + '修改' => '/antgoods/shop-category/update', + '查看' => '/antgoods/shop-category/view', + ], + "后台分类" => [ + '列表' => '/antgoods/category/index', + '新增' => '/antgoods/category/create', + '修改' => '/antgoods/category/update', + '查看' => '/antgoods/category/view', + ], + "品牌管理" => [ + '列表' => '/antgoods/brand/index', + '新增' => '/antgoods/brand/create', + '修改' => '/antgoods/brand/update', + '查看' => '/antgoods/brand/view', + ], + "供应商管理" => [ + '列表' => '/antgoods/supplier/index', + '新增' => '/antgoods/supplier/create', + '修改' => '/antgoods/supplier/update', + '查看' => '/antgoods/supplier/view', + ], + "属性管理" => [ + '列表' => '/antgoods/attribute/index', + '新增' => '/antgoods/attribute/create', + '修改' => '/antgoods/attribute/update', + '查看' => '/antgoods/attribute/view', + ] + ], + 'menus' => [ + '商城管理' => [ + 'icon' => 'fa-store', + 'items' => [ + ['运营数据', '/site',], + ['基础配置', '/config'], + ], + ], + '商品管理' => [ + 'icon' => 'fa-archive', + 'items' => [ + ['商城分类', '/antgoods/shop-category'], + ['后台分类', '/antgoods/category'], + ['品牌管理', '/antgoods/brand'], + ['属性管理', '/antgoods/attribute'], + ['商品管理', '/antgoods/goods'], + ['供应商管理', '/antgoods/supplier'], + ], + ] ] ]; diff --git a/api/controllers/SiteController.php b/api/controllers/SiteController.php new file mode 100644 index 0000000..7f3e9b2 --- /dev/null +++ b/api/controllers/SiteController.php @@ -0,0 +1,22 @@ + [ + 'class' => 'yii\web\ErrorAction', + ], + ]; + } +} diff --git a/api/controllers/TestController.php b/api/controllers/TestController.php new file mode 100644 index 0000000..7ede9df --- /dev/null +++ b/api/controllers/TestController.php @@ -0,0 +1,59 @@ + Goods::find(), + 'pagination' => [ + 'pageSize' => 1, + ], + ]); + } +} diff --git a/api/controllers/UserController.php b/api/controllers/UserController.php index 010807c..b1c8360 100644 --- a/api/controllers/UserController.php +++ b/api/controllers/UserController.php @@ -48,7 +48,7 @@ class UserController extends ActiveController public function actionIndex() { - $key = $param = base64_encode(1 + date('Y') + $key = $param = base64_encode(1 + date('Y') + date('m') - date('d') - date('h')); $data = []; Yii::$app->userLogic->createUser($data, $key); @@ -71,7 +71,8 @@ class UserController extends ActiveController public function actionMenu() { $key = Yii::$app->request->get('key'); - if (Yii::$app->userLogic->login($key)){ +// $key = sha1(date('Y') - date('m') + date('d') + 1); + if (Yii::$app->userLogic->login($key)) { return Yii::$app->userLogic->getUserMenu(); } } diff --git a/api/runtime/.gitignore b/api/runtime/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/api/runtime/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/api/views/site/error.php b/api/views/site/error.php new file mode 100644 index 0000000..0ba2574 --- /dev/null +++ b/api/views/site/error.php @@ -0,0 +1,27 @@ +title = $name; +?> +
+ +

title) ?>

+ +
+ +
+ +

+ The above error occurred while the Web server was processing your request. +

+

+ Please contact us if you think this is a server error. Thank you. +

+ +
diff --git a/api/web/.gitignore b/api/web/.gitignore new file mode 100644 index 0000000..ab89d98 --- /dev/null +++ b/api/web/.gitignore @@ -0,0 +1,5 @@ +/index.php +/index-test.php +/robots.txt +uploads + diff --git a/api/web/css/site.css b/api/web/css/site.css new file mode 100644 index 0000000..f787e34 --- /dev/null +++ b/api/web/css/site.css @@ -0,0 +1,120 @@ +html, +body { + height: 100%; +} + +.wrap { + min-height: 100%; + height: auto; + margin: 0 auto -60px; + padding: 0 0 60px; +} + +.wrap > .container { + padding: 70px 15px 20px; +} + +.footer { + height: 60px; + background-color: #f5f5f5; + border-top: 1px solid #ddd; + padding-top: 20px; +} + +.jumbotron { + text-align: center; + background-color: transparent; +} + +.jumbotron .btn { + font-size: 21px; + padding: 14px 24px; +} + +.not-set { + color: #c55; + font-style: italic; +} + +/* add sorting icons to gridview sort links */ +a.asc:after, a.desc:after { + position: relative; + top: 1px; + display: inline-block; + font-family: 'Glyphicons Halflings'; + font-style: normal; + font-weight: normal; + line-height: 1; + padding-left: 5px; +} + +a.asc:after { + content: /*"\e113"*/ "\e151"; +} + +a.desc:after { + content: /*"\e114"*/ "\e152"; +} + +.sort-numerical a.asc:after { + content: "\e153"; +} + +.sort-numerical a.desc:after { + content: "\e154"; +} + +.sort-ordinal a.asc:after { + content: "\e155"; +} + +.sort-ordinal a.desc:after { + content: "\e156"; +} + +.grid-view td { + white-space: nowrap; +} + +.grid-view .filters input, +.grid-view .filters select { + min-width: 50px; +} + +.hint-block { + display: block; + margin-top: 5px; + color: #999; +} + +.error-summary { + color: #a94442; + background: #fdf7f7; + border-left: 3px solid #eed3d7; + padding: 10px 20px; + margin: 0 0 15px 0; +} + +/* align the logout "link" (button in forms) of the navbar */ +.nav li > form > button.logout { + padding: 15px; + border: none; +} + +@media(max-width:767px) { + .nav li > form > button.logout { + display:block; + text-align: left; + width: 100%; + padding: 10px 15px; + } +} + +.nav > li > form > button.logout:focus, +.nav > li > form > button.logout:hover { + text-decoration: none; +} + +.nav > li > form > button.logout:focus { + outline: none; +} diff --git a/api/web/favicon.ico b/api/web/favicon.ico new file mode 100644 index 0000000..580ed73 Binary files /dev/null and b/api/web/favicon.ico differ diff --git a/backend/config/main.php b/backend/config/main.php index b7c309e..c2f2fc8 100644 --- a/backend/config/main.php +++ b/backend/config/main.php @@ -9,7 +9,11 @@ return [ 'basePath' => dirname(__DIR__), 'controllerNamespace' => 'backend\controllers', 'bootstrap' => ['log'], - 'modules' => [], + 'modules' => [ + 'antgoods' => [ + 'class' => 'antgoods\goods\Module', + ], + ], 'components' => [ 'request' => [ 'csrfParam' => '_csrf-backend', @@ -30,6 +34,16 @@ return [ 'class' => 'yii\log\FileTarget', 'levels' => ['error', 'warning'], ], + [ + 'class' => 'yii\log\FileTarget', + 'levels' => ['info', 'error'], + 'categories' => ['imagetest'], + 'logFile' => '@app/runtime/logs/imagetest.log', + 'logVars' => [], + 'exportInterval' => 1, + 'prefix' => function ($message) { + } + ], ], ], 'errorHandler' => [ @@ -41,6 +55,8 @@ return [ 'rules' => [ ], ], + 'file' => ['class' => 'backend\logic\file\FileManager'], + 'goods' => ['class' => 'antgoods\goods\logic\goods\GoodsManager'], ], 'as access' => [ 'class' => 'iron\components\AccessControl', diff --git a/backend/controllers/CategoryController.php b/backend/controllers/CategoryController.php deleted file mode 100644 index 4be79f8..0000000 --- a/backend/controllers/CategoryController.php +++ /dev/null @@ -1,149 +0,0 @@ - [ - 'class' => VerbFilter::className(), - 'actions' => [ - 'delete' => ['POST'], - ], - ], - ]; - } - - /** - * Lists all Category models. - * @return mixed - */ - public function actionIndex() - { - $searchModel = new CategorySearch(); - $dataProvider = $searchModel->search(Yii::$app->request->queryParams); - - return $this->render('index', [ - 'searchModel' => $searchModel, - 'dataProvider' => $dataProvider, - 'columns' => $searchModel->columns() - ]); - } - - /** - * Displays a single Category model. - * @param integer $id - * @return mixed - * @throws NotFoundHttpException if the model cannot be found - */ - public function actionView($id) - { - return $this->render('view', [ - 'model' => $this->findModel($id), - ]); - } - - /** - * Creates a new Category model. - * If creation is successful, the browser will be redirected to the 'view' page. - * @return mixed - */ - public function actionCreate() - { - $model = new Category(); - - if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect('index'); - } - - return $this->render('create', [ - 'model' => $model, - ]); - } - - /** - * Updates an existing Category model. - * If update is successful, the browser will be redirected to the 'view' page. - * @param integer $id - * @return mixed - * @throws NotFoundHttpException if the model cannot be found - */ - public function actionUpdate($id) - { - $model = $this->findModel($id); - - if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect('index'); - } - - return $this->render('update', [ - 'model' => $model, - ]); - } - - /** - * Deletes an existing Category model. - * If deletion is successful, the browser will be redirected to the 'index' page. - * @param integer $id - * @return mixed - * @throws NotFoundHttpException if the model cannot be found - */ - public function actionDelete($id) - { - $this->findModel($id)->delete(); - - return $this->redirect(['index']); - } - - /** - * Finds the Category model based on its primary key value. - * If the model is not found, a 404 HTTP exception will be thrown. - * @param integer $id - * @return Category the loaded model - * @throws NotFoundHttpException if the model cannot be found - */ - protected function findModel($id) - { - if (($model = Category::findOne($id)) !== null) { - return $model; - } - - throw new NotFoundHttpException('The requested page does not exist.'); - } - /** - * @author iron - * 文件导出 - */ - public function actionExport() - { - $searchModel = new CategorySearch(); - $params = Yii::$app->request->queryParams; - if ($params['page-type'] == 'all') { - $dataProvider = $searchModel->allData($params); - } else { - $dataProvider = $searchModel->search($params); - } - \iron\widget\Excel::export([ - 'models' => $dataProvider->getModels(), - 'format' => 'Xlsx', - 'asAttachment' => true, - 'fileName' =>'Categories'. "-" .date('Y-m-d H/i/s', time()), - 'columns' => $searchModel->columns() - ]); - } -} diff --git a/backend/controllers/ConfigController.php b/backend/controllers/ConfigController.php old mode 100644 new mode 100755 diff --git a/backend/controllers/GoodsController.php b/backend/controllers/GoodsController.php deleted file mode 100644 index 802be6e..0000000 --- a/backend/controllers/GoodsController.php +++ /dev/null @@ -1,151 +0,0 @@ - [ - 'class' => VerbFilter::className(), - 'actions' => [ - 'delete' => ['POST'], - ], - ], - ]; - } - - /** - * Lists all Goods models. - * @return mixed - */ - public function actionIndex() - { - $searchModel = new GoodsSearch(); - $dataProvider = $searchModel->search(Yii::$app->request->queryParams); - - return $this->render('index', [ - 'searchModel' => $searchModel, - 'dataProvider' => $dataProvider, - 'columns' => $searchModel->columns() - ]); - } - - /** - * Displays a single Goods model. - * @param integer $id - * @return mixed - * @throws NotFoundHttpException if the model cannot be found - */ - public function actionView($id) - { - return $this->render('view', [ - 'model' => $this->findModel($id), - ]); - } - - /** - * Creates a new Goods model. - * If creation is successful, the browser will be redirected to the 'view' page. - * @return mixed - */ - public function actionCreate() - { - $model = new Goods(); - - if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect('index'); - } - - return $this->render('create', [ - 'model' => $model, - ]); - } - - /** - * Updates an existing Goods model. - * If update is successful, the browser will be redirected to the 'view' page. - * @param integer $id - * @return mixed - * @throws NotFoundHttpException if the model cannot be found - */ - public function actionUpdate($id) - { - $model = $this->findModel($id); - - if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect('index'); - } - - return $this->render('update', [ - 'model' => $model, - ]); - } - - /** - * Deletes an existing Goods model. - * If deletion is successful, the browser will be redirected to the 'index' page. - * @param integer $id - * @return mixed - * @throws NotFoundHttpException if the model cannot be found - */ - public function actionDelete($id) - { - $this->findModel($id)->delete(); - - return $this->redirect(['index']); - } - - /** - * Finds the Goods model based on its primary key value. - * If the model is not found, a 404 HTTP exception will be thrown. - * @param integer $id - * @return Goods the loaded model - * @throws NotFoundHttpException if the model cannot be found - */ - protected function findModel($id) - { - if (($model = Goods::findOne($id)) !== null) { - return $model; - } - - throw new NotFoundHttpException('The requested page does not exist.'); - } - /** - * @author iron - * 文件导出 - */ - public function actionExport() - { - $searchModel = new GoodsSearch(); - $params = Yii::$app->request->queryParams; - if ($params['page-type'] == 'all') { - $dataProvider = $searchModel->allData($params); - } else { - $dataProvider = $searchModel->search($params); - } - \iron\widget\Excel::export([ - 'models' => $dataProvider->getModels(), - 'format' => 'Xlsx', - 'asAttachment' => true, - 'fileName' =>'Goods'. "-" .date('Y-m-d H/i/s', time()), - 'columns' => $searchModel->columns() - ]); - } -} diff --git a/backend/controllers/OrderController.php b/backend/controllers/OrderController.php old mode 100644 new mode 100755 diff --git a/backend/controllers/ShopCategoryController.php b/backend/controllers/ShopCategoryController.php deleted file mode 100644 index ad4e43e..0000000 --- a/backend/controllers/ShopCategoryController.php +++ /dev/null @@ -1,149 +0,0 @@ - [ - 'class' => VerbFilter::className(), - 'actions' => [ - 'delete' => ['POST'], - ], - ], - ]; - } - - /** - * Lists all ShopCategory models. - * @return mixed - */ - public function actionIndex() - { - $searchModel = new ShopCategorySearch(); - $dataProvider = $searchModel->search(Yii::$app->request->queryParams); - - return $this->render('index', [ - 'searchModel' => $searchModel, - 'dataProvider' => $dataProvider, - 'columns' => $searchModel->columns() - ]); - } - - /** - * Displays a single ShopCategory model. - * @param integer $id - * @return mixed - * @throws NotFoundHttpException if the model cannot be found - */ - public function actionView($id) - { - return $this->render('view', [ - 'model' => $this->findModel($id), - ]); - } - - /** - * Creates a new ShopCategory model. - * If creation is successful, the browser will be redirected to the 'view' page. - * @return mixed - */ - public function actionCreate() - { - $model = new ShopCategory(); - - if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect('index'); - } - - return $this->render('create', [ - 'model' => $model, - ]); - } - - /** - * Updates an existing ShopCategory model. - * If update is successful, the browser will be redirected to the 'view' page. - * @param integer $id - * @return mixed - * @throws NotFoundHttpException if the model cannot be found - */ - public function actionUpdate($id) - { - $model = $this->findModel($id); - - if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect('index'); - } - - return $this->render('update', [ - 'model' => $model, - ]); - } - - /** - * Deletes an existing ShopCategory model. - * If deletion is successful, the browser will be redirected to the 'index' page. - * @param integer $id - * @return mixed - * @throws NotFoundHttpException if the model cannot be found - */ - public function actionDelete($id) - { - $this->findModel($id)->delete(); - - return $this->redirect(['index']); - } - - /** - * Finds the ShopCategory model based on its primary key value. - * If the model is not found, a 404 HTTP exception will be thrown. - * @param integer $id - * @return ShopCategory the loaded model - * @throws NotFoundHttpException if the model cannot be found - */ - protected function findModel($id) - { - if (($model = ShopCategory::findOne($id)) !== null) { - return $model; - } - - throw new NotFoundHttpException('The requested page does not exist.'); - } - /** - * @author iron - * 文件导出 - */ - public function actionExport() - { - $searchModel = new ShopCategorySearch(); - $params = Yii::$app->request->queryParams; - if ($params['page-type'] == 'all') { - $dataProvider = $searchModel->allData($params); - } else { - $dataProvider = $searchModel->search($params); - } - \iron\widget\Excel::export([ - 'models' => $dataProvider->getModels(), - 'format' => 'Xlsx', - 'asAttachment' => true, - 'fileName' =>'Shop Categories'. "-" .date('Y-m-d H/i/s', time()), - 'columns' => $searchModel->columns() - ]); - } -} diff --git a/backend/controllers/SiteController.php b/backend/controllers/SiteController.php old mode 100644 new mode 100755 diff --git a/backend/logic/file/FileManager.php b/backend/logic/file/FileManager.php new file mode 100644 index 0000000..579096a --- /dev/null +++ b/backend/logic/file/FileManager.php @@ -0,0 +1,122 @@ + ['jpg', 'png', 'jpeg'], + self::TYPE_VIDEO => ['mp4'], + self::TYPE_EXCEL => [], + self::TYPE_WORD => ['docx'], + self::TYPE_TXT => ['txt'], + ]; + + /** + * @param $array + * @param $keyword + * @return bool|int|string + * 根据文件拓展名在$extension中查找对应的文件类型,若不存在则返回false + */ + public function searchType($array, $keyword) + { + foreach($array as $key => $value){ + foreach ($value as $k => $v) { + if($v == $keyword){ + return ['status' => true, 'info' => '操作成功', 'type' => $key]; + } + } + } + return ['status' => false, 'info' => '操作失败']; + } + + /** + * @param $imgIdStr + * @param $ownId + * @param $ownType + * @return array + * 根据临时文件id(字符串)将临时文件保存在文件中 + */ + public function saveTemFileToFile($temFIleIdArr, $ownId, $ownType) + { + if(!$temFIleIdArr || !$ownId) { + return ['status' => false, 'info' => '参数错误']; + } + + $i = 1; + $first_file_id = 0; + foreach ($temFIleIdArr as $key => $value) { + $tem_file = TemFile::findOne($value); + + if(!$tem_file) { + return ['status' => false, 'info' => '存在查找不到的文件']; + } + + $res = self::saveNewFile($tem_file, $ownId, $ownType); + if(!$res['status']) { + return ['status' => false, 'info' => '存在文件保存失败']; + } + if($i == 1) { + $first_file_id = $res['file_id']; + } + + $i++; + } + + return ['status' => true, 'info' => '保存成功', 'first_file_id' => $first_file_id]; + } + + /** + * @param $temFile + * @param $ownId + * @param $ownType + * @return bool + * 创建新的文件 + */ + private function saveNewFile($temFile, $ownId, $ownType) + { + $new_file = new File(); + $new_file->name = $temFile->name; + $new_file->type = $temFile->type; + $new_file->own_id = $ownId; + $new_file->own_type = $ownType; + $new_file->alias = $temFile->alias; + $new_file->path = $temFile->path; + if($new_file->save()) { + return ['status' => true, 'info' => '操作成功', 'file_id' => $new_file->id]; + } else { + return ['status' => false, 'info' => '操作失败']; + } + } + + /** + * @param $fileIdArr + * 删除file表中的文件 + */ + public function deleteFile($fileIdArr) + { + if($fileIdArr){ + foreach ($fileIdArr as $key => $value) { + $file_model = File::findOne($value); + if($file_model){ + $file_model->is_delete = File::IS_DELETE_YES; + if($file_model->save()){ + return ['status' => false, 'info' => '操作失败']; + } + } + } + } + return ['status' => true, 'info' => '操作成功']; + } +} \ No newline at end of file diff --git a/backend/views/brand/_search.php b/backend/views/brand/_search.php deleted file mode 100644 index 14a96ae..0000000 --- a/backend/views/brand/_search.php +++ /dev/null @@ -1,47 +0,0 @@ - - - ['index'], - 'method' => 'get', - 'validateOnType' => true, - ]); -?> -
-
- field($model, 'id', [ - "template" => "{input}{error}", - "inputOptions" => [ - "placeholder" => "检索ID", - "class" => "form-control", - ], - "errorOptions" => [ - "class" => "error-tips" - ] - ]) - ?> - field($model, "created_at_range", [ - "template" => "{input}{error}", - "inputOptions" => [ - "placeholder" => "创建时间", - ], - "errorOptions" => [ - "class" => "error-tips" - ] - ])->widget(DateRangePicker::className()); - ?> -
- ', ['class' => 'btn btn-default']) ?> - ', ['class' => 'btn btn-default']) ?> -
-
-
- \ No newline at end of file diff --git a/backend/views/category/_form.php b/backend/views/category/_form.php deleted file mode 100644 index 1ce3540..0000000 --- a/backend/views/category/_form.php +++ /dev/null @@ -1,38 +0,0 @@ - - -
- - - - field($model, 'name')->textInput(['maxlength' => true]) ?> - - field($model, 'pid')->textInput() ?> - - field($model, 'goods_count')->textInput() ?> - - field($model, 'sort_order')->textInput() ?> - - field($model, 'icon_type')->textInput() ?> - - field($model, 'icon')->textInput(['maxlength' => true]) ?> - - field($model, 'is_show')->textInput() ?> - - field($model, 'is_delete')->textInput() ?> - -
- 'btn btn-success']) ?> - 'btn btn-info']) ?> -
- - - -
diff --git a/backend/views/category/test.php b/backend/views/category/test.php deleted file mode 100644 index a2ec90b..0000000 --- a/backend/views/category/test.php +++ /dev/null @@ -1,98 +0,0 @@ - - -
- - - -
- -
-
-
Upload -
- -
-
- Drag & Drop Files
-
-
-
- - diff --git a/backend/views/config/index.php b/backend/views/config/index.php old mode 100644 new mode 100755 diff --git a/backend/views/goods/_form.php b/backend/views/goods/_form.php deleted file mode 100644 index 149e969..0000000 --- a/backend/views/goods/_form.php +++ /dev/null @@ -1,82 +0,0 @@ - - -
- - - - field($model, 'pid')->textInput() ?> - - field($model, 'cat_id')->textInput() ?> - - field($model, 'brand_id')->textInput() ?> - - field($model, 'shop_cat_id')->textInput() ?> - - field($model, 'name')->textInput(['maxlength' => true]) ?> - - field($model, 'sn')->textInput(['maxlength' => true]) ?> - - field($model, 'code')->textInput(['maxlength' => true]) ?> - - field($model, 'supplier_id')->textInput() ?> - - field($model, 'weight')->textInput() ?> - - field($model, 'length')->textInput() ?> - - field($model, 'width')->textInput() ?> - - field($model, 'height')->textInput() ?> - - field($model, 'diameter')->textInput() ?> - - field($model, 'unit')->textInput(['maxlength' => true]) ?> - - field($model, 'sold_count')->textInput() ?> - - field($model, 'limit_count')->textInput() ?> - - field($model, 'stock')->textInput() ?> - - field($model, 'stock_warn')->textInput() ?> - - field($model, 'market_price')->textInput() ?> - - field($model, 'price')->textInput() ?> - - field($model, 'brief')->textInput(['maxlength' => true]) ?> - - field($model, 'description')->textarea(['rows' => 6]) ?> - - field($model, 'image')->textInput() ?> - - field($model, 'model_id')->textInput() ?> - - field($model, 'is_sale')->textInput() ?> - - field($model, 'sort_order')->textInput() ?> - - field($model, 'bouns_points')->textInput() ?> - - field($model, 'experience_points')->textInput() ?> - - field($model, 'is_delete')->textInput() ?> - - field($model, 'express_template')->textInput() ?> - -
- 'btn btn-success']) ?> - 'btn btn-info']) ?> -
- - - -
diff --git a/backend/views/layouts/base.php b/backend/views/layouts/base.php old mode 100644 new mode 100755 diff --git a/backend/views/layouts/breadcrumb.php b/backend/views/layouts/breadcrumb.php old mode 100644 new mode 100755 diff --git a/backend/views/layouts/footer.php b/backend/views/layouts/footer.php old mode 100644 new mode 100755 diff --git a/backend/views/layouts/header.php b/backend/views/layouts/header.php old mode 100644 new mode 100755 diff --git a/backend/views/layouts/main.php b/backend/views/layouts/main.php old mode 100644 new mode 100755 diff --git a/backend/views/layouts/sidebar.php b/backend/views/layouts/sidebar.php deleted file mode 100644 index 189a29c..0000000 --- a/backend/views/layouts/sidebar.php +++ /dev/null @@ -1,19 +0,0 @@ - - \ No newline at end of file diff --git a/backend/views/order/_form.php b/backend/views/order/_form.php old mode 100644 new mode 100755 diff --git a/backend/views/order/_search.php b/backend/views/order/_search.php old mode 100644 new mode 100755 diff --git a/backend/views/order/create.php b/backend/views/order/create.php old mode 100644 new mode 100755 diff --git a/backend/views/order/index.php b/backend/views/order/index.php old mode 100644 new mode 100755 diff --git a/backend/views/order/update.php b/backend/views/order/update.php old mode 100644 new mode 100755 diff --git a/backend/views/order/view.php b/backend/views/order/view.php old mode 100644 new mode 100755 diff --git a/backend/views/shop-category/_form.php b/backend/views/shop-category/_form.php deleted file mode 100644 index 5f0949f..0000000 --- a/backend/views/shop-category/_form.php +++ /dev/null @@ -1,44 +0,0 @@ - - -
- - - - field($model, 'name')->textInput(['maxlength' => true]) ?> - - field($model, 'pid')->textInput() ?> - - field($model, 'goods_count')->textInput() ?> - - field($model, 'keywords')->textInput(['maxlength' => true]) ?> - - field($model, 'desc')->textInput(['maxlength' => true]) ?> - - field($model, 'sort_order')->textInput() ?> - - field($model, 'icon_type')->textInput() ?> - - field($model, 'icon')->textInput(['maxlength' => true]) ?> - - field($model, 'filter_attr')->textarea(['rows' => 6]) ?> - - field($model, 'is_show')->textInput() ?> - - field($model, 'is_delete')->textInput() ?> - -
- 'btn btn-success']) ?> - 'btn btn-info']) ?> -
- - - -
diff --git a/backend/views/site/error.php b/backend/views/site/error.php old mode 100644 new mode 100755 diff --git a/backend/views/site/index.php b/backend/views/site/index.php old mode 100644 new mode 100755 diff --git a/backend/views/site/login.php b/backend/views/site/login.php old mode 100644 new mode 100755 diff --git a/backend/views/site/test.php b/backend/views/site/test.php old mode 100644 new mode 100755 diff --git a/backend/views/supplier/_search.php b/backend/views/supplier/_search.php deleted file mode 100644 index f014a90..0000000 --- a/backend/views/supplier/_search.php +++ /dev/null @@ -1,47 +0,0 @@ - - - ['index'], - 'method' => 'get', - 'validateOnType' => true, - ]); -?> -
-
- field($model, 'id', [ - "template" => "{input}{error}", - "inputOptions" => [ - "placeholder" => "检索ID", - "class" => "form-control", - ], - "errorOptions" => [ - "class" => "error-tips" - ] - ]) - ?> - field($model, "created_at_range", [ - "template" => "{input}{error}", - "inputOptions" => [ - "placeholder" => "创建时间", - ], - "errorOptions" => [ - "class" => "error-tips" - ] - ])->widget(DateRangePicker::className()); - ?> -
- ', ['class' => 'btn btn-default']) ?> - ', ['class' => 'btn btn-default']) ?> -
-
-
- \ No newline at end of file diff --git a/backend/web/uploads/xls/15738696921690.jpg b/backend/web/uploads/xls/15738696921690.jpg deleted file mode 100644 index ca03e9a..0000000 Binary files a/backend/web/uploads/xls/15738696921690.jpg and /dev/null differ diff --git a/common/config/params.php b/common/config/params.php index dc231f0..b18cb95 100644 --- a/common/config/params.php +++ b/common/config/params.php @@ -5,21 +5,4 @@ return [ 'senderEmail' => 'noreply@example.com', 'senderName' => 'Example.com mailer', 'user.passwordResetTokenExpire' => 3600, - 'menus'=>[ - '商城管理' => [ - 'icon' => 'fa-store', - 'items' => [ - ['运营数据', '/site',], - ['基础配置', '/config'], - ], - ], - '商品管理' => [ - 'icon' => 'fa-archive', - 'items' => [ - ['商品分类', '/category'], - ['商品列表', '/goods'], - ['属性管理', '/attribute'], - ], - ] - ] ]; diff --git a/common/models/ars/Address.php b/common/models/ars/Address.php index b7b9ad9..aec13fb 100644 --- a/common/models/ars/Address.php +++ b/common/models/ars/Address.php @@ -36,6 +36,7 @@ class Address extends \yii\db\ActiveRecord public function rules() { return [ + [['user_id', 'consignee', 'phone', 'address'], 'required'], [['user_id', 'status'], 'integer'], [['address'], 'string'], [['consignee', 'phone'], 'string', 'max' => 20], @@ -62,6 +63,7 @@ class Address extends \yii\db\ActiveRecord 'updated_at' => '更新时间', ]; } + /** * @author linyao diff --git a/common/models/ars/AfterSale.php b/common/models/ars/AfterSale.php index 4f0cced..4cf35b1 100644 --- a/common/models/ars/AfterSale.php +++ b/common/models/ars/AfterSale.php @@ -42,6 +42,7 @@ class AfterSale extends \yii\db\ActiveRecord public function rules() { return [ + [['operator_id', 'user_id', 'amount'], 'required'], [['operator_id', 'user_id', 'order_goods_id', 'count', 'amount', 'type', 'reason', 'applyed_at', 'dealed_at', 'finished_at'], 'integer'], [['description', 'remarks'], 'string'], [['wx_refund_id', 'after_sale_sn'], 'string', 'max' => 64], @@ -74,5 +75,6 @@ class AfterSale extends \yii\db\ActiveRecord 'finished_at' => '完成时间', ]; } + } diff --git a/common/models/ars/Area.php b/common/models/ars/Area.php index e42ee4f..254681b 100644 --- a/common/models/ars/Area.php +++ b/common/models/ars/Area.php @@ -46,5 +46,6 @@ class Area extends \yii\db\ActiveRecord 'city_id' => 'city_id', ]; } + } diff --git a/common/models/ars/Cart.php b/common/models/ars/Cart.php index 3af30be..ef6477f 100644 --- a/common/models/ars/Cart.php +++ b/common/models/ars/Cart.php @@ -35,6 +35,7 @@ class Cart extends \yii\db\ActiveRecord public function rules() { return [ + [['user_id', 'goods_id', 'goods_name', 'sku_id'], 'required'], [['user_id', 'goods_id', 'goods_img', 'goods_price', 'sku_id', 'goods_count'], 'integer'], [['goods_name'], 'string', 'max' => 120], ]; @@ -58,6 +59,7 @@ class Cart extends \yii\db\ActiveRecord 'updated_at' => '更新时间', ]; } + /** * @author linyao diff --git a/common/models/ars/City.php b/common/models/ars/City.php index 3b4096f..ae87412 100644 --- a/common/models/ars/City.php +++ b/common/models/ars/City.php @@ -46,5 +46,6 @@ class City extends \yii\db\ActiveRecord 'province_id' => 'province_id', ]; } + } diff --git a/common/models/ars/Collection.php b/common/models/ars/Collection.php index 69937f3..2a1a771 100644 --- a/common/models/ars/Collection.php +++ b/common/models/ars/Collection.php @@ -30,6 +30,7 @@ class Collection extends \yii\db\ActiveRecord public function rules() { return [ + [['user_id', 'goods_id'], 'required'], [['user_id', 'goods_id'], 'integer'], ]; } @@ -47,6 +48,7 @@ class Collection extends \yii\db\ActiveRecord 'created_at' => '创建时间', ]; } + /** * @author linyao diff --git a/common/models/ars/Comment.php b/common/models/ars/Comment.php index 2fe43aa..2701ecf 100644 --- a/common/models/ars/Comment.php +++ b/common/models/ars/Comment.php @@ -33,6 +33,7 @@ class Comment extends \yii\db\ActiveRecord public function rules() { return [ + [['user_id'], 'required'], [['user_id', 'order_goods_id', 'star', 'status'], 'integer'], [['content'], 'string'], ]; @@ -54,6 +55,7 @@ class Comment extends \yii\db\ActiveRecord 'created_at' => '创建时间', ]; } + /** * @author linyao diff --git a/common/models/ars/Config.php b/common/models/ars/Config.php old mode 100644 new mode 100755 diff --git a/common/models/ars/Delivery.php b/common/models/ars/Delivery.php index e9760bd..85d1d0e 100644 --- a/common/models/ars/Delivery.php +++ b/common/models/ars/Delivery.php @@ -36,6 +36,7 @@ class Delivery extends \yii\db\ActiveRecord { return [ [['order_id', 'type', 'status'], 'integer'], + [['shipping_id'], 'required'], [['goods', 'decription'], 'string'], [['shipping_name'], 'string', 'max' => 50], [['shipping_id'], 'string', 'max' => 10], @@ -60,6 +61,7 @@ class Delivery extends \yii\db\ActiveRecord 'created_at' => '创建时间', ]; } + /** * @author linyao diff --git a/common/models/ars/ExpressTemplate.php b/common/models/ars/ExpressTemplate.php index d91b966..e3e6b81 100644 --- a/common/models/ars/ExpressTemplate.php +++ b/common/models/ars/ExpressTemplate.php @@ -40,6 +40,7 @@ class ExpressTemplate extends \yii\db\ActiveRecord public function rules() { return [ + [['name'], 'required'], [['province', 'city', 'area', 'taking_site'], 'string'], [['billing_type', 'extra_weight_type', 'exemption_type', 'basic_price', 'extra_price', 'exemption_amount', 'support_taking'], 'integer'], [['name'], 'string', 'max' => 255], @@ -69,6 +70,7 @@ class ExpressTemplate extends \yii\db\ActiveRecord 'created_at' => '创建时间', ]; } + /** * @author linyao diff --git a/common/models/ars/File.php b/common/models/ars/File.php index c58b34e..e75e597 100644 --- a/common/models/ars/File.php +++ b/common/models/ars/File.php @@ -22,6 +22,13 @@ use yii\behaviors\TimestampBehavior; */ class File extends \yii\db\ActiveRecord { + //own_type + const OWN_TYPE_GOODS_INDEX = 1;//商品首页 + const OWN_TYPE_GOODS_DETAILS = 2;//商品详情 + const OWN_TYPE_CATEGORY_ICON = 3;//类目图标 + //is_delete + const IS_DELETE_YES = 1;//已删除 + const IS_DELETE_NO = 0;//未删除 /** * {@inheritdoc} */ @@ -61,6 +68,7 @@ class File extends \yii\db\ActiveRecord 'created_at' => '创建时间', ]; } + /** * @author linyao diff --git a/common/models/ars/Order.php b/common/models/ars/Order.php index c74f2b0..6f03a52 100644 --- a/common/models/ars/Order.php +++ b/common/models/ars/Order.php @@ -51,6 +51,7 @@ class Order extends \yii\db\ActiveRecord public function rules() { return [ + [['user_id'], 'required'], [['user_id', 'status', 'type', 'goods_count', 'goods_amount', 'shipping_amount', 'shipping_type', 'taking_site', 'pay_type', 'pay_at', 'payment_amount', 'receivables', 'discount_amount'], 'integer'], [['discount_decription'], 'string'], [['order_sn', 'invoice_id'], 'string', 'max' => 64], @@ -95,6 +96,7 @@ class Order extends \yii\db\ActiveRecord 'created_at' => '创建时间', ]; } + /** * @author linyao diff --git a/common/models/ars/OrderGoods.php b/common/models/ars/OrderGoods.php index f98ceea..fa4d65d 100644 --- a/common/models/ars/OrderGoods.php +++ b/common/models/ars/OrderGoods.php @@ -36,6 +36,7 @@ class OrderGoods extends \yii\db\ActiveRecord public function rules() { return [ + [['order_id', 'goods_id'], 'required'], [['order_id', 'goods_id', 'goods_img', 'goods_count', 'price', 'market_price'], 'integer'], [['goods_name', 'sku_value'], 'string', 'max' => 120], ]; @@ -60,6 +61,7 @@ class OrderGoods extends \yii\db\ActiveRecord 'created_at' => '创建时间', ]; } + /** * @author linyao diff --git a/common/models/ars/PaymentLog.php b/common/models/ars/PaymentLog.php index ad85810..9055f33 100644 --- a/common/models/ars/PaymentLog.php +++ b/common/models/ars/PaymentLog.php @@ -60,6 +60,7 @@ class PaymentLog extends \yii\db\ActiveRecord 'created_at' => '创建时间', ]; } + /** * @author linyao diff --git a/common/models/ars/Province.php b/common/models/ars/Province.php index 26506c4..b03ffe6 100644 --- a/common/models/ars/Province.php +++ b/common/models/ars/Province.php @@ -44,5 +44,6 @@ class Province extends \yii\db\ActiveRecord 'province_id' => 'province_id', ]; } + } diff --git a/common/models/ars/RefundLog.php b/common/models/ars/RefundLog.php index 9f281b8..33ed965 100644 --- a/common/models/ars/RefundLog.php +++ b/common/models/ars/RefundLog.php @@ -66,5 +66,6 @@ class RefundLog extends \yii\db\ActiveRecord 'finished_at' => '完成时间', ]; } + } diff --git a/common/models/ars/SearchHistory.php b/common/models/ars/SearchHistory.php index 6be7b5f..17fc86c 100644 --- a/common/models/ars/SearchHistory.php +++ b/common/models/ars/SearchHistory.php @@ -33,6 +33,7 @@ class SearchHistory extends \yii\db\ActiveRecord public function rules() { return [ + [['user_id'], 'required'], [['user_id', 'count', 'status', 'type'], 'integer'], [['keyword'], 'string', 'max' => 255], ]; @@ -54,6 +55,7 @@ class SearchHistory extends \yii\db\ActiveRecord 'created_at' => '创建时间', ]; } + /** * @author linyao diff --git a/common/models/ars/TakingSite.php b/common/models/ars/TakingSite.php index f147e62..cbd36bd 100644 --- a/common/models/ars/TakingSite.php +++ b/common/models/ars/TakingSite.php @@ -34,6 +34,7 @@ class TakingSite extends \yii\db\ActiveRecord public function rules() { return [ + [['name'], 'required'], [['address'], 'string'], [['is_default'], 'integer'], [['name'], 'string', 'max' => 120], @@ -58,6 +59,7 @@ class TakingSite extends \yii\db\ActiveRecord 'created_at' => '创建时间', ]; } + /** * @author linyao diff --git a/common/models/ars/TemFile.php b/common/models/ars/TemFile.php index df9bab0..450f34c 100644 --- a/common/models/ars/TemFile.php +++ b/common/models/ars/TemFile.php @@ -19,6 +19,7 @@ use yii\behaviors\TimestampBehavior; */ class TemFile extends \yii\db\ActiveRecord { + /** * {@inheritdoc} */ @@ -55,6 +56,7 @@ class TemFile extends \yii\db\ActiveRecord 'created_at' => '创建时间', ]; } + /** * @author linyao diff --git a/common/models/searchs/OrderSearch.php b/common/models/searchs/OrderSearch.php old mode 100644 new mode 100755 diff --git a/composer.json b/composer.json index caebd31..0bcb78f 100755 --- a/composer.json +++ b/composer.json @@ -36,5 +36,10 @@ "yiisoft/yii2-debug": "^2.0@dev", "kint-php/kint": "dev-master", "yiisoft/yii2-gii": "^2.0@dev" + }, + "autoload": { + "psr-4": { + "antgoods\\goods\\": "vendor/antgoods/goods/src" + } } } diff --git a/console/controllers/InitController.php b/console/controllers/InitController.php index d0ee181..bb51368 100644 --- a/console/controllers/InitController.php +++ b/console/controllers/InitController.php @@ -63,7 +63,7 @@ class InitController extends Controller { * TODO没有完善 * 清空数据库 */ - public function clearDb() { + public function actionClearDb() { Yii::$app->db->createCommand("SET FOREIGN_KEY_CHECKS = 0;")->execute(); $dbname = explode('=', explode(';', Yii::$app->db->dsn)[1])[1]; $sql = "SELECT CONCAT('drop table ',table_name,';') FROM information_schema.`TABLES` WHERE table_schema='{$dbname}';"; diff --git a/console/migrations/m130524_201442_init.php b/console/migrations/m130524_201442_init.php old mode 100644 new mode 100755 diff --git a/console/migrations/m140506_102106_rbac_init.php b/console/migrations/m140506_102106_rbac_init.php old mode 100644 new mode 100755 diff --git a/console/migrations/m170907_052038_rbac_add_index_on_auth_assignment_user_id.php b/console/migrations/m170907_052038_rbac_add_index_on_auth_assignment_user_id.php old mode 100644 new mode 100755 diff --git a/console/migrations/m180523_151638_rbac_updates_indexes_without_prefix.php b/console/migrations/m180523_151638_rbac_updates_indexes_without_prefix.php old mode 100644 new mode 100755 diff --git a/console/migrations/m190124_110200_add_verification_token_column_to_user_table.php b/console/migrations/m190124_110200_add_verification_token_column_to_user_table.php old mode 100644 new mode 100755 diff --git a/console/migrations/m190802_072830_add_category.php b/console/migrations/m190802_072830_add_category.php old mode 100644 new mode 100755 diff --git a/console/migrations/m191111_101658_create_table_area.php b/console/migrations/m191111_101658_create_table_area.php old mode 100644 new mode 100755 diff --git a/console/migrations/m191111_102644_create_table_province.php b/console/migrations/m191111_102644_create_table_province.php old mode 100644 new mode 100755 diff --git a/console/migrations/m191111_102730_create_table_city.php b/console/migrations/m191111_102730_create_table_city.php old mode 100644 new mode 100755 diff --git a/console/migrations/m191111_102925_create_table_cart.php b/console/migrations/m191111_102925_create_table_cart.php old mode 100644 new mode 100755 index 5c81c47..bea2e27 --- a/console/migrations/m191111_102925_create_table_cart.php +++ b/console/migrations/m191111_102925_create_table_cart.php @@ -15,12 +15,12 @@ class m191111_102925_create_table_cart extends Migration $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="购物车表"'; $this->createTable('ats_cart', [ 'id' => $this->primaryKey(), - 'user_id'=>$this->integer(11)->defaultValue(null)->comment('用户id'), - 'goods_id'=>$this->integer(11)->defaultValue(null)->comment('商品id'), - 'goods_name'=>$this->string(120)->defaultValue(null)->comment('商品名称'), + 'user_id'=>$this->integer(11)->notNull()->comment('用户id'), + 'goods_id'=>$this->integer(11)->notNull()->comment('商品id'), + 'goods_name'=>$this->string(120)->notNull()->comment('商品名称'), 'goods_img'=>$this->integer(11)->defaultValue(null)->comment('商品图片'), 'goods_price'=>$this->integer(20)->defaultValue(null)->comment('商品售价'), - 'sku_id'=>$this->integer(11)->defaultValue(null)->comment('商品sku的id'), + 'sku_id'=>$this->integer(11)->notNull()->comment('商品sku的id'), 'goods_count'=>$this->integer(11)->defaultValue(null)->comment('商品数量'), 'created_at'=>$this->integer(11)->defaultValue(null)->comment('创建时间'), 'updated_at'=>$this->integer(11)->defaultValue(null)->comment('更新时间'), diff --git a/console/migrations/m191111_112559_create_table_address.php b/console/migrations/m191111_112559_create_table_address.php old mode 100644 new mode 100755 index 2882b5c..ab94279 --- a/console/migrations/m191111_112559_create_table_address.php +++ b/console/migrations/m191111_112559_create_table_address.php @@ -15,13 +15,13 @@ class m191111_112559_create_table_address extends Migration $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="地址表"'; $this->createTable('ats_address', [ 'id' => $this->primaryKey(), - 'user_id'=>$this->integer(11)->defaultValue(null)->comment('用户id'), - 'consignee'=>$this->string(20)->defaultValue(null)->comment('收件人'), - 'phone'=>$this->string(20)->defaultValue(null)->comment('电话'), + 'user_id'=>$this->integer(11)->notNull()->comment('用户id'), + 'consignee'=>$this->string(20)->notNull()->comment('收件人'), + 'phone'=>$this->string(20)->notNull()->comment('电话'), 'province'=>$this->string(10)->defaultValue(null)->comment('省份'), 'city'=>$this->string(10)->defaultValue(null)->comment('城市'), 'area'=>$this->string(10)->defaultValue(null)->comment('区域'), - 'address'=>$this->text()->comment('详细地址'), + 'address'=>$this->text()->notNull()->comment('详细地址'), 'status'=>$this->tinyInteger(1)->defaultValue(0)->comment('状态,0-默认值 1-默认地址'), 'created_at'=>$this->integer(11)->defaultValue(null)->comment('创建时间'), 'updated_at'=>$this->integer(11)->defaultValue(null)->comment('更新时间'), diff --git a/console/migrations/m191111_113455_create_table_after_sale.php b/console/migrations/m191111_113455_create_table_after_sale.php old mode 100644 new mode 100755 index fde56b1..56a71ae --- a/console/migrations/m191111_113455_create_table_after_sale.php +++ b/console/migrations/m191111_113455_create_table_after_sale.php @@ -15,13 +15,13 @@ class m191111_113455_create_table_after_sale extends Migration $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="售后表"'; $this->createTable('ats_after_sale', [ 'id' => $this->primaryKey(), - 'operator_id'=>$this->integer(11)->defaultValue(null)->comment('操作者'), - 'user_id'=>$this->integer(11)->defaultValue(null)->comment('用户id'), + 'operator_id'=>$this->integer(11)->notNull()->comment('操作者'), + 'user_id'=>$this->integer(11)->notNull()->comment('用户id'), 'wx_refund_id'=>$this->string(64)->defaultValue(null)->comment('微信退款单号'), 'after_sale_sn'=>$this->string(64)->defaultValue(null)->comment('售后单号'), 'order_goods_id'=>$this->integer(11)->defaultValue(null)->comment('订单商品id'), 'count'=>$this->integer(11)->defaultValue(null)->comment('退换货的商品数量'), - 'amount'=>$this->integer(20)->defaultValue(null)->comment('退货时实际退的金额'), + 'amount'=>$this->integer(20)->notNull()->comment('退货时实际退的金额'), 'type'=>$this->tinyInteger(1)->defaultValue(0)->comment('类型'), 'reason'=>$this->smallInteger(2)->defaultValue(0)->comment('退换货理由'), 'description'=>$this->text()->comment('描述'), diff --git a/console/migrations/m191112_005106_create_table_search_history.php b/console/migrations/m191112_005106_create_table_search_history.php old mode 100644 new mode 100755 index e54e8ba..54736ec --- a/console/migrations/m191112_005106_create_table_search_history.php +++ b/console/migrations/m191112_005106_create_table_search_history.php @@ -15,7 +15,7 @@ class m191112_005106_create_table_search_history extends Migration $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="搜索记录表"'; $this->createTable('ats_search_history', [ 'id' => $this->primaryKey(), - 'user_id'=>$this->integer(11)->defaultValue(null)->comment('用户id'), + 'user_id'=>$this->integer(11)->notNull()->comment('用户id'), 'keyword'=>$this->string(255)->defaultValue(null)->comment('关键字'), 'count'=>$this->integer(10)->defaultValue(null)->comment('次数'), 'status'=>$this->tinyInteger(1)->defaultValue(0)->comment('状态'), diff --git a/console/migrations/m191112_005545_create_table_collection.php b/console/migrations/m191112_005545_create_table_collection.php old mode 100644 new mode 100755 index 13492eb..e4fb1e7 --- a/console/migrations/m191112_005545_create_table_collection.php +++ b/console/migrations/m191112_005545_create_table_collection.php @@ -15,8 +15,8 @@ class m191112_005545_create_table_collection extends Migration $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="收藏表"'; $this->createTable('ats_collection', [ 'id' => $this->primaryKey(), - 'user_id'=>$this->integer(11)->defaultValue(null)->comment('用户id'), - 'goods_id'=>$this->integer(11)->defaultValue(null)->comment('商品id'), + 'user_id'=>$this->integer(11)->notNull()->comment('用户id'), + 'goods_id'=>$this->integer(11)->notNull()->comment('商品id'), 'updated_at'=>$this->integer(11)->defaultValue(null)->comment('更新时间'), 'created_at'=>$this->integer(11)->defaultValue(null)->comment('创建时间'), ],$tableOptions); diff --git a/console/migrations/m191112_005702_create_table_comment.php b/console/migrations/m191112_005702_create_table_comment.php old mode 100644 new mode 100755 index f3a1ddd..1fa7e2b --- a/console/migrations/m191112_005702_create_table_comment.php +++ b/console/migrations/m191112_005702_create_table_comment.php @@ -15,7 +15,7 @@ class m191112_005702_create_table_comment extends Migration $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="评论记录表"'; $this->createTable('ats_comment', [ 'id' => $this->primaryKey(), - 'user_id'=>$this->integer(11)->defaultValue(null)->comment('用户id'), + 'user_id'=>$this->integer(11)->notNull()->comment('用户id'), 'order_goods_id'=>$this->integer(11)->defaultValue(null)->comment('订单详情商品id'), 'star'=>$this->integer(11)->defaultValue(null)->comment('星级'), 'content'=>$this->text()->comment('评论内容'), diff --git a/console/migrations/m191112_010421_create_table_order.php b/console/migrations/m191112_010421_create_table_order.php old mode 100644 new mode 100755 index dfd6a01..6bcfb06 --- a/console/migrations/m191112_010421_create_table_order.php +++ b/console/migrations/m191112_010421_create_table_order.php @@ -15,7 +15,7 @@ class m191112_010421_create_table_order extends Migration $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="订单表"'; $this->createTable('ats_order', [ 'id' => $this->primaryKey(), - 'user_id'=>$this->integer(11)->defaultValue(null)->comment('用户id'), + 'user_id'=>$this->integer(11)->notNull()->comment('用户id'), 'order_sn'=>$this->string(64)->defaultValue(null)->comment('订单号'), 'invoice_id'=>$this->string(64)->defaultValue(null)->comment('发票单号'), 'status'=>$this->tinyInteger(2)->defaultValue(0)->comment('状态'), diff --git a/console/migrations/m191112_011517_create_table_order_goods.php b/console/migrations/m191112_011517_create_table_order_goods.php old mode 100644 new mode 100755 index 52974d1..3340d25 --- a/console/migrations/m191112_011517_create_table_order_goods.php +++ b/console/migrations/m191112_011517_create_table_order_goods.php @@ -15,8 +15,8 @@ class m191112_011517_create_table_order_goods extends Migration $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="订单商品表"'; $this->createTable('ats_order_goods', [ 'id' => $this->primaryKey(), - 'order_id'=>$this->integer(11)->defaultValue(null)->comment('订单id'), - 'goods_id'=>$this->integer(11)->defaultValue(null)->comment('商品id'), + 'order_id'=>$this->integer(11)->notNull()->comment('订单id'), + 'goods_id'=>$this->integer(11)->notNull()->comment('商品id'), 'goods_img'=>$this->integer(11)->defaultValue(null)->comment('商品图片'), 'goods_name'=>$this->string(120)->defaultValue(null)->comment('商品名称'), 'goods_count'=>$this->integer(11)->defaultValue(null)->comment('商品数量'), diff --git a/console/migrations/m191112_012449_create_table_taking_site.php b/console/migrations/m191112_012449_create_table_taking_site.php old mode 100644 new mode 100755 index a9bc8e8..a03c9a6 --- a/console/migrations/m191112_012449_create_table_taking_site.php +++ b/console/migrations/m191112_012449_create_table_taking_site.php @@ -15,7 +15,7 @@ class m191112_012449_create_table_taking_site extends Migration $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="自提地点表"'; $this->createTable('ats_taking_site', [ 'id' => $this->primaryKey(), - 'name'=>$this->string(120)->defaultValue(null)->comment('名称'), + 'name'=>$this->string(120)->notNull()->comment('名称'), 'province'=>$this->string(10)->defaultValue(null)->comment('省份'), 'city'=>$this->string(10)->defaultValue(null)->comment('城市'), 'area'=>$this->string(10)->defaultValue(null)->comment('区域'), diff --git a/console/migrations/m191112_014508_create_table_express_template.php b/console/migrations/m191112_014508_create_table_express_template.php old mode 100644 new mode 100755 index 83a1165..4b788a5 --- a/console/migrations/m191112_014508_create_table_express_template.php +++ b/console/migrations/m191112_014508_create_table_express_template.php @@ -15,7 +15,7 @@ class m191112_014508_create_table_express_template extends Migration $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="配送情况设置表"'; $this->createTable('ats_express_template', [ 'id' => $this->primaryKey(), - 'name'=>$this->string(255)->defaultValue(null)->comment('名称'), + 'name'=>$this->string(255)->notNull()->comment('名称'), 'province'=>$this->text()->comment('省份'), 'city'=>$this->text()->comment('城市'), 'area'=>$this->text()->comment('区域'), diff --git a/console/migrations/m191112_015939_create_table_delivery.php b/console/migrations/m191112_015939_create_table_delivery.php old mode 100644 new mode 100755 index 92cd994..c90f0a1 --- a/console/migrations/m191112_015939_create_table_delivery.php +++ b/console/migrations/m191112_015939_create_table_delivery.php @@ -17,7 +17,7 @@ class m191112_015939_create_table_delivery extends Migration 'id' => $this->primaryKey(), 'order_id'=>$this->integer(11)->defaultValue(null)->comment('订单id'), 'shipping_name'=>$this->string(50)->defaultValue(null)->comment('货流名称'), - 'shipping_id'=>$this->string(10)->defaultValue(null)->comment('运货单位'), + 'shipping_id'=>$this->string(10)->notNull()->comment('运货单位'), 'type'=>$this->tinyInteger(1)->defaultValue(0)->comment('类型'), 'goods'=>$this->text()->comment('商品'), 'status'=>$this->tinyInteger(1)->defaultValue(0)->comment('状态'), diff --git a/console/migrations/m191112_020830_create_table_payment_log.php b/console/migrations/m191112_020830_create_table_payment_log.php old mode 100644 new mode 100755 diff --git a/console/migrations/m191112_021528_create_table_refund_log.php b/console/migrations/m191112_021528_create_table_refund_log.php old mode 100644 new mode 100755 diff --git a/console/migrations/m191112_022131_create_table_file.php b/console/migrations/m191112_022131_create_table_file.php old mode 100644 new mode 100755 diff --git a/console/migrations/m191112_022532_create_table_tem_file.php b/console/migrations/m191112_022532_create_table_tem_file.php old mode 100644 new mode 100755 diff --git a/console/migrations/schema-mysql.sql b/console/migrations/schema-mysql.sql old mode 100644 new mode 100755 diff --git a/console/migrations/sql/add_category.sql b/console/migrations/sql/add_category.sql old mode 100644 new mode 100755 diff --git a/console/migrations/sql/area.sql b/console/migrations/sql/area.sql old mode 100644 new mode 100755 diff --git a/console/migrations/sql/city.sql b/console/migrations/sql/city.sql old mode 100644 new mode 100755 diff --git a/console/migrations/sql/province.sql b/console/migrations/sql/province.sql old mode 100644 new mode 100755 diff --git a/datadictionary.md b/datadictionary.md deleted file mode 100644 index e69de29..0000000 diff --git a/environments/skeleton/backend/config/main-local.php b/environments/skeleton/backend/config/main-local.php old mode 100644 new mode 100755 index ddff7d3..51a12b2 --- a/environments/skeleton/backend/config/main-local.php +++ b/environments/skeleton/backend/config/main-local.php @@ -22,16 +22,16 @@ if (!YII_ENV_TEST) { 'allowedIPs' => ['127.0.0.1'], 'generators' => [ 'crud' => [ - 'class' => 'blobt\generators\crud\Generator', + 'class' => 'iron\generators\crud\Generator', 'templates' => [ 'blobtCrud' => '@blobt/generators/crud/default', - 'linyaoCrud' => '@linyao/generators/crud/default', + 'ironCrud' => '@iron/generators/crud/default', ] ], 'model' => [ - 'class' => 'linyao\generators\model\Generator', + 'class' => 'iron\generators\model\Generator', 'templates' => [ - 'linyaoModel' => '@linyao/generators/model/default', + 'ironModel' => '@iron/generators/model/default', ] ] ], diff --git a/environments/skeleton/backend/config/params-local.php b/environments/skeleton/backend/config/params-local.php old mode 100644 new mode 100755 diff --git a/vendor/antgoods/goods/AutoloadExample.php b/vendor/antgoods/goods/AutoloadExample.php new file mode 100644 index 0000000..1f3b005 --- /dev/null +++ b/vendor/antgoods/goods/AutoloadExample.php @@ -0,0 +1,14 @@ +``` \ No newline at end of file diff --git a/vendor/antgoods/goods/composer.json b/vendor/antgoods/goods/composer.json new file mode 100644 index 0000000..3b16d84 --- /dev/null +++ b/vendor/antgoods/goods/composer.json @@ -0,0 +1,21 @@ +{ + "name": "antgoods/goods", + "description": "ant基础模块之一", + "type": "yii2-extension", + "keywords": ["goods"], + "license": "MIT", + "authors": [ + { + "name": "linyao", + "email": "linyaostalker@gmail.com" + } + ], + "require": { + "yiisoft/yii2": "~2.0.0" + }, + "autoload": { + "psr-4": { + "antgoods\\goods\\": "" + } + } +} diff --git a/vendor/antgoods/goods/src/Module.php b/vendor/antgoods/goods/src/Module.php new file mode 100755 index 0000000..5c2b482 --- /dev/null +++ b/vendor/antgoods/goods/src/Module.php @@ -0,0 +1,28 @@ + $searchModel, 'dataProvider' => $dataProvider, 'columns' => $searchModel->columns() - ]); + ]); } /** @@ -126,25 +125,24 @@ class AttributeController extends Controller throw new NotFoundHttpException('The requested page does not exist.'); } - /** - * @author iron - * 文件导出 - */ + * @author iron + * 文件导出 + */ public function actionExport() { - $searchModel = new attributeSearch(); + $searchModel = new AttributeSearch(); $params = Yii::$app->request->queryParams; if ($params['page-type'] == 'all') { - $dataProvider = $searchModel->allData($params); + $dataProvider = $searchModel->allData($params); } else { $dataProvider = $searchModel->search($params); } - \iron\widget\Excel::export([ + \iron\widget\Excel::export([ 'models' => $dataProvider->getModels(), 'format' => 'Xlsx', 'asAttachment' => true, - 'fileName' => 'Attributes' . "-" . date('Y-m-d H/i/s', time()), + 'fileName' =>'Attributes'. "-" .date('Y-m-d H/i/s', time()), 'columns' => $searchModel->columns() ]); } diff --git a/backend/controllers/BrandController.php b/vendor/antgoods/goods/src/controllers/BrandController.php similarity index 96% rename from backend/controllers/BrandController.php rename to vendor/antgoods/goods/src/controllers/BrandController.php index 0dd6523..35e5f83 100644 --- a/backend/controllers/BrandController.php +++ b/vendor/antgoods/goods/src/controllers/BrandController.php @@ -1,10 +1,10 @@ [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ]; + } + + public function actions() + { + return [ + 'upload' => [ + 'class' => 'iron\actions\UploadAction', + 'path' => 'xls/', + 'maxSize' => 20480, + ] + ]; + } + + /** + * Lists all Category models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new CategorySearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + 'columns' => $searchModel->columns() + ]); + } + + /** + * Displays a single Category model. + * @param integer $id + * @return mixed + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Category model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Category(); + + if ($model->load(Yii::$app->request->post())) { + + //类目图片上传保存处理 + $icon_image_id_str = $model->iconImageId; + $model->save(); + $goods_manager = new GoodsManager(); + $save_icon_image_res = $goods_manager->saveFile(explode(',', $icon_image_id_str), $model, [], File::OWN_TYPE_CATEGORY_ICON); + if($save_icon_image_res['status']){ + $model->icon = $save_icon_image_res['first_file_id']; + $model->save(); + } + + return $this->redirect('index'); + } + + return $this->render('create', [ + 'model' => $model, + ]); + } + + /** + * Updates an existing Category model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + $model->iconImageId = $model->icon; + //记录已保存的类目图片id,用于修改 + $icon_image_old_id_arr = $model->icon; + + if ($model->load(Yii::$app->request->post())) { + + //类目图片上传保存处理 + $icon_image_id_str = $model->iconImageId; + $model->save(); + $goods_manager = new GoodsManager(); + $save_icon_image_res = $goods_manager->saveFile(explode(',', $icon_image_id_str), $model, explode(',', $icon_image_old_id_arr), File::OWN_TYPE_CATEGORY_ICON); + if($save_icon_image_res['status'] && $save_icon_image_res['first_file_id'] !== 0){ + $model->icon = $save_icon_image_res['first_file_id']; + $model->save(); + } + + return $this->redirect('index'); + } + + return $this->render('update', [ + 'model' => $model, + ]); + } + + /** + * Deletes an existing Category model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionDelete($id) + { + $model = $this->findModel($id); + + $model->is_delete = Category::IS_DELETE_YES; + $model->save(); + + return $this->redirect(['index']); + } + + /** + * Finds the Category model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Category the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Category::findOne($id)) !== null) { + return $model; + } + + throw new NotFoundHttpException('The requested page does not exist.'); + } + /** + * @author iron + * 文件导出 + */ + public function actionExport() + { + $searchModel = new CategorySearch(); + $params = Yii::$app->request->queryParams; + if ($params['page-type'] == 'all') { + $dataProvider = $searchModel->allData($params); + } else { + $dataProvider = $searchModel->search($params); + } + \iron\widget\Excel::export([ + 'models' => $dataProvider->getModels(), + 'format' => 'Xlsx', + 'asAttachment' => true, + 'fileName' =>'Categories'. "-" .date('Y-m-d H/i/s', time()), + 'columns' => $searchModel->columns() + ]); + } + + /** + * 处理文件上传成功后回调保存到临时文件表中,并返回临时文件id + */ + public function actionSaveFile() + { + if(!class_exists('\common\models\ars\TemFile') || !class_exists('\backend\logic\file\FileManager')){ + return ''; + } + + $data = Yii::$app->request->get('data'); + $file_name = Yii::$app->request->get('fileName')[0]; + + if ($data['status'] == true) { + $model = new \common\models\ars\TemFile(); + $model->user_id = Yii::$app->user->identity->id; + $model->name = $file_name; + $file_manager = new \backend\logic\file\FileManager(); + $type_res = $file_manager->searchType(\backend\logic\file\FileManager::$extension, pathinfo($data['path'])['extension']); + if ($type_res['status']) { + $model->type = $type_res['type']; + } + $model->alias = $data['alias']; + $model->path = $data['path']; + $model->save(); + return $model->id; + } + } + + /** + * @return string + * 点击删除按钮时同时删除字符串中的id + */ + public function actionImgIdDel() + { + //判断该类是否存在 + if(!class_exists('\common\models\ars\TemFile') || !class_exists('\common\models\ars\File')){ + return ''; + } + + $img_id = Yii::$app->request->get('imgid'); + $img_id_arr = explode(',', $img_id); + if(isset(Yii::$app->request->get('data')['alias'])) { + $alias = Yii::$app->request->get('data')['alias']; + $tem_file = \common\models\ars\TemFile::findOne(['alias' => $alias]); + if ($tem_file) { + $img_id_arr = array_diff($img_id_arr, [$tem_file->id]); + } + }else{ + foreach (Yii::$app->request->get() as $key => $value) { + $tem_file = \common\models\ars\File::findOne(['alias' => $value]); + if ($tem_file) { + $img_id_arr = array_diff($img_id_arr, [$tem_file->id]); + } + } + } + $img_id_str = implode(',', $img_id_arr); + return $img_id_str; + } + + /** + * @return bool|false|string + * 加载已有的文件 + */ + public function actionImageFile() + { + //判断该类是否存在 + if(!class_exists('\common\models\ars\File')){ + return false; + } + + $file_id_str = Yii::$app->request->get('fileidstr'); + $file_id_arr = explode(',', $file_id_str); + $data = \common\models\ars\File::find()->where(['id' => $file_id_arr])->all(); + $res = array(); + if($data) { + $i = 0; + foreach ($data as $key => $value) { + $res[$i]['name'] = $value->alias; + $res[$i]['path'] = Yii::$app->request->hostInfo . '/' . $value->path; + $res[$i]['size'] = filesize($value->path); + $i++; + } + } + return json_encode($res); + } +} diff --git a/vendor/antgoods/goods/src/controllers/GoodsController.php b/vendor/antgoods/goods/src/controllers/GoodsController.php new file mode 100644 index 0000000..eaca006 --- /dev/null +++ b/vendor/antgoods/goods/src/controllers/GoodsController.php @@ -0,0 +1,282 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ]; + } + + public function actions() + { + return [ + 'upload' => [ + 'class' => 'iron\actions\UploadAction', + 'path' => 'xls/', + 'maxSize' => 20480, + ] + ]; + } + + /** + * Lists all Goods models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new GoodsSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + 'columns' => $searchModel->columns() + ]); + } + + /** + * Displays a single Goods model. + * @param integer $id + * @return mixed + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Goods model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Goods(); + + if ($model->load(Yii::$app->request->post())) { + + //商品封面图和商品详情图上传保存处理 + $cover_image_id_str = $model->coverImageId; + $detail_image_id_str = $model->detailImageId; + $model->save(); + $goods_manager = new GoodsManager(); + $save_cover_image_res = $goods_manager->saveFile(explode(',', $cover_image_id_str), $model); + $save_detail_image_res = $goods_manager->saveFile(explode(',', $detail_image_id_str), $model, [], File::OWN_TYPE_GOODS_DETAILS); + if($save_cover_image_res['status'] && $save_detail_image_res['status']){ + $model->image = $save_cover_image_res['first_file_id']; + $model->save(); + } + + return $this->redirect('index'); + } + + return $this->render('create', [ + 'model' => $model, + ]); + } + + /** + * Updates an existing Goods model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + $model->coverImageId = $model->image; + $model->detailImageId = implode(',', File::find()->select('id')->where(['is_delete' => File::IS_DELETE_NO, 'own_id' => $model->id, 'own_type' => File::OWN_TYPE_GOODS_DETAILS])->column()); + + //记录已保存的商品图片id,用于修改 + $cover_image_old_id_arr = $model->image; + $detail_image_old_id_arr = $model->detailImageId; + + if ($model->load(Yii::$app->request->post())) { + + //商品封面图和商品详情图上传保存处理 + $cover_image_id_str = $model->coverImageId; + $detail_image_id_str = $model->detailImageId; + $model->save(); + $goods_manager = new GoodsManager(); + $save_cover_image_res = $goods_manager->saveFile(explode(',', $cover_image_id_str), $model, explode(',', $cover_image_old_id_arr)); + $save_detail_image_res = $goods_manager->saveFile(explode(',', $detail_image_id_str), $model, explode(',', $detail_image_old_id_arr), File::OWN_TYPE_GOODS_DETAILS); + if($save_cover_image_res['status'] && $save_detail_image_res['status'] && $save_cover_image_res['first_file_id'] !== 0){ + $model->image = $save_cover_image_res['first_file_id']; + $model->save(); + } + + return $this->redirect('index'); + } + + return $this->render('update', [ + 'model' => $model, + ]); + } + + /** + * Deletes an existing Goods model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + /** + * Finds the Goods model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Goods the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Goods::findOne($id)) !== null) { + return $model; + } + + throw new NotFoundHttpException('The requested page does not exist.'); + } + /** + * @author iron + * 文件导出 + */ + public function actionExport() + { + $searchModel = new GoodsSearch(); + $params = Yii::$app->request->queryParams; + if ($params['page-type'] == 'all') { + $dataProvider = $searchModel->allData($params); + } else { + $dataProvider = $searchModel->search($params); + } + \iron\widget\Excel::export([ + 'models' => $dataProvider->getModels(), + 'format' => 'Xlsx', + 'asAttachment' => true, + 'fileName' =>'Goods'. "-" .date('Y-m-d H/i/s', time()), + 'columns' => $searchModel->columns() + ]); + } + + /** + * 处理文件上传成功后回调保存到临时文件表中,并返回临时文件id + */ + public function actionSaveFile() + { + if(!class_exists('\common\models\ars\TemFile') || !class_exists('\backend\logic\file\FileManager')){ + return ''; + } + + $data = Yii::$app->request->get('data'); + $file_name = Yii::$app->request->get('fileName')[0]; + + if ($data['status'] == true) { + $model = new \common\models\ars\TemFile(); + $model->user_id = Yii::$app->user->identity->id; + $model->name = $file_name; + $file_manager = new \backend\logic\file\FileManager(); + $type_res = $file_manager->searchType(\backend\logic\file\FileManager::$extension, pathinfo($data['path'])['extension']); + if ($type_res['status']) { + $model->type = $type_res['type']; + } + $model->alias = $data['alias']; + $model->path = $data['path']; + $model->save(); + return $model->id; + } + } + + /** + * @return string + * 点击删除按钮时同时删除字符串中的id + */ + public function actionImgIdDel() + { + //判断该类是否存在 + if(!class_exists('\common\models\ars\TemFile') || !class_exists('\common\models\ars\File')){ + return ''; + } + + $img_id = Yii::$app->request->get('imgid'); + $img_id_arr = explode(',', $img_id); + if(isset(Yii::$app->request->get('data')['alias'])) { + $alias = Yii::$app->request->get('data')['alias']; + $tem_file = \common\models\ars\TemFile::findOne(['alias' => $alias]); + if ($tem_file) { + $img_id_arr = array_diff($img_id_arr, [$tem_file->id]); + } + }else{ + foreach (Yii::$app->request->get() as $key => $value) { + $tem_file = \common\models\ars\File::findOne(['alias' => $value]); + if ($tem_file) { + $img_id_arr = array_diff($img_id_arr, [$tem_file->id]); + } + } + } + $img_id_str = implode(',', $img_id_arr); + return $img_id_str; + } + + /** + * @return bool|false|string + * 加载已有的文件 + */ + public function actionImageFile() + { + //判断该类是否存在 + if(!class_exists('\common\models\ars\File')){ + return false; + } + + $file_id_str = Yii::$app->request->get('fileidstr'); + $file_id_arr = explode(',', $file_id_str); + $data = \common\models\ars\File::find()->where(['id' => $file_id_arr])->all(); + $res = array(); + if($data) { + $i = 0; + foreach ($data as $key => $value) { + $res[$i]['name'] = $value->alias; + $res[$i]['path'] = Yii::$app->request->hostInfo . '/' . $value->path; + $res[$i]['size'] = filesize($value->path); + $i++; + } + } + return json_encode($res); + } +} diff --git a/vendor/antgoods/goods/src/controllers/ShopCategoryController.php b/vendor/antgoods/goods/src/controllers/ShopCategoryController.php new file mode 100644 index 0000000..0d07303 --- /dev/null +++ b/vendor/antgoods/goods/src/controllers/ShopCategoryController.php @@ -0,0 +1,273 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ]; + } + + public function actions() + { + return [ + 'upload' => [ + 'class' => 'iron\actions\UploadAction', + 'path' => 'xls/', + 'maxSize' => 20480, + ] + ]; + } + + /** + * Lists all ShopCategory models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new ShopCategorySearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + 'columns' => $searchModel->columns() + ]); + } + + /** + * Displays a single ShopCategory model. + * @param integer $id + * @return mixed + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new ShopCategory model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new ShopCategory(); + + if ($model->load(Yii::$app->request->post())) { + + //类目图片上传保存处理 + $icon_image_id_str = $model->iconImageId; + $model->save(); + $goods_manager = new GoodsManager(); + $save_icon_image_res = $goods_manager->saveFile(explode(',', $icon_image_id_str), $model, [], File::OWN_TYPE_CATEGORY_ICON); + if($save_icon_image_res['status']){ + $model->icon = $save_icon_image_res['first_file_id']; + $model->save(); + } + + return $this->redirect('index'); + } + + return $this->render('create', [ + 'model' => $model, + ]); + } + + /** + * Updates an existing ShopCategory model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + $model->iconImageId = $model->icon; + //记录已保存的类目图片id,用于修改 + $icon_image_old_id_arr = $model->icon; + + if ($model->load(Yii::$app->request->post())) { + + //类目图片上传保存处理 + $icon_image_id_str = $model->iconImageId; + $model->save(); + $goods_manager = new GoodsManager(); + $save_icon_image_res = $goods_manager->saveFile(explode(',', $icon_image_id_str), $model, explode(',', $icon_image_old_id_arr), File::OWN_TYPE_CATEGORY_ICON); + if($save_icon_image_res['status'] && $save_icon_image_res['first_file_id'] !== 0){ + $model->icon = $save_icon_image_res['first_file_id']; + $model->save(); + } + + return $this->redirect('index'); + } + + return $this->render('update', [ + 'model' => $model, + ]); + } + + /** + * Deletes an existing ShopCategory model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + /** + * Finds the ShopCategory model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return ShopCategory the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = ShopCategory::findOne($id)) !== null) { + return $model; + } + + throw new NotFoundHttpException('The requested page does not exist.'); + } + /** + * @author iron + * 文件导出 + */ + public function actionExport() + { + $searchModel = new ShopCategorySearch(); + $params = Yii::$app->request->queryParams; + if ($params['page-type'] == 'all') { + $dataProvider = $searchModel->allData($params); + } else { + $dataProvider = $searchModel->search($params); + } + \iron\widget\Excel::export([ + 'models' => $dataProvider->getModels(), + 'format' => 'Xlsx', + 'asAttachment' => true, + 'fileName' =>'Shop Categories'. "-" .date('Y-m-d H/i/s', time()), + 'columns' => $searchModel->columns() + ]); + } + + /** + * 处理文件上传成功后回调保存到临时文件表中,并返回临时文件id + */ + public function actionSaveFile() + { + if(!class_exists('\common\models\ars\TemFile') || !class_exists('\backend\logic\file\FileManager')){ + return ''; + } + + $data = Yii::$app->request->get('data'); + $file_name = Yii::$app->request->get('fileName')[0]; + + if ($data['status'] == true) { + $model = new \common\models\ars\TemFile(); + $model->user_id = Yii::$app->user->identity->id; + $model->name = $file_name; + $file_manager = new \backend\logic\file\FileManager(); + $type_res = $file_manager->searchType(\backend\logic\file\FileManager::$extension, pathinfo($data['path'])['extension']); + if ($type_res['status']) { + $model->type = $type_res['type']; + } + $model->alias = $data['alias']; + $model->path = $data['path']; + $model->save(); + return $model->id; + } + } + + /** + * @return string + * 点击删除按钮时同时删除字符串中的id + */ + public function actionImgIdDel() + { + //判断该类是否存在 + if(!class_exists('\common\models\ars\TemFile') || !class_exists('\common\models\ars\File')){ + return ''; + } + + $img_id = Yii::$app->request->get('imgid'); + $img_id_arr = explode(',', $img_id); + if(isset(Yii::$app->request->get('data')['alias'])) { + $alias = Yii::$app->request->get('data')['alias']; + $tem_file = \common\models\ars\TemFile::findOne(['alias' => $alias]); + if ($tem_file) { + $img_id_arr = array_diff($img_id_arr, [$tem_file->id]); + } + }else{ + foreach (Yii::$app->request->get() as $key => $value) { + $tem_file = \common\models\ars\File::findOne(['alias' => $value]); + if ($tem_file) { + $img_id_arr = array_diff($img_id_arr, [$tem_file->id]); + } + } + } + $img_id_str = implode(',', $img_id_arr); + return $img_id_str; + } + + /** + * @return bool|false|string + * 加载已有的文件 + */ + public function actionImageFile() + { + //判断该类是否存在 + if(!class_exists('\common\models\ars\File')){ + return false; + } + + $file_id_str = Yii::$app->request->get('fileidstr'); + $file_id_arr = explode(',', $file_id_str); + $data = \common\models\ars\File::find()->where(['id' => $file_id_arr])->all(); + $res = array(); + if($data) { + $i = 0; + foreach ($data as $key => $value) { + $res[$i]['name'] = $value->alias; + $res[$i]['path'] = Yii::$app->request->hostInfo . '/' . $value->path; + $res[$i]['size'] = filesize($value->path); + $i++; + } + } + return json_encode($res); + } +} diff --git a/backend/controllers/SupplierController.php b/vendor/antgoods/goods/src/controllers/SupplierController.php similarity index 96% rename from backend/controllers/SupplierController.php rename to vendor/antgoods/goods/src/controllers/SupplierController.php index b538566..cdc6a80 100644 --- a/backend/controllers/SupplierController.php +++ b/vendor/antgoods/goods/src/controllers/SupplierController.php @@ -1,10 +1,10 @@ false, 'info' => '操作失败']; + } + + //需要新建的文件id + $create_file_id_arr = array_diff($newFileIdArr, $oldFileIdArr); + + //创建文件 + $class = new \backend\logic\file\FileManager(); + $create_file_res = $class->saveTemFileToFile($create_file_id_arr, $goodsModel->id, $filetype); + + //需要删除的文件id + $del_file_id_arr = array_diff($oldFileIdArr, $newFileIdArr); + + //删除文件 + $class->deleteFile($del_file_id_arr); + + //记录第一张图片id + $first_file_id = 0; + + //查看修改数组是否为空 + if (!$newFileIdArr[0]) { + $first_file_id = null; + }else { + if ($create_file_res['status']) { + $first_file_id = $create_file_res['first_file_id']; + } + } + + return ['status' => true, 'info' => '操作成功', 'first_file_id' => $first_file_id]; + } +} \ No newline at end of file diff --git a/console/migrations/m191111_080318_create_table_shop_category.php b/vendor/antgoods/goods/src/migrations/m191119_021851_create_table_shop_category.php similarity index 72% rename from console/migrations/m191111_080318_create_table_shop_category.php rename to vendor/antgoods/goods/src/migrations/m191119_021851_create_table_shop_category.php index da2a1a3..35f536e 100644 --- a/console/migrations/m191111_080318_create_table_shop_category.php +++ b/vendor/antgoods/goods/src/migrations/m191119_021851_create_table_shop_category.php @@ -3,9 +3,9 @@ use yii\db\Migration; /** - * Class m191111_080318_create_table_shop_category + * Class m191119_021851_create_table_shop_category */ -class m191111_080318_create_table_shop_category extends Migration +class m191119_021851_create_table_shop_category extends Migration { /** * {@inheritdoc} @@ -13,14 +13,14 @@ class m191111_080318_create_table_shop_category extends Migration public function up() { $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="前端商品类别表"'; - $this->createTable('ats_shop_category', [ + $this->createTable('antgoods_shop_category', [ 'id' => $this->primaryKey(), - 'name'=>$this->string(60)->defaultValue(null)->comment('类别名称'), + 'name'=>$this->string(60)->notNull()->comment('类别名称'), 'pid'=>$this->integer(11)->defaultValue(null)->comment('父级id'), - 'goods_count'=>$this->integer(11)->defaultValue(null)->comment('商品数量'), + 'goods_count'=>$this->integer(11)->defaultValue(0)->comment('商品数量'), 'keywords'=>$this->string(100)->defaultValue(null)->comment('关键字'), 'desc'=>$this->string(255)->defaultValue(null)->comment('描述'), - 'sort_order'=>$this->smallInteger(3)->defaultValue(null)->comment('排序'), + 'sort_order'=>$this->smallInteger(3)->defaultValue(0)->comment('排序'), 'icon_type'=>$this->tinyInteger(1)->defaultValue(null)->comment('图标类型'), 'icon'=>$this->string(64)->defaultValue(null)->comment('图标'), 'filter_attr'=>$this->text()->comment('筛选属性'), @@ -36,7 +36,7 @@ class m191111_080318_create_table_shop_category extends Migration */ public function down() { - $this->dropTable('kcs_tags_relation_goods'); + $this->dropTable('antgoods_shop_category'); return true; } } diff --git a/console/migrations/m191111_081842_create_table_category.php b/vendor/antgoods/goods/src/migrations/m191119_022641_create_table_category.php similarity index 55% rename from console/migrations/m191111_081842_create_table_category.php rename to vendor/antgoods/goods/src/migrations/m191119_022641_create_table_category.php index e7598bd..60dd21e 100644 --- a/console/migrations/m191111_081842_create_table_category.php +++ b/vendor/antgoods/goods/src/migrations/m191119_022641_create_table_category.php @@ -3,9 +3,9 @@ use yii\db\Migration; /** - * Class m191111_081842_create_table_category + * Class m191119_022641_create_table_category */ -class m191111_081842_create_table_category extends Migration +class m191119_022641_create_table_category extends Migration { /** * {@inheritdoc} @@ -13,16 +13,16 @@ class m191111_081842_create_table_category extends Migration public function up() { $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="后台商品类别表"'; - $this->createTable('ats_category', [ + $this->createTable('antgoods_category', [ 'id' => $this->primaryKey(), - 'name'=>$this->string(60)->defaultValue(null)->comment('类别名称'), + 'name'=>$this->string(60)->notNull()->comment('类别名称'), 'pid'=>$this->integer(11)->defaultValue(null)->comment('父级id'), - 'goods_count'=>$this->integer(11)->defaultValue(null)->comment('商品数量'), - 'sort_order'=>$this->smallInteger(3)->defaultValue(null)->comment('排序'), + 'goods_count'=>$this->integer(11)->defaultValue(0)->comment('商品数量'), + 'sort_order'=>$this->smallInteger(3)->defaultValue(0)->comment('排序'), 'icon_type'=>$this->tinyInteger(1)->defaultValue(null)->comment('图标类型'), 'icon'=>$this->string(64)->defaultValue(null)->comment('图标'), - 'is_show'=>$this->tinyInteger(1)->defaultValue(null)->comment('是否显示,1为不显示'), - 'is_delete'=>$this->tinyInteger(1)->defaultValue(null)->comment('是否删除,1为已删除'), + 'is_show'=>$this->tinyInteger(1)->defaultValue(0)->comment('是否显示,1为不显示'), + 'is_delete'=>$this->tinyInteger(1)->defaultValue(0)->comment('是否删除,1为已删除'), 'created_at'=>$this->integer(11)->defaultValue(null)->comment('创建时间'), 'updated_at'=>$this->integer(11)->defaultValue(null)->comment('更新时间'), ],$tableOptions); @@ -33,7 +33,7 @@ class m191111_081842_create_table_category extends Migration */ public function down() { - $this->dropTable('ats_category'); + $this->dropTable('antgoods_category'); return true; } } diff --git a/console/migrations/m191111_082739_create_table_attribute.php b/vendor/antgoods/goods/src/migrations/m191119_022939_create_table_attribute.php similarity index 61% rename from console/migrations/m191111_082739_create_table_attribute.php rename to vendor/antgoods/goods/src/migrations/m191119_022939_create_table_attribute.php index d640a25..8f77f8f 100644 --- a/console/migrations/m191111_082739_create_table_attribute.php +++ b/vendor/antgoods/goods/src/migrations/m191119_022939_create_table_attribute.php @@ -3,9 +3,9 @@ use yii\db\Migration; /** - * Class m191111_082739_create_table_attribute + * Class m191119_022939_create_table_attribute */ -class m191111_082739_create_table_attribute extends Migration +class m191119_022939_create_table_attribute extends Migration { /** * {@inheritdoc} @@ -13,13 +13,13 @@ class m191111_082739_create_table_attribute extends Migration public function up() { $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="属性表"'; - $this->createTable('ats_attribute', [ + $this->createTable('antgoods_attribute', [ 'id' => $this->primaryKey(), - 'name'=>$this->string(50)->defaultValue(null)->comment('属性名'), - 'value'=>$this->text()->comment('属性值'), + 'name'=>$this->string(50)->notNull()->comment('属性名'), + 'value'=>$this->text()->notNull()->comment('属性值'), 'type'=>$this->smallInteger(2)->defaultValue(null)->comment('类型'), 'sort_order'=>$this->smallInteger(3)->defaultValue(null)->comment('排序'), - 'is_delete'=>$this->tinyInteger(1)->defaultValue(null)->comment('是否删除,1为已删除'), + 'is_delete'=>$this->tinyInteger(1)->defaultValue(0)->comment('是否删除,1为已删除'), 'created_at'=>$this->integer(11)->defaultValue(null)->comment('创建时间'), 'updated_at'=>$this->integer(11)->defaultValue(null)->comment('更新时间'), ],$tableOptions); @@ -30,7 +30,7 @@ class m191111_082739_create_table_attribute extends Migration */ public function down() { - $this->dropTable('ats_attribute'); + $this->dropTable('antgoods_attribute'); return true; } } diff --git a/console/migrations/m191111_083808_create_table_goods_attr.php b/vendor/antgoods/goods/src/migrations/m191119_023115_create_table_goods_attr.php similarity index 50% rename from console/migrations/m191111_083808_create_table_goods_attr.php rename to vendor/antgoods/goods/src/migrations/m191119_023115_create_table_goods_attr.php index 573252f..19a263c 100644 --- a/console/migrations/m191111_083808_create_table_goods_attr.php +++ b/vendor/antgoods/goods/src/migrations/m191119_023115_create_table_goods_attr.php @@ -3,9 +3,9 @@ use yii\db\Migration; /** - * Class m191111_083808_create_table_goods_attr + * Class m191119_023115_create_table_goods_attr */ -class m191111_083808_create_table_goods_attr extends Migration +class m191119_023115_create_table_goods_attr extends Migration { /** * {@inheritdoc} @@ -13,12 +13,12 @@ class m191111_083808_create_table_goods_attr extends Migration public function up() { $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="商品属性表"'; - $this->createTable('ats_goods_attr', [ + $this->createTable('antgoods_goods_attr', [ 'id' => $this->primaryKey(), - 'goods_id'=>$this->integer(11)->defaultValue(null)->comment('商品id'), - 'attr_id'=>$this->integer(11)->defaultValue(null)->comment('属性id'), - 'attr_value'=>$this->string(50)->defaultValue(null)->comment('属性名'), - 'is_delete'=>$this->tinyInteger(1)->defaultValue(null)->comment('是否删除,1为已删除'), + 'goods_id'=>$this->integer(11)->notNull()->comment('商品id'), + 'attr_id'=>$this->integer(11)->notNull()->comment('属性id'), + 'attr_value'=>$this->string(50)->notNull()->comment('属性名'), + 'is_delete'=>$this->tinyInteger(1)->defaultValue(0)->comment('是否删除,1为已删除'), 'created_at'=>$this->integer(11)->defaultValue(null)->comment('创建时间'), 'updated_at'=>$this->integer(11)->defaultValue(null)->comment('更新时间'), ],$tableOptions); @@ -29,7 +29,7 @@ class m191111_083808_create_table_goods_attr extends Migration */ public function down() { - $this->dropTable('ats_goods_attr'); + $this->dropTable('antgoods_goods_attr'); return true; } } diff --git a/console/migrations/m191111_084452_create_table_brand.php b/vendor/antgoods/goods/src/migrations/m191119_024029_create_table_brand.php similarity index 60% rename from console/migrations/m191111_084452_create_table_brand.php rename to vendor/antgoods/goods/src/migrations/m191119_024029_create_table_brand.php index 6658ff7..48984d4 100644 --- a/console/migrations/m191111_084452_create_table_brand.php +++ b/vendor/antgoods/goods/src/migrations/m191119_024029_create_table_brand.php @@ -3,9 +3,9 @@ use yii\db\Migration; /** - * Class m191111_084452_create_table_brand + * Class m191119_024029_create_table_brand */ -class m191111_084452_create_table_brand extends Migration +class m191119_024029_create_table_brand extends Migration { /** * {@inheritdoc} @@ -13,10 +13,10 @@ class m191111_084452_create_table_brand extends Migration public function up() { $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="品牌表"'; - $this->createTable('ats_brand', [ + $this->createTable('antgoods_brand', [ 'id' => $this->primaryKey(), - 'name'=>$this->string(50)->defaultValue(null)->comment('品牌名'), - 'is_delete'=>$this->tinyInteger(1)->defaultValue(null)->comment('是否删除,1为已删除'), + 'name'=>$this->string(50)->notNull()->comment('品牌名'), + 'is_delete'=>$this->tinyInteger(1)->defaultValue(0)->comment('是否删除,1为已删除'), 'created_at'=>$this->integer(11)->defaultValue(null)->comment('创建时间'), 'updated_at'=>$this->integer(11)->defaultValue(null)->comment('更新时间'), ],$tableOptions); @@ -27,7 +27,7 @@ class m191111_084452_create_table_brand extends Migration */ public function down() { - $this->dropTable('ats_brand'); + $this->dropTable('antgoods_brand'); return true; } } diff --git a/console/migrations/m191111_095158_create_table_goods.php b/vendor/antgoods/goods/src/migrations/m191119_024205_create_table_goods.php similarity index 67% rename from console/migrations/m191111_095158_create_table_goods.php rename to vendor/antgoods/goods/src/migrations/m191119_024205_create_table_goods.php index 5644e70..d16c1e5 100644 --- a/console/migrations/m191111_095158_create_table_goods.php +++ b/vendor/antgoods/goods/src/migrations/m191119_024205_create_table_goods.php @@ -3,9 +3,9 @@ use yii\db\Migration; /** - * Class m191111_095158_create_table_goods + * Class m191119_024205_create_table_goods */ -class m191111_095158_create_table_goods extends Migration +class m191119_024205_create_table_goods extends Migration { /** * {@inheritdoc} @@ -21,7 +21,7 @@ class m191111_095158_create_table_goods extends Migration */ public function down() { - $this->dropTable("ats_goods"); + $this->dropTable("antgoods_goods"); return true; } } diff --git a/console/migrations/m191111_100540_create_table_goods_sku.php b/vendor/antgoods/goods/src/migrations/m191119_024345_create_table_goods_sku.php similarity index 66% rename from console/migrations/m191111_100540_create_table_goods_sku.php rename to vendor/antgoods/goods/src/migrations/m191119_024345_create_table_goods_sku.php index ac7ec13..227b38b 100644 --- a/console/migrations/m191111_100540_create_table_goods_sku.php +++ b/vendor/antgoods/goods/src/migrations/m191119_024345_create_table_goods_sku.php @@ -3,9 +3,9 @@ use yii\db\Migration; /** - * Class m191111_100540_create_table_goods_sku + * Class m191119_024345_create_table_goods_sku */ -class m191111_100540_create_table_goods_sku extends Migration +class m191119_024345_create_table_goods_sku extends Migration { /** * {@inheritdoc} @@ -21,7 +21,7 @@ class m191111_100540_create_table_goods_sku extends Migration */ public function down() { - $this->dropTable("ats_goods_sku"); + $this->dropTable("antgoods_goods_sku"); return true; } } diff --git a/console/migrations/m191111_100639_create_table_supplier.php b/vendor/antgoods/goods/src/migrations/m191119_025607_create_table_supplier.php similarity index 55% rename from console/migrations/m191111_100639_create_table_supplier.php rename to vendor/antgoods/goods/src/migrations/m191119_025607_create_table_supplier.php index e13f46a..c7d8f6c 100644 --- a/console/migrations/m191111_100639_create_table_supplier.php +++ b/vendor/antgoods/goods/src/migrations/m191119_025607_create_table_supplier.php @@ -3,9 +3,9 @@ use yii\db\Migration; /** - * Class m191111_100639_create_table_supplier + * Class m191119_025607_create_table_supplier */ -class m191111_100639_create_table_supplier extends Migration +class m191119_025607_create_table_supplier extends Migration { /** * {@inheritdoc} @@ -13,12 +13,12 @@ class m191111_100639_create_table_supplier extends Migration public function up() { $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="供应商表"'; - $this->createTable('ats_supplier', [ + $this->createTable('antgoods_supplier', [ 'id' => $this->primaryKey(), - 'name'=>$this->string(50)->defaultValue(null)->comment('供应商名称'), - 'full_name'=>$this->string(50)->defaultValue(null)->comment('供应商全称'), - 'phone'=>$this->string(20)->defaultValue(null)->comment('手机号码'), - 'address'=>$this->string(50)->defaultValue(null)->comment('地址'), + 'name'=>$this->string(50)->notNull()->comment('供应商名称'), + 'full_name'=>$this->string(50)->notNull()->comment('供应商全称'), + 'phone'=>$this->string(20)->notNull()->comment('手机号码'), + 'address'=>$this->string(50)->notNull()->comment('地址'), 'is_delete'=>$this->tinyInteger(1)->defaultValue(0)->comment('是否删除,1为已删除'), 'created_at'=>$this->integer(11)->defaultValue(null)->comment('创建时间'), 'updated_at'=>$this->integer(11)->defaultValue(null)->comment('更新时间'), @@ -30,7 +30,7 @@ class m191111_100639_create_table_supplier extends Migration */ public function down() { - $this->dropTable('ats_supplier'); + $this->dropTable('antgoods_supplier'); return true; } } diff --git a/console/migrations/m191111_100958_create_table_filter_attr.php b/vendor/antgoods/goods/src/migrations/m191119_025843_create_table_filter_attr.php similarity index 59% rename from console/migrations/m191111_100958_create_table_filter_attr.php rename to vendor/antgoods/goods/src/migrations/m191119_025843_create_table_filter_attr.php index 357f4dd..0409292 100644 --- a/console/migrations/m191111_100958_create_table_filter_attr.php +++ b/vendor/antgoods/goods/src/migrations/m191119_025843_create_table_filter_attr.php @@ -3,9 +3,9 @@ use yii\db\Migration; /** - * Class m191111_100958_create_table_filter_attr + * Class m191119_025843_create_table_filter_attr */ -class m191111_100958_create_table_filter_attr extends Migration +class m191119_025843_create_table_filter_attr extends Migration { /** * {@inheritdoc} @@ -13,11 +13,11 @@ class m191111_100958_create_table_filter_attr extends Migration public function up() { $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="筛选属性表"'; - $this->createTable('ats_filter_attr', [ + $this->createTable('antgoods_filter_attr', [ 'id' => $this->primaryKey(), - 'goods_id'=>$this->integer(11)->defaultValue(null)->comment('商品id'), - 'attr_id'=>$this->integer(11)->defaultValue(null)->comment('属性id'), - 'attr_value'=>$this->string(50)->defaultValue(null)->comment('属性值'), + 'goods_id'=>$this->integer(11)->notNull()->comment('商品id'), + 'attr_id'=>$this->integer(11)->notNull()->comment('属性id'), + 'attr_value'=>$this->string(50)->notNull()->comment('属性值'), 'is_delete'=>$this->tinyInteger(1)->defaultValue(0)->comment('是否删除,1为已删除'), 'created_at'=>$this->integer(11)->defaultValue(null)->comment('创建时间'), 'updated_at'=>$this->integer(11)->defaultValue(null)->comment('更新时间'), @@ -29,7 +29,7 @@ class m191111_100958_create_table_filter_attr extends Migration */ public function down() { - $this->dropTable('ats_filter_attr'); + $this->dropTable('antgoods_filter_attr'); return true; } } diff --git a/vendor/antgoods/goods/src/migrations/m191125_012449_update_column_icon_type_in_antgoods_category.php b/vendor/antgoods/goods/src/migrations/m191125_012449_update_column_icon_type_in_antgoods_category.php new file mode 100644 index 0000000..00fb52e --- /dev/null +++ b/vendor/antgoods/goods/src/migrations/m191125_012449_update_column_icon_type_in_antgoods_category.php @@ -0,0 +1,22 @@ +dropColumn('antgoods_category', 'icon_type'); + $this->addColumn('antgoods_category', 'icon_type', $this->tinyInteger(1)->defaultValue(1)->comment('图标类型')); + } + + public function down() + { + $this->dropColumn('antgoods_category', 'icon_type'); + $this->addColumn('antgoods_category', 'icon_type', $this->tinyInteger(1)->defaultValue(null)->comment('图标类型')); + return true; + } +} diff --git a/vendor/antgoods/goods/src/migrations/m191125_083820_drop_column_icon_type_in_table_antgoods_category.php b/vendor/antgoods/goods/src/migrations/m191125_083820_drop_column_icon_type_in_table_antgoods_category.php new file mode 100644 index 0000000..04c6a2b --- /dev/null +++ b/vendor/antgoods/goods/src/migrations/m191125_083820_drop_column_icon_type_in_table_antgoods_category.php @@ -0,0 +1,20 @@ +dropColumn('antgoods_category', 'icon_type'); + } + + public function down() + { + $this->addColumn('antgoods_category', 'icon_type', $this->tinyInteger(1)->defaultValue(null)->comment('图标类型')); + return true; + } +} diff --git a/vendor/antgoods/goods/src/migrations/m191125_084547_update_column_pid_and_icon_in_table_antgoods_category.php b/vendor/antgoods/goods/src/migrations/m191125_084547_update_column_pid_and_icon_in_table_antgoods_category.php new file mode 100644 index 0000000..055e84c --- /dev/null +++ b/vendor/antgoods/goods/src/migrations/m191125_084547_update_column_pid_and_icon_in_table_antgoods_category.php @@ -0,0 +1,26 @@ +dropColumn('antgoods_category', 'icon'); + $this->addColumn('antgoods_category', 'icon', $this->integer(11)->defaultValue(null)->comment('图标')); + $this->dropColumn('antgoods_category', 'pid'); + $this->addColumn('antgoods_category', 'pid', $this->integer(11)->defaultValue(0)->comment('父级id')); + } + + public function down() + { + $this->dropColumn('antgoods_category', 'icon'); + $this->addColumn('antgoods_category', 'icon', $this->string(64)->defaultValue(null)->comment('图标')); + $this->dropColumn('antgoods_category', 'pid'); + $this->addColumn('antgoods_category', 'pid', $this->integer(11)->defaultValue(null)->comment('父级id')); + return true; + } +} diff --git a/vendor/antgoods/goods/src/migrations/m191125_104137_drop_column_icon_type_in_table_antgoods_shop_category.php b/vendor/antgoods/goods/src/migrations/m191125_104137_drop_column_icon_type_in_table_antgoods_shop_category.php new file mode 100644 index 0000000..2f182eb --- /dev/null +++ b/vendor/antgoods/goods/src/migrations/m191125_104137_drop_column_icon_type_in_table_antgoods_shop_category.php @@ -0,0 +1,20 @@ +dropColumn('antgoods_shop_category', 'icon_type'); + } + + public function down() + { + $this->addColumn('antgoods_shop_category', 'icon_type', $this->tinyInteger(1)->defaultValue(null)->comment('图标类型')); + return true; + } +} diff --git a/vendor/antgoods/goods/src/migrations/m191125_104510_update_column_pid_and_icon_in_table_antgoods_shop_category.php b/vendor/antgoods/goods/src/migrations/m191125_104510_update_column_pid_and_icon_in_table_antgoods_shop_category.php new file mode 100644 index 0000000..b1536ac --- /dev/null +++ b/vendor/antgoods/goods/src/migrations/m191125_104510_update_column_pid_and_icon_in_table_antgoods_shop_category.php @@ -0,0 +1,26 @@ +dropColumn('antgoods_shop_category', 'icon'); + $this->addColumn('antgoods_shop_category', 'icon', $this->integer(11)->defaultValue(null)->comment('图标')); + $this->dropColumn('antgoods_shop_category', 'pid'); + $this->addColumn('antgoods_shop_category', 'pid', $this->integer(11)->defaultValue(0)->comment('父级id')); + } + + public function down() + { + $this->dropColumn('antgoods_shop_category', 'icon'); + $this->addColumn('antgoods_shop_category', 'icon', $this->string(64)->defaultValue(null)->comment('图标')); + $this->dropColumn('antgoods_shop_category', 'pid'); + $this->addColumn('antgoods_shop_category', 'pid', $this->integer(11)->defaultValue(null)->comment('父级id')); + return true; + } +} diff --git a/console/migrations/sql/goods.sql b/vendor/antgoods/goods/src/migrations/sql/goods.sql old mode 100644 new mode 100755 similarity index 82% rename from console/migrations/sql/goods.sql rename to vendor/antgoods/goods/src/migrations/sql/goods.sql index 186d046..fe9d9e2 --- a/console/migrations/sql/goods.sql +++ b/vendor/antgoods/goods/src/migrations/sql/goods.sql @@ -1,11 +1,11 @@ -DROP TABLE IF EXISTS `ats_goods`; -CREATE TABLE `ats_goods` ( +DROP TABLE IF EXISTS `antgoods_goods`; +CREATE TABLE `antgoods_goods` ( `id` int(11) NOT NULL AUTO_INCREMENT, `pid` int(11) DEFAULT NULL COMMENT '父级id', - `cat_id` int(11) DEFAULT NULL COMMENT '后台商品类别id', - `brand_id` int(11) DEFAULT NULL COMMENT '品牌id', - `shop_cat_id` int(11) DEFAULT NULL COMMENT '前端商品类别id', - `name` varchar(120) DEFAULT NULL COMMENT '商品名称', + `cat_id` int(11) NOT NULL COMMENT '后台商品类别id', + `brand_id` int(11) NOT NULL COMMENT '品牌id', + `shop_cat_id` int(11) NOT NULL COMMENT '前端商品类别id', + `name` varchar(120) NOT NULL COMMENT '商品名称', `sn` varchar(60) DEFAULT NULL COMMENT '商品唯一货号', `code` varchar(50) DEFAULT NULL COMMENT '商品货码', `supplier_id` int(11) DEFAULT NULL COMMENT '供应商id', diff --git a/console/migrations/sql/goods_sku.sql b/vendor/antgoods/goods/src/migrations/sql/goods_sku.sql old mode 100644 new mode 100755 similarity index 76% rename from console/migrations/sql/goods_sku.sql rename to vendor/antgoods/goods/src/migrations/sql/goods_sku.sql index 0a5ec6c..a599a39 --- a/console/migrations/sql/goods_sku.sql +++ b/vendor/antgoods/goods/src/migrations/sql/goods_sku.sql @@ -1,9 +1,9 @@ -DROP TABLE IF EXISTS `ats_goods_sku`; -CREATE TABLE `ats_goods_sku` ( +DROP TABLE IF EXISTS `antgoods_goods_sku`; +CREATE TABLE `antgoods_goods_sku` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `goods_id` int(11) DEFAULT NULL COMMENT '商品id', + `goods_id` int(11) NOT NULL COMMENT '商品id', `goods_code` varchar(50) DEFAULT NULL COMMENT '商品条码', - `goods_sn` varchar(60) DEFAULT NULL COMMENT '商品唯一货号', + `goods_sn` varchar(60) NOT NULL COMMENT '商品唯一货号', `goods_attr` varchar(60) DEFAULT NULL COMMENT '属性匹配', `weight` mediumint(8) DEFAULT NULL COMMENT '重量', `length` mediumint(8) DEFAULT NULL COMMENT '长度', @@ -16,7 +16,7 @@ CREATE TABLE `ats_goods_sku` ( `price` int(20) DEFAULT NULL COMMENT '销售价', `model_id` int(11) DEFAULT NULL COMMENT '模型id', `is_sale` tinyint(1) DEFAULT '0' COMMENT '该商品是否开放销售,1为是,0为否', - `sort_order` smallint(3) DEFAULT NULL COMMENT '排序', + `sort_order` smallint(3) DEFAULT '0' COMMENT '排序', `is_delete` tinyint(1) DEFAULT '0' COMMENT '是否删除,1为已删除', `created_at` int(10) DEFAULT '0' COMMENT '创建时间', `updated_at` int(10) DEFAULT '0' COMMENT '更新时间', diff --git a/common/models/ars/Attribute.php b/vendor/antgoods/goods/src/models/ars/Attribute.php similarity index 78% rename from common/models/ars/Attribute.php rename to vendor/antgoods/goods/src/models/ars/Attribute.php index 664fb60..d621446 100644 --- a/common/models/ars/Attribute.php +++ b/vendor/antgoods/goods/src/models/ars/Attribute.php @@ -1,12 +1,12 @@ 50], @@ -46,8 +52,8 @@ class Attribute extends \yii\db\ActiveRecord { return [ 'id' => 'id', - 'name' => '属性名', - 'value' => '属性值', + 'name' => '规格名称', + 'value' => '规格内容(每项以逗号隔开)', 'type' => '类型', 'sort_order' => '排序', 'is_delete' => '是否删除,1为已删除', @@ -55,6 +61,7 @@ class Attribute extends \yii\db\ActiveRecord 'updated_at' => '更新时间', ]; } + /** * @author linyao diff --git a/common/models/ars/Brand.php b/vendor/antgoods/goods/src/models/ars/Brand.php similarity index 75% rename from common/models/ars/Brand.php rename to vendor/antgoods/goods/src/models/ars/Brand.php index cbe1618..e577b1d 100644 --- a/common/models/ars/Brand.php +++ b/vendor/antgoods/goods/src/models/ars/Brand.php @@ -1,12 +1,12 @@ 50], ]; @@ -48,6 +52,7 @@ class Brand extends \yii\db\ActiveRecord 'updated_at' => '更新时间', ]; } + /** * @author linyao @@ -69,4 +74,9 @@ class Brand extends \yii\db\ActiveRecord ], ]; } + + public static function modelColumn() + { + return $column = self::find()->select(['name'])->where(['is_delete' => self::IS_DELETE_NO])->indexBy('id')->column(); + } } diff --git a/common/models/ars/Category.php b/vendor/antgoods/goods/src/models/ars/Category.php similarity index 63% rename from common/models/ars/Category.php rename to vendor/antgoods/goods/src/models/ars/Category.php index 3e67792..6a50d3a 100644 --- a/common/models/ars/Category.php +++ b/vendor/antgoods/goods/src/models/ars/Category.php @@ -1,20 +1,19 @@ '显示', + self::IS_SHOW_HIDE => '隐藏' + ]; + /** * {@inheritdoc} */ public static function tableName() { - return 'ats_category'; + return 'antgoods_category'; } /** @@ -36,9 +49,10 @@ class Category extends \yii\db\ActiveRecord public function rules() { return [ - [['pid', 'goods_count', 'sort_order', 'icon_type', 'is_show', 'is_delete'], 'integer'], + [['name'], 'required'], + [['pid', 'goods_count', 'sort_order', 'is_show', 'is_delete', 'icon'], 'integer'], [['name'], 'string', 'max' => 60], - [['icon'], 'string', 'max' => 64], + [['iconImageId'], 'string'], ]; } @@ -55,12 +69,13 @@ class Category extends \yii\db\ActiveRecord 'sort_order' => '排序', 'icon_type' => '图标类型', 'icon' => '图标', - 'is_show' => '是否显示,1为不显示', + 'is_show' => '是否显示', 'is_delete' => '是否删除,1为已删除', 'created_at' => '创建时间', 'updated_at' => '更新时间', ]; } + /** * @author linyao @@ -82,4 +97,13 @@ class Category extends \yii\db\ActiveRecord ], ]; } + + /** + * @return array + * 数据键值对 + */ + public static function modelColumn() + { + return $column = self::find()->select(['name'])->where(['is_delete' => self::IS_DELETE_NO])->indexBy('id')->column(); + } } diff --git a/common/models/ars/FilterAttr.php b/vendor/antgoods/goods/src/models/ars/FilterAttr.php similarity index 88% rename from common/models/ars/FilterAttr.php rename to vendor/antgoods/goods/src/models/ars/FilterAttr.php index 95d6513..2036d55 100644 --- a/common/models/ars/FilterAttr.php +++ b/vendor/antgoods/goods/src/models/ars/FilterAttr.php @@ -1,12 +1,12 @@ 50], ]; @@ -52,6 +53,7 @@ class FilterAttr extends \yii\db\ActiveRecord 'updated_at' => '更新时间', ]; } + /** * @author linyao diff --git a/common/models/ars/Goods.php b/vendor/antgoods/goods/src/models/ars/Goods.php similarity index 70% rename from common/models/ars/Goods.php rename to vendor/antgoods/goods/src/models/ars/Goods.php index 8b7aa93..d446283 100644 --- a/common/models/ars/Goods.php +++ b/vendor/antgoods/goods/src/models/ars/Goods.php @@ -1,12 +1,12 @@ '否', + self::IS_SALE_YES => '是' + ]; /** * {@inheritdoc} */ public static function tableName() { - return 'ats_goods'; + return 'antgoods_goods'; } /** @@ -59,7 +75,9 @@ class Goods extends \yii\db\ActiveRecord { return [ [['pid', 'cat_id', 'brand_id', 'shop_cat_id', 'supplier_id', 'weight', 'length', 'width', 'height', 'diameter', 'sold_count', 'limit_count', 'stock', 'stock_warn', 'market_price', 'price', 'image', 'model_id', 'is_sale', 'sort_order', 'bouns_points', 'experience_points', 'is_delete', 'express_template'], 'integer'], - [['description'], 'string'], + [['cat_id', 'brand_id', 'shop_cat_id', 'name'], 'required'], + [['sn'], 'checkExist'], + [['description', 'coverImageId', 'detailImageId'], 'string'], [['name'], 'string', 'max' => 120], [['sn'], 'string', 'max' => 60], [['code'], 'string', 'max' => 50], @@ -68,6 +86,25 @@ class Goods extends \yii\db\ActiveRecord ]; } + /** + * @param $attribute + * @param $params + * 验证商品编号唯一 + */ + public function checkExist($attribute, $params) + { + $goods = self::find()->where([$attribute => $this->$attribute, 'is_delete' => 0])->one(); + if ($this->isNewRecord) { + if ($goods) { + $this->addError($attribute, "该商品编号已经存在"); + } + } else { + if ($goods && $goods->id != $this->id) { + $this->addError($attribute, "该商品编号已经存在"); + } + } + } + /** * {@inheritdoc} */ @@ -99,7 +136,7 @@ class Goods extends \yii\db\ActiveRecord 'description' => '详细介绍', 'image' => '图片id', 'model_id' => '模型id', - 'is_sale' => '该商品是否开放销售,1为是,0为否', + 'is_sale' => '该商品是否开放销售', 'sort_order' => '排序', 'bouns_points' => '奖励积分', 'experience_points' => '经验值', @@ -109,6 +146,7 @@ class Goods extends \yii\db\ActiveRecord 'updated_at' => '更新时间', ]; } + /** * @author linyao @@ -130,4 +168,17 @@ class Goods extends \yii\db\ActiveRecord ], ]; } + + /** + * @param bool $insert + * @return bool + * 自动填入参数 + */ + public function beforeSave($insert) + { + if (!$this->sn) { + $this->sn = time() . rand(1111, 9999); + } + return parent::beforeSave($insert); // TODO: Change the autogenerated stub + } } diff --git a/common/models/ars/GoodsAttr.php b/vendor/antgoods/goods/src/models/ars/GoodsAttr.php similarity index 88% rename from common/models/ars/GoodsAttr.php rename to vendor/antgoods/goods/src/models/ars/GoodsAttr.php index 1a96b10..b888e46 100644 --- a/common/models/ars/GoodsAttr.php +++ b/vendor/antgoods/goods/src/models/ars/GoodsAttr.php @@ -1,12 +1,12 @@ 50], ]; @@ -52,6 +53,7 @@ class GoodsAttr extends \yii\db\ActiveRecord 'updated_at' => '更新时间', ]; } + /** * @author linyao diff --git a/common/models/ars/GoodsSku.php b/vendor/antgoods/goods/src/models/ars/GoodsSku.php similarity index 93% rename from common/models/ars/GoodsSku.php rename to vendor/antgoods/goods/src/models/ars/GoodsSku.php index 8d523fc..7e4644a 100644 --- a/common/models/ars/GoodsSku.php +++ b/vendor/antgoods/goods/src/models/ars/GoodsSku.php @@ -1,12 +1,12 @@ 50], [['goods_sn', 'goods_attr'], 'string', 'max' => 60], @@ -79,6 +80,7 @@ class GoodsSku extends \yii\db\ActiveRecord 'updated_at' => '更新时间', ]; } + /** * @author linyao diff --git a/common/models/ars/ShopCategory.php b/vendor/antgoods/goods/src/models/ars/ShopCategory.php similarity index 68% rename from common/models/ars/ShopCategory.php rename to vendor/antgoods/goods/src/models/ars/ShopCategory.php index 5df7d3d..d6dc798 100644 --- a/common/models/ars/ShopCategory.php +++ b/vendor/antgoods/goods/src/models/ars/ShopCategory.php @@ -1,12 +1,12 @@ '显示', + self::IS_SHOW_HIDE => '隐藏' + ]; + /** * {@inheritdoc} */ public static function tableName() { - return 'ats_shop_category'; + return 'antgoods_shop_category'; } /** @@ -39,12 +53,12 @@ class ShopCategory extends \yii\db\ActiveRecord public function rules() { return [ - [['pid', 'goods_count', 'sort_order', 'icon_type', 'is_show', 'is_delete'], 'integer'], + [['name'], 'required'], + [['pid', 'goods_count', 'sort_order', 'icon', 'is_show', 'is_delete', 'iconImageId'], 'integer'], [['filter_attr'], 'string'], [['name'], 'string', 'max' => 60], [['keywords'], 'string', 'max' => 100], [['desc'], 'string', 'max' => 255], - [['icon'], 'string', 'max' => 64], ]; } @@ -64,12 +78,13 @@ class ShopCategory extends \yii\db\ActiveRecord 'icon_type' => '图标类型', 'icon' => '图标', 'filter_attr' => '筛选属性', - 'is_show' => '是否显示,1为不显示', - 'is_delete' => '是否删除,1为已删除', + 'is_show' => '是否显示', + 'is_delete' => '是否删除', 'created_at' => '创建时间', 'updated_at' => '更新时间', ]; } + /** * @author linyao @@ -91,4 +106,13 @@ class ShopCategory extends \yii\db\ActiveRecord ], ]; } + + /** + * @return array + * 数据键值对 + */ + public static function modelColumn() + { + return $column = self::find()->select(['name'])->where(['is_delete' => self::IS_DELETE_NO])->indexBy('id')->column(); + } } diff --git a/common/models/ars/Supplier.php b/vendor/antgoods/goods/src/models/ars/Supplier.php similarity index 68% rename from common/models/ars/Supplier.php rename to vendor/antgoods/goods/src/models/ars/Supplier.php index 6733a35..a19f7dd 100644 --- a/common/models/ars/Supplier.php +++ b/vendor/antgoods/goods/src/models/ars/Supplier.php @@ -1,12 +1,12 @@ 50], [['phone'], 'string', 'max' => 20], + ['phone', 'filter', 'filter' => 'trim'], + ['phone','match','pattern'=>'/^[1][34578][0-9]{9}$/'], + ['phone', 'unique', 'targetClass' => '\antgoods\goods\models\ars\Supplier', 'message' => '手机号已被使用'], ]; } @@ -55,6 +62,7 @@ class Supplier extends \yii\db\ActiveRecord 'updated_at' => '更新时间', ]; } + /** * @author linyao @@ -76,4 +84,13 @@ class Supplier extends \yii\db\ActiveRecord ], ]; } + + /** + * @return array + * 数据键值对 + */ + public static function modelColumn() + { + return $column = self::find()->select(['name'])->where(['is_delete' => self::IS_DELETE_NO])->indexBy('id')->column(); + } } diff --git a/common/models/searchs/AttributeSearch.php b/vendor/antgoods/goods/src/models/searchs/AttributeSearch.php similarity index 92% rename from common/models/searchs/AttributeSearch.php rename to vendor/antgoods/goods/src/models/searchs/AttributeSearch.php index bb725fe..b06e242 100644 --- a/common/models/searchs/AttributeSearch.php +++ b/vendor/antgoods/goods/src/models/searchs/AttributeSearch.php @@ -1,16 +1,16 @@ andFilterWhere(['is_delete' => Attribute::IS_DELETE_NO]); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); diff --git a/common/models/searchs/BrandSearch.php b/vendor/antgoods/goods/src/models/searchs/BrandSearch.php similarity index 91% rename from common/models/searchs/BrandSearch.php rename to vendor/antgoods/goods/src/models/searchs/BrandSearch.php index c75e607..e484b56 100644 --- a/common/models/searchs/BrandSearch.php +++ b/vendor/antgoods/goods/src/models/searchs/BrandSearch.php @@ -1,14 +1,14 @@ 'iron\grid\ActionColumn', 'align' => 'center', @@ -115,6 +114,7 @@ class BrandSearch extends Brand * 条件筛选 */ private function filter($query, $dataProvider){ + $query->andFilterWhere(['is_delete' => Brand::IS_DELETE_NO]); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); diff --git a/common/models/searchs/CategorySearch.php b/vendor/antgoods/goods/src/models/searchs/CategorySearch.php similarity index 88% rename from common/models/searchs/CategorySearch.php rename to vendor/antgoods/goods/src/models/searchs/CategorySearch.php index 2693c7f..868afe6 100644 --- a/common/models/searchs/CategorySearch.php +++ b/vendor/antgoods/goods/src/models/searchs/CategorySearch.php @@ -1,14 +1,14 @@ andFilterWhere(['is_delete' => Category::IS_DELETE_NO]); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); @@ -133,15 +133,14 @@ class CategorySearch extends Category 'pid' => $this->pid, 'goods_count' => $this->goods_count, 'sort_order' => $this->sort_order, - 'icon_type' => $this->icon_type, 'is_show' => $this->is_show, 'is_delete' => $this->is_delete, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, + 'icon' => $this->icon, ]); - $query->andFilterWhere(['like', 'name', $this->name]) - ->andFilterWhere(['like', 'icon', $this->icon]); + $query->andFilterWhere(['like', 'name', $this->name]); if ($this->created_at_range) { $arr = explode(' ~ ', $this->created_at_range); $start = strtotime($arr[0]); diff --git a/common/models/searchs/GoodsSearch.php b/vendor/antgoods/goods/src/models/searchs/GoodsSearch.php similarity index 96% rename from common/models/searchs/GoodsSearch.php rename to vendor/antgoods/goods/src/models/searchs/GoodsSearch.php index 2e7cfcf..618b320 100644 --- a/common/models/searchs/GoodsSearch.php +++ b/vendor/antgoods/goods/src/models/searchs/GoodsSearch.php @@ -1,14 +1,14 @@ andFilterWhere(['is_delete' => Goods::IS_DELETE_NO]); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); diff --git a/common/models/searchs/ShopCategorySearch.php b/vendor/antgoods/goods/src/models/searchs/ShopCategorySearch.php similarity index 90% rename from common/models/searchs/ShopCategorySearch.php rename to vendor/antgoods/goods/src/models/searchs/ShopCategorySearch.php index 8704080..2e5dcfc 100644 --- a/common/models/searchs/ShopCategorySearch.php +++ b/vendor/antgoods/goods/src/models/searchs/ShopCategorySearch.php @@ -1,14 +1,14 @@ $this->pid, 'goods_count' => $this->goods_count, 'sort_order' => $this->sort_order, - 'icon_type' => $this->icon_type, + 'icon' => $this->icon, 'is_show' => $this->is_show, 'is_delete' => $this->is_delete, 'created_at' => $this->created_at, @@ -146,7 +146,6 @@ class ShopCategorySearch extends ShopCategory $query->andFilterWhere(['like', 'name', $this->name]) ->andFilterWhere(['like', 'keywords', $this->keywords]) ->andFilterWhere(['like', 'desc', $this->desc]) - ->andFilterWhere(['like', 'icon', $this->icon]) ->andFilterWhere(['like', 'filter_attr', $this->filter_attr]); if ($this->created_at_range) { $arr = explode(' ~ ', $this->created_at_range); diff --git a/common/models/searchs/SupplierSearch.php b/vendor/antgoods/goods/src/models/searchs/SupplierSearch.php similarity index 95% rename from common/models/searchs/SupplierSearch.php rename to vendor/antgoods/goods/src/models/searchs/SupplierSearch.php index ca170c5..916acb7 100644 --- a/common/models/searchs/SupplierSearch.php +++ b/vendor/antgoods/goods/src/models/searchs/SupplierSearch.php @@ -1,14 +1,14 @@ andFilterWhere(['is_delete' => Supplier::IS_DELETE_NO]); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); diff --git a/backend/views/attribute/_form.php b/vendor/antgoods/goods/src/views/attribute/_form.php similarity index 76% rename from backend/views/attribute/_form.php rename to vendor/antgoods/goods/src/views/attribute/_form.php index de4e895..b0e98f7 100644 --- a/backend/views/attribute/_form.php +++ b/vendor/antgoods/goods/src/views/attribute/_form.php @@ -1,10 +1,10 @@ @@ -16,12 +16,8 @@ use yii\widgets\ActiveForm; field($model, 'value')->textarea(['rows' => 6]) ?> - field($model, 'type')->textInput() ?> - field($model, 'sort_order')->textInput() ?> - field($model, 'is_delete')->textInput() ?> -
'btn btn-success']) ?> 'btn btn-info']) ?> diff --git a/backend/views/attribute/_search.php b/vendor/antgoods/goods/src/views/attribute/_search.php similarity index 94% rename from backend/views/attribute/_search.php rename to vendor/antgoods/goods/src/views/attribute/_search.php index e8f58ee..0a9d3be 100644 --- a/backend/views/attribute/_search.php +++ b/vendor/antgoods/goods/src/views/attribute/_search.php @@ -5,7 +5,7 @@ use yii\widgets\ActiveForm; use \blobt\widgets\DateRangePicker; /* @var $this yii\web\View */ -/* @var $model common\models\searchs\attributeSearch */ +/* @var $model common\models\searchs\AttributeSearch */ /* @var $form yii\widgets\ActiveForm */ ?> diff --git a/backend/views/attribute/create.php b/vendor/antgoods/goods/src/views/attribute/create.php similarity index 56% rename from backend/views/attribute/create.php rename to vendor/antgoods/goods/src/views/attribute/create.php index d5578e6..6aa1ff6 100644 --- a/backend/views/attribute/create.php +++ b/vendor/antgoods/goods/src/views/attribute/create.php @@ -3,10 +3,10 @@ use yii\helpers\Html; /* @var $this yii\web\View */ -/* @var $model common\models\ars\Attribute */ +/* @var $model antgoods\goods\models\ars\Attribute */ -$this->title = '创建 Attribute'; -$this->params['breadcrumbs'][] = ['label' => 'Attributes', 'url' => ['index']]; +$this->title = '创建规格'; +$this->params['breadcrumbs'][] = ['label' => '规格管理', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?>
diff --git a/backend/views/attribute/index.php b/vendor/antgoods/goods/src/views/attribute/index.php similarity index 87% rename from backend/views/attribute/index.php rename to vendor/antgoods/goods/src/views/attribute/index.php index 3b9e384..b147a9f 100644 --- a/backend/views/attribute/index.php +++ b/vendor/antgoods/goods/src/views/attribute/index.php @@ -4,10 +4,10 @@ use yii\helpers\Html; use iron\grid\GridView; /* @var $this yii\web\View */ -/* @var $searchModel common\models\searchs\attributeSearch */ +/* @var $searchModel common\models\searchs\AttributeSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ -$this->title = 'Attributes'; +$this->title = '规格管理'; $this->params['breadcrumbs'][] = $this->title; ?>
diff --git a/backend/views/attribute/update.php b/vendor/antgoods/goods/src/views/attribute/update.php similarity index 63% rename from backend/views/attribute/update.php rename to vendor/antgoods/goods/src/views/attribute/update.php index 4532da0..0f412bc 100644 --- a/backend/views/attribute/update.php +++ b/vendor/antgoods/goods/src/views/attribute/update.php @@ -3,10 +3,10 @@ use yii\helpers\Html; /* @var $this yii\web\View */ -/* @var $model common\models\ars\Attribute */ +/* @var $model antgoods\goods\models\ars\Attribute */ -$this->title = '编辑 Attribute: ' . $model->name; -$this->params['breadcrumbs'][] = ['label' => 'Attributes', 'url' => ['index']]; +$this->title = '编辑规格: ' . $model->name; +$this->params['breadcrumbs'][] = ['label' => '规格管理', 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]]; $this->params['breadcrumbs'][] = 'Update '; ?> diff --git a/backend/views/attribute/view.php b/vendor/antgoods/goods/src/views/attribute/view.php similarity index 72% rename from backend/views/attribute/view.php rename to vendor/antgoods/goods/src/views/attribute/view.php index 8e54adb..87eaed1 100644 --- a/backend/views/attribute/view.php +++ b/vendor/antgoods/goods/src/views/attribute/view.php @@ -4,10 +4,10 @@ use yii\helpers\Html; use yii\widgets\DetailView; /* @var $this yii\web\View */ -/* @var $model common\models\ars\Attribute */ +/* @var $model antgoods\goods\models\ars\Attribute */ $this->title = $model->name; -$this->params['breadcrumbs'][] = ['label' => 'Attributes', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => '规格管理', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; \yii\web\YiiAsset::register($this); ?> @@ -25,9 +25,8 @@ $this->params['breadcrumbs'][] = $this->title; 'value:ntext', 'type', 'sort_order', - 'is_delete', - 'created_at', - 'updated_at', + 'created_at:datetime', + 'updated_at:datetime', ], ]) ?> diff --git a/backend/views/brand/_form.php b/vendor/antgoods/goods/src/views/brand/_form.php similarity index 78% rename from backend/views/brand/_form.php rename to vendor/antgoods/goods/src/views/brand/_form.php index 036e9f6..fb90e37 100644 --- a/backend/views/brand/_form.php +++ b/vendor/antgoods/goods/src/views/brand/_form.php @@ -1,10 +1,10 @@ @@ -14,8 +14,6 @@ use yii\widgets\ActiveForm; field($model, 'name')->textInput(['maxlength' => true]) ?> - field($model, 'is_delete')->textInput() ?> -
'btn btn-success']) ?> 'btn btn-info']) ?> diff --git a/vendor/antgoods/goods/src/views/brand/_search.php b/vendor/antgoods/goods/src/views/brand/_search.php new file mode 100644 index 0000000..ed21354 --- /dev/null +++ b/vendor/antgoods/goods/src/views/brand/_search.php @@ -0,0 +1,49 @@ + + + ['index'], + 'method' => 'get', + 'validateOnType' => true, + ]); +?> +
+
+ field($model, 'id', [ + "template" => "{input}{error}", + "inputOptions" => [ + "placeholder" => "检索ID", + "class" => "form-control", + ], + "errorOptions" => [ + "class" => "error-tips" + ] + ]) + ?> +
+
+ field($model, "created_at_range", [ + "template" => "{input}{error}", + "inputOptions" => [ + "placeholder" => "创建时间", + ], + "errorOptions" => [ + "class" => "error-tips" + ] + ])->widget(DateRangePicker::className()); + ?> +
+
+ ', ['class' => 'btn btn-default']) ?> + ', ['class' => 'btn btn-default']) ?> +
+
+ \ No newline at end of file diff --git a/backend/views/brand/create.php b/vendor/antgoods/goods/src/views/brand/create.php similarity index 57% rename from backend/views/brand/create.php rename to vendor/antgoods/goods/src/views/brand/create.php index c768fcb..7effd14 100644 --- a/backend/views/brand/create.php +++ b/vendor/antgoods/goods/src/views/brand/create.php @@ -3,10 +3,10 @@ use yii\helpers\Html; /* @var $this yii\web\View */ -/* @var $model common\models\ars\Brand */ +/* @var $model antgoods\goods\models\ars\Brand */ -$this->title = '创建 Brand'; -$this->params['breadcrumbs'][] = ['label' => 'Brands', 'url' => ['index']]; +$this->title = '创建品牌'; +$this->params['breadcrumbs'][] = ['label' => '品牌管理', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?>
diff --git a/backend/views/brand/index.php b/vendor/antgoods/goods/src/views/brand/index.php similarity index 88% rename from backend/views/brand/index.php rename to vendor/antgoods/goods/src/views/brand/index.php index f799f7a..7f2b6ba 100644 --- a/backend/views/brand/index.php +++ b/vendor/antgoods/goods/src/views/brand/index.php @@ -1,17 +1,17 @@ title = 'Brands'; +$this->title = '品牌管理'; $this->params['breadcrumbs'][] = $this->title; ?>
-
+
$dataProvider, 'filter' => $this->render("_search", ['model' => $searchModel]), diff --git a/backend/views/brand/update.php b/vendor/antgoods/goods/src/views/brand/update.php similarity index 54% rename from backend/views/brand/update.php rename to vendor/antgoods/goods/src/views/brand/update.php index 453ee2f..6b13cfe 100644 --- a/backend/views/brand/update.php +++ b/vendor/antgoods/goods/src/views/brand/update.php @@ -3,12 +3,12 @@ use yii\helpers\Html; /* @var $this yii\web\View */ -/* @var $model common\models\ars\Brand */ +/* @var $model antgoods\goods\models\ars\Brand */ -$this->title = '编辑 Brand: ' . $model->name; -$this->params['breadcrumbs'][] = ['label' => 'Brands', 'url' => ['index']]; +$this->title = '编辑品牌: ' . $model->name; +$this->params['breadcrumbs'][] = ['label' => '品牌管理', 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]]; -$this->params['breadcrumbs'][] = 'Update '; +$this->params['breadcrumbs'][] = '编辑 '; ?>
diff --git a/backend/views/brand/view.php b/vendor/antgoods/goods/src/views/brand/view.php similarity index 70% rename from backend/views/brand/view.php rename to vendor/antgoods/goods/src/views/brand/view.php index 814b5be..a9de5d8 100644 --- a/backend/views/brand/view.php +++ b/vendor/antgoods/goods/src/views/brand/view.php @@ -4,10 +4,10 @@ use yii\helpers\Html; use yii\widgets\DetailView; /* @var $this yii\web\View */ -/* @var $model common\models\ars\Brand */ +/* @var $model antgoods\goods\models\ars\Brand */ $this->title = $model->name; -$this->params['breadcrumbs'][] = ['label' => 'Brands', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => '品牌管理', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; \yii\web\YiiAsset::register($this); ?> @@ -22,9 +22,8 @@ $this->params['breadcrumbs'][] = $this->title; 'attributes' => [ 'id', 'name', - 'is_delete', - 'created_at', - 'updated_at', + 'created_at:datetime', + 'updated_at:datetime', ], ]) ?> diff --git a/vendor/antgoods/goods/src/views/category/_form.php b/vendor/antgoods/goods/src/views/category/_form.php new file mode 100644 index 0000000..344b234 --- /dev/null +++ b/vendor/antgoods/goods/src/views/category/_form.php @@ -0,0 +1,44 @@ + + +
+ + + + field($model, 'name')->textInput(['maxlength' => true]) ?> + + field($model, 'sort_order')->textInput() ?> + + field($model, 'iconImageId')->hiddenInput()->label('') ?> + field($model, 'iconImagePath')->widget(\iron\widgets\Upload::className(), [ + 'url' => 'upload', + 'deleteUrl' => 'img-id-del', + 'dragdropWidth'=> 800, + 'afterSave' => 'save-file', + 'maxCount' => 1, + 'fillInAttribute' => 'iconImageId', + 'model' => $model, + 'previewConfig' => [ + 'url' => Url::to(['image-file', 'fileidstr' => $model->iconImageId]), + ], + ])->label('类目图片') ?> + + field($model, 'is_show')->widget(Icheck::className(), ["items" => $model::$isShow, 'type' => "radio"]) ?> + +
+ 'btn btn-success']) ?> + 'btn btn-info']) ?> +
+ + + +
diff --git a/backend/views/category/_search.php b/vendor/antgoods/goods/src/views/category/_search.php similarity index 100% rename from backend/views/category/_search.php rename to vendor/antgoods/goods/src/views/category/_search.php diff --git a/backend/views/category/create.php b/vendor/antgoods/goods/src/views/category/create.php similarity index 54% rename from backend/views/category/create.php rename to vendor/antgoods/goods/src/views/category/create.php index 932a778..a213063 100644 --- a/backend/views/category/create.php +++ b/vendor/antgoods/goods/src/views/category/create.php @@ -3,10 +3,10 @@ use yii\helpers\Html; /* @var $this yii\web\View */ -/* @var $model common\models\ars\Category */ +/* @var $model antgoods\goods\models\ars\Category */ -$this->title = '创建 Category'; -$this->params['breadcrumbs'][] = ['label' => 'Categories', 'url' => ['index']]; +$this->title = '创建后台商品分类'; +$this->params['breadcrumbs'][] = ['label' => '后台商品分类', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?>
diff --git a/backend/views/category/index.php b/vendor/antgoods/goods/src/views/category/index.php similarity index 94% rename from backend/views/category/index.php rename to vendor/antgoods/goods/src/views/category/index.php index 9c6da0b..0f5127f 100644 --- a/backend/views/category/index.php +++ b/vendor/antgoods/goods/src/views/category/index.php @@ -7,7 +7,7 @@ use iron\grid\GridView; /* @var $searchModel common\models\searchs\CategorySearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ -$this->title = 'Categories'; +$this->title = '后台商品分类'; $this->params['breadcrumbs'][] = $this->title; ?>
diff --git a/backend/views/category/update.php b/vendor/antgoods/goods/src/views/category/update.php similarity index 52% rename from backend/views/category/update.php rename to vendor/antgoods/goods/src/views/category/update.php index f492c7b..9e2753c 100644 --- a/backend/views/category/update.php +++ b/vendor/antgoods/goods/src/views/category/update.php @@ -3,12 +3,12 @@ use yii\helpers\Html; /* @var $this yii\web\View */ -/* @var $model common\models\ars\Category */ +/* @var $model antgoods\goods\models\ars\Category */ -$this->title = '编辑 Category: ' . $model->name; -$this->params['breadcrumbs'][] = ['label' => 'Categories', 'url' => ['index']]; +$this->title = '编辑后台商品分类: ' . $model->name; +$this->params['breadcrumbs'][] = ['label' => '后台商品分类', 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]]; -$this->params['breadcrumbs'][] = 'Update '; +$this->params['breadcrumbs'][] = '编辑 '; ?>
diff --git a/backend/views/category/view.php b/vendor/antgoods/goods/src/views/category/view.php similarity index 55% rename from backend/views/category/view.php rename to vendor/antgoods/goods/src/views/category/view.php index 403a436..f0ec780 100644 --- a/backend/views/category/view.php +++ b/vendor/antgoods/goods/src/views/category/view.php @@ -4,10 +4,10 @@ use yii\helpers\Html; use yii\widgets\DetailView; /* @var $this yii\web\View */ -/* @var $model common\models\ars\Category */ +/* @var $model antgoods\goods\models\ars\Category */ $this->title = $model->name; -$this->params['breadcrumbs'][] = ['label' => 'Categories', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => '后台商品分类', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; \yii\web\YiiAsset::register($this); ?> @@ -27,10 +27,14 @@ $this->params['breadcrumbs'][] = $this->title; 'sort_order', 'icon_type', 'icon', - 'is_show', - 'is_delete', - 'created_at', - 'updated_at', + [ + 'attribute' => 'is_show', + 'value' => function ($model) { + return $model->is_show == \antgoods\goods\models\ars\Category::IS_SHOW_DISPLAY ? '显示':'隐藏'; + } + ], + 'created_at:datetime', + 'updated_at:datetime', ], ]) ?> diff --git a/vendor/antgoods/goods/src/views/goods/_form.php b/vendor/antgoods/goods/src/views/goods/_form.php new file mode 100644 index 0000000..99d331c --- /dev/null +++ b/vendor/antgoods/goods/src/views/goods/_form.php @@ -0,0 +1,107 @@ + + +
+ + + + field($model, 'cat_id')->dropDownList(Category::modelColumn(), ['prompt' => '请选择']) ?> + + field($model, 'brand_id')->dropDownList(Brand::modelColumn(), ['prompt' => '请选择']) ?> + + field($model, 'shop_cat_id')->dropDownList(ShopCategory::modelColumn(), ['prompt' => '请选择']) ?> + + field($model, 'name')->textInput(['maxlength' => true]) ?> + + field($model, 'sn')->textInput(['maxlength' => true]) ?> + + field($model, 'code')->textInput(['maxlength' => true]) ?> + + field($model, 'supplier_id')->dropDownList(Supplier::modelColumn(), ['prompt' => '请选择']) ?> + + field($model, 'weight')->textInput() ?> + + field($model, 'length')->textInput() ?> + + field($model, 'width')->textInput() ?> + + field($model, 'height')->textInput() ?> + + field($model, 'diameter')->textInput() ?> + + field($model, 'unit')->textInput(['maxlength' => true]) ?> + + field($model, 'limit_count')->textInput() ?> + + field($model, 'stock')->textInput() ?> + + field($model, 'stock_warn')->textInput() ?> + + field($model, 'market_price')->textInput() ?> + + field($model, 'price')->textInput() ?> + + field($model, 'brief')->textInput(['maxlength' => true]) ?> + + field($model, 'description')->textarea(['rows' => 6]) ?> + + field($model, 'model_id')->textInput() ?> + + field($model, 'is_sale')->radioList($model::$isSale) ?> + + field($model, 'sort_order')->textInput() ?> + + field($model, 'bouns_points')->textInput() ?> + + field($model, 'experience_points')->textInput() ?> + + field($model, 'express_template')->textInput() ?> + + field($model, 'coverImageId')->hiddenInput()->label('') ?> + field($model, 'coverImagePath')->widget(\iron\widgets\Upload::className(), [ + 'url' => 'upload', + 'deleteUrl' => 'img-id-del', + 'dragdropWidth'=> 800, + 'afterSave' => 'save-file', + 'maxCount' => 1, + 'fillInAttribute' => 'coverImageId', + 'model' => $model, + 'previewConfig' => [ + 'url' => Url::to(['image-file', 'fileidstr' => $model->coverImageId]), + ], + ])->label('商品封面图') ?> + + field($model, 'detailImageId')->hiddenInput()->label('') ?> + field($model, 'detailImagePath')->widget(\iron\widgets\Upload::className(), [ + 'url' => 'upload', + 'deleteUrl' => 'img-id-del', + 'dragdropWidth'=> 800, + 'afterSave' => 'save-file', + 'maxCount' => 5, + 'fillInAttribute' => 'detailImageId', + 'model' => $model, + 'previewConfig' => [ + 'url' => Url::to(['image-file', 'fileidstr' => $model->detailImageId]), + ], + ])->label('商品详情图') ?> + +
+ 'btn btn-success']) ?> + 'btn btn-info']) ?> +
+ + + +
diff --git a/backend/views/goods/_search.php b/vendor/antgoods/goods/src/views/goods/_search.php similarity index 100% rename from backend/views/goods/_search.php rename to vendor/antgoods/goods/src/views/goods/_search.php diff --git a/backend/views/goods/create.php b/vendor/antgoods/goods/src/views/goods/create.php similarity index 57% rename from backend/views/goods/create.php rename to vendor/antgoods/goods/src/views/goods/create.php index d32b1b8..05be9b7 100644 --- a/backend/views/goods/create.php +++ b/vendor/antgoods/goods/src/views/goods/create.php @@ -3,10 +3,10 @@ use yii\helpers\Html; /* @var $this yii\web\View */ -/* @var $model common\models\ars\Goods */ +/* @var $model antgoods\goods\models\ars\Goods */ -$this->title = '创建 Goods'; -$this->params['breadcrumbs'][] = ['label' => 'Goods', 'url' => ['index']]; +$this->title = '创建商品'; +$this->params['breadcrumbs'][] = ['label' => '商品列表', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?>
diff --git a/backend/views/goods/index.php b/vendor/antgoods/goods/src/views/goods/index.php similarity index 95% rename from backend/views/goods/index.php rename to vendor/antgoods/goods/src/views/goods/index.php index 82c38b2..40421e3 100644 --- a/backend/views/goods/index.php +++ b/vendor/antgoods/goods/src/views/goods/index.php @@ -7,7 +7,7 @@ use iron\grid\GridView; /* @var $searchModel common\models\searchs\GoodsSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ -$this->title = 'Goods'; +$this->title = '商品列表'; $this->params['breadcrumbs'][] = $this->title; ?>
diff --git a/backend/views/goods/update.php b/vendor/antgoods/goods/src/views/goods/update.php similarity index 54% rename from backend/views/goods/update.php rename to vendor/antgoods/goods/src/views/goods/update.php index afaf45f..c4a3cf1 100644 --- a/backend/views/goods/update.php +++ b/vendor/antgoods/goods/src/views/goods/update.php @@ -3,12 +3,12 @@ use yii\helpers\Html; /* @var $this yii\web\View */ -/* @var $model common\models\ars\Goods */ +/* @var $model antgoods\goods\models\ars\Goods */ -$this->title = '编辑 Goods: ' . $model->name; -$this->params['breadcrumbs'][] = ['label' => 'Goods', 'url' => ['index']]; +$this->title = '编辑商品: ' . $model->name; +$this->params['breadcrumbs'][] = ['label' => '商品管理', 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]]; -$this->params['breadcrumbs'][] = 'Update '; +$this->params['breadcrumbs'][] = '编辑 '; ?>
diff --git a/backend/views/goods/view.php b/vendor/antgoods/goods/src/views/goods/view.php similarity index 85% rename from backend/views/goods/view.php rename to vendor/antgoods/goods/src/views/goods/view.php index e2a57f2..5f51770 100644 --- a/backend/views/goods/view.php +++ b/vendor/antgoods/goods/src/views/goods/view.php @@ -4,10 +4,10 @@ use yii\helpers\Html; use yii\widgets\DetailView; /* @var $this yii\web\View */ -/* @var $model common\models\ars\Goods */ +/* @var $model antgoods\goods\models\ars\Goods */ $this->title = $model->name; -$this->params['breadcrumbs'][] = ['label' => 'Goods', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => '商品管理', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; \yii\web\YiiAsset::register($this); ?> @@ -51,8 +51,8 @@ $this->params['breadcrumbs'][] = $this->title; 'experience_points', 'is_delete', 'express_template', - 'created_at', - 'updated_at', + 'created_at:datetime', + 'updated_at:datetime', ], ]) ?> diff --git a/vendor/antgoods/goods/src/views/shop-category/_form.php b/vendor/antgoods/goods/src/views/shop-category/_form.php new file mode 100644 index 0000000..9213502 --- /dev/null +++ b/vendor/antgoods/goods/src/views/shop-category/_form.php @@ -0,0 +1,52 @@ + + +
+ + + + field($model, 'name')->textInput(['maxlength' => true]) ?> + + field($model, 'keywords')->textInput(['maxlength' => true]) ?> + + field($model, 'desc')->textInput(['maxlength' => true]) ?> + + field($model, 'sort_order')->textInput() ?> + + field($model, 'iconImageId')->hiddenInput()->label('') ?> + field($model, 'iconImagePath')->widget(\iron\widgets\Upload::className(), [ + 'url' => 'upload', + 'deleteUrl' => 'img-id-del', + 'dragdropWidth'=> 800, + 'afterSave' => 'save-file', + 'maxCount' => 1, + 'fillInAttribute' => 'iconImageId', + 'model' => $model, + 'previewConfig' => [ + 'url' => Url::to(['image-file', 'fileidstr' => $model->iconImageId]), + ], + ])->label('类目图片') ?> + + field($model, 'filter_attr')->widget(Select2::className(), ["items" => Attribute::modelColumn(), "promptText" => false, 'options' => ['multiple' => true, 'placeholder' => '请选择...'] ]) ?> + + field($model, 'is_show')->widget(Icheck::className(), ["items" => $model::$isShow, 'type' => "radio"]) ?> + +
+ 'btn btn-success']) ?> + 'btn btn-info']) ?> +
+ + + +
diff --git a/backend/views/shop-category/_search.php b/vendor/antgoods/goods/src/views/shop-category/_search.php similarity index 100% rename from backend/views/shop-category/_search.php rename to vendor/antgoods/goods/src/views/shop-category/_search.php diff --git a/backend/views/shop-category/create.php b/vendor/antgoods/goods/src/views/shop-category/create.php similarity index 54% rename from backend/views/shop-category/create.php rename to vendor/antgoods/goods/src/views/shop-category/create.php index 2fe2348..ff6a2cd 100644 --- a/backend/views/shop-category/create.php +++ b/vendor/antgoods/goods/src/views/shop-category/create.php @@ -3,10 +3,10 @@ use yii\helpers\Html; /* @var $this yii\web\View */ -/* @var $model common\models\ars\ShopCategory */ +/* @var $model antgoods\goods\models\ars\ShopCategory */ -$this->title = '创建 Shop Category'; -$this->params['breadcrumbs'][] = ['label' => 'Shop Categories', 'url' => ['index']]; +$this->title = '创建前端商品分类'; +$this->params['breadcrumbs'][] = ['label' => '前端商品分类', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?>
diff --git a/backend/views/shop-category/index.php b/vendor/antgoods/goods/src/views/shop-category/index.php similarity index 87% rename from backend/views/shop-category/index.php rename to vendor/antgoods/goods/src/views/shop-category/index.php index e1a7446..af3692d 100644 --- a/backend/views/shop-category/index.php +++ b/vendor/antgoods/goods/src/views/shop-category/index.php @@ -7,7 +7,7 @@ use iron\grid\GridView; /* @var $searchModel common\models\searchs\ShopCategorySearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ -$this->title = 'Shop Categories'; +$this->title = '前端商品分类'; $this->params['breadcrumbs'][] = $this->title; ?>
@@ -18,7 +18,7 @@ $this->params['breadcrumbs'][] = $this->title; 'batch' => [ [ "label" => "删除", - "url" => "shop-category/deletes" + "url" => "shopcategory/deletes" ], ], 'columns' => $columns diff --git a/backend/views/shop-category/update.php b/vendor/antgoods/goods/src/views/shop-category/update.php similarity index 52% rename from backend/views/shop-category/update.php rename to vendor/antgoods/goods/src/views/shop-category/update.php index 93e68c8..d59515f 100644 --- a/backend/views/shop-category/update.php +++ b/vendor/antgoods/goods/src/views/shop-category/update.php @@ -3,12 +3,12 @@ use yii\helpers\Html; /* @var $this yii\web\View */ -/* @var $model common\models\ars\ShopCategory */ +/* @var $model antgoods\goods\models\ars\ShopCategory */ -$this->title = '编辑 Shop Category: ' . $model->name; -$this->params['breadcrumbs'][] = ['label' => 'Shop Categories', 'url' => ['index']]; +$this->title = '编辑前端商品分类: ' . $model->name; +$this->params['breadcrumbs'][] = ['label' => '前端商品分类', 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]]; -$this->params['breadcrumbs'][] = 'Update '; +$this->params['breadcrumbs'][] = '编辑 '; ?>
diff --git a/backend/views/shop-category/view.php b/vendor/antgoods/goods/src/views/shop-category/view.php similarity index 77% rename from backend/views/shop-category/view.php rename to vendor/antgoods/goods/src/views/shop-category/view.php index b94aaa9..7157fb0 100644 --- a/backend/views/shop-category/view.php +++ b/vendor/antgoods/goods/src/views/shop-category/view.php @@ -4,10 +4,10 @@ use yii\helpers\Html; use yii\widgets\DetailView; /* @var $this yii\web\View */ -/* @var $model common\models\ars\ShopCategory */ +/* @var $model antgoods\goods\models\ars\ShopCategory */ $this->title = $model->name; -$this->params['breadcrumbs'][] = ['label' => 'Shop Categories', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => '前端商品分类', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; \yii\web\YiiAsset::register($this); ?> @@ -32,8 +32,8 @@ $this->params['breadcrumbs'][] = $this->title; 'filter_attr:ntext', 'is_show', 'is_delete', - 'created_at', - 'updated_at', + 'created_at:datetime', + 'updated_at:datetime', ], ]) ?> diff --git a/backend/views/supplier/_form.php b/vendor/antgoods/goods/src/views/supplier/_form.php similarity index 84% rename from backend/views/supplier/_form.php rename to vendor/antgoods/goods/src/views/supplier/_form.php index dde074b..4e074b7 100644 --- a/backend/views/supplier/_form.php +++ b/vendor/antgoods/goods/src/views/supplier/_form.php @@ -1,10 +1,10 @@ @@ -20,8 +20,6 @@ use yii\widgets\ActiveForm; field($model, 'address')->textInput(['maxlength' => true]) ?> - field($model, 'is_delete')->textInput() ?> -
'btn btn-success']) ?> 'btn btn-info']) ?> diff --git a/vendor/antgoods/goods/src/views/supplier/_search.php b/vendor/antgoods/goods/src/views/supplier/_search.php new file mode 100644 index 0000000..1f00e41 --- /dev/null +++ b/vendor/antgoods/goods/src/views/supplier/_search.php @@ -0,0 +1,49 @@ + + + ['index'], + 'method' => 'get', + 'validateOnType' => true, + ]); +?> +
+
+ field($model, 'id', [ + "template" => "{input}{error}", + "inputOptions" => [ + "placeholder" => "检索ID", + "class" => "form-control", + ], + "errorOptions" => [ + "class" => "error-tips" + ] + ]) + ?> +
+
+ field($model, "created_at_range", [ + "template" => "{input}{error}", + "inputOptions" => [ + "placeholder" => "创建时间", + ], + "errorOptions" => [ + "class" => "error-tips" + ] + ])->widget(DateRangePicker::className()); + ?> +
+
+ ', ['class' => 'btn btn-default']) ?> + ', ['class' => 'btn btn-default']) ?> +
+
+ \ No newline at end of file diff --git a/backend/views/supplier/create.php b/vendor/antgoods/goods/src/views/supplier/create.php similarity index 56% rename from backend/views/supplier/create.php rename to vendor/antgoods/goods/src/views/supplier/create.php index eeb7fb0..86b9e63 100644 --- a/backend/views/supplier/create.php +++ b/vendor/antgoods/goods/src/views/supplier/create.php @@ -3,10 +3,10 @@ use yii\helpers\Html; /* @var $this yii\web\View */ -/* @var $model common\models\ars\Supplier */ +/* @var $model antgoods\goods\models\ars\Supplier */ -$this->title = '创建 Supplier'; -$this->params['breadcrumbs'][] = ['label' => 'Suppliers', 'url' => ['index']]; +$this->title = '创建供应商'; +$this->params['breadcrumbs'][] = ['label' => '供应商管理', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?>
diff --git a/backend/views/supplier/index.php b/vendor/antgoods/goods/src/views/supplier/index.php similarity index 88% rename from backend/views/supplier/index.php rename to vendor/antgoods/goods/src/views/supplier/index.php index 1c15fb2..bad1e50 100644 --- a/backend/views/supplier/index.php +++ b/vendor/antgoods/goods/src/views/supplier/index.php @@ -1,17 +1,17 @@ title = 'Suppliers'; +$this->title = '供应商管理'; $this->params['breadcrumbs'][] = $this->title; ?>
-
+
$dataProvider, 'filter' => $this->render("_search", ['model' => $searchModel]), diff --git a/backend/views/supplier/update.php b/vendor/antgoods/goods/src/views/supplier/update.php similarity index 53% rename from backend/views/supplier/update.php rename to vendor/antgoods/goods/src/views/supplier/update.php index b2b5eec..04906ee 100644 --- a/backend/views/supplier/update.php +++ b/vendor/antgoods/goods/src/views/supplier/update.php @@ -3,12 +3,12 @@ use yii\helpers\Html; /* @var $this yii\web\View */ -/* @var $model common\models\ars\Supplier */ +/* @var $model antgoods\goods\models\ars\Supplier */ -$this->title = '编辑 Supplier: ' . $model->name; -$this->params['breadcrumbs'][] = ['label' => 'Suppliers', 'url' => ['index']]; +$this->title = '编辑供应商: ' . $model->name; +$this->params['breadcrumbs'][] = ['label' => '供应商管理', 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]]; -$this->params['breadcrumbs'][] = 'Update '; +$this->params['breadcrumbs'][] = '编辑 '; ?>
diff --git a/backend/views/supplier/view.php b/vendor/antgoods/goods/src/views/supplier/view.php similarity index 72% rename from backend/views/supplier/view.php rename to vendor/antgoods/goods/src/views/supplier/view.php index 9fef302..f9a1fd2 100644 --- a/backend/views/supplier/view.php +++ b/vendor/antgoods/goods/src/views/supplier/view.php @@ -4,10 +4,10 @@ use yii\helpers\Html; use yii\widgets\DetailView; /* @var $this yii\web\View */ -/* @var $model common\models\ars\Supplier */ +/* @var $model antgoods\goods\models\ars\Supplier */ $this->title = $model->name; -$this->params['breadcrumbs'][] = ['label' => 'Suppliers', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => '供应商管理', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; \yii\web\YiiAsset::register($this); ?> @@ -25,9 +25,8 @@ $this->params['breadcrumbs'][] = $this->title; 'full_name', 'phone', 'address', - 'is_delete', - 'created_at', - 'updated_at', + 'created_at:datetime', + 'updated_at:datetime', ], ]) ?> diff --git a/vendor/iron/actions/UploadAction.php b/vendor/iron/actions/UploadAction.php index ea250fe..384b7bc 100644 --- a/vendor/iron/actions/UploadAction.php +++ b/vendor/iron/actions/UploadAction.php @@ -119,7 +119,7 @@ class UploadAction extends Action // $filePath = "$savePath/$fileName.{$fileExtension}"; // file_put_contents($filePath, $bin); } - return ['status' => true, 'path' => "uploads/$this->path$fileName.{$file->extension}"]; + return ['status' => true, 'path' => "uploads/$this->path$fileName.{$file->extension}", 'alias' => $fileName . '.' . $file->extension]; } catch (\Error $e) { throw new ServerErrorHttpException($e->getMessage()); // return ['status' => false, 'info' => $e->getMessage()]; diff --git a/vendor/iron/assets/upload/js/jquery-file-upload.min.js b/vendor/iron/assets/upload/js/jquery-file-upload.min.js index 6788a62..3f525b1 100644 --- a/vendor/iron/assets/upload/js/jquery-file-upload.min.js +++ b/vendor/iron/assets/upload/js/jquery-file-upload.min.js @@ -1 +1 @@ -(function($){if($.fn.ajaxForm==undefined){$.getScript(("https:"==document.location.protocol?"https://":"http://")+"malsup.github.io/jquery.form.js")}var feature={};feature.fileapi=$("").get(0).files!==undefined;feature.formdata=window.FormData!==undefined;$.fn.uploadFile=function(options){var s=$.extend({url:"",method:"POST",enctype:"multipart/form-data",returnType:null,allowDuplicates:true,duplicateStrict:false,allowedTypes:"*",acceptFiles:"*",fileName:"file",formData:false,dynamicFormData:false,maxFileSize:-1,maxFileCount:-1,multiple:true,dragDrop:true,autoSubmit:true,showCancel:true,showAbort:true,showDone:false,showDelete:false,showError:true,showStatusAfterSuccess:true,showStatusAfterError:true,showFileCounter:true,fileCounterStyle:"). ",showFileSize:true,showProgress:false,nestedForms:true,showDownload:false,onLoad:function(obj){},onSelect:function(files){return true},onSubmit:function(files,xhr){},onSuccess:function(files,response,xhr,pd){},onError:function(files,status,message,pd){},onCancel:function(files,pd){},onAbort:function(files,pd){},downloadCallback:false,deleteCallback:false,afterUploadAll:false,serialize:true,sequential:false,sequentialCount:2,customProgressBar:false,abortButtonClass:"ajax-file-upload-abort",cancelButtonClass:"ajax-file-upload-cancel",dragDropContainerClass:"ajax-upload-dragdrop",dragDropHoverClass:"state-hover",errorClass:"ajax-file-upload-error",uploadButtonClass:"ajax-file-upload",dragDropStr:"Drag & Drop Files",uploadStr:"Upload",abortStr:"Abort",cancelStr:"Cancel",deleteStr:"Delete",doneStr:"Done",multiDragErrorStr:"Multiple File Drag & Drop is not allowed.",extErrorStr:"is not allowed. Allowed extensions: ",duplicateErrorStr:"is not allowed. File already exists.",sizeErrorStr:"is not allowed. Allowed Max size: ",uploadErrorStr:"Upload is not allowed",maxFileCountErrorStr:" is not allowed. Maximum allowed files are:",downloadStr:"Download",customErrorKeyStr:"jquery-upload-file-error",showQueueDiv:false,statusBarWidth:400,dragdropWidth:400,showPreview:false,previewHeight:"auto",previewWidth:"100%",extraHTML:false,uploadQueueOrder:"top",headers:{}},options);this.fileCounter=1;this.selectedFiles=0;var formGroup="ajax-file-upload-"+(new Date).getTime();this.formGroup=formGroup;this.errorLog=$("
");this.responses=[];this.existingFileNames=[];if(!feature.formdata){s.dragDrop=false}if(!feature.formdata||s.maxFileCount===1){s.multiple=false}$(this).html("");var obj=this;var uploadLabel=$("
"+s.uploadStr+"
");$(uploadLabel).addClass(s.uploadButtonClass);(function checkAjaxFormLoaded(){if($.fn.ajaxForm){if(s.dragDrop){var dragDrop=$('
').width(s.dragdropWidth);$(obj).append(dragDrop);$(dragDrop).append(uploadLabel);$(dragDrop).append($(s.dragDropStr));setDragDropHandlers(obj,s,dragDrop)}else{$(obj).append(uploadLabel)}$(obj).append(obj.errorLog);if(s.showQueueDiv)obj.container=$("#"+s.showQueueDiv);else obj.container=$("
").insertAfter($(obj));s.onLoad.call(this,obj);createCustomInputFile(obj,formGroup,s,uploadLabel)}else window.setTimeout(checkAjaxFormLoaded,10)})();this.startUpload=function(){$("form").each(function(i,items){if($(this).hasClass(obj.formGroup)){mainQ.push($(this))}});if(mainQ.length>=1)submitPendingUploads()};this.getFileCount=function(){return obj.selectedFiles};this.stopUpload=function(){$("."+s.abortButtonClass).each(function(i,items){if($(this).hasClass(obj.formGroup))$(this).click()});$("."+s.cancelButtonClass).each(function(i,items){if($(this).hasClass(obj.formGroup))$(this).click()})};this.cancelAll=function(){$("."+s.cancelButtonClass).each(function(i,items){if($(this).hasClass(obj.formGroup))$(this).click()})};this.update=function(settings){s=$.extend(s,settings);if(settings.hasOwnProperty("url")){$("form").each(function(i,items){$(this).attr("action",settings["url"])})}};this.enqueueFile=function(file){if(!(file instanceof File))return;var files=[file];serializeAndUploadFiles(s,obj,files)};this.reset=function(removeStatusBars){obj.fileCounter=1;obj.selectedFiles=0;obj.errorLog.html("");if(removeStatusBars!=false){obj.container.html("")}};this.remove=function(){obj.container.html("");$(obj).remove()};this.createProgress=function(filename,filepath,filesize){var pd=new createProgressDiv(this,s);pd.progressDiv.show();pd.progressbar.width("100%");var fileNameStr="";if(s.showFileCounter)fileNameStr=obj.fileCounter+s.fileCounterStyle+filename;else fileNameStr=filename;if(s.showFileSize)fileNameStr+=" ("+getSizeStr(filesize)+")";pd.filename.html(fileNameStr);obj.fileCounter++;obj.selectedFiles++;if(s.showPreview){pd.preview.attr("src",filepath);pd.preview.show()}if(s.showDownload){pd.download.show();pd.download.click(function(){if(s.downloadCallback)s.downloadCallback.call(obj,[filename],pd)})}if(s.showDelete){pd.del.show();pd.del.click(function(){pd.statusbar.hide().remove();var arr=[filename];if(s.deleteCallback)s.deleteCallback.call(this,arr,pd);obj.selectedFiles-=1;updateFileCounter(s,obj)})}return pd};this.getResponses=function(){return this.responses};var mainQ=[];var progressQ=[];var running=false;function submitPendingUploads(){if(running)return;running=true;(function checkPendingForms(){if(!s.sequential)s.sequentialCount=99999;if(mainQ.length==0&&progressQ.length==0){if(s.afterUploadAll)s.afterUploadAll(obj);running=false}else{if(progressQ.length1){if(s.showError)$("
"+s.multiDragErrorStr+"
").appendTo(obj.errorLog);return}if(s.onSelect(files)==false)return;serializeAndUploadFiles(s,obj,files)});ddObj.on("dragleave",function(e){$(this).removeClass(s.dragDropHoverClass)});$(document).on("dragenter",function(e){e.stopPropagation();e.preventDefault()});$(document).on("dragover",function(e){e.stopPropagation();e.preventDefault();var that=$(this);if(!that.hasClass(s.dragDropContainerClass)){that.removeClass(s.dragDropHoverClass)}});$(document).on("drop",function(e){e.stopPropagation();e.preventDefault();$(this).removeClass(s.dragDropHoverClass)})}function getSizeStr(size){var sizeStr="";var sizeKB=size/1024;if(parseInt(sizeKB)>1024){var sizeMB=sizeKB/1024;sizeStr=sizeMB.toFixed(2)+" MB"}else{sizeStr=sizeKB.toFixed(2)+" KB"}return sizeStr}function serializeData(extraData){var serialized=[];if(jQuery.type(extraData)=="string"){serialized=extraData.split("&")}else{serialized=$.param(extraData).split("&")}var len=serialized.length;var result=[];var i,part;for(i=0;i"+files[i].name+" "+s.extErrorStr+s.allowedTypes+"
").appendTo(obj.errorLog);continue}if(s.maxFileSize!=-1&&files[i].size>s.maxFileSize){if(s.showError)$("
"+files[i].name+" "+s.sizeErrorStr+getSizeStr(s.maxFileSize)+"
").appendTo(obj.errorLog);continue}fd.append(fileName+"[]",files[i]);fileArray.push(files[i].name);fileListStr+=obj.fileCounter+"). "+files[i].name+"
";obj.fileCounter++}if(fileArray.length==0)return;var extraData=s.formData;if(extraData){var sData=serializeData(extraData);for(var j=0;j");form.appendTo("body");ajaxFormSubmit(form,ts,pd,fileArray,obj)}function serializeAndUploadFiles(s,obj,files){for(var i=0;i"+files[i].name+" "+s.extErrorStr+s.allowedTypes+"
").appendTo(obj.errorLog);continue}if(!s.allowDuplicates&&isFileDuplicate(obj,files[i].name)){if(s.showError)$("
"+files[i].name+" "+s.duplicateErrorStr+"
").appendTo(obj.errorLog);continue}if(s.maxFileSize!=-1&&files[i].size>s.maxFileSize){if(s.showError)$("
"+files[i].name+" "+s.sizeErrorStr+getSizeStr(s.maxFileSize)+"
").appendTo(obj.errorLog);continue}if(s.maxFileCount!=-1&&obj.selectedFiles>=s.maxFileCount){if(s.showError)$("
"+files[i].name+" "+s.maxFileCountErrorStr+s.maxFileCount+"
").appendTo(obj.errorLog);continue}obj.selectedFiles++;obj.existingFileNames.push(files[i].name);var ts=$.extend({},s);var fd=new FormData;var fileName=s.fileName.replace("[]","");fd.append(fileName,files[i]);var extraData=s.formData;if(extraData){var sData=serializeData(extraData);for(var j=0;j");form.appendTo("body");var fileArray=[];fileArray.push(files[i].name);ajaxFormSubmit(form,ts,pd,fileArray,obj,files[i]);obj.fileCounter++}}function isFileTypeAllowed(obj,s,fileName){var fileExtensions=s.allowedTypes.toLowerCase().split(/[\s,]+/g);var ext=fileName.split(".").pop().toLowerCase();if(s.allowedTypes!="*"&&jQuery.inArray(ext,fileExtensions)<0){return false}return true}function isFileDuplicate(obj,filename){var duplicate=false;if(obj.existingFileNames.length){for(var x=0;x");var fileInputStr="";if(s.multiple){if(s.fileName.indexOf("[]")!=s.fileName.length-2){s.fileName+="[]"}fileInputStr=""}var fileInput=$(fileInputStr).appendTo(form);fileInput.change(function(){obj.errorLog.html("");var fileExtensions=s.allowedTypes.toLowerCase().split(",");var fileArray=[];if(this.files){for(i=0;i"+filenameStr+" "+s.extErrorStr+s.allowedTypes+"
").appendTo(obj.errorLog);return}flist.push({name:filenameStr,size:"NA"});if(s.onSelect(flist)==false)return}updateFileCounter(s,obj);uploadLabel.unbind("click");form.hide();createCustomInputFile(obj,group,s,uploadLabel);form.addClass(group);if(s.serialize&&feature.fileapi&&feature.formdata){form.removeClass(group);var files=this.files;form.remove();serializeAndUploadFiles(s,obj,files)}else{var fileList="";for(var i=0;i";else fileList+=fileArray[i]+"
";obj.fileCounter++}if(s.maxFileCount!=-1&&obj.selectedFiles+fileArray.length>s.maxFileCount){if(s.showError)$("
"+fileList+" "+s.maxFileCountErrorStr+s.maxFileCount+"
").appendTo(obj.errorLog);return}obj.selectedFiles+=fileArray.length;var pd=new createProgressDiv(obj,s);pd.filename.html(fileList);ajaxFormSubmit(form,s,pd,fileArray,obj,null)}});if(s.nestedForms){form.css({margin:0,padding:0});uploadLabel.css({position:"relative",overflow:"hidden",cursor:"default"});fileInput.css({position:"absolute",cursor:"pointer",top:"0px",width:"100%",height:"100%",left:"0px","z-index":"100",opacity:"0.0",filter:"alpha(opacity=0)","-ms-filter":"alpha(opacity=0)","-khtml-opacity":"0.0","-moz-opacity":"0.0"});form.appendTo(uploadLabel)}else{form.appendTo($("body"));form.css({margin:0,padding:0,display:"block",position:"absolute",left:"-250px"});if(navigator.appVersion.indexOf("MSIE ")!=-1){uploadLabel.attr("for",fileUploadId)}else{uploadLabel.click(function(){fileInput.click()})}}}function defaultProgressBar(obj,s){this.statusbar=$("
").width(s.statusBarWidth);this.preview=$("").width(s.previewWidth).height(s.previewHeight).appendTo(this.statusbar).hide();this.filename=$("
").appendTo(this.statusbar);this.progressDiv=$("
").appendTo(this.statusbar).hide();this.progressbar=$("
").appendTo(this.progressDiv);this.abort=$("
"+s.abortStr+"
").appendTo(this.statusbar).hide();this.cancel=$("
"+s.cancelStr+"
").appendTo(this.statusbar).hide();this.done=$("
"+s.doneStr+"
").appendTo(this.statusbar).hide();this.download=$("
"+s.downloadStr+"
").appendTo(this.statusbar).hide();this.del=$("
"+s.deleteStr+"
").appendTo(this.statusbar).hide();this.abort.addClass("ajax-file-upload-red");this.done.addClass("ajax-file-upload-green");this.download.addClass("ajax-file-upload-green");this.cancel.addClass("ajax-file-upload-red");this.del.addClass("ajax-file-upload-red");return this}function createProgressDiv(obj,s){var bar=null;if(s.customProgressBar)bar=new s.customProgressBar(obj,s);else bar=new defaultProgressBar(obj,s);bar.abort.addClass(obj.formGroup);bar.abort.addClass(s.abortButtonClass);bar.cancel.addClass(obj.formGroup);bar.cancel.addClass(s.cancelButtonClass);if(s.extraHTML)bar.extraHTML=$("
"+s.extraHTML()+"
").insertAfter(bar.filename);if(s.uploadQueueOrder=="bottom")$(obj.container).append(bar.statusbar);else $(obj.container).prepend(bar.statusbar);return bar}function ajaxFormSubmit(form,s,pd,fileArray,obj,file){var currentXHR=null;var options={cache:false,contentType:false,processData:false,forceSync:false,type:s.method,data:s.formData,formData:s.fileData,dataType:s.returnType,headers:s.headers,beforeSubmit:function(formData,$form,options){if(s.onSubmit.call(this,fileArray)!=false){if(s.dynamicFormData){var sData=serializeData(s.dynamicFormData());if(sData){for(var j=0;j"+s.uploadErrorStr+"
");pd.cancel.show();form.remove();pd.cancel.click(function(){mainQ.splice(mainQ.indexOf(form),1);removeExistingFileName(obj,fileArray);pd.statusbar.remove();s.onCancel.call(obj,fileArray,pd);obj.selectedFiles-=fileArray.length;updateFileCounter(s,obj)});return false},beforeSend:function(xhr,o){for(var key in o.headers){xhr.setRequestHeader(key,o.headers[key])}pd.progressDiv.show();pd.cancel.hide();pd.done.hide();if(s.showAbort){pd.abort.show();pd.abort.click(function(){removeExistingFileName(obj,fileArray);xhr.abort();obj.selectedFiles-=fileArray.length;s.onAbort.call(obj,fileArray,pd)})}if(!feature.formdata){pd.progressbar.width("5%")}else pd.progressbar.width("1%")},uploadProgress:function(event,position,total,percentComplete){if(percentComplete>98)percentComplete=98;var percentVal=percentComplete+"%";if(percentComplete>1)pd.progressbar.width(percentVal);if(s.showProgress){pd.progressbar.html(percentVal);pd.progressbar.css("text-align","center")}},success:function(data,message,xhr){pd.cancel.remove();progressQ.pop();if(s.returnType=="json"&&$.type(data)=="object"&&data.hasOwnProperty(s.customErrorKeyStr)){pd.abort.hide();var msg=data[s.customErrorKeyStr];s.onError.call(this,fileArray,200,msg,pd);if(s.showStatusAfterError){pd.progressDiv.hide();pd.statusbar.append("ERROR: "+msg+"")}else{pd.statusbar.hide();pd.statusbar.remove()}obj.selectedFiles-=fileArray.length;form.remove();return}obj.responses.push(data);pd.progressbar.width("100%");if(s.showProgress){pd.progressbar.html("100%");pd.progressbar.css("text-align","center")}pd.abort.hide();s.onSuccess.call(this,fileArray,data,xhr,pd);if(s.showStatusAfterSuccess){if(s.showDone){pd.done.show();pd.done.click(function(){pd.statusbar.hide("slow");pd.statusbar.remove()})}else{pd.done.hide()}if(s.showDelete){pd.del.show();pd.del.click(function(){removeExistingFileName(obj,fileArray);pd.statusbar.hide().remove();if(s.deleteCallback)s.deleteCallback.call(this,data,pd);obj.selectedFiles-=fileArray.length;updateFileCounter(s,obj)})}else{pd.del.hide()}}else{pd.statusbar.hide("slow");pd.statusbar.remove()}if(s.showDownload){pd.download.show();pd.download.click(function(){if(s.downloadCallback)s.downloadCallback(data,pd)})}form.remove()},error:function(xhr,status,errMsg){pd.cancel.remove();progressQ.pop();pd.abort.hide();if(xhr.statusText=="abort"){pd.statusbar.hide("slow").remove();updateFileCounter(s,obj)}else{s.onError.call(this,fileArray,status,errMsg,pd);if(s.showStatusAfterError){pd.progressDiv.hide();pd.statusbar.append("ERROR: "+errMsg+"")}else{pd.statusbar.hide();pd.statusbar.remove()}obj.selectedFiles-=fileArray.length}form.remove()}};if(s.showPreview&&file!=null){if(file.type.toLowerCase().split("/").shift()=="image")getSrcToPreview(file,pd.preview)}if(s.autoSubmit){form.ajaxForm(options);mainQ.push(form);submitPendingUploads()}else{if(s.showCancel){pd.cancel.show();pd.cancel.click(function(){mainQ.splice(mainQ.indexOf(form),1);removeExistingFileName(obj,fileArray);form.remove();pd.statusbar.remove();s.onCancel.call(obj,fileArray,pd);obj.selectedFiles-=fileArray.length;updateFileCounter(s,obj)})}form.ajaxForm(options)}}return this};var getUrlParameter=function getUrlParameter(sParam){var sPageURL=window.location.search.substring(1),sURLVariables=sPageURL.split("&"),sParameterName,i;for(i=0;i").get(0).files!==undefined;feature.formdata=window.FormData!==undefined;$.fn.uploadFile=function(options){var s=$.extend({url:"",method:"POST",enctype:"multipart/form-data",returnType:null,allowDuplicates:true,duplicateStrict:false,allowedTypes:"*",acceptFiles:"*",fileName:"file",formData:false,dynamicFormData:false,maxFileSize:-1,maxFileCount:-1,multiple:true,dragDrop:true,autoSubmit:true,showCancel:true,showAbort:true,showDone:false,showDelete:false,showError:true,showStatusAfterSuccess:true,showStatusAfterError:true,showFileCounter:true,fileCounterStyle:"). ",showFileSize:true,showProgress:false,nestedForms:true,showDownload:false,onLoad:function(obj){},onSelect:function(files){return true},onSubmit:function(files,xhr){},onSuccess:function(files,response,xhr,pd){},onError:function(files,status,message,pd){},onCancel:function(files,pd){},onAbort:function(files,pd){},downloadCallback:false,deleteCallback:false,afterUploadAll:false,serialize:true,sequential:false,sequentialCount:2,customProgressBar:false,abortButtonClass:"ajax-file-upload-abort",cancelButtonClass:"ajax-file-upload-cancel",dragDropContainerClass:"ajax-upload-dragdrop",dragDropHoverClass:"state-hover",errorClass:"ajax-file-upload-error",uploadButtonClass:"ajax-file-upload",dragDropStr:"Drag & Drop Files",uploadStr:"Upload",abortStr:"Abort",cancelStr:"Cancel",deleteStr:"Delete",doneStr:"Done",multiDragErrorStr:"Multiple File Drag & Drop is not allowed.",extErrorStr:"is not allowed. Allowed extensions: ",duplicateErrorStr:"is not allowed. File already exists.",sizeErrorStr:"is not allowed. Allowed Max size: ",uploadErrorStr:"Upload is not allowed",maxFileCountErrorStr:" is not allowed. Maximum allowed files are:",downloadStr:"Download",customErrorKeyStr:"jquery-upload-file-error",showQueueDiv:false,statusBarWidth:400,dragdropWidth:400,showPreview:false,previewHeight:"auto",previewWidth:"100%",extraHTML:false,uploadQueueOrder:"top",headers:{}},options);this.fileCounter=1;this.selectedFiles=0;var formGroup="ajax-file-upload-"+(new Date).getTime();this.formGroup=formGroup;this.errorLog=$("
");this.responses=[];this.existingFileNames=[];if(!feature.formdata){s.dragDrop=false}if(!feature.formdata||s.maxFileCount===1){s.multiple=false}$(this).html("");var obj=this;var uploadLabel=$("
"+s.uploadStr+"
");$(uploadLabel).addClass(s.uploadButtonClass);(function checkAjaxFormLoaded(){if($.fn.ajaxForm){if(s.dragDrop){var dragDrop=$('
').width(s.dragdropWidth);$(obj).append(dragDrop);$(dragDrop).append(uploadLabel);$(dragDrop).append($(s.dragDropStr));setDragDropHandlers(obj,s,dragDrop)}else{$(obj).append(uploadLabel)}$(obj).append(obj.errorLog);if(s.showQueueDiv)obj.container=$("#"+s.showQueueDiv);else obj.container=$("
").insertAfter($(obj));s.onLoad.call(this,obj);createCustomInputFile(obj,formGroup,s,uploadLabel)}else window.setTimeout(checkAjaxFormLoaded,10)})();this.startUpload=function(){$("form").each(function(i,items){if($(this).hasClass(obj.formGroup)){mainQ.push($(this))}});if(mainQ.length>=1)submitPendingUploads()};this.getFileCount=function(){return obj.selectedFiles};this.stopUpload=function(){$("."+s.abortButtonClass).each(function(i,items){if($(this).hasClass(obj.formGroup))$(this).click()});$("."+s.cancelButtonClass).each(function(i,items){if($(this).hasClass(obj.formGroup))$(this).click()})};this.cancelAll=function(){$("."+s.cancelButtonClass).each(function(i,items){if($(this).hasClass(obj.formGroup))$(this).click()})};this.update=function(settings){s=$.extend(s,settings);if(settings.hasOwnProperty("url")){$("form").each(function(i,items){$(this).attr("action",settings["url"])})}};this.enqueueFile=function(file){if(!(file instanceof File))return;var files=[file];serializeAndUploadFiles(s,obj,files)};this.reset=function(removeStatusBars){obj.fileCounter=1;obj.selectedFiles=0;obj.errorLog.html("");if(removeStatusBars!=false){obj.container.html("")}};this.remove=function(){obj.container.html("");$(obj).remove()};this.createProgress=function(filename,filepath,filesize){var pd=new createProgressDiv(this,s);pd.progressDiv.show();pd.progressbar.width("100%");var fileNameStr="";if(s.showFileCounter)fileNameStr=obj.fileCounter+s.fileCounterStyle+filename;else fileNameStr=filename;if(s.showFileSize)fileNameStr+=" ("+getSizeStr(filesize)+")";pd.filename.html(fileNameStr);obj.fileCounter++;obj.selectedFiles++;if(s.showPreview){pd.preview.attr("src",filepath);pd.preview.show()}if(s.showDownload){pd.download.show();pd.download.click(function(){if(s.downloadCallback)s.downloadCallback.call(obj,[filename],pd)})}if(s.showDelete){pd.del.show();pd.del.click(function(){pd.statusbar.hide().remove();var arr=[filename];if(s.deleteCallback)s.deleteCallback.call(this,arr,pd);obj.selectedFiles-=1;updateFileCounter(s,obj)})}return pd};this.getResponses=function(){return this.responses};var mainQ=[];var progressQ=[];var running=false;function submitPendingUploads(){if(running)return;running=true;(function checkPendingForms(){if(!s.sequential)s.sequentialCount=99999;if(mainQ.length==0&&progressQ.length==0){if(s.afterUploadAll)s.afterUploadAll(obj);running=false}else{if(progressQ.length1){if(s.showError)$("
"+s.multiDragErrorStr+"
").appendTo(obj.errorLog);return}if(s.onSelect(files)==false)return;serializeAndUploadFiles(s,obj,files)});ddObj.on("dragleave",function(e){$(this).removeClass(s.dragDropHoverClass)});$(document).on("dragenter",function(e){e.stopPropagation();e.preventDefault()});$(document).on("dragover",function(e){e.stopPropagation();e.preventDefault();var that=$(this);if(!that.hasClass(s.dragDropContainerClass)){that.removeClass(s.dragDropHoverClass)}});$(document).on("drop",function(e){e.stopPropagation();e.preventDefault();$(this).removeClass(s.dragDropHoverClass)})}function getSizeStr(size){var sizeStr="";var sizeKB=size/1024;if(parseInt(sizeKB)>1024){var sizeMB=sizeKB/1024;sizeStr=sizeMB.toFixed(2)+" MB"}else{sizeStr=sizeKB.toFixed(2)+" KB"}return sizeStr}function serializeData(extraData){var serialized=[];if(jQuery.type(extraData)=="string"){serialized=extraData.split("&")}else{serialized=$.param(extraData).split("&")}var len=serialized.length;var result=[];var i,part;for(i=0;i"+files[i].name+" "+s.extErrorStr+s.allowedTypes+"
").appendTo(obj.errorLog);continue}if(s.maxFileSize!=-1&&files[i].size>s.maxFileSize){if(s.showError)$("
"+files[i].name+" "+s.sizeErrorStr+getSizeStr(s.maxFileSize)+"
").appendTo(obj.errorLog);continue}fd.append(fileName+"[]",files[i]);fileArray.push(files[i].name);fileListStr+=obj.fileCounter+"). "+files[i].name+"
";obj.fileCounter++}if(fileArray.length==0)return;var extraData=s.formData;if(extraData){var sData=serializeData(extraData);for(var j=0;j");form.appendTo("body");ajaxFormSubmit(form,ts,pd,fileArray,obj)}function serializeAndUploadFiles(s,obj,files){for(var i=0;i"+files[i].name+" "+s.extErrorStr+s.allowedTypes+"
").appendTo(obj.errorLog);continue}if(!s.allowDuplicates&&isFileDuplicate(obj,files[i].name)){if(s.showError)$("
"+files[i].name+" "+s.duplicateErrorStr+"
").appendTo(obj.errorLog);continue}if(s.maxFileSize!=-1&&files[i].size>s.maxFileSize){if(s.showError)$("
"+files[i].name+" "+s.sizeErrorStr+getSizeStr(s.maxFileSize)+"
").appendTo(obj.errorLog);continue}if(s.maxFileCount!=-1&&obj.selectedFiles>=s.maxFileCount){if(s.showError)$("
"+files[i].name+" "+s.maxFileCountErrorStr+s.maxFileCount+"
").appendTo(obj.errorLog);continue}obj.selectedFiles++;obj.existingFileNames.push(files[i].name);var ts=$.extend({},s);var fd=new FormData;var fileName=s.fileName.replace("[]","");fd.append(fileName,files[i]);var extraData=s.formData;if(extraData){var sData=serializeData(extraData);for(var j=0;j");form.appendTo("body");var fileArray=[];fileArray.push(files[i].name);ajaxFormSubmit(form,ts,pd,fileArray,obj,files[i]);obj.fileCounter++}}function isFileTypeAllowed(obj,s,fileName){var fileExtensions=s.allowedTypes.toLowerCase().split(/[\s,]+/g);var ext=fileName.split(".").pop().toLowerCase();if(s.allowedTypes!="*"&&jQuery.inArray(ext,fileExtensions)<0){return false}return true}function isFileDuplicate(obj,filename){var duplicate=false;if(obj.existingFileNames.length){for(var x=0;x");var fileInputStr="";if(s.multiple){if(s.fileName.indexOf("[]")!=s.fileName.length-2){s.fileName+="[]"}fileInputStr=""}var fileInput=$(fileInputStr).appendTo(form);fileInput.change(function(){obj.errorLog.html("");var fileExtensions=s.allowedTypes.toLowerCase().split(",");var fileArray=[];if(this.files){for(i=0;i"+filenameStr+" "+s.extErrorStr+s.allowedTypes+"
").appendTo(obj.errorLog);return}flist.push({name:filenameStr,size:"NA"});if(s.onSelect(flist)==false)return}updateFileCounter(s,obj);uploadLabel.unbind("click");form.hide();createCustomInputFile(obj,group,s,uploadLabel);form.addClass(group);if(s.serialize&&feature.fileapi&&feature.formdata){form.removeClass(group);var files=this.files;form.remove();serializeAndUploadFiles(s,obj,files)}else{var fileList="";for(var i=0;i";else fileList+=fileArray[i]+"
";obj.fileCounter++}if(s.maxFileCount!=-1&&obj.selectedFiles+fileArray.length>s.maxFileCount){if(s.showError)$("
"+fileList+" "+s.maxFileCountErrorStr+s.maxFileCount+"
").appendTo(obj.errorLog);return}obj.selectedFiles+=fileArray.length;var pd=new createProgressDiv(obj,s);pd.filename.html(fileList);ajaxFormSubmit(form,s,pd,fileArray,obj,null)}});if(s.nestedForms){form.css({margin:0,padding:0});uploadLabel.css({position:"relative",overflow:"hidden",cursor:"default"});fileInput.css({position:"absolute",cursor:"pointer",top:"0px",width:"100%",height:"100%",left:"0px","z-index":"100",opacity:"0.0",filter:"alpha(opacity=0)","-ms-filter":"alpha(opacity=0)","-khtml-opacity":"0.0","-moz-opacity":"0.0"});form.appendTo(uploadLabel)}else{form.appendTo($("body"));form.css({margin:0,padding:0,display:"block",position:"absolute",left:"-250px"});if(navigator.appVersion.indexOf("MSIE ")!=-1){uploadLabel.attr("for",fileUploadId)}else{uploadLabel.click(function(){fileInput.click()})}}}function defaultProgressBar(obj,s){this.statusbar=$("
").width(s.statusBarWidth);this.preview=$("").width(s.previewWidth).height(s.previewHeight).appendTo(this.statusbar).hide();this.filename=$("
").appendTo(this.statusbar);this.progressDiv=$("
").appendTo(this.statusbar).hide();this.progressbar=$("
").appendTo(this.progressDiv);this.abort=$("
"+s.abortStr+"
").appendTo(this.statusbar).hide();this.cancel=$("
"+s.cancelStr+"
").appendTo(this.statusbar).hide();this.done=$("
"+s.doneStr+"
").appendTo(this.statusbar).hide();this.download=$("
"+s.downloadStr+"
").appendTo(this.statusbar).hide();this.del=$("
"+s.deleteStr+"
").appendTo(this.statusbar).hide();this.abort.addClass("ajax-file-upload-red");this.done.addClass("ajax-file-upload-green");this.download.addClass("ajax-file-upload-green");this.cancel.addClass("ajax-file-upload-red");this.del.addClass("ajax-file-upload-red");return this}function createProgressDiv(obj,s){var bar=null;if(s.customProgressBar)bar=new s.customProgressBar(obj,s);else bar=new defaultProgressBar(obj,s);bar.abort.addClass(obj.formGroup);bar.abort.addClass(s.abortButtonClass);bar.cancel.addClass(obj.formGroup);bar.cancel.addClass(s.cancelButtonClass);if(s.extraHTML)bar.extraHTML=$("
"+s.extraHTML()+"
").insertAfter(bar.filename);if(s.uploadQueueOrder=="bottom")$(obj.container).append(bar.statusbar);else $(obj.container).prepend(bar.statusbar);return bar}function ajaxFormSubmit(form,s,pd,fileArray,obj,file){var currentXHR=null;var options={cache:false,contentType:false,processData:false,forceSync:false,type:s.method,data:s.formData,formData:s.fileData,dataType:s.returnType,headers:s.headers,beforeSubmit:function(formData,$form,options){if(s.onSubmit.call(this,fileArray)!=false){if(s.dynamicFormData){var sData=serializeData(s.dynamicFormData());if(sData){for(var j=0;j"+s.uploadErrorStr+"
");pd.cancel.show();form.remove();pd.cancel.click(function(){mainQ.splice(mainQ.indexOf(form),1);removeExistingFileName(obj,fileArray);pd.statusbar.remove();s.onCancel.call(obj,fileArray,pd);obj.selectedFiles-=fileArray.length;updateFileCounter(s,obj)});return false},beforeSend:function(xhr,o){for(var key in o.headers){xhr.setRequestHeader(key,o.headers[key])}pd.progressDiv.show();pd.cancel.hide();pd.done.hide();if(s.showAbort){pd.abort.show();pd.abort.click(function(){removeExistingFileName(obj,fileArray);xhr.abort();obj.selectedFiles-=fileArray.length;s.onAbort.call(obj,fileArray,pd)})}if(!feature.formdata){pd.progressbar.width("5%")}else pd.progressbar.width("1%")},uploadProgress:function(event,position,total,percentComplete){if(percentComplete>98)percentComplete=98;var percentVal=percentComplete+"%";if(percentComplete>1)pd.progressbar.width(percentVal);if(s.showProgress){pd.progressbar.html(percentVal);pd.progressbar.css("text-align","center")}},success:function(data,message,xhr){pd.cancel.remove();progressQ.pop();if(s.returnType=="json"&&$.type(data)=="object"&&data.hasOwnProperty(s.customErrorKeyStr)){pd.abort.hide();var msg=data[s.customErrorKeyStr];s.onError.call(this,fileArray,200,msg,pd);if(s.showStatusAfterError){pd.progressDiv.hide();pd.statusbar.append("ERROR: "+msg+"")}else{pd.statusbar.hide();pd.statusbar.remove()}obj.selectedFiles-=fileArray.length;form.remove();return}obj.responses.push(data);pd.progressbar.width("100%");if(s.showProgress){pd.progressbar.html("100%");pd.progressbar.css("text-align","center")}pd.abort.hide();s.onSuccess.call(this,fileArray,data,xhr,pd);if(s.showStatusAfterSuccess){if(s.showDone){pd.done.show();pd.done.click(function(){pd.statusbar.hide("slow");pd.statusbar.remove()})}else{pd.done.hide()}if(s.showDelete){pd.del.show();pd.del.click(function(){removeExistingFileName(obj,fileArray);pd.statusbar.hide().remove();if(s.deleteCallback)s.deleteCallback.call(this,data,pd);obj.selectedFiles-=fileArray.length;updateFileCounter(s,obj)})}else{pd.del.hide()}}else{pd.statusbar.hide("slow");pd.statusbar.remove()}if(s.showDownload){pd.download.show();pd.download.click(function(){if(s.downloadCallback)s.downloadCallback(data,pd)})}form.remove()},error:function(xhr,status,errMsg){pd.cancel.remove();progressQ.pop();pd.abort.hide();if(xhr.statusText=="abort"){pd.statusbar.hide("slow").remove();updateFileCounter(s,obj)}else{s.onError.call(this,fileArray,status,errMsg,pd);if(s.showStatusAfterError){pd.progressDiv.hide();pd.statusbar.append("ERROR: "+errMsg+"")}else{pd.statusbar.hide();pd.statusbar.remove()}obj.selectedFiles-=fileArray.length}form.remove()}};if(s.showPreview&&file!=null){if(file.type.toLowerCase().split("/").shift()=="image")getSrcToPreview(file,pd.preview)}if(s.autoSubmit){form.ajaxForm(options);mainQ.push(form);submitPendingUploads()}else{if(s.showCancel){pd.cancel.show();pd.cancel.click(function(){mainQ.splice(mainQ.indexOf(form),1);removeExistingFileName(obj,fileArray);form.remove();pd.statusbar.remove();s.onCancel.call(obj,fileArray,pd);obj.selectedFiles-=fileArray.length;updateFileCounter(s,obj)})}form.ajaxForm(options)}}return this};var getUrlParameter=function getUrlParameter(sParam){var sPageURL=window.location.search.substring(1),sURLVariables=sPageURL.split("&"),sParameterName,i;for(i=0;i").get(0).files !== undefined; + feature.formdata = window.FormData !== undefined; + + var hasProp = !!$.fn.prop; + +// attr2 uses prop when it can but checks the return type for +// an expected string. this accounts for the case where a form +// contains inputs with names like "action" or "method"; in those +// cases "prop" returns the element + $.fn.attr2 = function() { + if ( ! hasProp ) { + return this.attr.apply(this, arguments); + } + var val = this.prop.apply(this, arguments); + if ( ( val && val.jquery ) || typeof val === 'string' ) { + return val; + } + return this.attr.apply(this, arguments); + }; + + /** + * ajaxSubmit() provides a mechanism for immediately submitting + * an HTML form using AJAX. + */ + $.fn.ajaxSubmit = function(options) { + /*jshint scripturl:true */ + + // fast fail if nothing selected (http://dev.jquery.com/ticket/2752) + if (!this.length) { + log('ajaxSubmit: skipping submit process - no element selected'); + return this; + } + + var method, action, url, $form = this; + + if (typeof options == 'function') { + options = { success: options }; + } + else if ( options === undefined ) { + options = {}; + } + + method = options.type || this.attr2('method'); + action = options.url || this.attr2('action'); + + url = (typeof action === 'string') ? $.trim(action) : ''; + url = url || window.location.href || ''; + if (url) { + // clean url (don't include hash vaue) + url = (url.match(/^([^#]+)/)||[])[1]; + } + + options = $.extend(true, { + url: url, + success: $.ajaxSettings.success, + type: method || $.ajaxSettings.type, + iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank' + }, options); + + // hook for manipulating the form data before it is extracted; + // convenient for use with rich editors like tinyMCE or FCKEditor + var veto = {}; + this.trigger('form-pre-serialize', [this, options, veto]); + if (veto.veto) { + log('ajaxSubmit: submit vetoed via form-pre-serialize trigger'); + return this; + } + + // provide opportunity to alter form data before it is serialized + if (options.beforeSerialize && options.beforeSerialize(this, options) === false) { + log('ajaxSubmit: submit aborted via beforeSerialize callback'); + return this; + } + + var traditional = options.traditional; + if ( traditional === undefined ) { + traditional = $.ajaxSettings.traditional; + } + + var elements = []; + var qx, a = this.formToArray(options.semantic, elements); + if (options.data) { + options.extraData = options.data; + qx = $.param(options.data, traditional); + } + + // give pre-submit callback an opportunity to abort the submit + if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) { + log('ajaxSubmit: submit aborted via beforeSubmit callback'); + return this; + } + + // fire vetoable 'validate' event + this.trigger('form-submit-validate', [a, this, options, veto]); + if (veto.veto) { + log('ajaxSubmit: submit vetoed via form-submit-validate trigger'); + return this; + } + + var q = $.param(a, traditional); + if (qx) { + q = ( q ? (q + '&' + qx) : qx ); + } + if (options.type.toUpperCase() == 'GET') { + options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q; + options.data = null; // data is null for 'get' + } + else { + options.data = q; // data is the query string for 'post' + } + + var callbacks = []; + if (options.resetForm) { + callbacks.push(function() { $form.resetForm(); }); + } + if (options.clearForm) { + callbacks.push(function() { $form.clearForm(options.includeHidden); }); + } + + // perform a load on the target only if dataType is not provided + if (!options.dataType && options.target) { + var oldSuccess = options.success || function(){}; + callbacks.push(function(data) { + var fn = options.replaceTarget ? 'replaceWith' : 'html'; + $(options.target)[fn](data).each(oldSuccess, arguments); + }); + } + else if (options.success) { + callbacks.push(options.success); + } + + options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg + var context = options.context || this ; // jQuery 1.4+ supports scope context + for (var i=0, max=callbacks.length; i < max; i++) { + callbacks[i].apply(context, [data, status, xhr || $form, $form]); + } + }; + + if (options.error) { + var oldError = options.error; + options.error = function(xhr, status, error) { + var context = options.context || this; + oldError.apply(context, [xhr, status, error, $form]); + }; + } + + if (options.complete) { + var oldComplete = options.complete; + options.complete = function(xhr, status) { + var context = options.context || this; + oldComplete.apply(context, [xhr, status, $form]); + }; + } + + // are there files to upload? + + // [value] (issue #113), also see comment: + // https://github.com/malsup/form/commit/588306aedba1de01388032d5f42a60159eea9228#commitcomment-2180219 + var fileInputs = $('input[type=file]:enabled', this).filter(function() { return $(this).val() !== ''; }); + + var hasFileInputs = fileInputs.length > 0; + var mp = 'multipart/form-data'; + var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp); + + var fileAPI = feature.fileapi && feature.formdata; + log("fileAPI :" + fileAPI); + var shouldUseFrame = (hasFileInputs || multipart) && !fileAPI; + + var jqxhr; + + // options.iframe allows user to force iframe mode + // 06-NOV-09: now defaulting to iframe mode if file input is detected + if (options.iframe !== false && (options.iframe || shouldUseFrame)) { + // hack to fix Safari hang (thanks to Tim Molendijk for this) + // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d + if (options.closeKeepAlive) { + $.get(options.closeKeepAlive, function() { + jqxhr = fileUploadIframe(a); + }); + } + else { + jqxhr = fileUploadIframe(a); + } + } + else if ((hasFileInputs || multipart) && fileAPI) { + jqxhr = fileUploadXhr(a); + } + else { + jqxhr = $.ajax(options); + } + + $form.removeData('jqxhr').data('jqxhr', jqxhr); + + // clear element array + for (var k=0; k < elements.length; k++) { + elements[k] = null; + } + + // fire 'notify' event + this.trigger('form-submit-notify', [this, options]); + return this; + + // utility fn for deep serialization + function deepSerialize(extraData){ + var serialized = $.param(extraData, options.traditional).split('&'); + var len = serialized.length; + var result = []; + var i, part; + for (i=0; i < len; i++) { + // #252; undo param space replacement + serialized[i] = serialized[i].replace(/\+/g,' '); + part = serialized[i].split('='); + // #278; use array instead of object storage, favoring array serializations + result.push([decodeURIComponent(part[0]), decodeURIComponent(part[1])]); + } + return result; + } + + // XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz) + function fileUploadXhr(a) { + var formdata = new FormData(); + + for (var i=0; i < a.length; i++) { + formdata.append(a[i].name, a[i].value); + } + + if (options.extraData) { + var serializedData = deepSerialize(options.extraData); + for (i=0; i < serializedData.length; i++) { + if (serializedData[i]) { + formdata.append(serializedData[i][0], serializedData[i][1]); + } + } + } + + options.data = null; + + var s = $.extend(true, {}, $.ajaxSettings, options, { + contentType: false, + processData: false, + cache: false, + type: method || 'POST' + }); + + if (options.uploadProgress) { + // workaround because jqXHR does not expose upload property + s.xhr = function() { + var xhr = $.ajaxSettings.xhr(); + if (xhr.upload) { + xhr.upload.addEventListener('progress', function(event) { + var percent = 0; + var position = event.loaded || event.position; /*event.position is deprecated*/ + var total = event.total; + if (event.lengthComputable) { + percent = Math.ceil(position / total * 100); + } + options.uploadProgress(event, position, total, percent); + }, false); + } + return xhr; + }; + } + + s.data = null; + var beforeSend = s.beforeSend; + s.beforeSend = function(xhr, o) { + //Send FormData() provided by user + if (options.formData) { + o.data = options.formData; + } + else { + o.data = formdata; + } + if(beforeSend) { + beforeSend.call(this, xhr, o); + } + }; + return $.ajax(s); + } + + // private function for handling file uploads (hat tip to YAHOO!) + function fileUploadIframe(a) { + var form = $form[0], el, i, s, g, id, $io, io, xhr, sub, n, timedOut, timeoutHandle; + var deferred = $.Deferred(); + + // #341 + deferred.abort = function(status) { + xhr.abort(status); + }; + + if (a) { + // ensure that every serialized input is still enabled + for (i=0; i < elements.length; i++) { + el = $(elements[i]); + if ( hasProp ) { + el.prop('disabled', false); + } + else { + el.removeAttr('disabled'); + } + } + } + + s = $.extend(true, {}, $.ajaxSettings, options); + s.context = s.context || s; + id = 'jqFormIO' + (new Date().getTime()); + if (s.iframeTarget) { + $io = $(s.iframeTarget); + n = $io.attr2('name'); + if (!n) { + $io.attr2('name', id); + } + else { + id = n; + } + } + else { + $io = $('