首页新增客户、项目统计

This commit is contained in:
hdm 2022-07-21 12:29:53 +08:00
parent 214d89dd98
commit 8f36f7905d

View File

@ -61,11 +61,13 @@ class Index extends BaseController
} }
foreach ($statistics as $key => $value) { foreach ($statistics as $key => $value) {
if (!$value ) unset($statistics[$key]); if (!$value) {
unset($statistics[$key]);
}
} }
return to_assign(0, 'ok', $statistics); return to_assign(0, 'ok', $statistics);
} } else {
else{
$admin = get_login_admin(); $admin = get_login_admin();
if (get_cache('menu' . $admin['id'])) { if (get_cache('menu' . $admin['id'])) {
$list = get_cache('menu' . $admin['id']); $list = get_cache('menu' . $admin['id']);
@ -95,8 +97,8 @@ class Index extends BaseController
$total = []; $total = [];
$adminCount = Db::name('Admin')->where('status', '1')->count(); $adminCount = Db::name('Admin')->where('status', '1')->count();
$approveCount = Db::name('Approve')->count(); $approveCount = Db::name('Approve')->count();
$expenseCount = Db::name('Expense')->count(); $expenseCount = Db::name('Expense')->where('status', '1')->count();
$invoiceCount = Db::name('Invoice')->count(); $invoiceCount = Db::name('Invoice')->where('status', '1')->count();
$total[] = array( $total[] = array(
'name' => '员工', 'name' => '员工',
'num' => $adminCount, 'num' => $adminCount,
@ -114,9 +116,23 @@ class Index extends BaseController
'num' => $invoiceCount, 'num' => $invoiceCount,
); );
$module = Db::name('AdminModule')->column('name'); $module = Db::name('AdminModule')->column('name');
if (in_array('customer', $module)) {
$customerCount = Db::name('Customer')->where([['delete_time', '=', 0]])->count();
$total[] = array(
'name' => '客户',
'num' => $customerCount,
);
}
if (in_array('contract', $module)) {
$contractCount = Db::name('Contract')->where([['delete_time', '=', 0]])->count();
$total[] = array(
'name' => '合同',
'num' => $contractCount,
);
}
if (in_array('project', $module)) { if (in_array('project', $module)) {
$projectCount = Db::name('Project')->where([['delete_time','>',0]])->count(); $projectCount = Db::name('Project')->where([['delete_time', '=', 0]])->count();
$taskCount = Db::name('ProjectTask')->where([['delete_time','>',0]])->count(); $taskCount = Db::name('ProjectTask')->where([['delete_time', '=', 0]])->count();
$total[] = array( $total[] = array(
'name' => '项目', 'name' => '项目',
'num' => $projectCount, 'num' => $projectCount,
@ -127,7 +143,7 @@ class Index extends BaseController
); );
} }
if (in_array('article', $module)) { if (in_array('article', $module)) {
$articleCount = Db::name('Article')->where([['delete_time','>',0]])->count(); $articleCount = Db::name('Article')->where([['delete_time', '=', 0]])->count();
$total[] = array( $total[] = array(
'name' => '文章', 'name' => '文章',
'num' => $articleCount, 'num' => $articleCount,