Function ReadSQL(W: String): String;
Begin
  Result:= 'Set DateFormat DMY '#13#10 + 
    ' Select '#13#10 + 
    '   OB.BOLUMADI, SUM(MIKTAR * H.UCRET) AS TUTAR '#13#10 + 
    ' FROM TBLOTOISEMRIHAREKET H '#13#10 + 
    ' LEFT OUTER JOIN TBLOTOBOLUMLER OB ON OB.ID = H.BOLUMID '#13#10 + 
	' LEFT OUTER JOIN TBLOTOISEMRI I ON I.ID = H.BASLIKID '#13#10 + 
    ' WHERE SATIRTIPI <> 2 '#13#10;
	
  if W <> '' Then 
    Result:= Result + ' AND CAST(CONVERT(VARCHAR, TARIH, 104) AS DATETIME) = CAST(' + QuotedStr(W) + ' AS DATETIME)'#13#10;
 
 Result:= Result + ' GROUP BY BOLUMADI '#13#10 + 
End;

procedure RaporLoad;
Begin
  if FFilter <> '' Then
  Begin
    SetQueryParam('kullaniciQ', 'TARIH', FFilter);
  End;  
End;

Function RaporFileName: String;
Begin
  Result:=  ParsDir + 'Oto Servis\BolumGunSonu.fr3';
End;

Function RaporDefaultSQL: String;
Begin
  Result:= ReadSQL(DateToStr(Date));
End;

procedure Start;
Begin
End;

Procedure Finish;
Begin
End;

Function ReadFilter(Var F: String): Boolean;
Var
  t1: TDateTime;
Begin
  F:= '';
  Result:= InputDate('Tarihi Girin', t1);
  if Result Then
   F:= DateToStr(T1);
End;

procedure Execute;
Var
  IDS: String;
Begin
  if ReadFilter(IDS) Then
  Begin
    CreateReport(IDS, ReadSQL(IDS), 
     'BOLUMADI;TUTAR', 
	 'Bölüm Adı;Servis Tutarı', 
	  0);
	
	CreateSummary('TUTAR', skSum);   
  End;
End;

Begin
End.