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_PUNCHITEM

AutoScript

start_agent_info
   AgentName = "AU_PUNCHITEM"
   AgentDescr = "Punch Item Handling"
   PR_FNAME = "AU_PUNCHITEM_E.FM"
   PR_TNAME = "AU_PUNCHITEM"
   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 "Task"
start_bpm_subactivity "Task"
    
    rec = __params[1]
    fin = SelectFrom("SELECT FINISHED FROM AU_STEP WHERE (AU_STEP=",rec,")")
    
    if (fin = 1) then
       call OnOpenForm_DisableAllFields()
    else
       call OnOpenForm_DisableField("FINISHED")
    endif        
    
    expr = strcat(rec,"=AU_STEP")        
    call OpenFormTop("ptEdit","AU_NEWTASK_E.FM","WORK.AU_STEP",1,expr)
    
end_bpm_subactivity
start_bpm_subactivity "New Child Task"
                                
    rec = __params[1]
    fin = SelectFrom("SELECT FINISHED FROM AU_STEP WHERE (AU_STEP=",rec,")")
    fin = val(fin)
    
    if (fin = 0) then
       call OpenFormTop("ptAppend","AU_NEWTASK_E.FM","WORK.AU_STEP",1,"?=AU_STEP","NEW_CHILD",rec)
    endif
    
end_bpm_subactivity
start_bpm_subactivity "New Parallel Task"
    
    rec = __params[1]
    fin = SelectFrom("SELECT FINISHED FROM AU_STEP WHERE (AU_STEP=",rec,")")
    fin = val(fin)
    
    if (fin = 0) then
       call OpenFormTop("ptAppend","AU_NEWTASK_E.FM","WORK.AU_STEP",1,"?=AU_STEP","NEW_PARALLEL",rec)
    endif
    
end_bpm_subactivity
start_bpm_validation
                                
    flag = message_yes_no("Does this creates a new Task?")
    if (flag = 1) then
       user = GetUserName()
       call bpm_startfsm ( "AU_SMALLTASK", "NEW_NEXT", __params[1], user )
    endif    
        
    result = 1
    
end_bpm_validation
end_bpm_activity

start_bpm_activity "Dispatch Punch Item"
start_bpm_subactivity "Process Form"
    
    rec = __params[1]
    expr = strcat(rec,"=AU_PUNCHITEM")
    call OpenFormTop("ptEdit","AU_PUNCHITEM_E.FM","WORK.AU_PUNCHITEM",1,expr)
    
end_bpm_subactivity
start_bpm_validation
    
    result = 1
    
end_bpm_validation
end_bpm_activity

start_bpm_activity "Assign Punch Item"
start_bpm_subactivity "Process Form"
    
    rec = __params[1]
    expr = strcat(rec,"=AU_PUNCHITEM")
    call OpenFormTop("ptEdit","AU_PUNCHITEM_E.FM","WORK.AU_PUNCHITEM",1,expr)
    
end_bpm_subactivity
start_bpm_validation
        
    result = 0
    pos = SelectFrom("SELECT RESP_POS FROM AU_PUNCHITEM WHERE (AU_PUNCHITEM=",__params[1],")")
    if (pos>0) then
        result = 1
        x = agent_askexpert( "AU_PUNCHITEM", "TO_ASSIGNEE", __params[1])                
    else
        call message("You must assign the punch item")
    endif    
        
end_bpm_validation
end_bpm_activity

start_bpm_activity "Punch Item"
start_bpm_subactivity "Process Form"
    
    rec = __params[1]
    expr = strcat(rec,"=AU_PUNCHITEM")
    call OpenFormTop("ptEdit","AU_PUNCHITEM_E.FM","WORK.AU_PUNCHITEM",1,expr)
    
end_bpm_subactivity
start_bpm_validation
        
    result = 0
    check = SelectFrom("SELECT TOCHECK_FLAG FROM AU_PUNCHITEM WHERE (AU_PUNCHITEM=",__params[1],")")
    if (check = 1) then
        result = 1
        x = agent_askexpert( "AU_PUNCHITEM", "TO_CHECK", __params[1])                
    else
        call message("You must check the punch item as finished")
    endif    
        
end_bpm_validation
end_bpm_activity

start_bpm_activity "Manage Punch Item"
start_bpm_subactivity "Process Form"
    
    rec = __params[1]
    expr = strcat(rec,"=AU_PUNCHITEM")
    call OpenFormTop("ptEdit","AU_PUNCHITEM_E.FM","WORK.AU_PUNCHITEM",1,expr)
    
end_bpm_subactivity
start_bpm_validation
                
    result = 0
    pos = SelectFrom("SELECT RESP_POS FROM AU_PUNCHITEM WHERE (AU_PUNCHITEM=",__params[1],")")
    if (pos > 0) then
        result = 1
      
     else     
        call message("You must assign the punch item")
    endif    
        
end_bpm_validation
end_bpm_activity

