<commit_before><?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of giftcard_manage
 *
 * @author pbchen
 */
class giftcard_manage extends CI_Controller {
    
    function __construct() {
        parent::__construct();
        $this->load->model('user_model');
        $this->load->model('giftcard_model');
        $this->load->model('customer_model');
        $this->load->model('wechat_model');
        $this->load->model('giftbook_model');
        $this->load->library('Data_table_parser');
        $this->data_table_parser->set_db($this->db);
        $this->load->library('uc_service', array('cfg' => $this->config->item('alw_uc')));
    }
    
    /**
     * 礼品卡下单
     */
    public function giftcard_order() {
        if ($_POST) {
            $data = $this->giftcard_model->get_giftcard_order_params();
            if ($insert_id = $this->giftcard_model->add_giftcard_order($data)) {
                json_out_put(return_model(0, '添加成功', $insert_id));
            } else {
                json_out_put(return_model('3001', '添加失败', NULL));
            }
        } else {
            $d = array('title' => '礼品卡管理', 'msg' => '', 'no_load_bootstrap_plugins' => true);
            $d['sales'] = $this->user_model->get_user();
            $d['customer'] = $this->customer_model->get_customer();
            $d['wechat'] = $this->wechat_model->get_wechat();
            $d['giftbook'] = $this->giftbook_model->get_giftbook_info();
            $this->layout->view('giftcard_manage/giftcard_order', $d);
        }
    }
    
    /**
     * 礼品卡编辑
     */
    public function edit_giftcard_order(){
        $id = $this->input->post('id');
        $d['sales_id'] = $this->input->post('sales');
        $d['custom_id'] = $this->input->post('customer');
        $d['end_user'] = $this->input->post('enduser');
        $d['wechat_id'] = $this->input->post('wechat');
        $d['remark'] = $this->input->post('remark');
        $affect_row = $this->giftcard_model->update_giftcard_order_info($d,array('id'=>$id));
        if (is_numeric($affect_row)) {
            json_out_put(return_model(0, '更新成功', $affect_row));
        } else {
            json_out_put(return_model('3001', '更新失败', NULL));
        }
    }
    
    /**
     * 加载编辑视图
     */
    public function edit_giftcard(){
        $id = $this->input->get('id');
        $d = array('title' => '编辑礼册', 'msg' => '', 'no_load_bootstrap_plugins' => true);
        $giftcard = $this->giftcard_model->get_giftcard_info(array('id'=>$id));
        $d['giftcard'] = $giftcard[0];
        $this->layout->view('giftcard_manage/edit_giftcard', $d);
    }
    
    /**
     * 礼册列表
     */
    public function giftcard_order_list() {
        $d = array('title' => '礼品卡管理', 'msg' => '');
        $d['sales'] = $this->user_model->get_user();
        $d['customer'] = $this->customer_model->get_customer();
        $d['wechat'] = $this->wechat_model->get_wechat();
        $this->layout->view('giftcard_manage/giftcard_order_list', $d);
    }
    
    /**
     * 礼册列表分页
     */
    public function giftcard_order_list_page() {
        $d = $this->giftcard_model->giftcard_order_list_page_data($this->data_table_parser);
        $this->load->view('json/datatable', $d);
    }
    
