This commit is contained in:
Dai 2024-09-09 16:06:56 +08:00
parent e5794d4822
commit c7b3f1ff2f

View File

@ -67,13 +67,15 @@ class TeacherScheduleTimeController extends BaseController
foreach ($student_schedule as $k => &$v) {
if ($v['studentSchedule']) {
$student = [];
foreach ($v['studentSchedule'] as $k1 => $v1) {
if ($v1['is_publish']) {
$student[] = $v1['student_name'];
}
}
} else {
$student[] = '';
}
$array[] = [
@ -82,7 +84,7 @@ class TeacherScheduleTimeController extends BaseController
'time_on' => $v['time'],
'subject' => $v['english_name'],
'teacher_name' => $v['teacher_name'],
'student_name' => implode(',', $student),
'student_name' => implode(',', array_unique($student)),
'time_num' => $v['hour'] . '/h',
];
$stu_nmae = $v['teacher_name'];
@ -95,6 +97,8 @@ class TeacherScheduleTimeController extends BaseController
'table_time' => $month,
'data' => $array,
];
$file_path = '/files/images/teacher_schedule/' . $month . "/{$request->teacher->id}/";
$base = [
'border' => 10,//图片外边框
@ -155,7 +159,7 @@ class TeacherScheduleTimeController extends BaseController
$sub = 0;
foreach ($item as $value) {
$sub++;
imagettftext($img, $base['text_size'], 0, $base['column_x_arr'][$sub] - $base['row_text_offset_arr'][$sub], $border_top + $base['row_hight'] - 10, $text_coler, $base['font_ulr'], $value);//写入data数据
imagettftext($img, $base['text_size'], 0, $base['column_x_arr'][$sub] - $base['row_text_offset_arr'][$sub], $border_top + $base['row_hight'] - 10, $text_coler, $base['font_ulr'], $value ?? '');//写入data数据
}
}
//计算标题写入起始位置
@ -164,7 +168,7 @@ class TeacherScheduleTimeController extends BaseController
$title_fout_width = $title_fout_box[2] - $title_fout_box[0];//右下角 X 位置 - 左下角 X 位置 为文字宽度
$title_fout_height = $title_fout_box[1] - $title_fout_box[7];//左下角 Y 位置- 左上角 Y 位置 为文字高度
//居中写入标题
imagettftext($img, $base['title_font_size'], 0, ($base['img_width'] - $title_fout_width) / 2, $base['title_height'], $text_coler, $base['font_ulr'], $params['title']);
imagettftext($img, $base['title_font_size'], 0, round(($base['img_width'] - $title_fout_width) / 2), $base['title_height'], $text_coler, $base['font_ulr'], $params['title']);
//写入制表时间
imagettftext($img, $base['text_size'], 0, $base['border'], $base['title_height'], $text_coler, $base['font_ulr'], 'Date' . $params['table_time']);
$save_path = $base['file_path'] . $params['file_name'];
@ -191,7 +195,6 @@ class TeacherScheduleTimeController extends BaseController
}
public function getWeek($date)
{
// $week_array = array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");