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 |
|
|