diff --git a/app/home/common.php b/app/home/common.php
index d4f8b84..e37e75c 100644
--- a/app/home/common.php
+++ b/app/home/common.php
@@ -6,9 +6,9 @@
*/
/**
======================
-*模块数据获取公共文件
+ *模块数据获取公共文件
======================
-*/
+ */
use think\facade\Cache;
use think\facade\Db;
@@ -21,7 +21,7 @@ function set_cache($key, $value, $date = 86400)
//读取缓存
function get_cache($key)
{
- return Cache::get($key);
+ return Cache::get($key);
}
//清空缓存
@@ -31,26 +31,25 @@ function clear_cache($key)
}
//读取系统配置
-function get_system_config($name,$key='')
+function get_system_config($name, $key = '')
{
- $config=[];
+ $config = [];
if (get_cache('system_config' . $name)) {
$config = get_cache('system_config' . $name);
} else {
- $conf = Db::name('config')->where('name',$name)->find();
- if($conf['content']){
+ $conf = Db::name('config')->where('name', $name)->find();
+ if ($conf['content']) {
$config = unserialize($conf['content']);
}
set_cache('system_config' . $name, $config);
}
- if($key==''){
+ if ($key == '') {
return $config;
+ } else {
+ if ($config[$key]) {
+ return $config[$key];
+ }
}
- else{
- if($config[$key]){
- return $config[$key];
- }
- }
}
//获取指定管理员的信息
@@ -64,12 +63,12 @@ function get_admin($id)
}
//获取当前登录用户的信息
-function get_login_admin($key='')
+function get_login_admin($key = '')
{
$session_admin = get_config('app.session_admin');
if (\think\facade\Session::has($session_admin)) {
$gougu_admin = \think\facade\Session::get($session_admin);
- $admin = get_admin($gougu_admin['id']);
+ $admin = get_admin($gougu_admin['id']);
if (!empty($key)) {
if (isset($admin[$key])) {
return $admin[$key];
@@ -94,14 +93,14 @@ function get_admin_menu()
//读取权限节点列表
function get_admin_rule()
{
- $rule = Db::name('AdminRule')->order('create_time asc')->select()->toArray();
+ $rule = Db::name('AdminRule')->order('id desc')->select()->toArray();
return $rule;
}
//读取权限分组列表
function get_admin_group()
{
- $group = Db::name('AdminGroup')->order('create_time asc')->select()->toArray();
+ $group = Db::name('AdminGroup')->order('id desc')->select()->toArray();
return $group;
}
@@ -117,7 +116,7 @@ function get_admin_group_info($id)
//菜单父子关系排序,用于后台菜单
function get_admin_menus()
{
- $admin = get_login_admin();
+ $admin = get_login_admin();
if (get_cache('menu' . $admin['id'])) {
$list = get_cache('menu' . $admin['id']);
} else {
@@ -135,49 +134,67 @@ function get_admin_menus()
return $list;
}
-
//读取部门列表
function get_department()
{
- $department = Db::name('Department')->select()->toArray();
+ $department = Db::name('Department')->where(['status' => 1])->select()->toArray();
return $department;
}
//获取某部门的子部门id
-function get_department_son($did = 0,$is_self=1)
+function get_department_son($did = 0, $is_self = 1)
{
- $department=get_department();
- $department_list = get_data_node($department,$did);
- $department_array = array_column($department_list,'id');
- if($is_self == 1){
- //包括自己在内
- $department_array[]=$did;
- }
- return $department_array;
+ $department = get_department();
+ $department_list = get_data_node($department, $did);
+ $department_array = array_column($department_list, 'id');
+ if ($is_self == 1) {
+ //包括自己在内
+ $department_array[] = $did;
+ }
+ return $department_array;
}
-
//读取关键字列表
function get_keywords()
{
- $keywords = Db::name('Keywords')->where(['status' => 1])->order('create_time asc')->select();
- return $keywords;
+ $keywords = Db::name('Keywords')->where(['status' => 1])->order('id desc')->select()->toArray();
}
//读取公告分类列表
function get_note_cate()
{
- $cate = Db::name('NoteCate')->order('create_time asc')->select()->toArray();
+ $cate = Db::name('NoteCate')->order('id desc')->select()->toArray();
return $cate;
}
//读取知识分类列表
function get_article_cate()
{
- $cate = Db::name('ArticleCate')->order('create_time asc')->select()->toArray();
+ $cate = Db::name('ArticleCate')->order('id desc')->select()->toArray();
return $cate;
}
+//读取开票主体
+function get_invoice_subject()
+{
+ $subject = Db::name('InvoiceSubject')->where(['status' => 1])->order('id desc')->select()->toArray();
+ return $subject;
+}
+
+//读取审核人
+function get_check_user($type=1)
+{
+ $user = Db::name('Check')
+ ->field('c.*,a.name as user')
+ ->alias('c')
+ ->join('admin a', 'a.id = c.uid', 'LEFT')
+ ->where(['c.type'=>$type,'c.status' => 1])
+ ->order('c.id desc')
+ ->select()
+ ->toArray();
+ return $user;
+}
+
/**
* 根据附件表的id返回url地址
* @param [type] $id [description]
@@ -206,13 +223,14 @@ function get_file($id)
* 节点权限判断
* @return bool
*/
-function check_auth($rule,$uid){
- $auth_list = Cache::get('RulesSrc' . $uid);
+function check_auth($rule, $uid)
+{
+ $auth_list = Cache::get('RulesSrc' . $uid);
if (!in_array($rule, $auth_list)) {
return false;
} else {
return true;
- }
+ }
}
/**
* 员工操作日志
@@ -300,9 +318,9 @@ function send_email($to, $subject = '', $content = '')
$mail->Host = $config['smtp'];
//端口 - likely to be 25, 465 or 587
$mail->Port = $config['smtp_port'];
- if($mail->Port == '465'){
- $mail->SMTPSecure = 'ssl';// 使用安全协议
- }
+ if ($mail->Port == '465') {
+ $mail->SMTPSecure = 'ssl'; // 使用安全协议
+ }
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//发送邮箱
@@ -322,7 +340,7 @@ function send_email($to, $subject = '', $content = '')
$mail->addAddress($to);
}
- $mail->isHTML(true);// send as HTML
+ $mail->isHTML(true); // send as HTML
//标题
$mail->Subject = $subject;
//HTML内容转换
@@ -331,8 +349,8 @@ function send_email($to, $subject = '', $content = '')
if ($status) {
return true;
} else {
- // echo "Mailer Error: ".$mail->ErrorInfo;// 输出错误信息
- // die;
+ // echo "Mailer Error: ".$mail->ErrorInfo;// 输出错误信息
+ // die;
return false;
}
}
diff --git a/app/home/controller/Expense.php b/app/home/controller/Expense.php
index ef053a8..3752795 100644
--- a/app/home/controller/Expense.php
+++ b/app/home/controller/Expense.php
@@ -73,9 +73,8 @@ class Expense extends BaseController
->each(function ($item, $key) {
$item->income_month = empty($item->income_month) ? '-' : date('Y-m', $item->income_month);
$item->expense_time = empty($item->expense_time) ? '-' : date('Y-m-d', $item->expense_time);
- $item->user_name = Db::name('Admin')->where(['id' => $item->uid])->value('name');
$item->admin_name = Db::name('Admin')->where(['id' => $item->admin_id])->value('name');
- $item->department = Db::name('Department')->where(['id' => $item->did])->value('title');
+ $item->department = Db::name('Department')->where(['id' => $item->admin_id])->value('title');
$item->check_name = Db::name('Admin')->where(['id' => $item->check_admin_id])->value('name');
$item->check_time = empty($item->check_time) ? '-' : date('Y-m-d H:i', $item->check_time);
$item->pay_name = Db::name('Admin')->where(['id' => $item->pay_admin_id])->value('name');
@@ -91,7 +90,7 @@ class Expense extends BaseController
if ($expense) {
$expense['income_month'] = empty($expense['income_month']) ? '-' : date('Y-m', $expense['income_month']);
$expense['expense_time'] = empty($expense['expense_time']) ? '-' : date('Y-m-d', $expense['expense_time']);
- $expense['user_name'] = Db::name('Admin')->where(['id' => $expense['uid']])->value('name');
+ $expense['user_name'] = Db::name('Admin')->where(['id' => $expense['admin_id']])->value('name');
$expense['department'] = Db::name('Department')->where(['id' => $expense['did']])->value('title');
$expense['amount'] = Db::name('ExpenseInterfix')->where(['exid' => $expense['id']])->sum('amount');
@@ -139,7 +138,6 @@ class Expense extends BaseController
if (request()->isAjax()) {
$dbRes = false;
$admin_id = $this->uid;
- $param['admin_id'] = $admin_id;
$param['income_month'] = isset($param['income_month']) ? strtotime(urldecode($param['income_month'])) : 0;
$param['expense_time'] = isset($param['expense_time']) ? strtotime(urldecode($param['expense_time'])) : 0;
$param['check_status'] = 1;
@@ -204,6 +202,8 @@ class Expense extends BaseController
return to_assign(1, $e->getError());
}
$param['create_time'] = time();
+ $param['admin_id'] = $admin_id;
+ $param['did'] = get_login_admin('did');
Db::startTrans();
try {
$exid = ExpenseList::strict(false)->field(true)->insertGetId($param);
diff --git a/app/home/controller/Income.php b/app/home/controller/Income.php
new file mode 100644
index 0000000..3c70e12
--- /dev/null
+++ b/app/home/controller/Income.php
@@ -0,0 +1,107 @@
+order('create_time asc')
+ ->paginate($rows, false, ['query' => $param])
+ ->each(function ($item, $key) {
+ $item->user = Db::name('Admin')->where(['id' => $item->admin_id])->value('name');
+ $item->department = Db::name('Department')->where(['id' => $item->did])->value('title');
+ $item->check_name = Db::name('Admin')->where(['id' => $item->check_admin_id])->value('name');
+ $item->check_time = empty($item->check_time) ? '-' : date('Y-m-d H:i', $item->check_time);
+ $item->open_name = Db::name('Admin')->where(['id' => $item->open_admin_id])->value('name');
+ $item->open_time = empty($item->open_time) ? '-' : date('Y-m-d H:i', $item->open_time);
+ });
+ return $expense;
+ }
+
+ public function detail($id = 0)
+ {
+ $invoice = Db::name('Invoice')->where(['id' => $id])->find();
+ if ($invoice) {
+ $invoice['user'] = Db::name('Admin')->where(['id' => $invoice['admin_id']])->value('name');
+ $invoice['department'] = Db::name('Department')->where(['id' => $invoice['did']])->value('title');
+ if ($invoice['check_admin_id'] > 0) {
+ $invoice['check_admin'] = Db::name('Admin')->where(['id' => $invoice['check_admin_id']])->value('name');
+ $invoice['check_time'] = empty($invoice['check_time']) ? '0' : date('Y-m-d H:i', $invoice['check_time']);
+ }
+ if ($invoice['open_admin_id'] > 0) {
+ $invoice['open_name'] = Db::name('Admin')->where(['id' => $invoice['open_admin_id']])->value('name');
+ $invoice['open_time'] = empty($invoice['open_time']) ? '0' : date('Y-m-d H:i', $invoice['open_time']);
+ }
+ }
+ return $invoice;
+ }
+
+ public function index()
+ {
+ if (request()->isAjax()) {
+ $param = get_params();
+ $where = [];
+ $where[] = ['status', 'in', [3,4,5]];
+ //按时间检索
+ $start_time = isset($param['start_time']) ? strtotime(urldecode($param['start_time'])) : 0;
+ $end_time = isset($param['end_time']) ? strtotime(urldecode($param['end_time'])) : 0;
+ if ($start_time > 0 && $end_time > 0) {
+ $where[] = ['expense_time', 'between', [$start_time, $end_time]];
+ }
+ $invoice = $this->get_list($param, $where);
+ return table_assign(0, '', $invoice);
+ } else {
+ return view();
+ }
+ }
+
+ //查看
+ public function view()
+ {
+ $id = empty(get_params('id')) ? 0 : get_params('id');
+ $detail = $this->detail($id);
+ View::assign('uid', $this->uid);
+ View::assign('detail', $detail);
+ return view();
+ }
+
+ //设置
+ public function check()
+ {
+ $param = get_params();
+ if (request()->isAjax()) {
+ if ($param['invoice_status'] == 2 || $param['invoice_status'] == 0) {
+ $param['check_time'] = time();
+ }
+ if ($param['check_status'] == 3) {
+ $param['open_time'] = time();
+ }
+ if ($param['check_status'] == 10) {
+ $param['update_time'] = time();
+ }
+ $res = InvoiceList::where('id', $param['id'])->strict(false)->field(true)->update($param);
+ if ($res !== false) {
+ return to_assign();
+ } else {
+ return to_assign(1, "操作失败");
+ }
+ }
+ }
+}
diff --git a/app/home/controller/Invoice.php b/app/home/controller/Invoice.php
index 899c481..431597d 100644
--- a/app/home/controller/Invoice.php
+++ b/app/home/controller/Invoice.php
@@ -13,6 +13,7 @@ use app\home\BaseController;
use app\home\model\InvoiceSubject;
use app\home\model\Invoice as InvoiceList;
use app\home\validate\InvoiceSubjectCheck;
+use app\home\validate\InvoiceCheck;
use think\exception\ValidateException;
use think\facade\Db;
use think\facade\View;
@@ -70,15 +71,12 @@ class Invoice extends BaseController
->order('create_time asc')
->paginate($rows, false, ['query' => $param])
->each(function ($item, $key) {
- $item->income_month = empty($item->income_month) ? '-' : date('Y-m', $item->income_month);
- $item->expense_time = empty($item->expense_time) ? '-' : date('Y-m-d', $item->expense_time);
- $item->user_name = Db::name('Admin')->where(['id' => $item->uid])->value('name');
- $item->admin_name = Db::name('Admin')->where(['id' => $item->admin_id])->value('name');
+ $item->user = Db::name('Admin')->where(['id' => $item->admin_id])->value('name');
$item->department = Db::name('Department')->where(['id' => $item->did])->value('title');
$item->check_name = Db::name('Admin')->where(['id' => $item->check_admin_id])->value('name');
$item->check_time = empty($item->check_time) ? '-' : date('Y-m-d H:i', $item->check_time);
- $item->pay_name = Db::name('Admin')->where(['id' => $item->pay_admin_id])->value('name');
- $item->pay_time = empty($item->pay_time) ? '-' : date('Y-m-d H:i', $item->pay_time);
+ $item->open_name = Db::name('Admin')->where(['id' => $item->open_admin_id])->value('name');
+ $item->open_time = empty($item->open_time) ? '-' : date('Y-m-d H:i', $item->open_time);
});
return $expense;
}
@@ -87,17 +85,15 @@ class Invoice extends BaseController
{
$invoice = Db::name('Invoice')->where(['id' => $id])->find();
if ($invoice) {
- $invoice['income_month'] = empty($invoice['income_month']) ? '-' : date('Y-m', $invoice['income_month']);
- $invoice['expense_time'] = empty($invoice['expense_time']) ? '-' : date('Y-m-d', $invoice['expense_time']);
- $invoice['user_name'] = Db::name('Admin')->where(['id' => $invoice['uid']])->value('name');
+ $invoice['user'] = Db::name('Admin')->where(['id' => $invoice['admin_id']])->value('name');
$invoice['department'] = Db::name('Department')->where(['id' => $invoice['did']])->value('title');
if ($invoice['check_admin_id'] > 0) {
$invoice['check_admin'] = Db::name('Admin')->where(['id' => $invoice['check_admin_id']])->value('name');
- $invoice['check_time'] = date('Y-m-d H:i:s', $invoice['check_time']);
+ $invoice['check_time'] = empty($invoice['check_time']) ? '0' : date('Y-m-d H:i', $invoice['check_time']);
}
- if ($invoice['pay_admin_id'] > 0) {
- $invoice['pay_admin'] = Db::name('Admin')->where(['id' => $invoice['pay_admin_id']])->value('name');
- $invoice['pay_time'] = date('Y-m-d H:i:s', $invoice['pay_time']);
+ if ($invoice['open_admin_id'] > 0) {
+ $invoice['open_name'] = Db::name('Admin')->where(['id' => $invoice['open_admin_id']])->value('name');
+ $invoice['open_time'] = empty($invoice['open_time']) ? '0' : date('Y-m-d H:i', $invoice['open_time']);
}
}
return $invoice;
@@ -122,134 +118,70 @@ class Invoice extends BaseController
}
}
- //添加
+ //添加&编辑
public function add()
{
- $id = empty(get_params('id')) ? 0 : get_params('id');
- if ($id > 0) {
- $detail = $this->detail($id);
- View::assign('detail', $detail);
- }
- View::assign('user', get_admin($this->uid));
- View::assign('id', $id);
- return view();
- }
-
- //提交添加
- public function post_submit()
- {
- $admin_id = $this->uid;
- $dbRes = false;
$param = get_params();
- $param['admin_id'] = $admin_id;
- $param['income_month'] = isset($param['income_month']) ? strtotime(urldecode($param['income_month'])) : 0;
- $param['expense_time'] = isset($param['expense_time']) ? strtotime(urldecode($param['expense_time'])) : 0;
- $param['check_status'] = 1;
- if (!empty($param['id']) && $param['id'] > 0) {
- try {
- validate(ExpenseCheck::class)->scene('edit')->check($param);
- } catch (ValidateException $e) {
- // 验证失败 输出错误信息
- return to_assign(1, $e->getError());
+ if (request()->isAjax()) {
+ //人类型判断
+ if ($param['type'] == 2) {
+ if (!$param['invoice_tax']) {
+ return to_assign(1, '纳税人识别号不能为空');
+ }
+ if (!$param['invoice_bank']) {
+ return to_assign(1, '开户银行不能为空');
+ }
+ if (!$param['invoice_account']) {
+ return to_assign(1, '银行账号不能为空');
+ }
+ if (!$param['invoice_banking']) {
+ return to_assign(1, '银行营业网点不能为空');
+ }
+ if (!$param['invoice_address']) {
+ return to_assign(1, '银地址不能为空');
+ }
}
- $param['update_time'] = time();
- Db::startTrans();
- try {
- $res = ExpenseList::where('id', $param['id'])->strict(false)->field(true)->update($param);
+ if (!empty($param['id']) && $param['id'] > 0) {
+ try {
+ validate(InvoiceCheck::class)->scene('edit')->check($param);
+ } catch (ValidateException $e) {
+ // 验证失败 输出错误信息
+ return to_assign(1, $e->getError());
+ }
+ $param['update_time'] = time();
+ $res = InvoiceList::where('id', $param['id'])->strict(false)->field(true)->update($param);
if ($res !== false) {
- $exid = $param['id'];
- //相关内容多个数组;
- $amountData = isset($param['amount']) ? $param['amount'] : '';
- $remarksData = isset($param['remarks']) ? $param['remarks'] : '';
- $cateData = isset($param['cate_id']) ? $param['cate_id'] : '';
- $idData = isset($param['expense_id']) ? $param['expense_id'] : 0;
- if ($amountData) {
- foreach ($amountData as $key => $value) {
- if (!$value) {
- continue;
- }
-
- $data = [];
- $data['id'] = $idData[$key];
- $data['exid'] = $exid;
- $data['admin_id'] = $admin_id;
- $data['amount'] = $amountData[$key];
- $data['cate_id'] = $cateData[$key];
- $data['remarks'] = $remarksData[$key];
- if ($data['amount'] == 0) {
- Db::rollback();
- return to_assign(1, '第' . ($key + 1) . '条报销金额不能为零');
- }
- if ($data['id'] > 0) {
- $data['update_time'] = time();
- $resa = Db::name('ExpenseInterfix')->strict(false)->field(true)->update($data);
- } else {
- $data['create_time'] = time();
- $eid = Db::name('ExpenseInterfix')->strict(false)->field(true)->insertGetId($data);
- }
- }
- }
- add_log('edit', $exid, $param);
- Db::commit();
- $dbRes = true;
+ return to_assign();
} else {
- Db::rollback();
+ return to_assign(1, '操作失败');
}
- } catch (\Exception $e) { ##这里参数不能删除($e:错误信息)
- Db::rollback();
- return to_assign(1, $e->getMessage());
- }
- } else {
- try {
- validate(ExpenseCheck::class)->scene('add')->check($param);
- } catch (ValidateException $e) {
- // 验证失败 输出错误信息
- return to_assign(1, $e->getError());
- }
- $param['create_time'] = time();
- Db::startTrans();
- try {
- $exid = ExpenseList::strict(false)->field(true)->insertGetId($param);
+ } else {
+ try {
+ validate(InvoiceCheck::class)->scene('add')->check($param);
+ } catch (ValidateException $e) {
+ // 验证失败 输出错误信息
+ return to_assign(1, $e->getError());
+ }
+ $admin_id = $this->uid;
+ $param['admin_id'] = $admin_id;
+ $param['did'] = get_login_admin('did');
+ $param['create_time'] = time();
+ $exid = InvoiceList::strict(false)->field(true)->insertGetId($param);
if ($exid) {
- //相关内容多个数组;
- $amountData = isset($param['amount']) ? $param['amount'] : '';
- $remarksData = isset($param['remarks']) ? $param['remarks'] : '';
- $cateData = isset($param['cate_id']) ? $param['cate_id'] : '';
- if ($amountData) {
- foreach ($amountData as $key => $value) {
- if (!$value) {
- continue;
- }
-
- $data = [];
- $data['exid'] = $exid;
- $data['admin_id'] = $admin_id;
- $data['amount'] = $amountData[$key];
- $data['cate_id'] = $cateData[$key];
- $data['remarks'] = $remarksData[$key];
- $data['create_time'] = time();
- if ($data['amount'] == 0) {
- Db::rollback();
- return to_assign(1, '第' . ($key + 1) . '条报销金额不能为零');
- }
- $eid = Db::name('ExpenseInterfix')->strict(false)->field(true)->insertGetId($data);
- }
- }
- add_log('add', $exid, $param);
- Db::commit();
- $dbRes = true;
+ return to_assign();
} else {
- Db::rollback();
+ return to_assign(1, '操作失败');
}
- } catch (\Exception $e) { ##这里参数不能删除($e:错误信息)
- Db::rollback();
- return to_assign(1, $e->getMessage());
}
- }
- if ($dbRes == true) {
- return to_assign();
} else {
- return to_assign(1, '保存失败');
+ $id = isset($param['id']) ? $param['id'] : 0;
+ if ($id > 0) {
+ $detail = $this->detail($id);
+ View::assign('detail', $detail);
+ }
+ View::assign('user', get_admin($this->uid));
+ View::assign('id', $id);
+ return view();
}
}
@@ -267,12 +199,12 @@ class Invoice extends BaseController
public function delete()
{
$id = get_params("id");
- $expense = $this->detail($id);
- if ($expense['check_status'] == 2) {
- return to_assign(1, "已审核的报销记录不能删除");
+ $detail = $this->detail($id);
+ if ($detail['invoice_status'] == 2) {
+ return to_assign(1, "已审核的发票不能删除");
}
- if ($expense['check_status'] == 3) {
- return to_assign(1, "已打款的报销记录不能删除");
+ if ($detail['invoice_status'] == 3) {
+ return to_assign(1, "已开具的发票不能删除");
}
$data['status'] = '-1';
$data['id'] = $id;
@@ -289,13 +221,14 @@ class Invoice extends BaseController
{
$param = get_params();
if (request()->isAjax()) {
- if ($param['check_status'] == 2 || $param['check_status'] == 0) {
- $param['check_admin_id'] = $this->uid;
+ if ($param['invoice_status'] == 2 || $param['invoice_status'] == 0) {
$param['check_time'] = time();
}
if ($param['check_status'] == 3) {
- $param['pay_admin_id'] = $this->uid;
- $param['pay_time'] = time();
+ $param['open_time'] = time();
+ }
+ if ($param['check_status'] == 10) {
+ $param['update_time'] = time();
}
$res = InvoiceList::where('id', $param['id'])->strict(false)->field(true)->update($param);
if ($res !== false) {
diff --git a/app/home/validate/InvoiceCheck.php b/app/home/validate/InvoiceCheck.php
index 6046c01..f3bc58d 100644
--- a/app/home/validate/InvoiceCheck.php
+++ b/app/home/validate/InvoiceCheck.php
@@ -5,19 +5,22 @@ use think\Validate;
class InvoiceCheck extends Validate
{
protected $rule = [
- 'code' => 'require',
- 'id' => 'require',
- 'status' => 'require'
+ 'amount' => 'require|float',
+ 'invoice_type' => 'require',
+ 'invoice_subject' => 'require',
+ 'id' => 'require'
];
protected $message = [
- 'code.require' => '报销凭证编号不能为空',
+ 'amount.require' => '开票金额不能为空',
+ 'amount.number' => '开票金额只能为数字',
'id.require' => '缺少更新条件',
- 'status.require' => '状态为必选',
+ 'invoice_type.require' => '请选择开票类型',
+ 'invoice_subject.require' => '请选择开票主体',
];
protected $scene = [
- 'add' => ['code'],
- 'edit' => ['id', 'code']
+ 'add' => ['amount','invoice_type','invoice_subject'],
+ 'edit' => ['id', 'amount','invoice_type','invoice_subject']
];
}
\ No newline at end of file
diff --git a/app/home/view/expense/add.html b/app/home/view/expense/add.html
index ab55715..1e96a7d 100644
--- a/app/home/view/expense/add.html
+++ b/app/home/view/expense/add.html
@@ -28,15 +28,22 @@
- 报销人* |
+ 报销审核人* |
-
-
+
+ |
+ 报销人 |
+
+ {$user.name}
|
报销部门 |
-
-
+ {$user.department}
|
@@ -86,16 +93,19 @@
- 报销人* |
+ 报销审核人* |
-
-
+
|
+ 报销人 |
+ {$expense.user_name} |
报销部门 |
-
-
-
- |
+ {$expense.department} |
报销选项* |
@@ -155,7 +165,6 @@
var form = layui.form
,layer = layui.layer
,table = layui.table
- ,employeepicker = layui.employeepicker//很重要
,laydate = layui.laydate;
laydate.render({
@@ -169,26 +178,6 @@
max:0,
showBottom: false
});
-
- // 选择员工
- $('.body-content').on('click','[name="name"]',function(){
- var that = $(this);
- var names = that.val(), ids = $('[name="uid"]').val();
- employeepicker.init({
- ids: ids,
- names: names,
- type: 0,
- department_url:"{:url('/home/api/get_department_tree')}",
- employee_url:"{:url('/home/api/get_employee')}",
- callback: function (ids, names, dids, departments) {
- $('[name="uid"]').val(ids);
- $('[name="did"]').val(dids);
- $('[name="department"]').val(departments);
- that.val(names);
- }
- })
- });
-
//监听提交
form.on('submit(webform)', function(data){
var interfix = $('.more_interfix');
@@ -255,23 +244,6 @@
that.parents(".more_interfix").remove();
}
});
-
- //报销成员修改
- $('[name="nickname"]').on('click',function() {
- var that=$(this);
- var ids=that.next().val(),names=that.val();
- employeepicker.init({
- ids:ids,
- names:names,
- type:0,
- callback:function(ids,names,dids,departments){
- that.val(names);
- that.next().val(ids);
- $('[name="department"]').val(departments);
- $('[name="did"]').val(dids);
- }
- });
- });
}
diff --git a/app/home/view/expense/index.html b/app/home/view/expense/index.html
index 3a6c4b6..5d36435 100644
--- a/app/home/view/expense/index.html
+++ b/app/home/view/expense/index.html
@@ -40,15 +40,15 @@
align: 'right',
width: 120,
},{
- field: 'user_name',
+ field: 'admin_name',
title: '报销人',
align: 'center',
- width: 90
+ width: 100
},{
field: 'department',
title: '报销部门',
align: 'center',
- width: 120
+ width: 150
},{
field: 'code',
title: '报销凭证编号',
@@ -57,17 +57,12 @@
field: 'expense_time',
title: '原始单据日期',
align: 'center',
- width: 110
+ width: 120
},{
field: 'income_month',
title: '入账月份',
align: 'center',
width: 90
- },{
- field: 'admin_name',
- title: '登记人',
- align: 'center',
- width: 100
},{
field: 'create_time',
title: '录入时间',
@@ -95,22 +90,22 @@
field: 'check_name',
title: '审核人',
align: 'center',
- width: 90
+ width: 100
},{
field: 'check_time',
title: '审核时间',
align: 'center',
- width: 136
+ width: 150
},{
field: 'pay_name',
title: '打款确认人',
align: 'center',
- width: 90
+ width: 100
},{
field: 'pay_time',
title: '打款确认时间',
align: 'center',
- width: 136
+ width: 150
}, {
field: 'right',
fixed: 'right',
@@ -147,7 +142,7 @@
table.on('tool(test)', function(obj) {
var data = obj.data;
if (obj.event === 'view') {
- rightpage.open("/home/expense/check?id="+data.id);
+ rightpage.open("/home/expense/view?id="+data.id);
return;
}
if (obj.event === 'edit') {
diff --git a/app/home/view/expense/view.html b/app/home/view/expense/view.html
index bd1f2e5..154569d 100644
--- a/app/home/view/expense/view.html
+++ b/app/home/view/expense/view.html
@@ -89,7 +89,7 @@
{/if}
{if condition="($expense.check_status == 2) AND ($uid == $expense.pay_admin_id)"}
- {/eq}
+ {/if}
{/block}
diff --git a/app/home/view/income/index.html b/app/home/view/income/index.html
new file mode 100644
index 0000000..d2243ba
--- /dev/null
+++ b/app/home/view/income/index.html
@@ -0,0 +1,143 @@
+{extend name="common/base"/}
+
+{block name="body"}
+
+{/block}
+
+
+
+{block name="script"}
+
+{include file="common/layui" base='base' extend="['rightpage']" use="['table','form']" callback="init" /}
+{/block}
+
diff --git a/app/home/view/income/view.html b/app/home/view/income/view.html
new file mode 100644
index 0000000..75eb566
--- /dev/null
+++ b/app/home/view/income/view.html
@@ -0,0 +1,167 @@
+{extend name="common/base"/}
+{block name="style"}
+
+{/block}
+
+{block name="body"}
+
+
发票详情
+
+
+ 开票金额 |
+
+ {$detail.amount}
+ |
+ 开票类型 |
+
+ {eq name="$detail.invoice_type" value="1"}增值税专用发票{/eq}
+ {eq name="$detail.invoice_type" value="2"}增值税普通发票{/eq}>
+ |
+ 开票主体 |
+
+ {volist name=":get_invoice_subject()" id="vo"}
+ {eq name="$vo.id" value="$detail.invoice_subject"}{$vo.title}{/eq}
+ {/volist}
+ |
+
+
+ 抬头类型 |
+
+ {eq name="$detail.type" value="1"}企业{/eq}
+ {eq name="$detail.type" value="2"}个人{/eq}
+ |
+ 开票抬头 |
+ {$detail.invoice_title} |
+ 电话号码 |
+ {$detail.invoice_phone} |
+
+
+ 纳税人识别号 |
+ {$detail.invoice_tax} |
+ 开户行 |
+ {$detail.invoice_bank} |
+ 银行账号 |
+ {$detail.invoice_account} |
+
+
+ 银行营业网点 |
+ {$detail.invoice_banking} |
+ 地址 |
+ {$detail.invoice_address} |
+
+ {notempty name="$detail.remark"}
+
+ 备注信息 |
+ {$detail.remark} |
+
+ {/notempty}
+
+ 发票状态 |
+
+ {if condition="($detail.check_time == 0)"}
+
+ {elseif condition="($detail.check_time == 1)"}
+ |
+
+
+ {if condition="($detail.check_time == 0)"}
+ 当前审核人 |
+ {$detail.check_admin} |
+ {else/}
+ 发票审核人 |
+ {$detail.check_admin} |
+ 审核时间 |
+ {$detail.check_admin} |
+ {/if}
+
+
+
+
+{/block}
+
+
+
+{block name="script"}
+
+{include file="common/layui" base='base' extend="[]" callback="init" /}
+{/block}
+
\ No newline at end of file
diff --git a/app/home/view/invoice/add.html b/app/home/view/invoice/add.html
index 5785336..65b40c1 100644
--- a/app/home/view/invoice/add.html
+++ b/app/home/view/invoice/add.html
@@ -28,33 +28,34 @@
开票主体* |
- |
抬头类型* |
-
-
+
+
|
开票抬头* |
- |
+ |
电话号码* |
- |
+ |
-
+
纳税人识别号* |
|
开户行* |
|
银行账号* |
- |
+ |
-
+
银行营业网点* |
|
地址* |
@@ -68,10 +69,11 @@
发票审核人* |
-
+
-
-
+ {volist name=":get_check_user(3)" id="vo"}
+
+ {/volist}
|
@@ -82,62 +84,64 @@
开票金额* |
-
+
|
开票类型* |
-
+
-
-
+
+
|
开票主体* |
-
+
-
-
+ {volist name=":get_invoice_subject()" id="vo"}
+
+ {/volist}
|
抬头类型* |
-
-
+
+
|
开票抬头* |
- |
+ |
电话号码* |
- |
+ |
-
+
纳税人识别号* |
- |
+ |
开户行* |
- |
+ |
银行账号* |
- |
+ |
-
+
银行营业网点* |
- |
+ |
地址* |
- |
+ |
备注信息 |
- |
+ |
发票审核人* |
-
+
-
-
+ {volist name=":get_check_user(3)" id="vo"}
+
+ {/volist}
|
@@ -162,23 +166,28 @@
,layer = layui.layer
,laydate = layui.laydate;
+ //选择收件人类型
+ form.on('radio(type)', function (data) {
+ if(data.value==2){
+ $('.invoice-type').hide();
+ }
+ else{
+ $('.invoice-type').show();
+ }
+ });
//监听提交
form.on('submit(webform)', function(data){
- var interfix = $('.more_interfix');
- if(interfix.length <1 ){
- layer.msg('至少要保留一个报销选项');
- return false;
- }
+
$.ajax({
- url:"{:url('/home/expense/add')}",
- type:'post',
- data:data.field,
- success:function(e){
- layer.msg(e.msg);
- if(e.code==0){
- parent.location.reload();
+ url:"{:url('/home/invoice/add')}",
+ type:'post',
+ data:data.field,
+ success:function(e){
+ layer.msg(e.msg);
+ if(e.code==0){
+ parent.location.reload();
+ }
}
- }
})
return false;
});
diff --git a/app/home/view/invoice/index.html b/app/home/view/invoice/index.html
index c9ce538..5e407e5 100644
--- a/app/home/view/invoice/index.html
+++ b/app/home/view/invoice/index.html
@@ -35,8 +35,8 @@
align: 'center',
width: 80
}, {
- field: 'amount',
- title: '客户名称',
+ field: 'invoice_title',
+ title: '开票抬头',
width: 240,
},{
field: 'amount',
@@ -46,10 +46,20 @@
},{
field: 'invoice_type',
title: '开票类型',
- align: 'right',
+ align: 'center',
width: 90,
+ templet:function(d){
+ var html='-';
+ if(d.invoice_type==1){
+ html='普票';
+ }
+ else if(d.invoice_type==2){
+ html='专票';
+ }
+ return html;
+ }
},{
- field: 'user_name',
+ field: 'user',
title: '申请人',
align: 'center',
width: 100
@@ -70,14 +80,23 @@
width: 120,
templet:function(d){
var html='审核不通过';
- if(d.check_status==1){
- html='报销审核中';
+ if(d.invoice_status==1){
+ html='审核中';
}
- else if(d.check_status==2){
- html='审核通过';
+ else if(d.invoice_status==2){
+ html='待开具';
}
- else if(d.check_status==3){
- html='已打款';
+ else if(d.invoice_status==3){
+ html='已开具';
+ }
+ else if(d.invoice_status==4){
+ html='部分到账';
+ }
+ else if(d.invoice_status==5){
+ html='全部到账';
+ }
+ else if(d.invoice_status==10){
+ html='已作废';
}
return html;
}
@@ -142,7 +161,7 @@
table.on('tool(test)', function(obj) {
var data = obj.data;
if (obj.event === 'view') {
- rightpage.open("/home/invoice/check?id="+data.id);
+ rightpage.open("/home/invoice/view?id="+data.id);
return;
}
if (obj.event === 'edit') {
@@ -150,7 +169,7 @@
return;
}
if (obj.event === 'del') {
- layer.confirm('确定删除该报销记录吗?', {
+ layer.confirm('确定删除该发票记录吗?', {
icon: 3,
title: '提示'
}, function(index) {
diff --git a/app/home/view/invoice/view.html b/app/home/view/invoice/view.html
index bd1f2e5..75eb566 100644
--- a/app/home/view/invoice/view.html
+++ b/app/home/view/invoice/view.html
@@ -8,88 +8,88 @@
{block name="body"}
-
报销详情
+
发票详情
- 报销凭证编号 |
- {$expense.code} |
- 入账月份 |
- {$expense.income_month} |
- 原始单据日期 |
- {$expense.expense_time} |
+ 开票金额 |
+
+ {$detail.amount}
+ |
+ 开票类型 |
+
+ {eq name="$detail.invoice_type" value="1"}增值税专用发票{/eq}
+ {eq name="$detail.invoice_type" value="2"}增值税普通发票{/eq}>
+ |
+ 开票主体 |
+
+ {volist name=":get_invoice_subject()" id="vo"}
+ {eq name="$vo.id" value="$detail.invoice_subject"}{$vo.title}{/eq}
+ {/volist}
+ |
- 报销人 |
- {$expense.user_name} |
- 报销部门 |
- {$expense.department} |
- 报销总费用(元) |
- {$expense.amount} |
+ 抬头类型 |
+
+ {eq name="$detail.type" value="1"}企业{/eq}
+ {eq name="$detail.type" value="2"}个人{/eq}
+ |
+ 开票抬头 |
+ {$detail.invoice_title} |
+ 电话号码 |
+ {$detail.invoice_phone} |
+
+ 纳税人识别号 |
+ {$detail.invoice_tax} |
+ 开户行 |
+ {$detail.invoice_bank} |
+ 银行账号 |
+ {$detail.invoice_account} |
+
+
+ 银行营业网点 |
+ {$detail.invoice_banking} |
+ 地址 |
+ {$detail.invoice_address} |
+
+ {notempty name="$detail.remark"}
- 报销状态 |
+ 备注信息 |
+ {$detail.remark} |
+
+ {/notempty}
+
+ 发票状态 |
- {if condition="$expense.check_status == 0"}
- 审核不通过 【原因:{$expense.check_remark}】
- {elseif condition="$expense.check_status == 1"}
- 报销审核中
- {elseif condition="$expense.check_status == 2"}
- 审核通过
- {elseif condition="$expense.check_status == 3"}
- 已打款
- {/if}
+ {if condition="($detail.check_time == 0)"}
+
+ {elseif condition="($detail.check_time == 1)"}
|
- {if condition="$expense.check_admin_id > 0"}
- 审核人 |
- {$expense.check_admin} |
- 审核时间 |
- {$expense.check_time} |
-
- {/if}
- {if condition="$expense.pay_admin_id > 0"}
-
- 打款确认人 |
- {$expense.pay_admin} |
- 打款确认时间 |
- {$expense.pay_time} |
-
- {/if}
-
- 费用金额 |
-
-
-
-
- 报销金额(元) |
- 报销类别 |
- 备注信息 |
-
- {volist name="$expense.list" id="vo"}
-
- {$vo.amount} |
- {$vo.cate_title} |
- {$vo.remarks} |
-
- {/volist}
-
-
- |
+ {if condition="($detail.check_time == 0)"}
+ 当前审核人 |
+ {$detail.check_admin} |
+ {else/}
+ 发票审核人 |
+ {$detail.check_admin} |
+ 审核时间 |
+ {$detail.check_admin} |
+ {/if}
{/block}
diff --git a/app/install/data/gouguoa.sql b/app/install/data/gouguoa.sql
index 8f3ca08..6a6fc5c 100644
--- a/app/install/data/gouguoa.sql
+++ b/app/install/data/gouguoa.sql
@@ -475,11 +475,10 @@ DROP TABLE IF EXISTS `oa_expense`;
CREATE TABLE `oa_expense` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`code` varchar(100) NOT NULL DEFAULT '' COMMENT '报销编码',
- `uid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '报销人员ID',
- `did` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '报销部门ID',
`income_month` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '入账月份',
`expense_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '原始单据日期',
- `admin_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建人',
+ `admin_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '报销人',
+ `did` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '报销部门ID',
`ptid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '预定字段:关联项目ID',
`status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态:-1删除 0禁用 1启用',
`check_admin_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '审核人ID',
@@ -575,7 +574,6 @@ CREATE TABLE `oa_invoice` (
`cmid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '预定字段:关联客户ID',
`crid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '预定字段:关联合同协议号ID',
`ptid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '预定字段:关联项目ID',
- `sid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '关联发票主体ID',
`cash_type` tinyint(1) UNSIGNED NULL DEFAULT 1 COMMENT '付款方式:1现金 2转账 3微信支付 4支付宝 5信用卡 6支票 7其他',
`is_cash` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '是否直接到账:0否 1是',
`amount` decimal(15, 2) NULL DEFAULT 0.00 COMMENT '发票金额',
@@ -583,17 +581,20 @@ CREATE TABLE `oa_invoice` (
`did` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '开发票部门',
`admin_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '发票申请人',
`check_admin_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '发票审核人',
+ `check_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '审核时间',
`open_admin_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '发票开具人',
+ `open_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '开票时间',
`type` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '抬头类型:1企业2个人',
+ `invoice_subject` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '关联发票主体ID',
`invoice_type` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '发票类型:1增值税专用发票2增值税普通发票',
- `invoice_title` varchar(100) NOT NULL DEFAULT '' COMMENT '纳税人名称',
+ `invoice_title` varchar(100) NOT NULL DEFAULT '' COMMENT '开票抬头',
`invoice_phone` varchar(100) NOT NULL DEFAULT '' COMMENT '电话号码',
`invoice_tax` varchar(100) NOT NULL DEFAULT '' COMMENT '纳税人识别号',
`invoice_bank` varchar(100) NOT NULL DEFAULT '' COMMENT '开户银行',
`invoice_account` varchar(100) NOT NULL DEFAULT '' COMMENT '银行账号',
`invoice_banking` varchar(100) NOT NULL DEFAULT '' COMMENT '银行营业网点',
`invoice_address` varchar(100) NOT NULL DEFAULT '' COMMENT '地址',
- `invoice_status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '发票状态:0审核不通过 1审核中 2审核通过 3待开具 4已开具 5部分到账 6全部到账 10已作废',
+ `invoice_status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '发票状态:0审核不通过 1审核中 2待开具 3已开具 4部分到账 5全部到账 10已作废',
`check_remark` text NULL COMMENT '审核不通过的理由',
`remark` text NULL COMMENT '备注',
`status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态:-1删除 0禁用 1正常',