/** * 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; }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function newAddressbook() { $model = new dAddressbook(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['dAddressbook'])) { $model->attributes = $_POST['dAddressbook']; $model->save(); if (isset($_POST['dAddressbook']['defaultgroup'])) { $modelgroup = new dAddressbookGroupDetail(); $modelgroup->parent_id = $_POST['dAddressbook']['defaultgroup']; $modelgroup->name_id = $model->id; $modelgroup->save(); Yii::app()->user->setFlash('success', 'data has been saved successfully'); } $this->redirect(array('index')); } return $model; }