chengkun
2025-05-22 1a8aea45ebb1582c9f65d9e8dcd520002f83ae12
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
 
class product_controller extends company{
    function index_action(){  
        $companyM        =    $this->MODEL('company');
        
        $where['uid']    =    $this->uid;
        
        if(trim($_GET['keyword'])){
            
            $where['title']        =    array('like',trim($_GET['keyword']));
            
            $urlarr['keyword']    =    trim($_GET['keyword']);
        }
        
        $data['field']    =    '`title`,`id`,`status`,`ctime`,`statusbody`';
        
        //分页链接
        $urlarr['page']    =    '{{page}}';
        $urlarr['c']    =    "product";
        $pageurl        =    Url('member',$urlarr);
        
        //提取分页
        $pageM            =    $this  -> MODEL('page');
        $pages            =    $pageM -> pageList('company_product',$where,$pageurl,$_GET['page']);
        
        //分页数大于0的情况下 执行列表查询
        if($pages['total'] > 0){
            
            $where['limit']            =    $pages['limit'];
            
            $List                    =    $companyM->getCompanyProductList($where,$data);
            $this->yunset("rows",$List);
        }
        
        $this->public_action();
        $this->company_satic();
        $this->com_tpl("product");
    }
    function add_action(){
        $this->public_action();
        $this->com_tpl("addproduct");
    }
    
    function save_action(){
        
        $companyM        =    $this->MODEL('company');
        
        $sql['title']    =    $_POST['title'];
        $sql['body']    =    $_POST['body'];
        $sql['file']    =    $_FILES['file'];
        
        
        if(!$_POST['id']){
            $sql['uid']        =    $this->uid;
            $sql['did']        =    $this->userdid;
            $sql['ctime']    =    time();
            $where            =    array();
        }else{
            $where['id']    =    (int)$_POST['id'];
            $where['uid']        =    $this->uid;
            $sql['status']    =    '0';
            $sql['uid']    =    $this->uid;
        }
        $return        =    $companyM->setCompanyProduct($where,$sql,$this->usertype);
        
        $this->ACT_layer_msg($return['msg'],$return['errcode'],$return['url']);
        
    }
    
    function edit_action(){ 
        $companyM    =    $this->MODEL('company');
        $this->public_action();
        $editrow    =    $companyM->getComProductInfo(array('uid'=>$this->uid,'id'=>(int)$_GET['id']));
        
        $editrow['body']    =    str_replace(array("ti<x>tle","“","”"),array("title"," "," "),$editrow['body']);
        
        $this->yunset("editrow",$editrow);
        $this->com_tpl("addproduct");
    }
    
    function del_action(){
        $companyM    =    $this->MODEL('company');
        
        $delid        =    $_GET['delid']?$_GET['delid']:$_GET['id'];
        
        $return        =    $companyM->delCompanyProduct($delid,array('utype' => 'user','uid'=>$this->uid));
   
        $this->layer_msg($return['msg'],$return['errcode'],$return['layertype'],$_SERVER['HTTP_REFERER']);
        
    }
    
    function show_action(){
        $companyM    =    $this->MODEL('company');
        
        if($_POST['id']){
            $row    =    $companyM->getComProductInfo(array('uid'=>$this->uid,'id'=>(int)$_POST['id']),array('field'=>'`statusbody`'));
            
            $data['statusbody']        =    $row['statusbody'];
            
            echo json_encode($data);die;
        }
    }
}
?>