<?php
/**
 * 클래스 설명
 *
 * @date : {작성일}
 * @version : 1.0
 * @author : {작성자}
 * @history :
 * - 파일생성 2017-12-11 by hclee@yellotravel.com
 */
defined('BASEPATH') OR exit('No direct script access allowed'); // 생성하는 모든 php파일에 삽입되어야 함
class ClassName extends CI_Controller {
    
/**
     * 생성자
     */
    
public function __construct() {
        
parent::__construct();    // 부모 생성자 호출

        //해당 class의 공통파트. 
        
$this->template->define('파일아이디''_part/파일명.html') ; // 각각 템플릿 파일에 {#파일이이디} 필요한 위치에 넣어준다.
    
}

    
/**
     * 해당 콘트롤러의 메인페이지 url => {BASEURL}/classname/
     */
    
public function index(){
        
//$this->load->library('라이브러리');    // 라이브러리 호출할때. /sm/application/libraries/{라이브러리}.php
        //$this->load->model('DB모델');    // 모델 호출할때. /sm/application/models/{DB모델}.php
        //$this->load->helper('사용자함수');    // 사용자함수 호출할때. /sm/application/helpers/{사용자함수}_helper.php
        //$this->load->config('설정파일');    // 설정파일 호출할때. application/config/{설정파일}.php


        
$this->template->set_title('타이틀 변경시');    // 없으면 config/menus.php에 설정된 메뉴설정에 의해 자동 세팅
        
$this->template->set_desc('페이지 설명 변경시');    // 없으면 config/menus.php에 설정된 메뉴설정에 의해 자동 세팅

        /**
         * 해당 페이지에서만 추가할 스크립트
         */
        
$this->template->set_head_script('<meta ...>');    // 추가 meta 태그 적용
        
$this->template->set_head_script('<link rel="stylesheet" href="...">');    // 추가 css 적용
        
$this->template->set_head_script('<script src="..."></script>');    // 추가 js파일 적용
        
$this->template->set_head_script('<script>alert("test");</script>');    // 추가 js 적용

        // 템플릿 변수 정의
        
$this->template->assign(array(
            
'변수명' => '$변수값',
        ));

        
// 템플릿 페이지 지정 /views/_page 하위
        //$this->template->set('classname/index.html'); // 없으면 /views/_page/{directory}/{class}/{method} 에 저장된 페이지 호출
        
        // 페이지 출력
        
$this->template->print_frame();
    }

    
/**
     * 해당 콘트롤러의 서브페이지1 url => {BASEURL}/classname/sub1
     */
    
public function sub1(){

        
// 템플릿 변수 정의
        
$this->template->assign(array(
            
'변수명' => '$변수값',
        ));

        
// 페이지 출력
        
$this->template->print_frame();
    }

    
/**
     * 해당 콘트롤러의 서브페이지1 실행 url => {BASEURL}/classname/sub1_run
     */
    
public function sub1_run(){
        
$ret 'process .......';
        if(
$ret){
            
//다음 페이지 이동 또는 성공처리 완료 알림
            
wg_alert('완료 되었습니다.');// 알림창
            
wg_gotoUrl('성공페이지');    // 페이지 이동
        
} else {

            
// 알림창 띄운 후 백처리 또는 에러페이지 호출
            
if(알림창일 경우){
                
wg_errorBack('처리 실패!'); // 오류 알림 후 뒤로 이동
            // 에러페이지 호출
            
} else if(에러페이지일 경우){
                
$this->template->error('오류');// => 오류처리 하는 샘플 확인 
            
}
        }
    }

    
/**
     * 프레임 변경시
     */
    
public function frame_change(){
        
$this->template->set_frame('blank');    // blank 프레임 세팅

        // 페이지 출력
        
$this->template->print_frame();
    }
}