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
Procedure : AU_PROJECT_FSM_AGENT

AutoScript

start_agent_info
   AgentName = "AU_PROJECT_FSM_AGENT"
   AgentDescr = "Project Agent"
   AgentLanguage = ""
   __timer_interval = 0 {....define (in seconds) the timer interval for the wake up}
   __delete_on_termination = 0 {....1=the agent frees itself when terminates its task}
end_agent_info

start_bpm_activity "Project Start"
start_bpm_subactivity "Project"
                                
    call OpenProjectDraw("setup",__params[2],0)
    
end_bpm_subactivity
start_bpm_subactivity "Task"
    
    rec = __params[1]
    expr = strcat(rec,"=AU_STEP")
    call OpenFormTop("ptEdit","AU_PROJECT_TASK_E.FM","WORK.AU_STEP",1,expr)
    
end_bpm_subactivity
end_bpm_activity

start_bpm_activity "Project Task"
start_bpm_subactivity "Project"
    
    call OpenProjectDraw("setup",__params[2],0)
    
end_bpm_subactivity
start_bpm_subactivity "Task"
    
    rec = __params[1]
    expr = strcat(rec,"=AU_STEP")
    call OpenFormTop("ptEdit","AU_PROJECT_TASK_E.FM","WORK.AU_STEP",1,expr)
    
end_bpm_subactivity
start_bpm_subactivity "Main Project"
    
    rec = __params[2]
    expr = strcat(rec,"=AU_STEP")
    call OnOpenForm_DisablePost()
    call OpenFormTop("ptEdit","AU_PROJECT_TASK_E.FM","WORK.AU_STEP",1,expr)
    
end_bpm_subactivity
end_bpm_activity

start_bpm_activity "Define Activities Dependencies and Durations"
start_bpm_subactivity "Dependencies and Durations"
     
    call OpenFormTop("ptBrowse","AU_STEP_DEP_B.FM","QRY.DATA","PROCESS_MODE",__params[2])
    
end_bpm_subactivity
start_bpm_validation
    
    result = 1                                                
    
end_bpm_validation
end_bpm_activity

start_bpm_activity "Define Activities Durations"
start_bpm_subactivity "Durations"
     
    call OpenFormTop("ptBrowse","AU_STEP_DUR_B.FM","QRY.DATA","PROCESS_MODE",__params[2])
    
end_bpm_subactivity
start_bpm_validation
                                
    result = 1
    
end_bpm_validation
end_bpm_activity

start_bpm_activity "Define Activities Dependencies and Durations"
start_bpm_subactivity "Dependencies and Durations"
     
    call OpenFormTop("ptBrowse","AU_STEP_DEP_B.FM","QRY.DATA","PROCESS_MODE",__params[2])
                                
end_bpm_subactivity
start_bpm_validation
    
    result = 1                                                
    
end_bpm_validation
end_bpm_activity

start_action

     mode = __params[1]                    
        
     if (mode = "CREATE_PROJECT") then

        uname = __params[2]                                
        comp = __params[3]                                
        title = __params[4]
        owner = __params[5]

        parent_step = GetThrVal("__parent_step")
        parent_step = val(parent_step)
        if (parent_step = 0) then

         __au_process = bpm_createprocess("AU_PROJECT_FSM_AGENT","",uname,1)
         call agent_setvar("__au_process")
         if (owner <> "") then
         call UpdateField("AU_PROCESS",__au_process,"COMM",title,"ROLE_OWNER",owner,"IS_PROJECT","1","")
         else
         call UpdateField("AU_PROCESS",__au_process,"COMM",title,"USER_OWNER",uname,"IS_PROJECT","1","")
         endif

         __au_step = bpm_assign_info ( "Project Start" , uname , rrole ) {....trick to get the step id}
         call bpm_setstepid(__au_step)
         call bpm_setstepactivity(title)
         call bpm_setstepcomment(title)
         call bpm_assign_job ( "Project Start" , uname , owner , 0 , __au_step, __au_process )

         result = "ok"

        elseif (parent_step > 0) then
                                                
         msg = "You cannot start a Project as a dependend task!"
         result = "error"                        

        endif

        return
     endif

     if (mode = "INSERT_CHILD") then

        uname = __params[2]
        comp = __params[3]
        title = __params[4]
        prj_id = __params[5]
        parent_id = __params[6]
        owner = __params[7]

        __au_process = prj_id
        call agent_setvar("__au_process")

        id = SelectFrom("SELECT AU_STEP FROM AU_STEP WHERE (STEP_DESCR = 'Define Activities Dependencies and Durations') AND (AU_PROCESS = ",prj_id,")")
        id = val(id)
        if (id = 0) then
         __au_step = bpm_assign_info ( "Define Activities Dependencies and Durations" , "" , "" )
         call bpm_setstepid(__au_step)
         pid = SelectFrom("SELECT AU_STEP FROM AU_STEP WHERE (SLEVEL = 0) AND (AU_PROCESS = ",prj_id,")")
         call bpm_setstepparent(pid)
         call bpm_setstepcomment(title)
         call bpm_setstepactivity(title)                                                
         call bpm_assign_job ( "Define Activities Dependencies and Durations" , uname , owner , 0 , __au_step, prj_id )
         call UpdateField("AU_STEP",__au_step,"ACTIVITY","Define Activities Dependencies and Durations","COMM","Define Activities Dependencies and Durations","")
        endif

        id = SelectFrom("SELECT AU_STEP FROM AU_STEP WHERE (STEP_DESCR = 'Define Project Starting Date') AND (AU_PROCESS = ",prj_id,")")
        id = val(id)
        if (id = 0) then
         __au_step = bpm_assign_info ( "Define Project Starting Date" , "" , "" )
         call bpm_setstepid(__au_step)
         pid = SelectFrom("SELECT AU_STEP FROM AU_STEP WHERE (SLEVEL = 0) AND (AU_PROCESS = ",prj_id,")")
         call bpm_setstepparent(pid)
         call bpm_setstepcomment(title)
         call bpm_setstepactivity(title)
         call bpm_assign_job ( "Define Project Starting Date" , uname , owner , 0 , __au_step, prj_id )
         call UpdateField("AU_STEP",__au_step,"ACTIVITY","Define Project Starting Date","COMM","Define Project Starting Date","")
        endif

        __au_step = bpm_assign_info ( "Project Task" , "" , "" ) {....trick to get the step id}
        call bpm_setstepid(__au_step)
        call bpm_setstepparent(parent_id)
        call bpm_setstepcomment(title)
        call bpm_setstepactivity(title)
        call bpm_assign_job ( "Project Task" , uname , owner , 0 , __au_step, prj_id )
        call UpdateField("AU_STEP",__au_step,"ACTIVITY",title,"")

        result = "ok"
        return
     endif

     if (mode = "DELETE_CHILD") then

        uname = __params[2]
        comp = __params[3]
        step_id = __params[4]
        parent_id = __params[5]

        flag = bpm_deleteactivity ( step_id, parent_id )
        if (flag = 1) then
         result = "ok"
        else
         msg = flag
         result = "error"
        endif

        return
     endif


end_action