<?php
keke_lang_class::load_lang_class ( 'sreward_task_class' );
class sreward_task_class extends keke_task_class {
public $_task_status_arr;
public $_work_status_arr;
public $_delay_rule;
public $_agree_id;
protected $_inited = false;
public static function get_instance($task_info) {
static $obj = null;
if ($obj == null) {
$obj = new sreward_task_class ( $task_info );
}
return $obj;
}
public function __construct($task_info) {
parent::__construct ( $task_info );
($this->_task_status == '6'||$this->_task_status == '8') and $this->_agree_id = db_factory::get_count ( sprintf ( " select agree_id from %switkey_agreement where task_id='%d'", TABLEPRE, $this->_task_id ) );
$this->init ();
}
public function init() {
if (! $this->_inited) {
$this->status_init ();
$this->delay_rule_init ();
$this->wiki_priv_init ();
$this->mark_init ();
}
$this->_inited = true;
}
public function mark_init() {
$m = $this->get_mark_count_ext ();
$t = $this->_task_info;
$t ['mark'] ['all'] = intval ( $m [1] ['c'] + $m [2] ['c'] );
$t ['mark'] ['master'] = intval ( $m [2] ['c'] );
$t ['mark'] ['wiki'] = intval ( $m [1] ['c'] );
$this->_task_info = $t;
}
public function status_init() {
$this->_task_status_arr = $this->get_task_status ();
$this->_work_status_arr = $this->get_work_status ();
}
public function delay_rule_init() {
$this->_delay_rule = keke_task_config::get_delay_rule ( $this->_model_id, '3600' );
}
public function wiki_priv_init() {
$arr = sreward_priv_class::get_priv ( $this->_task_id, $this->_model_id, $this->_userinfo );
$this->_priv = $this->user_priv_format ( $arr );
}
public function get_task_timedesc() {
global $_lang;
$status_arr = $this->_task_status_arr;
$task_status = $this->_task_status;
$task_info = $this->_task_info;
$time_desc = array ();
switch ($task_status) {
case "0" :
$time_desc ['ext_desc'] = $_lang ['task_nopay_can_not_look'];
break;
case "1" :
$time_desc ['ext_desc'] = $_lang ['wait_patient_to_audit'];
break;
case "2" :
$time_desc ['time_desc'] = $_lang ['from_hand_work_deadline'];
$time_desc ['time'] = $task_info ['sub_time'];
$time_desc ['ext_desc'] = $_lang ['hand_work_and_reward_trust'];
$time_desc ['g_action'] = $_lang ['now_employer_can_choose_work'];
break;
case "3" :
$time_desc ['time_desc'] = $_lang ['from_choose_deadline'];
$time_desc ['time'] = $task_info ['end_time'];
$time_desc ['ext_desc'] = $_lang ['work_choosing_and_wait_employer_choose'];
break;
case "4" :
$time_desc ['time_desc'] = $_lang ['from_vote_deadline'];
$time_desc ['time'] = $task_info ['sp_end_time'];
$time_desc ['ext_desc'] = $_lang ['no_choosing_wait_for_vote'];
break;
case "5" :
$time_desc ['time_desc'] = $_lang ['from_gs_deadline'];
$time_desc ['time'] = $task_info ['sp_end_time'];
$time_desc ['ext_desc'] = $_lang ['task_gs_and_emplyer_have_choose'];
break;
case "6" :
$time_desc ['ext_desc'] = $_lang ['employer_and_witkey_jf'];
break;
case "7" :
$time_desc ['ext_desc'] = $_lang ['task_frozen_can_not_operate'];
break;
case "8" :
$time_desc ['ext_desc'] = $_lang ['task_over_congra_witkey'];
break;
case "9" :
$time_desc ['ext_desc'] = $_lang ['pity_task_fail'];
break;
case "10" :
$time_desc ['ext_desc'] = $_lang ['fail_audit_please_repub'];
break;
case "11" :
$time_desc ['ext_desc'] = $_lang ['wait_for_task_arbitrate'];
break;
case "13" :
$time_desc ['ext_desc'] = $_lang ['task_frozen_when_jf'];
break;
}
return $time_desc;
}
public function getProjectProgressDesc() {
$arrTaskInfo = $this->_task_info;
$arrProjectProgress = array(
'1'=>array(
'status' => -1,
'desc' => '发布需求',
'time' => $arrTaskInfo['start_time'],
),
'2'=>array(
'status' => 2,
'desc' => '威客交稿',
'time' => $arrTaskInfo['sub_time'],
'timedesc' => '距离投稿结束时间剩余',
'timeing' => $arrTaskInfo['sub_time']
),
'3'=>array(
'status' => 3,
'desc' => '雇主选稿',
'time' => $arrTaskInfo['end_time'],
'timedesc' => '距离选稿结束时间剩余',
'timeing' => $arrTaskInfo['end_time']
),
'4'=>array(
'status' => 4,
'desc' => '投票期',
'time' => $arrTaskInfo['sp_end_time'],
'timedesc' => '距离投票期结束时间剩余',
'timeing' => $arrTaskInfo['sp_end_time']
),
'5'=>array(
'status' => 5,
'desc' => '公示期',
'time' => $arrTaskInfo['sp_end_time'],
'timedesc' => '距离公示期结束时间剩余',
'timeing' => $arrTaskInfo['sp_end_time']
),
'6'=>array(
'status' => 6,
'task_status' => 13,
'desc' => '稿件交付中'
),
'7'=>array(
'status' => 8,
'desc' => '评价'
),
);
return $arrProjectProgress;
}
public function get_work_info($w = array(), $order = null, $p = array()) {
global $kekezu, $_K, $uid,$gUid;
$work_arr = array ();
$sql = " select a.*,
b.seller_credit,b.seller_good_num,b.residency,b.seller_total_num,b.seller_level
from " . TABLEPRE . "witkey_task_work a
left join " . TABLEPRE . "witkey_space b on a.uid=b.uid";
$count_sql = " select count(a.work_id) from " . TABLEPRE . "witkey_task_work a left join " . TABLEPRE . "witkey_space b on a.uid=b.uid";
$where = " where a.task_id = ".$this->_task_id;
if (! empty ( $w )) {
$intWorkStatus = intval ( $w ['work_status'] );
switch($intWorkStatus){
case'2':
$where .= " and a.is_view !=1 ";
break;
case'4':
case'5':
case'7':
case'8':
$where .= " and a.work_status = '" . $intWorkStatus . "'";
break;
case'9':
$where .= " and a.uid = '$this->_uid'";
break;
}
}
$where .= " order by field(a.work_status,'8','7','5','4') desc, work_id asc ";
if (! empty ( $p )) {
$page_obj = $kekezu->_page_obj;
$page_obj->setAjax ( 1 );
$page_obj->setAjaxDom ( "gj_summery" );
$count = intval ( db_factory::get_count ( $count_sql . $where ) );
$pages = $page_obj->getPages ( $count, $p ['page_size'], $p ['page'], $p ['url'], $p ['anchor'] );
$where .= $pages ['where'];
$pages ['count'] = $count;
}
$work_info = db_factory::query ( $sql . $where );
$work_info = kekezu::get_arr_by_key ( $work_info, 'work_id' );
$work_arr ['work_info'] = $work_info;
$work_arr ['pages'] = $pages;
$work_ids = implode ( ',', array_keys ( $work_info ) );
$work_arr ['mark'] = $this->has_mark ( $work_ids );
$work_arr ['count'] = $count;
if(is_array($work_info)){
foreach($work_info as $k=>$v){
$work_arr ['work_info'][$k] = $v;
$work_arr ['work_info'][$k]['attachment'] = array();
if($v['work_file']){
$fileids = explode(',', $v['work_file']);
$fileids = array_filter($fileids);
$fileids = implode(',', $fileids);
$work_arr ['work_info'][$k]['attachment'] = db_factory::query('select file_id,save_name,file_name from '.TABLEPRE.'witkey_file where file_id in ('.$fileids.')');
}
$work_arr ['work_info'][$k]['comment'] = $this->get_comment ( 'work', $this->_task_id, $v['work_id'], $v['uid'] );
if($this->_task_status==4){
$arrVote = db_factory::get_count ( sprintf ( " select count(vote_id) from %switkey_vote where
work_id='%d' and uid='%d' and vote_ip='%s'", TABLEPRE, intval($v['work_id']), $this->_uid, kekezu::get_ip () ) );
if($arrVote){
$work_arr ['work_info'][$k]['vote'] = true;
}
unset($arrVote);
}
$arrFavorite = db_factory::get_count(sprintf('select count(*) from %s where uid = %d and obj_id = %d and keep_ty