diff --git a/application/controllers/zodiac.php b/application/controllers/zodiac.php
index 8a3f00e8..08b2f319 100644
--- a/application/controllers/zodiac.php
+++ b/application/controllers/zodiac.php
@@ -7,18 +7,36 @@ class Zodiac extends CI_Controller {
function __construct() {
parent::__construct();
+ $this->load->model('LunarNewYear_model');
}
- public function index()
+ public function index($z='rat')
{
- # code...
+ $this->edit_zodiac(mb_strtolower($z));
}
- public function edit_zodiac()
+ public function edit_zodiac($z='rat')
{
- $data['nav_view'] = $this->load->view('bootstrap/zodiac/nav', array('nav_active' => ''), true);
+ $data['nav_active'] = $data["current_zodiac"] = mb_strtolower($z);
+ $data["zodiac_fortune"] = $this->LunarNewYear_model->get_zodiac($data["current_zodiac"]);
+ // 预览编辑的问题
+ if (substr($data["zodiac_fortune"]->TheYearFortune, 0, 4) !== '
TheYearFortune = "
" . $data["zodiac_fortune"]->TheYearFortune . "
";
+ }
$this->load->view('bootstrap/header', $data);
$this->load->view('bootstrap/zodiac/edit',$data);
}
+ public function fortune_save()
+ {
+ $this->LunarNewYear_model->LNY_SX = trim($this->input->post("sx"));
+ $this->LunarNewYear_model->LNY_LuckyNumber = trim($this->input->post("lucky_num"));
+ $this->LunarNewYear_model->LNY_LuckyColor = trim($this->input->post("lucky_color"));
+ $this->LunarNewYear_model->LNY_LuckyFlower = trim($this->input->post("lucky_flo"));
+ $this->LunarNewYear_model->TheYearFortune = trim($this->input->post("theyearfortune"));
+ $this->LunarNewYear_model->theyearfortune_save();
+ $ret = array("name"=>"ok");
+ $this->output->set_content_type('application/json')->set_output(json_encode($ret));
+ }
+
}
diff --git a/application/models/LunarNewYear_model.php b/application/models/LunarNewYear_model.php
new file mode 100644
index 00000000..dad0fd5d
--- /dev/null
+++ b/application/models/LunarNewYear_model.php
@@ -0,0 +1,48 @@
+HT = $this->load->database('HT', TRUE);
+ }
+
+ public function get_zodiac($zodiac = 'rat')
+ {
+ $sql = "SELECT TOP 1 LNY_SN ,
+ LNY_SX ,
+ LNY_LuckyNumber ,
+ LNY_LuckyColor ,
+ LNY_LuckyFlower ,
+ TheYearFortune
+ FROM LunarNewYear
+ WHERE LOWER(LNY_SX)='$zodiac'";
+ $query = $this->HT->query($sql);
+ return $query->row();
+ }
+
+ public function theyearfortune_save()
+ {
+ $sql = "UPDATE LunarNewYear
+ SET LNY_LuckyNumber = ?,
+ LNY_LuckyColor = ?,
+ LNY_LuckyFlower = ?,
+ TheYearFortune = ?
+ WHERE LOWER(LNY_SX) = ?";
+ $query = $this->HT->query($sql, array(
+ $this->LNY_LuckyNumber,
+ $this->LNY_LuckyColor,
+ $this->LNY_LuckyFlower,
+ $this->TheYearFortune,
+ $this->LNY_SX
+ ));
+ return $query;
+ }
+
+}
diff --git a/application/views/bootstrap/zodiac/edit.php b/application/views/bootstrap/zodiac/edit.php
index c02dc01a..eea68e33 100644
--- a/application/views/bootstrap/zodiac/edit.php
+++ b/application/views/bootstrap/zodiac/edit.php
@@ -18,37 +18,35 @@ border-top: 1px solid #ccc;