GiftController.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. * Created by north.Deng's MAC
  4. * User: north.Deng
  5. * Date: 2018/2/28
  6. * Time: 下午12:30
  7. * description :
  8. */
  9. class GiftController extends AdminController
  10. {
  11. public function actionIndex()
  12. {
  13. $c = new EMongoCriteria();
  14. $c->type('==',0);
  15. $bs = Business::model()->findAll($c);
  16. $tmp =[];
  17. foreach ($bs as $gift) {
  18. $tmp[] = array('name' => $gift->source,'id' => (string)$gift->_id);
  19. }
  20. $tmp = CommonFn::getComboboxData($tmp, 0, false );
  21. $this->render('index',[
  22. 'gifts' => $tmp
  23. ]);
  24. }
  25. public function actionList()
  26. {
  27. $pageParams = CommonFn::getPageParams();
  28. $search = Yii::app()->request->getParam('search', '');
  29. $status = intval(Yii::app()->request->getParam('status', 100));
  30. $criteria = new EMongoCriteria($pageParams);
  31. if ($status != 100 ) {
  32. $criteria->status('==',$status);
  33. }
  34. if ($search) {
  35. $criteria->addCond('title','or',new MongoRegex('/' . $search . '/'));
  36. }
  37. $cursor = Gift::model()->findAll($criteria);
  38. $rows = CommonFn::getRowsFromCursor($cursor);
  39. $parsedRows = Gift::model()->parse($rows);
  40. $total = $cursor->count();
  41. echo CommonFn::composeDatagridData($parsedRows, $total);
  42. }
  43. public function actionEdit()
  44. {
  45. $id = Yii::app()->request->getParam('id','');
  46. $title = Yii::app()->request->getParam('title','');
  47. $gift_num = Yii::app()->request->getParam('gift_num','');
  48. $desc = Yii::app()->request->getParam('desc','');
  49. $supplier = Yii::app()->request->getParam('supplier','');
  50. if (!CommonFn::isMongoId($id)) {
  51. CommonFn::requestAjax(false,'id错误');exit;
  52. }
  53. $gift = Gift::get(new MongoId($id));
  54. $gift->title = $title;
  55. $gift->gift_num = $gift_num;
  56. $gift->desc = $desc;
  57. $gift->supplier = $supplier;
  58. $gift->save();
  59. CommonFn::requestAjax(true,'保存成功');exit;
  60. }
  61. public function actionAdd()
  62. {
  63. $title = Yii::app()->request->getParam('title','');
  64. $desc = Yii::app()->request->getParam('desc','');
  65. $gift_num = Yii::app()->request->getParam('gift_num','');
  66. $supplier = Yii::app()->request->getParam('supplier','');
  67. $gift = new Gift();
  68. $gift->title = $title;
  69. $gift->gift_num = $gift_num;
  70. $gift->desc = $desc;
  71. $gift->supplier = $supplier;
  72. $gift->save();
  73. CommonFn::requestAjax(true,'保存成功');exit;
  74. }
  75. public function actionOutputExcel()
  76. {
  77. $data = JGEmploye::model()->findAll();
  78. $res=Service::factory('ExcelService')->push($data);
  79. }
  80. }