修改文件、类型显示
This commit is contained in:
1 parent
6f5ffeb8d7
commit
7e9310e4dd
254 files changed
+5412
-4872
No files matched your search
+212
-254
@@ -12,34 +12,18 @@
|
||||
// 应用公共文件
|
||||
|
||||
// 获取类别列表
|
||||
function getCategory($str = 0)
|
||||
function getCategory($p_id = 0)
|
||||
{
|
||||
$category = new \app\system\model\Category;
|
||||
|
||||
// 如果参数格式不为数字的时候查询$pid
|
||||
if(is_numeric($str) == false)
|
||||
{
|
||||
// 根据父级id查询类别列表
|
||||
$str = $category
|
||||
->where('title', $str)
|
||||
->value('id');
|
||||
}
|
||||
|
||||
|
||||
$str == '' || $str == null ? $str=0 : $str = $str;
|
||||
// 根据父级id查询类别列表
|
||||
$list = $category
|
||||
->where('pid', $str)
|
||||
->where('status', 1)
|
||||
->field('id, title')
|
||||
->select();
|
||||
// 查询类别
|
||||
$category = new \app\system\model\Category;
|
||||
$list = $category->srcChild($p_id);
|
||||
|
||||
// 返回类别列表
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
function nianjiList($riqi=0)
|
||||
function nianJiNameList($riqi=0)
|
||||
{
|
||||
// 定义学年时间节点日期为每年的8月1日
|
||||
// $yd = '8-1';
|
||||
@@ -54,15 +38,7 @@
|
||||
$nian = date('Y', $riqi);
|
||||
}
|
||||
|
||||
|
||||
if($thisday <= $jiedian)
|
||||
{
|
||||
$str = 1;
|
||||
}else{
|
||||
$str = 0;
|
||||
}
|
||||
|
||||
|
||||
$thisday <= $jiedian ? $str = 1 : $str = 0;
|
||||
$nian = $nian - $str;
|
||||
|
||||
$njlist = array();
|
||||
@@ -78,7 +54,7 @@
|
||||
|
||||
|
||||
// 班级列表
|
||||
function banjinamelist()
|
||||
function banJiNamelist()
|
||||
{
|
||||
$bjarr = array(
|
||||
'1' => '一班'
|
||||
@@ -112,79 +88,62 @@
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* $date是时间戳
|
||||
* $type为1的时候是虚岁,2的时候是周岁
|
||||
*/
|
||||
function getAgeByBirth($date = 0, $type = 1){
|
||||
$nowYear = date("Y", time());
|
||||
$nowMonth = date("m", time());
|
||||
$nowDay = date("d", time());
|
||||
$birthYear = date("Y", $date);
|
||||
$birthMonth = date("m", $date);
|
||||
$birthDay = date("d", $date);
|
||||
if($type == 1){
|
||||
$age = $nowYear - ($birthYear - 1);
|
||||
}elseif($type == 2){
|
||||
if($nowMonth < $birthMonth){
|
||||
$age = $nowYear - $birthYear - 1;
|
||||
}elseif($nowMonth == $birthMonth){
|
||||
if($nowDay < $birthDay){
|
||||
$age = $nowYear - $birthYear - 1;
|
||||
}else{
|
||||
$age = $nowYear - $birthYear;
|
||||
}
|
||||
}else{
|
||||
$age = $nowYear - $birthYear;
|
||||
}
|
||||
}
|
||||
$nowYear = date("Y", time());
|
||||
$nowMonth = date("m", time());
|
||||
$nowDay = date("d", time());
|
||||
$birthYear = date("Y", $date);
|
||||
$birthMonth = date("m", $date);
|
||||
$birthDay = date("d", $date);
|
||||
if($type == 1){
|
||||
$age = $nowYear - ($birthYear - 1);
|
||||
}elseif($type == 2){
|
||||
if($nowMonth < $birthMonth){
|
||||
$age = $nowYear - $birthYear - 1;
|
||||
}elseif($nowMonth == $birthMonth){
|
||||
if($nowDay < $birthDay){
|
||||
$age = $nowYear - $birthYear - 1;
|
||||
}else{
|
||||
$age = $nowYear - $birthYear;
|
||||
}
|
||||
}else{
|
||||
$age = $nowYear - $birthYear;
|
||||
}
|
||||
}
|
||||
return $age;
|
||||
}
|
||||
|
||||
|
||||
// EXCEL表格列名
|
||||
function excelLieming()
|
||||
function excelColumnName()
|
||||
{
|
||||
$liemingarr = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL','AM','AN','AO','AP','AQ','AR','AS','AT','AU','AV','AW','AX','AY','AZ','BA','BB','BC','BD','BE','BF','BG','BH','BI','BJ','BK','BL','BM','BN','BO','BP','BQ','BR','BS','BT','BU','BV','BW'];
|
||||
return $liemingarr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 单位列表
|
||||
function schlist($low = '班级', $high = '其它级', $xueduan = array())
|
||||
function schoolList($low = '班级', $high = '其它级')
|
||||
{
|
||||
|
||||
// 实例化单位模型
|
||||
$sch = new \app\system\model\School;
|
||||
// 实例化类别数据模型
|
||||
$cat = new \app\system\model\Category;
|
||||
// 获取获取级别列表
|
||||
$catlist = $cat->where('pid', 102)
|
||||
$catlist = $cat->where('p_id', 102)
|
||||
->where('status', 1)
|
||||
->column('id', 'title');
|
||||
|
||||
// 获取学段列表
|
||||
if(count($xueduan) > 0){
|
||||
$xdlist = $cat->where('pid', 103)
|
||||
->where('status', 1)
|
||||
->where('title', 'in', $xueduan)
|
||||
->column('id');
|
||||
}else{
|
||||
$xdlist = $cat->where('pid', 103)
|
||||
->where('status', 1)
|
||||
->column('id');
|
||||
}
|
||||
|
||||
// 查询学校
|
||||
$schlist = $sch->where('jibie', 'between', [$catlist[$low], $catlist[$high]])
|
||||
->where('status', 1)
|
||||
->where('xueduan', 'in', $xdlist)
|
||||
->order(['paixu'])
|
||||
->field('id, title, jiancheng')
|
||||
->select();
|
||||
$schlist = $sch->where('jibie_id', 'between', [$catlist[$low], $catlist[$high]])
|
||||
->where('status', 1)
|
||||
->order(['paixu'])
|
||||
->field('id, title, jiancheng')
|
||||
->select();
|
||||
|
||||
return $schlist;
|
||||
}
|
||||
@@ -212,9 +171,7 @@
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* 获取文件信息并保存
|
||||
*
|
||||
* @param file对象 $file
|
||||
@@ -227,14 +184,17 @@
|
||||
* str $data['val'] 返回信息
|
||||
* str $data['url'] 文件路径
|
||||
*/
|
||||
function saveFileInfo($file,$list,$isSave=false)
|
||||
function saveFileInfo($file, $list, $isSave = false)
|
||||
{
|
||||
$hash = $file->hash('sha1');
|
||||
$f = new \app\system\model\Fields;
|
||||
$serFile = $f::where('hash', $hash)->find();
|
||||
|
||||
if($serFile)
|
||||
{
|
||||
$data['msg'] = '文件已经存在';
|
||||
$serFile->user_id = session('userid');
|
||||
$serFile->save();
|
||||
$data['msg'] = '文件已经存在';
|
||||
$data['val'] = true;
|
||||
$data['url'] = $serFile->url;
|
||||
return $data;
|
||||
@@ -248,12 +208,15 @@
|
||||
|
||||
if($isSave==true){
|
||||
$list['url'] = $savename;
|
||||
$list['newname'] = substr($savename, strripos($savename, '\\') + 1, strlen($savename)-strripos($savename, '\\'));
|
||||
$list['newname'] = substr($savename
|
||||
,strripos($savename, '\\') + 1
|
||||
,strlen($savename) - strripos($savename
|
||||
,'\\'));
|
||||
$list['hash'] = $file->hash('sha1');
|
||||
$list['userid'] = session('userid');
|
||||
$list['user_id'] = session('userid');
|
||||
$list['oldname'] = $file->getOriginalName();
|
||||
$list['fieldsize'] = $file->getSize();
|
||||
$list['category'] = $list['category'];
|
||||
$list['category_id'] = $list['category_id'];
|
||||
$list['bianjitime'] = $file->getMTime();
|
||||
$list['extension'] = $file->getOriginalExtension();
|
||||
|
||||
@@ -268,192 +231,187 @@
|
||||
}
|
||||
|
||||
|
||||
// 给数组按多条件排序
|
||||
function sortArrByManyField(){
|
||||
$args = func_get_args();
|
||||
if(empty($args)){
|
||||
return null;
|
||||
}
|
||||
$arr = array_shift($args);
|
||||
if(!is_array($arr)){
|
||||
throw new Exception("第一个参数不为数组");
|
||||
}
|
||||
|
||||
foreach($args as $key => $field){
|
||||
if(is_string($field)){
|
||||
$temp = array();
|
||||
foreach($arr as $index => $val){
|
||||
$temp[$index] = $val[$field];
|
||||
// 给数组按多条件排序
|
||||
function sortArrByManyField(){
|
||||
$args = func_get_args();
|
||||
if(empty($args)){
|
||||
return null;
|
||||
}
|
||||
$args[$key] = $temp;
|
||||
$arr = array_shift($args);
|
||||
if(!is_array($arr)){
|
||||
throw new Exception("第一个参数不为数组");
|
||||
}
|
||||
|
||||
foreach($args as $key => $field){
|
||||
if(is_string($field)){
|
||||
$temp = array();
|
||||
foreach($arr as $index => $val){
|
||||
$temp[$index] = $val[$field];
|
||||
}
|
||||
$args[$key] = $temp;
|
||||
}
|
||||
}
|
||||
$args[] = &$arr;//引用值
|
||||
$keys = array_keys($args[0]);
|
||||
call_user_func_array('array_multisort', $args);
|
||||
|
||||
return array_pop($args);;
|
||||
}
|
||||
}
|
||||
$args[] = &$arr;//引用值
|
||||
$keys = array_keys($args[0]);
|
||||
call_user_func_array('array_multisort', $args);
|
||||
|
||||
return array_pop($args);;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据键值,用数组2的值替换数组1的值
|
||||
* $cover 覆盖数组,存储新值的数组
|
||||
* $covered 被覆盖数组,被更改值的数组
|
||||
* 返回 新arr1
|
||||
* */
|
||||
function array_cover( $cover = array(), $covered = array() )
|
||||
{
|
||||
foreach ($cover as $key => $value) {
|
||||
if(isset($covered[$key]) == true)
|
||||
{
|
||||
$covered[$key] = $cover[$key];
|
||||
}
|
||||
}
|
||||
return $covered;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据考试ID值,判断考试开始或者结束时间是否已过
|
||||
* $kaoshiid 考试ID
|
||||
* $str 统计项目
|
||||
* 返回 $data
|
||||
* */
|
||||
function kaoshiDate($kaoshiid, $str='enddate')
|
||||
{
|
||||
$ks = new app\kaoshi\model\Kaoshi;
|
||||
$enddate = $ks->where('id', $kaoshiid)
|
||||
->value($str);
|
||||
|
||||
$thistime = time();
|
||||
if( $thistime > $enddate )
|
||||
/**
|
||||
* 根据键值,用数组2的值替换数组1的值
|
||||
* $cover 覆盖数组,存储新值的数组
|
||||
* $covered 被覆盖数组,被更改值的数组
|
||||
* 返回 新arr1
|
||||
* */
|
||||
function array_cover($cover = array(), $covered = array())
|
||||
{
|
||||
$data = true;
|
||||
}else{
|
||||
$data = false;
|
||||
foreach ($cover as $key => $value) {
|
||||
if(isset($covered[$key]) == true)
|
||||
{
|
||||
$covered[$key] = $cover[$key];
|
||||
}
|
||||
}
|
||||
return $covered;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * 根据考试ID值,判断考试开始或者结束时间是否已过
|
||||
// * $kaoshiid 考试ID
|
||||
// * $str 统计项目
|
||||
// * 返回 $data
|
||||
// * */
|
||||
// function kaoShiDate($kaoshiid, $str='enddate')
|
||||
// {
|
||||
// $ks = new app\kaoshi\model\Kaoshi;
|
||||
// $enddate = $ks->where('id', $kaoshiid)
|
||||
// ->value($str);
|
||||
|
||||
/**
|
||||
* 获取参加考试的学科
|
||||
* 返回 $data
|
||||
* */
|
||||
function subjectList()
|
||||
{
|
||||
$src = [
|
||||
'status' => 1
|
||||
,'kaoshi' =>1
|
||||
];
|
||||
|
||||
$sbj = new \app\teach\model\Subject;
|
||||
$data = $sbj->search($src);
|
||||
|
||||
return $data;
|
||||
}
|
||||
// $thistime = time();
|
||||
// if( $thistime > $enddate )
|
||||
// {
|
||||
// $data = true;
|
||||
// }else{
|
||||
// $data = false;
|
||||
// }
|
||||
// return $data;
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* 把request到的参数转换成数组,并删除空值
|
||||
*
|
||||
* @access public
|
||||
* @param str或array $str 表单中获取的参数
|
||||
* @return array 返回类型
|
||||
*/
|
||||
function strToarray($str)
|
||||
{
|
||||
// 如果str是字符串,则转换成数组
|
||||
if(is_array($str)==false)
|
||||
{
|
||||
$str = explode(',', $str);
|
||||
}
|
||||
// 循环数组,删除空元素
|
||||
foreach ($str as $key => $value) {
|
||||
if($value == "" && $value == null){
|
||||
unset($str[$key]);
|
||||
}
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
/**
|
||||
* 获取参加考试的学科
|
||||
* 返回 $data
|
||||
* */
|
||||
function subjectList()
|
||||
{
|
||||
$src = [
|
||||
'status' => 1
|
||||
,'kaoshi' =>1
|
||||
];
|
||||
|
||||
$sbj = new \app\teach\model\Subject;
|
||||
$data = $sbj->search($src);
|
||||
|
||||
/**
|
||||
* 把重新整理从数据模型中返回的对象
|
||||
* @access public
|
||||
* @param str或array $str 表单中获取的参数
|
||||
* @return array 返回类型
|
||||
*/
|
||||
function reSetObject($obj, $srcfrom)
|
||||
{
|
||||
// 整理变量
|
||||
$src = [
|
||||
'field' => 'update_time'
|
||||
,'order' => 'desc'
|
||||
,'page' => 1
|
||||
,'limit' => 10
|
||||
];
|
||||
$src = array_cover($srcfrom, $src) ;
|
||||
|
||||
// 整理数据
|
||||
$cnt = $obj->count();
|
||||
$obj = $obj->order(strval($src['field']), $src['order']);
|
||||
|
||||
$limit_start = $src['page'] * $src['limit'] - $src['limit'];
|
||||
$limit_length = $src['limit'];
|
||||
$obj = $obj->slice($limit_start, $limit_length);
|
||||
$data = [
|
||||
'code' => 0 // ajax请求次数,作为标识符
|
||||
,'msg' => "" // 获取到的结果数(每页显示数量)
|
||||
,'count' => $cnt // 符合条件的总数据量
|
||||
,'data' => $obj //获取到的数据结果
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把重新整理从数据模型中返回的对象
|
||||
* @access public
|
||||
* @param str或array $str 表单中获取的参数
|
||||
* @return array 返回类型
|
||||
*/
|
||||
function reSetArray($arr, $srcfrom)
|
||||
{
|
||||
// 整理变量
|
||||
$src = [
|
||||
'field' => 'update_time'
|
||||
,'order' => 'desc'
|
||||
,'page' => 1
|
||||
,'limit' => 10
|
||||
];
|
||||
$src = array_cover($srcfrom, $src) ;
|
||||
|
||||
// 重新整理数据
|
||||
$cnt = count($arr); # 记录总数
|
||||
if($cnt > 0){
|
||||
$src['order'] == 'desc' ? $src['order'] = SORT_DESC :$src['order'] = SORT_ASC; # 数据排序
|
||||
$arr = sortArrByManyField($arr,$src['field'],$src['order']);
|
||||
return $data;
|
||||
}
|
||||
$limit_start = $src['page'] * $src['limit'] - $src['limit']; # 获取当前页数据
|
||||
$limit_length = $src['limit'];
|
||||
$arr = array_slice($arr,$limit_start,$limit_length);
|
||||
$data = [ # 数据合并
|
||||
'code'=> 0 , # ajax请求次数,作为标识符
|
||||
'msg'=>"", # 获取到的结果数(每页显示数量)
|
||||
'count'=>$cnt, # 符合条件的总数据量
|
||||
'data'=>$arr, # 获取到的数据结果
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 把request到的参数转换成数组,并删除空值
|
||||
*
|
||||
* @access public
|
||||
* @param str或array $str 表单中获取的参数
|
||||
* @return array 返回类型
|
||||
*/
|
||||
function strToArray($str)
|
||||
{
|
||||
// 如果str是字符串,则转换成数组
|
||||
if(is_array($str) == false)
|
||||
{
|
||||
$str = explode(',', $str);
|
||||
}
|
||||
// 循环数组,删除空元素
|
||||
foreach ($str as $key => $value) {
|
||||
if($value == "" && $value == null){
|
||||
unset($str[$key]);
|
||||
}
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 把重新整理从数据模型中返回的对象
|
||||
* @access public
|
||||
* @param str或array $str 表单中获取的参数
|
||||
* @return array 返回类型
|
||||
*/
|
||||
function reSetObject($obj, $srcfrom)
|
||||
{
|
||||
// 整理变量
|
||||
$src = [
|
||||
'field' => 'update_time'
|
||||
,'order' => 'desc'
|
||||
,'page' => 1
|
||||
,'limit' => 10
|
||||
];
|
||||
$src = array_cover($srcfrom, $src) ;
|
||||
$str1 = $src['field'];
|
||||
$str2 = $src['order'];
|
||||
|
||||
// 整理数据
|
||||
$cnt = $obj->count();
|
||||
$obj = $obj->order($src['field'], $src['order']);
|
||||
|
||||
$limit_start = $src['page'] * $src['limit'] - $src['limit'];
|
||||
$limit_length = $src['limit'];
|
||||
$obj = $obj->slice($limit_start, $limit_length);
|
||||
$data = [
|
||||
'code' => 0 // ajax请求次数,作为标识符
|
||||
,'msg' => "" // 获取到的结果数(每页显示数量)
|
||||
,'count' => $cnt // 符合条件的总数据量
|
||||
,'data' => $obj //获取到的数据结果
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 把重新整理从数据模型中返回的对象
|
||||
* @access public
|
||||
* @param str或array $str 表单中获取的参数
|
||||
* @return array 返回类型
|
||||
*/
|
||||
function reSetArray($arr, $srcfrom)
|
||||
{
|
||||
// 整理变量
|
||||
$src = [
|
||||
'field' => 'update_time'
|
||||
,'order' => 'desc'
|
||||
,'page' => 1
|
||||
,'limit' => 10
|
||||
];
|
||||
$src = array_cover($srcfrom, $src) ;
|
||||
|
||||
// 重新整理数据
|
||||
$cnt = count($arr); # 记录总数
|
||||
if($cnt > 0){
|
||||
$src['order'] == 'desc' ? $src['order'] = SORT_DESC
|
||||
: $src['order'] = SORT_ASC; # 数据排序
|
||||
$arr = sortArrByManyField($arr, $src['field'], $src['order']);
|
||||
}
|
||||
$limit_start = $src['page'] * $src['limit'] - $src['limit']; # 获取当前页数据
|
||||
$limit_length = $src['limit'];
|
||||
$arr = array_slice($arr, $limit_start, $limit_length);
|
||||
$data = [ # 数据合并
|
||||
'code' => 0 , # ajax请求次数,作为标识符
|
||||
'msg' => "", # 获取到的结果数(每页显示数量)
|
||||
'count' => $cnt, # 符合条件的总数据量
|
||||
'data' => $arr, # 获取到的数据结果
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
Reference in new issue
Block a user