if (!ereg("[0-9]{4}-[0-9]{2}-[0-9]{2}", $pattern)) { $pattern_flag = false; } if ($pattern != '' && $pattern_flag == true) { $query = 'select count(*) as num from jGetMsgsEx(date(NOW()) -7, date(NOW()));'; } else { $query = 'select count(*) as num from jGetMsgsEx(date(NOW()) - 7, date(NOW()));'; } //echo $query; $db->query($query); $all_num = $db->value[0]['num']; $coms = array(); if ($all_num > 0) { if ($pattern != '' && $pattern_flag == true) { $query = 'SELECT * FROM jGetMsgsEx( \'' . db_class::escape_like($pattern) . '\', date(NOW()));'; } else { $query = 'SELECT * FROM jGetMsgsEx( date(NOW())-7, date(NOW()))'; } $db->query($query); $coms = $db->value; } $empl = new collection(); $empl->Load(TABLE_DLS, false, $where, 'name ASC'); $empl = $empl->_collection; $cats = new collection(); $cats->Load(TABLE_OBJECTS, false, $where, 'name ASC'); $cats = $cats->_collection; $page_break = get_page_break(SITE_URI_ROOT . $STORAGE['module'] . '/' . $STORAGE['action'] . '/', $all_num, $from, LIMIT_COMPANY_ON_PAGE, LIMIT_PAGE_ON_PAGE, $additional_vars); include SITE_FILE_ROOT . 'template/header.php'; include SITE_FILE_ROOT . 'template/' . $STORAGE['module'] . '/view.php'; include SITE_FILE_ROOT . 'template/footer.php';
$where = $department_id > 0 ? '"department_id"=' . $department_id : 'department_id IS NULL'; $query = 'SELECT * FROM "' . VIEW_EMPLOYEE . '" WHERE ' . $where . ' ORDER BY name ASC'; $db->query($query); $employees = $db->value; $where = $department_id > 0 ? 'parent_id=' . $department_id : 'parent_id IS NULL'; $query = 'SELECT * FROM "' . TABLE_DEPARMENT . '" WHERE ' . $where . ' ORDER BY name ' . $sort_dep_dir; $db->query($query); $departments = $db->value; for ($i = 0; $i < count($departments); $i++) { $employees = array_merge($employees, get_employee_in_dep($departments[$i]['id_department'], $sort_dep_dir)); } return $employees; } $employees = get_employee_in_dep($department_id, $sort_dir); $employees = array_slice($employees, $from, LIMIT_EMPLOYEE_ON_PAGE); $page_break = get_page_break(SITE_URI_ROOT . $STORAGE['module'] . '/' . $STORAGE['action'] . '/', $all_num, $from, LIMIT_EMPLOYEE_ON_PAGE, LIMIT_PAGE_ON_PAGE, $additional_vars, 'Aclick'); } $dep = new department(); $emp = new employee(); for ($i = 0; $i < count($employees); $i++) { $dep->Init(); $dep->id_department = $employees[$i]['department_id']; $dep->Load(); $n = 0; $employees[$i]['department'] = array(); $employees[$i]['department'][$n]['dep'] = $dep->name; if ($dep->head_id != 0) { $emp->id_employee = $dep->head_id; $emp->Load(); $employees[$i]['department'][$n]['head'] = $emp->name; } else {