Handtekening

  • 2 minutes to read

Controladdins

CFLImageViewer

Weergeven van afbeelding.

Op de pagina waar je de handtekening wil weergeven voorzie je

  • usercontrol voor de imageviewer:
 usercontrol(CFLImageViewer; CFLImageViewer)
    {
        ApplicationArea = All;  

        trigger ControlAddinReady()  
        var
            tempBlob: codeunit "Temp Blob";  
            CFLImageViewerMgt: Codeunit "CFL Image Mgt";  
        begin
            CalcFields("CFL Signature");  
            tempBlob.FromRecord(rec, rec.FieldNo("CFL Signature"));  
            CurrPage.CFLImageViewer.SetImage(CFLImageViewerMgt.GetPngUri(tempBlob)); 
            SignatureControlReady := true;  
        end;
    }
  • onaftergetrecord
trigger OnAfterGetRecord()
    var
        tempBlob: codeunit "Temp Blob";
        CFLImageViewerMgt: Codeunit "CFL Image Mgt";
    begin
        CalcFields("CFL Signature");
        tempBlob.FromRecord(rec, rec.fieldno("CFL Signature"));
        IF SignatureControlReady then
            CurrPage.CFLImageViewer.SetImage(CFLImageViewerMgt.GetPngUri(tempBlob));
    end;
  • Globale variabele:
    var
        SignatureControlReady: Boolean;

CFLSignatureControl

Capteren van handtekening.

Pages

CFL Signature

Pagina voor het capteren van een handtekening (implementatie van de CFLSignatureControl Addin). Functie voor het ophalen van de ingegeven handtekening:

procedure CFLGetSignature

procedure CFLGetSignature(var tmpBlob: codeunit "Temp Blob") ok: boolean

Retouneert de ingegeven handtekening.
returnvalue ok = true indien een handtekening is ingegeven.

Op de pagina waar je een handtekening wil capteren voorzie je deze action:

action(CFLSign)
{
    ApplicationArea = All;
    Caption = 'Sign';
    image = Signature;
    Promoted = true;
    PromotedIsBig = true;
    PromotedCategory = process;

    trigger OnAction()
    var
        CFLSignature: page "CFL Signature";
        tempBlob: codeunit "Temp Blob";
        CFLImageViewerMgt: Codeunit "CFL Image Mgt";
        OStream: OutStream;
        IStream: InStream;
        CFLUpdateSalesShipmentHeader: codeunit "CFL Update Sales Shpmt. Header";
    begin
        CFLSignature.RunModal();
        if CFLSignature.CFLGetSignature(tempBlob) then begin
            //de handtekening afbeelding zit in de tempblob en kan je nu opslaan.
            CurrPage.CFLImageViewer.SetImage(CFLImageViewerMgt.GetPngUri(tempBlob));
        end;
    end;
}

Voorbeeld

Hieronder een voorbeeld waarbij de signature wordt toegepast op de verkoopofferte en afgedrukt op het PDF-Tools rapport.

tableextension 50101 "SalesHeaderExt" extends "Sales Header"
{
    fields
    {
        field(50100; Signature; blob)
        {
            caption = 'Signature';
            Subtype = Bitmap;
        }
    }

    var
        myInt: Integer;
}

pageextension 50002 SalesQuoteExt extends "Sales Quote"
{
    layout
    {
        addlast(General)
        {
            group(CFLSignature)
            {
                Caption = 'Signature';
                usercontrol(CFLImageViewer; CFLImageViewer)
                {
                    ApplicationArea = All;
 
                    trigger ControlAddinReady()
                    var
                        tempBlob: codeunit "Temp Blob";
                        CFLImageViewerMgt: Codeunit "CFL Image Mgt";
                    begin
                        CalcFields("Signature");
                        tempBlob.FromRecord(rec, rec.FieldNo("Signature"));
                        CurrPage.CFLImageViewer.SetImage(CFLImageViewerMgt.GetPngUri(tempBlob));
                        SignatureControlReady := true;
                    end;
 
                }
            }
        }
    }
 
    actions
    {
        addlast("&Quote")
        {
            action(Sign)
            {
                ApplicationArea = All;
                Caption = 'Sign';
                image = Signature;
                Promoted = true;
                PromotedIsBig = true;
                PromotedCategory = process;
 
                trigger OnAction()
                var
                    CFLSignature: page "CFL Signature";
                    tempBlob: codeunit "Temp Blob";
                    CFLImageViewerMgt: Codeunit "CFL Image Mgt";
                    OStream: OutStream;
                    IStream: InStream;
                begin
                    CFLSignature.RunModal();
                    if CFLSignature.CFLGetSignature(tempBlob) then begin
                        tempBlob.CreateInStream(IStream);
                        Signature.CreateOutStream(OStream);
                        Copystream(OStream, IStream);
                        Rec.Modify(true);
                        CurrPage.CFLImageViewer.SetImage(CFLImageViewerMgt.GetPngUri(tempBlob));
                    end;
                end;
            }
        }
    }
 
    trigger OnAfterGetRecord()
    var
        tempBlob: codeunit "Temp Blob";
        CFLImageViewerMgt: Codeunit "CFL Image Mgt";
    begin
        CalcFields("Signature");
        tempBlob.FromRecord(rec, rec.fieldno("Signature"));
        IF SignatureControlReady then
            CurrPage.CFLImageViewer.SetImage(CFLImageViewerMgt.GetPngUri(tempBlob));
    end;
 
    var
        SignatureControlReady: Boolean;
}

codeunit 50101 "SalesQuoteSubs"
{
    [EventSubscriber(ObjectType::Report, Report::"CFL Sales - Quote", 'CFLOnAfterAddTotalsToDocument', '', false, false)]
    local procedure CFLOnAfterAddTotalsToDocument(SalesHeader: Record "Sales Header"; var intCounter: Integer; var PDFProgram: Codeunit "CFL PDFProgram")
    var
        CFLbase64Convert: codeunit "CFL Base64 Convert";
        Base64: text;
        IStream: instream;
    begin
        SalesHeader.CalcFields(Signature);
        if SalesHeader.Signature.HasValue then begin
            SalesHeader.Signature.CreateInStream(istream);
            BAse64 := CFLbase64Convert.CFLStreamToBase64String(IStream);
            PDFProgram.CFLSetFieldImage('LangeOmschrijving.' + format(intcounter), base64, 150);
        end;
    end;
}