Do not let any software impress you!

Only let it convince your intellect.
Slider img 1
Do not look for a business paradise!

It is a waste of time.
Slider img 2
Only yourself can push you uphill.

There is no easy road to prizes.
Slider img 3
Productivity is the name of the game.

And you have to conquer it.
Slider img 4
As long as you understand it,

you will start to build your know-how.
Slider img 5
We can help with that.

We have the tools and the method.
Slider img 6

Product
Quantity
UOM
Product ID
Price
Amount
Disc
VAT
Comments
Subject
Event Type
Customer
Contact
Έκπτωση
Total Vat
Total Amount
Offered Products
Date
Number
Currency
Sales Person

Title : Sale Offer

Toolbars

call BrowseEditDelete()
call CloseForm(True)
call CloseForm(False)

Buttons

Fields


 (AU_GOOD.CODE)
 (AU_GOOD.TITLE)
 (AU_KE_GOOD.QUANT)
 (AU_UNITMEAS.CODE)
 (AU_KE_GOOD.PRICE)
 (AU_KE_GOOD.VAT_PC)
 (AU_KE_GOOD.DISCOUNT)
 (AU_KE_GOOD.AMOUNT)
 (AU_KE_GOOD.COMMENT)
Subject (AU_EVENT.SUBJECT)
Event Type (AU_T_EVENT.DESCR)
Customer (AU_BUSINESS.TITLE)
Contact (AU_CONTACT.DISP_NAME)
¸êðôùóç (AU_EVENT.DISCOUNT)
Total Vat (AU_EVENT.VAT)
Total Amount (AU_EVENT.TOTAL_AMOUNT)
Date (AU_EVENT.DATE)
Number (AU_EVENT.NUMBER)
Currency (AU_CURRENCY.CCODE)
Sales Person (AU_CONTACT.DISP_NAME)
After Comment (AU_EVENT.MEMO2)
Before Comment (AU_EVENT.MEMO1)
Comments (AU_EVENT.MEMO)


AutoScript

lib

proc Form_Start()

     f = TopForm()
     p = PByName(f,"AU_EVENT")
     t = TByName(p,"AU_EVENT")
     pg = PByName(f,"AU_KE_GOOD")
     tg = TByName(pg,"AU_KE_GOOD")

     call OnOpenForm_DisableField("TOTAL_AMOUNT")

     task = FormTask(f)

     if (task = ptAppend) then

        str = SelectFrom("SELECT AU_T_EVENT, DESCR, CODE FROM AU_T_EVENT WHERE (CODE='AU_OFFER')")
        tevent = GetSQLSelectItem(str,1)
        tevent_descr = GetSQLSelectItem(str,2)
        tevent_code = GetSQLSelectItem(str,3)

        str = SelectFrom("SELECT AU_CURRENCY, CCODE FROM AU_CURRENCY WHERE (CCODE='EUR')")
        c_id = GetSQLSelectItem(str,1)
        ccode = GetSQLSelectItem(str,2)

        subject = GetMailSubject()
        cont_id = GetMailContactId()
        contname = SelectFrom("SELECT DISP_NAME FROM AU_CONTACT WHERE (AU_CONTACT=",cont_id,")")
        bus_id = GetMailBusinessId()
        busname = SelectFrom("SELECT TITLE FROM AU_BUSINESS WHERE (AU_BUSINESS=",bus_id,")")
        memo1 = GetMailText()

        call TEdit(t)
        call TSetFld(t,"AU_T_EVENT",tevent)
        call TSetFld(t,"F_AU_T_EVENT_CODE",tevent_code)
        call TSetFld(t,"F_AU_T_EVENT_DESCR",tevent_descr)
        call TSetFld(t,"AU_CURRENCY",c_id)
        call TSetFld(t,"F_AU_CURRENCY_CCODE",ccode)
        call TSetFld(t,"CONTACT_TO",cont_id)
        call TSetFld(t,"F_CONTACT_TO_DISP_NAME",contname)
        call TSetFld(t,"BUSINESS_TO",bus_id)
        call TSetFld(t,"F_BUSINESS_TO_TITLE",busname)
        call TSetFld(t,"SUBJECT",subject)
        call TSetFld(t,"MEMO",memo1)
        call TPost(t)

        call ReLoadEditFields(f)

     endif

     {......................................selection lists..............}
     start_sql "DESCR_SEL" "KOSMOS"
       SELECT AU_T_EVENT.DESCR, AU_T_EVENT.AU_T_EVENT
       FROM AU_KEVENT INNER JOIN AU_T_EVENT
       ON AU_KEVENT.AU_KEVENT = AU_T_EVENT.KEVENT1
       WHERE (AU_T_EVENT.KEVENT1=2)
       AND ((AU_T_EVENT.MOVE_VALUES_FLAG = 0) OR (AU_T_EVENT.MOVE_VALUES_FLAG IS NULL))
       AND (AU_T_EVENT.DESCR LIKE :E & '%')
       ORDER BY AU_T_EVENT.DESCR
     end_sql

     ft = FormTask(f)

     if (task = ptAppend) then
        call SetCaption("New Sale Offer")
     else
        call SetCaption("Sale Offer")
     endif