    /**
     * 修改开卡付款状态
     */
    public function update_paystatus(){
        $ids = $this->input->post('ids');
        $d['pay_status'] = $this->input->post('paystatus');
        $d['pay_remark'] = $this->input->post('pay_remark');
        $affect_row = $this->giftcard_model->update_giftcard_order_info($d,array(),array('id'=>$ids));
        if (is_numeric($affect_row)) {
            json_out_put(return_model(0, '更新成功', $affect_row));
        } else {
            json_out_put(return_model('3001', '更新失败', NULL));<commit_msg>print<commit_after><?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of giftcard_manage
 *
 * @author pbchen
 */
class giftcard_manage extends CI_Controller {
    
    function __construct() {
        parent::__construct();
        $this->load->model('user_model');
        $this->load->model('giftcard_model');
        $this->load->model('customer_model');
        $this->load->model('wechat_model');
        $this->load->model('giftbook_model');
        $this->load->library('Data_table_parser');
        $this->data_table_parser->set_db($this->db);
        $this->load->library('uc_service', array('cfg' => $this->config->item('alw_uc')));
    }
    
    /**
     * 礼品卡下单
     */
    public function giftcard_order() {
        if ($_POST) {
            $data = $this->giftcard_model->get_giftcard_order_params();
            if ($insert_id = $this->giftcard_model->add_giftcard_order($data)) {
                json_out_put(return_model(0, '添加成功', $insert_id));
            } else {
                json_out_put(return_model('3001', '添加失败', NULL));
            }
        } else {
            $d = array('title' => '礼品卡管理', 'msg' => '', 'no_load_bootstrap_plugins' => true);
            $d['sales'] = $this->user_model->get_user();
            $d['customer'] = $this->customer_model->get_customer();
            $d['wechat'] = $this->wechat_model->get_wechat();
            $d['giftbook'] = $this->giftbook_model->get_giftbook_info();
            $this->layout->view('giftcard_manage/giftcard_order', $d);
        }
    }
    
    /**
     * 礼品卡编辑
     */
    public function edit_giftcard_order(){
        $id = $this->input->post('id');
        $d['sales_id'] = $this->input->post('sales');
        $d['custom_id'] = $this->input->post('customer');
        $d['end_user'] = $this->input->post('enduser');
        $d['wechat_id'] = $this->input->post('wechat');
        $d['remark'] = $this->input->post('remark');
        $affect_row = $this->giftcard_model->update_giftcard_order_info($d,array('id'=>$id));
        if (is_numeric($affect_row)) {
            json_out_put(return_model(0, '更新成功', $affect_row));
        } else {
            json_out_put(return_model('3001', '更新失败', NULL));
        }
    }
    
    /**
     * 加载编辑视图
     */
    public function edit_giftcard(){
        $id = $this->input->get('id');
        $d = array('title' => '编辑礼册', 'msg' => '', 'no_load_bootstrap_plugins' => true);
        $giftcard = $this->giftcard_model->get_giftcard_info(array('id'=>$id));
        $d['giftcard'] = $giftcard[0];
        $this->layout->view('giftcard_manage/edit_giftcard', $d);
    }
    
    /**
     * 礼册列表
     */
    public function giftcard_order_list() {
        $d = array('title' => '礼品卡管理', 'msg' => '');
        $d['sales'] = $this->user_model->get_user();
        $d['customer'] = $this->customer_model->get_customer();
        $d['wechat'] = $this->wechat_model->get_wechat();
        $this->layout->view('giftcard_manage/giftcard_order_list', $d);
    }
    
    /**
     * 礼册列表分页
     */
    public function giftcard_order_list_page() {
        $d = $this->giftcard_model->giftcard_order_list_page_data($this->data_table_parser);
        $this->load->view('json/datatable', $d);
    }
    
    /**
     * 打印销售单
     */
    public function print_sales_order(){
        $id = $this->input->get('id');
        $order = $this->giftcard_model->sales_order_info(array('card_order.id'=>$id));
        $d['order'] = $order[0];
        $d['book'] = $this->giftcard_model->get_order_book(array('order_id'=>$id));
        $this->load->view('giftcard_manage/sales_order', $d);
    }
    
    /**
     * 修改开卡付款状态
     */
    public function update_paystatus(){
        $ids = $this->input->post('ids');
        $d['pay_status'] = $this->input->post('paystatus');
        $d['pay_remark'] = $this->input->post('pay_remark');
        $affect_row = $this->giftcard_model->update_giftcard_order_info($d,array(),array('id'=>$ids));
        if (is_numeric($affect_row)) {
            json_out_put(return_model(0, '更新成功', $affect_row));
        } else {
            json_out_put(return_model('3001', '更新失败', NULL));
{'fraction_non_alphanumeric': 0.19277696437286482, 'fraction_numerical': 0.004026354319180088, 'mean_word_length': 2.675784753363229, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 185, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1679565', 'n_tokens_mistral': 2889, 'n_tokens_neox': 2935, 'n_words': 361}