Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

113 lignes
3.7 KiB

  1. <?php
  2. namespace backend\modules\motorcade\controllers;
  3. use backend\modules\motorcade\models\searchProtocol;
  4. use Yii;
  5. use backend\modules\motorcade\models\BaseBusProtocol;
  6. use yii\helpers\Url;
  7. use yii\web\NotFoundHttpException;
  8. /**
  9. * BusProtocolController implements the CRUD actions for BaseBusProtocol model.
  10. */
  11. class BusProtocolController extends BaseController
  12. {
  13. public $layout = "@backend/modules/motorcade/views/layouts/iframe_new";
  14. /**
  15. * Lists all BaseBusProtocol models.
  16. * @param $BUS_ID string|integer 修改车辆基础信息和挂靠费用都是用的这里,以$BUS_ID为区分,会影响页面渲染
  17. * @return mixed
  18. */
  19. public function actionIndex($BUS_ID = '')
  20. {
  21. $searchModel = new searchProtocol();
  22. $searchModel->BUS_ID = $BUS_ID;
  23. if($BUS_ID === ''){
  24. $searchModel->PAID = 0;
  25. }
  26. $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
  27. return $this->render('index', [
  28. 'searchModel' => $searchModel,
  29. 'dataProvider' => $dataProvider,
  30. 'all' => $BUS_ID === '' ? true : false
  31. ]);
  32. }
  33. /**
  34. * Creates a new BaseBusProtocol model.
  35. * If creation is successful, the browser will be redirected to the 'view' page.
  36. * @param $BUS_ID integer
  37. * @return mixed
  38. */
  39. public function actionCreate($BUS_ID)
  40. {
  41. $model = new BaseBusProtocol();
  42. if ($model->load(Yii::$app->request->post()) && $model->save()) {
  43. return "<script>z.pjaxFinish('success', '添加成功', '#float-div');$.pjax.reload({container:'#protocol-pjax', timeout: false, replace: false, url: '" .
  44. Url::to(['index', 'BUS_ID' => $model->BUS_ID]) . "'})</script>";
  45. } else {
  46. $model->BUS_ID = $BUS_ID;
  47. return $this->render('_form', [
  48. 'model' => $model,
  49. ]);
  50. }
  51. }
  52. /**
  53. * Updates an existing BaseBusProtocol model.
  54. * If update is successful, the browser will be redirected to the 'view' page.
  55. * @param integer $id
  56. * @return mixed
  57. */
  58. public function actionUpdate($id)
  59. {
  60. $model = $this->findModel($id);
  61. if ($model->load(Yii::$app->request->post()) && $model->save()) {
  62. return "<script>z.pjaxFinish('success', '修改成功', '#float-div');$.pjax.reload({container:'#protocol-pjax', timeout: false, replace: false, url: '" .
  63. Url::to(['index', 'BUS_ID' => $model->BUS_ID]) . "'})</script>";
  64. } else {
  65. return $this->render('_form', [
  66. 'model' => $model,
  67. ]);
  68. }
  69. }
  70. /**
  71. * Deletes an existing BaseBusProtocol model.
  72. * If deletion is successful, the browser will be redirected to the 'index' page.
  73. * @param integer $id
  74. * @return mixed
  75. */
  76. public function actionDelete($id)
  77. {
  78. $model = $this->findModel($id);
  79. $model->delete();
  80. $function = "$.pjax.reload({container:'#protocol-pjax', timeout: false, replace: false, url: '" .
  81. Url::to(['index', 'BUS_ID' => $model->BUS_ID]) . "'})";
  82. $result = ['code' => 0, 'msg' => '删除成功!', 'callback' => $function];
  83. return json_encode($result);
  84. }
  85. /**
  86. * Finds the BaseBusProtocol model based on its primary key value.
  87. * If the model is not found, a 404 HTTP exception will be thrown.
  88. * @param integer $id
  89. * @return BaseBusProtocol the loaded model
  90. * @throws NotFoundHttpException if the model cannot be found
  91. */
  92. protected function findModel($id)
  93. {
  94. if (($model = BaseBusProtocol::findOne($id)) !== null) {
  95. return $model;
  96. } else {
  97. throw new NotFoundHttpException('The requested page does not exist.');
  98. }
  99. }
  100. }