/**
  * Deletes a particular model.
  * If deletion is successful, the browser will be redirected to the 'admin' page.
  * @param integer $id the ID of the model to be deleted
  */
 public function actionDelete($id)
 {
     if (!Tinghepxe::model()->findByAttributes(array('ma_loai_xe_ghep' => $id))) {
         $this->loadModel($id)->delete();
     }
     // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
     if (!isset($_GET['ajax'])) {
         $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
     }
 }
 /**
  * Deletes a particular model.
  * If deletion is successful, the browser will be redirected to the 'admin' page.
  * @param integer $id the ID of the model to be deleted
  */
 public function actionDelete_user_news($id, $type)
 {
     $tinKhachHang = $this->loadModel($id);
     if ($tinKhachHang->ma_loai_tin == Tinraovat::CODE_RV) {
         Tinraovat::model()->deleteAll('ma_tin =' . $tinKhachHang->ma_tin);
     } else {
         Tinghepxe::model()->deleteAll('ma_tin =' . $tinKhachHang->ma_tin);
     }
     $tinKhachHang->delete();
     $this->redirect(array('admin'));
 }
示例#3
0
 /**
  * 
  * @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]);
 }
示例#4
0
 /**
  * Update tin ghép xe
  * @param string $diaChiDi Địa chỉ đi
  * @param string $diaChiDen Địa chỉ đến
  * @param integer $noiDenTinh Mã tỉnh
  * @param integer $maLoaiXeGhep Mã loại xe muốn ghép
  * @param string $ngayKhoiHanh Ngày khởi hành
  * @param integer $maTin Mã tin đăng
  */
 public static function updateTinGhepXe($diaChiDi, $diaChiDen, $noiDenTinh, $maLoaiXeGhep, $ngayKhoiHanh, $maTin)
 {
     $sql = "UPDATE " . Tinghepxe::model()->tableName() . " SET dia_chi_di = '{$diaChiDi}',dia_chi_den= '{$diaChiDen}'," . " noi_den_tinh = {$noiDenTinh},ma_loai_xe_ghep = {$maLoaiXeGhep}," . " ngay_khoi_hanh = '{$ngayKhoiHanh}'" . " WHERE ma_tin ={$maTin}";
     Yii::app()->db->createCommand($sql)->execute();
 }