lihai-oa/app/api/common.php

132 lines
3.1 KiB
PHP
Raw Permalink Normal View History

2023-10-24 15:17:16 +08:00
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/GPL-3.0
* @link https://www.gougucms.com
*/
2023-10-31 10:23:32 +08:00
use think\facade\Db;
2023-10-24 15:17:16 +08:00
//读取文章分类列表
function get_article_cate()
{
$cate = \think\facade\Db::name('ArticleCate')->order('create_time asc')->select()->toArray();
return $cate;
2023-10-31 10:23:32 +08:00
}
//写入日志
function add_project_log($uid,$module,$param,$old)
{
$log_data = [];
$key_array = ['id', 'create_time', 'update_time', 'delete_time', 'over_time', 'md_content'];
foreach ($param as $key => $value) {
if (!in_array($key, $key_array)) {
$log_data[] = array(
'module' => $module,
'field' => $key,
$module . '_id' => $param['id'],
'admin_id' => $uid,
'old_content' => $old[$key],
'new_content' => $value,
'create_time' => time(),
);
}
}
Db::name('ProjectLog')->strict(false)->field(true)->insertAll($log_data);
2023-10-31 15:34:42 +08:00
}
function isAuthProject($uid)
{
if($uid == 1){
return 1;
}
$map = [];
$map[] = ['name', '=', 'project_admin'];
$map[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',uids)")];
$count = Db::name('DataAuth')->where($map)->count();
return $count;
2023-11-02 15:21:30 +08:00
}
//读取会议室
function oa_meeting_cate_column()
{
$list = Db::name('MeetingCate')->where(['status' => 1])->column('title', 'id');
return $list;
}
//读取部门列表
function get_department_column()
{
$department = Db::name('Department')->order('sort desc,id asc')->where(['status' => 1])->column('title', 'id');
return $department;
}
//读取印章类型
function oa_seal_cate_column()
{
$list = Db::name('SealCate')->where(['status' => 1])->column('title', 'id');
return $list;
}
//读取车辆类型
function oa_car_cate_column()
{
$list = Db::name('CarCate')->where(['status' => 1])->column('title,name', 'id');
$car = [];
foreach($list as $k=>$v) {
$car[$k] = $v['title'] . '[' . $v['name']. ']';
}
return $car;
}
//读取费用类型
function oa_cost_cate_column()
{
$list = Db::name('CostCate')->where(['status' => 1])->column('title', 'id');
return $list;
}
//读取职位
function get_position_column()
{
$position = Db::name('Position')->where(['status' => 1])->column('title', 'id');
return $position;
}
2023-11-03 15:44:33 +08:00
//是否是报销打款管理员,count>1即有权限
function isAuthExpense($uid)
{
if($uid == 1){
return 1;
}
$map = [];
$map[] = ['name', '=', 'finance_admin'];
$map[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',uids)")];
$count = Db::name('DataAuth')->where($map)->count();
return $count;
}
2023-11-03 17:43:28 +08:00
//是否是发票管理员,count>1即有权限
function isAuthInvoice($uid)
{
if($uid == 1){
return 1;
}
$map = [];
$map[] = ['name', '=', 'finance_admin'];
$map[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',conf_1)")];
$count = Db::name('DataAuth')->where($map)->count();
return $count;
}
2023-11-04 11:35:54 +08:00
//是否是到账管理员,count>1即有权限
function isAuthIncome($uid)
{
if($uid == 1){
return 1;
}
$map = [];
$map[] = ['name', '=', 'finance_admin'];
$map[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',conf_2)")];
$count = Db::name('DataAuth')->where($map)->count();
return $count;
}