REmployeController.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: north
  5. * Date: 2017/8/14
  6. * Time: 下午2:31
  7. */
  8. class REmployeController extends AdminController {
  9. public function actionIndex()
  10. {
  11. $status = CommonFn::getComboboxData(JEmploye::$status_option, 100, true, 100);//人员状态
  12. $auth = CommonFn::getComboboxData(JEmploye::$auth_option, 1, true, 100);
  13. $this->render('index',array(
  14. 'status' => $status,
  15. 'auth' => $auth
  16. ));
  17. }
  18. public function actionList()
  19. {
  20. $pageParams = CommonFn::getPageParams();
  21. $status = intval(Yii::app()->request->getParam('status', 100));
  22. $criteria = new EMongoCriteria($pageParams);
  23. if ($status != 100 ) {
  24. $criteria->status('==',$status);
  25. }
  26. $cursor = JEmploye::model()->findAll($criteria);
  27. $rows = CommonFn::getRowsFromCursor($cursor);
  28. $parsedRows = JEmploye::model()->parse($rows);
  29. $total = $cursor->count();
  30. echo CommonFn::composeDatagridData($parsedRows, $total);
  31. }
  32. public function actionEdit()
  33. {
  34. $id = Yii::app()->request->getParam('id','');
  35. $status = intval(Yii::app()->request->getParam('status',100));
  36. if ($status == 100) {
  37. CommonFn::requestAjax(false,'状态没有修改');exit;
  38. }
  39. if (!CommonFn::isMongoId($id)) {
  40. CommonFn::requestAjax(false,'id错误');exit;
  41. }
  42. $employe = JEmploye::get(new MongoId($id));
  43. $employe->status = $status;
  44. $employe->save();
  45. CommonFn::requestAjax(true,'保存成功');exit;
  46. }
  47. public function actionAdd()
  48. {
  49. $user_id = Yii::app()->request->getParam('user_id','');
  50. $user_name = Yii::app()->request->getParam('user_name','');
  51. $mobile = Yii::app()->request->getParam('mobile','');
  52. $auth = intval(Yii::app()->request->getParam('auth',''));
  53. $owned_stores = Yii::app()->request->getParam('owned_stores','');
  54. $desc = Yii::app()->request->getParam('desc','');
  55. $sex = Yii::app()->request->getParam('sex','');
  56. $status = intval(Yii::app()->request->getParam('status',100));
  57. if ($status == 100) {
  58. CommonFn::requestAjax(false,'状态没有修改');exit;
  59. }
  60. if (CommonFn::isMongoId($user_id)) {
  61. $user = RUser::get(new MongoId($user_id));
  62. if (empty($user)) {
  63. CommonFn::requestAjax(false,'id错误');exit;
  64. }
  65. }
  66. $employe = new JEmploye();
  67. $employe->user_id = $user->_id;
  68. $employe->user_name = $user_name;
  69. $employe->mobile = $mobile;
  70. $employe->auth = intval($auth);
  71. $employe->owned_stores = intval($owned_stores);
  72. $employe->desc = $desc;
  73. $employe->status = intval($status);
  74. $employe->sex = intval($sex);
  75. $employe->save();
  76. CommonFn::requestAjax(true,'保存成功');exit;
  77. }
  78. }