HouseKeepingController.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. /*$tmp = HouseKeeping::model()->findAll();
  14. foreach ($tmp as $k => $v) {
  15. $v->delete();
  16. }
  17. $tmp = JGEmploye::model()->findAll();
  18. foreach ($tmp as $k => $v) {
  19. $v->delete();
  20. }*/
  21. //$tmp = JEmploye::model()->findAll();
  22. //foreach ($tmp as $k => $v) {
  23. // $v->delete();
  24. //}
  25. $status_option = CommonFn::getComboboxData(HouseKeeping::$status_option, 1, true, 100);
  26. $type_option = CommonFn::getComboboxData(HouseKeeping::$type_option, 1, true, 100);
  27. $cart_options = CommonFn::getComboboxData(HouseKeeping::$cart_options, 1, true, 100);
  28. $skill_options = CommonFn::getComboboxData(HouseKeeping::$skill_options, 1, true, 100);
  29. $contract_option = CommonFn::getComboboxData(HouseKeeping::$contract_option, 1, true, 100);
  30. $c = new EMongoCriteria();
  31. $c->status('==',2);
  32. $tmp = Store::model()->findAll($c);
  33. foreach ($tmp as $k => $v) {
  34. $store_options[$v->store_id]['name'] = $v->store_name;
  35. }
  36. $this->render('index', [
  37. 'status_option' => $status_option,
  38. 'type_option' => $type_option,
  39. 'cart_options' => $cart_options,
  40. 'skill_options' => $skill_options,
  41. 'contract_option' => $contract_option,
  42. ]);
  43. }
  44. public function actionList()
  45. {
  46. $pageParams = CommonFn::getPageParams();
  47. $id = intval(Yii::app()->request->getParam('id'));
  48. $search = Yii::app()->request->getParam('search', '');
  49. $status = intval(Yii::app()->request->getParam('status', 100));
  50. $criteria = new EMongoCriteria($pageParams);
  51. // id筛选
  52. if ($id) {
  53. $criteria->_id('==', new MongoId($id));
  54. }
  55. // 状态筛选
  56. if ($status != 100) {
  57. $criteria->status('==', $status);
  58. }
  59. $criteria->sort('time',EMongoCriteria::SORT_DESC);
  60. $cursor = HouseKeeping::model()->findAll($criteria);
  61. $rows = CommonFn::getRowsFromCursor($cursor);
  62. $parsedRows = HouseKeeping::model()->parse($rows);
  63. $total = $cursor->count();
  64. echo CommonFn::composeDatagridData($parsedRows, $total);
  65. }
  66. public function actionEdit()
  67. {
  68. $status = intval(Yii::app()->request->getParam('status', 100));
  69. $contract = intval(Yii::app()->request->getParam('contract', 100));
  70. $type = intval(Yii::app()->request->getParam('type', 100));
  71. $cart = intval(Yii::app()->request->getParam('cart', 100));
  72. $skill = Yii::app()->request->getParam('skill_options');
  73. $skills = array();
  74. if (!empty($skill)) {
  75. foreach ($skill as $value) {
  76. $skills[] = intval($value);
  77. }
  78. }
  79. $age = intval(Yii::app()->request->getParam('age', 0));
  80. $tech = (Yii::app()->request->getParam('tech', ''));
  81. $tech_mobile = (Yii::app()->request->getParam('tech_mobile', ''));
  82. $desc = (Yii::app()->request->getParam('desc', ''));
  83. $yc_time = intval(Yii::app()->request->getParam('yc_time', ''));
  84. $server_start_time = intval(Yii::app()->request->getParam('server_start_time', ''));
  85. $status_time = intval(Yii::app()->request->getParam('status_time', ''));
  86. $server_end_time = intval(Yii::app()->request->getParam('server_end_time', ''));
  87. $store_id = (Yii::app()->request->getParam('store_id', ''));
  88. $id = Yii::app()->request->getParam('id');
  89. $cancel_cause = Yii::app()->request->getParam('cancel_cause','');
  90. if (!CommonFn::isMongoId($id)) {
  91. CommonFn::requestAjax(false, '修改失败', array());
  92. }
  93. $h = HouseKeeping::get(new MongoId($id));
  94. if (!empty($cancel_cause)) {
  95. $h->cancel_cause = $cancel_cause;
  96. }
  97. if (!empty($contract)) {
  98. $h->contract = $contract;
  99. }
  100. if (!empty($store_id)) {
  101. $h->store_id = $store_id;
  102. }
  103. if (!empty($type)) {
  104. $h->type = $type;
  105. }
  106. if (!empty($cart)) {
  107. $h->cart = $cart;
  108. }
  109. if (!empty($skills)) {
  110. $h->skill = $skills;
  111. }
  112. if (!empty($age)) {
  113. $h->age = $age;
  114. }
  115. if (!empty($desc)) {
  116. $h->desc = $desc;
  117. }
  118. if (!empty($status)) {
  119. $h->status = $status;
  120. }
  121. if (!empty($status_time)) {
  122. $h->status_time = $status_time;
  123. }
  124. if (!empty($server_start_time)) {
  125. $h->server_start_time = $server_start_time;
  126. }
  127. if (!empty($server_end_time)) {
  128. $h->server_end_time = $server_end_time;
  129. }
  130. if (!empty($yc_time)) {
  131. $h->yc_time = $yc_time;
  132. }
  133. if (!empty($tech)) {
  134. $h->tech = $tech;
  135. }
  136. if (!empty($tech_mobile)) {
  137. $h->tech_mobile = $tech_mobile;
  138. }
  139. $success = $h->save();
  140. CommonFn::requestAjax($success, '修改成功', array());
  141. }
  142. public function actionAdd()
  143. {
  144. $h = new HouseKeeping();
  145. $h->user_name = '1';
  146. $h->mobile = '15600266816';
  147. $h->type = 1;
  148. $h->cart = 1;
  149. $h->address = '1dsfafsdf';
  150. $h->server_start_time = time();
  151. $h->server_end_time = time();
  152. $h->skill = array(1,2,3);
  153. $h->yc_time = time();
  154. $h->age = 18;
  155. $h->desc = 'fasdf1';
  156. $h->status = 1;
  157. $h->status_time = time();
  158. $h->tech = '12asdf';
  159. $h->contract = 1;
  160. $h->time = time();
  161. $h->save();
  162. }
  163. public function actionOutputExcel()
  164. {
  165. $data = HouseKeeping::model()->findAll();
  166. Service::factory('Excel1Service')->push($data);
  167. }
  168. }