public function render($data) { $data['class'] = $data['style'] == 1 ? 'span12' : 'span6'; $limit = $data['limit'] > 0 ? intval($data['limit']) : 10; $data['list'] = D('KnowledgeView')->order('knowledge_id desc')->limit($limit)->select(); $userRole = M('userRole'); foreach ($data['list'] as $k => $v) { $data['list'][$k]['owner'] = getUserByRoleId($v['role_id']); } return $this->renderFile("index", $data); }
public function render($data) { $data['class'] = $data['style'] == 1 ? 'span12' : 'span6'; $limit = $data['limit'] > 0 ? intval($data['limit']) : 10; $where['owner_role_id'] = session('role_id'); $list = M('Event')->where($where)->limit($limit)->select(); foreach ($list as $key => $value) { $list[$key]["owner"] = getUserByRoleId($value['owner_role_id']); } $data['list'] = $list; return $this->renderFile("index", $data); }
public function index() { $d_contacts = D('ContactsView'); $p = isset($_GET['p']) ? intval($_GET['p']) : 1; $by = isset($_GET['by']) ? trim($_GET['by']) : ''; $below_ids = getSubRoleId(false); $all_ids = getSubRoleId(); $where = array(); $params = array(); $order = "create_time desc"; if ($_GET['desc_order']) { $order = trim($_GET['desc_order']) . ' desc'; } elseif ($_GET['asc_order']) { $order = trim($_GET['asc_order']) . ' asc'; } switch ($by) { case 'today': $where['create_time'] = array('gt', strtotime(date('Y-m-d', time()))); break; case 'week': $where['create_time'] = array('gt', strtotime(date('Y-m-d', time())) - (date('N', time()) - 1) * 86400); break; case 'month': $where['create_time'] = array('gt', strtotime(date('Y-m-01', time()))); break; case 'add': $order = 'create_time desc'; break; case 'update': $order = 'update_time desc'; break; case 'deleted': $where['is_deleted'] = 1; break; default: $where['owner_role_id'] = array('in', $all_ids); break; } if (!isset($where['owner_role_id'])) { $where['owner_role_id'] = array('in', $all_ids); } if (!isset($where['is_deleted'])) { $where['is_deleted'] = 0; } if ($_REQUEST["field"]) { $field = trim($_REQUEST['field']) == 'all' ? 'name|telephone|email|address|post|department|description' : $_REQUEST['field']; $search = empty($_REQUEST['search']) ? '' : trim($_REQUEST['search']); $condition = empty($_REQUEST['condition']) ? 'is' : trim($_REQUEST['condition']); if ('create_time' == $field || 'update_time' == $field) { $search = is_numeric($search) ? $search : strtotime($search); } switch ($condition) { case "is": $where[$field] = array('eq', $search); break; case "isnot": $where[$field] = array('neq', $search); break; case "contains": $where[$field] = array('like', '%' . $search . '%'); break; case "not_contain": $where[$field] = array('notlike', '%' . $search . '%'); break; case "start_with": $where[$field] = array('like', $search . '%'); break; case "end_with": $where[$field] = array('like', '%' . $search); break; case "is_empty": $where[$field] = array('eq', ''); break; case "is_not_empty": $where[$field] = array('neq', ''); break; case "gt": $where[$field] = array('gt', $search); break; case "egt": $where[$field] = array('egt', $search); break; case "lt": $where[$field] = array('lt', $search); break; case "elt": $where[$field] = array('elt', $search); break; case "eq": $where[$field] = array('eq', $search); break; case "neq": $where[$field] = array('neq', $search); break; case "between": $where[$field] = array('between', array($search - 1, $search + 86400)); break; case "nbetween": $where[$field] = array('not between', array($search, $search + 86399)); break; case "tgt": $where[$field] = array('gt', $search + 86400); break; default: $where[$field] = array('eq', $search); } $params = array('field=' . $field, 'condition=' . $condition, 'search=' . $_REQUEST["search"]); } if (trim($_GET['act']) == 'excel') { if (vali_permission('contacts', 'export')) { $order = $order ? $order : 'create_time desc'; $contactsList = $d_contacts->where($where)->order($order)->select(); $this->excelExport($contactsList); } else { alert('error', L('HAVE NOT PRIVILEGES'), $_SERVER['HTTP_REFERER']); } } else { $contactsList = $d_contacts->where($where)->order($order)->page($p . ',15')->select(); $count = $d_contacts->where($where)->count(); import("@.ORG.Page"); $Page = new Page($count, 15); if (!empty($_GET['by'])) { $params[] = "by=" . trim($_GET['by']); } $this->parameter = implode('&', $params); if ($_GET['desc_order']) { $params[] = "desc_order=" . trim($_GET['desc_order']); } elseif ($_GET['asc_order']) { $params[] = "asc_order=" . trim($_GET['asc_order']); } $Page->parameter = implode('&', $params); $this->assign('page', $Page->show()); if ($by == 'deleted') { foreach ($contactsList as $k => $v) { $contactsList[$k]["delete_role"] = getUserByRoleId($v['delete_role_id']); $contactsList[$k]["creator"] = getUserByRoleId($v['creator_role_id']); } } else { foreach ($contactsList as $k => $v) { $contactsList[$k]["creator"] = getUserByRoleId($v['creator_role_id']); } } //获取下级和自己的岗位列表,搜索用 $d_role_view = D('RoleView'); $this->role_list = $d_role_view->where('role.role_id in (%s)', implode(',', $below_ids))->select(); $this->assign('contactsList', $contactsList); $this->alert = parseAlert(); $this->display(); } }
public function getRoleList() { $idArray = getSubRoleId(); $roleList = array(); foreach ($idArray as $roleId) { $roleList[$roleId] = getUserByRoleId($roleId); } $this->ajaxReturn($roleList, '', 1); }
public function changeContent() { if ($this->isAjax()) { $contract = D('ContractView'); $where = array(); $where['contract.is_deleted'] = 0; $where['contract.owner_role_id'] = array('in', implode(',', getSubRoleId())); if ($_REQUEST["field"]) { if (trim($_REQUEST['field']) == "all") { $field = is_numeric(trim($_REQUEST['search'])) ? 'number|price|contract.description' : 'number|contract.description'; } else { $field = trim($_REQUEST['field']); } $search = empty($_REQUEST['search']) ? '' : trim($_REQUEST['search']); $condition = empty($_REQUEST['condition']) ? 'is' : trim($_REQUEST['condition']); if ('create_time' == $field || 'update_time' == $field || 'due_date' == $field) { $search = is_numeric($search) ? $search : strtotime($search); } switch ($condition) { case "is": $where['contract.' . $field] = array('eq', $search); break; case "isnot": $where['contract.' . $field] = array('neq', $search); break; case "contains": $where['contract.' . $field] = array('like', '%' . $search . '%'); break; case "not_contain": $where['contract.' . $field] = array('notlike', '%' . $search . '%'); break; case "start_with": $where['contract.' . $field] = array('like', $search . '%'); break; case "end_with": $where['contract.' . $field] = array('like', '%' . $search); break; case "is_empty": $where['contract.' . $field] = array('eq', ''); break; case "is_not_empty": $where['contract.' . $field] = array('neq', ''); break; case "gt": $where['contract.' . $field] = array('gt', $search); break; case "egt": $where['contract.' . $field] = array('egt', $search); break; case "lt": $where['contract.' . $field] = array('lt', $search); break; case "elt": $where['contract.' . $field] = array('elt', $search); break; case "eq": $where['contract.' . $field] = array('eq', $search); break; case "neq": $where['contract.' . $field] = array('neq', $search); break; case "between": $where['contract.' . $field] = array('between', array($search - 1, $search + 86400)); break; case "nbetween": $where['contract.' . $field] = array('not between', array($search, $search + 86399)); break; case "tgt": $where['contract.' . $field] = array('gt', $search + 86400); break; default: $where[$field] = array('eq', $search); } } $p = !$_REQUEST['p'] || $_REQUEST['p'] <= 0 ? 1 : intval($_REQUEST['p']); $list = $contract->where($where)->page($p . ',10')->order('contract.create_time desc')->select(); $count = $contract->where($where)->count(); foreach ($list as $key => $value) { $list[$key]['owner'] = getUserByRoleId($value['owner_role_id']); $list[$key]['creator'] = getUserByRoleId($value['creator_role_id']); $list[$key]['deletor'] = getUserByRoleId($value['delete_role_id']); } $data['list'] = $list; $data['p'] = $p; $data['count'] = $count; $data['total'] = $count % 10 > 0 ? ceil($count / 10) : $count / 10; $this->ajaxReturn($data, "", 1); } }
public function analytics() { $m_leads = M('leads'); if ($_GET['role']) { $role_id = intval($_GET['role']); } else { $role_id = 'all'; } if ($_GET['department'] && $_GET['department'] != 'all') { $department_id = intval($_GET['department']); } else { $department_id = D('RoleView')->where('role.role_id = %d', session('role_id'))->getField('department_id'); } if ($_GET['start_time']) { $start_time = strtotime(date('Y-m-d', strtotime($_GET['start_time']))); } $end_time = $_GET['end_time'] ? strtotime(date('Y-m-d 23:59:59', strtotime($_GET['end_time']))) : strtotime(date('Y-m-d 23:59:59', time())); if ($role_id == "all") { $roleList = getRoleByDepartmentId($department_id); $role_id_array = array(); foreach ($roleList as $v2) { $role_id_array[] = $v2['role_id']; } $where_source['creator_role_id'] = array('in', implode(',', $role_id_array)); $where_status['owner_role_id'] = array('in', implode(',', $role_id_array)); } else { $where_source['creator_role_id'] = $role_id; $where_status['owner_role_id'] = $role_id; } if ($start_time) { $where_source['create_time'] = array(array('elt', $end_time), array('egt', $start_time), 'and'); $where_status['create_time'] = array(array('elt', $end_time), array('egt', $start_time), 'and'); } else { $where_source['create_time'] = array('elt', $end_time); $where_status['create_time'] = array('elt', $end_time); } //线索来源统计 $setting = M('Fields')->where("model = 'leads' and field = 'source'")->getField('setting'); $setting_str = '$revenueList=' . $setting . ';'; //eval($setting_str); $source_count_array = array(); $sourceList = M('leads')->field('count(1) as num , source')->group('source')->where($where_source)->select(); foreach ($sourceList as $v) { $source = $v['source'] ? $v['source'] : L('OTHER'); $source_count[$source] = $v['num']; } foreach ($revenueList['data'] as $v) { if ($source_count[$v]) { $source_count_array[] = '["' . $v . '",' . $source_count[$v] . ']'; } else { $source_count_array[] = '["' . $v . '",0]'; } } $this->source_count = implode(',', $source_count_array); //Statistics Content $role_id_array = array(); if ($role_id == "all") { if ($department_id != "all") { if (session('?admin')) { $roleList = M('role')->where('user_id <> 0')->getField('role_id', true); } else { $roleList = getRoleByDepartmentId($department_id); } //$roleList = getRoleByDepartmentId($department_id); foreach ($roleList as $v) { $role_id_array[] = $v; } } else { $role_id_array = getSubRoleId(); } } else { $role_id_array[] = $role_id; } if ($start_time) { $create_time = array(array('elt', $end_time), array('egt', $start_time), 'and'); } else { $create_time = array('elt', $end_time); } $add_count_total = 0; $own_count_total = 0; $success_count_total = 0; $deal_count_total = 0; foreach ($role_id_array as $v) { $user = getUserByRoleId($v); $add_count = $m_leads->where(array('is_deleted' => 0, 'creator_role_id' => $v, 'create_time' => $create_time))->count(); $own_count = $m_leads->where(array('is_deleted' => 0, 'owner_role_id' => $v, 'create_time' => $create_time))->count(); $success_count = $m_leads->where(array('is_deleted' => 0, 'is_transformed' => 1, 'owner_role_id' => $v, 'create_time' => $create_time))->count(); $deal_count = $m_leads->where('is_deleted = 0 and owner_role_id = %d and is_transformed != 1 and update_time>create_time', $v)->count(); $reportList[] = array("user" => $user, "add_count" => $add_count, "own_count" => $own_count, "success_count" => $success_count, "deal_count" => $deal_count); $add_count_total += $add_count; $own_count_total += $own_count; $success_count_total += $success_count; $deal_count_total += $deal_count; } $this->total_report = array("add_count" => $add_count_total, "own_count" => $own_count_total, "success_count" => $success_count_total, "deal_count" => $deal_count_total); $this->reportList = $reportList; if (session('?admin')) { $idArray = M('role')->where('user_id <> 0')->getField('role_id', true); } else { $idArray = getSubRoleId(); } $roleList = array(); foreach ($idArray as $roleId) { $roleList[$roleId] = getUserByRoleId($roleId); } $this->roleList = $roleList; $departments = M('roleDepartment')->select(); $departmentList[] = M('roleDepartment')->where('department_id = %d', session('department_id'))->find(); $departmentList = array_merge($departmentList, getSubDepartment(session('department_id'), $departments, '')); $this->assign('departmentList', $departmentList); $this->alert = parseAlert(); $this->display(); }
/** *商机统计 * **/ public function analytics() { $m_business = M('Business'); if ($_GET['role']) { $role_id = intval($_GET['role']); } else { $role_id = 'all'; } if ($_GET['department'] && $_GET['department'] != 'all') { $department_id = intval($_GET['department']); } else { $department_id = D('RoleView')->where('role.role_id = %d', session('role_id'))->getField('department_id'); } if ($_GET['start_time']) { $start_time = strtotime(date('Y-m-d', strtotime($_GET['start_time']))); } $end_time = $_GET['end_time'] ? strtotime(date('Y-m-d 23:59:59', strtotime($_GET['end_time']))) : strtotime(date('Y-m-d 23:59:59', time())); if ($role_id == "all") { $roleList = getRoleByDepartmentId($department_id); $role_id_array = array(); foreach ($roleList as $v2) { $role_id_array[] = $v2['role_id']; } $where_source['creator_role_id'] = array('in', implode(',', $role_id_array)); $where_status['owner_role_id'] = array('in', implode(',', $role_id_array)); $where_money['owner_role_id'] = array('in', implode(',', $role_id_array)); $where_day_create['creator_role_id'] = array('in', implode(',', $role_id_array)); $where_day_success['owner_role_id'] = array('in', implode(',', $role_id_array)); } else { $where_source['creator_role_id'] = $role_id; $where_status['owner_role_id'] = $role_id; $where_money['owner_role_id'] = $role_id; $where_day_create['creator_role_id'] = array('in', implode(',', $role_id_array)); $where_day_success['owner_role_id'] = array('in', implode(',', $role_id_array)); } if ($start_time) { $where_source['create_time'] = array(array('lt', $end_time), array('gt', $start_time), 'and'); $where_status['create_time'] = array(array('lt', $end_time), array('gt', $start_time), 'and'); $where_money['create_time'] = array(array('lt', $end_time), array('gt', $start_time), 'and'); } else { $where_source['create_time'] = array('lt', $end_time); $where_status['create_time'] = array('lt', $end_time); $where_money['create_time'] = array('lt', $end_time); } //统计表内容 $role_id_array = array(); if ($role_id == "all") { if ($department_id != "all") { if (session('?admin')) { $roleList = M('role')->where('user_id <> 0')->getField('role_id', true); } else { $roleList = getRoleByDepartmentId($department_id); } foreach ($roleList as $v) { $role_id_array[] = $v; } } else { $role_id_array = getSubRoleId(); } } else { $role_id_array[] = $role_id; } if ($start_time) { $create_time = array(array('lt', $end_time), array('gt', $start_time), 'and'); } else { $create_time = array('lt', $end_time); } $add_count_total = 0; $own_count_total = 0; $success_count_total = 0; $deal_count_total = 0; foreach ($role_id_array as $v) { $user = getUserByRoleId($v); $add_count = $m_business->where(array('is_deleted' => 0, 'creator_role_id' => $v, 'create_time' => $create_time))->count(); $own_count = $m_business->where(array('is_deleted' => 0, 'owner_role_id' => $v, 'create_time' => $create_time))->count(); $success_count = $m_business->where(array('is_deleted' => 0, 'status_id' => 100, 'owner_role_id' => $v, 'create_time' => $create_time))->count(); $deal_count = $m_business->where('is_deleted = 0 and status_id not in(99,100) and owner_role_id = %d and update_time>create_time', $v)->count(); $reportList[] = array("user" => $user, "add_count" => $add_count, "own_count" => $own_count, "success_count" => $success_count, "deal_count" => $deal_count); $add_count_total += $add_count; $own_count_total += $own_count; $success_count_total += $success_count; $deal_count_total += $deal_count; } //商机来源统计图 $source_count_array = array(); $setting = M('Fields')->where("model = 'business' and field = 'origin'")->getField('setting'); $setting_str = '$sourceList=' . $setting . ';'; eval($setting_str); $where_source['is_deleted'] = 0; $source_total_count = 0; foreach ($sourceList['data'] as $v) { unset($where_source['origin']); $where_source['origin'] = $v; $target_count = $m_business->where($where_source)->count(); $source_count_array[] = '[' . '"' . $v . '",' . $target_count . ']'; $source_total_count += $target_count; } $source_count_array[] = '["' . L('OTHER') . '",' . ($add_count_total - $source_total_count) . ']'; $this->source_count = implode(',', $source_count_array); //商机阶段统计图 $status_count_array = array(); $statusList = M('BusinessStatus')->order('order_id desc')->where('status_id <> 99')->select(); $where_status['is_deleted'] = 0; $temp_count = 0; foreach ($statusList as $v) { unset($where_status['status_id']); $where_status['status_id'] = $v['status_id']; $target_count = $m_business->where($where_status)->count(); $status_count_array[] = '[' . '"' . $v['name'] . '",' . ($target_count + $temp_count) . ']'; $temp_count += $target_count; } $this->status_count = implode(',', array_reverse($status_count_array)); /*时间序列图(按日)*/ if ($end_time - 86400 * 30 > $start_time) { $this_time = $end_time - 86400 * 30; } else { $this_time = $start_time; } while (date('Y-m-d', $this_time) <= date('Y-m-d', $end_time)) { $day_count_array[] = "'" . date('Y/m/d', $this_time) . "'"; $time1 = strtotime(date('Y-m-d', $this_time)); $time2 = $time1 + 86400; $where_day_create['create_time'] = array(array('lt', $time2), array('gt', $time1), 'and'); $day_create_count_array[] = $m_business->where($where_day_create)->count(); $where_day_success['update_time'] = array(array('lt', $time2), array('gt', $time1), 'and'); $where_day_success['status_id'] = 100; $day_success_count_array[] = $m_business->where($where_day_success)->count(); $this_time += 86400; } $this->day_count = implode(',', $day_count_array); $this->day_create_count = implode(',', $day_create_count_array); $this->day_success_count = implode(',', $day_success_count_array); /*时间序列图(按周)*/ if ($end_time - 86400 * 365 > $start_time) { $this_time = $end_time - 86400 * 365 - 86400 * date('w'); } else { $this_time = $start_time - 86400 * date('w'); } while (date('Y-m-d', $this_time) <= date('Y-m-d', $end_time)) { $week_count_array[] = "'" . date('Y', $this_time) . ' s' . date('W', $this_time) . "'"; $time1 = strtotime(date('Y-m-d', $this_time)); $time2 = $time1 + 86400 * 7; $where_week_create['create_time'] = array(array('lt', $time2), array('gt', $time1), 'and'); $week_create_count_array[] = $m_business->where($where_week_create)->count(); $where_week_success['update_time'] = array(array('lt', $time2), array('gt', $time1), 'and'); $where_week_success['status_id'] = 100; $week_success_count_array[] = $m_business->where($where_week_success)->count(); $this_time += 86400 * 7; } $this->week_count = implode(',', $week_count_array); $this->week_create_count = implode(',', $week_create_count_array); $this->week_success_count = implode(',', $week_success_count_array); /*时间序列图(按月)*/ if ($end_time - 86400 * 365 > $start_time) { $this_time = $end_time - 86400 * 365; } else { $this_time = $start_time; } while (date('Y-m-d', $this_time) <= date('Y-m-d', $end_time)) { $month_count_array[] = "'" . date('Y/m', $this_time) . "'"; $time1 = strtotime(date('Y-m', $this_time)); $time2 = mktime(0, 0, 0, date('m', $this_time) + 1, 1, date('Y', $this_time)); $where_month_create['create_time'] = array(array('lt', $time2), array('gt', $time1), 'and'); $month_create_count_array[] = $m_business->where($where_month_create)->count(); $where_month_success['update_time'] = array(array('lt', $time2), array('gt', $time1), 'and'); $where_month_success['status_id'] = 100; $month_success_count_array[] = $m_business->where($where_month_success)->count(); $this_time = mktime(date('H', $this_time), date('i', $this_time), date('s', $this_time), date('m', $this_time) + 1, date('d', $this_time), date('Y', $this_time)); } $this->month_count = implode(',', $month_count_array); $this->month_create_count = implode(',', $month_create_count_array); $this->month_success_count = implode(',', $month_success_count_array); $max_money = $m_business->where($where_money)->Max('total_price'); $min_money = $m_business->where($where_money)->Min('total_price'); if ($max_money == $min_money) { $target_count = $m_business->where($where_money)->count(); $money_count_array[] = '["' . $max_money . L('YUAN') . '",' . $target_count . ']'; } else { $rank1 = round($min_money, 2); $rank2 = round($min_money + ($max_money - $min_money) * 0.25, 2); $rank3 = round($min_money + ($max_money - $min_money) * 0.5, 2); $rank4 = round($min_money + ($max_money - $min_money) * 0.75, 2); $rank5 = round($max_money, 2); $money_where = array(array('name' => $rank1 . '~' . $rank2 . L('YUAN'), 'where_money' => array(array('elt', $rank2), array('egt', $rank1), 'and')), array('name' => $rank2 . '~' . $rank3 . L('YUAN'), 'where_money' => array(array('elt', $rank3), array('gt', $rank2), 'and')), array('name' => $rank3 . '~' . $rank4 . L('YUAN'), 'where_money' => array(array('elt', $rank4), array('gt', $rank3), 'and')), array('name' => $rank4 . '~' . $rank5 . L('YUAN'), 'where_money' => array(array('elt', $rank5), array('egt', $rank4), 'and'))); $money_count_array = array(); foreach ($money_where as $v) { $where_money['total_price'] = $v['where_money']; $target_count = $m_business->where($where_money)->count(); $money_count_array[] = '[' . '"' . $v['name'] . '",' . $target_count . ']'; } } $this->money_count = implode(',', $money_count_array); $this->total_report = array("add_count" => $add_count_total, "own_count" => $own_count_total, "success_count" => $success_count_total, "deal_count" => $deal_count_total); $this->reportList = $reportList; if (session('?admin')) { $idArray = M('role')->where('user_id <> 0')->getField('role_id', true); } else { $idArray = getSubRoleId(); } $roleList = array(); foreach ($idArray as $roleId) { $roleList[$roleId] = getUserByRoleId($roleId); } $this->roleList = $roleList; $departments = M('roleDepartment')->select(); $departmentList[] = M('roleDepartment')->where('department_id = %d', session('department_id'))->find(); $departmentList = array_merge($departmentList, getSubDepartment(session('department_id'), $departments, '')); $this->assign('departmentList', $departmentList); $this->alert = parseAlert(); $this->display(); }
public function index() { $m_log = M('ActionLog'); $by = isset($_GET['by']) ? trim($_GET['by']) : ''; $where = array(); $params = array(); $order = "create_time desc"; if ($_GET['desc_order']) { $order = trim($_GET['desc_order']) . ' desc'; } elseif ($_GET['asc_order']) { $order = trim($_GET['asc_order']) . ' asc'; } $all_ids = getSubRoleId(); switch ($by) { case 'today': $where['create_time'] = array('gt', strtotime(date('Y-m-d', time()))); break; case 'week': $where['create_time'] = array('gt', strtotime(date('Y-m-d', time())) - (date('N', time()) - 1) * 86400); break; case 'month': $where['create_time'] = array('gt', strtotime(date('Y-m-01', time()))); break; case 'me': $where['role_id'] = session('role_id'); break; case 'add': $order = 'create_time desc'; break; } if (!isset($where['role_id'])) { $where['role_id'] = array('in', implode(',', getSubRoleId())); } if (trim($_GET['module'])) { $where['module_name'] = trim($_GET['module']); } if (trim($_GET['act'])) { $where['action_name'] = trim($_GET['act']); } if ($_REQUEST["field"]) { $field = trim($_REQUEST['field']) == 'all' ? 'subject|content' : $_REQUEST['field']; $search = empty($_REQUEST['search']) ? '' : trim($_REQUEST['search']); $condition = empty($_REQUEST['condition']) ? 'eq' : trim($_REQUEST['condition']); if ('create_time' == $field) { $search = strtotime($search); } $params = array('field=' . $_REQUEST['field'], 'condition=' . $condition, 'search=' . trim($_REQUEST["search"])); switch ($_REQUEST['condition']) { case "is": $where[$field] = array('eq', $search); break; case "isnot": $where[$field] = array('neq', $search); break; case "contains": $where[$field] = array('like', '%' . $search . '%'); break; case "not_contain": $where[$field] = array('notlike', '%' . $search . '%'); break; case "start_with": $where[$field] = array('like', $search . '%'); break; case "end_with": $where[$field] = array('like', '%' . $search); break; case "is_empty": $where[$field] = array('eq', ''); break; case "is_not_empty": $where[$field] = array('neq', ''); break; case "gt": $where[$field] = array('gt', $search); break; case "egt": $where[$field] = array('egt', $search); break; case "lt": $where[$field] = array('lt', $search); break; case "elt": $where[$field] = array('elt', $search); break; case "eq": $where[$field] = array('eq', $search); break; case "neq": $where[$field] = array('neq', $search); break; case "between": $where[$field] = array('between', array($search - 1, $search + 86400)); break; case "nbetween": $where[$field] = array('not between', array($search, $search + 86399)); break; case "tgt": $where[$field] = array('gt', $search + 86400); break; default: $where[$field] = array('eq', $search); } } $p = isset($_GET['p']) ? intval($_GET['p']) : 1; $list = $m_log->where($where)->page($p . ',10')->order($order)->select(); $count = $m_log->where($where)->count(); foreach ($list as $k => $v) { $param_name = ''; if (!empty($v['param_name'])) { $param_name = $v['param_name']; } if ($v['module_name'] == 'finance') { $module_name = substr($v['param_name'], 2); } else { $module_name = $v['module_name']; } $m_module_name = M($module_name); $id = $m_module_name->getPk(); $name = $m_module_name->where("{$id} = %d", $v['action_id'])->getField('name'); if (empty($name)) { $name = $m_module_name->where("{$id} = %d", $v['action_id'])->getField('subject'); } $list[$k]['content'] = $v['content'] . '---<a href="./index.php?m=' . $v[module_name] . '&a=view&' . $param_name . '&id=' . $v[action_id] . '">' . $name . '</a>'; } import("@.ORG.Page"); $Page = new Page($count, 10); if (!empty($_REQUEST['by'])) { $params['by'] = 'by=' . trim($_REQUEST['by']); } if (!empty($_REQUEST['module'])) { $params['module'] = 'module=' . trim($_REQUEST['module']); } if (!empty($_REQUEST['act'])) { $params['act'] = 'act=' . trim($_REQUEST['act']); } $this->parameter = implode('&', $params); if ($_GET['desc_order']) { $params[] = "desc_order=" . trim($_GET['desc_order']); } elseif ($_GET['asc_order']) { $params[] = "asc_order=" . trim($_GET['asc_order']); } $Page->parameter = implode('&', $params); $show = $Page->show(); $this->assign('page', $show); foreach ($list as $k => $v) { $list[$k]['creator'] = getUserByRoleId($v['role_id']); } $d_role_view = D('RoleView'); $this->role_list = $d_role_view->where('role.role_id in (%s)', implode(',', $below_ids))->select(); $this->assign('list', $list); $this->alert = parseAlert(); $this->display(); }
public function analytics() { $m_customer = M('Customer'); if ($_GET['role']) { $role_id = intval($_GET['role']); } else { $role_id = 'all'; } if ($_GET['department'] && $_GET['department'] != 'all') { $department_id = intval($_GET['department']); } else { $department_id = D('RoleView')->where('role.role_id = %d', session('role_id'))->getField('department_id'); } if ($_GET['start_time']) { $start_time = strtotime(date('Y-m-d', strtotime($_GET['start_time']))); } $end_time = $_GET['end_time'] ? strtotime(date('Y-m-d 23:59:59', strtotime($_GET['end_time']))) : strtotime(date('Y-m-d 23:59:59', time())); if ($role_id == "all") { $roleList = getRoleByDepartmentId($department_id); $role_id_array = array(); foreach ($roleList as $v2) { $role_id_array[] = $v2['role_id']; } $where_role_id = array('in', implode(',', $role_id_array)); $where_source['creator_role_id'] = $where_role_id; $where_industry['owner_role_id'] = $where_role_id; $where_renenue['creator_role_id'] = $where_role_id; $where_employees['creator_role_id'] = $where_role_id; } else { $where_source['creator_role_id'] = $role_id; $where_industry['owner_role_id'] = $role_id; $where_renenue['creator_role_id'] = $role_id; $where_employees['creator_role_id'] = $role_id; } if ($start_time) { $where_create_time = array(array('elt', $end_time), array('egt', $start_time), 'and'); $where_source['create_time'] = $where_create_time; $where_industry['create_time'] = $where_create_time; $where_renenue['create_time'] = $where_create_time; $where_employees['create_time'] = $where_create_time; } else { $where_source['create_time'] = array('elt', $end_time); $where_industry['create_time'] = array('elt', $end_time); $where_renenue['create_time'] = array('elt', $end_time); $where_employees['create_time'] = array('elt', $end_time); } //统计表内容 $role_id_array = array(); if ($role_id == "all") { if ($_GET['department'] != 'all') { if (session('?admin')) { $roleList = M('role')->where('user_id <> 0')->getField('role_id', true); } else { $roleList = getRoleByDepartmentId($department_id); } foreach ($roleList as $v) { $role_id_array[] = $v; } } else { $role_id_array = getSubRoleId(); } } else { $role_id_array[] = $role_id; } if ($start_time) { $create_time = array(array('elt', $end_time), array('egt', $start_time), 'and'); } else { $create_time = array('elt', $end_time); } $add_count_total = 0; $own_count_total = 0; $success_count_total = 0; $deal_count_total = 0; $busi_customer_array = M('Business')->getField('customer_id', true); $busi_customer_id = implode(',', $busi_customer_array); foreach ($role_id_array as $v) { $user = getUserByRoleId($v); $add_count = $m_customer->where(array('is_deleted' => 0, 'creator_role_id' => $v, 'create_time' => $create_time))->count(); $own_count = $m_customer->where(array('is_deleted' => 0, 'owner_role_id' => $v, 'create_time' => $create_time))->count(); $success_count = $m_customer->where(array('is_deleted' => 0, 'customer_id' => array('in', $busi_customer_id), 'owner_role_id' => $v, 'create_time' => $create_time))->count(); $reportList[] = array("user" => $user, "add_count" => $add_count, "own_count" => $own_count, "success_count" => $success_count); $add_count_total += $add_count; $own_count_total += $own_count; $success_count_total += $success_count; } //来源统计图 $source_count_array = array(); $setting = M('Fields')->where("model = 'customer' and field = 'origin'")->getField('setting'); $setting_str = '$sourceList=' . $setting . ';'; eval($setting_str); $source_total_count = 0; foreach ($sourceList[data] as $v) { unset($where_source['origin']); $where_source['origin'] = $v; $target_count = $m_customer->where($where_source)->count(); $source_count_array[] = '[' . '"' . $v . '",' . $target_count . ']'; $source_total_count += $target_count; } $source_count_array[] = '["' . L('OTHER') . '",' . ($add_count_total - $source_total_count) . ']'; $this->source_count = implode(',', $source_count_array); //客户行业统计图 $industry_count_array = array(); $setting = M('Fields')->where("model = 'customer' and field = 'industry'")->getField('setting'); $setting_str = '$industryList=' . $setting . ';'; eval($setting_str); $where_industry['is_deleted'] = 0; $industry_total_count = 0; foreach ($industryList['data'] as $v) { unset($where_employees['industry']); $where_industry['industry'] = $v; $target_count = $m_customer->where($where_industry)->count(); $industry_total_count += $target_count; $industry_count_array[] = '["' . $v . '",' . $target_count . ']'; } $industry_count_array[] = '["' . L('OTHER') . '",' . ($add_count_total - $industry_total_count) . ']'; $this->industry_count = implode(',', $industry_count_array); //客户员工数统计 $employees_count_array = array(); $setting = M('Fields')->where("model = 'customer' and field = 'no_of_employees'")->getField('setting'); $setting_str = '$no_List=' . $setting . ';'; eval($setting_str); $where_employees['is_deleted'] = 0; $no_total_count = 0; foreach ($no_List['data'] as $v) { unset($where_employees['no_of_employees']); $where_employees['no_of_employees'] = $v; $target_count = $m_customer->where($where_employees)->count(); $no_total_count += $target_count; $employees_count_array[] = '["' . $v . '",' . $target_count . ']'; } $employees_count_array[] = '["' . L('OTHER') . '",' . ($add_count_total - $no_total_count) . ']'; $this->employees_count = implode(',', $employees_count_array); //客户营业额统计 $revenue_count_array = array(); $setting = M('Fields')->where("model = 'customer' and field = 'annual_revenue'")->getField('setting'); $setting_str = '$revenueList=' . $setting . ';'; eval($setting_str); $where_renenue['is_deleted'] = 0; $revenue_total_count = 0; foreach ($revenueList['data'] as $v) { unset($where_renenue['annual_revenue']); $where_renenue['annual_revenue'] = $v; $target_count = $m_customer->where($where_renenue)->count(); $revenue_count_array[] = '[' . '"' . $v . '",' . $target_count . ']'; $revenue_total_count += $target_count; } $revenue_count_array[] = '["' . L('OTHER') . '",' . ($add_count_total - $target_count) . ']'; $this->revenue_count = implode(',', $revenue_count_array); $this->total_report = array("add_count" => $add_count_total, "own_count" => $own_count_total, "success_count" => $success_count_total); $this->reportList = $reportList; if (session('?admin')) { $idArray = M('role')->where('user_id <> 0')->getField('role_id', true); } else { $idArray = getSubRoleId(); } $roleList = array(); foreach ($idArray as $roleId) { $roleList[$roleId] = getUserByRoleId($roleId); } $this->roleList = $roleList; $departments = M('roleDepartment')->select(); $departmentList[] = M('roleDepartment')->where('department_id = %d', session('department_id'))->find(); $departmentList = array_merge($departmentList, getSubDepartment(session('department_id'), $departments, '')); $this->assign('departmentList', $departmentList); $this->alert = parseAlert(); $this->display(); }
public function analytics() { $m_shoukuan = M('receivables'); $m_shoukuandan = M('receivingorder'); $m_fukuan = M('payables'); $m_fukuandan = M('paymentorder'); if ($_GET['role']) { $role_id = intval($_GET['role']); } else { $role_id = 'all'; } if ($_GET['department'] && $_GET['department'] != 'all') { $department_id = intval($_GET['department']); } else { $department_id = D('RoleView')->where('role.role_id = %d', session('role_id'))->getField('department_id'); } if ($_GET['start_time']) { $start_time = strtotime(date('Y-m-d', strtotime($_GET['start_time']))); } $end_time = $_GET['end_time'] ? strtotime(date('Y-m-d 23:59:59', strtotime($_GET['end_time']))) : strtotime(date('Y-m-d 23:59:59', time())); if ($role_id == "all") { $roleList = getRoleByDepartmentId($department_id); $role_id_array = array(); foreach ($roleList as $v2) { $role_id_array[] = $v2['role_id']; } $where_role_id = array('in', implode(',', $role_id_array)); $where_shoukuan['owner_role_id'] = $where_role_id; } else { $where_shoukuan['owner_role_id'] = $role_id; } $year = date('Y'); $moon = 1; $shoukuan_moon_count = array(); $fukuan_moon_count = array(); $shijishoukuan_moon_count = array(); $shijifukuan_moon_count = array(); while ($moon <= 12) { if ($moon == 12) { $where_shoukuan['pay_time'] = array(array('egt', strtotime($year . '-' . $moon . '-1')), array('lt', strtotime($year + 1 . '-1-1')), 'and'); } else { $where_shoukuan['pay_time'] = array(array('egt', strtotime($year . '-' . $moon . '-1')), array('lt', strtotime($year . '-' . ($moon + 1) . '-1')), 'and'); } $shoukuanList = $m_shoukuan->where($where_shoukuan)->select(); $fukuanList = $m_fukuan->where($where_shoukuan)->select(); $total_shoukuan_money = 0; $total_shijishoukuan_money = 0; foreach ($shoukuanList as $v) { $total_shoukuan_money += $v['price']; $shoukuandan_list = $m_shoukuandan->where('receivables_id = %d', $v['receivables_id'])->getField('money', true); foreach ($shoukuandan_list as $v2) { $total_shijishoukuan_money += $v2; } } $total_fukuan_money = 0; $total_shijifukuan_money = 0; foreach ($fukuanList as $v) { $total_fukuan_money += $v['price']; $fukuandan_list = $m_fukuandan->where('payables_id = %d', $v['payables_id'])->getField('money', true); foreach ($fukuandan_list as $v2) { $total_shijifukuan_money += $v2; } } $shoukuan_moon_count[] = $total_shoukuan_money; $shijishoukuan_moon_count[] = $total_shijishoukuan_money; $fukuan_moon_count[] = $total_fukuan_money; $shijifukuan_moon_count[] = $total_shijifukuan_money; $moon++; } $moon_count['shoukuan'] = '[' . implode(',', $shoukuan_moon_count) . ']'; $moon_count['shijishoukuan'] = '[' . implode(',', $shijishoukuan_moon_count) . ']'; $moon_count['fukuan'] = '[' . implode(',', $fukuan_moon_count) . ']'; $moon_count['shijifukuan'] = '[' . implode(',', $shijifukuan_moon_count) . ']'; $this->moon_count = $moon_count; $previous_year = $year - 1; $moon = 1; $shoukuan_thisyear_count = array(); $shoukuan_previousyear_count = array(); $fukuan_thisyear_count = array(); $fukuan_previousyear_count = array(); while ($moon <= 12) { if ($moon == 12) { $where_thisyear_shoukuan['pay_time'] = array(array('egt', strtotime($year . '-' . $moon . '-1')), array('lt', strtotime($year + 1 . '-1-1')), 'and'); $where_previousyear_shoukuan['pay_time'] = array(array('egt', strtotime($previous_year . '-' . $moon . '-1')), array('lt', strtotime($previous_year + 1 . '-1-1')), 'and'); } else { $where_thisyear_shoukuan['pay_time'] = array(array('egt', strtotime($year . '-' . $moon . '-1')), array('lt', strtotime($year . '-' . ($moon + 1) . '-1')), 'and'); $where_previousyear_shoukuan['pay_time'] = array(array('egt', strtotime($previous_year . '-' . $moon . '-1')), array('lt', strtotime($previous_year . '-' . ($moon + 1) . '-1')), 'and'); } $thisyear_shoukuanList = $m_shoukuan->where($where_thisyear_shoukuan)->select(); $previousyear_shoukuanList = $m_shoukuan->where($where_previousyear_shoukuan)->select(); $thisyear_fukuanList = $m_fukuan->where($where_thisyear_shoukuan)->select(); $previousyear_fukuanList = $m_fukuan->where($where_previousyear_shoukuan)->select(); $total_thisyear_shoukuan_count = 0; $total_previousyear_shoukuan_count = 0; foreach ($thisyear_shoukuanList as $v) { $total_thisyear_shoukuan_count += $v['price']; } foreach ($previousyear_shoukuanList as $v) { $total_previousyear_shoukuan_count += $v['price']; } $shoukuan_thisyear_count[] = $total_thisyear_shoukuan_count; $shoukuan_previousyear_count[] = $total_previousyear_shoukuan_count; $total_thisyear_fukuan_count = 0; $total_previousyear_fukuan_count = 0; foreach ($thisyear_fukuanList as $v) { $total_thisyear_fukuan_count += $v['price']; } foreach ($previousyear_fukuanList as $v) { $total_previousyear_fukuan_count += $v['price']; } $fukuan_thisyear_count[] = $total_thisyear_fukuan_count; $fukuan_previousyear_count[] = $total_previousyear_fukuan_count; $moon++; } $year_count['shoukuan_previousyear'] = '[' . implode(',', $shoukuan_previousyear_count) . ']'; $year_count['shoukuan_thisyear'] = '[' . implode(',', $shoukuan_thisyear_count) . ']'; $year_count['fukuan_previousyear'] = '[' . implode(',', $fukuan_previousyear_count) . ']'; $year_count['fukuan_thisyear'] = '[' . implode(',', $fukuan_thisyear_count) . ']'; $this->year_count = $year_count; //统计表内容 $role_id_array = array(); if ($role_id == "all") { if ($department_id != "all") { if (session('?admin')) { $roleList = M('role')->where('user_id <> 0')->getField('role_id', true); } else { $roleList = getRoleByDepartmentId($department_id); } foreach ($roleList as $v) { $role_id_array[] = $v; } } else { $role_id_array = getSubRoleId(); } } else { $role_id_array[] = $role_id; } if ($start_time) { $create_time = array(array('elt', $end_time), array('egt', $start_time), 'and'); } else { $create_time = array('elt', $end_time); } //应收款数 未收款 部分收款 应收金额 实际收款金额 应付款数 未付款 部分付款 应付金额 实际付款金额 $reportList = array(); $shoukuan_count_total = 0; $weishou_count_total = 0; $bufenshoukuan_count_total = 0; $shoukuan_money_total = 0; $yishou_money_total = 0; $shoukuandan_count_total = 0; $fukuan_count_total = 0; $weifu_count_total = 0; $bufenfukuan_count_total = 0; $fukuan_money_total = 0; $yifu_money_total = 0; $fukuandan_count_total = 0; foreach ($role_id_array as $v) { $user = getUserByRoleId($v); $shoukuan_count = 0; $weishou_count = 0; $bufenshoukuan_count = 0; $shoukuan_money = 0; $yishou_money = 0; $shoukuandan_count = 0; $fukuan_count = 0; $weifu_count = 0; $bufenfukuan_count = 0; $fukuan_money = 0; $yifu_money = 0; $fukuandan_count = 0; $shoukuan_count = $m_shoukuan->where(array('is_deleted' => 0, 'owner_role_id' => $v, 'pay_time' => $create_time))->count(); $weishou_count = $m_shoukuan->where(array('is_deleted' => 0, 'status' => 0, 'owner_role_id' => $v, 'pay_time' => $create_time))->count(); $bufenshoukuan_count = $m_shoukuan->where(array('is_deleted' => 0, 'status' => 1, 'owner_role_id' => $v, 'pay_time' => $create_time))->count(); $shoukuandan_count = $m_shoukuandan->where(array('is_deleted' => 0, 'owner_role_id' => $v, 'pay_time' => $create_time))->count(); $shoukuan_money = round($m_shoukuan->where(array('is_deleted' => 0, 'owner_role_id' => $v, 'pay_time' => $create_time))->sum('price'), 2); $shoukuan_id_array = $m_shoukuan->where(array('is_deleted' => 0, 'owner_role_id' => $v, 'pay_time' => $create_time))->getField('receivables_id', true); $shijishoukuan_money = 0; foreach ($shoukuan_id_array as $v2) { $shoukuandan_list = $m_shoukuandan->where('status = 1 and is_deleted=0 and receivables_id = %d', $v2)->getField('money', true); foreach ($shoukuandan_list as $v3) { $shijishoukuan_money += $v3; } } $yishou_money = round($shijishoukuan_money, 2); $fukuan_count = $m_fukuan->where(array('is_deleted' => 0, 'owner_role_id' => $v, 'pay_time' => $create_time))->count(); $weifu_count = $m_fukuan->where(array('is_deleted' => 0, 'status' => 0, 'owner_role_id' => $v, 'pay_time' => $create_time))->count(); $bufenfukuan_count = $m_fukuan->where(array('is_deleted' => 0, 'status' => 1, 'owner_role_id' => $v, 'pay_time' => $create_time))->count(); $fukuandan_count = $m_fukuandan->where(array('is_deleted' => 0, 'owner_role_id' => $v, 'pay_time' => $create_time))->count(); $fukuan_money = $n = round($m_fukuan->where(array('is_deleted' => 0, 'owner_role_id' => $v, 'pay_time' => $create_time))->sum('price'), 2); $fukuan_id_array = $m_fukuan->where(array('is_deleted' => 0, 'owner_role_id' => $v, 'pay_time' => $create_time))->getField('payables_id', true); $shijifukuan_money = 0; foreach ($fukuan_id_array as $v4) { $fukuandan_list = $m_fukuandan->where('status = 1 and is_deleted=0 and payables_id = %d', $v4)->getField('money', true); foreach ($fukuandan_list as $v5) { $shijifukuan_money += $v5; } } $yifu_money = round($shijifukuan_money, 2); $reportList[] = array("user" => $user, "shoukuan_count" => $shoukuan_count, "shoukuan_money" => $shoukuan_money, "weishou_count" => $weishou_count, "bufenshoukuan_count" => $bufenshoukuan_count, "yishou_money" => $yishou_money, "shoukuandan_count" => $shoukuandan_count, "fukuan_count" => $fukuan_count, 'weifu_count' => $weifu_count, "bufenfukuan_count" => $bufenfukuan_count, "fukuan_money" => $fukuan_money, "yifu_money" => $yifu_money, "fukuandan_count" => $fukuandan_count); $shoukuan_count_total += $shoukuan_count; $weishou_count_total += $weishou_count; $bufenshoukuan_count_total += $bufenshoukuan_count; $shoukuan_money_total += $shoukuan_money; $yishou_money_total += $yishou_money; $shoukuandan_count_total += $shoukuandan_count; $fukuan_count_total += $fukuan_count; $weifu_count_total += $weifu_count; $bufenfukuan_count_total += $bufenfukuan_count; $fukuan_money_total += $fukuan_money; $yifu_money_total += $yifu_money; $fukuandan_count_total += $fukuandan_count; } $total_report = array("shoukuan_count" => $shoukuan_count_total, "weishou_count" => $weishou_count_total, "bufenshoukuan_count" => $bufenshoukuan_count_total, "shoukuan_money" => $shoukuan_money_total, "yishou_money" => $yishou_money_total, "shoukuandan_count" => $shoukuandan_count_total, "fukuan_count" => $fukuan_count_total, "weifu_count" => $weifu_count_total, "bufenfukuan_count" => $bufenfukuan_count_total, "fukuan_money" => $fukuan_money_total, "yifu_money" => $yifu_money_total, "fukuandan_count" => $fukuandan_count_total); $this->reportList = $reportList; $this->total_report = $total_report; if (session('?admin')) { $idArray = M('role')->where('user_id <> 0')->getField('role_id', true); } else { $idArray = getSubRoleId(); } $roleList = array(); foreach ($idArray as $roleId) { $roleList[$roleId] = getUserByRoleId($roleId); } $this->roleList = $roleList; $departments = M('roleDepartment')->select(); $departmentList[] = M('roleDepartment')->where('department_id = %d', session('department_id'))->find(); $departmentList = array_merge($departmentList, getSubDepartment(session('department_id'), $departments, '')); $this->assign('departmentList', $departmentList); $this->display(); }
public function analytics() { $m_task = M('Task'); if ($_GET['role']) { $role_id = intval($_GET['role']); } else { $role_id = 'all'; } if ($_GET['department'] && $_GET['department'] != 'all') { $department_id = intval($_GET['department']); } else { $department_id = D('RoleView')->where('role.role_id = %d', session('role_id'))->getField('department_id'); } if ($_GET['start_time']) { $start_time = strtotime($_GET['start_time']); } $end_time = $_GET['end_time'] ? strtotime($_GET['end_time']) : time(); if ($role_id == "all") { if (session('?admin')) { $roleList = M('role')->where('user_id <> 0')->getField('role_id', true); } else { $roleList = getRoleByDepartmentId($department_id); } //$roleList = getRoleByDepartmentId($department_id); $role_id_array = array(); foreach ($roleList as $v) { $role_id_array[] = '%,' . $v['role_id'] . ',%'; } $where_completion['owner_role_id'] = array('like', $role_id_array, 'or'); } else { $where_completion['owner_role_id'] = array('like', '%,' . $role_id . ',%'); } if ($start_time) { $where_create_time = array(array('lt', $end_time), array('gt', $start_time), 'and'); $where_completion['create_time'] = $where_create_time; } else { $where_completion['create_time'] = array('lt', $end_time); } $completion_count_array = array(); $statusList = array(L('NOT_START'), L('DELAY'), L('ONGOING'), L('COMPLETE')); $where_completion['is_deleted'] = 0; $where_completion['isclose'] = 0; foreach ($statusList as $v) { $where_completion['status'] = $v; $target_count = $m_task->where($where_completion)->count(); $completion_count_array[] = '[' . '"' . $v . '",' . $target_count . ']'; } $this->completion_count = implode(',', $completion_count_array); $role_id_array = array(); if ($role_id == "all") { if ($department_id != "all") { if (session('?admin')) { $roleList = M('role')->where('user_id <> 0')->getField('role_id', true); } else { $roleList = getRoleByDepartmentId($department_id); } //$roleList = getRoleByDepartmentId($department_id); foreach ($roleList as $v) { $role_id_array[] = $v; } } else { $role_id_array = getSubRoleId(); } } else { $role_id_array[] = $role_id; } if ($start_time) { $create_time = array(array('lt', $end_time), array('gt', $start_time), 'and'); } else { $create_time = array('lt', $end_time); } $own_count_total = 0; $new_count_total = 0; $late_count_total = 0; $deal_count_total = 0; $success_count_total = 0; $busi_customer_array = M('Business')->getField('customer_id', true); $busi_customer_id = implode(',', $busi_customer_array); foreach ($role_id_array as $v) { $user = getUserByRoleId($v); $owner_role_id = array('like', '%,' . $v . ',%'); $own_count = $m_task->where(array('is_deleted' => 0, 'isclose' => 0, 'owner_role_id' => $owner_role_id, 'create_date' => $create_time))->count(); $new_count = $m_task->where(array('is_deleted' => 0, 'isclose' => 0, 'status' => L('NOT_START'), 'owner_role_id' => $owner_role_id, 'create_date' => $create_time))->count(); $late_count = $m_task->where(array('is_deleted' => 0, 'isclose' => 0, 'status' => L('DELAY'), 'owner_role_id' => $owner_role_id, 'create_date' => $create_time))->count(); $deal_count = $m_task->where(array('is_deleted' => 0, 'isclose' => 0, 'status' => L('ONGOING'), 'owner_role_id' => $owner_role_id, 'create_date' => $create_time))->count(); $success_count = $m_task->where(array('is_deleted' => 0, 'isclose' => 0, 'status' => L('COMPLETE'), 'owner_role_id' => $owner_role_id, 'create_date' => $create_time))->count(); $reportList[] = array("user" => $user, "new_count" => $new_count, "late_count" => $late_count, "own_count" => $own_count, "success_count" => $success_count, "deal_count" => $deal_count); $late_count_total += $late_count; $own_count_total += $own_count; $success_count_total += $success_count; $deal_count_total += $deal_count; $new_count_total += $new_count; } $this->total_report = array("new_count" => $new_count_total, "late_count" => $late_count_total, "own_count" => $own_count_total, "success_count" => $success_count_total, "deal_count" => $deal_count_total); $this->reportList = $reportList; if (session('?admin')) { $idArray = M('role')->where('user_id <> 0')->getField('role_id', true); } else { $idArray = getSubRoleId(); } //$idArray = getSubRoleId(); $roleList = array(); foreach ($idArray as $roleId) { $roleList[$roleId] = getUserByRoleId($roleId); } $this->roleList = $roleList; $departments = M('roleDepartment')->select(); $department_id = D('RoleView')->where('role.role_id = %d', session('role_id'))->getField('department_id'); $departmentList[] = M('roleDepartment')->where('department_id = %d', $department_id)->find(); $departmentList = array_merge($departmentList, getSubDepartment($department_id, $departments, '')); $this->assign('departmentList', $departmentList); $this->display(); }
/** *任务日志 * **/ public function tasklog() { $value = unserialize(M('config')->where('name = "defaultinfo"')->getField('value')); if ($this->isPost()) { $module = $_POST['module']; $task_id = $_POST['task_id']; $m_log = M('Log'); $m_file = M('File'); $m_log->create(); $m_log->category_id = 1; $m_log->create_date = time(); $m_log->update_date = time(); if (array_sum($_FILES['file']['size'])) { //如果有文件上传 上传附件 import('@.ORG.UploadFile'); //导入上传类 $upload = new UploadFile(); //设置上传文件大小 $upload->maxSize = 20000000; //设置附件上传目录 $dirname = './Uploads/' . date('Ym', time()) . '/' . date('d', time()) . '/'; $upload->allowExts = explode(',', $value['allow_file_type']); // 设置附件上传类型 if (!is_dir($dirname) && !mkdir($dirname, 0777, true)) { $this->error(L('ATTACHMENTS TO UPLOAD DIRECTORY CANNOT WRITE')); } $upload->savePath = $dirname; if (!$upload->upload()) { // 上传错误提示错误信息 alert('error', $upload->getErrorMsg(), $_SERVER['HTTP_REFERER']); } else { // 上传成功 获取上传文件信息 $info = $upload->getUploadFileInfo(); } } if (empty($_POST['content'])) { alert('error', '内容描述不能为空!', $_SERVER['HTTP_REFERER']); } if ($log_id = $m_log->add()) { $taskList = M('Task')->where('task_id = %d', $task_id)->find(); M('Task')->where('task_id = %d', $task_id)->setField('about_roles', $taskList['about_roles'] . $_POST['about_roles']); M('Task')->where('task_id = %d', $task_id)->setField('status', $_POST['status']); $send_email_array = $taskList['about_roles'] . $taskList['owner_role_id']; $data['log_id'] = $log_id; $data['task_id'] = $task_id; $send_email_str = explode(',', $send_email_array); $creator = getUserByRoleId(session('role_id')); $email_content = "发件人:" . $creator['user_name'] . "<br>" . "部门:" . $creator['department_name'] . "<br>" . '岗位:' . $creator['role_name'] . "<br>" . '内容:' . "<pre>" . $_POST['content'] . "</pre>" . "<br>" . '发件时间:' . date('Y-m-d H:i:s', time()); if ($send_email_str) { foreach ($send_email_str as $k => $v) { if ($v != "" && $v != session('role_id')) { if (intval($_POST['email_alert']) == 1) { sysSendEmail($v, $taskList['subject'], $email_content); } if (intval($_POST['message_alert']) == 1) { sendMessage($v, $email_content, 1); } } } } if (M('RLogTask')->add($data)) { foreach ($info as $key => $value) { $data['name'] = $value['name']; $data['file_path'] = $value['savepath'] . $value['savename']; $data['role_id'] = $_POST['role_id']; $data['size'] = $value['size']; $data['create_date'] = time(); if ($file_id = $m_file->add($data)) { $temp = array(); $temp['file_id'] = $file_id; $temp['log_id'] = $log_id; if (!M('RFileLog')->add($temp)) { alert('error', '部分文件上传失败,请联系管理员!', $_SERVER['HTTP_REFERER']); } } else { alert('error', L('ADD_ATTACHMENTS_FAIL'), $_SERVER['HTTP_REFERER']); } } alert('success', L('ADD SUCCESS', array(L('LOG'))), $_SERVER['HTTP_REFERER']); } else { alert('error', L('ADD_LOG_FAILED'), $_SERVER['HTTP_REFERER']); } } else { alert('error', L('ADD_LOG_FAILED'), $_SERVER['HTTP_REFERER']); } } elseif ($_GET['id']) { $this->allowExts = $value['allow_file_type']; $this->model_id = $_GET['id']; $status = M('Task')->where('task_id = %d', $_GET['id'])->getField('status'); $this->status = $status; $this->display(); } else { alert('error', L('PARAMETER_ERROR'), $_SERVER['HTTP_REFERER']); } }
public function more() { $log_id = $_POST['log_id']; if (empty($log_id)) { $this->ajaxReturn('error', '参数错误', 0); } $m_action_log = M('actionLog'); $m_comment = M('comment'); $actionLog = $m_action_log->where('log_id = %d', $log_id)->find(); if (empty($actionLog)) { $this->ajaxReturn('error', '信息不存在或已删除!', 0); } //查评论 //如果是评论日志,则从操作日志表中根据action_id查找,否则根据操作日志表的log_id查找 if ($actionLog['module_name'] == 'log') { $comment = $m_comment->where('module = "%s" and module_id = %d', 'log', $actionLog['action_id'])->order('create_time desc')->limit(5, 1000)->select(); } else { $comment = $m_comment->where('module = "%s" and module_id = %d', 'dynamic', $actionLog['log_id'])->order('create_time desc')->limit(5, 1000)->select(); } foreach ($comment as $key => $val) { $comment[$key]['comment_role'] = getUserByRoleId($val['creator_role_id']); $comment[$key]['time'] = date('Y-m-d H:i:s', $val['create_time']); } //println($comment); $this->ajaxReturn($comment, 'success', 1); }