diff --git a/app/chengji/controller/Bjtongji.php b/app/chengji/controller/Bjtongji.php
index f61e8bca..c2a6e64f 100644
--- a/app/chengji/controller/Bjtongji.php
+++ b/app/chengji/controller/Bjtongji.php
@@ -203,10 +203,10 @@ class Bjtongji extends BaseController
}
$sheet->mergeCells($colname[$col].'3:'.$colname[$col].'4');
$sheet->setCellValue($colname[$col].'3', '全科及格率%');
- $sheet->getStyle($colname[$col].'3')->getAlignment()->setWrapText(true);
$col++;
$sheet->mergeCells($colname[$col].'3:'.$colname[$col].'4');
$sheet->setCellValue($colname[$col].'3', '全科平均');
+ $sheet->getStyle('C3:'.$colname[$col].'4')->getAlignment()->setWrapText(true);
@@ -257,14 +257,26 @@ class Bjtongji extends BaseController
];
$sheet->getStyle('A3:'.$colname[$col].($row-1))->applyFromArray($styleArray);
// 修改标题字号
- $spreadsheet->getActiveSheet()->getStyle('A1')->getFont()->setBold(true)->setName('宋体')->setSize(20);
+ $sheet->getStyle('A1')->getFont()->setBold(true)->setName('宋体')->setSize(20);
// 设置行高
- $spreadsheet->getActiveSheet()->getDefaultRowDimension()->setRowHeight(35);
- $spreadsheet->getActiveSheet()->getRowDimension('3:4')->setRowHeight(25);
-
-
+ $sheet->getDefaultRowDimension()->setRowHeight(35);
+ $sheet->getRowDimension('3:4')->setRowHeight(25);
+ // 设置列宽
+ $sheet->getDefaultColumnDimension()->setWidth(8.3);
+ $sheet->getColumnDimension('A')->setWidth(5);
+ $sheet->getColumnDimension('B')->setWidth(10.5);
+ // 页面设置
+ $sheet->getPageSetup()->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE);
+ $sheet->getPageSetup()->setPaperSize(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4);
+ $sheet->getPageMargins()->setTop(0.8);
+ $sheet->getPageMargins()->setRight(0.2);
+ $sheet->getPageMargins()->setLeft(0.2);
+ $sheet->getPageMargins()->setBottom(0.8);
+ // 打印居中
+ $sheet->getPageSetup()->setHorizontalCentered(true);
+ $sheet->getPageSetup()->setVerticalCentered(false);
// 保存文件
$filename = $tabletitle.date('ymdHis').'.xlsx';
@@ -273,6 +285,8 @@ class Bjtongji extends BaseController
header('Cache-Control: max-age=0');
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx');
$writer->save('php://output');
+ ob_flush();
+ flush();
}
diff --git a/app/chengji/controller/Index.php b/app/chengji/controller/Index.php
index f95daf3f..61e47e85 100644
--- a/app/chengji/controller/Index.php
+++ b/app/chengji/controller/Index.php
@@ -721,39 +721,39 @@ class Index extends BaseController
->setDescription("该表格由".session('username').session('id')."于".$thistime."在尚码成绩管理系统中下载,只作为内部交流材料,不允许外泄。") //描述
->setKeywords("尚码 成绩管理") //关键字
->setCategory("成绩管理"); //分类
-
+
// 设置表头信息
$sheet->setCellValue('A1', $tabletitle);
- $sheet->setCellValue('A2', '序号');
- $sheet->setCellValue('B2', '班级');
- $sheet->setCellValue('C2', '姓名');
- $sheet->setCellValue('D2', '性别');
+ $hb = 5 + $ks->ksSubject->count();
+ $sheet->mergeCells('A1:'.$colname[$hb].'1');
+ $sheet->setCellValue('A3', '序号');
+ $sheet->setCellValue('B3', '班级');
+ $sheet->setCellValue('C3', '姓名');
+ $sheet->setCellValue('D3', '性别');
$i = 4;
- foreach ($ks->ks_subject as $key => $value) {
- $sheet->setCellValue($colname[$i].'2', $value->subject_name->title);
+ foreach ($ks->ksSubject as $key => $value) {
+ $sheet->setCellValue($colname[$i].'3', $value->subject_name->title);
$i++;
}
- $sheet->setCellValue($colname[$i].'2', '平均分');
- $sheet->setCellValue($colname[$i+1].'2', '总分');
+ $sheet->setCellValue($colname[$i].'3', '平均分');
+ $sheet->setCellValue($colname[$i+1].'3', '总分');
$i=$i+4;
- $sheet->setCellValue($colname[$i].'2', '项目');
- $sheet->setCellValue($colname[$i].'3', '人数');
- $sheet->setCellValue($colname[$i].'4', '平均分');
- $sheet->setCellValue($colname[$i].'5', '优秀率%');
- $sheet->setCellValue($colname[$i].'6', '及格率%');
- $sheet->setCellValue($colname[$i].'7', '标准差');
+ $sheet->setCellValue($colname[$i].'3', '项目');
+ $sheet->setCellValue($colname[$i].'4', '人数');
+ $sheet->setCellValue($colname[$i].'5', '平均分');
+ $sheet->setCellValue($colname[$i].'6', '优秀率%');
+ $sheet->setCellValue($colname[$i].'7', '及格率%');
+ $sheet->setCellValue($colname[$i].'8', '标准差');
$i++;
- foreach ($ks->ks_subject as $key => $value) {
- $sheet->setCellValue($colname[$i].'2', $value->subject_name->title);
+ foreach ($ks->ksSubject as $key => $value) {
+ $sheet->setCellValue($colname[$i].'3', $value->subject_name->title);
$i++;
}
- $sheet->setCellValue($colname[$i+1].'2', '总平均分');
- $sheet->setCellValue($colname[$i+2].'2', '全科及格率%');
// 循环写出成绩及个人信息
- $i = 3;
+ $i = 4;
foreach ($chengjiinfo as $key => $value) {
// 表格赋值
$sheet->setCellValue('A'.$i, $i-2);
@@ -761,7 +761,7 @@ class Index extends BaseController
$sheet->setCellValue('C'.$i, $value['student']);
$sheet->setCellValue('D'.$i, $value['sex']);
$colcnt = 4;
- foreach ($ks->ks_subject as $k => $val) {
+ foreach ($ks->ksSubject as $k => $val) {
if(isset($value[$val->subject_name->lieming]))
{
$sheet->setCellValue($colname[$colcnt].$i, $value[$val->subject_name->lieming]);
@@ -773,24 +773,76 @@ class Index extends BaseController
$i++;
}
+ // 居中
+ $styleArrayJZ = [
+ 'alignment' => [
+ 'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
+ 'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER, //垂直居中
+ ],
+ ];
+ $sheet->getStyle('A1:'.$colname[$colcnt+1].($i-1))->applyFromArray($styleArrayJZ);
+
+ // 加边框
+ $styleArrayBK = [
+ 'borders' => [
+ 'allBorders' => [
+ 'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
+ 'color' => ['argb' => '00000000'],
+ ],
+ ],
+ ];
+ $sheet->getStyle('A3:'.$colname[$colcnt+1].($i-1))->applyFromArray($styleArrayBK);
+
+
+
$tj = new \app\chengji\model\Tongji;
$nianji = array();
$chengjiinfo = $kh->srcChengji($src);
$temp = $tj->tongjiSubject($chengjiinfo,$src['kaoshi']);
isset($colcnt) ? $colcnt = $colcnt+5 : $colcnt = 12;
+ $colBiankuang = $colcnt;
// 循环写出统计结果
- foreach ($ks->ks_subject as $key => $value) {
- $sheet->setCellValue($colname[$colcnt].'3', $temp['cj'][$value->subject_name->lieming]['xkcnt']);
- $sheet->setCellValue($colname[$colcnt].'4', $temp['cj'][$value->subject_name->lieming]['avg']);
- $sheet->setCellValue($colname[$colcnt].'5', $temp['cj'][$value->subject_name->lieming]['youxiu']);
- $sheet->setCellValue($colname[$colcnt].'6', $temp['cj'][$value->subject_name->lieming]['jige']);
- $sheet->setCellValue($colname[$colcnt].'7', $temp['cj'][$value->subject_name->lieming]['biaozhuncha']);
+ foreach ($ks->ksSubject as $key => $value) {
+ $sheet->setCellValue($colname[$colcnt].'4', $temp['cj'][$value->subject_name->lieming]['xkcnt']);
+ $sheet->setCellValue($colname[$colcnt].'5', $temp['cj'][$value->subject_name->lieming]['avg']);
+ $sheet->setCellValue($colname[$colcnt].'6', $temp['cj'][$value->subject_name->lieming]['youxiu']);
+ $sheet->setCellValue($colname[$colcnt].'7', $temp['cj'][$value->subject_name->lieming]['jige']);
+ $sheet->setCellValue($colname[$colcnt].'8', $temp['cj'][$value->subject_name->lieming]['biaozhuncha']);
$colcnt++;
}
- $sheet->setCellValue($colname[$colcnt+1].'3', $temp['cj']['all']['avg']);
- $sheet->setCellValue($colname[$colcnt+2].'3', $temp['cj']['all']['jige']);
+ $sheet->setCellValue($colname[$colBiankuang-1].'9', '总平均分');
+ $sheet->setCellValue($colname[$colBiankuang].'9', $temp['cj']['all']['avg']);
+ $sheet->mergeCells($colname[$colBiankuang].'9:'.$colname[$colcnt-1].'9');
+ $sheet->setCellValue($colname[$colBiankuang-1].'10', '全科及格率');
+ $sheet->setCellValue($colname[$colBiankuang].'10', $temp['cj']['all']['jige']);
+ $sheet->mergeCells($colname[$colBiankuang].'10:'.$colname[$colcnt-1].'10');
+ $sheet->getStyle($colname[$colBiankuang-1].'3:'.$colname[$colcnt-1].'10')->applyFromArray($styleArrayJZ);
+ $sheet->getStyle($colname[$colBiankuang-1].'3:'.$colname[$colcnt-1].'10')->applyFromArray($styleArrayBK);
+
+ // 修改标题字号
+ $sheet->getStyle('A1')->getFont()->setBold(true)->setName('宋体')->setSize(16);
+ // 设置行高
+ $sheet->getDefaultRowDimension()->setRowHeight(22.5);
+ $sheet->getRowDimension('1')->setRowHeight(25);
+ // 设置列宽
+ $sheet->getDefaultColumnDimension()->setWidth(9);
+ $sheet->getColumnDimension('A')->setWidth(6);
+ $sheet->getColumnDimension('B')->setWidth(12);
+ $sheet->getColumnDimension($colname[$colBiankuang-1])->setWidth(13);
+
+
+ // 页面设置
+ $sheet->getPageSetup()->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE);
+ $sheet->getPageSetup()->setPaperSize(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4);
+ $sheet->getPageMargins()->setTop(0.8);
+ $sheet->getPageMargins()->setRight(0.2);
+ $sheet->getPageMargins()->setLeft(0.2);
+ $sheet->getPageMargins()->setBottom(0.8);
+ // 打印居中
+ $sheet->getPageSetup()->setHorizontalCentered(true);
+ $sheet->getPageSetup()->setVerticalCentered(false);
// 保存文件
@@ -871,7 +923,7 @@ class Index extends BaseController
$srcAll['banji']= array_column($kh->cyBanji($srcAll), 'id');
$chengjiinfo = $kh->srcChengji($src);
- $njtj = $tj->tongji($chengjiinfo,$src['kaoshi']);
+ $njtj = $tj->tongjiSubject($chengjiinfo,$src['kaoshi']);
// 获取部分学生成绩
$chengjiinfo = $kh->srcChengji($src);
@@ -915,7 +967,7 @@ class Index extends BaseController
$row = 1; # 定义从 $row 行开始写入数据
- $rows = count($ks->ks_subject); # 定义学生信息列要合并的行数
+ $rows = count($ks->ksSubject); # 定义学生信息列要合并的行数
// 给单元格加边框
$styleArray = [
@@ -931,6 +983,7 @@ class Index extends BaseController
],
];
+
// 从这里开始循环写入学生成绩
foreach ($chengjiinfo as $key => $value) {
@@ -958,16 +1011,16 @@ class Index extends BaseController
// 写入成绩
- foreach ($ks->ks_subject as $k => $val) {
+ foreach ($ks->ksSubject as $k => $val) {
$sheet->setCellValue('D'.($row+$k), $val->subjectName->title);
$sheet->setCellValue('E'.($row+$k), $value[$val->subject_name->lieming]); # 得分
- $sheet->setCellValue('F'.($row+$k), $njtj[$val->subject_name->lieming]['avg']);
- $sheet->setCellValue('G'.($row+$k), $njtj[$val->subject_name->lieming]['max']);
- $sheet->setCellValue('H'.($row+$k), $njtj[$val->subject_name->lieming]['youxiu']);
- $sheet->setCellValue('I'.($row+$k), $njtj[$val->subject_name->lieming]['jige']);
- $sheet->setCellValue('J'.($row+$k), $njtj[$val->subject_name->lieming]['sifenwei'][0]);
- $sheet->setCellValue('K'.($row+$k), $njtj[$val->subject_name->lieming]['sifenwei'][1]);
- $sheet->setCellValue('L'.($row+$k), $njtj[$val->subject_name->lieming]['sifenwei'][2]);
+ $sheet->setCellValue('F'.($row+$k), $njtj['cj'][$val->subject_name->lieming]['avg']);
+ $sheet->setCellValue('G'.($row+$k), $njtj['cj'][$val->subject_name->lieming]['max']);
+ $sheet->setCellValue('H'.($row+$k), $njtj['cj'][$val->subject_name->lieming]['youxiu']);
+ $sheet->setCellValue('I'.($row+$k), $njtj['cj'][$val->subject_name->lieming]['jige']);
+ $sheet->setCellValue('J'.($row+$k), $njtj['cj'][$val->subject_name->lieming]['sifenwei'][0]);
+ $sheet->setCellValue('K'.($row+$k), $njtj['cj'][$val->subject_name->lieming]['sifenwei'][1]);
+ $sheet->setCellValue('L'.($row+$k), $njtj['cj'][$val->subject_name->lieming]['sifenwei'][2]);
}
// 设置格式
diff --git a/app/chengji/controller/Njtongji.php b/app/chengji/controller/Njtongji.php
index e35b6d3f..76e5f377 100644
--- a/app/chengji/controller/Njtongji.php
+++ b/app/chengji/controller/Njtongji.php
@@ -197,10 +197,10 @@ class Njtongji extends BaseController
}
$sheet->mergeCells($colname[$col].'3:'.$colname[$col].'4');
$sheet->setCellValue($colname[$col].'3', '全科及格率%');
- $sheet->getStyle($colname[$col].'3')->getAlignment()->setWrapText(true);
$col++;
$sheet->mergeCells($colname[$col].'3:'.$colname[$col].'4');
$sheet->setCellValue($colname[$col].'3', '总平均分');
+ $sheet->getStyle('C3:'.$colname[$col].'4')->getAlignment()->setWrapText(true);
$row = 5;
foreach ($data as $key => $value) {
@@ -239,10 +239,26 @@ class Njtongji extends BaseController
];
$sheet->getStyle('A3:'.$colname[$col].($row-1))->applyFromArray($styleArray);
// 修改标题字号
- $spreadsheet->getActiveSheet()->getStyle('A1')->getFont()->setBold(true)->setName('宋体')->setSize(20);
+ $sheet->getStyle('A1')->getFont()->setBold(true)->setName('宋体')->setSize(20);
// 设置行高
- $spreadsheet->getActiveSheet()->getDefaultRowDimension()->setRowHeight(35);
- $spreadsheet->getActiveSheet()->getRowDimension('3:4')->setRowHeight(25);
+ $sheet->getDefaultRowDimension()->setRowHeight(35);
+ $sheet->getRowDimension('3:4')->setRowHeight(25);
+ // 设置列宽
+ $sheet->getDefaultColumnDimension()->setWidth(8.3);
+ $sheet->getColumnDimension('A')->setWidth(5);
+ $sheet->getColumnDimension('B')->setWidth(10.5);
+
+
+ // 页面设置
+ $sheet->getPageSetup()->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE);
+ $sheet->getPageSetup()->setPaperSize(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4);
+ $sheet->getPageMargins()->setTop(0.8);
+ $sheet->getPageMargins()->setRight(0.2);
+ $sheet->getPageMargins()->setLeft(0.2);
+ $sheet->getPageMargins()->setBottom(0.8);
+ // 打印居中
+ $sheet->getPageSetup()->setHorizontalCentered(true);
+ $sheet->getPageSetup()->setVerticalCentered(false);
diff --git a/app/chengji/view/index/dw_chengji.html b/app/chengji/view/index/dw_chengji.html
index 4e9ca68a..87c8a7c1 100644
--- a/app/chengji/view/index/dw_chengji.html
+++ b/app/chengji/view/index/dw_chengji.html
@@ -108,7 +108,6 @@ layui.use(['form'], function(){
},
dataType:'json',
success:function(result){
- console.log(result);
$(bj).append('');
// if(result.length > 0){
result.forEach(function(val,index){
diff --git a/app/chengji/view/index/dw_chengjitiao.html b/app/chengji/view/index/dw_chengjitiao.html
index d104cdd2..35338fa6 100644
--- a/app/chengji/view/index/dw_chengjitiao.html
+++ b/app/chengji/view/index/dw_chengjitiao.html
@@ -111,7 +111,6 @@ layui.use(['form'], function(){
},
dataType:'json',
success:function(result){
- console.log(result);
$(bj).append('');
// if(result.length > 0){
result.forEach(function(val,index){
diff --git a/app/common.php b/app/common.php
index 5f03a75a..020c1847 100644
--- a/app/common.php
+++ b/app/common.php
@@ -11,212 +11,212 @@
// 应用公共文件
-// 获取类别列表
-function getCategory($str = 0)
-{
-
- $category = new \app\system\model\Category;
-
- // 如果参数格式不为数字的时候查询$pid
- if(is_numeric($str) == false)
+ // 获取类别列表
+ function getCategory($str = 0)
{
- // 根据父级id查询类别列表
- $str = $category
- ->where('title',$str)
- ->value('id');
- }
+ $category = new \app\system\model\Category;
- $str == '' || $str == null ? $str=0 :$str=$str;
-
-
- // 根据父级id查询类别列表
- $list = $category
- ->where('pid',$str)
- ->where('status',1)
- ->field('id,title')
- ->select();
-
-
- // 返回类别列表
- return $list;
-}
-
-
-function nianjiList($riqi=0)
-{
- // 定义学年时间节点日期为每年的8月1日
- // $yd = '8-1';
- if($riqi == 0)
- {
- $jiedian = strtotime(date('Y').'-8-1');
- $thisday = time();
- $nian = date('Y');
- }else{
- $jiedian = strtotime(date('Y',$riqi).'-8-1');
- $thisday = $riqi;
- $nian = date('Y',$riqi);
- }
-
-
- if($thisday<=$jiedian)
- {
- $str = 1;
- }else{
- $str = 0;
- }
-
-
- $nian = $nian - $str;
-
- $njlist = array();
-
- $njlist[$nian]='一年级';
- $njlist[$nian-1]='二年级';
- $njlist[$nian-2]='三年级';
- $njlist[$nian-3]='四年级';
- $njlist[$nian-4]='五年级';
- $njlist[$nian-5]='六年级';
-
- return $njlist;
-}
-
-
-// 班级列表
-function banjinamelist()
-{
- $bjarr = array(
- '1'=>'一班',
- '2'=>'二班',
- '3'=>'三班',
- '4'=>'四班',
- '5'=>'五班',
- '6'=>'六班',
- '7'=>'七班',
- '8'=>'八班',
- '9'=>'九班',
- '10'=>'十班',
- '11'=>'十一班',
- '12'=>'十二班',
- '13'=>'十三班',
- '14'=>'十四班',
- '15'=>'十五班',
- '16'=>'十六班',
- '17'=>'十七班',
- '18'=>'十八班',
- '19'=>'十九班',
- '20'=>'二十班',
- '21'=>'二十一班',
- '22'=>'二十二班',
- '23'=>'二十三班',
- '24'=>'二十四班',
- '25'=>'二十五班',
- );
-
- return $bjarr;
-}
-
-
-
-
-/**
-* $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;
- }
- }
- return $age;
-}
-
-
-// EXCEL表格列名
-function excelLieming()
-{
- $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())
-{
-
- // 实例化单位模型
- $sch = new \app\system\model\School;
- // 实例化类别数据模型
- $cat = new \app\system\model\Category;
- // 获取获取级别列表
- $catlist = $cat->where('pid',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();
-
- return $schlist;
-}
-
-
-// 整理教师名
-function teacherNames($list = array())
-{
- if(count($list) == 0 )
- {
- return '';
- }
-
-
- $names = '';
- foreach ($list as $key => $value) {
- if($key == 0)
+ // 如果参数格式不为数字的时候查询$pid
+ if(is_numeric($str) == false)
{
- $names = $value['teacher']['xingming'];
- }else{
- $names = $names . '、'. $value['teacher']['xingming'];
+ // 根据父级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();
+
+
+ // 返回类别列表
+ return $list;
}
- return $names;
-}
+
+ function nianjiList($riqi=0)
+ {
+ // 定义学年时间节点日期为每年的8月1日
+ // $yd = '8-1';
+ if($riqi == 0)
+ {
+ $jiedian = strtotime(date('Y').'-8-1');
+ $thisday = time();
+ $nian = date('Y');
+ }else{
+ $jiedian = strtotime(date('Y',$riqi).'-8-1');
+ $thisday = $riqi;
+ $nian = date('Y',$riqi);
+ }
+
+
+ if($thisday<=$jiedian)
+ {
+ $str = 1;
+ }else{
+ $str = 0;
+ }
+
+
+ $nian = $nian - $str;
+
+ $njlist = array();
+
+ $njlist[$nian]='一年级';
+ $njlist[$nian-1]='二年级';
+ $njlist[$nian-2]='三年级';
+ $njlist[$nian-3]='四年级';
+ $njlist[$nian-4]='五年级';
+ $njlist[$nian-5]='六年级';
+
+ return $njlist;
+ }
+
+
+ // 班级列表
+ function banjinamelist()
+ {
+ $bjarr = array(
+ '1'=>'一班',
+ '2'=>'二班',
+ '3'=>'三班',
+ '4'=>'四班',
+ '5'=>'五班',
+ '6'=>'六班',
+ '7'=>'七班',
+ '8'=>'八班',
+ '9'=>'九班',
+ '10'=>'十班',
+ '11'=>'十一班',
+ '12'=>'十二班',
+ '13'=>'十三班',
+ '14'=>'十四班',
+ '15'=>'十五班',
+ '16'=>'十六班',
+ '17'=>'十七班',
+ '18'=>'十八班',
+ '19'=>'十九班',
+ '20'=>'二十班',
+ '21'=>'二十一班',
+ '22'=>'二十二班',
+ '23'=>'二十三班',
+ '24'=>'二十四班',
+ '25'=>'二十五班',
+ );
+
+ return $bjarr;
+ }
+
+
+
+
+ /**
+ * $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;
+ }
+ }
+ return $age;
+ }
+
+
+ // EXCEL表格列名
+ function excelLieming()
+ {
+ $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())
+ {
+
+ // 实例化单位模型
+ $sch = new \app\system\model\School;
+ // 实例化类别数据模型
+ $cat = new \app\system\model\Category;
+ // 获取获取级别列表
+ $catlist = $cat->where('pid',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();
+
+ return $schlist;
+ }
+
+
+ // 整理教师名
+ function teacherNames($list = array())
+ {
+ if(count($list) == 0 )
+ {
+ return '';
+ }
+
+
+ $names = '';
+ foreach ($list as $key => $value) {
+ if($key == 0)
+ {
+ $names = $value['teacher']['xingming'];
+ }else{
+ $names = $names . '、'. $value['teacher']['xingming'];
+ }
+ }
+
+ return $names;
+ }
@@ -275,37 +275,6 @@ function teacherNames($list = array())
}
-
-
-
-/**
- * 数组重新排序
- * $array 要排序的数组
- * $field 排序字段
- * $sort 排序方式 SORT_DESC 降序;SORT_ASC 升序
- * */
-// function arraySequence($data, $field = 'id', $sort = 'desc') {
-
-// // // 获取当前地址
-// // $mod = strtolower(app('http')->getName());
-// // $con = strtolower(request()->controller());
-// // $act = strtolower(request()->action());
-
-// // $url = $mod.'/'.$con.'/'.$act;
-
-// // halt($url);
-// // 排序方式
-// $sort == 'desc' ? $sort = 'SORT_DESC' : $sort = 'SORT_ASC';
-// // 获取参考列
-// $column = array_column($data, $field);
-// // 排序
-// array_multisort($column, $sort, $data);
-
-
-
-// return $data;
-// }
-
function sortArrByManyField(){
$args = func_get_args();
if(empty($args)){
@@ -395,21 +364,21 @@ function subjectList()
* @param str或array $str 表单中获取的参数
* @return array 返回类型
*/
-function strToarray($str)
-{
- // 如果str是字符串,则转换成数组
- if(is_array($str)==false)
+ function strToarray($str)
{
- $str = explode(',', $str);
- }
- // 循环数组,删除空元素
- foreach ($str as $key => $value) {
- if($value == "" && $value == null){
- unset($str[$key]);
+ // 如果str是字符串,则转换成数组
+ if(is_array($str)==false)
+ {
+ $str = explode(',', $str);
}
+ // 循环数组,删除空元素
+ foreach ($str as $key => $value) {
+ if($value == "" && $value == null){
+ unset($str[$key]);
+ }
+ }
+ return $str;
}
- return $str;
-}