Пример #1
0
 public function show($condition = '')
 {
     $sql = "SELECT * FROM " . DB_PREFIX . "bill_record WHERE 1 " . $condition;
     $q = $this->db->query($sql);
     $data = array();
     $user_id_array = array();
     $user_id = $space = '';
     $bill_id = 0;
     //目前取记录,根据某个订单的来检索
     include_once CUR_CONF_PATH . 'lib/bill.class.php';
     $this->bill = new bill();
     while ($row = $this->db->fetch_array($q)) {
         $checkbool = $row['bill_id'] ? $this->bill->checkLocked($row['bill_id']) : 0;
         $row['locked'] = $checkbool ? 1 : 0;
         if ($row['user_id']) {
             $user_id_array[$row['user_id']] = $row['user_id'];
         }
         $data[] = $row;
     }
     if ($user_id_array) {
         $user_id = implode(',', $user_id_array);
         include_once ROOT_PATH . 'lib/class/auth.class.php';
         $auth = new auth();
         $tmp = $auth->getMemberById($user_id);
         $user_info = array();
         foreach ($tmp as $k => $v) {
             $user_info[$v['id']] = $v['user_name'];
         }
         foreach ($data as $k => $v) {
             $data[$k]['user_name'] = $user_info[$v['user_id']];
         }
     }
     return $data;
 }
Пример #2
0
 public function getMemberById()
 {
     $id = $this->input['id'] ? trim($this->input['id']) : 0;
     $data = array();
     if (!empty($id)) {
         include_once ROOT_PATH . 'lib/class/auth.class.php';
         $auth = new auth();
         $data = $auth->getMemberById($id);
     }
     $this->addItem($data);
     $this->output();
 }
Пример #3
0
 public function show($condition = '')
 {
     $sql = "SELECT * FROM " . DB_PREFIX . "bill WHERE 1 " . $condition;
     $q = $this->db->query($sql);
     $data = array();
     $user_id = $space = '';
     $project_id = $space_second = '';
     while ($row = $this->db->fetch_array($q)) {
         if ($row['user_id']) {
             $user_id .= $space . $row['user_id'];
             $space = ',';
         }
         if ($row['project_id']) {
             $project_id .= $space_second . $row['project_id'];
             $space_second = ',';
         }
         $row['cost_capital'] = hg_cny($row['cost']);
         $row['advice_capital'] = hg_cny($row['advice']);
         $data[] = $row;
     }
     if ($user_id) {
         include_once ROOT_PATH . 'lib/class/auth.class.php';
         $auth = new auth();
         $tmp = $auth->getMemberById($user_id);
         $user_info = array();
         foreach ($tmp as $k => $v) {
             $user_info[$v['id']] = $v['user_name'];
         }
     }
     if ($project_id) {
         include_once CUR_CONF_PATH . 'lib/project.class.php';
         $project = new project();
         $project_info = $tmp = array();
         $tmp = $project->show(' AND id IN(' . $project_id . ')');
         foreach ($tmp as $k => $v) {
             $project_info[$v['id']] = $v['name'];
         }
     }
     foreach ($data as $k => $v) {
         if ($user_info) {
             $data[$k]['user_name'] = $user_info[$v['user_id']];
         }
         if ($project_info) {
             $data[$k]['project_name'] = $project_info[$v['project_id']];
         }
         if (!$v['title']) {
             $data[$k]['title'] = date('Y-m-d', $v['business_time']) . '-' . $data[$k]['project_name'];
         }
     }
     return $data;
 }
Пример #4
0
 public function getOrgByUserid()
 {
     $user_id = $this->input['user_id'] ? intval($this->input['user_id']) : 0;
     $data = array();
     if ($user_id) {
         include_once ROOT_PATH . 'lib/class/auth.class.php';
         $auth = new auth();
         $user_info = $auth->getMemberById($user_id);
         if ($user_info) {
             $user_info = $user_info[0];
             $ret = $this->getTopFatherOrgid($user_info['org_id']);
             if ($ret) {
                 $this->addItem($ret);
             }
         }
     }
     $this->addItem($data);
     $this->output();
 }
Пример #5
0
 public function create($data)
 {
     if ($data) {
         $sql = 'INSERT INTO ' . DB_PREFIX . 'churu SET ';
         $p = '';
         foreach ($data as $k => $v) {
             $sql .= $p . $k . "='" . $v . "'";
             $p = ',';
         }
         $re = $this->db->query($sql);
         $data['id'] = $this->db->insert_id();
         include_once ROOT_PATH . 'lib/class/auth.class.php';
         $auth = new auth();
         $arr = $auth->getMemberById($data['uid']);
         $data['user_name'] = $arr[0]['user_name'];
         $data['org_name'] = $arr[0]['org_name'];
         //print_r($data);die;
         return $data;
     } else {
         return false;
     }
 }
