You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

261 lines
8.9 KiB

  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. require APPPATH . '/libraries/REST_Controller.php';
  4. class Management extends REST_Controller
  5. {
  6. /****************************************************************************
  7. * 공용 순서변경
  8. ***************************************************************************/
  9. function sort_post()
  10. {
  11. $key = $this->input->post('key', TRUE);
  12. $sort_idx = $this->input->post("sort_order", TRUE);
  13. $table = $this->input->post('table', TRUE);
  14. $sort_col = $this->input->post('sort', TRUE);
  15. if(empty($key) OR empty($table) or empty($sort_col))
  16. $this->response(array('message'=>'잘못된 접근입니다.'));
  17. $update_array = array();
  18. for($i=1; $i<=count($sort_idx); $i++)
  19. {
  20. $update_array[] = array(
  21. $key => $sort_idx[$i-1],
  22. $sort_col => $i
  23. );
  24. }
  25. $this->db->update_batch($table, $update_array, $key);
  26. }
  27. /**********************************************************************
  28. * FAQ 카테고리 삭제
  29. ***********************************************************************/
  30. function faq_category_delete()
  31. {
  32. $fac_idx = $this->delete('fac_idx', TRUE);
  33. if (empty($fac_idx)) $this->error_return("FAQ 그룹 고유키값이 없습니다.", 400);
  34. $upd_user = $this->member->is_login();
  35. $upd_datetime = date('Y-m-d H:i:s');
  36. $this->db
  37. ->where('fac_idx', $fac_idx)
  38. ->set('fac_status','N')
  39. ->set('sort','0')
  40. ->set('upd_user', $upd_user)
  41. ->set('upd_datetime', $upd_datetime)
  42. ->update('faq_category');
  43. $this->db
  44. ->where('fac_idx', $fac_idx)
  45. ->set('faq_status','N')
  46. ->set('sort','0')
  47. ->set('upd_user', $upd_user)
  48. ->set('upd_datetime', $upd_datetime)
  49. ->update('faq');
  50. }
  51. /**********************************************************************
  52. * FAQ 목록 가져오기
  53. ***********************************************************************/
  54. function faq_get()
  55. {
  56. $this->load->model('faq_model');
  57. $fac_idx = trim($this->get('fac_idx', TRUE));
  58. if (empty($fac_idx)) $this->error_return("FAQ 그룹 고유키값이 없습니다.", 400);
  59. $faq_list = $this->faq_model->get_detail_list($fac_idx);
  60. $this->response($faq_list, 200);
  61. }
  62. function faq_category_get()
  63. {
  64. $this->load->model('faq_model');
  65. $fac_idx = trim($this->get('fac_idx', TRUE));
  66. if (empty($fac_idx)) $this->error_return("FAQ 그룹 고유키값이 없습니다.", 400);
  67. $result = $this->faq_model->get_category($fac_idx);
  68. $this->response($result, 200);
  69. }
  70. /**********************************************************************
  71. * FAQ 삭제
  72. ***********************************************************************/
  73. function faq_delete()
  74. {
  75. $this->load->model('faq_model');
  76. $faq_idx = $this->delete('faq_idx', TRUE);
  77. if (empty($faq_idx)) $this->error_return("FAQ 고유키값이 없습니다.", 400);
  78. // 기존 FAQ 값을 불러온다.
  79. $faq = $this->faq_model->get_faq($faq_idx);
  80. $this->db
  81. ->where('faq_idx', $faq_idx)
  82. ->set('faq_status','N')
  83. ->set('upd_user', $this->member->is_login() )
  84. ->set('upd_datetime', date('Y-m-d H:i:s'))
  85. ->update('faq');
  86. $this->faq_model->update_category_count($faq['fac_idx']);
  87. }
  88. /**
  89. * 팝업 목록
  90. */
  91. function popups_get() {
  92. $page_rows = $this->input->get('take', TRUE, 15);
  93. $start = $this->input->get('skip', TRUE);
  94. $this->db
  95. ->select('SQL_CALC_FOUND_ROWS P.*, M.mem_nickname AS upd_username', FALSE)
  96. ->from('popup AS P')
  97. ->join('member AS M','M.mem_idx=P.upd_user','inner')
  98. ->where('pop_status', 'Y')
  99. ->order_by('pop_idx DESC')
  100. ->limit($page_rows, $start);
  101. $result = $this->db->get();
  102. $return['lists'] = $result->result_array();
  103. $return['totalCount'] = (int)$this->db->query("SELECT FOUND_ROWS() AS cnt")->row(0)->cnt;
  104. foreach($return['lists'] as $i=>&$row)
  105. {
  106. $row['nums'] = $return['totalCount'] - $i - $start;
  107. $row['pop_state'] = (strtotime($row['pop_start']) <= time() && strtotime($row['pop_end']) >= time())?'표시중':'미표시중';
  108. }
  109. $this->response($return, 200);
  110. }
  111. /**
  112. * 팝업 삭제
  113. */
  114. function popups_delete()
  115. {
  116. $pop_idx = $this->delete('pop_idx', TRUE);
  117. $mem_idx = $this->member->is_login();
  118. if(empty($pop_idx)) $this->response('잘못된 접근입니다.', 400);
  119. $data['upd_datetime'] = date('Y-m-d H:i:s');
  120. $data['upd_user'] = $mem_idx;
  121. $data['pop_status'] = 'N';
  122. $this->db->where('pop_idx', $pop_idx);
  123. $this->db->update('popup', $data);
  124. }
  125. /**
  126. * 사이트맵 목록
  127. */
  128. function sitemaps_get()
  129. {
  130. $page_rows = $this->input->get('take', TRUE, 15);
  131. $start = $this->input->get('skip', TRUE);
  132. $this->db
  133. ->select('SQL_CALC_FOUND_ROWS S.*, M.mem_nickname AS upd_username', FALSE)
  134. ->from('sitemap AS S')
  135. ->join('member AS M','M.mem_idx=S.upd_user','inner')
  136. ->order_by('sit_idx DESC')
  137. ->limit($page_rows, $start);
  138. $result = $this->db->get();
  139. $return['lists'] = $result->result_array();
  140. $return['totalCount'] = (int)$this->db->query("SELECT FOUND_ROWS() AS cnt")->row(0)->cnt;
  141. $this->response($return, 200);
  142. }
  143. function sitemaps_delete()
  144. {
  145. $sit_idx = $this->delete('sit_idx', TRUE);
  146. if(empty($sit_idx)) $this->response(array('message'=>'잘못된 접근입니다.'), 400);
  147. $this->db->where('sit_idx', $sit_idx)->delete('sitemap');
  148. }
  149. // Q&A 분류 삭제
  150. function qna_category_delete()
  151. {
  152. $qnc_idx = $this->delete('qnc_idx', TRUE);
  153. if(empty($qnc_idx)) $this->response(array('message'=>'잘못된 접근입니다.'), 400);
  154. $data['upd_user'] = $this->member->is_login();
  155. $data['upd_datetime'] = date('Y-m-d H:i:s');
  156. $data['qnc_status'] = 'N';
  157. $this->db->where('qnc_idx', $qnc_idx)->update('qna_category', $data);
  158. }
  159. function qna_delete()
  160. {
  161. $qna_idx= $this->delete('qna_idx', TRUE);
  162. if(empty($qna_idx)) $this->response(array('message'=>'잘못된 접근입니다.'), 400);
  163. $data['upd_user'] = $this->member->is_login();
  164. $data['upd_datetime'] = date('Y-m-d H:i:s');
  165. $data['qna_status'] = 'N';
  166. $this->db->where('qna_idx', $qna_idx)->update('qna', $data);
  167. }
  168. function qna_get()
  169. {
  170. $startdate = $this->get('startdate', TRUE);
  171. $enddate = $this->get('enddate', TRUE);
  172. $qna_ans_status = $this->get('qna_ans_status', TRUE);
  173. $st = $this->get('st', TRUE);
  174. $sc = $this->get('sc', TRUE);
  175. $page_rows = $this->get('take', TRUE);
  176. $start = $this->get('skip', TRUE);
  177. if(! empty($page_rows)) $this->db->limit($page_rows, $start);
  178. if(! empty($startdate)) $this->db->where('reg_datetime >=', $startdate.' 00:00:00');
  179. if(! empty($enddate)) $this->db->where('reg_datetime <=', $enddate.' 23:59:59');
  180. if(! empty($qna_ans_status)) $this->db->where('qna_ans_status', $qna_ans_status);
  181. if(! empty($st) && ! empty($sc)) $this->db->like($sc, $st);
  182. $this->db->select("SQL_CALC_FOUND_ROWS Q.*, QC.qnc_title, M.mem_nickname AS qna_ans_upd_username",FALSE);
  183. $this->db->order_by('qna_idx DESC');
  184. $this->db->from('qna AS Q');
  185. $this->db->join('qna_category AS QC','QC.qnc_idx=Q.qnc_idx','left');
  186. $this->db->join('member AS M','M.mem_idx=Q.qna_ans_user','left');
  187. $this->db->where('qna_status','Y');
  188. $result = $this->db->get();
  189. $return['lists'] = $result->result_array();
  190. $return['totalCount'] = (int)$this->db->query("SELECT FOUND_ROWS() AS cnt")->row(0)->cnt;
  191. foreach($return['lists'] as $i=>&$row)
  192. {
  193. $row['nums'] = $return['totalCount'] - $i - $start;
  194. }
  195. $this->response($return, 200);
  196. }
  197. /**
  198. * 공용 에디트
  199. */
  200. function updates_post()
  201. {
  202. $table = $this->post('table', TRUE);
  203. $key_column = $this->post('key_column', TRUE);
  204. $key = $this->post('key', TRUE);
  205. $values = $this->post('values', TRUE);
  206. if(empty($table) OR empty($key_column) OR empty($key)) $this->response(array('message'=>'잘못된 접근입니다.'), 400);
  207. $values['upd_datetime'] = date('Y-m-d H:i:s');
  208. $values['upd_user'] = $this->member->is_login();
  209. $this->db->where($key_column, $key);
  210. $this->db->update($table, $values);
  211. }
  212. }