* Code for export users.

This commit is contained in:
孙广明
2022-06-02 14:52:16 +08:00
parent 846992386c
commit 23d19bd6b3
3 changed files with 59 additions and 4 deletions
Regular → Executable
+3 -1
View File
@@ -151,6 +151,7 @@ $filter->user->login = new stdclass();
$filter->user->edit = new stdclass();
$filter->webhook->bind = new stdclass();
$filter->user->ajaxgetmore = new stdclass();
$filter->user->export = new stdclass();
$filter->repo->ajaxsynccommit = new stdclass();
$filter->repo->apigetrepobyurl = new stdclass();
$filter->search->index = new stdclass();
@@ -320,7 +321,8 @@ $filter->testtask->default->cookie['preProductID'] = 'int';
$filter->todo->export->cookie['checkedItem'] = 'reg::checked';
$filter->user->login->cookie['keepLogin'] = 'equal::on';
$filter->user->login->cookie['keepLogin'] = 'equal::on';
$filter->user->export->cookie['checkedItem'] = 'reg::any';
$filter->block->default->get['hash'] = 'reg::md5';
$filter->block->main->get['blockid'] = 'code';
+2 -2
View File
@@ -68,7 +68,7 @@ js::set('confirmDelete', $lang->user->confirmDelete);
</div>
<div class='main-col'>
<div class="cell<?php if($type == 'bysearch') echo ' show';?>" id="queryBox" data-module='user'></div>
<form class='main-table table-user' data-ride='table' action='<?php echo $this->createLink('user', 'batchEdit', "deptID=$deptID")?>' method='post' id='userListForm'>
<form class='main-table table-user skip-iframe-modal' data-ride='table' action='<?php echo $this->createLink('user', 'batchEdit', "deptID=$deptID")?>' method='post' id='userListForm'>
<?php $canBatchEdit = common::hasPriv('user', 'batchEdit');?>
<table class='table has-sort-head' id='userList'>
<thead>
@@ -105,7 +105,7 @@ js::set('confirmDelete', $lang->user->confirmDelete);
<tr>
<td class='c-id'>
<?php if($canBatchEdit):?>
<?php echo html::checkbox('users', array($user->account => '')) . sprintf('%03d', $user->id);?>
<?php echo html::checkbox('users', array($user->id => '')) . sprintf('%03d', $user->id);?>
<?php else:?>
<?php printf('%03d', $user->id);?>
<?php endif;?>
Regular → Executable
+54 -1
View File
@@ -658,7 +658,7 @@ class user extends control
{
if(isset($_POST['users']))
{
$this->view->users = $this->dao->select('*')->from(TABLE_USER)->where('account')->in($this->post->users)->orderBy('id')->fetchAll('id');
$this->view->users = $this->dao->select('*')->from(TABLE_USER)->where('id')->in($this->post->users)->orderBy('id')->fetchAll('id');
}
elseif($_POST)
{
@@ -1076,6 +1076,59 @@ class user extends control
$this->display();
}
public function export($browseType, $param, $type, $orderBy)
{
if($_POST)
{
$this->loadModel('file');
$this->user->setListValue();
$userLang = $this->lang->user;
$userConfig = $this->config->user;
/* Create field lists. */
$fields = $this->post->exportFields ? $this->post->exportFields : explode(',', $userConfig->list->exportFields);
foreach($fields as $key => $fieldName)
{
$fieldName = trim($fieldName);
$fields[$fieldName] = isset($userLang->$fieldName) ? $userLang->$fieldName : $fieldName;
unset($fields[$key]);
}
/* Get users. */
$users = $this->dao->select('*')->from(TABLE_USER)->where($this->session->userQueryCondition)
->beginIF($this->post->exportType == 'selected')->andWhere('id')->in($this->cookie->checkedItem)->fi()
->orderBy($orderBy)->fetchAll('id');
/* Get role, products and executions. */
$roleList = $this->lang->user->roleList;
$genderList = $this->lang->user->genderList;
$typeList = $this->lang->user->typeList;
$depts = $this->loadModel('dept')->getOptionMenu();
foreach($depts as $id => $dept) $depts[$id] = "$dept(#$id)";
foreach($users as $user)
{
if(isset($userLang->roleList[$user->role])) $user->role = $userLang->roleList[$user->role];
if(isset($userLang->genderList[$user->gender])) $user->gender = $userLang->genderList[$user->gender];
if(isset($userLang->typeList[$user->type])) $user->type = $userLang->typeList[$user->type];
if(isset($depts[$user->dept])) $depts = $depts[$user->dept];
}
$this->post->set('fields', $fields);
$this->post->set('rows', $users);
$this->post->set('kind', 'user');
$this->fetch('file', 'export2' . $this->post->fileType, $_POST);
}
$fileName = $this->lang->user->common;
$this->view->fileName = $fileName;
$this->view->allExportFields = $this->config->user->list->exportFields;
$this->view->customExport = true;
$this->display();
}
/**
* User dynamic.
*