end

proc Select_DESCR_SEL_Params()

   s = GetEditedText()
   call ParamsEmbSQL("DESCR_SEL";s)

end

{============================ Form_OnSelect ===========================}

proc Form_OnSelect (tname, fldname, str, t, oldstr, sq )

     if (tname = "AU_GOOD") then

        f = TopForm()
        p = PByName(f,"AU_KE_GOOD")
        t = TByName(p,"AU_KE_GOOD")
        line = TRecNo(t)
        line = line - 1

        {.............ðáñå ôçí ôéìç êáôáëüãïõ...}
        price = TGetFldNum(sq,"RCOST0")

        call TEdit(t)
        call TSetFld(t,"PRICE",price)
        call TPost(t)

        call pc_exit()
        call price_exit()

        call ReLoadEditFields(f)

     endif
end

proc eidh_exit()

     f      = TopForm()
     pke_eid = PByName(f;"AU_KE_GOOD")
     t      = TByName(pke_eid;"AU_KE_GOOD")
     line = TRecNo(t)
     line = line - 1

     eid = TGetFld(t;"AU_GOOD")
     start_sql "*" "KOSMOS"
         SELECT AU_UNITMEAS.CODE, AU_UNITMEAS.AU_UNITMEAS
         FROM AU_GOOD_UNITMEAS INNER JOIN AU_UNITMEAS ON AU_GOOD_UNITMEAS.AU_UNITMEAS = AU_UNITMEAS.AU_UNITMEAS
         WHERE (((AU_GOOD_UNITMEAS.AU_GOOD)=:GOOD) AND ((AU_GOOD_UNITMEAS.IS_MAIN)='1'));
     end_sql
     q = QueryByName()
     call TSetParam(q,"GOOD",eid)
     call TExecute(q)
     mm     = TGetFld(q,"AU_UNITMEAS")
     mm_c = TGetFld(q,"CODE")
     call FreeEmbSQL(q)

     start_sql "*" "KOSMOS"
         SELECT AU_RESOURCE_COST.RCOST0, AU_RESOURCE.RECID
         FROM AU_RESOURCE INNER JOIN AU_RESOURCE_COST ON AU_RESOURCE.AU_RESOURCE = AU_RESOURCE_COST.AU_RESOURCE
         WHERE (((AU_RESOURCE_COST.IS_VALID)='1') AND ((AU_RESOURCE.RTYPE)='AU_GOOD') AND ((AU_RESOURCE.RECID)=:GOOD));
     end_sql
     q = QueryByName()
     call TSetParam(q,"GOOD",eid)
     call TExecute(q)
     price = TGetFLD(q,"RCOST0")
     call FreeEmbSQL(q)

     call TEdit(t)
     call TSetFld(t;"AU_UNITMEAS";mm)
     call TSetFld(t;"F_AU_UNITMEAS_CODE";mm_c)
     call TSetFld(t;"PRICE";price)
     posot = TGetFld(t,"QUANT")
     posot = val(posot)
     if (posot = 0) then
        call TSetFld(t;"QUANT";"1")
     endif
     call TPost(t)

     call ReLoadEditFields(f;pke_eid;line)