start_bpm_activity "Punch Item Note"
start_bpm_subactivity "Process Form"
    
    rec = __params[1]
    expr = strcat(rec,"=AU_PUNCHITEM")
    call OpenFormTop("ptEdit","AU_PUNCHITEM_E.FM","WORK.AU_PUNCHITEM",1,expr)
    
end_bpm_subactivity
start_bpm_validation
    
    result = 1
    
end_bpm_validation
end_bpm_activity

start_bpm_activity "Check Completion"
start_bpm_subactivity "Process Form"
    
    rec = __params[1]
    expr = strcat(rec,"=AU_PUNCHITEM")
    call OpenFormTop("ptEdit","AU_PUNCHITEM_E.FM","WORK.AU_PUNCHITEM",1,expr)
    
end_bpm_subactivity
start_bpm_validation
                        
    result = 0
    pos = SelectFrom("SELECT TOCHECK_FLAG FROM AU_PUNCHITEM WHERE (AU_PUNCHITEM=",__params[1],")")
    pos = val(pos)    
    if (pos = 0) then
        result = 1
        x = agent_askexpert( "AU_PUNCHITEM", "TO_RECHECK", __params[1])
     else     
        flag = message_yes_no("Are you sure the punch item is CLOSED?")
        if (flag = 1) then
         call UpdateField("AU_PUNCHITEM", __params[1], "STATUS","CLOSED","")
        else
         result = 0
        endif
    endif    
        
end_bpm_validation
end_bpm_activity

start_action

     mode = __params[1]
     rec_id = __params[2]

     if (mode = "START") then

         __au_process = bpm_createprocess("AU_PUNCHITEM","QA MANAGER","",1) {expert_activ_flag = 1}

         str = SelectFrom("SELECT PLNO, ISSUEDESCR FROM AU_PUNCHITEM WHERE (AU_PUNCHITEM=",rec_id,")")
         sep = Escape(1,-1)
         comm = GetStrArgumentNo(str,sep,1)
         uname = GetStrArgumentNo(str,sep,2)
         rname = GetStrArgumentNo(str,sep,3)
         bus_id = GetStrArgumentNo(str,sep,4)

         plno = SelectFrom("SELECT MAX(PLNO) FROM AU_PUNCHITEM") {....TO BE IMPROVED BY PROJECT NAME!!!}
         plno = val(plno)
         plno = plno + 1

         call UpdateField("AU_PUNCHITEM", rec_id, "AU_PROCESS",__au_process,"PLNO",plno,"")

         call bpm_setprocess(__au_process)
         call bpm_assign_job ( "Assign Punch Item" ,"","QA MANAGER", 0 , rec_id )
         if (bus_id > 0) then
         call bpm_setprocessbusiness(bus_id)
         endif
         call bpm_setprocedureowner(user) {.....set the procedure owner}
         call bpm_setstepcomment(comm)
         call bpm_setstepid(rec_id)
         call bpm_setprocess(__au_process)
         r = bpm_assign_info( "Punch Item Note" ,"","PROJECT DESIGNER", 0 , rec_id )
         call bpm_setprocess(__au_process)
         r = bpm_assign_info( "Punch Item Note" ,"","CLIENT REPRESENTATIVE", 0 , rec_id )
         call bpm_setprocess(__au_process)
         call bpm_assign_job( "Punch Item" ,"","SUBCONTRUCTOR REPRESENTATIVE", 0 , rec_id )

     endif

     if (mode = "TO_ASSIGNEE") then

         str = SelectFrom("SELECT AU_PROCESS, RESP_POS FROM AU_PUNCHITEM WHERE (AU_PUNCHITEM=",rec_id,")")
         sep = Escape(1,-1)
         __au_process = GetStrArgumentNo(str,sep,1)
         rname         = GetStrArgumentNo(str,sep,2)
         rname         = SelectFrom("SELECT POS_D FROM AU_POS WHERE (AU_POS=",rname,")")

         call bpm_setprocess(__au_process)                                
         call bpm_assign_job ( "Manage Punch Item" ,"",rname, 0 , rec_id )

     endif

     if (mode = "TO_CHECK") then

         __au_process = SelectFrom("SELECT AU_PROCESS FROM AU_PUNCHITEM WHERE (AU_PUNCHITEM=",rec_id,")")

         call bpm_setprocess(__au_process)
         call bpm_assign_job ( "Check Completion" ,"","QA MANAGER", 0 , rec_id )

     endif


     if (mode = "TO_RECHECK") then

         __au_process = SelectFrom("SELECT AU_PROCESS FROM AU_PUNCHITEM WHERE (AU_PUNCHITEM=",rec_id,")")

         call bpm_setprocess(__au_process)
         call bpm_assign_job( "Punch Item" ,"","SUBCONTRUCTOR REPRESENTATIVE", 0 , rec_id )

     endif
     return {....fsm must never reach end_action }

end_action