/** * 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')); } }
/** * This is the default 'index' action that is invoked * By defaul i will display the list of tinghepxe table */ public function actionIndex($currentPageXe = null, $currentPageKTX = null, $callIndirectly = false) { if (!$callIndirectly) { $app = Yii::app(); $app->session['currentPageXeAtHome'] = 1; $app->session['currentPageKhachAtHome'] = 1; } $tinghepxe = new Tinghepxe(); //table khách tìm xe $paginatorKTX = new Paginate($currentPageKTX, new Tinkhachhang(), self::LIMITED_RECORD_KTX, ' ma_loai_tin = ' . Tinghepxe::CODE_KTX); $khachtimxe = $tinghepxe->listTinGhepXeByType($paginatorKTX, Tinghepxe::CODE_KTX); //table xe tim khach $paginatorXTK = new Paginate($currentPageXe, new Tinkhachhang(), self::LIMITED_RECORD_XTK, ' ma_loai_tin = ' . Tinghepxe::CODE_XTK); $xetimkhach = $tinghepxe->listTinGhepXeByType($paginatorXTK, Tinghepxe::CODE_XTK); //render view $data = array('khachtimxe' => $khachtimxe, 'paginatorKTX' => $paginatorKTX, 'urlPaginatorXe' => 'site/pagektx?p=', 'xetimkhach' => $xetimkhach, 'paginatorXTK' => $paginatorXTK, 'urlPaginatorKhach' => 'site/pagextk?p=', 'ajaxElementId' => '#indexPage'); if (Yii::app()->request->isAjaxRequest) { $this->renderPartial('index', $data); } else { $this->render('index', $data); } }
echo $form->labelEx($tinKhachHang, 'noi_dung_tin'); ?> <?php echo $form->textArea($tinKhachHang, 'noi_dung_tin', array('rows' => 6, 'cols' => 50, 'id' => 'noi-dung-tin')); ?> <?php echo $form->error($tinKhachHang, 'noi_dung_tin'); ?> </div> <div class="col-md-6"> <?php echo $form->labelEx($tinKhachHang, 'trang_thai'); ?> <?php echo $form->dropDownList($tinKhachHang, 'trang_thai', Tinghepxe::getStatusTinDang(), array('class' => 'form-control')); ?> <?php echo $form->error($tinKhachHang, 'trang_thai'); ?> </div> <div class="col-md-6"> <?php echo $form->labelEx($tinGhepXe, 'dia_chi_di'); ?> <?php echo $form->textField($tinGhepXe, 'dia_chi_di', array('class' => 'form-control')); ?> <?php echo $form->error($tinGhepXe, 'dia_chi_di');
<?php return array('elements' => array('tinkhachhang' => array('type' => 'form', 'title' => 'Sửa tin đăng:', 'elements' => array('<div class="col-xs-12 col-sm-6 col-md-6">', 'nguoi_lien_lac' => array('type' => 'text', 'class' => 'form-control'), '</div>' . '<div class="col-xs-12 col-sm-5 col-md-5 pull-right">', 'so_dien_thoai' => array('type' => 'text', 'class' => 'form-control'), '</div>' . '<div class="clearfix"></div>' . '<div class="col-xs-12 col-sm-6 col-md-6">', 'tieu_de_tin' => array('type' => 'text', 'class' => 'form-control'), '</div>' . '<div class="col-xs-12 col-sm-5 col-md-5 pull-right">', 'tinh_thanh' => array('type' => 'dropdownlist', 'items' => Province::listProvinces(), 'class' => 'form-control'), '</div>' . '<div class="clearfix"></div>' . '<div class="col-xs-12 col-sm-6 col-md-6">', 'trang_thai' => array('type' => 'dropdownlist', 'items' => Tinghepxe::getStatusTinDang(), 'class' => 'form-control'), '</div>' . '<div class="col-md-12">', 'noi_dung_tin' => array('type' => 'textarea', 'rows' => '10', 'class' => 'form-control', 'id' => 'noi-dung-tin'), '</div>')), 'tinghepxe' => array('type' => 'form', 'elements' => array('<div class ="col-md-6">', 'dia_chi_di' => ['type' => 'text', 'class' => 'form-control'], '</div>' . '<div class ="col-md-5 pull-right">', 'dia_chi_den' => ['type' => 'text', 'class' => 'form-control'], '</div>' . '<div class="clearfix"></div>' . '<div class ="col-md-6">', 'noi_den_tinh' => ['type' => 'dropdownlist', 'items' => Province::listProvinces(), 'class' => 'form-control'], '</div>' . '<div class ="col-md-5 pull-right">', 'ma_loai_xe_ghep' => ['type' => 'dropdownlist', 'items' => Loaixeghep::optionLoaiXeGhep(), 'class' => 'form-control'], '</div>' . '<div class="clearfix"></div>' . '<div class ="col-md-3">', 'ngay_khoi_hanh' => ['type' => 'date', 'class' => 'form-control'], '</div>'))), 'buttons' => array('<div class="col-md-12 text-center">', 'dangtin' => array('type' => 'submit', 'label' => 'Đăng tin', 'class' => 'btn-success'), '</div>'));
/** * 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')); }
/** * Xem chi tiết tin khách tìm xe */ public function actionXem_chi_tiet() { $maTin = Yii::app()->request->getParam('id'); if ($maTin == '') { $this->redirect(Yii::app()->homeUrl); } $modelKTX = new Tinghepxe(); if (!($tinKTX = $modelKTX->getTinGhepXe($maTin))) { $this->redirect(['site/index']); } $this->render('xem_chi_tiet', ['tinKTX' => $tinKTX]); }
/** * * @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]); }
/** * 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(); }
/** * Xem chi tiết tin Xe tìm khách */ public function actionXem_chi_tiet($condition = null) { $maTin = Yii::app()->request->getParam('id'); $modelXTK = new Tinghepxe(); if (!($tinXTK = $modelXTK->getTinGhepXe($maTin))) { $this->redirect(['site/index']); } $this->render('xem_chi_tiet', ['tinXTK' => $tinXTK]); }