end

proc posot_exit()

     f      = TopForm()
     pke_eid = PByName(f;"AU_KE_GOOD")
     t      = TByName(pke_eid;"AU_KE_GOOD")
     line = TRecNo(t)
     line = line - 1

     posot = TGetFld(t,"QUANT")
     timi = TGetFld(t,"PRICE")
     ekpt = TGetFld(t,"DISCOUNT")
     fpa     = TGetFld(t,"VAT_PC")
     axia = posot*timi -posot * timi*ekpt/100
     axia = axia + axia*fpa/100

     call TEdit(t)
     call TSetFld(t,"AMOUNT",axia)
     call TPost(t)

     call ReLoadEditFields(f;pke_eid;line)

end

{============================== get_total ================================}

fun get_total()

    rcount = TRecordCount(tg
    recno = TRecNo(tg

    total = 0
    call TFirst(tg
    for i = 1 to rcount
        am = TGetFld(tg,"AMOUNT")

        total = total + am

        call TNext(tg)
    next

    call TGotoCurRow(tg,recno)

    result = total

end

{============================== get_vat ================================}

fun get_vat()

    rcount = TRecordCount(tg
    recno = TRecNo(tg

    total = 0
    call TFirst(tg
    for i = 1 to rcount
        fpa = TGetFld(tg,"VAT_PC")
        amount = TGetFld(tg,"AMOUNT")

        total = total + amount*fpa/100

        call TNext(tg)
    next

    call TGotoCurRow(tg,recno)

    result = total

end

{============================== set_discount ================================}

proc set_discount()


    rcount = TRecordCount(tg
    recno = TRecNo(tg)
     disc = TGetFld(t,"DISCOUNT")

    totalVat = 0
    call TFirst(tg
    for i = 1 to rcount

       posot = TGetFld(tg,"QUANT")
       timi = TGetFld(tg,"PRICE")
       fpa = TGetFld(tg,"VAT_PC")
       axia = posot*timi -posot * timi*disc/100
     ` axia = axia + axia*fpa/100

        call TEdit(tg)
        call TSetFld(tg,"DISCOUNT",disc)
        call TSetFld(tg,"AMOUNT",axia)
        call TPost(tg)

        call TNext(tg)
    next

    call TGotoCurRow(tg,recno)

    call ReLoadEditFields(f)

end

fun get_date()

    result = iif(AU_EVENT!DATE<>"", AU_EVENT!DATE, crDate)

end

{============================== Form_BeforeClose ==========================}

fun Form_BeforeClose()

    result = 1
return
    f     = TopForm()
    fname = GetResName(f)
    p     = PByName(f;"AU_KE_GOOD")
    t     = TByName(p;"AU_KE_GOOD")
    pev = PByName(f;"AU_EVENT")
    t_ev = TByName(pev;"AU_EVENT")

    tev = TGetFld(t_ev;"AU_T_EVENT")
    diak = LookUp("AU_T_EVENT";"AU_T_EVENT";tev;"DIAK_AXION";"")

    rcount = TRecordCount(t)
    call TFirst(t)

    for i = 1 to rcount
        eid = TGetFld(t;"AU_GOOD")

        pos = TGetFld(t;"QUANT")
        axi = TGetFld(t;"AMOUNT")

        if (eid = 0) then
         call message("Move without Good!")
         result = 0
         return
        endif

        if (pos = 0) then
         call message("Move without Quantity!")
         result = 0
         return
        endif

        if (diak = 1) then
         if (axi = 0) then
         call message("Move without Amount!")
         result = 0
         return
         endif
        endif

        call TNext(t)
    next

    endif

end

{============================= Form_End ===============================}

proc Form_End ( uvalue )

     if (task = ptAppend) then {....in case of an independent appending (user appending}}

        param = GetParameter("AU_STARTCOORDINATORONSALESOFFER")

        if (param = "TRUE") then

         call bpm_startcoordinator ( "AU_SALE_OFFER_COORDINATOR", uvalue )

        endif

     endif

end {...form end}