public function actionUser_edit() { $this->setauth(); //检查有无权限 $id = $_GET['id']; $detail = VcosMember::model()->findByPk($id); $country = VcosCountry::model()->findAll(); $nation = VcosMemberNation::model()->findAll(); if ($_POST) { $sql = "SELECT * FROM vcos_member WHERE passport_number = '{$_POST['passport']}' AND member_code NOT IN ({$_POST['member_id']})"; $result = Yii::app()->db->createCommand($sql)->queryAll(); if ($result) { die(Helper::show_message(yii::t('vcos', '此护照已被使用'))); } if ($_POST['member_id'] != '' && $_POST['cn_name'] != '' && $_POST['last_name'] != '' && $_POST['first_name'] != '' && $_POST['dob'] != '' && $_POST['birth_place'] != '' && $_POST['passport'] != '' && $_POST['passport_validate'] != '' && $_POST['issue_place'] != '' && $_POST['ic_number'] != '') { $passport_validate = explode(" - ", $_POST['passport_validate']); $detail->member_id = $id; $detail->cn_name = $_POST['cn_name']; $detail->last_name = $_POST['last_name']; $detail->first_name = $_POST['first_name']; $detail->sex = $_POST['sex']; $detail->date_of_birth = strtotime($_POST['dob']); $detail->birth_place = $_POST['birth_place']; $detail->country_code = $_POST['country']; $detail->nation_code = $_POST['nation']; $detail->mobile_number = $_POST['mobile']; $detail->passport_number = $_POST['passport']; $detail->passport_date_issue = strtotime($passport_validate[0]); $detail->passport_expiry_date = strtotime($passport_validate[1]); $detail->passport_place_issue = $_POST['issue_place']; $detail->resident_id_card = $_POST['ic_number']; $detail->member_name = $_POST['member_name']; $detail->member_email = $_POST['email']; if ($detail->save() > 0) { Helper::show_message(yii::t('vcos', '修改成功'), Yii::app()->createUrl("User/user_list")); } else { Helper::show_message(yii::t('vcos', '修改失败')); } } else { Helper::show_message(yii::t('vcos', '修改失败')); } } $this->render('user_edit', array('detail' => $detail, 'country' => $country, 'nation' => $nation)); }
public function actionProduct_country_edit() { $this->setauth(); //检查有无权限 $p_db = Yii::app()->p_db; $id = $_GET['id']; $country = VcosCountry::model()->findByPk($id); if ($_POST) { $name = isset($_POST['name']) ? $_POST['name'] : ''; $name_en = isset($_POST['name_en']) ? $_POST['name_en'] : ''; $photo = ''; if ($_FILES['photo']['error'] != 4) { $result = Helper::upload_file('photo', Yii::app()->params['img_save_url'] . 'basic_images/' . Yii::app()->params['month'], 'image', 3); $photo = $result['filename']; } $photo_url = 'basic_images/' . Yii::app()->params['month'] . '/' . $photo; $state = isset($_POST['state']) ? $_POST['state'] : '0'; // var_dump($_POST);exit; //事务处理 $transaction = $p_db->beginTransaction(); try { $country->country_cn_name = $name; $country->country_en_name = $name_en; if ($photo) { $country->country_logo = $photo_url; } $country->status = $state; $country->save(); $transaction->commit(); Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Basic/product_country_list")); } catch (Exception $e) { $transaction->rollBack(); Helper::show_message(yii::t('vcos', '修改失败。')); } } $this->render('product_country_edit', array('country' => $country)); }