public static function upload_file($input_name, $file_path = './', $type = 'image', $allow_size = 2) { // 上传的文件 $file = $_FILES[$input_name]; // 错误信息 $error = ''; // 允许上传的文件类型数组 $allow_type = array('image' => array('jpg' => 'image/jpeg', 'png' => 'image/png', 'gif' => 'image/gif')); // 检查上传文件的类型是否在允许的文件类型数组里 if (!in_array($file['type'], $allow_type[$type])) { $error = "请上传" . implode('、', array_keys($allow_type[$type])) . "格式的文件"; Helper::show_message($error); die; } // 检查上传文件的大小是否超过指定大小 $size = $allow_size * 1024 * 1024; if ($file['size'] > $size) { $error = "你上传的文件大小请不要超过{$allow_size}MB"; Helper::show_message($error); die; } // 错误状态 switch ($file['error']) { case 1: $error = '你所上传的文件大小超过了服务器配置的大小'; Helper::show_message($error); die; case 2: $error = '你所上传的文件大小超过了表单设置的大小'; Helper::show_message($error); die; case 3: $error = '网络出现问题,请检查你的网络是否连接?'; Helper::show_message($error); die; case 4: $error = '请选择你要上传的文件'; Helper::show_message($error); die; } // 自动生成目录 if (!file_exists($file_path)) { mkdir($file_path, 0777, true); } if ($error) { return array('error' => 1, 'warning' => $error); } // 生成保存到服务器的文件名 $filename = date('YmdHis') . mt_rand(1000, 9999) . "." . array_search($file['type'], $allow_type[$type]); // 保存上传文件到本地目录 if (move_uploaded_file($file['tmp_name'], $file_path . "/" . $filename)) { return array('error' => 0, 'filename' => $filename); } }
/** * 编辑活动分类* */ public function actionActivity_category_edit() { $this->setauth(); // 检查有无权限 $p_db = Yii::app()->p_db; $id = $_GET['id']; $activity_category = VcosActivityCategory::model()->findByPk($id); if ($_POST) { $activity = isset($_POST['activity']) ? $_POST['activity'] : 0; $name = isset($_POST['name']) ? $_POST['name'] : ''; $sort = isset($_POST['sort']) ? $_POST['sort'] : ''; $state = isset($_POST['state']) ? $_POST['state'] : '0'; // 事务处理 $transaction = $p_db->beginTransaction(); try { $activity_category->activity_id = $activity; $activity_category->activity_category_name = $name; $activity_category->sort_order = $sort; $activity_category->status = $state; $activity_category->save(); $transaction->commit(); Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Activity/activity_category_list")); } catch (Exception $e) { $transaction->rollBack(); Helper::show_message(yii::t('vcos', '修改失败。')); } } $sql = "SELECT activity_id,activity_name FROM `vcos_activity` WHERE status=1"; $activity = Yii::app()->p_db->createCommand($sql)->queryAll(); $this->render('activity_category_edit', array('activity_category' => $activity_category, 'activity' => $activity)); }
public function actionActivity_product_edit() { $this->setauth(); //检查有无权限 $p_db = Yii::app()->p_db; $id = $_GET['id']; $layer_cat = ''; $layer_cat2 = ''; $layer_1 = ''; $layer_2 = ''; $layer_3 = ''; $product_sel = ''; $category_code = ''; $activity_product = VcosActivityProduct::model()->findByPk($id); if ($_POST) { $activicty = isset($_POST['activity']) ? $_POST['activity'] : 0; $product = isset($_POST['product']) ? $_POST['product'] : 0; $shop = isset($_POST['shop']) ? $_POST['shop'] : 0; $activity_child = isset($_POST['activity_child']) ? $_POST['activity_child'] : 0; $activity_category = isset($_POST['activity_category']) ? $_POST['activity_category'] : 0; $sort = isset($_POST['sort']) ? $_POST['sort'] : ''; $product_type = isset($_POST['product_type']) ? $_POST['product_type'] : 0; $time = explode(" - ", $_POST['time']); $s_time = $time[0] . ' ' . $_POST['stime']; $e_time = $time[1] . ' ' . $_POST['etime']; $stime = date('Y/m/d H:i:s', strtotime($s_time)); $etime = date('Y/m/d H:i:s', strtotime($e_time)); if ($product_type == 3) { $product_shop = $shop; $activity_category = ''; } elseif ($product_type == 6) { $product_shop = $product; $activity_category = $activity_category; } elseif ($product_type == 4) { $product_shop = $activity_child; $activity_category = ''; } //事务处理 $transaction = $p_db->beginTransaction(); try { $activity_product->activity_id = $activicty; $activity_product->product_id = $product_shop; $activity_product->activity_cid = $activity_category; $activity_product->sort_order = $sort; $activity_product->start_show_time = $stime; $activity_product->end_show_time = $etime; $activity_product->product_type = $product_type; $activity_product->save(); $transaction->commit(); Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Activity/activity_product_list")); } catch (Exception $e) { $transaction->rollBack(); Helper::show_message(yii::t('vcos', '修改失败。')); } } $sql = "SELECT activity_id,activity_name FROM `vcos_activity` WHERE status=1"; $activity = Yii::app()->p_db->createCommand($sql)->queryAll(); //$sql = "SELECT product_id,product_name FROM `vcos_product` WHERE status=1"; //$product = Yii::app()->p_db->createCommand($sql)->queryAll(); $sql = "SELECT activity_cid,activity_category_name FROM `vcos_activity_category` WHERE status=1 AND activity_id = " . $activity_product['activity_id']; $activity_category = Yii::app()->p_db->createCommand($sql)->queryAll(); $sql = "SELECT shop_id,shop_title FROM `vcos_shop` "; $shop = Yii::app()->p_db->createCommand($sql)->queryAll(); $sql = "SELECT activity_id,activity_name FROM `vcos_activity` WHERE activity_id !=" . $activity[0]['activity_id']; $activity_child = Yii::app()->p_db->createCommand($sql)->queryAll(); if ($activity_product['product_type'] == 6) { $sql = "SELECT category_code FROM `vcos_product` WHERE product_id=" . $activity_product['product_id']; $category_code = Yii::app()->p_db->createCommand($sql)->queryRow(); $category_code = $category_code['category_code']; $sql = "SELECT parent_cid FROM `vcos_category` WHERE category_code =" . $category_code; $layer_cat_2 = $p_db->createCommand($sql)->queryRow(); $sql = "SELECT parent_cid FROM `vcos_category` WHERE category_code =" . $layer_cat_2['parent_cid']; $layer_cat_1 = $p_db->createCommand($sql)->queryRow(); $sql = "SELECT category_code,name,parent_cid FROM `vcos_category` WHERE parent_cid=0"; $layer_1 = $p_db->createCommand($sql)->queryAll(); $sql = "SELECT category_code,name,parent_cid FROM `vcos_category` WHERE parent_cid=" . $layer_cat_1['parent_cid']; $layer_2 = $p_db->createCommand($sql)->queryAll(); $sql = "SELECT category_code,name,parent_cid FROM `vcos_category` WHERE parent_cid=" . $layer_cat_2['parent_cid']; $layer_3 = $p_db->createCommand($sql)->queryAll(); $sql = "SELECT product_id,product_name FROM `vcos_product` WHERE category_code=" . $category_code; $product = $p_db->createCommand($sql)->queryAll(); $layer_cat = $layer_cat_1['parent_cid']; $layer_cat2 = $layer_cat_2['parent_cid']; } else { $sql = "SELECT category_code,name,parent_cid FROM `vcos_category` WHERE parent_cid=0"; $layer_1 = $p_db->createCommand($sql)->queryAll(); $sql = "SELECT category_code,name,parent_cid FROM `vcos_category` WHERE parent_cid=" . $layer_1[0]['category_code']; $layer_2 = $p_db->createCommand($sql)->queryAll(); $sql = "SELECT category_code,name,parent_cid FROM `vcos_category` WHERE parent_cid=" . $layer_2[0]['category_code']; $layer_3 = $p_db->createCommand($sql)->queryAll(); $sql = "SELECT product_id,product_name,category_code FROM `vcos_product` WHERE status=1 AND category_code=" . $layer_3[0]['category_code']; $product = Yii::app()->p_db->createCommand($sql)->queryAll(); } $this->render('activity_product_edit', array('activity_child' => $activity_child, 'shop' => $shop, 'activity' => $activity, 'product' => $product, 'activity_category' => $activity_category, 'activity_product' => $activity_product, 'layer_cat' => $layer_cat, 'layer_cat2' => $layer_cat2, 'layer_1' => $layer_1, 'layer_2' => $layer_2, 'layer_3' => $layer_3, 'category_code' => $category_code)); }
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)); }
public function actionNav_product_category_add() { $this->setauth(); //检查有无权限 $p_db = Yii::app()->p_db; $group = new VcosNavigationGroup(); $group_category = new VcosNavigationGroupCategory(); $nav = isset($_POST['nav']) ? $_POST['nav'] : 0; $val = isset($_POST['val']) ? $_POST['val'] : 0; $parent = isset($_POST['parent']) ? $_POST['parent'] : 0; $name = isset($_POST['name']) ? $_POST['name'] : ''; $sort = isset($_POST['sort']) ? $_POST['sort'] : ''; $img_name = isset($_POST['img_name']) ? $_POST['img_name'] : ''; $cat_name = isset($_POST['cat_name']) ? $_POST['cat_name'] : ''; $highlight = isset($_POST['highlight']) ? $_POST['highlight'] : 0; //var_dump($_POST);exit; if ($val == 0 || $val == '') { //新增 if ($parent == 0) { $photo = ''; if ($_FILES[$img_name]['error'] != 4) { $result = Helper::upload_file($img_name, Yii::app()->params['img_save_url'] . 'navigation_images/' . Yii::app()->params['month'], 'image', 3); $photo = $result['filename']; } $photo_url = 'navigation_images/' . Yii::app()->params['month'] . '/' . $photo; //事务处理 $transaction = $p_db->beginTransaction(); try { $group->navigation_id = $nav; $group->navigation_group_name = $name; $group->sort_order = $sort; $group->img_url = $photo_url; $group->save(); //$id = $group->attributes['navigation_group_id']; $transaction->commit(); Helper::show_message(yii::t('vcos', '添加成功。'), Yii::app()->createUrl("Navigation/nav_column_set", array('nav' => $nav, 'act' => 'category', 'op' => 1))); } catch (Exception $e) { $transaction->rollBack(); Helper::show_message(yii::t('vcos', '添加失败。'), Yii::app()->createUrl("Navigation/nav_column_set", array('nav' => $nav, 'act' => 'category', 'op' => 1))); } } else { //事务处理 $transaction = $p_db->beginTransaction(); try { $group_category->navigation_group_id = $parent; $group_category->navigation_category_name = $name; $group_category->sort_order = $sort; $group_category->is_highlight = $highlight; $group_category->category_type = 1; $group_category->mapping_id = $cat_name; $group_category->save(); //$id = $group->attributes['navigation_group_id']; $transaction->commit(); Helper::show_message(yii::t('vcos', '添加成功。'), Yii::app()->createUrl("Navigation/nav_column_set", array('nav' => $nav, 'act' => 'category', 'op' => 1))); } catch (Exception $e) { $transaction->rollBack(); Helper::show_message(yii::t('vcos', '添加失败。'), Yii::app()->createUrl("Navigation/nav_column_set", array('nav' => $nav, 'act' => 'category', 'op' => 1))); } } } else { //修改 if ($parent == 0) { $photo = ''; if ($_FILES[$img_name]['error'] != 4) { $result = Helper::upload_file($img_name, Yii::app()->params['img_save_url'] . 'navigation_images/' . Yii::app()->params['month'], 'image', 3); $photo = $result['filename']; } $photo_url = 'navigation_images/' . Yii::app()->params['month'] . '/' . $photo; //事务处理 $transaction = $p_db->beginTransaction(); try { if ($photo == '') { $sql = "UPDATE `vcos_navigation_group` SET navigation_group_name='{$name}' WHERE navigation_group_id='{$val}'"; } else { $sql = "UPDATE `vcos_navigation_group` SET navigation_group_name='{$name}',img_url='{$photo_url}' WHERE navigation_group_id='{$val}'"; } Yii::app()->p_db->createCommand($sql)->execute(); $transaction->commit(); Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Navigation/nav_column_set", array('nav' => $nav, 'act' => 'category', 'op' => 1))); } catch (Exception $e) { $transaction->rollBack(); Helper::show_message(yii::t('vcos', '修改失败。'), Yii::app()->createUrl("Navigation/nav_column_set", array('nav' => $nav, 'act' => 'category', 'op' => 1))); } } else { //事务处理 $transaction = $p_db->beginTransaction(); try { $sql = "UPDATE `vcos_navigation_group_category` SET navigation_category_name='{$name}',mapping_id='{$cat_name}',is_highlight='{$highlight}' WHERE navigation_group_cid='{$val}'"; Yii::app()->p_db->createCommand($sql)->execute(); $transaction->commit(); Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Navigation/nav_column_set", array('nav' => $nav, 'act' => 'category', 'op' => 1))); } catch (Exception $e) { $transaction->rollBack(); Helper::show_message(yii::t('vcos', '修改失败。'), Yii::app()->createUrl("Navigation/nav_column_set", array('nav' => $nav, 'act' => 'category', 'op' => 1))); } } } }
public function actionShop_operation() { $this->setauth(); //检查有无权限 $p_db = Yii::app()->p_db; if ($_POST) { $str_sql = ''; $str_cat2 = array(); $str_cat1 = array(); $shop = $_POST['shop']; $data = $_POST['code']; //分区一二三级 $cat1 = ''; $cat2 = ''; $cat3 = ''; foreach ($data as $row) { if (strlen($row) == 2) { $cat1 .= $row . ','; } else { if (strlen($row) == 4) { $cat2 .= $row . ','; } else { if (strlen($row)) { $cat3 .= $row . ','; } } } } $cat1 = trim($cat1, ','); $cat2 = trim($cat2, ','); $cat3 = trim($cat3, ','); $cat1 = explode(',', $cat1); $cat2 = explode(',', $cat2); $cat3 = explode(',', $cat3); //连接三级sql,并判断父类存在否 if (!empty($cat3)) { foreach ($cat3 as $row) { $parent_1 = substr($row, 0, 2); $parent_2 = substr($row, 0, 4); if (!in_array($parent_1, $cat1) && !in_array($parent_1, $str_cat1)) { $str_cat1[] = $parent_1; } if (!in_array($parent_2, $cat2) && !in_array($parent_2, $str_cat2)) { $str_cat2[] = $parent_2; } $str_sql .= "('{$shop}','{$row}','3','1','1','{$parent_2}'),"; } } //连接二级,全选状态 if (!empty($cat2)) { foreach ($cat2 as $row) { $parent_1 = substr($row, 0, 2); if ($row != '') { $str_sql .= "('{$shop}','{$row}','2','1','1','{$parent_1}'),"; } } } //连接二级不选中状态 if (!empty($str_cat2)) { foreach ($str_cat2 as $row) { $parent_1 = substr($row, 0, 2); if ($row != '') { $str_sql .= "('{$shop}','{$row}','2','0','1','{$parent_1}'),"; } } } //连接一级,全选状态 if (!empty($cat1)) { foreach ($cat1 as $row) { if ($row != '') { $str_sql .= "('{$shop}','{$row}','1','1','1','0'),"; } } } //连接一级不选中状态 if (!empty($str_cat1)) { foreach ($str_cat1 as $row) { if ($row != '') { $str_sql .= "('{$shop}','{$row}','1','0','1','0'),"; } } } $str_sql = trim($str_sql, ','); $transaction = $p_db->beginTransaction(); try { $sql = "INSERT INTO `vcos_shop_operation_category`(shop_id,category_code,tree_type,is_sub_all,status,parent_catogory_code) VALUES" . $str_sql; $result = $p_db->createCommand($sql)->execute(); $transaction->commit(); Helper::show_message(yii::t('vcos', '添加成功。'), Yii::app()->createUrl("Shop/Shop_operation")); } catch (Exception $e) { $transaction->rollBack(); Helper::show_message(yii::t('vcos', '添加失败。')); } } $sql = "SELECT shop_id,shop_title FROM `vcos_shop` WHERE shop_status=1"; $shop = $p_db->createCommand($sql)->queryAll(); $sql = "SELECT category_code,name,parent_cid FROM `vcos_category` WHERE status=1 AND parent_cid=0"; $cat1_sel = $p_db->createCommand($sql)->queryAll(); $sql = "SELECT category_code,name,parent_cid FROM `vcos_category` WHERE status=1 AND length(category_code)=4 ORDER BY parent_cid"; $cat2_sel = $p_db->createCommand($sql)->queryAll(); $sql = "SELECT category_code,name,parent_cid FROM `vcos_category` WHERE status=1 AND length(category_code)=7 ORDER BY parent_cid"; $cat3_sel = $p_db->createCommand($sql)->queryAll(); $cat1_but = $cat1_sel[0]['category_code']; $cat2_but = $cat2_sel[0]['category_code']; $this->render('shop_operation', array('cat1_but' => $cat1_but, 'cat2_but' => $cat2_but, 'shop' => $shop, 'cat1_sel' => $cat1_sel, 'cat2_sel' => $cat2_sel, 'cat3_sel' => $cat3_sel)); }
public function actionProduct_graphic_edit() { $this->setauth(); //检查有无权限 $p_db = Yii::app()->p_db; $id = $_GET['id']; $product_graphic = VcosProductGraphic::model()->findByPk($id); if ($_POST) { $product = isset($_POST['product']) ? $_POST['product'] : 0; $desc = isset($_POST['desc']) ? $_POST['desc'] : ''; $sort = isset($_POST['sort']) ? $_POST['sort'] : 0; $photo = ''; if ($_FILES['photo']['error'] != 4) { $result = Helper::upload_file('photo', Yii::app()->params['img_save_url'] . 'product_images/' . Yii::app()->params['month'], 'image', 3); $photo = $result['filename']; } $photo_url = 'product_images/' . Yii::app()->params['month'] . '/' . $photo; //事务处理 $transaction = $p_db->beginTransaction(); try { $product_graphic->product_id = $product; if ($desc != '') { $product_graphic->graphic_desc = $desc; } if ($photo) { $product_graphic->img_url = $photo_url; } $product_graphic->sort_order = $sort; $product_graphic->save(); $transaction->commit(); Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Product/product_graphic_list")); } catch (Exception $e) { $transaction->rollBack(); Helper::show_message(yii::t('vcos', '修改失败。')); } } $sql = "SELECT category_code FROM `vcos_product` WHERE product_id=" . $product_graphic['product_id']; $category_code = Yii::app()->p_db->createCommand($sql)->queryRow(); $category_code = $category_code['category_code']; $sql = "SELECT parent_cid FROM `vcos_category` WHERE category_code =" . $category_code; $layer_cat_2 = $p_db->createCommand($sql)->queryRow(); $sql = "SELECT parent_cid FROM `vcos_category` WHERE category_code =" . $layer_cat_2['parent_cid']; $layer_cat_1 = $p_db->createCommand($sql)->queryRow(); $sql = "SELECT category_code,name,parent_cid FROM `vcos_category` WHERE parent_cid=0"; $layer_1 = $p_db->createCommand($sql)->queryAll(); $sql = "SELECT category_code,name,parent_cid FROM `vcos_category` WHERE parent_cid=" . $layer_cat_1['parent_cid']; $layer_2 = $p_db->createCommand($sql)->queryAll(); $sql = "SELECT category_code,name,parent_cid FROM `vcos_category` WHERE parent_cid=" . $layer_cat_2['parent_cid']; $layer_3 = $p_db->createCommand($sql)->queryAll(); $sql = "SELECT product_id,product_name FROM `vcos_product` WHERE category_code=" . $category_code; $product = $p_db->createCommand($sql)->queryAll(); $layer_cat = $layer_cat_1['parent_cid']; $layer_cat2 = $layer_cat_2['parent_cid']; $this->render('product_graphic_edit', array('product_graphic' => $product_graphic, 'product' => $product, 'layer_cat' => $layer_cat, 'layer_cat2' => $layer_cat2, 'layer_1' => $layer_1, 'layer_2' => $layer_2, 'layer_3' => $layer_3, 'category_code' => $category_code)); }
public function actionWifi_config_edit() { $this->setauth(); //检查有无权限 $id = $_GET['id']; $wifi = VcosWifiConfig::model()->findByPk($id); if ($_POST) { if ($_POST['describe'] != '' && $_POST['loginurl'] != '' && $_POST['logouturl'] != '' && $_POST['change'] != '' && $_POST['notice'] != '' && $_POST['policy'] != '' && $_POST['ssid'] != '' && $_POST['acip'] != '' && $_POST['apmac'] != '') { $wifi->config_id = $id; $wifi->config_describe = $_POST['describe']; $wifi->config_login_url = $_POST['loginurl']; $wifi->config_logout_url = $_POST['logouturl']; $wifi->config_change_url = $_POST['change']; $wifi->config_notice = $_POST['notice']; $wifi->config_policy = $_POST['policy']; $wifi->config_ssid = $_POST['ssid']; $wifi->config_acip = $_POST['acip']; $wifi->config_apmac = $_POST['apmac']; if ($wifi->save() > 0) { Helper::show_message(yii::t('vcos', '修改成功'), Yii::app()->createUrl("Wifisetting/wifi_config_list")); } else { Helper::show_message(yii::t('vcos', '修改失败')); } } else { Helper::show_message(yii::t('vcos', '修改失败')); } } $this->render('wifi_config_edit', array('wifi' => $wifi)); }
public function actionHelp_category_edit() { $this->setauth(); //检查有无权限 $id = $_GET['id']; $help_category = VcosHelpCategory::model()->findByPk($id); $sql = "SELECT b.id FROM vcos_help_category a LEFT JOIN vcos_help_category_language b ON a.id = b.category_id WHERE a.id = {$id} AND b.iso ='" . Yii::app()->params['language'] . "'"; $id2 = Yii::app()->m_db->createCommand($sql)->queryRow(); $help_category_language = VcosHelpCategoryLanguage::model()->findByPk($id2['id']); if ($_POST) { $state = isset($_POST['state']) ? $_POST['state'] : '0'; //事务处理 $db = Yii::app()->m_db; $transaction = $db->beginTransaction(); try { if (isset($_POST['language']) && $_POST['language'] != '') { //编辑系统语言和外语状态下 //编辑主表 $db->createCommand()->update('vcos_help_category', array('state' => $state), 'id = :id', array(':id' => $id)); //编辑系统语言 $category_columns = array('category_name' => $_POST['title']); //编辑系统语言 $db->createCommand()->update('vcos_help_category_language', $category_columns, 'id=:id', array(':id' => $id2['id'])); //判断外语是新增OR编辑 if ($_POST['judge'] == 'add') { //新增外语 $db->createCommand()->insert('vcos_help_category_language', array('category_id' => $id, 'iso' => $_POST['language'], 'category_name' => $_POST['title_iso'])); } else { //编辑外语 $columns = array('category_name' => $_POST['title_iso']); $db->createCommand()->update('vcos_help_category_language', $columns, 'id=:id', array(':id' => $_POST['judge'])); } //事务提交 $transaction->commit(); Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Commentandhelp/help_category")); } else { //只编辑系统语言状态下 $help_category->id = $id; $help_category->state = $state; $help_category->save(); $help_category_language->id = $id2['id']; $help_category_language->category_name = $_POST['title']; $help_category_language->save(); $transaction->commit(); Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Commentandhelp/help_category")); } } catch (Exception $e) { $transaction->rollBack(); } } $this->render('help_category_edit', array('help_category' => $help_category, 'help_category_language' => $help_category_language)); }
public function actionUpdateProductCheckInventory() { $this->setauth(); //检查有无权限 $p_db = Yii::app()->p_db; $code = isset($_POST['code']) ? $_POST['code'] : ''; $name = isset($_POST['name']) ? $_POST['name'] : ''; $status = isset($_POST['status']) ? $_POST['status'] : ''; $inventory_old = isset($_POST['inventory_old']) ? $_POST['inventory_old'] : ''; $inventory = isset($_POST['inventory']) ? $_POST['inventory'] : ''; $time = date('Y-m-d H:i:s', time()); $this_user_name = Yii::app()->user->name; $flag = 0; if ($code != '') { $transaction = $p_db->beginTransaction(); try { $check_code = OrderService::createOrderno(); //新增盘点记录 $sql = "INSERT INTO `vcos_product_check` (check_code,check_time,check_type,check_people) VALUES ('{$check_code}','{$time}','{$status[0]}','{$this_user_name}')"; Yii::app()->p_db->createCommand($sql)->execute(); for ($i = 0; $i < count($code); $i++) { $sql = "INSERT INTO `vcos_product_check_detail` (check_code,product_name,inventory_num,check_num,product_code) VALUES ('{$check_code}','{$name[$i]}','{$inventory_old[$i]}','{$inventory[$i]}','{$code[$i]}')"; Yii::app()->p_db->createCommand($sql)->execute(); $sql = "UPDATE `vcos_product` SET inventory_num='{$inventory[$i]}' WHERE product_code='{$code[$i]}'"; Yii::app()->p_db->createCommand($sql)->execute(); } $transaction->commit(); $flag = 1; } catch (Exception $e) { $transaction->rollBack(); $flag = 0; } } if ($flag == 1) { Helper::show_message(yii::t('vcos', '提交成功。'), Yii::app()->createUrl("Product/product_check")); } else { Helper::show_message(yii::t('vcos', '提交失败。'), Yii::app()->createUrl("Product/product_check")); } }
public function actionRestaurant_img_edit() { $this->setauth(); //检查有无权限 $id = $_GET['id']; $restaurant_img = VcosRestaurantImg::model()->findByPk($id); if ($_POST) { $photo = ''; if ($_FILES['photo']['error'] != 4) { $result = Helper::upload_file('photo', Yii::app()->params['img_save_url'] . 'restaurant_images/' . Yii::app()->params['month'], 'image', 3); $photo = $result['filename']; } $state = isset($_POST['state']) ? $_POST['state'] : '0'; $iso = isset($_POST['language']) ? $_POST['language'] : 'zh_cn'; /* if($state == '0'){ $result = VcosRestaurantImg::model()->count('id=:id',array(':id'=>$id)); if($result>0){ die(Helper::show_message(yii::t('vcos', '此分类正在使用,不能禁用'))); } }*/ //事务处理 $db = Yii::app()->m_db; $transaction = $db->beginTransaction(); try { $restaurant_img->id = $id; $restaurant_img->restaurant_id = $_POST['restaurant']; $restaurant_img->state = $state; $restaurant_img->iso = $iso; if ($photo) { $restaurant_img->img_url = 'restaurant_images/' . Yii::app()->params['month'] . '/' . $photo; } $restaurant_img->save(); $transaction->commit(); Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Restaurant/Restaurant_img_list")); } catch (Exception $e) { $transaction->rollBack(); Helper::show_message(yii::t('vcos', '修改失败。'), '#'); } } $res_sql = "SELECT a.restaurant_id,b.restaurant_name FROM vcos_restaurant a LEFT JOIN vcos_restaurant_language b ON a.restaurant_id = b.restaurant_id WHERE b.iso = '" . Yii::app()->language . "' AND a.restaurant_state = '1'"; $restaurant_sel = Yii::app()->m_db->createCommand($res_sql)->queryAll(); $this->render('restaurant_img_edit', array('restaurant_sel' => $restaurant_sel, 'restaurant_img' => $restaurant_img)); }
public function actionGoods_order_edit() { $this->setauth(); //检查有无权限 $id = $_GET['id']; $detail = VcosMemberOrder::model()->findByPk($id); if ($_POST) { $detail->order_id = $id; $detail->order_remark = $_POST['remark']; $detail->order_status = $_POST['state']; $detail->is_read = '1'; if ($detail->save() > 0) { Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Dutyfreegoods/goods_order_list")); } else { Helper::show_message(yii::t('vcos', '修改失败。')); } } $sql = "SELECT *\r\n FROM vcos_member_order_detail\r\n WHERE order_serial_num = '{$detail->order_serial_num}'"; $sub_detail = Yii::app()->m_db->createCommand($sql)->queryAll(); $sql = "SELECT cn_name FROM vcos_member WHERE member_code = {$detail->membership_code}"; $user = Yii::app()->db->createCommand($sql)->queryRow(); $this->render('goods_order_edit', array('detail' => $detail, 'sub_detail' => $sub_detail, 'user' => $user)); }
public function actionGoods_order_edit() { $this->setauth(); //检查有无权限 $id = $_GET['id']; $detail = VcosGoodsOrder::model()->findByPk($id); if ($_POST) { $detail->order_id = $id; $detail->order_remark = $_POST['remark']; $detail->order_state = $_POST['state']; $detail->is_read = '1'; if ($detail->save() > 0) { Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Dutyfreegoods/goods_order_list")); } else { Helper::show_message(yii::t('vcos', '修改失败。')); } } $sql = "SELECT a.*, c.goods_name, b.goods_img_url \r\n FROM vcos_goods_order_detail a, vcos_dutyfree_goods b, vcos_dutyfree_goods_language c\r\n WHERE a.goods_id=b.goods_id AND a.order_serial_num = {$detail->order_serial_num} AND b.goods_id = c.goods_id AND c.iso = '" . Yii::app()->language . "'"; $sub_detail = Yii::app()->m_db->createCommand($sql)->queryAll(); $user = VcosMember::model()->findByPk($detail->membership_id); $this->render('goods_order_edit', array('detail' => $detail, 'sub_detail' => $sub_detail, 'user' => $user)); }
public function actionResetpassword() { $id = $_GET['id']; $admin = VcosAdmin::model()->findByPk($id); $admin->admin_id = $id; $admin->admin_password = md5('12345678'); if ($admin->save() > 0) { Helper::show_message(yii::t('vcos', '重设成功,密码为12345678。'), Yii::app()->createUrl("Auth/admin")); } else { Helper::show_message(yii::t('vcos', '重设失败。')); } }
public function actionNavigation_group_brand_edit() { $this->setauth(); //检查有无权限 $p_db = Yii::app()->p_db; $id = $_GET['id']; $navigation_group_brand = VcosNavigationGroupBrand::model()->findByPk($id); if ($_POST) { $navigation = isset($_POST['navigation']) ? $_POST['navigation'] : 0; $brand = isset($_POST['brand']) ? $_POST['brand'] : 0; $sort = isset($_POST['sort']) ? $_POST['sort'] : '0'; $state = isset($_POST['state']) ? $_POST['state'] : '0'; //事务处理 $transaction = $p_db->beginTransaction(); try { $navigation_group_brand->navigation_group_id = $navigation; $navigation_group_brand->brand_id = $brand; $navigation_group_brand->sort_order = $sort; $navigation_group_brand->status = $state; $navigation_group_brand->save(); $transaction->commit(); Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Navigation/navigation_group_brand_list")); } catch (Exception $e) { $transaction->rollBack(); Helper::show_message(yii::t('vcos', '修改失败。')); } } $sql = "SELECT navigation_group_id,navigation_group_name FROM `vcos_navigation_group` WHERE status=1"; $navigation_group = Yii::app()->p_db->createCommand($sql)->queryAll(); $sql = "SELECT brand_id,brand_cn_name FROM `vcos_brand` WHERE brand_status=1"; $brand = Yii::app()->p_db->createCommand($sql)->queryAll(); $this->render('navigation_group_brand_edit', array('brand' => $brand, 'navigation_group' => $navigation_group, 'navigation_group_brand' => $navigation_group_brand)); }
public function actionBrand_edit() { $this->setauth(); //检查有无权限 $p_db = Yii::app()->p_db; $id = $_GET['id']; $brand = VcosBrand::model()->findByPk($id); if ($_POST) { $name = isset($_POST['name']) ? $_POST['name'] : ''; $names = isset($_POST['names']) ? $_POST['names'] : ''; $country = isset($_POST['country']) ? $_POST['country'] : 0; $desc = isset($_POST['desc']) ? $_POST['desc'] : ''; $photo = ''; if ($_FILES['photo']['error'] != 4) { $result = Helper::upload_file('photo', Yii::app()->params['img_save_url'] . 'activity_images/' . Yii::app()->params['month'], 'image', 3); $photo = $result['filename']; } $photo_url = 'activity_images/' . Yii::app()->params['month'] . '/' . $photo; $state = isset($_POST['state']) ? $_POST['state'] : '0'; //事务处理 $transaction = $p_db->beginTransaction(); try { $brand->brand_cn_name = $name; $brand->brand_en_name = $names; $brand->country_id = $country; $brand->brand_desc = $desc; $brand->brand_status = $state; if ($photo) { $brand->brand_logo = $photo_url; } $brand->save(); $transaction->commit(); Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Brand/brand_list")); } catch (Exception $e) { $transaction->rollBack(); Helper::show_message(yii::t('vcos', '修改失败。')); } } $sql = "SELECT country_id,country_cn_name FROM `vcos_country` WHERE status =1"; $country = Yii::app()->p_db->createCommand($sql)->queryAll(); $this->render('brand_edit', array('brand' => $brand, 'country' => $country)); }
public function actionRoom_detail_edit() { $this->setauth(); //检查有无权限 $id = $_GET['id']; $detail = VcosRoomDetail::model()->findByPk($id); $sql = "SELECT b.id FROM vcos_room_detail a LEFT JOIN vcos_room_detail_language b ON a.detail_id = b.detail_id WHERE a.detail_id = {$id} AND b.iso ='" . Yii::app()->params['language'] . "'"; $id2 = Yii::app()->m_db->createCommand($sql)->queryRow(); $detail_language = VcosRoomDetailLanguage::model()->findByPk($id2['id']); if ($_POST) { $photo = ''; if ($_FILES['photo']['error'] != 4) { $result = Helper::upload_file('photo', Yii::app()->params['img_save_url'] . 'room_images/' . Yii::app()->params['month'], 'image', 3); $photo = $result['filename']; } $state = isset($_POST['state']) ? $_POST['state'] : '0'; //匹配替换编辑器中图片路径 $msg = $_POST['describe']; $img_ueditor = Yii::app()->params['img_ueditor_php']; $describe = preg_replace($img_ueditor, '', $msg); if ($_POST['describe_iso'] != '') { $msg_iso = $_POST['describe_iso']; $describe_iso = preg_replace($img_ueditor, '', $msg_iso); } //事务处理 $db = Yii::app()->m_db; $transaction = $db->beginTransaction(); try { if (isset($_POST['language']) && $_POST['language'] != '') { //编辑系统语言和外语状态下 //编辑主表 $columns = array('room_id' => $_POST['room'], 'detail_state' => $state); if ($photo) { //判断有无上传图片 $columns['room_img_url'] = 'room_images/' . Yii::app()->params['month'] . '/' . $photo; } $db->createCommand()->update('vcos_room_detail', $columns, 'detail_id = :id', array(':id' => $id)); //编辑系统语言 $db->createCommand()->update('vcos_room_detail_language', array('room_describe' => $describe), 'id=:id', array(':id' => $id2['id'])); //判断外语是新增OR编辑 if ($_POST['judge'] == 'add') { //新增外语 $db->createCommand()->insert('vcos_room_detail_language', array('detail_id' => $id, 'iso' => $_POST['language'], 'room_describe' => $describe_iso)); } else { //编辑外语 $db->createCommand()->update('vcos_room_detail_language', array('room_describe' => $describe_iso), 'id=:id', array(':id' => $_POST['judge'])); } //事务提交 $transaction->commit(); Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Room/room_detail")); } else { //只编辑系统语言状态下 $detail->detail_id = $id; $detail->room_id = $_POST['room']; $detail->detail_state = $state; if ($photo != '') { $detail->room_img_url = 'room_images/' . Yii::app()->params['month'] . '/' . $photo; } $detail->save(); $detail_language->id = $id2['id']; $detail_language->room_describe = $describe; $detail_language->save(); $transaction->commit(); Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Room/room_detail")); } } catch (Exception $e) { $transaction->rollBack(); Helper::show_message(yii::t('vcos', '修改失败。'), '#'); } } $sql = "SELECT * FROM vcos_room a LEFT JOIN vcos_room_language b ON a.room_id = b.room_id WHERE a.room_state = '1' AND b.iso = '" . Yii::app()->language . "'"; $room = Yii::app()->m_db->createCommand($sql)->queryAll(); $this->render('room_detail_edit', array('room' => $room, 'detail' => $detail, 'detail_language' => $detail_language)); }
public function actionResetpassword() { $id = $_GET['id']; $detail = VcosMember::model()->findByPk($id); $detail->member_id = $id; $detail->member_password = md5('888888'); if ($detail->save() > 0) { Helper::show_message(yii::t('vcos', '重设成功(密码为:12345678)'), Yii::app()->createUrl("User/user_list")); } else { Helper::show_message(yii::t('vcos', '重设失败')); } }
public function actionAd_edit() { $this->setauth(); //检查有无权限 $id = $_GET['id']; $ad = VcosAd::model()->findByPk($id); $sql = "SELECT b.id FROM vcos_ad a LEFT JOIN vcos_ad_language b ON a.ad_id = b.ad_id WHERE a.ad_id = {$id} AND b.iso ='" . Yii::app()->params['language'] . "'"; $id2 = Yii::app()->m_db->createCommand($sql)->queryRow(); $ad_language = VcosAdLanguage::model()->findByPk($id2['id']); if ($_POST) { /* $photo=''; if($_FILES['photo']['error']!=4){ $result=Helper::upload_file('photo', Yii::app()->params['img_save_url'].'myad_images/'.Yii::app()->params['month'], 'image', 3); $photo=$result['filename']; }*/ $photo = ''; $photo_iso = ''; if ($_FILES['photo']['error'] != 4) { $result = Helper::upload_file('photo', Yii::app()->params['img_save_url'] . 'myad_images/' . Yii::app()->params['month'], 'image', 3); $photo = $result['filename']; } if (isset($_POST['language']) && $_POST['language'] != '') { if ($_FILES['photo_iso']['error'] != 4) { $result = Helper::upload_file('photo_iso', Yii::app()->params['img_save_url'] . 'myad_images/' . Yii::app()->params['month'], 'image', 3); $photo_iso = $result['filename']; } } /* $photo_iso_url = ''; if($photo_iso){//判断有无上传图片 $photo_iso_url = 'myad_images/'.Yii::app()->params['month'].'/'.$photo_iso; }*/ $photo_url = ''; if ($photo) { //判断有无上传图片 $photo_url = 'myad_images/' . Yii::app()->params['month'] . '/' . $photo; } if ($_POST['type'] == 0) { //模块 $link_url = "article?article_id=" . $_POST['link_model']; if (isset($_POST['language']) && $_POST['language'] != '') { $link_url_iso = "article?article_id=" . $_POST['link_model_iso']; } } else { if ($_POST['type'] == 1) { $link_url = $_POST['link_url']; if (isset($_POST['language']) && $_POST['language'] != '') { $link_url_iso = $_POST['link_url_iso']; } } } $state = isset($_POST['state']) ? $_POST['state'] : '0'; $db = Yii::app()->m_db; $transaction = $db->beginTransaction(); try { if (isset($_POST['language']) && $_POST['language'] != '') { //编辑系统语言和外语状态下 //编辑主表 $columns = array('ad_state' => $state, 'ad_position' => $_POST['position'], 'link_type' => $_POST['type']); $db->createCommand()->update('vcos_ad', $columns, 'ad_id = :id', array(':id' => $id)); //编辑系统语言 $l_colums = array('name' => $_POST['title'], 'link_url' => $link_url); if ($photo) { //判断有无上传图片 $l_colums['img_url'] = 'myad_images/' . Yii::app()->params['month'] . '/' . $photo; } $db->createCommand()->update('vcos_ad_language', $l_colums, 'id=:id', array(':id' => $id2['id'])); //判断外语是新增OR编辑 if ($_POST['judge'] == 'add') { //新增外语 $columns = array('ad_id' => $id, 'iso' => $_POST['language'], 'name' => $_POST['title_iso'], 'link_url' => $link_url_iso); if ($photo_iso) { //判断有无上传图片 $columns['img_url'] = 'myad_images/' . Yii::app()->params['month'] . '/' . $photo_iso; } $db->createCommand()->insert('vcos_ad_language', $columns); } else { //编辑外语 $columns = array('name' => $_POST['title_iso'], 'link_url' => $link_url_iso); if ($photo_iso) { //判断有无上传图片 $columns['img_url'] = 'myad_images/' . Yii::app()->params['month'] . '/' . $photo_iso; } $db->createCommand()->update('vcos_ad_language', $columns, 'id=:id', array(':id' => $_POST['judge'])); } //事务提交 $transaction->commit(); Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Ad/ad_list")); } else { //只编辑系统语言状态下 $ad->ad_id = $id; $ad->ad_state = $state; $ad->ad_position = $_POST['position']; $ad->link_type = $_POST['type']; $ad->save(); $ad_language->id = $id2['id']; $ad_language->name = $_POST['title']; if ($photo) { //判断有无上传图片 $ad_language->img_url = 'myad_images/' . Yii::app()->params['month'] . '/' . $photo; } //$ad_language->img_url = $photo_url; $ad_language->link_url = $link_url; $ad_language->save(); $transaction->commit(); Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Ad/ad_list")); } } catch (Exception $e) { $transaction->rollBack(); Helper::show_message(yii::t('vcos', '修改失败。'), '#'); } } $sql = "SELECT a.article_id,b.article_title FROM `vcos_article` a LEFT JOIN `vcos_article_language` b ON a.article_id = b.article_id WHERE b.iso = 'zh_cn' AND a.article_state = '1'"; $title_sel = Yii::app()->m_db->createCommand($sql)->queryAll(); $sql = "SELECT a.article_id,b.article_title FROM `vcos_article` a LEFT JOIN `vcos_article_language` b ON a.article_id = b.article_id WHERE b.iso = 'en' AND a.article_state = '1'"; $title_en_sel = Yii::app()->m_db->createCommand($sql)->queryAll(); $position = VcosAdPosition::model()->findAll(); $this->render('ad_edit', array('title_sel' => $title_sel, 'title_en_sel' => $title_en_sel, 'ad' => $ad, 'position' => $position, 'ad_language' => $ad_language)); }
public function actionCommentandhelp_category_edit() { if ($this->auth[0] == '0') { $access = TRUE; } else { $error = Yii::app()->createUrl('error/index'); $this->redirect($error); } $id = $_GET['id']; $category = VcosCommentAndHelpCategory::model()->findByPk($id); if ($_POST) { $photo = ''; if ($_FILES['photo']['error'] != 4) { $result = Helper::upload_file('photo', Yii::app()->params['img_save_url'] . 'system_images/' . Yii::app()->params['month'], 'image', 3); $photo = $result['filename']; } $state = isset($_POST['state']) ? $_POST['state'] : '0'; if ($_POST['name'] != '' && $_POST['url'] != '' && $_POST['bgcolor'] != '') { $category->id = $id; $category->cnh_category_name = $_POST['name']; $category->cnh_herf_url = $_POST['url']; $category->bg_color = $_POST['bgcolor']; $category->state = $state; if ($photo) { $old = Yii::app()->params['img_save_url'] . $category['cnh_img_url']; if (file_exists($old) && $category['cnh_img_url']) { unlink($old); } $category->cnh_img_url = 'system_images/' . Yii::app()->params['month'] . '/' . $photo; } if ($category->save() > 0) { Helper::show_message(yii::t('vcos', '修改成功'), Yii::app()->createUrl("Systemsetting/Commentandhelp_category")); } else { Helper::show_message(yii::t('vcos', '修改失败')); } } else { Helper::show_message(yii::t('vcos', '修改失败')); } } $this->render('commentandhelp_category_edit', array('category' => $category)); }
public function actionReport_edit() { $this->setauth(); //检查有无权限 $id = $_GET['id']; $record = VcosWeatherRecord::model()->findByPk($id); if ($_POST) { $iso = isset($_POST['language']) ? $_POST['language'] : 'zh_cn'; //判断语言 if (isset($_POST['language']) && $_POST['language'] != '') { //外语 $time = explode(" - ", $_POST['time_iso']); $stime = date('Y/m/d H:i:s', strtotime($time[0])); $etime = date('Y/m/d H:i:s', strtotime($time[1]) + "86399"); $record->record_id = $id; $weathers = explode("-", $_POST['weather_iso']); $record->weather_id = $weathers[0]; $record->weather_name = $weathers[1]; $record->city_id = $_POST['city_iso']; $record->record_start_time = $stime; $record->record_end_time = $etime; $record->record_temperature_min = $_POST['min_temp_iso']; $record->record_temperature_max = $_POST['max_temp_iso']; $record->wind_direction = $_POST['direction_iso']; $record->wind_scale = $_POST['scale_iso']; $record->iso = $iso; $count = $record->update('record_id', 'weather_id', 'weather_name', 'record_start_time', 'record_end_time', 'record_temperature_min', 'record_temperature_max', 'wind_direction', 'wind_scale', 'iso'); if ($count > 0) { Helper::show_message(yii::t('vcos', '修改成功'), Yii::app()->createUrl("Weather/Report_list")); } else { Helper::show_message(yii::t('vcos', '修改失败')); } } else { //中文 $time = explode(" - ", $_POST['time']); $stime = date('Y/m/d H:i:s', strtotime($time[0])); $etime = date('Y/m/d H:i:s', strtotime($time[1]) + "86399"); $record->record_id = $id; $weathers = explode("-", $_POST['weather']); $record->weather_id = $weathers[0]; $record->weather_name = $weathers[1]; $record->city_id = $_POST['city']; $record->record_start_time = $stime; $record->record_end_time = $etime; $record->record_temperature_min = $_POST['min_temp']; $record->record_temperature_max = $_POST['max_temp']; $record->wind_direction = $_POST['direction']; $record->wind_scale = $_POST['scale']; $record->iso = $iso; $count = $record->update('record_id', 'weather_id', 'weather_name', 'record_start_time', 'record_end_time', 'record_temperature_min', 'record_temperature_max', 'wind_direction', 'wind_scale', 'iso'); if ($count > 0) { Helper::show_message(yii::t('vcos', '修改成功'), Yii::app()->createUrl("Weather/Report_list")); } else { Helper::show_message(yii::t('vcos', '修改失败')); } } } $sql = "SELECT a.city_id,b.city_name,b.iso FROM `vcos_strategy_city` a LEFT JOIN `vcos_strategy_city_language` b ON a.city_id = b.city_id WHERE a.state = '1' "; $city_sel = Yii::app()->db->createCommand($sql)->queryAll(); $sql = "SELECT a.id,b.weather_name,b.iso FROM `vcos_weather` a LEFT JOIN `vcos_weather_language` b ON a.id=b.weather_id"; $weather = Yii::app()->db->createCommand($sql)->queryAll(); //风速 $sql = "SELECT a.id,b.wind_scale_name,b.iso FROM `vcos_wind_scale` a LEFT JOIN `vcos_wind_scale_language` b ON a.id=b.wind_scale_id"; $wind_scale = Yii::app()->db->createCommand($sql)->queryAll(); //风向 $sql = "SELECT a.id,b.wind_direction_name,b.iso FROM `vcos_wind_direction` a LEFT JOIN `vcos_wind_direction_language` b ON a.id=b.wind_direction_id"; $wind_direction = Yii::app()->db->createCommand($sql)->queryAll(); $this->render('edit', array('city_sel' => $city_sel, 'record' => $record, 'weather' => $weather, 'wind_scale' => $wind_scale, 'wind_direction' => $wind_direction)); }
public function actionMain_nav_edit() { $this->setauth(); //检查有无权限 $id = $_GET['id']; $main_nav = VcosMainNav::model()->findByPk($id); $sql = "SELECT b.id FROM vcos_main_nav a LEFT JOIN vcos_main_nav_language b ON a.nav_id = b.nav_id WHERE a.nav_id = {$id} AND b.iso ='" . Yii::app()->language . "'"; $id2 = Yii::app()->m_db->createCommand($sql)->queryRow(); $main_nav_language = VcosMainNavLanguage::model()->findByPk($id2['id']); if ($_POST) { $photo = ''; $photo_iso = ''; if ($_FILES['photo']['error'] != 4) { $result = Helper::upload_file('photo', Yii::app()->params['img_save_url'] . 'main_images/' . Yii::app()->params['month'], 'image', 3); $photo = $result['filename']; } if (isset($_POST['language']) && $_POST['language'] != '') { if ($_FILES['photo_iso']['error'] != 4) { $result = Helper::upload_file('photo_iso', Yii::app()->params['img_save_url'] . 'main_images/' . Yii::app()->params['month'], 'image', 3); $photo_iso = $result['filename']; } } $photo_url = ''; if ($photo) { //判断有无上传图片 $photo_url = 'main_images/' . Yii::app()->params['month'] . '/' . $photo; } //$state = isset($_POST['state'])?$_POST['state']:'0'; //事务处理 $db = Yii::app()->m_db; $transaction = $db->beginTransaction(); try { if (isset($_POST['language']) && $_POST['language'] != '') { //编辑系统语言和外语状态下 //编辑主表 $columns = array('state' => $_POST['state'], 'sequence' => $_POST['sequence'], 'category_id' => $_POST['category']); $db->createCommand()->update('vcos_main_nav', $columns, 'nav_id = :id', array(':id' => $id)); //编辑系统语言 $columns = array('name' => $_POST['name'], 'bg_color' => $_POST['bgcolor']); if ($photo) { //判断有无上传图片 $columns['img_url'] = 'main_images/' . Yii::app()->params['month'] . '/' . $photo; } $db->createCommand()->update('vcos_main_nav_language', $columns, 'id=:id', array(':id' => $id2['id'])); //判断外语是新增OR编辑 if ($_POST['judge'] == 'add') { //新增外语 $columns = array('nav_id' => $id, 'iso' => $_POST['language'], 'name' => $_POST['name_iso'], 'bg_color' => $_POST['bgcolor']); if ($photo_iso) { //判断有无上传图片 $columns['img_url'] = 'main_images/' . Yii::app()->params['month'] . '/' . $photo_iso; } $db->createCommand()->insert('vcos_main_nav_language', $columns); } else { //编辑外语 $columns = array('name' => $_POST['name_iso'], 'bg_color' => $_POST['bgcolor']); if ($photo_iso) { //判断有无上传图片 $columns['img_url'] = 'main_images/' . Yii::app()->params['month'] . '/' . $photo_iso; } $db->createCommand()->update('vcos_main_nav_language', $columns, 'id=:id', array(':id' => $_POST['judge'])); } //事务提交 $transaction->commit(); Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Main/Main_nav_list")); } else { //只编辑系统语言状态下 $main_nav->nav_id = $id; $main_nav->state = $_POST['state']; $main_nav->sequence = $_POST['sequence']; $main_nav->category_id = $_POST['category']; $main_nav->save(); $main_nav_language->id = $id2['id']; $main_nav_language->name = $_POST['name']; $main_nav_language->bg_color = $_POST['bgcolor']; //$main_nav_language->img_url = $photo_url; if ($photo) { //判断有无上传图片 $main_nav_language->img_url = 'main_images/' . Yii::app()->params['month'] . '/' . $photo; } $main_nav_language->save(); $transaction->commit(); Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Main/Main_nav_list")); } } catch (Exception $e) { $transaction->rollBack(); Helper::show_message(yii::t('vcos', '修改失败。'), '#'); } } $sql = "SELECT a.main_id,b.name FROM `vcos_main_category` a LEFT JOIN `vcos_main_category_language` b ON a.main_id = b.main_id WHERE a.state = '1' AND b.iso = '" . Yii::app()->language . "'"; $category_sel = Yii::app()->m_db->createCommand($sql)->queryAll(); $this->render('main_nav_edit', array('category_sel' => $category_sel, 'main_nav' => $main_nav, 'main_nav_language' => $main_nav_language)); }
public function actionWifi_service_edit() { $this->setauth(); //检查有无权限 $id = $_GET['id']; $wifi_item = VcosWifiItem::model()->findByPk($id); $sql = "SELECT b.id FROM vcos_wifi_item a LEFT JOIN vcos_wifi_item_language b ON a.wifi_id = b.wifi_id WHERE a.wifi_id = {$id} AND b.iso ='" . Yii::app()->params['language'] . "'"; $id2 = Yii::app()->m_db->createCommand($sql)->queryRow(); $wifi_item_language = VcosWifiItemLanguage::model()->findByPk($id2['id']); if ($_POST) { $state = isset($_POST['state']) ? $_POST['state'] : '0'; $price = isset($_POST['price']) ? $_POST['price'] * 100 : '0'; $time = isset($_POST['time']) ? $_POST['time'] : '0'; //事务处理 $db = Yii::app()->m_db; $transaction = $db->beginTransaction(); try { if (isset($_POST['language']) && $_POST['language'] != '') { //编辑系统语言和外语状态下 //编辑主表 $columns = array('sale_price' => $price, 'status' => $state, 'wifi_time' => $time); $db->createCommand()->update('vcos_wifi_item', $columns, 'wifi_id = :id', array(':id' => $id)); //编辑系统语言 $db->createCommand()->update('vcos_wifi_item_language', array('wifi_name' => $_POST['name']), 'id=:id', array(':id' => $id2['id'])); //判断外语是新增OR编辑 if ($_POST['judge'] == 'add') { //新增外语 $db->createCommand()->insert('vcos_wifi_item_language', array('wifi_id' => $id, 'iso' => $_POST['language'], 'wifi_name' => $_POST['name_iso'])); } else { //编辑外语 $db->createCommand()->update('vcos_wifi_item_language', array('wifi_name' => name_iso), 'id=:id', array(':id' => $_POST['judge'])); } //事务提交 $transaction->commit(); Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Wifisetting/wifi_service_list")); } else { //只编辑系统语言状态下 $wifi_item->wifi_id = $id; $wifi_item->sale_price = $price; $wifi_item->wifi_time = $time; $wifi_item->status = $state; $wifi_item->save(); $wifi_item_language->id = $id2['id']; $wifi_item_language->wifi_name = $_POST['name']; $wifi_item_language->save(); $transaction->commit(); Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Wifisetting/wifi_service_list")); } } catch (Exception $e) { $transaction->rollBack(); Helper::show_message(yii::t('vcos', '修改失败。'), '#'); } } $this->render('wifi_service_edit', array('wifi_item' => $wifi_item, 'wifi_item_language' => $wifi_item_language)); }
public function init() { MyLanguage::setLanguage(); if (empty(Yii::app()->user->id)) { if (!stripos(Yii::app()->request->getUrl(), 'login')) { $this->redirect(Yii::app()->createUrl('login/login')); } } else { $admin_id = Yii::app()->user->id; $sql = "SELECT * FROM vcos_admin WHERE admin_id = '{$admin_id}'"; $result = Yii::app()->m_db->createCommand($sql)->queryRow(); if (!$result) { Yii::app()->session->clear(); Yii::app()->session->destroy(); die(Helper::show_message(Yii::t('vcos', '你的账户已经被删除了'), Yii::app()->createUrl("login/login"))); } } $this->auth = $this->setmyaction(); }
public function actionSafe_info_edit() { $this->setauth(); //检查有无权限 $db = Yii::app()->m_db; $id = $_GET['id']; $safe = VcosSafe::model()->findByPk($id); $sql = "SELECT b.id FROM vcos_safe a LEFT JOIN vcos_safe_language b ON a.safe_id = b.safe_id WHERE a.safe_id = {$id} AND b.iso ='" . Yii::app()->params['language'] . "'"; $id2 = Yii::app()->m_db->createCommand($sql)->queryRow(); $safe_language = VcosSafeLanguage::model()->findByPk($id2['id']); if ($_POST) { $state = isset($_POST['state']) ? $_POST['state'] : '0'; //事务处理 $db = Yii::app()->m_db; $transaction = $db->beginTransaction(); try { if (isset($_POST['language']) && $_POST['language'] != '') { //编辑系统语言和外语状态下 //编辑主表 $db->createCommand()->update('vcos_safe', array('safe_state' => $state), 'safe_id = :id', array(':id' => $id)); //编辑系统语言 $db->createCommand()->update('vcos_safe_language', array('safe_title' => $_POST['title'], 'safe_content' => $_POST['describe']), 'id=:id', array(':id' => $id2['id'])); //判断外语是新增OR编辑 if ($_POST['judge'] == 'add') { //新增外语 $db->createCommand()->insert('vcos_safe_language', array('safe_id' => $id, 'iso' => $_POST['language'], 'safe_title' => $_POST['title_iso'], 'safe_content' => $_POST['describe_iso'])); } else { //编辑外语 $db->createCommand()->update('vcos_safe_language', array('safe_title' => $_POST['title_iso'], 'safe_content' => $_POST['describe_iso']), 'id=:id', array(':id' => $_POST['judge'])); } //事务提交 $transaction->commit(); Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Safe/safe_info_list")); } else { //只编辑系统语言 $safe->safe_state = $state; $safe->save(); $safe_language->id = $id2['id']; $safe_language->safe_title = $_POST['title']; $safe_language->safe_content = $_POST['describe']; $safe_language->save(); $transaction->commit(); Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Safe/safe_info_list")); } } catch (Exception $e) { $transaction->rollBack(); Helper::show_message(yii::t('vcos', '修改失败。')); } } $this->render('safe_info_edit', array('safe' => $safe, 'safe_language' => $safe_language)); }
public function actionService_img_edit() { $this->setauth(); //检查有无权限 $id = $_GET['id']; $lifeservice_img = VcosLifeserviceImg::model()->findByPk($id); $sql = "SELECT ls_category FROM `vcos_lifeservice` WHERE ls_id = " . $lifeservice_img['lifeservice_id']; $lifeservice_category = Yii::app()->m_db->createCommand($sql)->queryRow(); if ($_POST) { $photo = ''; if ($_FILES['photo']['error'] != 4) { $result = Helper::upload_file('photo', Yii::app()->params['img_save_url'] . 'lifeservice_images/' . Yii::app()->params['month'], 'image', 3); $photo = $result['filename']; } $state = isset($_POST['state']) ? $_POST['state'] : '0'; $iso = isset($_POST['language']) ? $_POST['language'] : 'zh_cn'; //事务处理 $db = Yii::app()->m_db; $transaction = $db->beginTransaction(); try { $lifeservice_img->id = $id; $lifeservice_img->lifeservice_id = $_POST['life_category']; $lifeservice_img->state = $state; $lifeservice_img->iso = $iso; if ($photo) { $lifeservice_img->img_url = 'lifeservice_images/' . Yii::app()->params['month'] . '/' . $photo; } $lifeservice_img->save(); $transaction->commit(); Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Lifeservice/Service_img_list")); } catch (Exception $e) { $transaction->rollBack(); Helper::show_message(yii::t('vcos', '修改失败。'), '#'); } } $life_sql = "SELECT a.lc_id,b.lc_name FROM vcos_lifeservice_category a LEFT JOIN vcos_lifeservice_category_language b ON a.lc_id = b.lc_id WHERE b.iso = '" . Yii::app()->language . "' AND a.lc_state = '1'"; $lifeservice_sel = Yii::app()->m_db->createCommand($life_sql)->queryAll(); $sql = "SELECT a.ls_id,b.ls_title FROM vcos_lifeservice a LEFT JOIN vcos_lifeservice_language b ON a.ls_id = b.ls_id WHERE (a.ls_state = '1' OR a.ls_id={$lifeservice_img['lifeservice_id']}) AND b.iso = '" . Yii::app()->language . "' AND a.ls_category = " . $lifeservice_category['ls_category']; $life_title_sel = Yii::app()->m_db->createCommand($sql)->queryAll(); $this->render('service_img_edit', array('life_title_sel' => $life_title_sel, 'lifeservice_sel' => $lifeservice_sel, 'lifeservice_img' => $lifeservice_img, 'lifeservice_category' => $lifeservice_category['ls_category'])); }
public function actionArticle_edit() { $this->setauth(); // 检查有无权限 $id = $_GET['id']; $article = VcosArticle::model()->findByPk($id); $sql = "SELECT b.id FROM vcos_article a LEFT JOIN vcos_article_language b ON a.article_id = b.article_id WHERE a.article_id = {$id} AND b.iso ='" . Yii::app()->params['language'] . "'"; $id2 = Yii::app()->m_db->createCommand($sql)->queryRow(); $article_language = VcosArticleLanguage::model()->findByPk($id2['id']); if ($_POST) { $photo = ''; if ($_FILES['photo']['error'] != 4) { $result = Helper::upload_file('photo', Yii::app()->params['img_save_url'] . 'article_images/' . Yii::app()->params['month'], 'image', 3); $photo = $result['filename']; } $state = isset($_POST['state']) ? $_POST['state'] : '0'; $times = date("Y/m/d H:i:s", time()); $time = explode(" - ", $_POST['time']); $s_time = $time[0] . ' ' . $_POST['stime']; $e_time = $time[1] . ' ' . $_POST['etime']; $stime = date('Y/m/d H:i:s', strtotime($s_time)); $etime = date('Y/m/d H:i:s', strtotime($e_time)); // 匹配替换编辑器中图片路径 $msg = $_POST['contents']; $img_ueditor = Yii::app()->params['img_ueditor_php']; $describe = preg_replace($img_ueditor, '', $msg); if ($_POST['contents_iso'] != '') { $msg_iso = $_POST['contents_iso']; $describe_iso = preg_replace($img_ueditor, '', $msg_iso); } // 事务处理 $db = Yii::app()->m_db; $transaction = $db->beginTransaction(); try { if (isset($_POST['language']) && $_POST['language'] != '') { // 编辑系统语言和外语状态下 // 编辑主表 $columns = array('article_time' => $times, 'article_start_time' => $stime, 'article_end_time' => $etime, 'article_state' => $state); if ($photo) { // 判断有无上传图片 $columns['article_img_url'] = 'article_images/' . Yii::app()->params['month'] . '/' . $photo; } $db->createCommand()->update('vcos_article', $columns, 'article_id = :id', array(':id' => $id)); // 编辑系统语言 $db->createCommand()->update('vcos_article_language', array('article_title' => $_POST['title'], 'article_abstract' => $_POST['abstract'], 'article_content' => $describe), 'id=:id', array(':id' => $id2['id'])); // 判断外语是新增OR编辑 if ($_POST['judge'] == 'add') { // 新增外语 $db->createCommand()->insert('vcos_article_language', array('article_id' => $id, 'iso' => $_POST['language'], 'article_title' => $_POST['title_iso'], 'article_abstract' => $_POST['abstract_iso'], 'article_content' => $describe_iso)); } else { // 编辑外语 $db->createCommand()->update('vcos_article_language', array('article_title' => $_POST['title_iso'], 'article_abstract' => $_POST['abstract_iso'], 'article_content' => $describe_iso), 'id=:id', array(':id' => $_POST['judge'])); } // 事务提交 $transaction->commit(); Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Article/Article_list")); } else { // 只编辑系统语言 $article->article_id = $id; $article->article_time = $times; $article->article_start_time = $stime; $article->article_end_time = $etime; $article->article_state = $state; if ($photo) { $article->article_img_url = 'article_images/' . Yii::app()->params['month'] . '/' . $photo; } $article->save(); $article_language->id = $id2['id']; $article_language->article_content = $describe; $article_language->article_title = $_POST['title']; $article_language->article_abstract = $_POST['abstract']; $article_language->save(); $transaction->commit(); Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Article/Article_list")); } } catch (Exception $e) { $transaction->rollBack(); Helper::show_message(yii::t('vcos', '修改失败。')); } } $this->render('article_edit', array('article' => $article, 'article_language' => $article_language)); }
public function actionCruise_model_edit() { $this->setauth(); //检查有无权限 //获取当前配置的默认邮轮 $cruise_id = Yii::app()->params['cruise_id']; $sql = "SELECT * FROM `vcos_cruise_model` WHERE cruise_id='{$cruise_id}' LIMIT 1"; $model = Yii::app()->m_db->createCommand($sql)->queryRow(); //判断是否提交需判断 if ($model) { $act = 1; } else { $act = 0; } if ($_POST) { $photo = ''; if ($_FILES['photo']['error'] != 4) { $result = Helper::upload_file('photo', Yii::app()->params['img_save_url'] . 'cruiseinfo_images/' . Yii::app()->params['month'], 'image', 3); $photo = $result['filename']; } $photo1 = ''; if ($_FILES['photo1']['error'] != 4) { $result = Helper::upload_file('photo1', Yii::app()->params['img_save_url'] . 'cruiseinfo_images/' . Yii::app()->params['month'], 'image', 3); $photo1 = $result['filename']; } $photo_url = 'cruiseinfo_images/' . Yii::app()->params['month'] . '/' . $photo; $photo1_url = 'cruiseinfo_images/' . Yii::app()->params['month'] . '/' . $photo1; //事务处理 $db = Yii::app()->m_db; $transaction = $db->beginTransaction(); try { $sql = ''; $sql_u = ''; if ($photo != '' && $photo1 != '') { $sql = "INSERT INTO `vcos_cruise_model` (cruise_id,img_back,img_back_over) values ('{$cruise_id}','{$photo_url}','{$photo1_url}')"; $sql_u = "UPDATE `vcos_cruise_model` set img_back='{$photo_url}',img_back_over='{$photo1_url}' WHERE cruise_id='{$cruise_id}'"; } else { if ($photo != '' && $photo1 == '') { $sql = "INSERT INTO `vcos_cruise_model` (cruise_id,img_back) values ('{$cruise_id}','{$photo_url}')"; $sql_u = "UPDATE `vcos_cruise_model` set img_back='{$photo_url}' WHERE cruise_id='{$cruise_id}'"; } else { if ($photo == '' && $photo1 != '') { $sql = "INSERT INTO `vcos_cruise_model` (cruise_id,img_back_over) values ('{$cruise_id}','{$photo1_url}')"; $sql_u = "UPDATE `vcos_cruise_model` set img_back_over='{$photo1_url}' WHERE cruise_id='{$cruise_id}'"; } } } if ($sql != '' || $sql_u != '') { if ($act == 1) { Yii::app()->m_db->createCommand($sql_u)->execute(); } else { Yii::app()->m_db->createCommand($sql)->execute(); } } $transaction->commit(); Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Cruiseinfo/cruise_model_edit")); } catch (Exception $e) { $transaction->rollBack(); Helper::show_message(yii::t('vcos', '修改失败。'), '#'); } } $this->render('cruise_model_edit', array('model' => $model, 'act' => $act)); }
public function actionShop_category_edit() { $this->setauth(); //检查有无权限 $p_db = Yii::app()->p_db; $id = $_GET['id']; $shop_category = VcosShopCategory::model()->findByPk($id); if ($_POST) { $shop = isset($_POST['shop']) ? $_POST['shop'] : '0'; $category = isset($_POST['category_3']) ? $_POST['category_3'] : 0; $sort = isset($_POST['sort']) ? $_POST['sort'] : 0; //事务处理 $transaction = $p_db->beginTransaction(); try { $shop_category->shop_id = $shop; $shop_category->category_code = $category; $shop_category->sort_order = $sort; $shop_category->save(); $transaction->commit(); Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Shop/shop_category_list")); } catch (Exception $e) { $transaction->rollBack(); Helper::show_message(yii::t('vcos', '修改失败。')); } } $category_code = $shop_category['category_code']; $sql = "SELECT parent_cid FROM `vcos_category` WHERE category_code =" . $category_code; $layer_cat_2 = $p_db->createCommand($sql)->queryRow(); $sql = "SELECT parent_cid FROM `vcos_category` WHERE category_code =" . $layer_cat_2['parent_cid']; $layer_cat_1 = $p_db->createCommand($sql)->queryRow(); $sql = "SELECT shop_id,shop_title from `vcos_shop` WHERE shop_status=1"; $shop = $p_db->createCommand($sql)->queryAll(); $sql = "SELECT category_code,name,parent_cid FROM `vcos_category` WHERE parent_cid=0"; $layer_1 = $p_db->createCommand($sql)->queryAll(); $sql = "SELECT category_code,name,parent_cid FROM `vcos_category` WHERE parent_cid=" . $layer_cat_1['parent_cid']; $layer_2 = $p_db->createCommand($sql)->queryAll(); $sql = "SELECT category_code,name,parent_cid FROM `vcos_category` WHERE parent_cid=" . $layer_cat_2['parent_cid']; $layer_3 = $p_db->createCommand($sql)->queryAll(); $this->render('shop_category_edit', array('shop' => $shop, 'layer_cat' => $layer_cat_1['parent_cid'], 'layer_cat2' => $layer_cat_2['parent_cid'], 'shop_category' => $shop_category, 'layer_1' => $layer_1, 'layer_2' => $layer_2, 'layer_3' => $layer_3)); }
public function actionCruise_deck_point_edit() { $this->setauth(); //检查有无权限 $id = $_GET['id']; $cruise_deck_point = VcosCruiseDeckPoint::model()->findByPk($id); $sql = "SELECT b.id FROM vcos_cruise_deck_point a LEFT JOIN vcos_cruise_deck_point_language b ON a.deck_point_id = b.deck_point_id WHERE a.deck_point_id = {$id} AND b.iso ='" . Yii::app()->language . "'"; $id2 = Yii::app()->m_db->createCommand($sql)->queryRow(); $cruise_deck_point_language = VcosCruiseDeckPointLanguage::model()->findByPk($id2['id']); if ($_POST) { $photo = ''; $photo_iso = ''; if ($_FILES['photo']['error'] != 4) { $result = Helper::upload_file('photo', Yii::app()->params['img_save_url'] . 'cruiseinfo_images/' . Yii::app()->params['month'], 'image', 3); $photo = $result['filename']; } if (isset($_POST['language']) && $_POST['language'] != '') { if ($_FILES['photo_iso']['error'] != 4) { $result = Helper::upload_file('photo_iso', Yii::app()->params['img_save_url'] . 'cruiseinfo_images/' . Yii::app()->params['month'], 'image', 3); $photo_iso = $result['filename']; } } $state = isset($_POST['state']) ? $_POST['state'] : '0'; //匹配替换编辑器中图片路径 $msg = $_POST['contents']; $img_ueditor = Yii::app()->params['img_ueditor_php']; $describe = preg_replace($img_ueditor, '', $msg); if ($_POST['contents_iso'] != '') { $msg_iso = $_POST['contents_iso']; $describe_iso = preg_replace($img_ueditor, '', $msg_iso); } //事务处理 $db = Yii::app()->m_db; $transaction = $db->beginTransaction(); try { if (isset($_POST['language']) && $_POST['language'] != '') { //编辑系统语言和外语状态下 //编辑主表 $columns = array('deck_point_state' => $state, 'deck_number' => $_POST['number'], 'deck_id' => $_POST['deck']); $db->createCommand()->update('vcos_cruise_deck_point', $columns, 'deck_point_id = :id', array(':id' => $id)); if ($photo_iso) { //判断有无上传图片 $photo_iso_url = 'cruiseinfo_images/' . Yii::app()->params['month'] . '/' . $photo_iso; } $columns_deck_point = array('deck_point_name' => $_POST['name'], 'deck_point_describe' => $_POST['desc'], 'deck_point_info' => $describe); if ($photo != '') { //判断有无上传图片 $columns_deck_point['img_url'] = 'cruiseinfo_images/' . Yii::app()->params['month'] . '/' . $photo; } //编辑系统语言 $db->createCommand()->update('vcos_cruise_deck_point_language', $columns_deck_point, 'id=:id', array(':id' => $id2['id'])); //判断外语是新增OR编辑 if ($_POST['judge'] == 'add') { //新增外语 $db->createCommand()->insert('vcos_cruise_deck_point_language', array('deck_point_id' => $id, 'iso' => $_POST['language'], 'img_url' => $photo_iso_url, 'deck_point_name' => $_POST['name_iso'], 'deck_point_describe' => $_POST['desc_iso'], 'deck_point_info' => $describe_iso)); } else { //编辑外语 $columns_deck_point_language = array('deck_point_name' => $_POST['name_iso'], 'deck_point_describe' => $_POST['desc_iso'], 'deck_point_info' => $describe_iso); if ($photo_iso != '') { //判断有无上传图片 $columns_deck_point_language['img_url'] = 'cruiseinfo_images/' . Yii::app()->params['month'] . '/' . $photo_iso; } $db->createCommand()->update('vcos_cruise_deck_point_language', $columns_deck_point_language, 'id=:id', array(':id' => $_POST['judge'])); } //事务提交 $transaction->commit(); Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Cruiseinfo/Cruise_deck_point_list")); } else { //只编辑系统语言状态下 $cruise_deck_point->deck_point_state = $state; $cruise_deck_point->deck_number = $_POST['number']; $cruise_deck_point->deck_id = $_POST['deck']; $cruise_deck_point->save(); $cruise_deck_point_language->id = $id2['id']; if ($photo != '') { //判断有无上传图片 $cruise_deck_point_language->img_url = 'cruiseinfo_images/' . Yii::app()->params['month'] . '/' . $photo; } //$cruise_deck_point_language->img_url = 'cruiseinfo_images/'.Yii::app()->params['month'].'/'.$photo_iso; $cruise_deck_point_language->deck_point_name = $_POST['name']; $cruise_deck_point_language->deck_point_describe = $_POST['desc']; $cruise_deck_point_language->deck_point_info = $describe; $cruise_deck_point_language->save(); $transaction->commit(); Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Cruiseinfo/Cruise_deck_point_list")); } } catch (Exception $e) { $transaction->rollBack(); Helper::show_message(yii::t('vcos', '修改失败。'), '#'); } } $sql = "SELECT a.deck_id,b.deck_name FROM `vcos_cruise_deck` a LEFT JOIN `vcos_cruise_deck_language` b ON a.deck_id = b.deck_id WHERE b.iso = '" . Yii::app()->language . "'"; $deck_sel = Yii::app()->m_db->createCommand($sql)->queryAll(); $this->render('cruise_deck_point_edit', array('deck_sel' => $deck_sel, 'cruise_deck_point' => $cruise_deck_point, 'cruise_deck_point_language' => $cruise_deck_point_language)); }