/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function newSmsout() { $model = new sSmsout(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['sSmsout'])) { //Save to Log File $model->attributes = $_POST['sSmsout']; $model->created_date = time(); $model->sender_id = Yii::app()->user->id; $model->save(); //Create Send SMS File $models = dAddressbookGroupDetail::model()->findAll(array('condition' => 'parent_id = :parent', 'params' => array(':parent' => $model->receivergroup_id))); foreach ($models as $model1) { $_rand = mt_rand(100, 999); $myfile = $model->id . "-" . $_rand . "-" . dAddressbook::model()->findByPk($model1->name_id)->complete_name . ".txt"; $fh = fopen("C:\\wamp\\apps\\sms\\outgoing\\" . $myfile, "w") or die("can't open file"); $stringData = "To: " . dAddressbook::model()->findByPk($model1->name_id)->handphone . "\n"; fwrite($fh, $stringData); $stringData = "\n"; fwrite($fh, $stringData); $stringData = $model->message; fwrite($fh, $stringData); fclose($fh); } $this->redirect(array('/sSmsout')); } return $model; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = dAddressbook::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }