12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?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()
- {
- $this->render('index');
- }
- 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','');
- $desc = Yii::app()->request->getParam('desc','');
- $supplier = Yii::app()->request->getParam('supplier','');
- $supplier_name = Yii::app()->request->getParam('supplier_name','');
- $supplier_mobile = Yii::app()->request->getParam('supplier_mobile','');
- if (!CommonFn::isMongoId($id)) {
- CommonFn::requestAjax(false,'id错误');exit;
- }
- $gift = Gift::get(new MongoId($id));
- $gift->title = $title;
- $gift->desc = $desc;
- $gift->supplier = array(
- 'supplier' => $supplier,
- 'name' => $supplier_name,
- 'mobile' => $supplier_mobile,
- );
- $gift->save();
- CommonFn::requestAjax(true,'保存成功');exit;
- }
- public function actionAdd()
- {
- $title = Yii::app()->request->getParam('title','');
- $desc = Yii::app()->request->getParam('desc','');
- $supplier = Yii::app()->request->getParam('supplier','');
- $supplier_name = Yii::app()->request->getParam('supplier_name','');
- $supplier_mobile = Yii::app()->request->getParam('supplier_mobile','');
- $gift = new Gift();
- $gift->title = $title;
- $gift->desc = $desc;
- $gift->supplier = array(
- 'supplier' => $supplier,
- 'name' => $supplier_name,
- 'mobile' => $supplier_mobile,
- );
- $gift->save();
- CommonFn::requestAjax(true,'保存成功');exit;
- }
- public function actionOutputExcel()
- {
- $data = JGEmploye::model()->findAll();
- $res=Service::factory('ExcelService')->push($data);
- }
- }
|