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.
		
		
		
		
		
			
		
			
				
					
					
						
							142 lines
						
					
					
						
							4.3 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							142 lines
						
					
					
						
							4.3 KiB
						
					
					
				
								<?php
							 | 
						|
								defined('BASEPATH') OR exit('No direct script access allowed');
							 | 
						|
								/**
							 | 
						|
								 * Class Order
							 | 
						|
								 * ------------------------------------------------------------------------------
							 | 
						|
								 * 주문페이지
							 | 
						|
								 */
							 | 
						|
								class Order extends WB_Controller {
							 | 
						|
								
							 | 
						|
								
							 | 
						|
								    public function index()
							 | 
						|
								    {
							 | 
						|
								        $this->db->select('*');
							 | 
						|
								        $this->db->from('order');
							 | 
						|
								        $this->db->where('active','Y');
							 | 
						|
								        $this->db->order_by('idx DESC');
							 | 
						|
								        $result = $this->db->get()->result_array();
							 | 
						|
								
							 | 
						|
								        $this->data['list'] = $result;
							 | 
						|
								        // 레이아웃 & 뷰파일 설정
							 | 
						|
								        $this->theme    = $this->site->get_layout();
							 | 
						|
								        $this->view     = "/order/index";
							 | 
						|
								        $this->active   = "/order/index";
							 | 
						|
								
							 | 
						|
								
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    public function view($value) {
							 | 
						|
								        $this->db->select('*');
							 | 
						|
								        $this->db->from('order');
							 | 
						|
								        $this->db->where('idx',$value);
							 | 
						|
								        $this->db->where('active','Y');
							 | 
						|
								        $this->db->order_by('idx DESC');
							 | 
						|
								        $result = $this->db->get()->row_array();
							 | 
						|
								
							 | 
						|
								        $this->data['list'] = $result;
							 | 
						|
								
							 | 
						|
								        if(! $result) {
							 | 
						|
								            alert("없는 페이지 입니다");
							 | 
						|
								            exit;
							 | 
						|
								        }
							 | 
						|
								        // 레이아웃 & 뷰파일 설정
							 | 
						|
								        $this->theme    = $this->site->get_layout();
							 | 
						|
								        $this->view     = "/order/view";
							 | 
						|
								        $this->active   = "/order/view";
							 | 
						|
								
							 | 
						|
								
							 | 
						|
								    }
							 | 
						|
								    public function form($value = "")
							 | 
						|
								    {    //코드이그나이트에 들어있는것
							 | 
						|
								        $this->load->library('form_validation');
							 | 
						|
								
							 | 
						|
								        // 필수 입력되어야 하는 필드 설정      //input name명
							 | 
						|
								        $this->form_validation->set_rules('hu_name', '주문자이름', 'required|min_length[3]');
							 | 
						|
								        $this->form_validation->set_rules('ord_name', '상품명', 'required');
							 | 
						|
								        $this->form_validation->set_rules('pay', '가격', 'required');
							 | 
						|
								        $this->form_validation->set_rules('ord_num', '주문번호', 'required');
							 | 
						|
								        $this->form_validation->set_rules('ord_count', '개수', 'required|numeric');
							 | 
						|
								        $this->form_validation->set_rules('pos_money', '택배비', 'required');
							 | 
						|
								
							 | 
						|
								
							 | 
						|
								        if($this->form_validation->run() != FALSE )
							 | 
						|
								        {
							 | 
						|
								                //DB실제컬럼명      <-값을 넣어줌   //input name명
							 | 
						|
								            $od['order_hu_name'] = $this->input->post('hu_name', TRUE);
							 | 
						|
								            $od['order_name'] = $this->input->post('ord_name', TRUE);
							 | 
						|
								            $od['payment'] = $this->input->post('pay', TRUE);
							 | 
						|
								            $od['order_num'] = $this->input->post('ord_num', TRUE);
							 | 
						|
								            $od['count'] = $this->input->post('ord_count', TRUE);
							 | 
						|
								            $od['post_num'] = $this->input->post('pos_num', TRUE);
							 | 
						|
								            $od['post_money'] = $this->input->post('pos_money', TRUE);
							 | 
						|
								            $od['point'] = $this->input->post('point', TRUE);
							 | 
						|
								
							 | 
						|
								            if( ! $od['order_hu_name']) alert('주문자 이름은 필수입력입니다.');
							 | 
						|
								
							 | 
						|
								            if(empty($value)) {
							 | 
						|
								                $od['time'] = date('Y-m-d H:i:s');
							 | 
						|
								
							 | 
						|
								                $this->db->insert('order', $od);
							 | 
						|
								            }
							 | 
						|
								            else {
							 | 
						|
								
							 | 
						|
								                $this->db->where('idx', $value);
							 | 
						|
								                $this->db->update('order', $od);
							 | 
						|
								            }
							 | 
						|
								
							 | 
						|
								            alert('등록되었습니다.', base_url('order/index'));
							 | 
						|
								
							 | 
						|
								        }
							 | 
						|
								        else
							 | 
						|
								        {
							 | 
						|
								            $this->data['view'] = array();
							 | 
						|
								
							 | 
						|
								            // $value 가 비어있지 않을경우만 실행
							 | 
						|
								            if( ! empty($value) )
							 | 
						|
								            {
							 | 
						|
								                $this->db->select('*');
							 | 
						|
								                $this->db->from('order');
							 | 
						|
								                $this->db->where('idx',$value);
							 | 
						|
								                $this->db->where('active','Y');
							 | 
						|
								                $this->db->order_by('idx DESC');
							 | 
						|
								                $result = $this->db->get()->row_array();
							 | 
						|
								
							 | 
						|
								                $this->data['view'] = $result;
							 | 
						|
								
							 | 
						|
								                if(! $this->data['view'])
							 | 
						|
								                {
							 | 
						|
								
							 | 
						|
								                    alert("없는 페이지 입니다");
							 | 
						|
								                    exit;
							 | 
						|
								                }
							 | 
						|
								            }
							 | 
						|
								
							 | 
						|
								            // 레이아웃 & 뷰파일 설정
							 | 
						|
								            $this->theme    = $this->site->get_layout();
							 | 
						|
								            $this->view     = "/order/form";
							 | 
						|
								            $this->active   = "/order/form";
							 | 
						|
								
							 | 
						|
								        }
							 | 
						|
								
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    public function remove($value)
							 | 
						|
								    {
							 | 
						|
								
							 | 
						|
								        $data['active'] = 'N';
							 | 
						|
								        $this->db->where('idx', $value);
							 | 
						|
								        //$this->db->set('active','N');
							 | 
						|
								        if( $this->db->update('order',$data)) {
							 | 
						|
								            alert('삭제되았습니다..', base_url('order/index'));
							 | 
						|
								
							 | 
						|
								        }
							 | 
						|
								        else {
							 | 
						|
								            alert('삭제에 실패했스비다..', base_url('order/index'));
							 | 
						|
								
							 | 
						|
								        }
							 | 
						|
								
							 | 
						|
								
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								
							 | 
						|
								}
							 |