From 477fa683ed12d7728f0bc3102f1b0c878a1158ab Mon Sep 17 00:00:00 2001 From: lyt Date: Mon, 29 Apr 2019 17:09:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=8E123=E6=90=AC=E8=BF=81=E7=9A=84?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E9=9C=80=E6=B1=82=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webht/controllers/demandform.php | 167 ++++++++++++++++ webht/models/demandform_model.php | 119 +++++++++++ webht/views/demandform/index.php | 160 +++++++++++++++ webht/views/demandform/index1.php | 315 ++++++++++++++++++++++++++++++ webht/views/demandform/reply.php | 122 ++++++++++++ 5 files changed, 883 insertions(+) create mode 100644 webht/controllers/demandform.php create mode 100644 webht/models/demandform_model.php create mode 100644 webht/views/demandform/index.php create mode 100644 webht/views/demandform/index1.php create mode 100644 webht/views/demandform/reply.php diff --git a/webht/controllers/demandform.php b/webht/controllers/demandform.php new file mode 100644 index 00000000..3e5b94bf --- /dev/null +++ b/webht/controllers/demandform.php @@ -0,0 +1,167 @@ +load->model('Demandform_model'); + } + + /*! + * @author LYT + * @date 2018-01-23 + * @param [type] $coli_sn 订单主表的COLI_SN + * @param integer $form_id 默认值2是0.1版本固定的 + */ + public function index($coli_sn = null, $form_id = 2) + { + header("Cache-Control: no-store"); + + // 已填则返回成功 + $is_replied = $this->Demandform_model->get_reply($coli_sn); + + $form_id = intval(trim($form_id)); + $_raw_data = $this->Demandform_model->get_form_detail($form_id); + $part = array(); + foreach ($_raw_data->formdetail as $key => $fd) { + $tmp_a = array(); + $tmp_r = array(); + foreach ($_raw_data->answer as $ka => $a) { + if ($fd->FD_id === $a->A_FD_id) { + $tmp_a[] = $a; + } + } + if ( ! empty($is_replied)) { + foreach ($is_replied as $kr => $re) { + if ($re->FD_id === $fd->FD_id) { + $tmp_r[] = $re->CRD_content; + } + } + } + $fd->reply = $tmp_r; + $fd->answer = (object) $tmp_a; + // part set + $part["part1"]["title"] = "PART 1 -- Travel Preference"; + $part["part2"]["title"] = "PART 2"; + if (intval(trim($fd->FD_section)) === 1) { + $part["part1"]["data"][] = $fd; + } + if (intval(trim($fd->FD_section)) === 2) { + $part["part2"]["data"][] = $fd; + } + } + $_raw_data->part = $part; + unset($_raw_data->formdetail); + unset($_raw_data->answer); + $_raw_data->coli = $coli_sn; + + if ( ! empty($is_replied)) { + $this->load->view('demandform/thanks', $_raw_data); + return; + } + + $this->load->view('demandform/index', $_raw_data); + return; + } + + public function form_save() + { + $all_post = $this->input->post(); + + $ret["code"] = 1; + $ret["msg"] = ""; + // 已填则返回成功 -- todo + + $check_input = array(); + foreach ($all_post["q"] as $key => $value) { + if ($value["required"] == 1 && empty($value["answer"])) { + $ret["code"] = 0; + $ret["msg"][] = $key; + } + } + if ($ret["code"] == 0) { + return $this->output->set_content_type('text/plain')->set_output(json_encode($ret)); + } + // CD_CustomerReply + $this->Demandform_model->CR_COLI_sn = trim($this->input->post("coli_sn")); + $this->Demandform_model->CR_F_id = trim($this->input->post("fid")); + $d = $a = $c = ""; + foreach ($all_post["q"] as $key => $value) { + $split_answer = null; + $class_max = 0; + if (trim($value["ismain"]) != 1) { + continue; + } + $class_max = (count($value["answer"])-1); + $split_answer = explode("=_", $value["answer"][$class_max]); + if (trim($value["qclass"]) === 'D' && ! empty($split_answer)) { + $d = (isset($split_answer) ? $split_answer[1] : "?"); + } + if (trim($value["qclass"]) === 'A' && ! empty($split_answer)) { + $a = (isset($split_answer) ? $split_answer[1] : "?"); + } + if (trim($value["qclass"]) === 'C' && ! empty($split_answer)) { + $c = (isset($split_answer) ? $split_answer[1] : "?"); + } + } + $this->Demandform_model->CR_result = $d . $a . $c; + // CD_CustomerReplyDetail + $this->Demandform_model->CRD_CR_id = $this->Demandform_model->reply_save(); + $reply_detail = array(); + foreach ($all_post["q"] as $key => $value) { + if (empty($value["atext"]) && empty($value["answer"])) { + continue; + } + $this->Demandform_model->CRD_FD_id = $value["fdid"]; + $this->Demandform_model->CRD_result = null; + $this->Demandform_model->CRD_Answer = null; + $this->Demandform_model->CRD_content = null; + + if (isset($value["answer"])) { + foreach ($value["answer"] as $ka => $va) { + $split_answer = null; + $split_answer = explode("=_", trim($value["answer"][$ka])); + $this->Demandform_model->CRD_Answer = $split_answer[0]; + $this->Demandform_model->CRD_content = (!empty($split_answer) ? ($split_answer[2]) : ""); + if ( ! empty($value["qclass"]) && ! empty($split_answer)) { + $this->Demandform_model->CRD_result = (!empty($split_answer) ? $split_answer[1] : "?"); + } + // 这里是 选择题others选项的可填入项 + $this->Demandform_model->CRD_content .= (isset($value["atext"]) ? $value["atext"] : ""); + $this->Demandform_model->replydetail_save(); + } + } else { + // 这里是填空题的输入 + $this->Demandform_model->CRD_content = $value["atext"]; + $this->Demandform_model->replydetail_save(); + } + } + return $this->output->set_content_type('text/plain')->set_output(json_encode($ret)); + } + + public function view_reply($coli) + { + $reply = $this->Demandform_model->get_reply($coli); + $reply_arr = array(); + $reply_fd_arr = array(); + foreach ($reply as $key => $r) { + $class_key = trim($r->FD_class) ? trim($r->FD_class) : "normal"; + $reply_arr["CR_result"] = $r->CR_result; + $reply_arr[$class_key]["q" . $r->FD_id][] = $r; + } + $this->load->view('demandform/reply', $reply_arr); + } + + public function converet_answer($answer) + { + $ret = ord($answer)-64; + $ret = ($ret > 3) ? 3 : $ret; + return $ret; + } + + +} diff --git a/webht/models/demandform_model.php b/webht/models/demandform_model.php new file mode 100644 index 00000000..dd80ba58 --- /dev/null +++ b/webht/models/demandform_model.php @@ -0,0 +1,119 @@ +INFO = $this->load->database('INFO', TRUE); + } + + public function get_form_detail($form_id) + { + $ret = (object) array(); + $form_sql = "SELECT top 1 * FROM CD_form WHERE f_id=$form_id " ; + $f_query = $this->INFO->query($form_sql); + $ret->form = $f_query->row(); + + $formdetail_sql = "SELECT fd.* + FROM CD_formdetail fd + WHERE fd.FD_F_id=$form_id order by FD_sort asc" ; + $fd_query = $this->INFO->query($formdetail_sql); + $ret->formdetail = $fd_query->result(); + + $answer_sql = "SELECT a.* + FROM CD_formdetail fd + INNER JOIN CD_answer a ON a.A_FD_id=fd.FD_id + WHERE fd.FD_F_id=$form_id " ; + $a_query = $this->INFO->query($answer_sql); + $ret->answer = $a_query->result(); + + return $ret; + } + + // CD_CustomerReply + public $CR_COLI_sn; + public $CR_F_id; + public $CR_result; + + public function reply_save() + { + $rsql = "INSERT INTO CD_CustomerReply ( + CR_COLI_sn + ,CR_F_id + ,CR_replytime + ,CR_result) + VALUES + (? + ,? + ,GETDATE() + ,N?)"; + // log_message('error',$this->INFO->compile_binds($rsql, + $rquery = $this->INFO->query($rsql, + array($this->CR_COLI_sn, $this->CR_F_id, $this->CR_result)); + $cr_id_q = "SELECT TOP 1 CR_id + FROM CD_CustomerReply + WHERE CR_COLI_sn=? + ORDER BY CR_replytime DESC"; + $cr_query = $this->INFO->query($cr_id_q, array($this->CR_COLI_sn)); + $cr_id_r = $cr_query->row(); + return $cr_id_r->CR_id; + } + + // CD_CustomerReplyDetail + public $CRD_FD_id; + public $CRD_Answer; + public $CRD_content; + public $CRD_result; + public $CRD_CR_id; + + public function replydetail_save() + { + $rdsql = "INSERT INTO CD_CustomerReplyDetail + (CRD_CR_id + ,CRD_FD_id + ,CRD_Answer + ,CRD_content + ,CRD_result + ) + VALUES (?,?,?,N?,?) "; + // log_message('error',$this->INFO->compile_binds($rdsql, + $rdquery = $this->INFO->query($rdsql, + array( + $this->CRD_CR_id, + $this->CRD_FD_id, + $this->CRD_Answer, + $this->CRD_content, + $this->CRD_result + ) + ); + return $this->INFO->insert_id(); + } + + public function get_reply($coli) + { + $sql = "SELECT fd.FD_id, + fd.FD_F_id, + fd.FD_section, + cr.CR_replytime, + cr.CR_COLI_sn, + cr.CR_result, + fd.FD_class, + fd.FD_ismain, + crd.CRD_result, + fd.FD_question, + crd.CRD_content + FROM CD_CustomerReply cr + INNER JOIN CD_CustomerReplyDetail crd ON crd.CRD_CR_id=cr.CR_id + INNER JOIN CD_FormDetail fd ON CRD_FD_id=FD_id + WHERE CR_COLI_sn='$coli' + ORDER BY fd.FD_section ASC,fd.FD_sort ASC + "; + $query = $this->INFO->query($sql); + + return $query->result(); + } + + + +} diff --git a/webht/views/demandform/index.php b/webht/views/demandform/index.php new file mode 100644 index 00000000..2dfb008b --- /dev/null +++ b/webht/views/demandform/index.php @@ -0,0 +1,160 @@ + + + + + + + + We Complete You + + + + + + + + +
+ +
+
+
+ + + +
    +
  • ", $form->F_comment); + $form_com = str_replace("\n", "
    ", $form_com); + echo $form_com; + ?> +
  • +
+ + $p) { ?> +

+
$q) { ?> +

+ . FD_question ?> + FD_required==1){ ?> + + +

+ + + + + + FD_AnswerType)) > 0) { // 选择题 + $answer_type = intval(trim($q->FD_AnswerType))==1 ? "radio" : "checkbox"; + ?> + answer as $ka => $an) { ?> + + + + + + + +
+ + + + +
+
+ + + + + + diff --git a/webht/views/demandform/index1.php b/webht/views/demandform/index1.php new file mode 100644 index 00000000..07c122f9 --- /dev/null +++ b/webht/views/demandform/index1.php @@ -0,0 +1,315 @@ + + + + + Easy Planning from now! + + + + + + + + + + + + + + +
+
+
+ +
+

Easy Planning from now! The only thing you need to do is telling us your preference. Leave the rest to Us!

+
+ + + +
+ $p) { ?> +

+

$q) { ?> +

FD_question ?>

+ + + + + FD_AnswerType)) === 1) { ?> +
    + answer as $ka => $an) { ?> +
  1. + +
  2. + +
+ + + +

+ +
+ +
+
+ + + +
+ + + + diff --git a/webht/views/demandform/reply.php b/webht/views/demandform/reply.php new file mode 100644 index 00000000..f47388c5 --- /dev/null +++ b/webht/views/demandform/reply.php @@ -0,0 +1,122 @@ + + + + + + + + customer reply + + + + +
+ +

未收到回复

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + $qn) { ?> + + + + + + + +
等级关键问题辅助信息
+ + + $qa) { + if (intval($qa[0]->FD_ismain) == 1) { + echo $qa[0]->FD_question; + foreach ($qa as $ka => $answer) { ?> +

CRD_result) . "." . $answer->CRD_content; ?>

+ +
+ $qa) { + if (intval($qa[0]->FD_ismain) != 1) { ?> + FD_question; ?> + $answer) { ?> +

CRD_result) . "." . $answer->CRD_content; ?>

+ +
+ + + $qa) { + if (intval($qa[0]->FD_ismain) == 1) { + echo $qa[0]->FD_question; + foreach ($qa as $ka => $answer) { ?> +

CRD_result) . "." . $answer->CRD_content; ?>

+ +
+ $qa) { + if (intval($qa[0]->FD_ismain) != 1) { ?> + FD_question; ?> + $answer) { ?> +

CRD_result) . "." . $answer->CRD_content; ?>

+ +
+ + + $qa) { + if (intval($qa[0]->FD_ismain) == 1) { ?> + FD_question; + foreach ($qa as $ka => $answer) { ?> +

CRD_result) . "." . $answer->CRD_content; ?>

+ + +
+ $qa) { ?> + FD_ismain) != 1) { ?> + FD_question; ?> + $answer) { ?> +

CRD_content; ?>

+ + +
+ 其他信息 +
+ FD_question; ?> + + $na) { ?> +

CRD_content; ?>

+ +
+ + +
+ + +