Пример #6
0
 public function show_audit($bill_id)
 {
     $sql = "SELECT * FROM " . DB_PREFIX . "bill WHERE id=" . $bill_id;
     $f = $this->db->query_first($sql);
     $sql = "SELECT * FROM " . DB_PREFIX . "audit_queue WHERE bill_id=" . $bill_id;
     $q = $this->db->query($sql);
     $audit_record_id = $space = "";
     while ($row = $this->db->fetch_array($q)) {
         $audit_record_id .= $space . $row["audit_record_id"];
         $space = ",";
     }
     //还有下一级审批则获取下一级审批人 若打回或审批完成获取报销人
     if ($audit_record_id != "" && $f['is_approve'] != 2) {
         $sql = "SELECT * FROM " . DB_PREFIX . "audit_record WHERE id IN(" . $audit_record_id . ")";
         $q = $this->db->query($sql);
         while ($row = $this->db->fetch_array($q)) {
             if ($row['audit_level'] == $f['audit_level']) {
                 $audit_user_name = $row['user_name'];
                 $audit_user_id = $row['user_id'];
             }
         }
         $state = 1;
     } else {
         $audit_user_id = $f['user_id'];
         include_once ROOT_PATH . 'lib/class/auth.class.php';
         $auth = new auth();
         $tmp = $auth->getMemberById($audit_user_id);
         foreach ($tmp as $k => $v) {
             $audit_user_name = $v['user_name'];
         }
         $state = 2;
     }
     return array('id' => $id, 'audit_user_name' => $audit_user_name, 'audit_user_id' => $audit_user_id, 'state' => $state);
 }
Пример #7
0
 public function qingjia_count($condition, $start_time = '', $end_time = '')
 {
     $sql = "SELECT * FROM " . DB_PREFIX . "qingjia_record WHERE 1 ";
     $q = $this->db->query($sql);
     while ($row = $this->db->fetch_array($q)) {
         $data[] = $row;
     }
     $data2 = array();
     $sql2 = "SELECT * FROM " . DB_PREFIX . "xiaojia_record where 1 " . $condition;
     $q = $this->db->query($sql2);
     while ($row = $this->db->fetch_array($q)) {
         foreach ($data as $key => $vo) {
             if ($row['record_id'] == $vo['id']) {
                 $data2[$vo['user_id']][] = $row;
             }
         }
     }
     $user_id = $space = '';
     foreach ($data2 as $key => $vo) {
         foreach ($vo as $k => $v) {
             if ($start_time == '' && $end_time == '') {
                 $data2[$key]['time'] += $v['end_time'] - $v['start_time'];
             } elseif ($v['end_time'] >= $end_time && $v['start_time'] <= $start_time) {
                 $data2[$key]['time'] += $end_time - $start_time + 60 * 60 * 24;
             } elseif ($v['end_time'] <= $end_time && $v['start_time'] >= $start_time) {
                 $data2[$key]['time'] += $v['end_time'] - $v['start_time'];
             } elseif ($v['end_time'] <= $end_time && $v['start_time'] <= $start_time && $v['end_time'] >= $start_time) {
                 $data2[$key]['time'] += $v['end_time'] - $start_time;
             } elseif ($v['end_time'] >= $end_time && $v['start_time'] >= $start_time && $v['start_time'] <= $end_time) {
                 $data2[$key]['time'] += $end_time - $v['start_time'];
             }
             $sort_id[] = $v['sort_id'];
         }
         $user_id .= $space . $key;
         $space = ',';
     }
     if ($user_id) {
         include_once ROOT_PATH . 'lib/class/auth.class.php';
         $auth = new auth();
         $tmp = $auth->getMemberById($user_id);
         $user_info = array();
         foreach ($tmp as $k => $v) {
             $user_info[$v['id']] = $v['user_name'];
         }
     }
     if ($sort_id) {
         include_once CUR_CONF_PATH . 'lib/qingjia_sort.class.php';
         $sort = new qingjia_sort();
         $sort_tmp = $sort_info = array();
         $sort_tmp = $sort->get_sort_name($sort_id);
         foreach ($sort_tmp as $k => $v) {
             $sort_info[$v['id']] = $v['name'];
         }
     }
     foreach ($data2 as $k => $v) {
         if ($user_info) {
             $data2[$k]['user_name'] = $user_info[$k];
         }
         if ($sort_info) {
             foreach ($v as $key => $vo) {
                 $data2[$k][$key]['sort_name'] = $sort_info[$vo['sort_id']];
             }
         }
     }
     return $data2;
 }
Пример #8
0
 function get_avatar($id)
 {
     include_once ROOT_PATH . 'lib/class/auth.class.php';
     $auth = new auth();
     $userinfo = $auth->getMemberById($id);
     return $userinfo[0]['avatar'];
 }