/** * * @param Tinkhachhang $tinKhachHang */ private function _updateTinGhepXe($tinKhachHang) { $tinGhepXe = Tinghepxe::model()->findByAttributes(array('ma_tin' => $tinKhachHang->ma_tin)); if (isset($_POST['Tinkhachhang'])) { $tinKhachHang->attributes = $_POST['Tinkhachhang']; $tinGhepXe->attributes = $_POST['Tinghepxe']; if ($tinKhachHang->validate() and $tinGhepXe->validate()) { //Lưu dữ liệu vào CSDL và redirect trang $tinKhachHang->save(false); Tinghepxe::updateTinGhepXe($tinGhepXe->dia_chi_di, $tinGhepXe->dia_chi_den, $tinGhepXe->noi_den_tinh, $tinGhepXe->ma_loai_xe_ghep, $tinGhepXe->ngay_khoi_hanh, $tinGhepXe->ma_tin); $this->redirect(array('admin')); } } $this->render('updateTinGhepXe', array('tinKhachHang' => $tinKhachHang, 'tinGhepXe' => $tinGhepXe)); }
/** * * @param integer $maTin Mã tin */ private function __suaTinGhepXe($maTin) { $form = new CForm('application.views.user.khach_hang._formGX'); $form['tinkhachhang']->model = $tinKH = Tinkhachhang::model()->findByPk($maTin); $form['tinghepxe']->model = Tinghepxe::model()->find("ma_tin = {$maTin}"); if ($form->submitted('dangtin') && $form->validate()) { $tinkhachhang = $form['tinkhachhang']->model; $tinghepxe = $form['tinghepxe']->model; //update tin khách hàng sau đó là tin ghép xe if ($tinkhachhang->save(false)) { Tinghepxe::updateTinGhepXe($tinghepxe->dia_chi_di, $tinghepxe->dia_chi_den, $tinghepxe->noi_den_tinh, $tinghepxe->ma_loai_xe_ghep, $tinghepxe->ngay_khoi_hanh, $tinghepxe->ma_tin); } } //render view $this->render('sua_tin', ['form' => $form]); }