consulting.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <?php
  2. /**
  3. * 咨询管理
  4. ***/
  5. defined('InShopNC') or exit('Access Invalid!');
  6. class consultingControl extends SystemControl{
  7. public function __construct(){
  8. parent::__construct();
  9. Language::read('consulting');
  10. }
  11. /**
  12. * 咨询管理
  13. */
  14. public function consultingOp(){
  15. $condition = array();
  16. if(chksubmit()){
  17. $member_name = trim($_GET['member_name']);
  18. if($member_name != ''){
  19. $condition['member_name'] = array('like', '%' . $member_name . '%');
  20. Tpl::output('member_name', $member_name);
  21. }
  22. $consult_content = trim($_GET['consult_content']);
  23. if($consult_content != ''){
  24. $condition['consult_content'] = array('like', '%' . $consult_content . '%');
  25. Tpl::output('consult_content', $consult_content);
  26. }
  27. $ctid = intval($_GET['ctid']);
  28. if ($ctid > 0) {
  29. $condition['ct_id'] = $ctid;
  30. Tpl::output('ctid', $ctid);
  31. }
  32. }
  33. $model_consult = Model('consult');
  34. $consult_list = $model_consult->getConsultList($condition,'*', 0, 10);
  35. Tpl::output('show_page',$model_consult->showpage());
  36. Tpl::output('consult_list',$consult_list);
  37. // 咨询类型
  38. $consult_type = rkcache('consult_type', true);
  39. Tpl::output('consult_type', $consult_type);
  40. Tpl::showpage('consulting.index');
  41. }
  42. public function deleteOp(){
  43. if(empty($_REQUEST['consult_id'])){
  44. showMessage(Language::get('nc_common_del_fail'));
  45. }
  46. $array_id = array();
  47. if(!empty($_GET['consult_id'])){
  48. $array_id[] = intval($_GET['consult_id']);
  49. }
  50. if(!empty($_POST['consult_id'])){
  51. $array_id = $_POST['consult_id'];
  52. }
  53. $consult = Model('consult');
  54. if($consult->delConsult(array('consult_id' => array('in', $array_id)))){
  55. $this->log(L('nc_delete,consulting').'[ID:'.$array_id.']',null);
  56. showMessage(Language::get('nc_common_del_succ'));
  57. }else{
  58. showMessage(Language::get('nc_common_del_fail'));
  59. }
  60. }
  61. /**
  62. * 咨询设置
  63. */
  64. public function settingOp() {
  65. $model_setting = Model('setting');
  66. if (chksubmit()){
  67. $update_array = array();
  68. $update_array['consult_prompt'] = $_POST['consult_prompt'];
  69. $result = $model_setting->updateSetting($update_array);
  70. if ($result === true){
  71. $this->log('编辑咨询文字提示',1);
  72. showMessage(L('nc_common_save_succ'));
  73. }else {
  74. $this->log('编辑咨询文字提示',0);
  75. showMessage(L('nc_common_save_fail'));
  76. }
  77. }
  78. $setting_list = $model_setting->getListSetting();
  79. Tpl::output('setting_list', $setting_list);
  80. Tpl::showpage('consulting.setting');
  81. }
  82. /**
  83. * 咨询类型列表
  84. */
  85. public function type_listOp() {
  86. $model_ct = Model('consult_type');
  87. if (chksubmit()) {
  88. $ctid_array = $_POST['del_id'];
  89. if (!is_array($ctid_array)) {
  90. showMessage(L('param_error'));
  91. }
  92. foreach ($ctid_array as $val){
  93. if (!is_numeric($val)) {
  94. showMessage(L('param_error'));
  95. }
  96. }
  97. $result = $model_ct->delConsultType(array('ct_id' => array('in', $ctid_array)));
  98. if ($result) {
  99. $this->log('删除咨询类型 ID:'.implode(',', $ctid_array), 1);
  100. showMessage(L('nc_common_del_succ'));
  101. } else {
  102. $this->log('删除咨询类型 ID:'.implode(',', $ctid_array), 0);
  103. showMessage(L('nc_common_del_fail'));
  104. }
  105. }
  106. $type_list = $model_ct->getConsultTypeList(array(), 'ct_id,ct_name,ct_sort');
  107. Tpl::output('type_list', $type_list);
  108. Tpl::showpage('consulting.type_list');
  109. }
  110. /**
  111. * 新增咨询类型
  112. */
  113. public function type_addOp() {
  114. if (chksubmit()) {
  115. // 验证
  116. $obj_validate = new Validate();
  117. $obj_validate->validateparam = array(
  118. array("input"=>$_POST["ct_name"], "require"=>"true", "message"=>'请填写咨询类型名称'),
  119. array("input"=>$_POST["ct_sort"], "require"=>"true", 'validator'=>'Number', "message"=>'请正确填写咨询类型排序'),
  120. );
  121. $error = $obj_validate->validate();
  122. if ($error != ''){
  123. showMessage(Language::get('error').$error,'','','error');
  124. }
  125. $insert = array();
  126. $insert['ct_name'] = trim($_POST['ct_name']);
  127. $insert['ct_sort'] = intval($_POST['ct_sort']);
  128. $insert['ct_introduce'] = $_POST['ct_introduce'];
  129. $result = Model('consult_type')->addConsultType($insert);
  130. if ($result){
  131. $this->log('新增咨询类型',1);
  132. showMessage(L('nc_common_save_succ'), urlAdmin('consulting', 'type_list'));
  133. }else {
  134. $this->log('新增咨询类型',0);
  135. showMessage(L('nc_common_save_fail'));
  136. }
  137. }
  138. Tpl::showpage('consulting.type_add');
  139. }
  140. /**
  141. * 编辑咨询类型
  142. */
  143. public function type_editOp() {
  144. $model_ct = Model('consult_type');
  145. if (chksubmit()) {
  146. // 验证
  147. $obj_validate = new Validate();
  148. $obj_validate->validateparam = array(
  149. array("input"=>$_POST["ct_name"], "require"=>"true", "message"=>'请填写咨询类型名称'),
  150. array("input"=>$_POST["ct_sort"], "require"=>"true", 'validator'=>'Number', "message"=>'请正确填写咨询类型排序'),
  151. );
  152. $error = $obj_validate->validate();
  153. if ($error != ''){
  154. showMessage(Language::get('error').$error,'','','error');
  155. }
  156. $where = array();
  157. $where['ct_id'] = intval($_POST['ct_id']);
  158. $update = array();
  159. $update['ct_name'] = trim($_POST['ct_name']);
  160. $update['ct_sort'] = intval($_POST['ct_sort']);
  161. $update['ct_introduce'] = $_POST['ct_introduce'];
  162. $result = $model_ct->editConsultType($where, $update);
  163. if ($result){
  164. $this->log('编辑咨询类型 ID:'.$where['ct_id'],1);
  165. showMessage(L('nc_common_op_succ'), urlAdmin('consulting', 'type_list'));
  166. }else {
  167. $this->log('编辑咨询类型 ID:'.$where['ct_id'],0);
  168. showMessage(L('nc_common_op_fail'));
  169. }
  170. }
  171. $ct_id = intval($_GET['ct_id']);
  172. if ($ct_id <= 0) {
  173. showMessage(L('param_error'));
  174. }
  175. $ct_info = $model_ct->getConsultTypeInfo(array('ct_id' => $ct_id));
  176. Tpl::output('ct_info', $ct_info);
  177. Tpl::showpage('consulting.type_edit');
  178. }
  179. /**
  180. * 删除咨询类型
  181. */
  182. public function type_delOp() {
  183. $ct_id = intval($_GET['ct_id']);
  184. if ($ct_id <= 0) {
  185. showMessage(L('param_error'));
  186. }
  187. $result = Model('consult_type')->delConsultType(array('ct_id' => $ct_id));
  188. if ($result) {
  189. $this->log('删除咨询类型 ID:'.$ct_id, 1);
  190. showMessage(L('nc_common_del_succ'));
  191. } else {
  192. $this->log('删除咨询类型 ID:'.$ct_id, 0);
  193. showMessage(L('nc_common_del_fail'));
  194. }
  195. }
  196. }