The eccoMAGIC Forums
http://forums.eccoMAGIC.com/forum/YaBB.pl
the SLANG EXTENSION and Guest Programming >> Slang Rules Scripts, Functions, Examples and HOW TO >> Employee Project Cost template
http://forums.eccoMAGIC.com/forum/YaBB.pl?num=1207347453

Message started by albertschepers on 04/04/08 at 17:17:32

Title: Employee Project Cost template
Post by albertschepers on 04/04/08 at 17:17:32

An Ecco template file used to extract consistant information into folders.  When used for many emplyees it assists to extract consistant information for input into spreadsheet or data base for compilation and preparation of invoicing.

Title: Re: Employee Project Cost template
Post by Admin on 04/06/08 at 18:06:04



Wow,  cool stuff!


@All,

What is this ?


Quote:
To take advantage of the special EccoEXT features there are certain input rules that must be followed.  The inten is that all entries may be made in the Calandar or the TO-Do folder with automatic assignment to the various folders depending on the entry.  The reason for the data structure was to facilitate data entry on a Palm calandar device where the seperate folders are not included and then after syncronization the data may be extracted and placed into the appropriate folers.



Includes great LUA script functions:


Quote:
luacmd.lua
     function dependssequential()
     --      
     --      this script sequentially will assign a selected item to be dependant on the next selected item
     --
     --      Version 1.0
     --      February 2, 2008
     --      Albert Schepers
     --
     NumberItems=get_select_items()
     MaxNumber=table.maxn(NumberItems)
     --
     --      verify that there are more than one item selected
     --
     if MaxNumber <= 1 then
       msgbox("Need more than one itme selected","Error 001")
     else
     --
     --      Loop to add dependancies
     --
     for inc1 = 1,MaxNumber-1 do
          add_depend_item(NumberItems[inc1+1],NumberItems[inc1])
     end
     end
     end
     
     
     function dependsmany()
     --      
     --      this script will assign all selected items to be dependant on the last item selected
     --
     --      Version 1.0
     --      February 1, 2008
     --      Albert Schepers
     --
     NumberItems=get_select_items()
     MaxNumber=table.maxn(NumberItems)
     --
     --      verify that there are more than one item selected
     --
     if MaxNumber <= 1 then
       msgbox("Need more than one itme selected","Error 001")
     else
     --
     --      Loop to add dependancies
     --
     for inc1 = 1,MaxNumber-1 do
          add_depend_item(NumberItems[MaxNumber],NumberItems[inc1])
     end
     end
     end
     
     
     function dependsone()
     --      
     --      this script will assign to all selected items to be dependant on the first item selected
     --
     --      Version 1.0
     --      February 1, 2008
     --      Albert Schepers
     --
     NumberItems=get_select_items()
     MaxNumber=table.maxn(NumberItems)
     --
     --      verify that there are more than one item selected
     --
     if MaxNumber < 1 then
       msgbox("Need more than one itme selected","Error 001")
     else
     --
     --      Loop to add dependancies
     --
     for inc1 = 2,MaxNumber do
          add_depend_item(NumberItems[inc1],NumberItems[1])
     end
     end
     end
     
     function ProjectToITT()
     NumberItems=get_select_items()                        -- get the item ids of all selected items
     MaxItems=table.maxn(NumberItems)                        -- determine the total number of selected items
     for ctr=1, MaxItems do
       set_item_text(NumberItems[ctr],"#"..get_folder_value("Project",NumberItems[ctr]).." "..get_item_text(NumberItems[ctr]))
     end
     end
     
     
     function JobCostAlbert()                              -- function name note the () at the end of the name
     name="Albert Schepers"                              -- employee name
     folder="P:\\common\\"                                    -- set the directory into which the data file will be placed
     file=folder..name..".txt"                              -- create a txt file name from the folder and emplyee name
     io.output(file,"w+")                                    -- open an empty file for output if file exists it will be emptied, this is done early to ensure an empty file should the extraction fail
     NumberItems=get_select_items()                        -- get the item ids of all selected items
     MaxItems=table.maxn(NumberItems)                        -- determine the total number of selected items
     if get_folder_value("Appointments",NumberItems[1])=="" then
       msgbox("Invalid Selection\nNot a TLI (no Appointment date)","error 1")
     else -- line 8
       if MaxItems > 0 then                              -- A checks to see if there are one or more items
         h1="Date"                                    -- all the hn variables are the header row for teh output data
         h2=",".."Start Time"
         h3=",".."End Time"
         h4=",".."Employee Name"
         h5=",".."Project Number"
         h6=",".."Work Description"
         h7=",".."Regular Hours"
         h8=",".."Overtime 1"
         h9=",".."Overtime 2"
         h10=",".."Mileage"
         h11=",".."Expense Amount"
         h12=",".."Expense Type"
         h13=",".."Equipment Time"
         h14=",".."Equipment Description"
         h15=",".."Consumable Quantity"
         h16=",".."Consumable Description"
         h17=",".."Reimbursable Amount"
         h18=",".."Reimbursible Description"
         header=h1..h2..h3..h4..h5..h6..h7..h8..h9..h10..h11..h12..h13..h14..h15..h16..h17..h18.."\n"
         io.write(header)                                    -- store the header row in the open data file
         ctr1=1                                          -- set the counter to 1 for the while loop
         while ctr1 <= MaxItems do
           datetime=get_folder_value("Appointments",NumberItems[ctr1])
           if datetime~="" then                              -- check to see if the date has no value and if true set variables for following lines
             date=datetime
             starttime=tonumber(string.sub(datetime,9,12))
             stoptime=tonumber(string.sub(datetime,14,17))
             project=get_folder_value("Project",NumberItems[ctr1])
           else -- line 35                                    -- if it has no value then set the start and stop times to null
             stoptime=""
             starttime=""
           end -- line 35
           text=get_item_text(NumberItems[ctr1])
           if string.sub(text,1,1)=="#" or string.sub(text,1,1)=="$" then            -- get rid of the front end of the text if it starts with #
             if string.sub(text,1,3)=="#m " or string.sub(text,1,3)=="#M " then
               text=text.." Mileage"                              -- add "Mileage" to the string if it represents mileage (#m)
             end  -- line 46
             text=string.match(text,"%s%a\.*")                        -- regex expression that replaces the text with the end of the string
           end  -- line 45
           ptr1=ctr1                                    -- set pointer to current item
           j=ctr1
           while j<MaxItems do                              -- do loop to concatenate text based on the next item text not starting with a #
             ctr1=j
             nexttext=get_item_text(NumberItems[j+1])
             nextdate=get_folder_value("Appointments",NumberItems[j+1])
             first = string.sub(nexttext,1,1)
             if first =="#"  or first =="$" then
               j=MaxItems
             else
               if nextdate=="" then
                 text=text.." "..nexttext
               else -- line 58
                 j=MaxItems                                    -- exit the loop pas the next item is a TLI, the Appoinments folder has value
               end -- line 58
             end -- line 57
             j=j+1                                          -- increment the cocatenation loop (j)
           end -- line 51
           f1='"'..date..'"'
           f2=',"'..starttime..'"'
           f3=',"'..stoptime..'"'
           f4=',"'..name..'"'
           f5=',"'..project..'"'
           f6=',"'..text..'"'
           f7=','..get_folder_value("Reg",NumberItems[ptr1])
           f8=','..get_folder_value("OT1",NumberItems[ptr1])
           f9=','..get_folder_value("OT2",NumberItems[ptr1])
           f10=','..get_folder_value("Mileage",NumberItems[ptr1])
           f11=','..get_folder_value("Expense Amount",NumberItems[ptr1])
           f12=',"'..get_folder_value("Expense Type",NumberItems[ptr1])..'"'
           f13=',"'..get_folder_value("Equipment Time",NumberItems[ptr1])..'"'
           f14=',"'..get_folder_value("Equipment Description",NumberItems[ptr1])..'"'
           f15=','..get_folder_value("Consumable",NumberItems[ptr1])
           f16=',"'..get_folder_value("Consumable Description",NumberItems[ptr1])..'"'
           f17=','..get_folder_value("Reimbursable",NumberItems[ptr1])
           f18=',"'..get_folder_value("Reimbursable Description",NumberItems[ptr1])..'"'
          data=f1..f2..f3..f4..f5..f6..f7..f8..f9..f10..f11..f12..f13..f14..f15..f16..f17..f18.."\n"
           io.write(data)
           ctr1=ctr1+1                                          -- increment the counter
         end -- line 33                                          -- end of the while loop
       else -- line 11
         msgbox("No items selected","error 2")
       end -- line 11
     end -- line 8
     io.close()
     msgbox("Click on enter to finish","Last Message")
     end -- line 1                                          function end


Title: Re: Employee Project Cost template
Post by Admin on 04/06/08 at 18:26:21




and these rules:



Code:
Auto-Assign Rules
     Project (text)
           Rule 1
                 ++:T!+:imatch(ITT,'#(\w+)\s+.*'):left(ITT,1)=="#"
     Reg (number)
           Rule 1
                 ++:!+-MT:0.+substr(GFV(Appointments),14,2)-substr(GFV(Appointments),9,2)+
                 (0.+substr(GFV(Appointments),16,2)-substr(GFV(Appointments),11,2))/60:left(ITT,1)=="#"
     Mileage (number)
           Rule 1
                 ++:!+-:imatch(ITT,'^#M\s*(\d+)\s.*')
                 example
                       #m 360
     Expense Amount (number)
           Rule 1
                 ++:!+:imatch(ITT,'^#E\s*(\d+)\s*.*')
                 Example
                       #e 10 print 8x11
     Equipment Time (number)
           Rule 1
                 ++:MP!+:getpv(fv(Reg), il() == 0):imatch(ITT,'^#q\s*.*')
                 Example
                       #q probe
     Consumable (number)
           Rule 1
                 ++:!+:imatch(ITT,'^#c\s*(\d+.\d*)\s*.*')
                 Example
                       #c 25 powder
     Reimbursable (number)
           Rule 1
                 ++:!+:match(ITT,'^\$\s*(\d*\.\d\d)\s+.*')
                 Example
                       $25.46 hotdog
     Reimbursable GST (number)
           Rule 1
                 ++:!+:0.+GFV("Reimbursable")*.06:
     Expense Type (pop up)
           Rule 1
                 ++:!+:imatch(ITT,"^#e\s+\d+\s+(.*)")
                 Example
                       #e 10 print 8x11
     Equipment Description (pop up)
           Rule 1
                 ++:!+-:imatch(ITT,"^#q\s+(.*)")
                 Example
                       #q probe
     Comsumable Descripion (pop up)
           Rule 1
                 ++:!+:imatch(ITT,'^#c\s*\d+.\d*\s*(.*)')
                 Example
                       #c 25 powder
     Reimbursable Description (text)
           Rule 1
                 ++:!+:match(ITT,'^\$\s*\d*\.\d\d\s*(.*)')
                 Example
                       $25.46 hotdog
     Returned Call (Date)
           Rule 1
                 ++:!+:if([Done],NOW,'')

The eccoMAGIC Forums » Powered by YaBB 2.1!
YaBB © 2000-2005. All Rights Reserved.