Files
cm-ggotmaeule-backend/application/controllers/admin/reserve/Reserve.php

142 lines
3.5 KiB
PHP

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Reserve class
*/
class Reserve extends MY_Controller
{
/**
* 관리자 페이지 상의 현재 디렉토리입니다
* 페이지 이동시 필요한 정보입니다
*/
public $pagedir = 'reserve/reserve';
/**
* 모델을 로딩합니다
*/
protected $models = array('Contents_category', 'Apps');
/**
* 이 컨트롤러의 메인 모델 이름입니다
*/
protected $modelname = 'Contents_category_model';
/**
* 헬퍼를 로딩합니다
*/
protected $helpers = array('form', 'array');
function __construct()
{
parent::__construct();
/**
* 라이브러리를 로딩합니다
*/
$this->load->library(array('pagination', 'querystring'));
}
/**
* 목록을 가져오는 메소드입니다
*/
public function index()
{
$view = array();
$view['view'] = array();
/**
* 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
*/
$param =& $this->querystring;
$app_id = $this->input->get('app_id');
if ($app_id) {
$where = array(
'cat_parent' => '0',
'app_id' => $app_id,
);
$result = $this->{$this->modelname}->get('', '', $where, '', '', 'cat_sort', 'desc');
$view['view']['data'] = $result;
}
$view['view']['applist'] = $this->Apps_model->app_list();
/**
* primary key 정보를 저장합니다
*/
$view['view']['primary_key'] = $this->{$this->modelname}->primary_key;
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'index');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
/**
* 게시판 글쓰기 또는 수정 페이지를 가져오는 메소드입니다
*/
public function write($app_id = 0)
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
/**
* 프라이머리키에 숫자형이 입력되지 않으면 에러처리합니다
*/
$primary_key = $this->{$this->modelname}->primary_key;
if (! $this->input->post('is_submit')) {
alert('잘못된 접근입니다');
}
$cat_time = $this->input->post('cat_publish_time');
if ($cat_time) {
foreach ($cat_time as $key => $value) {
if ($value) {
$updatedata = array(
'cat_publish_time' => $value,
);
} else {
$updatedata = array(
'cat_publish_time' => null,
);
}
$upwhere = array(
'cat_id' => $key,
);
$this->{$this->modelname}->update('', $updatedata, $upwhere);
}
}
$this->session->set_flashdata('message','정상적으로 수정되었습니다');
/**
* 게시물의 신규입력 또는 수정작업이 끝난 후 목록 페이지로 이동합니다
*/
$param =& $this->querystring;
$redirecturl = admin_url($this->pagedir . '?app_id=' . $this->input->post('app_id'));
redirect($redirecturl);
}
}