chengkun
2025-04-18 1bb985f32f2efe0f9dd69f3cf29a1c809b1cf96d
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
<?php
class Smarty_Internal_Compile_Fairs extends Smarty_Internal_CompileBase{
    public $required_attributes = array('item');
    public $optional_attributes = array('name', 'key', 'len', 'sort','limit', 'ispage','state','type');
    public $shorttag_order = array('from', 'item', 'key', 'name');
    public function compile($args, $compiler, $parameter){
        $_attr = $this->getAttributes($compiler, $args);
        $from = $_attr['from'];
        $item = $_attr['item'];
        $name = $_attr['item'];
        $name=str_replace('\'','',$name);
        $name=$name?$name:'list';$name='$'.$name;
        if (!strncmp("\$_smarty_tpl->tpl_vars[$item]", $from, strlen($item) + 24)) {
            $compiler->trigger_template_error("item variable {$item} may not be the same variable as at 'from'", $compiler->lex->taglineno);
        }
 
        //自定义标签START
        $OutputStr=''.$name.'=array();$time=time();$paramer='.ArrayToString($_attr,true).';
        global $db,$db_config,$config;
        $ParamerArr = GetSmarty($paramer,$_GET,$_smarty_tpl);
        $paramer = $ParamerArr[arr];
        $Purl =  $ParamerArr[purl];
        global $ModuleName;
        if(!$Purl["m"]){
            $Purl["m"]=$ModuleName;
        }
        $where = "1";
        //根据后台设置开启/隐藏
        $where .= " and `is_open`=1";
        if($config[\'did\']){
            $where.=" and `did`=\'".$config[\'did\']."\'";
        }
        if($paramer[state]==\'1\'){//尚未开始
            $where .=" AND unix_timestamp(`starttime`)>\'$time\'";
        }elseif($paramer[state]==\'2\'){//进行中
            $where .=" AND unix_timestamp(`starttime`)<\'$time\' AND unix_timestamp(`endtime`)>\'$time\'";
        }elseif($paramer[state]==\'3\'){//已结束
            $where .=" AND unix_timestamp(`endtime`)<\'$time\'";
        }
        //查询条数
        if($paramer[limit]){
            $limit=" LIMIT ".$paramer[limit];
        }else{
            $limit=" LIMIT 20";
        }
        if($paramer[ispage]){
            if(isset($paramer["type"])) {
               $Purl["type"] = $paramer["type"]; 
            }
            $limit = PageNav($paramer,$_GET,"zhaopinhui",$where,$Purl,"",6,$_smarty_tpl);
        }
        $where .= " ORDER BY";
        $select = "`id`,`starttime`,`endtime`,`title`,`is_themb`,`is_themb_wap`,`address`";
        if($paramer[state]){
            // 单类型获取,直接按开始时间排序
            $where .= " unix_timestamp(`starttime`)";
 
            if($paramer[sort]){
                $where .= " $paramer[sort]";
            }else{
                $where .= " ASC ";
            }
        }else{
            // 查询招聘列表,判断有没有未结束的招聘会,确定排序
            $zphlist  =  $db->DB_select_once("zhaopinhui","unix_timestamp(`endtime`)>\'$time\'","`id`");
            // 有未结束的,条件查询
            if(!empty($zphlist)){
                // 条件排序,进行中在最上面,接着是未开始,最后是已结束
                $select .= ",CASE WHEN unix_timestamp(`endtime`)>\'$time\' THEN unix_timestamp(`starttime`)";
                $select .= " WHEN unix_timestamp(`endtime`)<\'$time\' THEN -1*unix_timestamp(`starttime`) END AS `zph_px`";
 
                $where .= " CASE";
                $where .= " WHEN unix_timestamp(`starttime`)<\'$time\' AND unix_timestamp(`endtime`)>\'$time\' THEN 0";
                $where .= " WHEN unix_timestamp(`starttime`)>\'$time\' THEN 1";
                $where .= " WHEN unix_timestamp(`endtime`)<\'$time\' THEN 2";
                $where .= " END, `zph_px` ASC";
            }else{
                // 全部结束。按时间开始时间倒序排列
                $where .= " unix_timestamp(`starttime`) DESC";
            }
        }
 
        '.$name.'=$db->select_all("zhaopinhui",$where.$limit, $select);
 
        if(is_array('.$name.')){
            foreach('.$name.' as $key=>$v){
                $array_zid[]=$v[id];
            }
            if(!empty($array_zid)){
                $rows=$db->select_all("zhaopinhui_com","`zid` in (".implode(\',\',$array_zid).") and `status`=1","`uid`,`zid`,`jobid`");
                $zph_com=array();
                $job_ids=array();
                foreach($rows as $va){
                    
                    $arr_uid[]=$a_uid[$va[zid]][]=$va[uid];
 
                    if($va[jobid]){
 
                        $job_ids = array_unique(array_merge($job_ids,@explode(",",$va[jobid])));
 
                    }
                    
                }
                
                if(!empty($arr_uid)){
                    $arr_uid  =  array_unique($arr_uid);
                    $joblist = $db->select_all("company_job","`uid` in (".implode(\',\',$arr_uid).") and `state`=1 and `status`=0 and `r_status`=1 GROUP BY `uid`","`uid`,count(*) as `num`, sum(`zp_num`) `zp_num`");
 
                    $comalljobnum = array();
 
                    foreach($joblist as $val){
                        
                        $comalljobnum[$val[uid]][jobnum] = $val[num];
                        $comalljobnum[$val[uid]][zpnum] = $val[zp_num];
                    }
                    
                    $jobidlist = $db->select_all("company_job","`id` in (".implode(\',\',$job_ids).") and `state`=1 and `status`=0 and `r_status`=1","`id`");
 
                    $jidarr =   array();
 
                    foreach($jobidlist as $jidv){
                        $jidarr[] = $jidv[id];
                    }
 
                    foreach($rows as $k=>$v){
 
                        $rows[$k][jobnum] = 0;
                        $rows[$k][zpnum]  =   isset($comalljobnum[$v[uid]][zpnum]) ? $comalljobnum[$v[uid]][zpnum] : 0; 
                        if($v["jobid"]){
 
                            $jobidarr = @explode(",",$v["jobid"]);
 
                            foreach($jobidarr as $jv){
 
                                if(in_array($jv,$jidarr)){
 
                                    $rows[$k][jobnum]++;
 
                                }
 
                            }
 
                        }else{
 
                            $rows[$k][jobnum]  =  $comalljobnum[$v[uid]][jobnum]; 
                            
                        }
 
                    }
                }
            }
 
            $weekarray=array("日","一","二","三","四","五","六");
            foreach('.$name.' as $key=>$v){
                '.$name.'[$key]["comnum"]=0;
                '.$name.'[$key]["jobnum"]=0;
                '.$name.'[$key]["zpnum"]=0;
                foreach($rows as $val){
                    if($v[id] == $val[zid]){
                        '.$name.'[$key]["comnum"]++;
                        '.$name.'[$key]["jobnum"]+=$val[jobnum];
                        '.$name.'[$key]["zpnum"] =$val[zpnum];
                    }
                }
                '.$name.'[$key]["starttime_n"]=date(\'Y\',strtotime($v[starttime])).\'年\'.date(\'n\',strtotime($v[starttime]))."月";
                '.$name.'[$key]["stime"]=strtotime($v[starttime])-time();
                '.$name.'[$key]["etime"]=strtotime($v[endtime])-time();
                if($paramer[len]){
                    '.$name.'[$key]["title"]=mb_substr($v[\'title\'],0,$paramer[len],"utf-8");
                }
                '.$name.'[$key]["url"]=Url("zph",array("c"=>\'show\',"id"=>$v[\'id\']),"1");
                '.$name.'[$key]["week"] = $weekarray[date(\'w\',strtotime($v[\'starttime\']))];
 
                '.$name.'[$key][\'is_themb\'] = checkpic($v[\'is_themb\'],$config[\'sy_zph_icon\']);
                '.$name.'[$key][\'is_themb_wap\'] = checkpic($v[\'is_themb_wap\'],'.$name.'[$key][\'is_themb\']);
            }
        }';
        //自定义标签 END
       // global $DiyTagOutputStr;
       // $DiyTagOutputStr[]=$OutputStr;
        return SmartyOutputStr($this,$compiler,$_attr,'fairs',$name,$OutputStr,$name);
    }
}
class Smarty_Internal_Compile_Fairselse extends Smarty_Internal_CompileBase{
    public function compile($args, $compiler, $parameter){
        $_attr = $this->getAttributes($compiler, $args);
 
        list($openTag, $nocache, $item, $key) = $this->closeTag($compiler, array('fairs'));
        $this->openTag($compiler, 'fairselse', array('fairselse', $nocache, $item, $key));
 
        return "<?php }\nif (!\$_smarty_tpl->tpl_vars[$item]->_loop) {\n?>";
    }
}
class Smarty_Internal_Compile_Fairsclose extends Smarty_Internal_CompileBase{
    public function compile($args, $compiler, $parameter){
        $_attr = $this->getAttributes($compiler, $args);
        if ($compiler->nocache) {
            $compiler->tag_nocache = true;
        }
 
        list($openTag, $compiler->nocache, $item, $key) = $this->closeTag($compiler, array('fairs', 'fairselse'));
 
        return "<?php } ?>";
    }
}