public function actionUpdateCalonKaryawan($id) { $modelp = $this->loadModel($id); $model = new KKaryawanM(); $model->lokasi_id = Params::DEFAULT_LOKASI; $format = new CustomFormat(); /*inisialisasi model karyawan yang diisi dari model pelamar*/ $model->attributes = $modelp->getAttributes(); $model->nama_karyawan = $modelp->nama_pelamar; $model->tempatlahir_karyawan = $modelp->tempatlahir_pelamar; $model->tgllahir_karyawan = $modelp->tgl_lahirpelamar; $model->tglditerima = $modelp->tglditerima; $model->alamat_karyawan = $modelp->alamat_pelamar; $model->nomobile_karyawan = $modelp->nomobile_pelamar; $model->warganegara_karyawan = $modelp->warganegara_pelamar; $model->photo_karyawan = $modelp->photopelamar; $model->agama = $modelp->agama; $model->pelamar_id = $modelp->pelamar_id; if (isset($_POST['KKaryawanM'])) { $model->unsetAttributes(); $model->attributes = $_POST['KKaryawanM']; $model->tglditerima = $_POST['tglditerima']; //$format->formatDateForDb($_POST['tglditerima']); $model->karyawan_aktif = 1; $model->tgllahir_karyawan = $_POST['tgllahir_karyawan']; $model->create_user_id = Yii::app()->session['loginpemakai_id']; $model->create_time = date('Y-m-d H:i:s'); $modelp->tglditerima = $model->tglditerima; $modelp->tglmulaibekerja = isset($_POST['tglmulaibekerja']) ? $_POST['tglmulaibekerja'] : null; // $modelp->tgllowongan = $format->formatDbtoDate($modelp->tgllowongan); // $modelp->Create_Time = $format->formatDbToDateTime($modelp->Create_Time); // print_r($modelp->tgl_lahirpelamar);exit(); // $modelp->tgl_lahirpelamar = $format->formatDbtoDate($modelp->tgl_lahirpelamar); // print_r($modelp->tgl_lahirpelamar);exit(); $transaksi = Yii::app()->db->beginTransaction(); // try{ if (!empty($model->photo_karyawan)) { $model->photo_karyawan = $random . $model->photo_karyawan; Yii::import("ext.EPhpThumb.EPhpThumb"); $thumb = new EPhpThumb(); $thumb->init(); // this is needed $fullImgName = $model->photo_karyawan; $fullImgSource = Params::pathIconModulDirectory() . $fullImgName; $fullThumbSource = Params::pathIconModulThumbsDirectory() . 'kecil_' . $fullImgName; if ($model->validate()) { if ($model->save()) { $gambar->saveAs($fullImgSource); $thumb->create($fullImgSource)->resize(200, 200)->save($fullThumbSource); $modelp->karyawan_id = $model->karyawan_id; $modelp->save(); $transaksi->commit(); $this->redirect(array('admin')); } } } else { $model->photo_karyawan = $modelp->photopelamar; if ($model->validate()) { // print_r($model->attributes);exit(); if ($model->save()) { $modelp->karyawan_id = $model->karyawan_id; $modelp->save(); $transaksi->commit(); $this->redirect(array('admin')); } } } //}catch(Exception $e){ // $transaksi->rollback(); // } } $this->render('updatekaryawan', array('model' => $model, 'modelp' => $modelp)); }