Go Back   MarcomCentral (PTI) and FusionPro User Communities > Support > Issues, Questions, Etc.

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old December 1st, 2016, 10:25 AM
Landisa's Avatar
Landisa Landisa is offline
Junior Community Member
 
Join Date: Jun 2014
Location: United States
Posts: 31
Exclamation Extra Data Tables in Result

My reporting form has been modified this year and I was trying out some new code that was a lot more condensed than my previous code.

However, it seems that the data table does not create a new one for each property but makes doubles and extras of the first table.

Can someone look at the code and forms and see what I missed?
I thought it had to do with clearing the data array but I can't figure out where I am running into trouble (probably because I have been staring at this code for weeks now). Any help would be greatly appreciated!

Code:
//Link to the external data file.  
//The '\t' is used to indicate TAB delimited data in this external data file
data = new ExternalDataFileEx("property.txt", "\t");

if (!data.valid)
{
   ReportError("Cannot successfully read/find the external data file.");
}

// Create empty
var tables = [];
var tbl = [];

//Get a count of the total number of records in the external data file
NumberOfRecords = data.recordCount;

var type = [
    ['Horses', 'Horses, Mules and Asses (ponies, donkeys, burros)*', 5.85],
    ['Cattle','Cattle (cows, bulls, yearlings)*', 2.29],
    ['Bison','Domestic Bison*', 6.38],
    ['Sheep','Sheep*', 0.54],
    ['Swine','Swine (report all swine three months of age or older)', 0.78], 
    ['Goats','Goats*', 0.54],
    ['Poultry','Poultry (chickens, turkeys, geese, ducks and other domestic birds raised as food or to produce feathers)', 0.05],
    ['Bees','Bees (number of hives or boards)', 0.41],
    ['Domestic','Alternative Livestock (privately owned caribou, mule deer, whitetail deer, elk, moose, antelope, mountain sheep, mountain goats indigenous to Montana)*', 26.23],    
    ['Ratites','Ratites (ostriches, rheas, emus)*', 9.37],
    ['Llamas','Llamas and Alpacas*' , 9.37]
];

//Now, loop through all records in the external data file and find the records that belong to the customer.
for (var n = 1; n <= NumberOfRecords; n++) 
{
    function ExField(field) { return data.GetFieldValue(n, field); }
    
    if (ExField("CID") == Field("Customer ID")) 
    {
        
        //Create Table
        var myTable = new FPTable;
        
        myTable.AddColumns(26500, 5800, 7500, 10800);
        
        tbl.push(["County: " + ExField("County Name"), "Property ID: " + ExField("Property ID"), "", ""]); // Title
        tbl.push(["Livestock Type", "A <br> Count", "B <br> Fee Amount", "C <br> Calculate Total"]); // Header
                
        type.forEach(function(s) 
        {
            var [field, description, price] = s;
            field = ExField(field);
            description = "<leading newsize = 120>" + description;
            price = "&nbsp; x &nbsp;" + FormatNumber('$00.00', price).replace('$0','$ &nbsp;')+ " = ";
            tbl.push([description, '', price,'']);
        });

        // Footer
        tbl.push(["Add amounts in column C. <br><b>This is your total Per Capita Fee Amount due for this county.</b>", "", "", "<b>$</b>"]); 
                
        // Formatting 
        for (var i=0; i<tbl.length; i++) 
        {
            var row = myTable.AddRow();
            var cell = row.Cells[0];
            
            cell.PointSize = 11; 
            cell.Margins = new FPTableMargins;
            cell.Margins = {Bottom: 10, Top: 23, Left: 250, Right: 250};
            row.CopyCells (0,1,2,3);
            row.minHeight = 1500;
         
            myTable.ShadingColor1 = 'White';
            myTable.ShadingPct1 = 100;
            myTable.ShadingRepeat1 = 1;
            myTable.ShadingColor2 = 'Black 9%';
            myTable.ShadingPct2 = 100;
            myTable.ShadingRepeat2 = 1;
            myTable.ShadingType = 'ByRow'; //or “ByColumn”
            
            if (i == 0) 
            {
                cell.VAlign = 'Bottom';
                cell.Bold = 'On';  
            }
            
            if (i == 1) 
            {
                cell.PointSize = 10;
                cell.ShadeColor = "Brown";
                cell.ShadePct = 100;
                cell.TextColor = "White";
                cell.HAlign = "Center";
                cell.Bold = 'On';
                cell.SetBorders("Thin", "Black 25%","Top", "Bottom", "Right", "Left");
                row.minHeight = 3000;
                row.CopyCells (0,1,2,3);
            }
            
            if (i > 1) 
            {
                cell.Bold = 'Off';
                cell.SetBorders("Thin", "Black 25%","Top", "Bottom", "Right", "Left");
                cell.HAlign = "Left";
                row.minHeight = 1500;
                row.CopyCells (0,1,2,3);
            }
            
            if (i == 13) 
            {
                cell.PointSize = 10;
                cell.HStraddle = 3;
                cell.HAlign = "Right"; 
            }
            
            cell.VAlign = 'Middle';
            row.CopyCells (0,1,2,3);
            
            //Assign the content
            var [col1,col2,col3,col4] = tbl[i];
            row.SetContents(col1,col2,col3,col4);
        }

        myTable.Rows[0].Cells[1].HStraddle = 3;
        myTable.Rows[13].Cells[3].HAlign = "Left";

        // Push variable into Array
        tables.push(myTable.MakeTags()); 
    }
}
return tables.join('<br>');
Attached Files
File Type: zip Reporting Form 2017.zip (723.4 KB, 8 views)
__________________
Audra Landis
Computer Systems Admin

VDP Producer v10.0.3
Windows 7 / Windows 10
Acrobat Pro DC (2015.010.20056)

Last edited by Landisa; December 2nd, 2016 at 11:07 AM.. Reason: Updated with Code snippet
Reply With Quote
Reply

Tags
data, double, extra, tables

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 09:50 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.