public void buildReport()
        {
            Root = new RootElement ("");
            var v = new UIView ();
            v.Frame = new RectangleF (10, 10, 600, 10);
            var dummy = new Section (v);
            Root.Add (dummy);
            var headerLabel = new UILabel (new RectangleF (10, 10, 800, 48)) {
                Font = UIFont.BoldSystemFontOfSize (18),
                BackgroundColor = ColorHelper.GetGPPurple (),
                TextAlignment = UITextAlignment.Center,
                TextColor = UIColor.White,
                Text = "Owner Fee Target Progress"
            };
            var view = new UIViewBordered ();
            view.Frame = new RectangleF (10, 20, 800, 48);
            view.Add (headerLabel);
            Root.Add (new Section (view));

            //			NumberFormatInfo nfi = new CultureInfo ("en-US", false).NumberFormat;

            for (int i = 0; i < report.branches.Count; i++) {
                Branch branch = report.branches [i];
                Section s = new Section (branch.name);
                //var t1 = new StringElement(branch.name + " Branch Totals");
                //s.Add(t1);
                Root.Add (s);

                for (int j = 0; j < branch.owners.Count; j++) {
                    Owner o = branch.owners [j];
                    Section ownerSection = new Section (o.name);
                    ownerSection.Add (new BigFinanceElement ("Invoiced MTD Total:  ", o.invoicedMTDTotal));
                    StyledStringElement recMTD = new StyledStringElement ("Recorded MTD");
                    recMTD.BackgroundColor = UIColor.LightGray;
                    recMTD.TextColor = UIColor.White;
                    ownerSection.Add (recMTD);
                    ownerSection.Add (getElement (o.recordedMTD.achieved, "Achieved:  "));
                    ownerSection.Add (getElement (o.recordedMTD.estimatedTarget, "Estimated Target:  "));
                    ownerSection.Add (getElement (o.recordedMTD.invoicedDebits, "Invoiced Debits:  "));
                    ownerSection.Add (getElement (o.recordedMTD.unbilled, "Unbilled:  "));
                    ownerSection.Add (getElement (o.recordedMTD.total, "Total:  "));
                    //
                    StyledStringElement recYTD = new StyledStringElement ("Recorded YTD");
                    recYTD.BackgroundColor = UIColor.LightGray;
                    recYTD.TextColor = UIColor.White;
                    ownerSection.Add (recYTD);
                    ownerSection.Add (getElement (o.recordedYTD.achieved, "Achieved:  "));
                    ownerSection.Add (getElement (o.recordedYTD.estimatedTarget, "Estimated Target:  "));
                    ownerSection.Add (getElement (o.recordedYTD.invoiced, "Invoiced:  "));
                    ownerSection.Add (getElement (o.recordedYTD.unbilled, "Unbilled:  "));
                    ownerSection.Add (getElement (o.recordedYTD.total, "Total:  "));

                    Root.Add (ownerSection);

                }
            }
            for (var i = 0; i < 10; i++) {
                Root.Add (new Section (" "));
            }
        }
        public void buildReport()
        {
            Root = new RootElement ("");
            var v = new UIView ();
            v.Frame = new RectangleF (10, 10, 600, 10);
            var dummy = new Section (v);
            Root.Add (dummy);
            var headerLabel = new UILabel (new RectangleF (10, 10, 800, 48)) {
                Font = UIFont.BoldSystemFontOfSize (18),
                BackgroundColor = ColorHelper.GetGPPurple (),
                TextAlignment = UITextAlignment.Center,
                TextColor = UIColor.White,
                Text = "Branch Matter Analysis"
            };
            var view = new UIViewBordered ();
            view.Frame = new RectangleF (10, 20, 800, 48);
            view.Add (headerLabel);
            Root.Add (new Section (view));
            //
            for (int i = 0; i < report.branches.Count; i++) {
                Branch branch = report.branches [i];

                Section s = new Section (branch.name + " Branch Totals");
                Root.Add (s);
                //
                if (branch.branchTotals.matterActivity != null) {
                    var matterActivitySection = new Section ();
                    var mTitle = new TitleElement ("Matter Activity");
                    matterActivitySection.Add (mTitle);
                    matterActivitySection.Add (new NumberElement (branch.branchTotals.matterActivity.active, "Active Matters: "));
                    matterActivitySection.Add (new NumberElement (
                        branch.branchTotals.matterActivity.deactivated,
                        "Deactivated Matters: "
                    ));
                    matterActivitySection.Add (new NumberElement (branch.branchTotals.matterActivity.newWork, "New Work: "));
                    matterActivitySection.Add (new NumberElement (branch.branchTotals.matterActivity.workedOn, "Worked On: "));

                    matterActivitySection.Add (new NumberElement (branch.branchTotals.matterActivity.noActivity, "No Activity: "));
                    matterActivitySection.Add (new StringElement ("No Activity Duration: " + branch.branchTotals.matterActivity.noActivityDuration));
                    Root.Add (matterActivitySection);
                }
                //
                if (branch.branchTotals.matterBalances != null) {
                    var matterBalancesSection = new Section ();
                    var mTitle = new TitleElement ("Matter Balances");
                    matterBalancesSection.Add (mTitle);
                    matterBalancesSection.Add (getElement (branch.branchTotals.matterBalances.business, S.GetText (S.BUSINESS) + ": "));
                    matterBalancesSection.Add (getElement (branch.branchTotals.matterBalances.trust, S.GetText (S.TRUST_BALANCE) + ": "));
                    matterBalancesSection.Add (getElement (branch.branchTotals.matterBalances.investment, S.GetText (S.INVESTMENTS) + ": "));
                    matterBalancesSection.Add (getElement (branch.branchTotals.matterBalances.unbilled, "Unbilled: "));
                    matterBalancesSection.Add (getElement (branch.branchTotals.matterBalances.pendingDisbursements, "Pending Disb.: "));
                    Root.Add (matterBalancesSection);
                }

            }

            for (var i = 0; i < 10; i++) {
                Root.Add (new Section (" "));
            }
        }
        public void buildReport()
        {
            Root = new RootElement ("");
            var v = new UIView ();
            v.Frame = new RectangleF (10, 10, 600, 10);
            var dummy = new Section (v);
            Root.Add (dummy);
            var headerLabel = new UILabel (new RectangleF (10, 10, 800, 48)) {
                Font = UIFont.BoldSystemFontOfSize (18),
                BackgroundColor = ColorHelper.GetGPPurple (),
                TextAlignment = UITextAlignment.Center,
                TextColor = UIColor.White,
                Text = "Owner Matter Analysis"
            };
            var view = new UIViewBordered ();
            view.Frame = new RectangleF (10, 10, 800, 48);
            view.Add (headerLabel);
            Root.Add (new Section (view));

            //NumberFormatInfo nfi = new CultureInfo ("en-US", false).NumberFormat;
            for (int i = 0; i < report.branches.Count; i++) {
                Branch branch = report.branches [i];
                Section s = new Section (branch.name);
                Root.Add (s);

                for (int j = 0; j < branch.owners.Count; j++) {
                    Owner o = branch.owners [j];
                    Section seco = new Section (o.name);

                    var recMTD = new TitleElement ("Matter Activity");
                    seco.Add (recMTD);
                    seco.Add (new NumberElement (o.matterActivity.active, "Active:  "));
                    seco.Add (new NumberElement (o.matterActivity.deactivated, "Deactivated:  "));
                    seco.Add (new NumberElement (o.matterActivity.newWork, "New Work:  "));
                    seco.Add (new NumberElement (o.matterActivity.workedOn, "Worked On:  "));
                    seco.Add (new NumberElement (o.matterActivity.noActivity, "No Activity:  "));
                    seco.Add (new StringElement ("No Activity Duration:  " + o.matterActivity.noActivityDuration));
                    //
                    var recYTD = new TitleElement ("Matter Balances");
                    seco.Add (recYTD);
                    seco.Add (getElement (o.matterBalances.business, S.GetText (S.BUSINESS) + ":  "));
                    seco.Add (getElement (o.matterBalances.trust, S.GetText (S.TRUST) + ":  "));
                    seco.Add (getElement (o.matterBalances.investment, S.GetText (S.INVESTMENTS) + ":  "));
                    seco.Add (getElement (o.matterBalances.unbilled, "Unbilled:  "));
                    seco.Add (getElement (o.matterBalances.pendingDisbursements, "Pending Disb:  "));

                    Root.Add (seco);

                }

            }

            for (var i = 0; i < 10; i++) {
                Root.Add (new Section (" "));
            }
        }
        /*
         * "practiceTotals":{"invoicedMTDTotal":0.0,
        "matterActivity":{"active":581,"workedOn":529,"newWork":581,"deactivated":0,"noActivity":0,"noActivityDuration":"6 Months"},
        "matterBalances":{"unbilled":107253.15,"pendingDisbursements":500.0,"investment":-1000.0,"trust":-5852921.0,"business":704265.82}}}}
         */
        public void buildFeeTargetReport()
        {
            //NumberFormatInfo nfi = new CultureInfo ("en-US", false).NumberFormat;
            Root = new RootElement ("");
            var v = new UIView ();
            v.Frame = new RectangleF (10, 10, 600, 10);
            var dummy = new Section (v);
            Root.Add (dummy);
            var headerLabel = new UILabel (new RectangleF (10, 10, 800, 48)) {
                Font = UIFont.BoldSystemFontOfSize (18),
                BackgroundColor = ColorHelper.GetGPPurple (),
                TextAlignment = UITextAlignment.Center,
                TextColor = UIColor.White,
                Text = "Practice Matter Analysis"
            };
            var view = new UIViewBordered ();
            view.Frame = new RectangleF (10, 10, 800, 48);
            view.Add (headerLabel);
            Root.Add (new Section (view));

            PracticeTotals totals = this.report.practiceTotals;

            var totSection = new Section ("Practice Totals");
            Root.Add (totSection);

            if (totals.matterActivity != null) {
                var matterActivitySection = new Section ();
                var mTitle = new TitleElement ("Matter Activity");
                matterActivitySection.Add (mTitle);
                matterActivitySection.Add (new NumberElement (totals.matterActivity.active, "Active:  "));
                matterActivitySection.Add (new NumberElement (totals.matterActivity.deactivated, "Deactivated:  "));
                matterActivitySection.Add (new NumberElement (totals.matterActivity.newWork, "New Work:  "));

                matterActivitySection.Add (new NumberElement (totals.matterActivity.workedOn, "Worked On:  "));
                matterActivitySection.Add (new NumberElement (totals.matterActivity.noActivity, "No Activity:  "));
                matterActivitySection.Add (new StringElement ("No Activity Duration:  " + totals.matterActivity.noActivityDuration));
                Root.Add (matterActivitySection);
            }
            //
            if (totals.matterBalances != null) {
                var matterBalancesSection = new Section ();
                var mTitle = new TitleElement ("Matter Balances");
                matterBalancesSection.Add (mTitle);
                matterBalancesSection.Add (getElement (totals.matterBalances.business, S.GetText (S.BUSINESS) + ": "));
                matterBalancesSection.Add (getElement (totals.matterBalances.trust, S.GetText (S.TRUST_BALANCE) + ": "));
                matterBalancesSection.Add (getElement (totals.matterBalances.investment, S.GetText (S.INVESTMENTS) + ": "));
                matterBalancesSection.Add (getElement (totals.matterBalances.unbilled, "Unbilled: "));
                matterBalancesSection.Add (getElement (totals.matterBalances.pendingDisbursements, "Pending Disb.: "));
                Root.Add (matterBalancesSection);
            }

            for (var i = 0; i < 10; i++) {
                Root.Add (new Section (" "));
            }
        }
        public void buildReport()
        {
            Root = new RootElement ("");
            var v = new UIView ();
            v.Frame = new RectangleF (10, 10, 600, 10);
            var dummy = new Section (v);
            Root.Add (dummy);
            var headerLabel = new UILabel (new RectangleF (10, 10, 800, 48)) {
                Font = UIFont.BoldSystemFontOfSize (18),
                BackgroundColor = ColorHelper.GetGPPurple (),
                TextAlignment = UITextAlignment.Center,
                TextColor = UIColor.White,
                Text = "Branch Fee Target Progress"
            };
            var view = new UIViewBordered ();
            view.Frame = new RectangleF (10, 20, 800, 48);
            view.Add (headerLabel);
            Root.Add (new Section (view));

            for (int i = 0; i < report.branches.Count; i++) {
                Branch branch = report.branches [i];

                Section s = new Section (branch.name);

                var t2 = new BigFinanceElement ("Invoiced MTD Total:  ", branch.branchTotals.InvoicedMTDTotal);
                s.Add (t2);
                //
                Section s2 = new Section (branch.name + " Recorded MTD");
                s2.Add (getElement (branch.branchTotals.recordedMTD.achieved, "Achieved:  "));
                s2.Add (getElement (branch.branchTotals.recordedMTD.estimatedTarget, "Estimated Target:  "));
                s2.Add (getElement (branch.branchTotals.recordedMTD.invoicedDebits, "Invoiced Debits:  "));
                s2.Add (getElement (branch.branchTotals.recordedMTD.unbilled, "Unbilled:  "));
                s2.Add (getElement (branch.branchTotals.recordedMTD.total, "Total:  "));
                //
                Section s21 = new Section (branch.name + " Recorded YTD");
                s21.Add (getElement (branch.branchTotals.recordedYTD.achieved, "Achieved:  "));
                s21.Add (getElement (branch.branchTotals.recordedYTD.estimatedTarget, "Estimated Target:  "));
                s21.Add (getElement (branch.branchTotals.recordedYTD.invoiced, "Invoiced:  "));
                s21.Add (getElement (branch.branchTotals.recordedYTD.unbilled, "Unbilled:  "));
                s21.Add (getElement (branch.branchTotals.recordedYTD.total, "Total:  "));

                Root.Add (s);
                Root.Add (s2);
                Root.Add (s21);

            }
            for (var i = 0; i < 10; i++) {
                Root.Add (new Section (" "));
            }
        }
        private void BuildHeaderLabel()
        {
            string s = "Post Fee";
            if (isUnbillable) {
                s = "Post Unbillable Fee";
            }

            headerLabel = new UILabel (new RectangleF (10, 10, 480, 40)) {
                Font = UIFont.BoldSystemFontOfSize (20),
                BackgroundColor = ColorHelper.GetGPPurple (),
                TextAlignment = UITextAlignment.Center,
                TextColor = UIColor.White,
                Text = s
            };
            var view = new UIViewBordered ();
            view.Frame = new RectangleF (10, 10, 480, 40);
            view.Add (headerLabel);
            var topSection = new Section (view);

            Root.Add (topSection);
            String name = "";
            if (matter != null) {
                name = matter.matterName;
            }
            var sec = new Section (name);
            var timeBased = new BooleanElement (S.GetText (S.TIME_BASED_ACTIVITY), isTimeBased);

            timeBased.ValueChanged += delegate {
                if (isBusy) {
                    Busy ();
                    return;
                }
                selectedTariff = null;
                feeAmount.Value = null;
                if (timeBased.Value == true) {
                    isTimeBased = true;
                    if (IsTariffCacheFilled ()) {
                        RefreshFromCache ();
                        BuildInterface ();
                    } else {
                        GetTariffCodes (100, DataUtil.TARIFF_CODE_TYPE_FEES);
                    }

                } else {
                    isTimeBased = false;
                    if (IsTariffCacheFilled ()) {
                        RefreshFromCache ();
                        BuildInterface ();
                    } else {
                        GetTariffCodes (0, DataUtil.TARIFF_CODE_TYPE_FEES);
                    }
                }
            };
            sec.Add (timeBased);
            Root.Add (sec);
        }
        private void BuildSections()
        {
            var headerLabel = new UILabel (new RectangleF (10, 10, 370, 40)) {
                Font = UIFont.BoldSystemFontOfSize (20),
                BackgroundColor = ColorHelper.GetGPPurple (),
                TextAlignment = UITextAlignment.Center,
                TextColor = UIColor.White,
                Text = "Post Note"
            };
            var view = new UIViewBordered ();
            view.Frame = new RectangleF (10, 10, 370, 40);
            view.Add (headerLabel);
            var topSection = new Section (view);

            Root.Add (topSection);

            string name = "";
            if (matter != null) {
                name = matter.matterName;
            }
            var sec = new Section (name);
            //
            addBusySection ();
            var tarSec = new Section ();
            if (tariffList != null && tariffList.Count > 0) {
                btnTar = new StyledStringElement ("Select Activity Code");
                btnTar.TextColor = ColorHelper.GetGPLightPurple ();
                btnTar.Alignment = UITextAlignment.Center;
                btnTar.Accessory = UITableViewCellAccessory.DisclosureIndicator;
                btnTar.Tapped += delegate {
                    if (tariffList == null) {

                    } else {
                        string[] btns = new string[tariffList.Count];
                        for (int i = 0; i < tariffList.Count; i++) {
                            btns [i] = tariffList [i].name;
                        }
                        actionSheet = new UIActionSheet ("Activity Codes", null, "Cancel", null, btns) {
                            Style = UIActionSheetStyle.Default
                        };

                        actionSheet.Clicked += delegate (object sender, UIButtonEventArgs args) {
                            if (args.ButtonIndex == tariffList.Count) {
                                //ignored - cancelled
                            } else {
                                narration.Value = tariffList [args.ButtonIndex].narration;
                                selectedTariff = tariffList [args.ButtonIndex];
                                BuildInterface ();
                            }

                        };

                        actionSheet.ShowInView (View);
                    }

                };
                tarSec.Add (btnTar);
            }
            //
            var narrSec = new Section ("Note Narration");

            if (selectedTariff == null) {
                narration = new EntryElement ("Narration", "Narration", null);
            } else {
                narrSec = new Section (selectedTariff.name);
                narration = new EntryElement ("Narration", "Narration", selectedTariff.narration);
            }
            narration.KeyboardType = UIKeyboardType.Default;
            narrSec.Add (narration);
            //
            picker = new UIDatePicker ();
            //picker.Frame = new RectangleF (10f, 10f, 320f, 320f);
            picker.Mode = UIDatePickerMode.Date;
            picker.Date = DateTime.Now;

            var pickerSection = new Section (picker);

            Root.Add (sec);
            Root.Add (tarSec);
            Root.Add (narrSec);
            Root.Add (pickerSection);
            BuildButtons ();
        }
        private void buildInterface()
        {
            Console.WriteLine ("ProvisionDialog  - building user interface");
            Root = new RootElement ("GhostPractice Device Activation");
            Section sec1 = new Section ();
            var welcome = new StyledStringElement ("Welcome to GhostPractice!", "");
            welcome.Alignment = UITextAlignment.Center;
            welcome.Font = UIFont.BoldSystemFontOfSize (30);
            welcome.TextColor = ColorHelper.GetGPPurple ();
            sec1.Add (welcome);
            //Root.Add (sec1);
            //
            var headerLabel = new UILabel (new RectangleF (10, 10, 700, 40)) {
                Font = UIFont.BoldSystemFontOfSize (20),
                BackgroundColor = ColorHelper.GetGPPurple (),
                TextAlignment = UITextAlignment.Center,
                TextColor = UIColor.White,
                Text = "Welcome to GhostPractice Mobile!"
            };
            var view = new UIViewBordered ();
            view.Frame = new RectangleF (10, 10, 700, 40);
            view.Add (headerLabel);
            var topSection = new Section (view);

            Root.Add (topSection);
            //
            for (var i = 0; i < 6; i++) {
                Root.Add (new Section ("  "));
            }

            var label = new Section ("Please enter the activation code that was given or sent to you by GhostPractice Support and send it to the office.");

            var sec2 = new Section ("    ");
            Root.Add (sec2);
            Root.Add (label);
            //

            var sec3 = new Section ();
            activationCode = new EntryElement ("Activation Code", "Enter Activation Code", String.Empty);
            sec3.Add (activationCode);
            btn = new StyledStringElement ("Send Activation Code") { Accessory = UITableViewCellAccessory.DetailDisclosureButton };
            btn.Alignment = UITextAlignment.Center;
            btn.BackgroundColor = ColorHelper.GetGPPurple ();
            btn.TextColor = UIColor.White;
            btn.Tapped += delegate() {
                if (!isBusy) {
                    validate ();
                } else {
                    Wait ();
                }
            };
            btn.AccessoryTapped += delegate {
                if (!isBusy) {
                    validate ();
                } else {
                    Wait ();
                }
            };
            sec4 = new Section (" ");
            sec4.Add (btn);
            Root.Add (sec3);
            Root.Add (sec4);
        }
        public void BuildInterface()
        {
            Root.Clear ();

            var headerLabel = new UILabel (new RectangleF (10, 10, 300, 40)) {
                Font = UIFont.BoldSystemFontOfSize (20),
                BackgroundColor = ColorHelper.GetGPPurple (),
                TextAlignment = UITextAlignment.Center,
                TextColor = UIColor.White,
                Text = "Practice Reports"
            };
            var view = new UIViewBordered ();
            view.Frame = new RectangleF (10, 10, 300, 40);
            view.Add (headerLabel);
            var topSection = new Section (view);
            Root.Add (topSection);
            Root.Add (new Section (" "));
            addBusySection ();
            //
            Root.Add (new Section (NSUserDefaults.StandardUserDefaults.StringForKey ("userName")));
            var getReportsSection = new Section ("Report Selection");

            btnFinance =
                new StyledStringElement ("Financial Status Report",
                null,
                UITableViewCellStyle.Subtitle) {
                DetailColor = UIColor.Gray
            };
            btnFinance.Tapped += delegate() {
                CheckIfBusy (FINANCIAL_STATUS);
            };
            btnFinance.AccessoryTapped += delegate() {
                CheckIfBusy (FINANCIAL_STATUS);
            };
            getReportsSection.Add (btnFinance);
            //getReportsSection.Add (new StringElement (" "));
            //
            btnFeeTarget =
                new StyledStringElement ("Fee Target Progress Report",
                null,
                UITableViewCellStyle.Subtitle) {
                DetailColor = UIColor.Gray
            };

            btnFeeTarget.Tapped += delegate() {
                CheckIfBusy (FEE_TARGET);
            };
            btnFeeTarget.AccessoryTapped += delegate() {
                CheckIfBusy (FEE_TARGET);
            };
            getReportsSection.Add (btnFeeTarget);
            //getReportsSection.Add (new StringElement (" "));
            //
            btnMatterAnalysis = new StyledStringElement ("Matter Analysis Report");
            btnMatterAnalysis =
                new StyledStringElement ("Matter Analysis Report",
                null,
                UITableViewCellStyle.Subtitle) {
                DetailColor = UIColor.Gray
            };
            btnMatterAnalysis.Tapped += delegate() {
                CheckIfBusy (MATTER_ANALYSIS);
            };
            btnMatterAnalysis.AccessoryTapped += delegate() {
                CheckIfBusy (MATTER_ANALYSIS);
            };
            getReportsSection.Add (btnMatterAnalysis);
            //getReportsSection.Add (new StringElement (" "));
            //
            Root.Add (getReportsSection);
            addImageSection ();
        }
        public void BuildInterface()
        {
            if (Root == null) {
                Root = new RootElement ("");
            }
            Root.Clear ();
            String name = "";
            if (searchResult != null) {
                name = searchResult.matterName;
            }
            headerLabel = new UILabel (new RectangleF (40, 10, 620, 40)) {
                Font = UIFont.BoldSystemFontOfSize (20),
                BackgroundColor = ColorHelper.GetGPPurple (),
                TextAlignment = UITextAlignment.Center,
                TextColor = UIColor.White,
                Text = name
            };
            var view = new UIViewBordered ();
            view.Frame = new RectangleF (40, 10, 620, 40);
            view.Add (headerLabel);
            var topSection = new Section (view);

            Root.Add (topSection);
            //
            var sec = new Section ("");
            matterName = new TitleElement ("Matter Details");
            if (searchResult != null) {
                ownerName = new StringsElement ("Owner", searchResult.currentOwner);
                matterID = new NumberElement (
                    Convert.ToInt16 (searchResult.matterID), "Matter ID");
                if (searchResult.matterLegacyAccount == null || searchResult.matterLegacyAccount.Trim () == "") {
                    //ignore
                } else {
                    legacy = new StringsElement (
                        "Legacy Account",
                        searchResult.matterLegacyAccount
                    );
                }
                clientName = new StringsElement ("Client", "" + searchResult.clientName);
            }
            //
            var sec2 = new Section ("");
            if (matter == null) {
                busBal = new FinanceElement (S.GetText (S.BUSINESS_BALANCE) + ":", 0.00);
                currBal = new FinanceElement (S.GetText (S.CURRENT_BALANCE) + ":", 0.00);
                trustBal = new FinanceElement (S.GetText (S.TRUST_BALANCE) + ":", 0.00);
                reserveTrust = new FinanceElement (S.GetText (S.RESERVE_TRUST) + ":", 0.00);
                unbilled = new FinanceElement (S.GetText (S.UNBILLED_BALANCE) + ":", 0.00);
                pending = new FinanceElement (S.GetText (S.PENDING_DISBURSEMENTS) + ":", 0.00);
                investTrust = new FinanceElement (S.GetText (S.INVESTMENT_TRUST) + ":", 0.00);
            } else {
                busBal = new FinanceElement (S.GetText (S.BUSINESS_BALANCE) + ":", matter.businessBalance, deviceType);
                currBal = new FinanceElement (S.GetText (S.CURRENT_BALANCE) + ":", matter.currentBalance, deviceType);
                unbilled = new FinanceElement (S.GetText (S.UNBILLED_BALANCE) + ":", matter.unbilledBalance, deviceType);
                trustBal = new FinanceElement (S.GetText (S.TRUST_BALANCE) + ":", matter.trustBalance, deviceType);
                reserveTrust = new FinanceElement (S.GetText (S.RESERVE_TRUST) + ":", matter.reserveTrust, deviceType);
                pending = new FinanceElement (S.GetText (S.PENDING_DISBURSEMENTS) + ":", matter.pendingDisbursementBalance, deviceType);
                investTrust = new FinanceElement (S.GetText (S.INVESTMENT_TRUST) + ":", matter.investmentTrustBalance, deviceType
                );

            }
            //
            sec.Add (matterName);
            sec.Add (clientName);
            sec.Add (ownerName);
            sec.Add (matterID);
            Root.Add (sec);
            //
            sec2.Add (busBal);
            sec2.Add (trustBal);
            sec2.Add (investTrust);
            sec2.Add (currBal);
            sec2.Add (reserveTrust);
            sec2.Add (unbilled);
            sec2.Add (pending);
            if (legacy != null) {
                sec2.Add (legacy);
            }

            Root.Add (sec2);
        }
        public void buildFeeTargetReport()
        {
            //NumberFormatInfo nfi = new CultureInfo ("en-US", false).NumberFormat;
            Root = new RootElement ("Fee Target Progress");
            var v = new UIView ();
            v.Frame = new RectangleF (10, 10, 600, 10);
            var dummy = new Section (v);
            Root.Add (dummy);
            var headerLabel = new UILabel (new RectangleF (10, 10, 800, 48)) {
                Font = UIFont.BoldSystemFontOfSize (18),
                BackgroundColor = ColorHelper.GetGPPurple (),
                TextAlignment = UITextAlignment.Center,
                TextColor = UIColor.White,
                Text = "Practice Fee Target Progress"
            };
            var view = new UIViewBordered ();
            view.Frame = new RectangleF (10, 20, 800, 48);
            view.Add (headerLabel);
            Root.Add (new Section (view));

            PracticeTotals totals = this.report.practiceTotals;

            var ptLabel = new UILabel (new RectangleF (10, 10, 800, 24)) {
                Font = UIFont.BoldSystemFontOfSize (24),
                TextAlignment = UITextAlignment.Center,
                TextColor = ColorHelper.GetGPPurple (),
                Text = "Practice Totals"
            };

            var totSection = new Section ("Practice Totals");
            var tot1 = new BigFinanceElement ("Invoiced MTD Total:  ", totals.invoicedMTDTotal);

            totSection.Add (tot1);
            Root.Add (totSection);

            if (totals.recordedMTD != null) {

                var mtdSection = new Section ("Recorded MTD");
                mtdSection.Add (getElement (totals.recordedMTD.achieved, "Achieved: "));
                mtdSection.Add (getElement (totals.recordedMTD.estimatedTarget, "Estimated Target: "));
                mtdSection.Add (getElement (totals.recordedMTD.invoicedDebits, "Invoiced Debits: "));
                mtdSection.Add (getElement (totals.recordedMTD.unbilled, "Unbilled: "));
                mtdSection.Add (getElement (totals.recordedMTD.total, "Total: "));
                Root.Add (mtdSection);
            }
            if (totals.recordedYTD != null) {

                var mtdSection = new Section ("Recorded YTD");
                mtdSection.Add (getElement (totals.recordedYTD.achieved, "Achieved: "));
                mtdSection.Add (getElement (totals.recordedYTD.estimatedTarget, "Estimated Target: "));
                mtdSection.Add (getElement (totals.recordedYTD.invoiced, "Invoiced: "));
                mtdSection.Add (getElement (totals.recordedYTD.unbilled, "Unbilled: "));
                mtdSection.Add (getElement (totals.recordedYTD.total, "Total: "));
                Root.Add (mtdSection);
            }
            if (totals.matterActivity != null) {
                var matterActivitySection = new Section ("Matter Activity");
                var tot2 = new NumberElement (totals.matterActivity.active, "Active Matters: ");
                matterActivitySection.Add (tot2);
                var tot3 = new NumberElement (totals.matterActivity.deactivated, "Deactivated Matters: ");
                matterActivitySection.Add (tot3);
                var tot4 = new NumberElement (totals.matterActivity.newWork, "New Work: ");
                matterActivitySection.Add (tot4);
                var tot5 = new NumberElement (totals.matterActivity.noActivity, "No Activity: ");
                matterActivitySection.Add (tot5);
                var tot6 = new StringElement ("No Activity Duration:   " + totals.matterActivity.noActivityDuration);
                matterActivitySection.Add (tot6);
                Root.Add (matterActivitySection);
            }
            //
            if (totals.matterBalances != null) {
                var matterBalancesSection = new Section ("Matter Balances");
                matterBalancesSection.Add (getElement (totals.matterBalances.business, "Business: "));
                matterBalancesSection.Add (getElement (totals.matterBalances.unbilled, "Unbilled: "));
                matterBalancesSection.Add (getElement (totals.matterBalances.trust, "Trust Balance: "));
                matterBalancesSection.Add (getElement (totals.matterBalances.investment, "Investments: "));
                Root.Add (matterBalancesSection);
            }
            for (var i = 0; i < 10; i++) {
                Root.Add (new Section (" "));
            }
        }
        public void buildReport()
        {
            Root = new RootElement ("");
            var v = new UIView ();
            v.Frame = new RectangleF (10, 10, 600, 10);
            var dummy = new Section (v);
            Root.Add (dummy);

            var headerLabel = new UILabel (new RectangleF (10, 10, 800, 48)) {
                Font = UIFont.BoldSystemFontOfSize (18),
                BackgroundColor = ColorHelper.GetGPPurple (),
                TextAlignment = UITextAlignment.Center,
                TextColor = UIColor.White,
                Text = "Branch Financial Status"
            };
            var view = new UIViewBordered ();
            view.Frame = new RectangleF (10, 20, 800, 48);
            view.Add (headerLabel);
            var topSection = new Section (view);

            Root.Add (topSection);

            //branch name view
            var branchLabel = new UILabel (new RectangleF (10, 10, 800, 24)) {
                Font = UIFont.BoldSystemFontOfSize (24),
                TextAlignment = UITextAlignment.Center,
                TextColor = ColorHelper.GetGPPurple (),
                Text = branch.name
            };
            var bs = new Section (branch.name);
            Root.Add (bs);

            var business = new Section ();
            business.Add (getElement (branch.businessStatus.businessDebtors, S.GetText (S.BUSINESS_DEBTORS) + ":  "));
            business.Add (getElement (branch.businessStatus.businessCreditors, S.GetText (S.BUSINESS_CREDITORS) + ":  "));
            business.Add (getElement (branch.businessStatus.banksTotal, "Banks Total:  "));
            business.Add (getElement (branch.businessStatus.pendingDisbursements, S.GetText (S.PENDING_DISBURSEMENTS) + ":  "));
            business.Add (getElement (branch.businessStatus.unbilled, "Unbilled:  "));
            business.Add (getElement (branch.businessStatus.vat, S.GetText (S.VAT) + ":  "));
            business.Add (getElement (branch.businessStatus.availableForTransfer, "Available for Transfer:  "));

            for (var i = 0; i < branch.businessStatus.banks.Count; i++) {
                var bn = new TitleElement (branch.businessStatus.banks [i].name);
                business.Add (bn);
                Bank bank = branch.businessStatus.banks [i];
                business.Add (getElement (bank.balance, "Balance:  "));
                business.Add (getElement (bank.receiptsForPeriod, "Receipts:  "));
                business.Add (new StringElement ("Date Reconciled:  " + bank.dateReconciled));
                business.Add (getElement (bank.reconciledAmount, "Reconciled Amount:  "));

            }
            Root.Add (business);
            //
            var trust = new Section (S.GetText (S.TRUST_STATUS));
            trust.Add (getElement (branch.trustStatus.banksTotal, "Banks Total:  "));
            trust.Add (getElement (branch.trustStatus.trustCreditors, S.GetText (S.TRUST_CREDITORS) + ":  "));
            trust.Add (getElement (branch.trustStatus.investments, S.GetText (S.INVESTMENTS) + ":  "));

            for (var i = 0; i < branch.trustStatus.banks.Count; i++) {
                var bn = new TitleElement (branch.trustStatus.banks [i].name);
                trust.Add (bn);
                Bank bank = branch.trustStatus.banks [i];
                trust.Add (getElement (bank.balance, "Balance:  "));
                trust.Add (getElement (bank.receiptsForPeriod, "Receipts:  "));
                trust.Add (new StringElement ("Date Reconciled:  " + bank.dateReconciled));
                trust.Add (getElement (bank.reconciledAmount, "Reconciled Amount:  "));

            }
            Root.Add (trust);
            for (var i = 0; i < 10; i++) {
                Root.Add (new Section (" "));
            }
        }