chengkun
2025-04-30 6ab292fb7415be124651e312ec4f21c594568f17
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
 
class crmclass_controller extends adminCommon{
    
    function index_action(){
        $categoryM            =    $this -> MODEL('category');
    
        $whereData['keyid'] =    '0';
        
        $position            =    $categoryM -> getCrmClassList($whereData);
 
        $this    ->    yunset('position',$position);
        $this    ->    yuntpl(array('admin/crm_class'));
    }
    
    function save_action(){
        $_POST        =    $this -> post_trim($_POST);
        
        $addData['ctype']         = $_POST['ctype'];
        $addData['name']         = explode('-',$_POST['name']);
        $addData['variable']    = explode('-',$_POST['str']);
        $addData['keyid']         = $_POST['nid'];
        
        $categoryM                 = $this   -> MODEL('category');
        $return                    = $categoryM -> addCrmClass($addData);
        echo $return['msg'];die;
    }
    
    function up_action(){
 
        $categoryM    = $this        ->    MODEL('category');
        
        //查询子类别
        if($_GET['id']){
            $id                    =    $_GET['id'];
            $whereOne['id']        =    $id;
            $whereTwo['keyid']    =    $id;
            $whereTwo['orderby']=    'sort,asc';
            $class1                =     $categoryM    ->    getCrmClass($whereOne);
            $class2                =    $categoryM    ->    getCrmClassList($whereTwo);
            $this    ->    yunset("id",$id);
            $this    ->    yunset("class1",$class1);
            $this    ->    yunset("class2",$class2);
        }
        $position                =    $categoryM    ->    getCrmClassList(array('keyid'=>'0'));
        $this    ->    yunset("position",$position);
        $this    ->    yuntpl(array('admin/crm_class'));
    }
    
    //删除
    function del_action(){
        $whereData                =    array();
        $data                    =    array();
        $categoryM                =    $this    ->    MODEL('category');
        if($_GET['delid']){//单个删除
            $this                ->    check_token();
            $whereData['id']    =    $_GET['delid'];
            $data['type']        =    'one';    
        }
        if($_POST['del']){//批量删除
            $whereData['id']    =    array('in',pylode(',',$_POST['del']));
            $data['type']        =    'all';    
        }
        $return    =    $categoryM    ->    delCrmClass($whereData,$data);
        $this   ->  layer_msg( $return['msg'],$return['errcode'],$return['layertype'],$_SERVER['HTTP_REFERER'],2,1);
    }
    
    function ajax_action(){
        $categoryM            =    $this    ->    MODEL('category');
        $whereData['id']    =    $_POST['id'];
        $addData['sort']    =    $_POST['sort'];
        $addData['name']    =    $_POST['name'];
        
        $categoryM    ->    addCrmClass($addData,$whereData);
        echo '1';
        die;
    }
    
    function upCache_action() {
        
        include_once (LIB_PATH . 'cache.class.php');
        $cacheclass = new cache(PLUS_PATH, $this->obj);
        $makecache = $cacheclass->crm_cache('crm.cache.php');
 
        echo $makecache ? 1 : 0;
        die();
    }
    
}
?>