Exemplo n.º 1
0
 public function process()
 {
     $ids = trim($this->input['id']);
     $sql = 'SELECT id,feedback_id,user_id,credit FROM ' . DB_PREFIX . 'record_person WHERE id in( ' . $ids . ')';
     $q = $this->db->query($sql);
     while ($r = $this->db->fetch_array($q)) {
         $feedback_id = $r['feedback_id'];
         if (!$r['credit'] && $r['user_id']) {
             $uncredit_user[] = $r['user_id'];
         }
         if ($r['credit'] && $r['user_id']) {
             $credit_user[] = $r['user_id'];
         }
     }
     if ($feedback_id) {
         $sql = 'SELECT user_id,org_id,is_credit,credit1,credit2,title,admin_user FROM ' . DB_PREFIX . 'feedback WHERE id =' . $feedback_id;
         $count = $this->db->query_first($sql);
     }
     if ($this->user['group_type'] > MAX_ADMIN_TYPE && $count['admin_user']) {
         $admin_user = array();
         $admin_user = explode(',', $count['admin_user']);
         if (!in_array($this->user['user_name'], $admin_user)) {
             $this->errorOutput("对不起,您没有此表单的权限");
         }
     } elseif ($this->user['group_type'] > MAX_ADMIN_TYPE && !$count['admin_user']) {
         $this->verify_content_prms(array('_action' => 'manage'));
         if (!$this->user['prms']['default_setting']['manage_other_data']) {
             if ($count['user_id'] != $this->user['user_id']) {
                 $this->errorOutput(NO_PRIVILEGE);
             }
         }
         if ($this->user['prms']['default_setting']['manage_other_data'] == 1 && $this->user['slave_org']) {
             if (!in_array($count['org_id'], explode(',', $this->user['slave_org']))) {
                 $this->errorOutput(NO_PRIVILEGE);
             }
         }
     }
     if (!$ids) {
         $this->output(NOID);
     }
     $pro = intval($this->input['process']);
     $sql = 'UPDATE ' . DB_PREFIX . 'record_person SET process = ' . $pro . ' WHERE id in(' . $ids . ')';
     $this->db->query($sql);
     $ret = array('id' => explode(',', $ids), 'process' => $pro);
     /******************会员报名通过审核后添加积分*******************/
     if ($feedback_id && $ret && $count['is_credit'] && AUDIT_ADD_CRIDET && $pro === 1 && $uncredit_user) {
         require_once ROOT_DIR . 'lib/class/members.class.php';
         $members = new members();
         if (is_array($uncredit_user)) {
             $uncredit_user = array_unique($uncredit_user);
             foreach ($uncredit_user as $k => $user_id) {
                 $re = $members->add_credit($user_id, array('credit1' => $count['credit1'], 'credit2' => $count['credit2']), $feedback_id, APP_UNIQUEID, MOD_UNIQUEID, 'audit', '参与:' . $count['title'], '反馈表单');
                 if ($re[0]['logid']) {
                     $addcredit_user[] = $user_id;
                 }
             }
         }
         if ($addcredit_user) {
             $addcredit_user = implode(',', $addcredit_user);
             $sql = 'UPDATE ' . DB_PREFIX . 'record_person SET credit = 1 WHERE feedback_id = ' . $feedback_id . ' and user_id in(' . $addcredit_user . ')';
             $this->db->query($sql);
         }
     }
     /******************会员报名通过审核后添加积分*******************/
     /******************会员报名打回后减积分*******************/
     if ($feedback_id && $ret && $count['is_credit'] && AUDIT_ADD_CRIDET && $pro !== 1 && $credit_user) {
         require_once ROOT_DIR . 'lib/class/members.class.php';
         $members = new members();
         if (is_array($credit_user)) {
             $credit_user = array_unique($credit_user);
             foreach ($credit_user as $k => $user_id) {
                 $re = $members->sub_credit($user_id, array('credit1' => $count['credit1'], 'credit2' => $count['credit2']), $feedback_id, APP_UNIQUEID, MOD_UNIQUEID, 'audit', '删除:' . $count['title'], '反馈表单');
                 if ($re[0]['logid']) {
                     $subcredit_user[] = $user_id;
                 }
             }
         }
         if ($subcredit_user) {
             $subcredit_user = implode(',', $subcredit_user);
             $sql = 'UPDATE ' . DB_PREFIX . 'record_person SET credit = 0 WHERE feedback_id = ' . $feedback_id . ' and user_id in(' . $subcredit_user . ')';
             $this->db->query($sql);
         }
     }
     /******************会员报名打回后减积分*******************/
     /****计算已通过处理人数和未通过处理人数******/
     $result[1] = $result[2] = 0;
     $sql = 'SELECT process,count(process) as count FROM ' . DB_PREFIX . 'record_person  WHERE feedback_id = ' . $feedback_id . ' GROUP BY process';
     $q = $this->db->query($sql);
     while ($r = $this->db->fetch_array($q)) {
         $result[$r['process']] = $r['count'];
     }
     $sql = 'UPDATE ' . DB_PREFIX . 'feedback SET processed_count = ' . $result[1] . ', unprocessed_count = ' . $result[2];
     $sql .= " WHERE id = '" . $feedback_id . "'";
     $this->db->query($sql);
     /****计算已通过处理人数和未通过处理人数******/
     $this->addItem($ret);
     $this->output();
 }