123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- <?php
- namespace backend\controllers;
- use backend\models\AuthArea;
- use common\models\Design;
- use common\models\Offer;
- use yii;
- use yii\filters\AccessControl;
- /**
- * 免费报价/设计
- * @package backend\controllers
- */
- class OfferdesignController extends BaseController
- {
- public $layout = 'iframe';
- const PAGESIZE = 20;//分页数
- public function behaviors()
- {
- return [
- 'access' => [
- 'class' => AccessControl::className(),
- 'rules' => [
- [
- 'actions' => [],
- 'allow' => true,
- 'roles' => ['@'],
- ],
- ],
- ],
- ];
- }
- /**
- *报价列表
- * @return string
- */
- public function actionOffer()
- {
- $search =['start'=>'','end'=>''];
- $search['start'] = Yii::$app->request->get('start');
- $search['end'] = Yii::$app->request->get('end');
- $models = Offer::find()->where(['status'=>Offer::STATUS_YES]);
- if(!empty($search['start']))
- $models->andWhere("c_time > :start",[':start'=>strtotime($search['start'])]);
- if(!empty($search['end']))
- $models->andWhere("c_time < :end",[':end'=>strtotime($search['end'])+(3600*24-1)]);
- $citys = AuthArea::queryAuth();
- if($citys=='all')
- $models;
- elseif (!empty($citys))
- $models->andWhere("area_id in ({$citys})");
- else
- $models->andWhere("area_id = -1");
- $pages = new yii\data\Pagination(["totalCount" => $models->count(), "pageSize" => self::PAGESIZE]);
- $models = $models->offset($pages->offset)->limit($pages->limit)->orderBy("id DESC")->all();
- return $this->render('offer', ['models' => $models, 'pages' => $pages,'name'=>'免费报价列表','search'=>$search]);
- }
- /**
- * 删除报价
- */
- public function actionDelOffer()
- {
- $id = Yii::$app->request->post('id');
- $model = Offer::find()->where(['id'=>$id])->one();
- $result = ['sign'=>1,'msg'=>'删除成功'];
- if(!empty($model))
- {
- $model->status = Offer::STATUS_NO;
- if(!$model->save())
- $result= ['sign'=>0,'msg'=>'删除失败'];
- }else{
- $result= ['sign'=>0,'msg'=>'找不到该记录'];
- }
- return json_encode($result);
- }
- /**
- *设计列表
- * @return string
- */
- public function actionDesign()
- {
- $search =['start'=>'','end'=>''];
- $search['start'] = Yii::$app->request->get('start');
- $search['end'] = Yii::$app->request->get('end');
- $models = Design::find()->where(['status'=>Design::STATUS_YES]);
- if(!empty($search['start']))
- $models->andWhere("c_time > :start",[':start'=>strtotime($search['start'])]);
- if(!empty($search['end']))
- $models->andWhere("c_time < :end",[':end'=>strtotime($search['end'])+(3600*24-1)]);
- $citys = AuthArea::queryAuth();
- if($citys=='all')
- $models;
- elseif (!empty($citys))
- $models->andWhere("area_id in ({$citys})");
- else
- $models->andWhere("area_id = -1");
- $pages = new yii\data\Pagination(["totalCount" => $models->count(), "pageSize" => self::PAGESIZE]);
- $models = $models->offset($pages->offset)->limit($pages->limit)->orderBy(",id DESC")->all();
- return $this->render('design', ['models' => $models, 'pages' => $pages,'name'=>'免费设计列表','search'=>$search]);
- }
- /**
- * 删除设计
- */
- public function actionDelDesign()
- {
- $id = Yii::$app->request->post('id');
- $model = Design::find()->where(['id'=>$id])->one();
- $result = ['sign'=>1,'msg'=>'删除成功'];
- if(!empty($model))
- {
- $model->status = Design::STATUS_NO;
- if(!$model->save())
- $result= ['sign'=>0,'msg'=>'删除失败'];
- }else{
- $result= ['sign'=>0,'msg'=>'找不到该记录'];
- }
- return json_encode($result);
- }
- }
|