You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

130 line
3.7 KiB

  1. <?php
  2. namespace backend\modules\motorcade\controllers;
  3. use backend\modules\motorcade\models\BaseBusProtocol;
  4. use Yii;
  5. use backend\modules\motorcade\models\BusProtocolFee;
  6. use backend\modules\motorcade\models\searchProtocolFee;
  7. use yii\web\NotFoundHttpException;
  8. use yii\helpers\Url;
  9. /**
  10. * ProtocolFeeController implements the CRUD actions for BusProtocolFee model.
  11. */
  12. class ProtocolFeeController extends BaseController
  13. {
  14. public $layout = "@backend/modules/motorcade/views/layouts/iframe_new";
  15. /**
  16. * Lists all BusProtocolFee models.
  17. * @return mixed
  18. */
  19. public function actionIndex()
  20. {
  21. $searchModel = new searchProtocolFee();
  22. $searchModel->PAID = 0;
  23. $searchModel->RUN_DATE = date('Y-m-d');
  24. $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
  25. return $this->render('index', [
  26. 'searchModel' => $searchModel,
  27. 'dataProvider' => $dataProvider,
  28. ]);
  29. }
  30. /**
  31. * Displays a single BusProtocolFee model.
  32. * @param integer $id
  33. * @return mixed
  34. */
  35. public function actionView($id)
  36. {
  37. return $this->render('view', [
  38. 'model' => $this->findModel($id),
  39. ]);
  40. }
  41. /**
  42. * Creates a new BusProtocolFee model.
  43. * If creation is successful, the browser will be redirected to the 'view' page.
  44. * @return mixed
  45. */
  46. public function actionCreate()
  47. {
  48. $model = new BusProtocolFee();
  49. if ($model->load(Yii::$app->request->post()) && $model->save()) {
  50. return $this->redirect(['view', 'id' => $model->ID]);
  51. } else {
  52. return $this->render('create', [
  53. 'model' => $model,
  54. ]);
  55. }
  56. }
  57. /**
  58. * Deletes an existing BusProtocolFee model.
  59. * If deletion is successful, the browser will be redirected to the 'index' page.
  60. * @param integer $id
  61. * @return mixed
  62. */
  63. public function actionDelete($id)
  64. {
  65. $this->findModel($id)->delete();
  66. return $this->redirect(['index']);
  67. }
  68. /**
  69. * Finds the BusProtocolFee model based on its primary key value.
  70. * If the model is not found, a 404 HTTP exception will be thrown.
  71. * @param integer $id
  72. * @return BusProtocolFee the loaded model
  73. * @throws NotFoundHttpException if the model cannot be found
  74. */
  75. protected function findModel($id)
  76. {
  77. if (($model = BusProtocolFee::findOne($id)) !== null) {
  78. return $model;
  79. } else {
  80. throw new NotFoundHttpException('The requested page does not exist.');
  81. }
  82. }
  83. /**
  84. * 批量确认收取挂靠协议费用
  85. */
  86. public function actionMultiPaid()
  87. {
  88. $id_str = Yii::$app->request->post('id');
  89. $count = BusProtocolFee::updateAll(['PAID' => 1], 'ID in (' . $id_str . ')');
  90. if ($count > 0) {
  91. $result = ['code' => 0, 'msg' => '确认成功!'];
  92. } else {
  93. $result = ['code' => 1, 'msg' => '确认失败!'];
  94. }
  95. return json_encode($result);
  96. }
  97. /**
  98. * 确认收取费用.
  99. * @param integer $id
  100. * @return mixed
  101. */
  102. public function actionPaid($id)
  103. {
  104. $model = $this->findModel($id);
  105. $function = "$.pjax.reload({container:'#protocol-pjax', timeout: false, replace: false, url: '" .
  106. Url::to(['index']) . "'})";
  107. if ($model !== null) {
  108. $model->PAID = 1;
  109. $model->save(false);
  110. $result = ['code' => 0, 'msg' => '确认收取成功!', 'callback' => $function];
  111. } else {
  112. $result = ['code' => 1, 'msg' => '确认失败!', 'callback' => $function];
  113. }
  114. return json_encode($result);
  115. }
  116. }