HouseKeepingController.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. /**
  3. * Created by north.Deng's MAC
  4. * User: north.Deng
  5. * Date: 2018/1/8
  6. * Time: 上午11:39
  7. * description :
  8. */
  9. class HouseKeepingController extends AdminController
  10. {
  11. public function actionIndex()
  12. {
  13. $status_option = CommonFn::getComboboxData(HouseKeeping::$status_option, 1, true, 100);
  14. $type_option = CommonFn::getComboboxData(HouseKeeping::$type_option, 1, true, 100);
  15. $cart_options = CommonFn::getComboboxData(HouseKeeping::$cart_options, 1, true, 100);
  16. $skill_options = CommonFn::getComboboxData(HouseKeeping::$skill_options, 1, true, 100);
  17. $contract_option = CommonFn::getComboboxData(HouseKeeping::$contract_option, 1, true, 100);
  18. $this->render('index', [
  19. 'status_option' => $status_option,
  20. 'type_option' => $type_option,
  21. 'cart_options' => $cart_options,
  22. 'skill_options' => $skill_options,
  23. 'contract_option' => $contract_option,
  24. ]);
  25. }
  26. public function actionList()
  27. {
  28. $pageParams = CommonFn::getPageParams();
  29. $id = intval(Yii::app()->request->getParam('id'));
  30. $search = Yii::app()->request->getParam('search', '');
  31. $status = intval(Yii::app()->request->getParam('status', 100));
  32. $criteria = new EMongoCriteria($pageParams);
  33. // id筛选
  34. if ($id) {
  35. $criteria->_id('==', new MongoId($id));
  36. }
  37. // 状态筛选
  38. if ($status != 100) {
  39. $criteria->status('==', $status);
  40. }
  41. $cursor = HouseKeeping::model()->findAll($criteria);
  42. $rows = CommonFn::getRowsFromCursor($cursor);
  43. $parsedRows = HouseKeeping::model()->parse($rows);
  44. $total = $cursor->count();
  45. echo CommonFn::composeDatagridData($parsedRows, $total);
  46. }
  47. public function actionEdit()
  48. {
  49. $status = intval(Yii::app()->request->getParam('status', 100));
  50. $contract = intval(Yii::app()->request->getParam('contract', 100));
  51. $type = intval(Yii::app()->request->getParam('type', 100));
  52. $cart = intval(Yii::app()->request->getParam('cart', 100));
  53. $skill = intval(Yii::app()->request->getParam('skill', 100));
  54. $age = intval(Yii::app()->request->getParam('age', 0));
  55. $tech = (Yii::app()->request->getParam('tech', ''));
  56. $desc = (Yii::app()->request->getParam('desc', ''));
  57. $yc_time = intval(Yii::app()->request->getParam('yc_time', ''));
  58. $server_start_time = intval(Yii::app()->request->getParam('server_start_time', ''));
  59. $status_time = intval(Yii::app()->request->getParam('status_time', ''));
  60. $server_end_time = intval(Yii::app()->request->getParam('server_end_time', ''));
  61. $id = Yii::app()->request->getParam('id');
  62. if (!CommonFn::isMongoId($id)) {
  63. CommonFn::requestAjax(false, '修改失败', array());
  64. }
  65. $h = HouseKeeping::get(new MongoId($id));
  66. if (!empty($contract)) {
  67. $h->contract = $contract;
  68. }
  69. if (!empty($type)) {
  70. $h->type = $type;
  71. }
  72. if (!empty($cart)) {
  73. $h->cart = $cart;
  74. }
  75. if (!empty($skill)) {
  76. $h->skill = $skill;
  77. }
  78. if (!empty($age)) {
  79. $h->age = $age;
  80. }
  81. if (!empty($desc)) {
  82. $h->desc = $desc;
  83. }
  84. if (!empty($status)) {
  85. $h->status = $status;
  86. }
  87. if (!empty($status_time)) {
  88. $h->status_time = $status_time;
  89. }
  90. if (!empty($server_start_time)) {
  91. $h->server_start_time = $server_start_time;
  92. }
  93. if (!empty($server_end_time)) {
  94. $h->server_end_time = $server_end_time;
  95. }
  96. if (!empty($yc_time)) {
  97. $h->yc_time = $yc_time;
  98. }
  99. if (!empty($tech)) {
  100. $h->tech = $tech;
  101. }
  102. $success = $h->save();
  103. CommonFn::requestAjax($success, '修改成功', array());
  104. }
  105. public function actionAdd()
  106. {
  107. $h = new HouseKeeping();
  108. $h->user_name = '1';
  109. $h->mobile = '15600266816';
  110. $h->type = 1;
  111. $h->cart = 1;
  112. $h->address = '1dsfafsdf';
  113. $h->server_start_time = time();
  114. $h->server_end_time = time();
  115. $h->skill = 1;
  116. $h->yc_time = time();
  117. $h->age = 18;
  118. $h->desc = 'fasdf1';
  119. $h->status = 1;
  120. $h->status_time = time();
  121. $h->tech = '12asdf';
  122. $h->contract = 1;
  123. $h->time = time();
  124. $h->save();
  125. }
  126. }