SendorderLogController.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace company\modules\manage\controllers;
  3. use common\library\Apireturn;
  4. use common\models\MaterType;
  5. use common\models\SendOrder;
  6. use common\models\SendOrderLog;
  7. use common\models\UserCompany;
  8. use yii;
  9. use yii\filters\AccessControl;
  10. /**
  11. * 派单管理
  12. * @package backend\controllers
  13. */
  14. class SendorderLogController extends LoginverifyController
  15. {
  16. public $layout = 'iframe';
  17. const PAGESIZE = 20;//分页数
  18. public function behaviors()
  19. {
  20. return [
  21. 'access' => [
  22. 'class' => AccessControl::className(),
  23. 'rules' => [
  24. [
  25. 'actions' => [],
  26. 'allow' => true,
  27. 'roles' => ['@'],
  28. ],
  29. ],
  30. ],
  31. ];
  32. }
  33. /**
  34. * 列表
  35. * @return string
  36. */
  37. public function actionIndex()
  38. {
  39. $models = SendOrderLog::find()->with('sendorder')->where("uid = :uid AND status != :status",[':uid'=>Yii::$app->user->id,':status'=>SendOrderLog::STATUS_CANCEL]);
  40. $pages = new yii\data\Pagination(["totalCount" => $models->count(), "pageSize" => self::PAGESIZE]);
  41. $models = $models->offset($pages->offset)->limit($pages->limit)->orderBy("id DESC")->all();
  42. return $this->render('index', ['models' => $models, 'pages' => $pages,'name'=>'派单管理']);
  43. }
  44. /**
  45. * 处理
  46. */
  47. public function actionHandle()
  48. {
  49. if(Yii::$app->request->isPost)
  50. {
  51. $id = Yii::$app->request->post('id');
  52. $model = SendOrderLog::find()->where(['id'=>$id,'uid'=>Yii::$app->user->id])->one();
  53. if(empty($model))
  54. return Apireturn::returnJson(0,'找不到记录');
  55. $model->handle = SendOrderLog::HANDLE_YES;
  56. if($model->save())
  57. return Apireturn::returnJson(1,'处理成功');
  58. else
  59. return Apireturn::returnJson(0,'处理失败');
  60. }
  61. }
  62. /**
  63. * 查看
  64. */
  65. public function actionEdit()
  66. {
  67. $id = Yii::$app->request->get('id');
  68. $model= SendOrderLog::find()->where(['id'=>$id,'uid'=>Yii::$app->user->id])->one();
  69. if(empty($model))
  70. {
  71. Yii::$app->getSession()->setFlash('error', '找不到记录');
  72. return $this->redirect(Yii::$app->request->referrer);
  73. }
  74. $name = "查看";
  75. return $this->render('edit',['model'=>$model,'name'=>$name]);
  76. }
  77. }