Files
cm-web-legacy/application/models/admin/cs/m_bbs_notice.php
2020-06-10 06:19:03 +09:00

301 lines
10 KiB
PHP
Executable File

<?
defined('BASEPATH') OR exit('No direct script access allowed');
class m_bbs_notice extends CI_Model{
// 생성자, 해당 모델이 생성될때 항상 실행되는 초기화작업
function __construct(){
parent::__construct();
$this->load->database();
$this->load->library('session');
}
#---------------------------------------------------------------------------
# PURPOSE : 공지 - list
# CREATE : 2018-02-27
#---------------------------------------------------------------------------
function bbs_notice_list($req_data){
# request
$offset = $req_data['offset'];
$limit = $req_data['limit'];
$search_type = $req_data['search_type'];
$search_keyword = $req_data['search_keyword'];
if(isset($req_data['search_click'])==true) $search_click = $req_data['search_click'];
if($search_click=='1') {
$today_date = date("Y-m-d").' 00:00:00';
$this->db->where('reg_date >=', $today_date);
}
if($search_type!='' && $search_keyword!=''){
$this->db->like($search_type, $search_keyword);
}
$this->db->where('is_del', 'N');
$this->db->from('bbs_notice');
$this->db->order_by('idx desc');
$this->db->limit($limit, $offset);
$res = $this->db->get();
$row = $res->result_array();
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 공지 - list - total count
# CREATE : 2018-02-27
#---------------------------------------------------------------------------
function bbs_notice_list_total_count($req_data){
# request
$search_type = $req_data['search_type'];
$search_keyword = $req_data['search_keyword'];
if(isset($req_data['search_click'])==true) $search_click = $req_data['search_click'];
if($search_click=='1') {
$today_date = date("Y-m-d").' 00:00:00';
$this->db->where('reg_date >=', $today_date);
}
if($search_type!='' && $search_keyword!=''){
$this->db->like($search_type, $search_keyword);
}
$this->db->where('is_del', 'N');
$this->db->from('bbs_notice');
$row = $this->db->count_all_results();
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 1:1문의 - select
# CREATE : 2018-02-27
#---------------------------------------------------------------------------
function bbs_question_select($req_data){
# request
$idx = $req_data;
$this->db->where('idx', $idx);
$this->db->where('is_del', 'N');
$this->db->from('bbs_question');
$res = $this->db->get();
$row = $res->result_array();
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 1:1문의 reply - insert
# CREATE : 2018-02-27
#---------------------------------------------------------------------------
function bbs_question_reply_insert($req_data){
# request
$idx = $req_data['p_idx'];
$user_id = $this->session->userdata('Adm_Id');
$user_name = $this->session->userdata('Adm_Name');
$now_date = date("Y-m-d H:i:s");
$this->db->select('max(s_idx) + 1 as s_idx');
$this->db->where('p_idx', $idx);
$this->db->from('bbs_question');
$res1 = $this->db->get();
$row1 = $res1->result_array();
$s_idx = $row1[0]['s_idx'];
$req_data['write_id'] = $user_id;
$req_data['write_name'] = $user_name;
$req_data['reg_date'] = $now_date;
$req_data['update_id'] = $user_id;
$req_data['update_date']= $now_date;
$req_data['s_idx'] = $s_idx;
$req_data['is_reply'] = 'Y';
$row = $this->db->insert('bbs_question', $req_data);
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 1:1문의 is_reply - update
# CREATE : 2018-02-27
#---------------------------------------------------------------------------
function bbs_question_is_reply_update($req_data){
# request
$idx = $req_data;
$user_id = $this->session->userdata('Adm_Id');
$now_date = date("Y-m-d H:i:s");
$update_data = array('is_reply' => 'Y',
'update_id' => $user_id,
'update_date' => $now_date
);
$this->db->where('idx', $idx);
$row = $this->db->update('bbs_question', $update_data);
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 1:1문의 is_del update
# CREATE : 2018-02-27
#---------------------------------------------------------------------------
function bbs_question_is_del_update($req_data){
$user_id = $this->session->userdata('Adm_Id');
$now_date = date("Y-m-d H:i:s");
$arr_update_data = array();
foreach($req_data as $key=>$val) {
$arr_update_data[$key]['idx'] = $val;
$arr_update_data[$key]['is_del'] = 'Y';
$arr_update_data[$key]['update_id'] = $user_id;
$arr_update_data[$key]['update_date'] = $now_date;
}
$this->db->update_batch('bbs_question', $arr_update_data, 'idx');
}
#---------------------------------------------------------------------------
# PURPOSE : 1:1문의 신규 count
# CREATE : 2018-02-27
#---------------------------------------------------------------------------
function bbs_question_new_count(){
$now_date = date("Y-m-d").' 00:00:00';
$this->db->where('reg_date >=', $now_date);
$this->db->where('is_del', 'N');
$this->db->where('s_idx', '1');
$this->db->from('bbs_question');
$row = $this->db->count_all_results();
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 1:1문의 처리상태 count
# CREATE : 2018-02-27
#---------------------------------------------------------------------------
function bbs_question_group_by_is_reply(){
$this->db->select('is_reply, count(is_reply) as cnt');
$this->db->where('is_del', 'N');
$this->db->where('s_idx', '1');
$this->db->group_by("is_reply");
$this->db->from('bbs_question');
$res = $this->db->get();
$row = $res->result_array();
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 공지 - insert
# CREATE : 2018-02-27
#---------------------------------------------------------------------------
function bbs_notice_insert($req_data){
$user_id = $this->session->userdata('Adm_Id');
$user_name = $this->session->userdata('Adm_Name');
$now_date = date("Y-m-d H:i:s");
$req_data['write_id'] = $user_id;
$req_data['write_name'] = $user_name;
$req_data['reg_date'] = $now_date;
$req_data['update_id'] = $user_id;
$req_data['update_date']= $now_date;
$row = $this->db->insert('bbs_notice', $req_data);
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 공지 - select
# CREATE : 2018-02-27
#---------------------------------------------------------------------------
function bbs_notice_select($req_data){
# request
$idx = $req_data;
$this->db->where('idx', $idx);
$this->db->where('is_del', 'N');
$this->db->from('bbs_notice');
$res = $this->db->get();
$row = $res->result_array();
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 공지 - update
# CREATE : 2018-02-27
#---------------------------------------------------------------------------
function bbs_notice_update($req_data){
# request
$idx = $req_data['idx'];
unset($req_data['idx']);
$user_id = $this->session->userdata('Adm_Id');
$now_date = date("Y-m-d H:i:s");
$req_data['update_id'] = $user_id;
$req_data['update_date'] = $now_date;
$this->db->where('idx', $idx);
$row = $this->db->update('bbs_notice', $req_data);
return $row;
}
#---------------------------------------------------------------------------
# PURPOSE : 공지 is_del update
# CREATE : 2018-02-27
#---------------------------------------------------------------------------
function bbs_notice_is_del_update($req_data){
$user_id = $this->session->userdata('Adm_Id');
$now_date = date("Y-m-d H:i:s");
$arr_update_data = array();
foreach($req_data as $key=>$val) {
$arr_update_data[$key]['idx'] = $val;
$arr_update_data[$key]['is_del'] = 'Y';
$arr_update_data[$key]['update_id'] = $user_id;
$arr_update_data[$key]['update_date'] = $now_date;
}
$this->db->update_batch('bbs_notice', $arr_update_data, 'idx');
}
#---------------------------------------------------------------------------
# PURPOSE : 신규 count
# CREATE : 2018-06-11
#---------------------------------------------------------------------------
function bbs_notice_new_count(){
$now_date = date("Y-m-d").' 00:00:00';
$this->db->where('reg_date >=', $now_date);
$this->db->where('is_del', 'N');
$this->db->from('bbs_notice');
$row = $this->db->count_all_results();
return $row;
}
}
?>