Files
liche/admin/controllers/Expfile.php
T
2021-07-05 09:56:27 +08:00

95 lines
3.1 KiB
PHP
Executable File

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Created by PhpStorm.
* User: xuxb
* Date: 2020/7/9
* Time: 17:04
*/
class Expfile extends HD_Controller{
public function index(){
$this->lists();
}
public function lists(){
$page = $this->input->get('page');
$size = $this->input->get('size');
!$page && $page = 1;
!$size && $size = 20;
$this->load->model('sys/sys_plan_model', 'plan_model');
$this->load->model("sys/sys_admin_model", 'admin_model');
$where = array(
'type' => 1,
);
if(1 != $this->role){//超级管理员可以看到所有
$where['admin_id'] = $this->uid;
}
$total = $this->plan_model->count($where);
$lists = array();
if($total){
$select = "id, title, total_num, finish_num, plan_info, status, admin_id";
$order = "id DESC";
$rows = $this->plan_model->select($where, $order, $page, $size, $select);
$admin_ids = array_column($rows, 'admin_id');
$admin_ids = array_unique($admin_ids);
$where = array("id in (" . implode(',', $admin_ids) . ")" => null);
$select = 'id, username';
$map_admin = $this->admin_model->map('id', 'username', $where, 'id DESC', 0 ,0, $select);
foreach($rows as $row){
$plan_info = json_decode($row['plan_info'], true);
if(1 == $row['status']){
$percent = "100%";
} elseif($row['total_num'] <= $row['finish_num']) {
$percent = "99%";
} else {
$percent = round($row['finish_num'] * 100 / $row['total_num'], 2) . "%";
}
$url = $plan_info['file_info']['url'];
$http = server_http();
$url = str_replace('http://', $http, $url);
$lists[] = array(
'id' => $row['id'],
'admin_name' => $map_admin[$row['admin_id']],
'title' => $row['title'],
"file_name" => $plan_info['file_info']['name'],
'percent' => $percent,
"status" => $row['status'],
"url" => $url,
);
}
}
$this->data['pager'] = array('count' => ceil($total/$size), 'curr' => $page, 'totle' => $total, 'total' => $total);
$this->data['lists'] = $lists;
$this->data['_title'] = '导出文件列表';
return $this->show_view('app/appusual/expfile/lists', true);
}
public function get(){
// TODO: Implement get() method.
}
public function add(){
// TODO: Implement add() method.
}
public function edit(){
// TODO: Implement edit() method.
}
public function del(){
// TODO: Implement del() method.
}
public function batch(){
// TODO: Implement batch() method.
}
public function export(){
// TODO: Implement export() method.
}
}