@@ -7,7 +7,7 @@ import { Klass } from 'src/db/entities/Klass.entity';
77import { User } from '@shared/entities/User.entity' ;
88import { In , FindOptionsWhere } from 'typeorm' ;
99import { getReportDateFilter , getDateRange } from '@shared/utils/entity/filters.util' ;
10- import { ISpecialField } from '@shared/utils/importer/types' ;
10+ import { IImageField , ISpecialField } from '@shared/utils/importer/types' ;
1111import * as ExcelJS from 'exceljs' ;
1212import { getUniqueValues , groupDataByKeysAndCalc , groupDataByKeyFn } from '@shared/utils/reportData.util' ;
1313import { ReportGroup } from 'src/db/entities/ReportGroup.entity' ;
@@ -40,6 +40,7 @@ interface SessionData {
4040 topic : string ;
4141 lessonCount : number ;
4242 teacherName : string ;
43+ signatureData ?: string ;
4344}
4445
4546interface StudentAttendanceData {
@@ -137,6 +138,7 @@ const getReportData: IGetReportDataFunction<KlassAttendanceReportParams, KlassAt
137138 topic : session ?. reportGroup ?. lesson ?. name || '' ,
138139 lessonCount : session ? lessonCountsBySession [ session . id ] : 0 ,
139140 teacherName : session ?. reportGroup ?. teacher ?. name || '' ,
141+ signatureData : session ?. reportGroup ?. signatureData ,
140142 } ) ) ;
141143 } ) ;
142144
@@ -419,6 +421,45 @@ const BUILDING = {
419421 } ;
420422 } ,
421423
424+ // Build signature section: one signature (first available) below the entire table
425+ buildSignatureSection ( sessions : SessionData [ ] , tableEndRow : number ) {
426+ const signatureRow = tableEndRow + 2 ; // Leave 2 rows spacing after table
427+
428+ const firstSignature = sessions . find ( s => s . signatureData ) ?. signatureData ;
429+
430+ const specialFields : ISpecialField [ ] = [ ] ;
431+ const images : IImageField [ ] = [ ] ;
432+
433+ if ( firstSignature ) {
434+ specialFields . push ( {
435+ cell : { r : signatureRow , c : 0 } ,
436+ value : 'חתימת המורה' ,
437+ style : {
438+ font : { bold : true , size : 12 , name : 'Arial' } ,
439+ alignment : {
440+ horizontal : 'center' as const ,
441+ vertical : 'middle' as const ,
442+ readingOrder : 'rtl' as const
443+ }
444+ }
445+ } ) ;
446+
447+ images . push ( {
448+ imageBase64Data : firstSignature ,
449+ position : {
450+ tl : { row : signatureRow , col : 1 } ,
451+ ext : { width : 120 , height : 80 }
452+ }
453+ } ) ;
454+ }
455+
456+ return {
457+ specialFields,
458+ images,
459+ additionalRows : firstSignature ? 8 : 0
460+ } ;
461+ } ,
462+
422463 // Main function - orchestrates building the Excel data structure
423464 buildExcelData ( data : KlassAttendanceReportData ) : KlassAttendanceReportData {
424465 const { klassName, institutionName, institutionCode, sessions, students, startDate, endDate } = data ;
@@ -436,17 +477,23 @@ const BUILDING = {
436477 const tableSection = BUILDING . buildTableSection ( sessions , students ) ;
437478
438479
439- // 3. Combine everything
480+ // 3. Build signature section - one signature below the table
481+ const signatureSection = BUILDING . buildSignatureSection ( sessions , tableSection . totalRowCount ) ;
482+
483+ // 4. Combine everything
440484 const specialFields = [
441485 ...titleSection . specialFields ,
442486 ...tableSection . specialFields ,
487+ ...signatureSection . specialFields ,
443488 ] ;
444489 const borderRanges = [ ...titleSection . borderRanges , ...tableSection . borderRanges ] ;
490+ const images = signatureSection . images ;
445491
446492 console . log ( 'buildExcelData output:' , {
447- rowCount : tableSection . totalRowCount ,
493+ rowCount : tableSection . totalRowCount + signatureSection . additionalRows ,
448494 specialFieldCount : specialFields . length ,
449495 borderRangeCount : borderRanges . length ,
496+ imageCount : images . length ,
450497 } ) ;
451498
452499 return {
@@ -462,6 +509,7 @@ const BUILDING = {
462509 sheetName : klassName || 'יומן נוכחות' ,
463510 specialFields,
464511 borderRanges,
512+ images,
465513 } ;
466514 }
467515}
0 commit comments