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

No
Event Type
Reason
Accept From Production
Accept From Sales
First Date
Last Date
Date
Notes

Title : Event

Toolbars

call CloseForm(True)
call load()
call CloseForm(False)

Buttons

Fields


No (AU_EVENT.NUMBER)
 (AU_T_EVENT.DESCR)
Event Type (AU_T_EVENT.CODE)
Reason (AU_EVENT.REASON1)
Accept From Production (AU_EVENT.PROD0_ACCEPT_FLAG)
Accept From Sales (AU_EVENT.PROD1_ACCEPT_FLAG)
First Date (AU_EVENT.DATE1)
Last Date (AU_EVENT.DATE2)
Date (AU_EVENT.DATE)
Notes (AU_EVENT.NOTES)


AutoScript

lib

{================================== Form_Start ==============================}

proc Form_Start()

     f = TopForm()
     task = FormTask(f)
     p = PByName(f,"AU_EVENT")
     t = TByName(p,"AU_EVENT")

     __params[6] = val(__params[6])
     if (__params[6] = 0) then
        call OnOpenForm_HideControl("PLAN_BTN")
     endif

     call SetCaption("Production Order")

     if (task = ptAppend) then

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

        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,"STATUS","MASSIVE")
        call TPost(t)

        call ReLoadEditFields(f)

     endif

     {......................................selection lists..............}
     start_sql "DESCR_SEL" "KOSMOS"
       SELECT AU_T_EVENT.DESCR, AU_T_EVENT.CODE, 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=15)
       AND (AU_T_EVENT.DESCR LIKE :E & '%')
       ORDER BY AU_T_EVENT.DESCR
     end_sql
     start_sql "CODE_SEL" "KOSMOS"
       SELECT AU_T_EVENT.CODE, 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=15)
       AND (AU_T_EVENT.CODE LIKE :E & '%')
       ORDER BY AU_T_EVENT.CODE
     end_sql

end

proc Select_DESCR_SEL_Params()

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

end

proc Select_CODE_SEL_Params()

   s = GetEditedText()
   call ParamsEmbSQL("CODE_SEL",s)

end

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

fun Form_BeforeClose()

    result = 1

    comm1 = TGetFld(t,"REASON1")
end

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

proc Form_End ( uvalue )

     if (task = ptAppend) then

        call bpm_startcoordinator ( "AU_PRODUCTION_MASS_COORDINATOR", uvalue, "AU_MASS_PROD_ORDER_E.FM", comm1 )

     else

        call bpm_clientchangescomments(f,comm1)

     endif

end

{================================ plan_production ============================}

proc plan_production()

     __step_descr = "Production"                    { description of production activity to be created }
     __step_role = "Production Dept"          { assigned role of production activity }
     __agent_name = __params[7]                     { mass production agent name }
     __agent_id = __params[8]                     { mass production agent id }
     __mass_order_id = TGetFld(t,"AU_EVENT")      { mass order id }
     __warehouse_in_id = 1                          { warehouse id of raw matterials }
     __warehouse_out_id = 1                         { warehouse of products }
     __process_id = __params[6]
     __date1 = TGetFld(t,"DATE1")
     __date2 = TGetFld(t,"DATE2")

     call sched_calculate()

end

proc load()

     event_id = TGetFld(t,"AU_EVENT")

     start_sql "*" "KOSMOS"
       SELECT * FROM AU_EVENT_PROD
       WHERE (LEV = 0) AND (AU_EVENT = 613)
     end_sql
     q1 = QueryByName()
     call TExecute(q1)
     count = TRecordCount(q1)

     call TFirst(q1)
     for i = 1 to count

         prodform_id = TGetFld(q1,"AU_PROD_FORM")
         quant = TGetFld(q1,"QUANT")
         umeas_id = TGetFld(q1,"AU_UNITMEAS")
         good_id = TGetFld(q1,"AU_GOOD")
         lev = TGetFld(q1,"LEV")
         fprod_id = TGetFld(q1,"FINAL_PROD")

         start_sql "*" "KOSMOS"
         INSERT INTO AU_EVENT_PROD
         end_sql
         q2 = QueryByName()
         call TSetFld(q2,"AU_EVENT","Float",event_id)
         call TSetFld(q2,"AU_PROD_FORM","Float",prodform_id)
         call TSetFld(q2,"QUANT","Float",quant)
         call TSetFld(q2,"AU_UNITMEAS","Float",umeas_id)
         call TSetFld(q2,"AU_GOOD","Float",good_id)
         call TSetFld(q2,"LEV","Float",lev)
         call TSetFld(q2,"FINAL_PROD","Float",fprod_id)
         call TExecute(q2)
         call FreeEmbSQL(q2)

         call TNext(q1)
     next
     call FreeEmbSQL(q1)

end