public function answerlist()
 {
     if ($_POST['rquestion']) {
         $data['qid'] = $_POST['qid'];
         $data['content'] = $_POST['reply'];
         $data['create_time'] = time();
         $data['creater_id'] = ADMINUSERID;
         $data['reply_type'] = 'operation';
         pm_db::tran_query("BEGIN");
         $id = pm_db::insert('crm_answer', $data, 'tran');
         $reply['operation'] = 2;
         //运营已回复
         $status = pm_db::update('crm_question', $reply, "question_id = '{$_POST['qid']}'", 'tran');
         if ($id && $status) {
             pm_db::tran_query("COMMIT");
             mod_login::message('回复成功');
         } else {
             pm_db::tran_query("ROLLBACK");
             mod_login::message('回复失败');
         }
         pm_db::tran_query("END");
         exit;
     }
     $qid = $_GET['qid'];
     $info = mod_crmmanage::getqbyid($qid);
     $memberinfo = mod_member::get_oneamdinbyuser_id($info['create_id']);
     $proinfo = mod_product::get_one_product($info['game_id']);
     $serinfo = mod_crmmanage::getserverbyid($info['server_id']);
     $info['truename'] = $memberinfo['truename'];
     $info['pname'] = $proinfo['pname'];
     $info['server_name'] = $serinfo['server_name'];
     $tlist = mod_crmmanage::getqtype();
     $alist = mod_crmmanage::getanswerlist($qid);
     $userlist = mod_crmmanage::getusername();
     if ($alist) {
         foreach ($alist as &$value) {
             if ($value['reply_type'] != 'customer') {
                 foreach ($userlist as $val) {
                     if ($val['user_id'] == $value['creater_id']) {
                         $value['username'] = $val['user_name'];
                     }
                 }
             }
         }
     }
     pm_tpl::assign("tlist", $tlist);
     pm_tpl::assign("alist", $alist);
     pm_tpl::assign("info", $info);
     pm_tpl::assign("ur_here", "回复列表");
     pm_tpl::assign('action_link', array('href' => '?c=crmoper&a=index', 'text' => '问题列表'));
     pm_tpl::display('crmoper_answerlist');
 }
 public function answerlist()
 {
     if ($_POST['rquestion']) {
         if (ADMINUSERID == 249) {
             dump($_POST);
             exit;
         }
         $data['qid'] = $_POST['qid'];
         $data['content'] = $_POST['reply'];
         $data['create_time'] = time();
         $data['creater_id'] = ADMINUSERID;
         $data['reply_type'] = 'cus_server';
         pm_db::tran_query("BEGIN");
         $id = pm_db::insert('crm_answer', $data, 'tran');
         $reply['lastreply_id'] = ADMINUSERID;
         $reply['lastreply_time'] = time();
         if (isset($_POST['to_server']) && !empty($_POST['to_server'])) {
             if ($_POST['operation'] == 0 && $_POST['status'] == 'untreated') {
                 $reply['operation'] = 3;
             }
         } else {
             if ($_POST['operation'] == 3) {
                 $reply['operation'] = 0;
             }
             $reply['status'] = 'processed';
         }
         $status = pm_db::update('crm_question', $reply, "question_id = '{$_POST['qid']}'", 'tran');
         if ($id && $status) {
             pm_db::tran_query("COMMIT");
             mod_login::message('回复成功');
         } else {
             pm_db::tran_query("ROLLBACK");
             mod_login::message('回复失败');
         }
         pm_db::tran_query("END");
         exit;
     }
     if ($_POST['tooperation']) {
         $data['operation'] = 1;
         $data['status'] = 'untreated';
         $status = pm_db::update('crm_question', $data, "question_id = '{$_POST['qid']}'");
         if ($status) {
             mod_login::message('转交成功!');
         } else {
             mod_login::message('转交失败!');
         }
         exit;
     }
     if ($_POST['cquestion']) {
         $data['status'] = 'closed';
         $data['operation'] = 0;
         $status = pm_db::update('crm_question', $data, "question_id = '{$_POST['qid']}'");
         if ($status) {
             mod_login::message('问题关闭成功!');
         } else {
             mod_login::message('问题关闭失败!');
         }
         exit;
     }
     $qid = $_GET['qid'];
     $info = mod_crmmanage::getqbyid($qid);
     $memberinfo = mod_member::get_oneamdinbyuser_id($info['create_id']);
     $admin_info = mod_member::get_oneamdinbyuser_id(ADMINUSERID);
     $proinfo = mod_product::get_one_product($info['game_id']);
     $serinfo = mod_crmmanage::getserverbyid($info['server_id']);
     $info['truename'] = $memberinfo['truename'];
     $info['pname'] = $proinfo['pname'];
     $info['server_name'] = $serinfo['server_name'];
     $info['is_right'] = strpos($admin_info['rights'], 'custom-question');
     $tlist = mod_crmmanage::getqtype();
     $alist = mod_crmmanage::getanswerlist($qid);
     $userlist = mod_crmmanage::getusername();
     if ($alist) {
         foreach ($alist as &$value) {
             if ($value['reply_type'] != 'customer') {
                 foreach ($userlist as $val) {
                     if ($val['user_id'] == $value['creater_id']) {
                         $value['username'] = $val['user_name'];
                     }
                 }
             }
         }
     }
     pm_tpl::assign("tlist", $tlist);
     pm_tpl::assign("alist", $alist);
     pm_tpl::assign("info", $info);
     pm_tpl::assign("ur_here", "回复列表");
     pm_tpl::assign('action_link', array('href' => '?c=crmmanage&a=index', 'text' => '问题列表'));
     pm_tpl::display('crmmanage_answerlist');
 }
 public function allot()
 {
     $username = $_GET['user'];
     $user_id = $_GET['user_id'];
     $uinfo = mod_member::get_oneamdinbyuser_id($user_id);
     if ($uinfo['user_name'] != $username) {
         mod_login::message('对不起,非法操作');
     }
     if ($_POST['submit']) {
         $sright = r_serialize(forrightserialize($_POST['action_code']));
         mod_member::saverights($sright, $user_id);
         mod_login::message('权限赋予成功');
     } else {
         $rightlist = mod_menu::get_user_action();
         $haveright = mod_member::get_right($user_id);
         $role['action_list'] = forunrightserialize(r_unserialize($haveright));
         pm_tpl::assign('priv_arr', $rightlist);
         pm_tpl::assign('role', $role);
         pm_tpl::assign('uinfo', $uinfo);
         pm_tpl::assign('ur_here', '分派权限');
         $action_link = array('href' => '?c=member&a=member_list', 'text' => '管理员列表');
         pm_tpl::assign('action_link', $action_link);
         pm_tpl::display('member_allot');
     }
 }