123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
- /**
- * Created by north.Deng's MAC
- * User: north.Deng
- * Date: 2018/2/28
- * Time: 下午12:30
- * description :
- */
- class GiftController extends AdminController
- {
- public function actionIndex()
- {
- $c = new EMongoCriteria();
- $c->type('==',0);
- $bs = Business::model()->findAll($c);
- $tmp =[];
- foreach ($bs as $gift) {
- $tmp[] = array('name' => "$gift->source-$gift->name-$gift->mobile",'id' => (string)$gift->_id);
- }
- $tmp = CommonFn::getComboboxData($tmp, 0, false );
- $type_option = CommonFn::getComboboxData(Gift::$type_options, 1, true, 100);
- $this->render('index',[
- 'gifts' => $tmp,
- 'type' => $type_option,
- ]);
- }
- public function actionList()
- {
- $pageParams = CommonFn::getPageParams();
- $search = Yii::app()->request->getParam('search', '');
- $status = intval(Yii::app()->request->getParam('status', 100));
- $criteria = new EMongoCriteria($pageParams);
- if ($status != 100 ) {
- $criteria->status('==',$status);
- }
- if ($search) {
- $criteria->addCond('title','or',new MongoRegex('/' . $search . '/'));
- }
- $cursor = Gift::model()->findAll($criteria);
- $rows = CommonFn::getRowsFromCursor($cursor);
- $parsedRows = Gift::model()->parse($rows);
- $total = $cursor->count();
- echo CommonFn::composeDatagridData($parsedRows, $total);
- }
- public function actionEdit()
- {
- $id = Yii::app()->request->getParam('id','');
- $title = Yii::app()->request->getParam('title','');
- $gift_num = Yii::app()->request->getParam('gift_num','');
- $desc = Yii::app()->request->getParam('desc','');
- $type = (int)Yii::app()->request->getParam('type','');
- $supplier = Yii::app()->request->getParam('supplier','');
- if ($type == 100) {
- CommonFn::requestAjax(false,'请选择礼包类型');exit;
- }
- if (!CommonFn::isMongoId($id)) {
- CommonFn::requestAjax(false,'id错误');exit;
- }
- $gift = Gift::get(new MongoId($id));
- $gift->title = $title;
- $gift->gift_num = $gift_num;
- $gift->desc = $desc;
- $gift->supplier = $supplier;
- $gift->type = (int)$type;
- $gift->save();
- CommonFn::requestAjax(true,'保存成功');exit;
- }
- public function actionAdd()
- {
- $title = Yii::app()->request->getParam('title','');
- $desc = Yii::app()->request->getParam('desc','');
- $gift_num = Yii::app()->request->getParam('gift_num','');
- $supplier = Yii::app()->request->getParam('supplier','');
- $type = (int)Yii::app()->request->getParam('type','');
- if ($type == 100) {
- CommonFn::requestAjax(false,'请选择礼包类型');exit;
- }
- if(!$title || !$desc || !$gift_num || !$supplier ) {
- CommonFn::requestAjax(false,'请填写完整数据');exit;
- }
- $gift = new Gift();
- $gift->title = $title;
- $gift->gift_num = $gift_num;
- $gift->desc = $desc;
- $gift->type = (int)$type;
- $gift->supplier = $supplier;
- $gift->save();
- CommonFn::requestAjax(true,'保存成功');exit;
- }
- public function actionOutputExcel()
- {
- $data = JGEmploye::model()->findAll();
- $res=Service::factory('ExcelService')->push($data);
- }
- }
|