GiftController.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. $this->render('index');
  14. }
  15. public function actionList()
  16. {
  17. $pageParams = CommonFn::getPageParams();
  18. $search = Yii::app()->request->getParam('search', '');
  19. $status = intval(Yii::app()->request->getParam('status', 100));
  20. $criteria = new EMongoCriteria($pageParams);
  21. if ($status != 100 ) {
  22. $criteria->status('==',$status);
  23. }
  24. if ($search) {
  25. $criteria->addCond('title','or',new MongoRegex('/' . $search . '/'));
  26. }
  27. $cursor = Gift::model()->findAll($criteria);
  28. $rows = CommonFn::getRowsFromCursor($cursor);
  29. $parsedRows = Gift::model()->parse($rows);
  30. $total = $cursor->count();
  31. echo CommonFn::composeDatagridData($parsedRows, $total);
  32. }
  33. public function actionEdit()
  34. {
  35. $id = Yii::app()->request->getParam('id','');
  36. $title = Yii::app()->request->getParam('title','');
  37. $desc = Yii::app()->request->getParam('desc','');
  38. $supplier = Yii::app()->request->getParam('supplier','');
  39. $supplier_name = Yii::app()->request->getParam('supplier_name','');
  40. $supplier_mobile = Yii::app()->request->getParam('supplier_mobile','');
  41. if (!CommonFn::isMongoId($id)) {
  42. CommonFn::requestAjax(false,'id错误');exit;
  43. }
  44. $gift = Gift::get(new MongoId($id));
  45. $gift->title = $title;
  46. $gift->desc = $desc;
  47. $gift->supplier = array(
  48. 'supplier' => $supplier,
  49. 'name' => $supplier_name,
  50. 'mobile' => $supplier_mobile,
  51. );
  52. $gift->save();
  53. CommonFn::requestAjax(true,'保存成功');exit;
  54. }
  55. public function actionAdd()
  56. {
  57. $title = Yii::app()->request->getParam('title','');
  58. $desc = Yii::app()->request->getParam('desc','');
  59. $supplier = Yii::app()->request->getParam('supplier','');
  60. $supplier_name = Yii::app()->request->getParam('supplier_name','');
  61. $supplier_mobile = Yii::app()->request->getParam('supplier_mobile','');
  62. $gift = new Gift();
  63. $gift->title = $title;
  64. $gift->desc = $desc;
  65. $gift->supplier = array(
  66. 'supplier' => $supplier,
  67. 'name' => $supplier_name,
  68. 'mobile' => $supplier_mobile,
  69. );
  70. $gift->save();
  71. CommonFn::requestAjax(true,'保存成功');exit;
  72. }
  73. public function actionOutputExcel()
  74. {
  75. $data = JGEmploye::model()->findAll();
  76. $res=Service::factory('ExcelService')->push($data);
  77. }
  78. }