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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
<?php
 
class hr_controller extends adminCommon{
    
    //设置高级搜索功能
    
    function set_search(){
        
        $search_list[]    =    array("param"=>"status", "name"=>'前台显示', "value"=>array("1"=>"显示", "0"=>"不显示"));
        
        $ad_time        =    array('1'=>'今天', '3'=>'最近三天', '7'=>'最近七天', '15'=>'最近半月', '30'=>'最近一个月');
        
        $search_list[]    =    array("param"=>"end", "name"=>'上传日期', "value"=>$ad_time);
        
        $this->yunset("search_list",$search_list);
    }
    
    function index_action(){
        
        $this->set_search();
        
        $HrM        =    $this->MODEL('hr');
        
        if($_GET["type"]!=""){
            
            if($_GET["type"]=="1"){
                
                $where['name']    =    array('like',trim($_GET['keyword']));
            
            }elseif($_GET['type']=="2"){
                
                $hrclass     =    $HrM -> getClassList(array('name'=>array('like',trim($_GET['keyword']))),'id');
                
                if ($hrclass){
                    
                    foreach($hrclass as $v){
                        
                        $cids[]        =    $v['id'];
                    }
                    
                    $where['cid']   =    array('in',pylode(',', $cids));
                }
            }
            
            $urlarr["keyword"]=$_GET["keyword"];
            
            $urlarr["type"]=$_GET["type"];
        }
         
        if($_GET['status']=="0"){
            
            $where['is_show']    =    $_GET['status'];
            
            $urlarr['status']    =    $_GET['status'];
        
        }elseif($_GET['status']=="1"){
            
            $where['is_show']    =   $_GET['status'];
            
            $urlarr['status']    =    $_GET['status'];
        
        }    
        
        if($_GET['end']){
            
            if($_GET['end'] == 1){
                
                $where['add_time']    =    array('>=',strtotime(date("Y-m-d 00:00:00")));
            
            }else{
                
                $where['add_time']    =    array('>=',strtotime('-'.intval($_GET['end']).' day'));
            }
            
            $urlarr['end']    =    $_GET['end'];
            
        }
        $urlarr                =   $_GET;
        $urlarr['page']        =    "{{page}}";
        
        $pageurl            =    Url($_GET['m'],$urlarr,'admin');
        
        $pageM                =    $this  -> MODEL('page');
        
        $pages                =    $pageM -> pageList('toolbox_doc',$where,$pageurl,$_GET['page']);
        
        if($pages['total'] > 0){
            
            if($_GET['order']){
                
                $where['orderby']        =    $_GET['t'].','.$_GET['order'];
                
                $urlarr['order']        =    $_GET['order'];
                
                $urlarr['t']            =    $_GET['t'];
           
            }else{   
                
                $where['orderby']        =    'id';        
            
            }    
            
            $where['limit']                =    $pages['limit'];         
            
            $ListHr       =    $HrM -> getList($where);           
            
            $t_class    =    $HrM -> getClassList();
            
            if(is_array($ListHr )){
                
                foreach($ListHr  as $key=>$val){
                    
                    foreach($t_class as $value){
                        
                        if($val['cid']==$value['id']){
                            
                            $ListHr[$key]['cname']=$value['name'];
                        
                        }
                    
                    }
                
                }
            
            }
        
        }
        
        $this->yunset("rows" , $ListHr); 
            
        $this->yunset("get_type", $_GET);
            
        $this->yuntpl(array('admin/admin_hr_toolbox'));
        
    }
    
    function add_action(){
        
        $HrM    =    $this->MODEL('hr');
        
        if($_GET['id']){
            
            $id            =        intval($_GET['id']);
            
            $info        =        $HrM   ->  getInfo($id);
            
            $this         ->  yunset("row",  $info);
            
            $this         ->  yunset('lasturl',   $_SERVER['HTTP_REFERER']);
        
        }
        
        $ListHr        =    $HrM -> getClassList();
        
        $this->yunset("t_class", $ListHr);
        
        $this->yuntpl(array('admin/admin_hr_adddoc'));
    }
    function save_action(){
        
        $HrM    =    $this->MODEL('hr');
        
        if($_POST['submit']){
            
            if($_POST['name'] == ''){
                
                $this->ACT_layer_msg("文档名称不能为空!",8,$_SERVER['HTTP_REFERER']);
                
            }else if($_POST['cid'] == ''){
                
                $this->ACT_layer_msg("请选择文档分类!",8,$_SERVER['HTTP_REFERER']);
            }
            
            if($_FILES['file']['name']==''){
                
                if($_POST['url']==''){
                    
                    $this->ACT_layer_msg("请选择上传文档!",8,$_SERVER['HTTP_REFERER']);
                
                }else{
                    
                    $_POST['url']    =    str_replace($this->config['sy_weburl'],"",$_POST['url']);
                    $post             =     array(
                        'name'        =>    $_POST['name'],
                        'cid'        =>    $_POST['cid'],
                        'is_show'    =>    $_POST['is_show'],
                        'url'        =>    $_POST['url'],
                        'add_time'    =>    time(),
                    );
                    $nid    =    $HrM->upHrInfo(array('id'=>intval($_POST['id'])),array('post'=>$post));
                    
                    $nid?$this->ACT_layer_msg( "文档更新(ID:".$_POST['id'].")成功!",9,"index.php?m=hr",2,1):$this->ACT_layer_msg( "文档更新(ID:".$_POST['id'].")失败!",8,"index.php?m=hr",2,1);
                
                }
            
            }else{
                
                
                $upArr  =  array(
                    'file'  =>  $_FILES['file'],
                    'dir'   =>  'hrdoc'
                );
                
                $uploadM  =  $this->MODEL('upload');
                
                $result   =  $uploadM -> uploadDoc($upArr);
                
                if ($result['msg']){
                    
                    $this->ACT_layer_msg($result['msg'],8);
                    
                }else{
                    $_POST['url']  =  $result['docurl'];
                    
                    if($_POST['id']){
                        
                        $post    =     array(
                            'name'        =>    $_POST['name'],
                            'cid'        =>    $_POST['cid'],
                            'is_show'    =>    $_POST['is_show'],
                            'url'        =>    $_POST['url'],
                            'add_time'    =>    time(),
                        );
                        $nid    =    $HrM->upHrInfo(array('id'=>intval($_POST['id'])),array('post'=>$post));
                        $msg="更新";
                    }else{
                        
                        $nid=$HrM -> addHrInfo($_POST);
                        $msg="添加";
                    }
                    
                    $nid?$this->ACT_layer_msg( "文档(ID:".$_POST['id'].")".$msg."成功!",9,"index.php?m=hr",2,1):$this->ACT_layer_msg( "文档(ID:".$_POST['id'].")".$msg."失败!",8,"index.php?m=hr",2,1);
                }
            }
        }
    }
    
    function del_action(){
        
        $this->check_token();
        
        $HrM    =    $this -> Model('hr');
        
        $delID    =    $_GET['id'] ? intval($_GET['id']) : $_GET['del'];
        
        $addArr    =    $HrM -> delHr($delID);
        
        $this   ->  layer_msg( $addArr['msg'],$addArr['errcode'],$addArr['layertype'],$_SERVER['HTTP_REFERER'],2,1);
        
    }
   
   function show_action(){
        $HrM    =    $this -> Model('hr');
        $nid    =    $HrM-> upHrInfo(array('id' => array('=', $_GET['id'])),array('post'=>array(''.$_GET['type'].''=>$_GET['rec'])));    
        echo $nid?1:0;die;
    
    }
}
 
?>