PageRenderTime 57ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/src/testSource/phpcms/content/application/controllers/message.php

https://gitlab.com/loda.sun.suryani/qijiatuku
PHP | 1292 lines | 1119 code | 56 blank | 117 comment | 139 complexity | 4f350373ef788133d3ee957d54c94b6f MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. if (! defined ( 'BASEPATH' ))
  3. exit ( 'No direct script access allowed' );
  4. class Message extends CI_Controller {
  5. function __construct() {
  6. parent::__construct ();
  7. $this->load->library ( 'form_validation' ); //表单验证类
  8. $this->load->library ( 'datagrid' ); //文本控件
  9. $this->load->helper ( 'url' );
  10. $this->load->helper ( 'html' );
  11. $this->load->library ( 'editors' );
  12. $this->load->library ( 'session' ); //session类
  13. $this->load->helper ( 'pagenav' ); //分页类
  14. $this->load->helper ( 'toolkit' );
  15. $this->load->helper ( 'security' );
  16. $this->load->library ( 'CommonCache', '', 'cache' );
  17. $this->load->library ( 'tgapi' ); //上传图片API
  18. }
  19. //大缩略图
  20. function single_upload() {
  21. $api = $this->tgapi->get_tg_api ();
  22. $api->load ( "upload" );
  23. $file = $_FILES ['Filedata'] ['tmp_name'];
  24. $new_file = $api->upload->from_files ( $file );
  25. $url = $api->upload->get_url ( $new_file );
  26. //将$new_file 保存到数据库,字段为 char(13)
  27. //echo "$url|$new_file"; 7237829.19
  28. echo "<img width=70 height=70 src=$url><input value=$new_file type=hidden name=api id=api >";
  29. }
  30. function index() {
  31. //$shop_id = $this->input->get('shop_id');
  32. $user_id = $this->input->get ( 'user_id' );
  33. $ip = $_SERVER ["REMOTE_ADDR"];
  34. $theverify = $this->input->get ( 'theverify' );
  35. $pass = "cms_fuwu.jia.com"; //这里是说好的密码
  36. $check_key = cms_inner_verify ( $user_id, $ip, $pass );
  37. //my_debug($check_key);
  38. if ($theverify != $check_key) {
  39. echo "验证不通过!";
  40. exit ();
  41. }
  42. $view_data = array ();
  43. $view_data ['grid'] = '';
  44. $view_data ['getpageinfo'] = '';
  45. $view_data ['shop_id'] = ''; //服务商列表
  46. $view_data ['shop_name'] = null;
  47. $reply_type = $this->input->get ( 'select_reply_options' );
  48. $user_id = intval ( $this->input->get ( 'user_id' ) );
  49. if (! $user_id) {
  50. $user_id = '0';
  51. }
  52. //===========根据回复筛选==={{============================================================
  53. $sql_count_yes = "SELECT count(*) as tot FROM com_comment WHERE user_id = $user_id AND comment_content IS NOT NULL AND comment_reply IS NOT NULL";
  54. $sql_count_no = "SELECT count(*) as tot FROM com_comment WHERE user_id = $user_id AND comment_content IS NOT NULL AND comment_reply IS NULL";
  55. $count_yes = $this->db->get_record_by_sql ( $sql_count_yes, 'num' );
  56. $count_no = $this->db->get_record_by_sql ( $sql_count_no, 'num' );
  57. $count_all = $count_yes [0] + $count_no [0];
  58. $select_reply_options = array ();
  59. if ($reply_type == 0 || ! $reply_type) {
  60. $select_reply_options [0] = "<li><a href=" . modify_build_url (
  61. array ('select_reply_options' => 0, 'page' => 0 ) ) . " class=\"cur\" >全部咨询<em>({$count_all})</em></a>";
  62. } else {
  63. $select_reply_options [0] = "<li><a href=" . modify_build_url (
  64. array ('select_reply_options' => 0, 'page' => 0 ) ) . " >全部咨询<em>({$count_all})</em></a>";
  65. }
  66. if ($reply_type == 1) {
  67. $select_reply_options [1] = "<li><a href=" . modify_build_url (
  68. array ('select_reply_options' => 1, 'page' => 0 ) ) . " class=\"cur\">已回复<em>({$count_yes [0]})</em></a>";
  69. } else {
  70. $select_reply_options [1] = "<li><a href=" . modify_build_url (
  71. array ('select_reply_options' => 1, 'page' => 0 ) ) . " >已回复<em>({$count_yes [0]})</em></a>";
  72. }
  73. if ($reply_type == 2) {
  74. $select_reply_options [2] = "<li><a href=" . modify_build_url (
  75. array ('select_reply_options' => 2, 'page' => 0 ) ) . " class=\"cur\">未回复<em>({$count_no [0]})</em></a>";
  76. } else {
  77. $select_reply_options [2] = "<li><a href=" . modify_build_url (
  78. array ('select_reply_options' => 2, 'page' => 0 ) ) . " >未回复<em>({$count_no [0]})</em></a>";
  79. }
  80. $view_data ['select_reply_options'] = $select_reply_options;
  81. //==========================end}}=============================================================
  82. //=========列表===={{=============================================================
  83. $sql_where = "WHERE user_id = $user_id AND comment_content IS NOT NULL ";
  84. if ($this->input->get_post ( 'select_reply_options' ) == '1') {
  85. $sql_where = $sql_where . "&& length(comment_reply)>0";
  86. }
  87. if ($this->input->get_post ( 'select_reply_options' ) == '2') {
  88. $sql_where = $sql_where . "&& comment_reply is null";
  89. }
  90. //my_debug($this->input->get_post ( 'start_time' ));
  91. if ($this->input->post ( 'start_time' )) {
  92. $time_start = strtotime ( trim ( $this->input->get_post ( 'start_time' ) ) );
  93. $sql_where = sprintf ( "$sql_where AND create_time >= '%s' ", $time_start,
  94. $time_start );
  95. }
  96. if ($this->input->post ( 'end_time' )) {
  97. $time_end = strtotime ( trim ( $this->input->post ( 'end_time' ) ) );
  98. $sql_where = sprintf ( "$sql_where AND create_time <='%s' ", $time_end, $time_end );
  99. }
  100. if ($this->input->post ( 'key_value' )) {
  101. $re_str = array ("'", "\"", "’", "‘", "”", "“" );
  102. if (intval ( $this->input->get_post ( 'key_type' ) ) == 1) {
  103. $shop_name = trim (
  104. str_replace ( $re_str, '', $this->input->post ( 'key_value' ) ) );
  105. //my_debug($shop_name);
  106. if (strpos ( " " . $shop_name, "_" ) > 0) {
  107. $shop_name = str_replace ( "_", "#_", $shop_name );
  108. }
  109. if (strpos ( " " . $shop_name, "%" ) > 0) {
  110. $shop_name = str_replace ( "%", "#%", $shop_name );
  111. }
  112. $sql_where = $sql_where . sprintf ( " AND shop_name like '%s%s%s' ESCAPE '#' ",
  113. '%', $shop_name, '%' );
  114. }
  115. if (intval ( $this->input->get_post ( 'key_type' ) ) == 2) {
  116. $comment_content = trim (
  117. str_replace ( $re_str, '', $this->input->post ( 'key_value' ) ) );
  118. if (strpos ( " " . $comment_content, "_" ) > 0) {
  119. $comment_content = str_replace ( "_", "#_", $comment_content );
  120. }
  121. if (strpos ( " " . $comment_content, "%" ) > 0) {
  122. $comment_content = str_replace ( "%", "#%", $comment_content );
  123. }
  124. $sql_where = $sql_where . sprintf (
  125. " AND comment_content like '%s%s%s' ESCAPE '#' ", '%', $comment_content,
  126. '%' );
  127. }
  128. }
  129. //my_debug($sql_where);
  130. if (url_get ( 'count_page' ) != '') {
  131. $count_page = url_get ( 'count_page' );
  132. } else {
  133. $count_page = 10;
  134. }
  135. if (url_get ( 'page' ) <= 0 || url_get ( 'page' ) == '') {
  136. $page = 1;
  137. } else {
  138. $page = url_get ( 'page' );
  139. }
  140. $sql_count = "SELECT count(*) as tot FROM com_comment $sql_where";
  141. $row = $this->db->get_record_by_sql ( $sql_count, 'num' );
  142. $t_count = $row [0];
  143. $p_count = ceil ( $t_count / $count_page );
  144. if ($page > $p_count && $p_count > 0) {
  145. $page = $p_count;
  146. }
  147. $t_first = ($page - 1) * $count_page;
  148. $sql = "SELECT * FROM com_comment $sql_where ORDER BY is_arbitrated ASC,comment_id DESC";
  149. $sql = "$sql LIMIT $t_first,$count_page";
  150. //my_debug($sql);
  151. $data = $this->db->get_rows_by_sql ( $sql );
  152. if (count ( $data )) {
  153. foreach ( $data as $k => $row ) {
  154. $data [$k] ['create_time'] = date ( "Y-m-d H:i:s", $row ['create_time'] );
  155. $data [$k] ['comment_reply_time'] = date ( "Y-m-d H:i:s",
  156. $row ['comment_reply_time'] );
  157. }
  158. }
  159. $view_data ['grid'] = $data;
  160. $getpageinfo = toolkit_pages_b ( $page, $t_count,
  161. modify_build_url ( array ('page' => '' ) ), $count_page, 8, '' );
  162. if ($getpageinfo) {
  163. $view_data ['getpageinfo'] = $getpageinfo ['pagecode'];
  164. }
  165. $this->load->view ( 'comment_admin/comment_server_view', $view_data );
  166. }
  167. function fuwu_admin() {
  168. //服务商家
  169. $shop_id = $this->input->get ( 'shop_id' );
  170. $ip = $_SERVER ["REMOTE_ADDR"];
  171. $theverify = $this->input->get ( 'theverify' );
  172. $pass = "cms_fuwu.jia.com"; //这里是说好的密码
  173. $check_key = cms_inner_verify ( $shop_id, $ip, $pass );
  174. //my_debug($check_key);
  175. if ($theverify != $check_key) {
  176. echo "验证不通过!";
  177. exit ();
  178. }
  179. $view_data = array ();
  180. $view_data ['pages_nav'] = '';
  181. $view_data ['main_grid'] = '';
  182. $view_data ['getpageinfo'] = '';
  183. $view_data ['shop_id'] = '';
  184. $view_data ['shop_name'] = null;
  185. $reply_type = $this->input->get ( 'select_reply_options' );
  186. $shop_id = intval ( $this->input->get ( 'shop_id' ) );
  187. //===========根据回复筛选==={{============================================================
  188. $sql_count_yes = "SELECT count(*) as tot FROM com_comment WHERE shop_id = '$shop_id' AND reply_update>0"; //已回复
  189. $sql_count_no = "SELECT count(*) as tot FROM com_comment WHERE shop_id = '$shop_id' AND reply_update=0"; //未回复数量
  190. $count_yes = $this->db->get_record_by_sql ( $sql_count_yes, 'num' );
  191. $count_no = $this->db->get_record_by_sql ( $sql_count_no, 'num' );
  192. $count_all = $count_yes [0] + $count_no [0];
  193. $select_reply_options = array ();
  194. if ($reply_type == 0 || ! $reply_type) {
  195. $select_reply_options [0] = "<li><a href=" . modify_build_url (
  196. array ('select_reply_options' => 0, 'page' => 0 ) ) . " class=\"cur\" >全部咨询<em>({$count_all})</em></a>";
  197. } else {
  198. $select_reply_options [0] = "<li><a href=" . modify_build_url (
  199. array ('select_reply_options' => 0, 'page' => 0 ) ) . " >全部咨询<em>({$count_all})</em></a>";
  200. }
  201. if ($reply_type == 1) {
  202. $select_reply_options [1] = "<li><a href=" . modify_build_url (
  203. array ('select_reply_options' => 1, 'page' => 0 ) ) . " class=\"cur\">已回复<em>({$count_yes [0]})</em></a>";
  204. } else {
  205. $select_reply_options [1] = "<li><a href=" . modify_build_url (
  206. array ('select_reply_options' => 1, 'page' => 0 ) ) . " >已回复<em>({$count_yes [0]})</em></a>";
  207. }
  208. if ($reply_type == 2) {
  209. $select_reply_options [2] = "<li><a href=" . modify_build_url (
  210. array ('select_reply_options' => 2, 'page' => 0 ) ) . " class=\"cur\">未回复<em>({$count_no [0]})</em></a>";
  211. } else {
  212. $select_reply_options [2] = "<li><a href=" . modify_build_url (
  213. array ('select_reply_options' => 2, 'page' => 0 ) ) . " >未回复<em>({$count_no [0]})</em></a>";
  214. }
  215. $view_data ['select_reply_options'] = $select_reply_options;
  216. //==========================end}}=============================================================
  217. //=========列表===={{=============================================================
  218. $sql_where = "WHERE shop_id = $shop_id AND LENGTH(comment_content)>0 AND is_anonymous !=1";
  219. if ($this->input->get_post ( 'select_reply_options' ) == '1') {
  220. $sql_where = $sql_where . "&& reply_update>0";
  221. }
  222. if ($this->input->get_post ( 'select_reply_options' ) == '2') {
  223. $sql_where = $sql_where . "&& reply_update=0";
  224. }
  225. if ($this->input->get_post ( 'start_time' )) {
  226. $time_start = strtotime ( trim ( $this->input->get_post ( 'start_time' ) ) );
  227. $sql_where = sprintf ( "$sql_where AND create_time >= '%s' ", $time_start,
  228. $time_start );
  229. }
  230. if ($this->input->get_post ( 'end_time' )) {
  231. $time_end = strtotime ( trim ( $this->input->get_post ( 'end_time' ) ) );
  232. $sql_where = sprintf ( "$sql_where AND create_time <='%s' ", $time_end, $time_end );
  233. }
  234. if ($this->input->post ( 'key_value' )) {
  235. $re_str = array ("'", "\"", "’", "‘", "”", "“" );
  236. if (intval ( $this->input->get_post ( 'key_type' ) ) == 1) {
  237. $user_name = trim (
  238. str_replace ( $re_str, '', $this->input->post ( 'key_value' ) ) );
  239. if (strpos ( " " . $user_name, "_" ) > 0) {
  240. $user_name = str_replace ( "_", "#_", $user_name );
  241. }
  242. if (strpos ( " " . $user_name, "%" ) > 0) {
  243. $user_name = str_replace ( "%", "#%", $user_name );
  244. }
  245. $sql_where = $sql_where . sprintf ( " AND user_name like '%s%s%s' ESCAPE '#' ",
  246. '%', $user_name, '%' );
  247. }
  248. if (intval ( $this->input->get_post ( 'key_type' ) ) == 2) {
  249. $comment_content = trim (
  250. str_replace ( $re_str, '', $this->input->post ( 'key_value' ) ) );
  251. if (strpos ( " " . $comment_content, "_" ) > 0) {
  252. $comment_content = str_replace ( "_", "#_", $comment_content );
  253. }
  254. if (strpos ( " " . $comment_content, "%" ) > 0) {
  255. $comment_content = str_replace ( "%", "#%", $comment_content );
  256. }
  257. $sql_where = $sql_where . sprintf (
  258. " AND comment_content like '%s%s%s' ESCAPE '#'", '%', $comment_content, '%' );
  259. }
  260. }
  261. $page = $this->input->get_post ( 'page' );
  262. if ($this->input->get_post ( 'count_page' ) != '') {
  263. $count_page = $this->input->get_post ( 'count_page' );
  264. } else {
  265. $count_page = 10;
  266. }
  267. if ($page == 0 || $page == '') {
  268. $page = 1;
  269. }
  270. //my_debug($page);
  271. $sql_count = "SELECT count(*) as tot FROM com_comment $sql_where";
  272. $row = $this->db->get_record_by_sql ( $sql_count, 'num' );
  273. $t_count = $row [0];
  274. $p_count = ceil ( $t_count / $count_page );
  275. if ($page > $p_count && $p_count > 0) {
  276. $page = $p_count;
  277. }
  278. //my_debug($page);
  279. $t_first = ($page - 1) * $count_page;
  280. $sql = "SELECT * FROM com_comment $sql_where ORDER BY is_arbitrated ASC ,comment_id DESC";
  281. $sql = "$sql LIMIT $t_first,$count_page";
  282. //my_debug ( $sql );
  283. $data = $this->db->get_rows_by_sql ( $sql );
  284. if (count ( $data )) {
  285. foreach ( $data as $k => $row ) {
  286. $data [$k] ['create_time'] = date ( "Y-m-d H:i:s", $row ['create_time'] );
  287. $data [$k] ['comment_reply_time'] = date ( "Y-m-d H:i:s",
  288. $row ['comment_reply_time'] );
  289. $data [$k] ['comment_reply'] = $this->shielding_mobile ( $row ['comment_reply'] );
  290. $data [$k] ['comment_content'] = $this->shielding_mobile (
  291. $row ['comment_content'] );
  292. }
  293. }
  294. $view_data ['grid'] = $data;
  295. $getpageinfo = toolkit_pages_b ( $page, $t_count,
  296. modify_build_url ( array ('page' => '' ) ), $count_page, 8, '' );
  297. if ($getpageinfo) {
  298. $view_data ['getpageinfo'] = $getpageinfo ['pagecode'];
  299. }
  300. $this->load->view ( 'comment_admin/comment_fuwu_admin_view', $view_data );
  301. }
  302. function fuwu_del() {
  303. $comment_id = intval ( $this->input->get_post ( 'id' ) );
  304. $this->db->where ( 'comment_id', $comment_id );
  305. $success = $this->db->update ( 'com_comment', array ('is_arbitrated' => '2' ) );
  306. echo $success;
  307. }
  308. function fuwu_reply() {
  309. $comment_id = intval ( $this->input->get_post ( 'id' ) );
  310. $reply_content = trim ( $this->input->get_post ( 'content' ) );
  311. $reply_content = $this->js_unescape ( $reply_content );
  312. $record = $this->db->get_record_by_field ( 'com_comment', 'comment_id', $comment_id );
  313. $reply_update = $record ['reply_update'] + 1;
  314. $this->db->where ( 'comment_id', $comment_id );
  315. $success = $this->db->update ( 'com_comment',
  316. array (
  317. 'comment_reply' => $reply_content,
  318. 'reply_update' => $reply_update,
  319. 'comment_reply_time' => time () ) );
  320. echo $success; //;
  321. }
  322. /*private function do_post_api($api_server, $api, $req_body, $port = 9091) {
  323. $ch = curl_init ();
  324. curl_setopt ( $ch, CURLOPT_URL, "$api_server$api" );
  325. curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
  326. @curl_setopt ( $ch, CURLOPT_TIMEOUT_MS, 2000 );
  327. curl_setopt ( $ch, CURLOPT_POST, 1 );
  328. curl_setopt ( $ch, CURLOPT_POSTFIELDS, $req_body );
  329. $data = curl_exec ( $ch );
  330. $curl_errno = curl_errno ( $ch );
  331. $curl_error = curl_error ( $ch );
  332. curl_close ( $ch );
  333. if ($curl_errno > 0) {
  334. exit (
  335. "function do_post_api error; <br>\ncURL Error ({$curl_errno}): {$curl_error}<br>\n{$api_server}{$api}<br>\n$req_body" );
  336. }
  337. return $data;
  338. }*/
  339. private function js_unescape($str) {
  340. $ret = '';
  341. $len = strlen ( $str );
  342. for($i = 0; $i < $len; $i ++) {
  343. if ($str [$i] == '%' && $str [$i + 1] == 'u') {
  344. $val = hexdec ( substr ( $str, $i + 2, 4 ) );
  345. if ($val < 0x7f)
  346. $ret .= chr ( $val );
  347. else if ($val < 0x800)
  348. $ret .= chr ( 0xc0 | ($val >> 6) ) . chr ( 0x80 | ($val & 0x3f) );
  349. else
  350. $ret .= chr ( 0xe0 | ($val >> 12) ) . chr ( 0x80 | (($val >> 6) & 0x3f) ) . chr (
  351. 0x80 | ($val & 0x3f) );
  352. $i += 5;
  353. } else if ($str [$i] == '%') {
  354. $ret .= urldecode ( substr ( $str, $i, 3 ) );
  355. $i += 2;
  356. } else
  357. $ret .= $str [$i];
  358. }
  359. return $ret;
  360. }
  361. private function pass($shop_id, $theverify) {
  362. //服务商家
  363. $ip = $_SERVER ["REMOTE_ADDR"];
  364. $pass = "cms_diaoding.jia.com"; //这里是说好的密码
  365. $check_key = cms_inner_verify ( $shop_id, $ip, $pass );
  366. my_debug ( $check_key );
  367. if ($theverify != $check_key) {
  368. echo "验证不通过!";
  369. exit ();
  370. }
  371. }
  372. private function data_list($scheme_id, $element_type) {
  373. $record_bg = $this->db->get_rows_by_sql (
  374. "SELECT * FROM diaoding_element WHERE scheme_id='$scheme_id' AND element_type='$element_type'" );
  375. if (count ( $record_bg )) {
  376. foreach ( $record_bg as $k => $v ) {
  377. $record_bg [$k] ['qeekaPrice'] = 0;
  378. if ($v ['good_price']) {
  379. $record_bg [$k] ['qeekaPrice'] = $v ['good_price'];
  380. }
  381. $record_bg [$k] ['attributeValue'] = "0,0";
  382. $good_size = $v ['good_size'];
  383. if ($good_size) {
  384. $record_bg [$k] ['attributeValue'] = str_replace ( "*", ",", $good_size );
  385. }
  386. /*$good_id = $v ['good_id'];
  387. $file = file_get_contents ( "http://10.10.21.126:9101/item/getItem?itemId=$good_id" );
  388. $content = json_decode ( $file, true );
  389. $record_bg [$k] ['attributeValue'] = "0,0";
  390. $record_bg [$k] ['qeekaPrice'] = 0;
  391. if (isset ( $content ['result'] )) {
  392. if ($content ['result'] ['itemBase'] ['qeekaPrice']) {
  393. $record_2 [$k] ['qeekaPrice'] = $content ['result'] ['itemBase'] ['qeekaPrice'] / 100;
  394. $content1 = json_decode ( $content ['result'] ['itemBase'] ['attributeJson'],
  395. true );
  396. if (isset ( $content1 [3] ['attributeValue'] ) && strpos (
  397. $content1 [3] ['attributeValue'], "*" ) !== false) {
  398. $record_2 [$k] ['attributeValue'] = str_replace ( "*", ",",
  399. $content1 [3] ['attributeValue'] );
  400. }
  401. }
  402. }*/
  403. }
  404. }
  405. return $record_bg;
  406. }
  407. private function shielding_mobile($str) {
  408. $str = preg_replace ( "/([0-9]{7})([0-9]{3})/", "$1***", $str );
  409. $y = preg_match_all ( '#https?://(.*?)($|/)#m', $str, $r );
  410. preg_match_all ( '@[a-zA-Z0-9\-\.]+\.(cn|com|org|net|mil|edu)@i', "$str", $r );
  411. if (count ( $r [0] )) {
  412. foreach ( $r [0] as $u ) {
  413. if ($u) {
  414. $jia = strpos ( "$u", "jia.com" );
  415. $tg = strpos ( "$u", "tg.com.cn" );
  416. if (! $jia && ! $tg) {
  417. $str = str_replace ( "$u", "***", $str );
  418. }
  419. /*if (! in_array ( "$u", $url )) {
  420. //$str = preg_replace ( "/([A-Za-z]+).([A-Za-z]+)/", "*.*", $str );
  421. }*/
  422. }
  423. }
  424. }
  425. $list = $this->db->get_rows_by_sql ( "SELECT * FROM cms_badword" );
  426. if (count ( $list )) {
  427. foreach ( $list as $v ) {
  428. $str = str_replace ( $v ['badword'], "X", $str );
  429. }
  430. }
  431. return $str;
  432. }
  433. //吊顶商城后台列表模板页面
  434. function diaoding_cms() {
  435. //服务商家
  436. $shop_id = intval ( $this->input->get ( 'shop_id' ) );
  437. $user_id = $shop_id;
  438. $theverify = $this->input->get ( 'theverify' );
  439. $this->pass ( $shop_id, $theverify ); //认证
  440. $view_data = array ();
  441. /*分页列表*/
  442. $page = intval ( $this->input->get ( 'page' ) );
  443. if ($page <= 0 || $page == '') {
  444. $page = 1;
  445. } else {
  446. $page = intval ( $this->input->get ( 'page' ) );
  447. }
  448. $page_size = 10;
  449. $sql_where = 'where 1';
  450. if ($user_id) {
  451. $sql_where = " WHERE user_id='$user_id'";
  452. }
  453. $sql_count = "SELECT count(*) as tot FROM diaoding_scheme_setting " . $sql_where; //取总数,用于分页
  454. $tcount = $this->db->get_record_by_sql ( $sql_count, 'num' );
  455. $t_count = $tcount [0];
  456. $real_page = intval ( ceil ( $t_count / $page_size ) );
  457. if ($page > $real_page && $real_page > 0) {
  458. $page = $real_page;
  459. }
  460. $t_first = ($page - 1) * $page_size;
  461. $sql = "SELECT * FROM diaoding_scheme_setting $sql_where order by setting_id desc LIMIT $t_first,$page_size";
  462. $list = $this->db->get_rows_by_sql ( $sql );
  463. //api图片
  464. $api = $this->tgapi->get_tg_api ();
  465. $api->load ( "upload" );
  466. if (count ( $list )) {
  467. foreach ( $list as $k => $row ) {
  468. $list [$k] ['create_time'] = date ( "Y-m-d", $row ['create_time'] );
  469. $img_addr = $row ['setting_img_small'];
  470. $url = $api->upload->get_url ( $img_addr );
  471. $list [$k] ['setting_img_small'] = "<img src=$url width=70 height=70>";
  472. //$data [$k] ['edit'] = " <button id='diaoding_modify_{$row ['setting_id']}' class='td_p' onclick='diaoding_modify($row ['setting_id']);return false;'>编辑</button>";
  473. $list [$k] ['eidt'] = sprintf (
  474. "<a href='%s' target='_blank'>编辑</a>",
  475. modify_build_url (
  476. array (
  477. 'm' => "update",
  478. 'setting_id' => $row ['setting_id'],
  479. "layout_id" => $row ['layout_id'],
  480. "scheme_id" => $row ['scheme_id'] ) ) );
  481. $list [$k] ['delete'] = sprintf (
  482. "<a href='%s' onclick=return(confirm('确定要删除记录吗?'))>删除</a>",
  483. modify_build_url (
  484. array (
  485. 'm' => "delete",
  486. 'setting_id' => $row ['setting_id'],
  487. 'user_id' => $row ['user_id'] ) ) );
  488. }
  489. }
  490. //my_debug($list);
  491. $pagenav = toolkit_pages_b ( $page, $t_count,
  492. modify_build_url ( array ('page' => $page ) ), $page_size, 8, '' );
  493. $view_data ['list'] = $list;
  494. if ($pagenav) {
  495. $view_data ['getpageinfo'] = $pagenav ['pagecode'];
  496. } else {
  497. $view_data ['getpageinfo'] = '';
  498. }
  499. $this->load->view ( 'comment_admin/diaoding_cms_view', $view_data );
  500. }
  501. //商家预设列表
  502. function diaoding_set() {
  503. $shop_id = intval ( $this->input->get ( 'shop_id' ) );
  504. $theverify = intval ( $this->input->get ( 'theverify' ) );
  505. $this->pass ( $shop_id, $theverify ); //认证
  506. $sch = $this->db->get_record_by_sql (
  507. "SELECT scheme_id FROM diaoding_scheme WHERE shop_id='$shop_id'" );
  508. $scheme_id = $sch ['scheme_id'];
  509. //my_debug($scheme_id);
  510. $view_data = array ();
  511. /*分页列表*/
  512. $page = intval ( $this->input->get ( 'page' ) );
  513. if ($page <= 0 || $page == '') {
  514. $page = 1;
  515. } else {
  516. $page = intval ( $this->input->get ( 'page' ) );
  517. }
  518. $page_size = 10;
  519. $sql_where = "WHERE scheme_id='$scheme_id'";
  520. $sql_count = "SELECT count(*) as tot FROM diaoding_layout " . $sql_where; //取总数,用于分页
  521. $tcount = $this->db->get_record_by_sql ( $sql_count, 'num' );
  522. $t_count = $tcount [0];
  523. $real_page = intval ( ceil ( $t_count / $page_size ) );
  524. if ($page > $real_page && $real_page > 0) {
  525. $page = $real_page;
  526. }
  527. $t_first = ($page - 1) * $page_size;
  528. $sql = "SELECT * FROM diaoding_layout $sql_where order by scheme_id desc LIMIT $t_first,$page_size";
  529. $list = $this->db->get_rows_by_sql ( $sql );
  530. //my_debug($list);
  531. $pagenav = toolkit_pages_b ( $page, $t_count,
  532. modify_build_url ( array ('page' => $page ) ), $page_size, 8, '' );
  533. $view_data ['list'] = $list;
  534. $view_data ['getpageinfo'] = '';
  535. if ($pagenav) {
  536. $view_data ['getpageinfo'] = $pagenav ['pagecode'];
  537. }
  538. $this->load->view ( 'comment_admin/diaoding_scheme_view', $view_data );
  539. }
  540. //商家预设
  541. function diaoding_setshop() {
  542. //服务商家
  543. $shop_id = $this->input->get ( 'shop_id' );
  544. $theverify = $this->input->get ( 'theverify' );
  545. $this->pass ( $shop_id, $theverify ); //认证
  546. $scheme_id = $this->input->get ( 'scheme_id' );
  547. $record_bg = $this->data_list ( $scheme_id, 1 );
  548. $record_2 = $this->data_list ( $scheme_id, 2 );
  549. $record_3 = $this->data_list ( $scheme_id, 3 );
  550. $record_4 = $this->data_list ( $scheme_id, 4 );
  551. $record_5 = $this->data_list ( $scheme_id, 5 );
  552. //my_debug($record_4);
  553. $view_data = array ();
  554. $view_data ['element'] = NULL;
  555. $view_data ['element_bg'] = NULL;
  556. $view_data ['element_bg'] = $record_bg;
  557. $view_data ['element_2'] = $record_2;
  558. $view_data ['element_3'] = $record_3;
  559. $view_data ['element_4'] = $record_4;
  560. $view_data ['element_5'] = $record_5;
  561. //my_debug($record_bg);
  562. //---选择器=-控制分类-
  563. $category_record = $this->db->get_record_by_field ( "diaoding_scheme",
  564. 'scheme_id', $scheme_id );
  565. $category_id = $category_record ['category_id'];
  566. $this->load->model ( 'diaodingtag_model' );
  567. $data = NULL;
  568. $data .= $this->diaodingtag_model->build_tag_select ( 'tagselector', array (13 ),
  569. array ($category_id ), 'setting_tag' );
  570. $data .= "<style>.selected {border-bottom:1px solid #ff0000;color:red;}
  571. .tag_dimen{color:blue;}
  572. #tagselector {border:1px solid #f0f0f0;padding:6px;}
  573. #div{border:1px solid #f0f0f0;margin:2px;padding:1px;}
  574. #span{border:1px solid #909090;margin:2px;padding:1px;}
  575. </style>
  576. ";
  577. $view_data ['show_setting_tag'] = $data;
  578. //=============================标签器 }}end===================================
  579. //上传控件---大缩略图---start
  580. $this->load->library ( 'editors' );
  581. $data_url_pic = modify_build_url ( array ('m' => 'single_upload' ) );
  582. $pic = array (
  583. 'element_id' => 'custom_file_upload',
  584. 'script' => $data_url_pic,
  585. 'lable' => "false" );
  586. $view_data ['upload_file'] = $this->editors->get_upload ( $pic, 'uploadify' );
  587. //=================上传控件
  588. //编辑器---------------------
  589. /*$eddt = array (
  590. 'id' => 'setting_memo',
  591. 'value' => '',
  592. 'width' => '600px',
  593. 'height' => '200px' );
  594. $view_data ['setting_memo'] = $this->editors->getedit ( $eddt );*/
  595. //----end 编辑器----------
  596. $this->load->view ( 'diaoding_setting/diaoding_setshop_view', $view_data );
  597. }
  598. function insert() {
  599. $shop_id = $this->input->get ( 'shop_id' );
  600. $theverify = $this->input->get ( 'theverify' );
  601. $this->pass ( $shop_id, $theverify ); //认证
  602. $scheme_id = $this->input->get ( 'scheme_id' );
  603. $layout_id = $this->input->get ( 'layout_id' );
  604. $persist_record = $this->db->get_record_by_field ( "diaoding_scheme", 'scheme_id',
  605. $scheme_id );
  606. $setting_tag = $this->input->post ( 'setting_tag' );
  607. if (! $setting_tag) {
  608. $setting_tag = "c" . $persist_record ['category_id'] . "c";
  609. }
  610. $shop_id = $persist_record ['shop_id'];
  611. $room_name = $this->input->post ( 'room_name' );
  612. $room_width = $this->input->post ( 'room_width' );
  613. $room_height = $this->input->post ( 'room_height' );
  614. $dd_images = $this->input->post ( 'dd_images' ); //吊顶图片数组赋到隐藏域中
  615. $dd_type = $this->input->post ( 'dd_type' );
  616. $pp_code = $this->input->post ( 'pp_code' );
  617. $tc_code = $this->input->post ( 'tc_code' );
  618. $dqmk_group = $this->input->post ( 'dqmk_group' );
  619. $yf = $this->input->post ( 'yf' ); //安装费
  620. $sbt_price = $this->input->post ( 'sbt_price' );
  621. $zlg_price = $this->input->post ( 'zlg_price' );
  622. $sjlg_price = $this->input->post ( 'sjlg_price' );
  623. $fltz_price = $this->input->post ( 'fltz_price' );
  624. $total = $this->input->post ( 'total' ); //吊顶计算出来总价 --
  625. $setting_img_small = $this->input->post ( 'api' ); //缩略图
  626. //====================新加的info_extra、info_extra_2字段 2012.10.29
  627. $info_highlight = $this->input->post ( 'info_highlight' );
  628. $info_extra = $this->input->post ( 'info_extra' );
  629. $info_extra_2 = $this->input->post ( 'info_extra_2' );
  630. //=======================================================
  631. $insert = array (
  632. 'scheme_id' => $scheme_id,
  633. 'layout_id' => $layout_id,
  634. 'user_id' => $shop_id,
  635. 'setting_tag' => $setting_tag,
  636. 'setting_name' => $room_name,
  637. 'setting_width' => $room_width,
  638. 'setting_heigth' => $room_height,
  639. 'mail_price' => $yf,
  640. 'dd_images' => $dd_images,
  641. 'dqmk_group' => $dqmk_group,
  642. 'dd_type' => $dd_type,
  643. 'pp_code' => $pp_code,
  644. 'tc_code' => $tc_code,
  645. 'sbt_price' => $sbt_price,
  646. 'fltz_price' => $fltz_price,
  647. 'total' => $total,
  648. 'setting_img_small' => $setting_img_small,
  649. 'info_highlight' => $info_highlight,
  650. 'info_extra' => $info_extra,
  651. 'info_extra_2' => $info_extra_2,
  652. "create_time" => time () );
  653. my_debug ( $insert );
  654. //exit;
  655. $db_ret = $this->db->insert ( "diaoding_scheme_setting", $insert );
  656. if ($db_ret) {
  657. msg ( "DIY入库成功", modify_build_url ( array ('m' => 'diaoding_setshop' ) ) );
  658. }
  659. }
  660. function delete() {
  661. $shop_id = intval ( $this->input->get ( 'shop_id' ) );
  662. $theverify = $this->input->get ( 'theverify' );
  663. $this->pass ( $shop_id, $theverify ); //认证
  664. $record_id = $this->input->get ( "setting_id" );
  665. $record_id = intval ( $record_id );
  666. $this->db->where ( 'setting_id', $record_id );
  667. $success = $this->db->delete ( 'diaoding_scheme_setting' );
  668. if ($success) {
  669. msg ( "", modify_build_url ( array ("m" => "diaoding_cms" ) ) );
  670. }
  671. }
  672. //吊顶后台商家素材方案列表
  673. function diaoding_scheme_list() {
  674. //服务商家
  675. $shop_id = intval ( $this->input->get ( 'shop_id' ) );
  676. $user_id = $shop_id;
  677. $theverify = $this->input->get ( 'theverify' );
  678. $this->pass ( $shop_id, $theverify ); //认证*/
  679. $view_data = array ();
  680. $view_data ['pages_nav'] = '';
  681. $view_data ['main_grid'] = '';
  682. $view_data ['num'] = '';
  683. //=======================方案列表================================
  684. $page_size = 10;
  685. $total_num = 0;
  686. $page_num = $this->input->post ( 'page_num' );
  687. if ($page_num < 1) {
  688. $page_num = 1;
  689. }
  690. $sql_where = "WHERE length(scheme_name)>0 && shop_id = $user_id ";
  691. if ($this->input->post ( 'scheme_name' )) {
  692. $sql_where = $sql_where . sprintf ( " AND scheme_name like '%s%s%s' ", '%',
  693. $this->input->post ( 'scheme_name' ), '%' );
  694. }
  695. $sql_count = "SELECT count(*) as tot FROM diaoding_scheme $sql_where";
  696. $row = $this->db->get_record_by_sql ( $sql_count, 'num' );
  697. $total_num = $row [0];
  698. $pages_obj = new PageNav ( $page_size, $total_num, $page_num, 10, 2 );
  699. $view_data ['pages_nav'] = $pages_obj->show_pages ();
  700. $select_limit_start = intval ( ($page_num - 1) * $page_size );
  701. $sql = "SELECT * FROM diaoding_scheme $sql_where ORDER BY scheme_id DESC";
  702. $sql = "$sql LIMIT {$select_limit_start},{$page_size}";
  703. $data = $this->db->get_rows_by_sql ( $sql );
  704. //my_debug($data);
  705. $field_list = trim ( 'none' );
  706. $field_arr = null;
  707. if ($field_list) {
  708. $field_arr = explode ( ',', $field_list );
  709. $field_arr = array_flip ( $field_arr );
  710. }
  711. if (count ( $data )) {
  712. foreach ( $data as $k => $row ) {
  713. if ($field_arr) {
  714. $data [$k] = array_intersect_key ( $row, $field_arr );
  715. }
  716. $data [$k] ['方案ID'] = $row ['scheme_id'];
  717. $data [$k] ['方案名称'] = $row ['scheme_name'];
  718. $data [$k] ['操作'] = sprintf ( "<a href='%s'>空间列表</a>",
  719. modify_build_url (
  720. array ('m' => 'layout_list', 'sid' => $row ['scheme_id'] ) ) );
  721. $data [$k] ['操作'] .= "<font color = \"blue\">&nbsp;|&nbsp;</font>";
  722. $data [$k] ['操作'] .= "<a href = \"javascript void(0)\" onclick=\"edit_scheme({$row['scheme_id']});return false;\">编辑</a>";
  723. $data [$k] ['操作'] .= "<font color = \"blue\">&nbsp;|&nbsp;</font>";
  724. $data [$k] ['操作'] .= "<a href = \"javascript void(0)\" onclick=\"if(!confirm('确定要删除?')){return false;}del_scheme({$row['scheme_id']});return false;\"\">刪除</a>";
  725. //my_debug($data);
  726. $this->datagrid->reset ();
  727. $view_data ['main_grid'] = $this->datagrid->build ( 'datagrid', $data, TRUE );
  728. }
  729. }
  730. $view_data ['num'] = $total_num;
  731. $this->load->view ( 'diaoding/scheme_list_view', $view_data );
  732. }
  733. function edit_scheme() {
  734. $shop_id = intval ( $this->input->get ( 'shop_id' ) );
  735. $user_id = $shop_id;
  736. $theverify = $this->input->get ( 'theverify' );
  737. $this->pass ( $shop_id, $theverify ); //认证*/
  738. $scheme_id = intval ( $this->input->get ( 'sid' ) );
  739. $view_data = array ();
  740. $view_data ['record'] = null;
  741. if (! $scheme_id) {
  742. $success = $this->db->insert ( 'diaoding_scheme',
  743. array ('scheme_name' => '', 'shop_id' => $user_id, 'create_time' => time () ) );
  744. if ($success) {
  745. $scheme_id = $this->db->insert_id ();
  746. redirect (
  747. modify_build_url ( array ('sid' => $scheme_id, 'shop_id' => $user_id ) ) );
  748. }
  749. }
  750. //===================清理无效数据{{=====================================
  751. $time_limit = time () - 60 * 60 * 2;
  752. $this->db->query (
  753. sprintf ( "DELETE FROM diaoding_scheme WHERE ( scheme_name = '') AND create_time<%s",
  754. $time_limit ) );
  755. //==========end}}=====================================================================
  756. //=================={{品牌列表=================================================
  757. $category_list = $this->db->get_rows_by_sql (
  758. "select*from diaoding_tag where tag_dimension_id=13" );
  759. $pinpai_arr [0] = "-请选择品牌-";
  760. foreach ( $category_list as $k => $v ) {
  761. $pinpai_arr [$v ['tag_id']] = $v ['tag_name'];
  762. }
  763. $view_data ['pinpai'] = $pinpai_arr;
  764. //===================================)).end================================
  765. $view_data ['record'] = $this->db->get_record_by_field ( 'diaoding_scheme',
  766. 'scheme_id', $scheme_id );
  767. $scheme_name = trim ( $this->input->post ( 'scheme_name' ) );
  768. $category_id = intval ( $this->input->post ( 'category_id' ) );
  769. $shop_id = intval ( $this->input->post ( 'shop_id' ) );
  770. $scheme_memo = trim ( $this->input->post ( 'scheme_memo' ) );
  771. $this->form_validation->set_rules ( 'scheme_name', '方案名称', 'required' );
  772. $this->form_validation->set_rules ( 'category_id', '品牌id', 'required|is_natural_no_zero' );
  773. $this->form_validation->set_rules ( 'shop_id', '店铺id', 'required' );
  774. if ($this->input->post ( 'submitform' )) {
  775. if ($this->form_validation->run () == true) {
  776. $this->db->where ( 'scheme_id', $scheme_id );
  777. $success = $this->db->update ( 'diaoding_scheme',
  778. array (
  779. 'scheme_name' => $scheme_name,
  780. 'scheme_memo' => $scheme_memo,
  781. 'category_id' => $category_id,
  782. 'shop_id' => $shop_id,
  783. 'create_time' => $create_time ) );
  784. if ($success) {
  785. echo "<script>if(parent.window.close_dialog){parent.window.close_dialog();}</script>";
  786. } else {
  787. msg ( "数据更新错误", modify_build_url () );
  788. }
  789. }
  790. }
  791. $this->load->view ( 'diaoding/scheme_edit_view', $view_data );
  792. }
  793. function layout_list() {
  794. $shop_id = intval ( $this->input->get ( 'shop_id' ) );
  795. $user_id = $shop_id;
  796. $theverify = $this->input->get ( 'theverify' );
  797. $this->pass ( $shop_id, $theverify ); //认证*/
  798. $view_data = array ();
  799. $view_data ['pages_nav'] = '';
  800. $view_data ['main_grid'] = '';
  801. $scheme_id = intval ( $this->input->get ( 'sid' ) );
  802. $view_data ['scheme_id'] = $scheme_id;
  803. //=======================方案列表================================
  804. $page_size = 10;
  805. $total_num = 0;
  806. $page_num = $this->input->post ( 'page_num' );
  807. if ($page_num < 1) {
  808. $page_num = 1;
  809. }
  810. $sql_where = "WHERE scheme_id ='$scheme_id' AND length(layout_name) > 0";
  811. if ($this->input->post ( 'layout_name' )) {
  812. $sql_where = $sql_where . sprintf ( " AND layout_name like '%s%s%s' ", '%',
  813. $this->input->post ( 'layout_name' ), '%' );
  814. }
  815. $sql_count = "SELECT count(*) as tot FROM diaoding_layout $sql_where";
  816. $row = $this->db->get_record_by_sql ( $sql_count, 'num' );
  817. $total_num = $row [0];
  818. $pages_obj = new PageNav ( $page_size, $total_num, $page_num, 10, 2 );
  819. $view_data ['pages_nav'] = $pages_obj->show_pages ();
  820. $select_limit_start = intval ( ($page_num - 1) * $page_size );
  821. $sql = "SELECT * FROM diaoding_layout $sql_where ORDER BY layout_id DESC";
  822. $sql = "$sql LIMIT {$select_limit_start},{$page_size}";
  823. $data = $this->db->get_rows_by_sql ( $sql );
  824. //my_debug($data);
  825. $field_list = trim ( 'none' );
  826. $field_arr = null;
  827. if ($field_list) {
  828. $field_arr = explode ( ',', $field_list );
  829. $field_arr = array_flip ( $field_arr );
  830. }
  831. if (count ( $data )) {
  832. foreach ( $data as $k => $row ) {
  833. if ($field_arr) {
  834. $data [$k] = array_intersect_key ( $row, $field_arr );
  835. }
  836. $data [$k] ['空间ID'] = $row ['layout_id'];
  837. $data [$k] ['空间名称'] = $row ['layout_name'];
  838. $data [$k] ['操作'] = sprintf ( "<a href='%s' >空间预设</a>",
  839. modify_build_url (
  840. array ( 'm' => 'diaoding_setshop',
  841. 'scheme_id' => $row ['scheme_id'],
  842. 'layout_id' => $row ['layout_id'] ) ) );
  843. $data [$k] ['操作'] .= "<font color = \"blue\">&nbsp;|&nbsp;</font>";
  844. $data [$k] ['操作'] .= "<a href = \"javascript void(0)\" onclick=\"element_list({$row['layout_id']},{$row['scheme_id']});return false;\">素材列表</a>";
  845. $data [$k] ['操作'] .= "<font color = \"blue\">&nbsp;|&nbsp;</font>";
  846. $data [$k] ['操作'] .= "<a href = \"javascript void(0)\" onclick=\"edit_layout({$row['layout_id']},{$scheme_id});return false;\">编辑</a>";
  847. $data [$k] ['操作'] .= "<font color = \"blue\">&nbsp;|&nbsp;</font>";
  848. $data [$k] ['操作'] .= "<a href = \"javascript void(0)\" onclick=\"if(!confirm('确定要删除?')){return false;}del_layout({$row['layout_id']});return false;\"\">刪除</a>";
  849. //my_debug($data);
  850. $this->datagrid->reset ();
  851. $view_data ['main_grid'] = $this->datagrid->build ( 'datagrid', $data, TRUE );
  852. }
  853. }
  854. $this->load->view ( 'diaoding/layout_list_view', $view_data );
  855. }
  856. function edit_layout() {
  857. $shop_id = intval ( $this->input->get ( 'shop_id' ) );
  858. $user_id = $shop_id;
  859. $theverify = $this->input->get ( 'theverify' );
  860. $this->pass ( $shop_id, $theverify ); //认证*/
  861. $layout_id = intval ( $this->input->get ( 'id' ) );
  862. $scheme_id = intval ( $this->input->get ( 'sid' ) );
  863. $view_data = array ();
  864. $view_data ['record'] = null;
  865. if (! $layout_id) {
  866. $default_data = array (
  867. 'layout_name' => '',
  868. 'scheme_id' => $scheme_id,
  869. /*'layout_width' => 70, //默认单元格宽度
  870. 'layout_height' => 70, //默认单元格高度
  871. 'layout_product_width' => 140, //默认产品宽度
  872. 'layout_product_height' => 60, //默认产品高度*/
  873. 'create_time' => time () );
  874. $success = $this->db->insert ( 'diaoding_layout', $default_data );
  875. if ($success) {
  876. $layout_id = $this->db->insert_id ();
  877. redirect ( modify_build_url ( array ('id' => $layout_id ) ) );
  878. }
  879. }
  880. //===================清理无效数据{{=====================================
  881. $time_limit = time () - 60 * 60 * 2;
  882. $this->db->query (
  883. sprintf ( "DELETE FROM diaoding_layout WHERE ( layout_name = '') AND create_time<%s",
  884. $time_limit ) );
  885. //==========end}}=====================================================================
  886. $view_data ['record'] = $this->db->get_record_by_field ( 'diaoding_layout',
  887. 'layout_id', $layout_id );
  888. $layout_name = trim ( $this->input->post ( 'layout_name' ) );
  889. $layout_memo = trim ( $this->input->post ( 'layout_memo' ) );
  890. /*$layout_width = intval ( $this->input->post ( 'layout_width' ) );
  891. $layout_height = intval ( $this->input->post ( 'layout_height' ) );
  892. $layout_num = intval ( $this->input->post ( 'layout_num' ) );
  893. $layout_total = intval ( $this->input->post ( 'layout_total' ) );
  894. $layout_product_width = intval ( $this->input->post ( 'layout_product_width' ) );
  895. $layout_product_height = intval ( $this->input->post ( 'layout_product_height' ) );*/
  896. $this->form_validation->set_rules ( 'layout_name', '空间名称', 'required' );
  897. if ($this->input->post ( 'submitform' )) {
  898. if ($this->form_validation->run () == true) {
  899. $this->db->where ( 'layout_id', $layout_id );
  900. $success = $this->db->update ( 'diaoding_layout',
  901. array (
  902. 'layout_name' => $layout_name,
  903. 'layout_memo' => $layout_memo,
  904. /*'layout_width' => $layout_width,
  905. 'layout_height' => $layout_height,
  906. 'layout_num' => $layout_num,
  907. 'layout_total' => $layout_total,
  908. 'layout_product_width' => $layout_product_width,
  909. 'layout_product_height' => $layout_product_height,*/
  910. 'create_time' => time () ) );
  911. if ($success) {
  912. echo "<script>if(parent.window.close_dialog){parent.window.close_dialog();}</script>";
  913. } else {
  914. msg ( "数据更新错误", modify_build_url () );
  915. }
  916. }
  917. }
  918. $this->load->view ( 'diaoding/layout_edit_view', $view_data );
  919. }
  920. function element_list() {
  921. $shop_id = intval ( $this->input->get ( 'shop_id' ) );
  922. $user_id = $shop_id;
  923. $theverify = $this->input->get ( 'theverify' );
  924. $this->pass ( $shop_id, $theverify ); //认证*/
  925. $view_data = array ();
  926. $view_data ['pages_nav'] = '';
  927. $view_data ['main_grid'] = '';
  928. $layout_id = intval ( $this->input->get ( 'lid' ) );
  929. $scheme_id = intval ( $this->input->get ( 'sid' ) );
  930. $view_data ['layout_id'] = $layout_id;
  931. $view_data ['scheme_id'] = $scheme_id;
  932. //=======================方案列表================================
  933. $page_size = 10;
  934. $total_num = 0;
  935. $page_num = $this->input->post ( 'page_num' );
  936. if ($page_num < 1) {
  937. $page_num = 1;
  938. }
  939. $sql_where = "WHERE layout_id ='$layout_id' AND length(element_name) > 0";
  940. if ($this->input->post ( 'element_name' )) {
  941. $sql_where = $sql_where . sprintf ( " AND element_name like '%s%s%s' ", '%',
  942. $this->input->post ( 'element_name' ), '%' );
  943. }
  944. $sql_count = "SELECT count(*) as tot FROM diaoding_element $sql_where";
  945. $row = $this->db->get_record_by_sql ( $sql_count, 'num' );
  946. $total_num = $row [0];
  947. $pages_obj = new PageNav ( $page_size, $total_num, $page_num, 10, 2 );
  948. $view_data ['pages_nav'] = $pages_obj->show_pages ();
  949. $select_limit_start = intval ( ($page_num - 1) * $page_size );
  950. $sql = "SELECT * FROM diaoding_element $sql_where ORDER BY element_id DESC";
  951. $sql = "$sql LIMIT {$select_limit_start},{$page_size}";
  952. $data = $this->db->get_rows_by_sql ( $sql );
  953. //my_debug($data);
  954. $field_list = trim ( 'none' );
  955. $field_arr = null;
  956. if ($field_list) {
  957. $field_arr = explode ( ',', $field_list );
  958. $field_arr = array_flip ( $field_arr );
  959. }
  960. if (count ( $data )) {
  961. foreach ( $data as $k => $row ) {
  962. if ($field_arr) {
  963. $data [$k] = array_intersect_key ( $row, $field_arr );
  964. }
  965. $data [$k] ['素材ID'] = $row ['element_id'];
  966. $data [$k] ['素材名称'] = $row ['element_name'];
  967. if ($row ['element_type'] == 1) {
  968. $data [$k] ['类型'] = '背景';
  969. }
  970. if ($row ['element_type'] == 2) {
  971. $data [$k] ['类型'] = '照明';
  972. }
  973. if ($row ['element_type'] == 3) {
  974. $data [$k] ['类型'] = '取暖';
  975. }
  976. if ($row ['element_type'] == 4) {
  977. $data [$k] ['类型'] = '排气';
  978. }
  979. if ($row ['element_type'] == 5) {
  980. $data [$k] ['类型'] = '多功能';
  981. }
  982. $data [$k] ['商品id'] = $row ['good_id'];
  983. /*$data [$k] ['图片宽'] = $row ['lay_width'];
  984. $data [$k] ['图片高'] = $row ['lay_heigth'];*/
  985. $data [$k] ['商品图片'] = "<img src={$row['lay_img_path']} height=44 border=0/>";
  986. $data [$k] ['操作'] = "<a href = \"javascript void(0)\" onclick=\"edit_element({$row['element_id']},0,0);return false;\">编辑</a>";
  987. $data [$k] ['操作'] .= "<font color = \"blue\">&nbsp;|&nbsp;</font>";
  988. $data [$k] ['操作'] .= "<a href = \"javascript void(0)\" onclick=\"if(!confirm('确定要删除?')){return false;}del_layout({$row['element_id']});return false;\"\">刪除</a>";
  989. //my_debug($data);
  990. $this->datagrid->reset ();
  991. $view_data ['main_grid'] = $this->datagrid->build ( 'datagrid', $data, TRUE );
  992. }
  993. }
  994. $this->load->view ( 'diaoding/element_list_view', $view_data );
  995. }
  996. function edit_element() {
  997. $shop_id = intval ( $this->input->get ( 'shop_id' ) );
  998. $user_id = $shop_id;
  999. $theverify = $this->input->get ( 'theverify' );
  1000. $this->pass ( $shop_id, $theverify ); //认证*/
  1001. $UID = $this->session->userdata ( 'UID' );
  1002. $TG_user_name = $this->session->userdata ( 'TG_user_name' );
  1003. $TG_checkKey = $this->session->userdata ( 'TG_checkKey' );
  1004. $element_id = intval ( $this->input->get ( 'id' ) );
  1005. $layout_id = intval ( $this->input->get ( 'lid' ) );
  1006. $scheme_id = intval ( $this->input->get ( 'sid' ) );
  1007. $view_data = array ();
  1008. $view_data ['record'] = null;
  1009. if (! $element_id) {
  1010. $default_data = array (
  1011. 'element_name' => '',
  1012. 'layout_id' => $layout_id,
  1013. 'scheme_id' => $scheme_id,
  1014. 'create_time' => time () );
  1015. $success = $this->db->insert ( 'diaoding_element', $default_data );
  1016. if ($success) {
  1017. $element_id = $this->db->insert_id ();
  1018. redirect ( modify_build_url ( array ('id' => $element_id ) ) );
  1019. }
  1020. }
  1021. //===================清理无效数据{{=====================================
  1022. $time_limit = time () - 60 * 60 * 2;
  1023. $this->db->query (
  1024. sprintf (
  1025. "DELETE FROM diaoding_element WHERE ( element_name = '') AND create_time<%s",
  1026. $time_limit ) );
  1027. //==========end}}=====================================================================
  1028. $element_select_data = array ();
  1029. $element_select_data ['0'] = '-选择类型-';
  1030. $element_select_data ['1'] = '背景';
  1031. $element_select_data ['2'] = '照明';
  1032. $element_select_data ['3'] = '取暖';
  1033. $element_select_data ['4'] = '排气';
  1034. $element_select_data ['5'] = '多功能';
  1035. $view_data ['element_select'] = $element_select_data;
  1036. $view_data ['record'] = $this->db->get_record_by_field ( 'diaoding_element', 'element_id',
  1037. $element_id );
  1038. $element_name = trim ( $this->input->post ( 'element_name' ) );
  1039. $element_type = intval ( $this->input->post ( 'element_type' ) );
  1040. $qb_type = intval ( $this->input->post ( 'qb_type' ) );
  1041. $good_id = trim ( $this->input->post ( 'good_id' ) );
  1042. $good_price = $this->input->post ( 'good_price' );
  1043. $good_size = $this->input->post ( 'good_size' );
  1044. //============================{{图片上传begin==============================
  1045. $element_pic = modify_build_url (
  1046. array (
  1047. 'c' => 'diaodingscheme',
  1048. 'm' => 'upload',
  1049. 'element_id' => $element_id,
  1050. 'page' => 'element_pic',
  1051. 'TG_loginuserid' => $UID,
  1052. 'TG_loginuser' => base64_encode ( $TG_user_name ),
  1053. 'TG_checkKey' => $TG_checkKey,
  1054. 'input' => 'element_pic' ) );
  1055. $pic = array (
  1056. 'element_id' => 'element_pic',
  1057. 'queue_id' => 'custom_queue',
  1058. 'script' => $element_pic,
  1059. 'lable' => "false" );
  1060. $view_data ['element_picture'] = $this->editors->get_upload ( $pic );
  1061. //=============================.end}}======================================
  1062. //my_debug($element_type);
  1063. $this->form_validation->set_message ( 'is_natural_no_zero', '素材类型必须选择' );
  1064. $this->form_validation->set_rules ( 'element_name', '素材名称', 'required' );
  1065. $this->form_validation->set_rules ( 'good_id', '商品id', 'numeric|required' );
  1066. $this->form_validation->set_rules ( 'good_price', '商品价格', 'required' );
  1067. $this->form_validation->set_rules ( 'good_size', '商品规格', 'required' );
  1068. $this->form_validation->set_rules ( 'element_type', '素材类型', 'is_natural_no_zero|required' );
  1069. $this->form_validation->set_rules ( 'qb_type', '是否对称', 'required' );
  1070. if ($this->input->post ( 'submit' )) {
  1071. if ($this->form_validation->run () == true) {
  1072. $this->db->where ( 'element_id', $element_id );
  1073. $success = $this->db->update ( 'diaoding_element',
  1074. array (
  1075. 'element_name' => $element_name,
  1076. 'element_type' => $element_type,
  1077. 'good_id' => $good_id,
  1078. 'good_price' => $good_price,
  1079. 'good_size' => $good_size,
  1080. 'qb_type' => $qb_type,
  1081. 'create_time' => time () ) );
  1082. if ($success) {
  1083. echo "<script>if(parent.window.close_dialog){parent.window.close_dialog();}</script>";
  1084. } else {
  1085. msg ( "数据更新错误", modify_build_url () );
  1086. }
  1087. }
  1088. }
  1089. $this->load->view ( 'diaoding/element_edit_view', $view_data );
  1090. }
  1091. function del_element() {
  1092. $shop_id = intval ( $this->input->get ( 'shop_id' ) );
  1093. $user_id = $shop_id;
  1094. $theverify = $this->input->get ( 'theverify' );
  1095. $this->pass ( $shop_id, $theverify ); //认证*/
  1096. $element_id = $this->input->get ( 'id' );
  1097. $record_info = $this->db->get_record_by_field ( 'diaoding_element', 'element_id',
  1098. $element_id );
  1099. if ($record_info ['lay_img_path']) {
  1100. $old_img = (FCPATH . $record_info ['lay_img_path']);
  1101. if (file_exists ( $old_img ) == true) {
  1102. unlink ( $old_img );
  1103. }
  1104. }
  1105. $this->db->where ( 'element_id', $element_id );
  1106. $this->db->delete ( 'diaoding_element' );
  1107. echo "<script>if(parent.window.close_dialog){parent.window.close_dialog();}</script>";
  1108. return;
  1109. }
  1110. function del_layout() {
  1111. $shop_id = intval ( $this->input->get ( 'shop_id' ) );
  1112. $user_id = $shop_id;
  1113. $theverify = $this->input->get ( 'theverify' );
  1114. $this->pass ( $shop_id, $theverify ); //认证*/
  1115. $layout_id = intval ( $this->input->get ( 'lid' ) );
  1116. $sql = "select (lay_img_path) from diaoding_element where layout_id = $layout_id";
  1117. $img_rows = $this->db->get_rows_by_sql ( $sql );
  1118. if (count ( $img_rows ) > 0) {
  1119. foreach ( $img_rows as $k => $v ) {
  1120. $old_img = (FCPATH . $v ['lay_img_path']);
  1121. if (file_exists ( $old_img ) == true) {
  1122. unlink ( $old_img );
  1123. }
  1124. }
  1125. }
  1126. $this->db->where ( 'layout_id', $layout_id );
  1127. $this->db->delete ( 'diaoding_element' );
  1128. $this->db->where ( 'layout_id', $layout_id );
  1129. $this->db->delete ( 'diaoding_layout' );
  1130. return;
  1131. }
  1132. function del_scheme() {
  1133. $shop_id = intval ( $this->input->get ( 'shop_id' ) );
  1134. $user_id = $shop_id;
  1135. $theverify = $this->input->get ( 'theverify' );
  1136. $this->pass ( $shop_id, $theverify ); //认证*/
  1137. $scheme_id = intval ( $this->input->get ( 'sid' ) );
  1138. $sql = "select (lay_img_path) from diaoding_element where scheme_id = $scheme_id";
  1139. $img_rows = $this->db->get_rows_by_sql ( $sql );
  1140. if (count ( $img_rows ) > 0) {
  1141. foreach ( $img_rows as $k => $v ) {
  1142. $old_img = (FCPATH . $v ['lay_img_path']);
  1143. if (file_exists ( $old_img ) == true) {
  1144. unlink ( $old_img );
  1145. }
  1146. }
  1147. }
  1148. $this->db->where ( 'scheme_id', $scheme_id );
  1149. $this->db->delete ( 'diaoding_element' );
  1150. $this->db->where ( 'scheme_id', $scheme_id );
  1151. $this->db->delete ( 'diaoding_layout' );
  1152. $this->db->where ( 'scheme_id', $scheme_id );
  1153. $this->db->delete ( 'diaoding_scheme' );
  1154. return;
  1155. }
  1156. function upload() {
  1157. if (count ( $_FILES ) < 1) {
  1158. my_debug ( "没有发现上传文件" );
  1159. return;
  1160. }
  1161. if (! array_key_exists ( 'Filedata', $_FILES )) {
  1162. my_debug ( "非法的上传操作" );
  1163. return;
  1164. }
  1165. $file_name = $_FILES ['Filedata'] ['name'];
  1166. $file_name_parts = explode ( '.', $file_name );
  1167. if (count ( $file_name_parts ) < 2) {
  1168. my_debug ( "非法的文件名" );
  1169. return;
  1170. }
  1171. $len = count ( $file_name_parts );
  1172. $file_ext_name = $file_name_parts [$len - 1];
  1173. $file_ext_name = strtolower ( $file_ext_name );
  1174. if (! $file_ext_name) {
  1175. my_debug ( "非法的文件扩展名" );
  1176. return;
  1177. }
  1178. if (! in_array ( $file_ext_name,
  1179. array ('gif', 'jpg', 'jpe…

Large files files are truncated, but you can click here to view the full file