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.

141 lines
4.3 KiB

  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. /**
  4. * Class Order
  5. * ------------------------------------------------------------------------------
  6. * 주문페이지
  7. */
  8. class Order extends WB_Controller {
  9. public function index()
  10. {
  11. $this->db->select('*');
  12. $this->db->from('order');
  13. $this->db->where('active','Y');
  14. $this->db->order_by('idx DESC');
  15. $result = $this->db->get()->result_array();
  16. $this->data['list'] = $result;
  17. // 레이아웃 & 뷰파일 설정
  18. $this->theme = $this->site->get_layout();
  19. $this->view = "/order/index";
  20. $this->active = "/order/index";
  21. }
  22. public function view($value) {
  23. $this->db->select('*');
  24. $this->db->from('order');
  25. $this->db->where('idx',$value);
  26. $this->db->where('active','Y');
  27. $this->db->order_by('idx DESC');
  28. $result = $this->db->get()->row_array();
  29. $this->data['list'] = $result;
  30. if(! $result) {
  31. alert("11 페이지 입니다");
  32. exit;
  33. }
  34. // 레이아웃 & 뷰파일 설정
  35. $this->theme = $this->site->get_layout();
  36. $this->view = "/order/view";
  37. $this->active = "/order/view";
  38. }
  39. public function form($value = "")
  40. { //코드이그나이트에 들어있는것
  41. $this->load->library('form_validation');
  42. // 필수 입력되어야 하는 필드 설정 //input name명
  43. $this->form_validation->set_rules('hu_name', '주문자이름', 'required|min_length[3]');
  44. $this->form_validation->set_rules('ord_name', '상품명', 'required');
  45. $this->form_validation->set_rules('pay', '가격', 'required');
  46. $this->form_validation->set_rules('ord_num', '주문번호', 'required');
  47. $this->form_validation->set_rules('ord_count', '개수', 'required|numeric');
  48. $this->form_validation->set_rules('pos_money', '택배비', 'required');
  49. if($this->form_validation->run() != FALSE )
  50. {
  51. //DB실제컬럼명 <-값을 넣어줌 //input name명
  52. $od['order_hu_name'] = $this->input->post('hu_name', TRUE);
  53. $od['order_name'] = $this->input->post('ord_name', TRUE);
  54. $od['payment'] = $this->input->post('pay', TRUE);
  55. $od['order_num'] = $this->input->post('ord_num', TRUE);
  56. $od['count'] = $this->input->post('ord_count', TRUE);
  57. $od['post_num'] = $this->input->post('pos_num', TRUE);
  58. $od['post_money'] = $this->input->post('pos_money', TRUE);
  59. $od['point'] = $this->input->post('point', TRUE);
  60. if( ! $od['order_hu_name']) alert('주문자 이름은 필수입력입니다.');
  61. if(empty($value)) {
  62. $od['time'] = date('Y-m-d H:i:s');
  63. $this->db->insert('order', $od);
  64. }
  65. else {
  66. $this->db->where('idx', $value);
  67. $this->db->update('order', $od);
  68. }
  69. alert('등록되었습니다.', base_url('order/index'));
  70. }
  71. else
  72. {
  73. $this->data['view'] = array();
  74. // $value 가 비어있지 않을경우만 실행
  75. if( ! empty($value) )
  76. {
  77. $this->db->select('*');
  78. $this->db->from('order');
  79. $this->db->where('idx',$value);
  80. $this->db->where('active','Y');
  81. $this->db->order_by('idx DESC');
  82. $result = $this->db->get()->row_array();
  83. $this->data['view'] = $result;
  84. if(! $this->data['view'])
  85. {
  86. alert("35 페이지 입니다");
  87. exit;
  88. }
  89. }
  90. // 레이아웃 & 뷰파일 설정
  91. $this->theme = $this->site->get_layout();
  92. $this->view = "/order/form";
  93. $this->active = "/order/form";
  94. }
  95. }
  96. public function remove($value)
  97. {
  98. $data['active'] = 'N';
  99. $this->db->where('idx', $value);
  100. //$this->db->set('active','N');
  101. if( $this->db->update('order',$data)) {
  102. alert('삭제되았습니다..', base_url('order/index'));
  103. }
  104. else {
  105. alert('삭제에 실패했스비다..', base_url('order/index'));
  106. }
  107. }
  108. }