12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- namespace company\modules\manage\controllers;
- use common\library\Apireturn;
- use common\models\MaterType;
- use common\models\SendOrder;
- use common\models\SendOrderLog;
- use common\models\UserCompany;
- use yii;
- use yii\filters\AccessControl;
- /**
- * 派单管理
- * @package backend\controllers
- */
- class SendorderLogController extends LoginverifyController
- {
- public $layout = 'iframe';
- const PAGESIZE = 20;//分页数
- public function behaviors()
- {
- return [
- 'access' => [
- 'class' => AccessControl::className(),
- 'rules' => [
- [
- 'actions' => [],
- 'allow' => true,
- 'roles' => ['@'],
- ],
- ],
- ],
- ];
- }
- /**
- * 列表
- * @return string
- */
- public function actionIndex()
- {
- $models = SendOrderLog::find()->with('sendorder')->where("uid = :uid AND status != :status",[':uid'=>Yii::$app->user->id,':status'=>SendOrderLog::STATUS_CANCEL]);
- $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('index', ['models' => $models, 'pages' => $pages,'name'=>'派单管理']);
- }
- /**
- * 处理
- */
- public function actionHandle()
- {
- if(Yii::$app->request->isPost)
- {
- $id = Yii::$app->request->post('id');
- $model = SendOrderLog::find()->where(['id'=>$id,'uid'=>Yii::$app->user->id])->one();
- if(empty($model))
- return Apireturn::returnJson(0,'找不到记录');
- $model->handle = SendOrderLog::HANDLE_YES;
- if($model->save())
- return Apireturn::returnJson(1,'处理成功');
- else
- return Apireturn::returnJson(0,'处理失败');
- }
- }
- /**
- * 查看
- */
- public function actionEdit()
- {
- $id = Yii::$app->request->get('id');
- $model= SendOrderLog::find()->where(['id'=>$id,'uid'=>Yii::$app->user->id])->one();
- if(empty($model))
- {
- Yii::$app->getSession()->setFlash('error', '找不到记录');
- return $this->redirect(Yii::$app->request->referrer);
- }
- $name = "查看";
- return $this->render('edit',['model'=>$model,'name'=>$name]);
- }
- }
|