Case of
: (_rep_Event (_rep_kBody)=kTrue)
wo_tCompany:=wo_asCompany_id{SRRecord}
wo_dDeliveryDate:=wo_adDelivery_Date{SRRecord}
wo_tCustomerOrderNumber:=""
wo_tSalesOrder:=wo_asSales_Order_id{SRRecord}
$wo_SoIndex:=Find in array(sor_asSales_Order_id;wo_tSalesOrder)
If ($wo_SoIndex>0)
wo_tCustomerOrderNumber:=so_asCustomer_Order_Number{$wo_SoIndex}
  //wo_tCompany:=so_asCompany_id{$wo_SoIndex}
wo_tCompany:=co_asName{$wo_SoIndex}
wo_dDeliveryDate:=so_adFirst_Delivery_Date{$wo_SoIndex}
End if

wo_tMaterial:=pr_asProduct_id{SRRecord}
wo_tPhases:=wo_atInfo{SRRecord}
wo_tSalesProduct:=""
$wo_lSorIndex:=_arr InTwoFind (->sor_asSales_Order_id;->wo_asSales_Order_id{SRRecord};->sor_alRow_Number;->wo_alSales_Order_Row_id{SRRecord};1)
If ($wo_lSorIndex>0)
wo_dDeliveryDate:=sor_adDelivered_Date{$wo_lSorIndex}
If (sor_asProduct_id{$wo_lSorIndex}#pr_asProduct_id{SRRecord})
wo_tSalesProduct:=sor_asProduct_id{$wo_lSorIndex}
End if
End if

wo_tFile:=wo_asDrawing_Number{SRRecord}
_pict:=_pict*0
If(wo_tFile#"")
wo_lDocIndex:=Find in array(wo_atDocumentInFolder;"@"+wo_tFile+"@.geo")
If (wo_lDocIndex<=0)
  wo_tFile:=Replace string(wo_tFile;"-";"_")
  wo_lDocIndex:=Find in array(wo_atDocumentInFolder;"@"+wo_tFile+"@.geo")
End if
If (wo_lDocIndex>0)
_doc_ Execute (wo_tConverterPath;"-s -w 300 -h 300 -b"+ksSpace+ksQuoteDouble+wo_atDocPathtInFolder{wo_lDocIndex}+ksQuoteDouble;"";0)
wo_tDocPath:=Replace string(wo_atDocPathtInFolder{wo_lDocIndex};".geo";".bmp")
If (wo_tDocPath#"") & (Test path name(wo_tDocPath)>0)
READ PICTURE FILE(wo_tDocPath;_pict)
_doc DELETE (wo_tDocPath)
End if
End if
End if

: (_rep_Event (_rep_kInit)=kTrue)
COMPILER_sor
COMPILER_wos
COMPILER_pr
C_PICTURE(_pict)
_rep_ARRAYS (wo_kTbl;co_kName;pr_kName;pr_kProduct_ID)


: (_rep_Event (_rep_kStart)=kTrue)
If(_el Tbl=so_kTbl)
_sel_ SEL_TO_ARR_ONE (so_kSales_Order_ID;->so_asSales_Order_ID)
_qry ARRAY (wo_kSales_Order_id;->so_asSales_Order_ID
End if

_rep_SELECTION_TO_ARRAYS
_rep_ORDER (wo_kSales_Order_id;wo_kSales_Order_Row_id;wo_kDelivery_Date;wo_kProduction_Lot;wo_kInfo)

$wo_lArrSize:=Size of array(wo_asProduction_Lot)
_thm OPEN ($wo_lArrSize+3;_lang Current ("Loading arrays")+"...";_fld Name (_rep_kName);True)

_thm UPDATE (1)
ARRAY TEXT(wo_atDocumentInFolder;0)
ARRAY TEXT(wo_atDocPathtInFolder;0)
C_TEXT(wo_tPath;wo_tConverterPath;wo_tDocPath)
wo_tPath:="Y:\\"
wo_tPath:=_doc_ PathReplace (kTrue;wo_tPath;"")
wo_tConverterPath:="C:\\TRUMPF.NET\\Utils\\geoview\\bin\\geoviewer.exe"
wo_tConverterPath:=_doc_ PathReplace (kTrue;wo_tConverterPath;"")
Case of
: (Test path name(wo_tPath)#Is a directory)
_err MESSAGE (_lang Current ("Directory not found")+": "+wo_tPath;Current method name;kFalse)
: (Test path name(wo_tConverterPath)#Is a document)
_err MESSAGE (_lang Current ("Geoviewer not found")+": "+wo_tConverterPath;Current method name;kFalse)
Else

ARRAY TEXT(_atArr;0)
ARRAY LONGINT(_alArr;0)
ARRAY TEXT(_atArr2;0)
_doc FOLDER_STRUCTURE_CREATE (wo_tPath;1;->_atArr;->_alArr;->_atArr2)
COPY ARRAY(_atArr;wo_atDocumentInFolder)
COPY ARRAY(_atArr2;wo_atDocPathtInFolder)
ARRAY TEXT(_atArr;0)
ARRAY LONGINT(_alArr;0)
ARRAY TEXT(_atArr2;0)
End case

_thm UPDATE (2)
_qry ARRAY (sor_kSales_Order_id;->wo_asSales_Order_id)
_ptr:=_fld PtrToFldNumArr (sor_kSales_Order_id;sor_kRow_Number;sor_kProduct_id;sor_kDelivered_Date;so_kCustomer_Order_Number;so_kFirst_Delivery_Date;so_kCompany_id;co_kName)
_ptr2:=_fld PtrToFldArr2 (_ptr)
_sel SEL_TO_ARR (_ptr;_ptr2)

_thm UPDATE (3)
_qry ARRAY (wos_kProduction_Lot;->wo_asProduction_Lot)
_ord FLD (wos_kTbl;wos_kWork_Phase;kTrue)
_sel_ SEL_TO_ARR_TWO (wos_kProduction_Lot;->wos_asProduction_Lot;wos_kWork_Load_Group_id;->wos_asWork_Load_Group_id)

For ($wo_lIndex;1;$wo_lArrSize)
_thm UPDATE ($wo_lIndex+2)
If (_thm Cancelled =kTrue)
$wo_lIndex:=$wo_lArrSize+1
Else
wo_atInfo{$wo_lIndex}:=""
$wo_lIndex2:=Find in array(wos_asProduction_Lot;wo_asProduction_Lot{$wo_lIndex})
If($wo_lIndex2>0)
While ($wo_lIndex2>0)
If (wos_asWork_Load_Group_id{$wo_lIndex2}#<>w_tRawMaterialLoadGroupId)
If (wo_atInfo{$wo_lIndex}#"")
wo_atInfo{$wo_lIndex}:=wo_atInfo{$wo_lIndex}+", "
End if
wo_atInfo{$wo_lIndex}:=wo_atInfo{$wo_lIndex}+wos_asWork_Load_Group_id{$wo_lIndex2}
End if
$wo_lIndex2:=Find in array(wos_asProduction_Lot;wo_asProduction_Lot{$wo_lIndex};$wo_lIndex2+1)
End while
End if
End if
End for
_thm CLOSE

End case
