public function index()
 {
     $first = empty($_GET['start']) ? 0 : (int) $_GET['start'];
     $cont['game_id'] = mod_product::get_cur_pid();
     $qtype = $_GET['qtype_id'];
     $qtype && ($cont['qtype_id'] = $qtype);
     $cont['operation'] = 1;
     $startdate = $_GET['startdate'] ? $_GET['startdate'] : date('Y-m-d', strtotime('-7 day'));
     $enddate = $_GET['enddate'] ? $_GET['enddate'] : date('Y-m-d', strtotime('today'));
     $tlist = mod_crmmanage::getqtype();
     $qlist = mod_crmmanage::getqlist($cont, $startdate, $enddate, $first, PAGE_ROWS);
     $where = $qlist['where'];
     $total = $qlist['total'];
     foreach ($tlist as $key => $value) {
         $newtype[$key + 1] = $value;
     }
     $newtype = genTree($newtype);
     pm_tpl::assign("ur_here", "问题列表");
     //pm_tpl::assign('gid',$gid);  //选择的游戏
     pm_tpl::assign('qtype', $qtype);
     pm_tpl::assign("qlist", $qlist['list']);
     pm_tpl::assign("tlist", $tlist);
     pm_tpl::assign("ser_tlist", $newtype);
     pm_tpl::assign("startdate", $startdate);
     pm_tpl::assign("enddate", $enddate);
     pm_tpl::assign('action_link_1', array('href' => '?c=crmoper&a=export&query=' . urlencode($where), 'target' => '__blank', 'text' => '导出html'));
     $cont && ($url = http_build_query($cont));
     pm_tpl::assign('page_url', '?c=crmoper&a=index&startdate=' . $startdate . '&enddate=' . $enddate . '&' . $url);
     pm_tpl::assign('pages', mod_pager::get_page_number_list($total, $first, PAGE_ROWS));
     pm_tpl::display('crmoper_index');
 }
 public function index()
 {
     $first = empty($_GET['start']) ? 0 : (int) $_GET['start'];
     $gid = $_GET['game_id'];
     $qtype = $_GET['qtype_id'];
     $qid = trim($_GET['question_id']);
     $account = trim($_GET['account']);
     $nick = trim($_GET['nick']);
     $content = trim($_GET['content']);
     $status = trim($_GET['status']);
     $operation = trim($_GET['operation']);
     $is_tel = $_GET['is_tel'];
     $gid && ($cont['game_id'] = $gid);
     $qtype && ($cont['qtype_id'] = $qtype);
     $qid && ($cont['question_id'] = $qid);
     $account && ($cont['account'] = $account);
     $nick && ($cont['nick'] = $nick);
     $content && ($cont['content'] = $content);
     $is_tel && ($cont['is_tel'] = $is_tel);
     $cont['status'] = $status;
     $cont['operation'] = $operation;
     $startdate = $_GET['startdate'] ? $_GET['startdate'] : date('Y-m-d', strtotime('-7 day'));
     $enddate = $_GET['enddate'] ? $_GET['enddate'] : date('Y-m-d', strtotime('today'));
     $plist = mod_product::getcrmproduct();
     $userlist = mod_crmmanage::getusername();
     $tlist = mod_crmmanage::getqtype();
     $qlist = mod_crmmanage::getqlist($cont, $startdate, $enddate, $first, PAGE_ROWS);
     foreach ($qlist['list'] as &$value) {
         if ($value['status'] == 'untreated' && $value['operation'] == '1') {
             if ($value['lastreply_time']) {
                 if ($value['lastreply_time'] + 5 * 24 * 3600 < time()) {
                     $value['color'] = '#FF3300';
                 }
             } else {
                 if ($value['create_time'] + 5 * 24 * 3600 < time()) {
                     $value['color'] = '#FF3300';
                 }
             }
         }
         if ($value['status'] == 'untreated' && $value['operation'] == 2) {
             $value['color'] = 'green';
         }
         if ($value['status'] == 'untreated' && $value['operation'] == 3) {
             $firstanswer = mod_crmmanage::getfirstanswerbyqid($value['question_id']);
             if ($firstanswer['creater_id'] == $value['lastreply_id']) {
                 $value['color'] = '#ffa500';
             }
         }
         foreach ($userlist as $val) {
             if ($value['create_id'] == $val['user_id']) {
                 $value['create_name'] = $val['truename'];
             }
         }
     }
     unset($value);
     $total = $qlist['total'];
     foreach ($tlist as $key => $value) {
         $newtype[$key + 1] = $value;
     }
     $newtype = genTree($newtype);
     pm_tpl::assign("ur_here", "问题列表");
     pm_tpl::assign('gid', $gid);
     //选择的游戏
     pm_tpl::assign('qid', $qid);
     pm_tpl::assign('account', $account);
     pm_tpl::assign('nick', $nick);
     pm_tpl::assign('is_tel', $is_tel);
     pm_tpl::assign('content', $content);
     pm_tpl::assign('status', $status);
     pm_tpl::assign('operation', $operation);
     pm_tpl::assign('qtype', $qtype);
     pm_tpl::assign("qlist", $qlist['list']);
     pm_tpl::assign("tlist", $tlist);
     pm_tpl::assign("ser_tlist", $newtype);
     pm_tpl::assign("startdate", $startdate);
     pm_tpl::assign("enddate", $enddate);
     pm_tpl::assign("plist", $plist);
     pm_tpl::assign('action_link', array('href' => '?c=crmmanage&a=addquestion', 'text' => '添加问题'));
     //pm_tpl::assign('action_link_1',array('href' => '?c=crmmanage&a=export&query='.urlencode($where),'target' =>'__blank','text' => '导出html'));
     $cont && ($url = http_build_query($cont));
     pm_tpl::assign('page_url', '?c=crmmanage&a=index&startdate=' . $startdate . '&enddate=' . $enddate . '&' . $url);
     pm_tpl::assign('pages', mod_pager::get_page_number_list($total, $first, PAGE_ROWS));
     pm_tpl::display('crmmanage_index');
 }