help_store.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <?php
  2. /**
  3. * 店铺帮助管理
  4. *
  5. *
  6. *
  7. ***/
  8. defined('InShopNC') or exit('Access Invalid!');
  9. class help_storeControl extends SystemControl{
  10. public function __construct(){
  11. parent::__construct();
  12. }
  13. /**
  14. * 帮助列表
  15. */
  16. public function help_storeOp() {
  17. $model_help = Model('help');
  18. $condition = array();
  19. $condition['help_id'] = array('gt','99');//内容列表不显示系统自动添加的数据
  20. if (trim($_GET['key']) != '') {
  21. $condition['help_title'] = array('like','%'.$_GET['key'].'%');
  22. }
  23. $type_id = intval($_GET['type_id']);
  24. if ($type_id > 0) {
  25. $condition['type_id'] = $type_id;
  26. }
  27. $help_list = $model_help->getStoreHelpList($condition,10);
  28. Tpl::output('help_list',$help_list);
  29. Tpl::output('show_page',$model_help->showpage());
  30. $type_list = $model_help->getStoreHelpTypeList();
  31. Tpl::output('type_list',$type_list);
  32. Tpl::showpage('help_store.list');
  33. }
  34. /**
  35. * 帮助类型
  36. */
  37. public function help_typeOp() {
  38. $model_help = Model('help');
  39. $condition = array();
  40. $type_list = $model_help->getStoreHelpTypeList($condition,10);
  41. Tpl::output('type_list',$type_list);
  42. Tpl::output('show_page',$model_help->showpage());
  43. Tpl::showpage('help_store_type.list');
  44. }
  45. /**
  46. * 新增帮助
  47. *
  48. */
  49. public function add_helpOp() {
  50. $model_help = Model('help');
  51. if (chksubmit()) {
  52. $help_array = array();
  53. $help_array['help_title'] = $_POST['help_title'];
  54. $help_array['help_url'] = $_POST['help_url'];
  55. $help_array['help_info'] = $_POST['content'];
  56. $help_array['help_sort'] = intval($_POST['help_sort']);
  57. $help_array['type_id'] = intval($_POST['type_id']);
  58. $help_array['update_time'] = time();
  59. $help_array['page_show'] = '1';//页面类型:1为店铺,2为会员
  60. $state = $model_help->addHelp($help_array);
  61. if ($state) {
  62. if (!empty($_POST['file_id']) && is_array($_POST['file_id'])){
  63. $model_help->editHelpPic($state, $_POST['file_id']);
  64. }
  65. $this->log('新增店铺帮助,编号'.$state);
  66. showMessage(Language::get('nc_common_save_succ'),'index.php?act=help_store&op=help_store');
  67. } else {
  68. showMessage(Language::get('nc_common_save_fail'));
  69. }
  70. }
  71. $type_list = $model_help->getStoreHelpTypeList();
  72. Tpl::output('type_list',$type_list);
  73. $condition = array();
  74. $condition['item_id'] = '0';
  75. $pic_list = $model_help->getHelpPicList($condition);
  76. Tpl::output('pic_list',$pic_list);
  77. Tpl::showpage('help_store.add');
  78. }
  79. /**
  80. * 编辑帮助
  81. *
  82. */
  83. public function edit_helpOp() {
  84. $model_help = Model('help');
  85. $condition = array();
  86. $help_id = intval($_GET['help_id']);
  87. $condition['help_id'] = $help_id;
  88. $help_list = $model_help->getStoreHelpList($condition);
  89. $help = $help_list[0];
  90. Tpl::output('help',$help);
  91. if (chksubmit()) {
  92. $help_array = array();
  93. $help_array['help_title'] = $_POST['help_title'];
  94. $help_array['help_url'] = $_POST['help_url'];
  95. $help_array['help_info'] = $_POST['content'];
  96. $help_array['help_sort'] = intval($_POST['help_sort']);
  97. $help_array['type_id'] = intval($_POST['type_id']);
  98. $help_array['update_time'] = time();
  99. $state = $model_help->editHelp($condition, $help_array);
  100. if ($state) {
  101. $this->log('编辑店铺帮助,编号'.$help_id);
  102. showMessage(Language::get('nc_common_save_succ'),'index.php?act=help_store&op=help_store');
  103. } else {
  104. showMessage(Language::get('nc_common_save_fail'));
  105. }
  106. }
  107. $type_list = $model_help->getStoreHelpTypeList();
  108. Tpl::output('type_list',$type_list);
  109. $condition = array();
  110. $condition['item_id'] = $help_id;
  111. $pic_list = $model_help->getHelpPicList($condition);
  112. Tpl::output('pic_list',$pic_list);
  113. Tpl::showpage('help_store.edit');
  114. }
  115. /**
  116. * 删除帮助
  117. *
  118. */
  119. public function del_helpOp() {
  120. $model_help = Model('help');
  121. $condition = array();
  122. $condition['help_id'] = intval($_GET['help_id']);
  123. $state = $model_help->delHelp($condition,array($condition['help_id']));
  124. if ($state) {
  125. $this->log('删除店铺帮助,编号'.$condition['help_id']);
  126. showMessage(Language::get('nc_common_del_succ'),'index.php?act=help_store&op=help_store');
  127. } else {
  128. showMessage(Language::get('nc_common_del_fail'));
  129. }
  130. }
  131. /**
  132. * 新增帮助类型
  133. *
  134. */
  135. public function add_typeOp() {
  136. $model_help = Model('help');
  137. if (chksubmit()) {
  138. $type_array = array();
  139. $type_array['type_name'] = $_POST['type_name'];
  140. $type_array['type_sort'] = intval($_POST['type_sort']);
  141. $type_array['help_show'] = intval($_POST['help_show']);//是否显示,0为否,1为是
  142. $type_array['page_show'] = '1';//页面类型:1为店铺,2为会员
  143. $state = $model_help->addHelpType($type_array);
  144. if ($state) {
  145. $this->log('新增店铺帮助类型,编号'.$state);
  146. showMessage(Language::get('nc_common_save_succ'),'index.php?act=help_store&op=help_type');
  147. } else {
  148. showMessage(Language::get('nc_common_save_fail'));
  149. }
  150. }
  151. Tpl::showpage('help_store_type.add');
  152. }
  153. /**
  154. * 编辑帮助类型
  155. *
  156. */
  157. public function edit_typeOp() {
  158. $model_help = Model('help');
  159. $condition = array();
  160. $condition['type_id'] = intval($_GET['type_id']);
  161. $type_list = $model_help->getHelpTypeList($condition);
  162. $type = $type_list[0];
  163. if (chksubmit()) {
  164. $type_array = array();
  165. $type_array['type_name'] = $_POST['type_name'];
  166. $type_array['type_sort'] = intval($_POST['type_sort']);
  167. $type_array['help_show'] = intval($_POST['help_show']);//是否显示,0为否,1为是
  168. $state = $model_help->editHelpType($condition, $type_array);
  169. if ($state) {
  170. $this->log('编辑店铺帮助类型,编号'.$condition['type_id']);
  171. showMessage(Language::get('nc_common_save_succ'),'index.php?act=help_store&op=help_type');
  172. } else {
  173. showMessage(Language::get('nc_common_save_fail'));
  174. }
  175. }
  176. Tpl::output('type',$type);
  177. Tpl::showpage('help_store_type.edit');
  178. }
  179. /**
  180. * 删除帮助类型
  181. *
  182. */
  183. public function del_typeOp() {
  184. $model_help = Model('help');
  185. $condition = array();
  186. $condition['type_id'] = intval($_GET['type_id']);
  187. $state = $model_help->delHelpType($condition);
  188. if ($state) {
  189. $this->log('删除店铺帮助类型,编号'.$condition['type_id']);
  190. showMessage(Language::get('nc_common_del_succ'),'index.php?act=help_store&op=help_type');
  191. } else {
  192. showMessage(Language::get('nc_common_del_fail'));
  193. }
  194. }
  195. /**
  196. * 上传图片
  197. */
  198. public function upload_picOp() {
  199. $data = array();
  200. if (!empty($_FILES['fileupload']['name'])) {//上传图片
  201. $fprefix = 'help_store';
  202. $upload = new UploadFile();
  203. $upload->set('default_dir',ATTACH_ARTICLE);
  204. $upload->set('fprefix',$fprefix);
  205. $upload->upfile('fileupload');
  206. $model_upload = Model('upload');
  207. $file_name = $upload->file_name;
  208. $insert_array = array();
  209. $insert_array['file_name'] = $file_name;
  210. $insert_array['file_size'] = $_FILES['fileupload']['size'];
  211. $insert_array['upload_time'] = time();
  212. $insert_array['item_id'] = intval($_GET['item_id']);
  213. $insert_array['upload_type'] = '2';
  214. $result = $model_upload->add($insert_array);
  215. if ($result) {
  216. $data['file_id'] = $result;
  217. $data['file_name'] = $file_name;
  218. }
  219. }
  220. echo json_encode($data);exit;
  221. }
  222. /**
  223. * 删除图片
  224. */
  225. public function del_picOp() {
  226. $condition = array();
  227. $condition['upload_id'] = intval($_GET['file_id']);
  228. $model_help = Model('help');
  229. $state = $model_help->delHelpPic($condition);
  230. if ($state) {
  231. echo 'true';exit;
  232. } else {
  233. echo 'false';exit;
  234. }
  235. }
  236. }