/** * Copy record * If copy is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be copy */ public function actionCopy($id) { $data = $this->loadModel($id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['GameEventActivityModel'])) { $model = new GameEventActivityModel(); $model->attributes = $_POST['GameEventActivityModel']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('copy', array('model' => $data)); }
public function init() { // this method is called when the module is being created // you may place code here to customize the module or the application $cs = Yii::app()->getClientScript(); $this->_assetsUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('application.modules.event.assets'), false, 1, YII_DEBUG); $cs->registerCssFile($this->_assetsUrl . "/css/event.css"); // import the module-level models and components $this->setImport(array('event.models.*')); $userPhone = yii::app()->user->getState('msisdn'); if ($userPhone && (!isset($_SESSION['visit']) || !$_SESSION['visit'])) { $_SESSION['visit'] = 1; $gameEventActivity = new GameEventActivityModel(); $gameEventActivity->user_phone = $userPhone; $gameEventActivity->activity = 'visit'; $gameEventActivity->updated_time = date('Y-m-d H:i:s'); $gameEventActivity->note = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $gameEventActivity->save(); } }
public function actionShare() { $userPhone = yii::app()->user->getState('msisdn'); $isShare = GameEventActivityModel::isShareOnDay($userPhone, date('Y-m-d')); if ($isShare) { $this->redirect('/event/play/thank'); Yii::app()->end(); } $error = 0; $isSend = false; if (Yii::app()->request->isPostRequest) { $isSend = 0; $phoneList = $_POST['phone_list']; if ($phoneList != '') { $phoneArr = explode(',', $phoneList); if ($phoneArr) { foreach ($phoneArr as $key => $value) { $phone = Formatter::formatPhone($value); if (Formatter::isVinaphoneNumber($phone)) { $isSend++; $sms = new SmsClient(); $content = 'DV Chacha - Vinaphone kinh chao Quy Khach. Quy Khach vua duoc thue bao ' . $userPhone . ' moi dua tai trong chuong trinh "Vui cung Chacha - Nhan qua nhu y" voi giai thuong hap dan len toi 20 trieu dong. Chi tiet moi Quy Khach xem tai day http://m.chacha.vn/event'; $sms->sentMT("9234", $phone, 0, $content, 0, "", time(), 9234); } } if ($isSend > 0) { //chia se it nhat duoc 1 so vinaphone $gameActivity = new GameEventActivityModel(); $gameActivity->setAttribute('user_phone', $userPhone); $gameActivity->setAttribute('activity', 'share'); $gameActivity->setAttribute('point', 1); $gameActivity->setAttribute('updated_time', date('Y-m-d H:i:s')); $gameActivity->setAttribute('note', $phoneList, PDO::PARAM_STR); $gameActivity->save(); $this->redirect('/event/play/thank'); } } } else { //ko có sô dt nao $error = 1; } } $this->render('share', array('isShare' => $isShare, 'error' => $error, 'isSend' => $isSend)); }