Hello all,
I've been trying to make this work but after much hair pulling have had no luck with it.
I have a three page pdf. On the first page are two tabls of employee names. Each row in the tables includes a cell for the employee name and also one that holds a checkbox.
The second and third pages are time sheets appropriate for the department that each employee is in. These two pages are hidden.
So the idea is that if a particular employee is selected by the check mark, a time sheet with his name, dates and other info would be printed. One department is straightforward in that there is one sheet per employee.
The trouble is with the other department, in that for that department, each time sheet has four columns, at the top of each goes one employee's name. So the logic for this department is as follows:
1. count how many names are selected
2. if four or less are selected, enter first selected name into the first row of the first column, the second into the first rown of the second column, the third into the first row of the third colum etc.
3. if more than four are selected, enter the first four names into the first page, print the page, and enter the remaining into the second page and print, and so on until all selected names are processed.
1. works fine
2. works fine
3. works but not correctly.
So if I have say six names selected, for example, aaa, ,bbb, ccc, ddd, eee, and fff what end at the top of the columns on first page is:
eee, fff, ccc, ddd and on the second page its the same thing
The actual bit of formcalc script to do this is below, obviously it is incorrect or else missing something.
Any pointers and suggestions (in formcalc if possible) would be very welcome and appreciated.
Thanks.
// use a for loop to count number of names selected. tabel has 15 employee names
for i = 0 upto 14 do
if ((not (form1.main.front.Table2.Row[i].dbmname.isNull | form1.main.front.Table2.Row[i].dbmname == "")) and (form1.main.front.Table2.Row[i].Checkbox == 1)) then
ns = ns + 1 // ns = number of names selected
endif
endfor
for i = 0 upto 14 do //if any names are selected then process and print desk and maintenance sheet
//check to see if selected rows are not empty
if ((not (form1.main.front.Table2.Row[i].dbmname.isNull | form1.main.front.Table2.Row[i].dbmname == "")) and (form1.main.front.Table2.Row[i].Checkbox == 1)) then
//enter first selected name into column 1 and second into colum 2 etc...
form1.dbm_sheet.Table3.header2.dbm_name[np] = form1.main.front.Table2.Row[i].dbmname.rawValue
//np = name position to select next column that the next name will go into
np = np + 1
//ok - check if number of names selected was 4 or more and if first four names have been entered, lets print the first timesheet
if ((ns >= 4) and (np == 4)) then
xfa.host.print(1, "2", "2", 1, 1, 0, 0, 0) //print sheet
//first sheet with 4 names is printed, therefore reduce ns by 4
ns = ns - 4
//first sheet printed, reset np to zero
np = 0
//if less than 4 names were selected OR are left after printing first 4 then process remaining names
elseif ((ns < 4) and (np == ns)) then
xfa.host.print(1, "2", "2", 1, 1, 0, 0, 0)
// blank remaining columns that are supposed to be empty : if there are less than four names to be printed on the sheet
for i = (np) upto 3 do
form1.dbm_sheet.Table3.header2.dbm_name[np] = ""
endfor
endif
endfor
endif
endfor
Views
Replies
Total Likes