/**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['TblPegawai2'])) {
         $model->attributes = $_POST['TblPegawai2'];
         $d_nip = $_POST['TblPegawai2']['nip'];
         $d_nama = $_POST['TblPegawai2']['nama'];
         $d_alamat = $_POST['TblPegawai2']['alamat'];
         $d_tanggal_lahir = $_POST['TblPegawai2']['tanggal_lahir'];
         $d_agama = $_POST['TblPegawai2']['agama'];
         $sql = "UPDATE tbl_pegawai SET nip=:d_nip, nama=:d_nama, alamat=:d_alamat, tanggal_lahir=:d_tanggal_lahir, agama=:d_agama WHERE nip=:id";
         $cmd = Yii::app()->db->createCommand($sql);
         $cmd->bindParam(":d_nip", $d_nip, PDO::PARAM_INT);
         $cmd->bindParam(":d_nama", $d_nama, PDO::PARAM_STR);
         $cmd->bindParam(":d_alamat", $d_alamat, PDO::PARAM_STR);
         $cmd->bindParam(":d_tanggal_lahir", $d_tanggal_lahir, PDO::PARAM_STR);
         $cmd->bindParam(":d_agama", $d_agama, PDO::PARAM_STR);
         $cmd->bindParam(":id", $id, PDO::PARAM_INT);
         try {
             $cmd->execute();
             $this->redirect(array('admin'));
         } catch (Exception $e) {
             ii::app()->user->setFlash('adaKesalahan', "Ada kesalahan : " . "{$e->getMessage()}");
         }
         // if($model->save())
         // 	$this->redirect(array('view','id'=>$model->nip));
     }
     $this->render('update', array('model' => $model));
 }
 public function actionAddAvatar()
 {
     $saveAvatar = $this->actionUpload();
     $jsonDecode = CJSON::decode($saveAvatar);
     if (!empty($jsonDecode) && isset($jsonDecode['success']) && $jsonDecode['success'] == true && !empty($jsonDecode['uploadName'])) {
         // save photo
         $user = Y - ii::app()->user->model;
         $user->photo = $jsonDecode['uploadName'];
         $user->saveAttributes(array('photo'));
     }
     echo $saveAvatar;
 }
Example #3
0
	/**
	 * Logs out the current user and redirect to homepage.
	 */
	public function actionLogout()
	{
		Yii::app()->user->logout();
                ii::app()->user->setState('FB',NULL);
		$this->redirect(Yii::app()->homeUrl);
	}