12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- /**
- * 红包管理
- *
- *
- *
- ***/
- defined('InShopNC') or exit('Access Invalid!');
- class bonusControl extends SystemControl{
- public function __construct(){
- parent::__construct();
- }
- public function bonus_typeOp(){
- $bonus_type = Model('bonus_type');
- $bonus_list = $bonus_type->getAll();
- Tpl::output('bonus_list', $bonus_list) ;
- $this->show_menu('bonus','bonus_type_list');
- Tpl::showpage('bonus.bonus_type_list');
- }
- public function bonus_type_addOp() {
- $this->show_menu('bonus','bonus_type_add');
- $this->bonus_form();
- }
- public function bonus_type_editOp() {
- $id = $_GET['id'];
- $this->show_menu('type','bonus_type_edit');
- $this->bonus_form($id);
- }
- public function bonus_type_saveOp() {
- $type_id = $_POST['type_id'] ? $_POST['type_id'] : 0;
- $bonus_value = array(
- 'type_name' => $_POST['type_name'],
- 'send_type' => $_POST['send_type'],
- 'send_start_date' => strtotime(trim($_POST['send_start_date'])),
- 'send_end_date' => strtotime(trim($_POST['send_end_date'])),
- 'use_start_date' => strtotime(trim($_POST['use_start_date'])),
- 'use_end_date' => strtotime(trim($_POST['use_end_date']))
- );
- $bonus_type = Model('bonus_type');
- $bonus_type->save($bonus_value, $type_id);
- if(intval($_POST['send_type']) === 1){
- $bonus_file = $_FILES['bonus_file'];
- if($bonus_file && !empty($bonus_file['name'])){
- if ($bonus_file['tmp_name'] == ""){
- $this->setError('上传失败,请联系服务器管理员。');
- return false;
- }
- $bonus_file_content = file_get_contents($bonus_file['tmp_name']);
- $bonus = Model('user_bonus');
- $bonus->loadFile($bonus_file_content);
- }
- }
- $this->bonus_typeOp();
- }
- private function bonus_form($id = 0){
- Tpl::output('id', $id);
- if($id > 0){
- $bonus_type = Model('bonus_type');
- $bonus_type_data = $bonus_type->get($id);
- Tpl::output('data', $bonus_type_data[0]);
- }
- Tpl::showpage('bonus.bonus_type_form');
- }
- private function show_menu($menu_type,$menu_key=''){
- $menu_array = array();
- switch ($menu_type) {
- case 'bonus':
- $menu_array = array(
- 1=>array('menu_key'=>'bonus_type_list','menu_name'=>'红包类型列表', 'menu_url'=>'index.php?act=bonus&op=bonus_type'),
- 2=>array('menu_key'=>'bonus_type_add','menu_name'=>'添加红包类型', 'menu_url'=>'index.php?act=bonus&op=bonus_type_add'),
- );
- break;
- case 'type':
- $menu_array = array(
- 1=>array('menu_key'=>'bonus_type_edit','menu_name'=>'编辑红包类型', 'menu_url'=>'index.php?act=bonus&op=bonus_type_edit')
- );
- break;
- }
- Tpl::output('menu',$menu_array);
- Tpl::output('menu_key',$menu_key);
- }
- }
|