|
|
@ -34,29 +34,38 @@ class index extends publicBase { |
|
|
|
} |
|
|
|
|
|
|
|
public function ajax_save_formula() { |
|
|
|
$uinfo = $this->_check_login(); |
|
|
|
|
|
|
|
$name = trim($this->post('name')); |
|
|
|
$source = trim($this->post('source')); |
|
|
|
$method = trim($this->post('method')); |
|
|
|
$herbs = $this->post('herbs'); |
|
|
|
|
|
|
|
//新增药方 |
|
|
|
$mformula = new mFormula(); |
|
|
|
$id = $mformula->createCase($name, $source, $method, $herbs); |
|
|
|
|
|
|
|
//生成唯一id 防止重复请求 |
|
|
|
$request_id = md5($uinfo['uid'] . $name . $source . $herbs); |
|
|
|
$request_times = $mformula->requestLimit(sprintf(_QR_REQUEST_LIMIT, $request_id), 1, 60); |
|
|
|
if (!$request_times) $this->ajax_json(false, $mformula->getError()); |
|
|
|
|
|
|
|
//新增药方 |
|
|
|
$id = $mformula->createFormula($uinfo['uid'], $name, $source, $method, $herbs); |
|
|
|
if (!$id) $this->ajax_json(false, $mformula->getError()); |
|
|
|
|
|
|
|
$this->ajax_json(true, '添加成功'); |
|
|
|
$this->ajax_json(true, '添加成功', array('id' => $id)); |
|
|
|
} |
|
|
|
|
|
|
|
public function ajax_update_formula() { |
|
|
|
$uinfo = $this->_check_login(); |
|
|
|
|
|
|
|
$id = $this->post('id') + 0; |
|
|
|
$name = trim($this->post('name')); |
|
|
|
$source = trim($this->post('source')); |
|
|
|
$original = trim($this->post('original')); |
|
|
|
$method = trim($this->post('method')); |
|
|
|
$herbs = $this->post('herbs'); |
|
|
|
|
|
|
|
$mformula = new mFormula(); |
|
|
|
$res = $mformula->updateCase($id, $name, $source, $method, $herbs); |
|
|
|
$res = $mformula->saveFormula($uinfo['uid'], $id, $name, $source, $method, $herbs); |
|
|
|
if (!$res) $this->ajax_json(false, $mformula->getError()); |
|
|
|
|
|
|
|
$this->ajax_json(true, '保存成功'); |
|
|
|