Exemplo n.º 1
0
            public ContactData getContact(int contactId)
            {
                string sql = "SELECT c.ContactId, c.firstName, c.lastName, c.title, c.organizationName, c.address1, c.address2, c.city, c.provinceState, c.postalZipCode, c.phoneNumber1, c.phoneNumber2, c.faxNumber, c.mobileNumber, c.emailAddress, l.CategoryId ";

                sql += " from contactdata c left join ContactLinkToCategory l on (c.ContactId = l.ContactId) ";
                sql += " WHERE " + DBDialect.isNull("c.Deleted") + " ";

                sql += " AND C.ContactId = " + contactId + "; ";

                Dictionary <int, ContactData> list = new Dictionary <int, ContactData>();
                DataSet ds = this.RunSelectQuery(sql);

                if (this.hasRows(ds))
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        ContactData item = new ContactData();
                        item.contactId = Convert.ToInt32(dr["ContactId"]);
                        if (list.ContainsKey(item.contactId))
                        {
                            item = list[item.contactId];
                        }
                        else
                        {
                            item.firstName        = (dr["firstName"]).ToString();
                            item.lastName         = (dr["lastName"]).ToString();
                            item.title            = (dr["title"]).ToString();
                            item.organizationName = (dr["organizationName"]).ToString();
                            item.address1         = (dr["address1"]).ToString();
                            item.address2         = (dr["address2"]).ToString();
                            item.city             = (dr["city"]).ToString();
                            item.provinceState    = (dr["provinceState"]).ToString();
                            item.postalZipCode    = (dr["postalZipCode"]).ToString();
                            item.phoneNumber1     = (dr["phoneNumber1"]).ToString();
                            item.phoneNumber2     = (dr["phoneNumber2"]).ToString();
                            item.faxNumber        = (dr["faxNumber"]).ToString();
                            item.mobileNumber     = (dr["mobileNumber"]).ToString();
                            item.emailAddress     = (dr["emailAddress"]).ToString();
                        }

                        int CategoryId = getPossiblyNullValue(dr, "CategoryId", Int32.MinValue);
                        if (CategoryId >= 0)
                        {
                            item.contactCategoryIds.Add(CategoryId);
                        }

                        if (!list.ContainsKey(item.contactId))
                        {
                            list.Add(item.contactId, item);
                        }
                    } // foreach row
                }     // if there is data

                List <ContactData> ret = new List <ContactData>(list.Values);

                if (ret.Count == 1)
                {
                    ContactData[] arr = ret.ToArray();
                    return(arr[0]);
                }
                return(new ContactData());
            } // getContact
Exemplo n.º 2
0
            } // getContact

            public ContactData[] getContacts(ContactPlaceholderData data, int[] categoryIds, string[] orgNamesToDisplay)
            {
                string sql = "SELECT c.ContactId, c.firstName, c.lastName, c.title, c.organizationName, c.address1, c.address2, c.city, c.provinceState, c.postalZipCode, c.phoneNumber1, c.phoneNumber2, c.faxNumber, c.mobileNumber, c.emailAddress, l.CategoryId ";

                sql += " from contactdata c left join ContactLinkToCategory l on (c.ContactId = l.ContactId) ";
                sql += " WHERE " + DBDialect.isNull("c.Deleted") + " ";

                if (categoryIds.Length > 0)
                {
                    sql += " AND l.CategoryId in (" + StringUtils.Join(",", categoryIds) + ") ";
                }

                if (orgNamesToDisplay.Length > 0)
                {
                    foreach (string org in orgNamesToDisplay)
                    {
                        sql += " AND c.organizationName like '" + dbEncode(org) + "' ";
                    }
                }

                switch (data.nameDisplayMode)
                {
                case ContactPlaceholderData.ContactNameDisplayMode.FirstnameLastname:
                    sql += " ORDER BY c.firstName ";
                    break;

                case ContactPlaceholderData.ContactNameDisplayMode.LastnameFirstname:
                    sql += " ORDER BY c.lastName ";
                    break;

                default:
                    throw new ArgumentException("invalid ContactNameDisplayMode");
                }// switch


                Dictionary <int, ContactData> list = new Dictionary <int, ContactData>();
                DataSet ds = this.RunSelectQuery(sql);

                if (this.hasRows(ds))
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        ContactData item = new ContactData();
                        item.contactId = Convert.ToInt32(dr["ContactId"]);
                        if (list.ContainsKey(item.contactId))
                        {
                            item = list[item.contactId];
                        }
                        else
                        {
                            item.firstName        = (dr["firstName"]).ToString();
                            item.lastName         = (dr["lastName"]).ToString();
                            item.title            = (dr["title"]).ToString();
                            item.organizationName = (dr["organizationName"]).ToString();
                            item.address1         = (dr["address1"]).ToString();
                            item.address2         = (dr["address2"]).ToString();
                            item.city             = (dr["city"]).ToString();
                            item.provinceState    = (dr["provinceState"]).ToString();
                            item.postalZipCode    = (dr["postalZipCode"]).ToString();
                            item.phoneNumber1     = (dr["phoneNumber1"]).ToString();
                            item.phoneNumber2     = (dr["phoneNumber2"]).ToString();
                            item.faxNumber        = (dr["faxNumber"]).ToString();
                            item.mobileNumber     = (dr["mobileNumber"]).ToString();
                            item.emailAddress     = (dr["emailAddress"]).ToString();
                        }

                        int CategoryId = getPossiblyNullValue(dr, "CategoryId", Int32.MinValue);
                        if (CategoryId >= 0)
                        {
                            item.contactCategoryIds.Add(CategoryId);
                        }

                        if (!list.ContainsKey(item.contactId))
                        {
                            list.Add(item.contactId, item);
                        }
                    } // foreach row
                }     // if there is data

                List <ContactData> ret = new List <ContactData>(list.Values);

                return(ret.ToArray());
            } // getContacts
Exemplo n.º 3
0
        } // getContacts

        public static bool DeleteContact(ContactData contactToDelete)
        {
            return(new ContactDataDb().Delete(contactToDelete.contactId));
        }
Exemplo n.º 4
0
        private string getAddEditContactForm(ContactPlaceholderData data, ContactData contactToEdit, CmsPage page, int identifier, CmsLanguage langToRenderFor)
        {
            string ControlId = "Contacts_" + page.ID.ToString() + "_" + identifier.ToString() + langToRenderFor.shortCode;
            bool   editing   = (contactToEdit.contactId > -1);

            // -- process form actions
            string action              = PageUtils.getFromForm(ControlId + "action", "");
            string _userErrorMessage   = "";
            string _userMessage        = "";
            bool   _showContactDetails = true;

            if (editing && String.Compare(action, "deleteContact", true) == 0)
            {
                bool b = ContactData.DeleteContact(contactToEdit);
                if (b)
                {
                    _userMessage        = "The contact \"" + getNameDisplayOutput(data, contactToEdit) + "\" has been deleted";
                    _showContactDetails = false;
                }
                else
                {
                    _userErrorMessage = "Error: could not delete contact. There was a database error";
                }
            }
            else if (String.Compare(action, "addNewContact", true) == 0)
            {
                if (!editing)
                {
                    contactToEdit = new ContactData();
                }

                contactToEdit.firstName        = PageUtils.getFromForm(ControlId + "firstName", contactToEdit.firstName);
                contactToEdit.lastName         = PageUtils.getFromForm(ControlId + "lastName", contactToEdit.lastName);
                contactToEdit.title            = PageUtils.getFromForm(ControlId + "title", contactToEdit.title);
                contactToEdit.organizationName = PageUtils.getFromForm(ControlId + "organizationName", contactToEdit.organizationName);
                contactToEdit.address1         = PageUtils.getFromForm(ControlId + "address1", contactToEdit.address1);
                contactToEdit.address2         = PageUtils.getFromForm(ControlId + "address2", contactToEdit.address2);
                contactToEdit.city             = PageUtils.getFromForm(ControlId + "city", contactToEdit.city);
                contactToEdit.provinceState    = PageUtils.getFromForm(ControlId + "provinceState", contactToEdit.provinceState);
                contactToEdit.postalZipCode    = PageUtils.getFromForm(ControlId + "postalZipCode", contactToEdit.postalZipCode);
                contactToEdit.phoneNumber1     = PageUtils.getFromForm(ControlId + "phoneNumber1", contactToEdit.phoneNumber1);
                contactToEdit.phoneNumber2     = PageUtils.getFromForm(ControlId + "phoneNumber2", contactToEdit.phoneNumber2);
                contactToEdit.faxNumber        = PageUtils.getFromForm(ControlId + "faxNumber", contactToEdit.faxNumber);
                contactToEdit.mobileNumber     = PageUtils.getFromForm(ControlId + "mobileNumber", contactToEdit.mobileNumber);
                contactToEdit.emailAddress     = PageUtils.getFromForm(ControlId + "emailAddress", contactToEdit.emailAddress);

                string[] s_catIds = PageUtils.getFromForm(ControlId + "category");
                int[]    catIds   = StringUtils.ToIntArray(s_catIds);
                contactToEdit.contactCategoryIds.Clear();
                contactToEdit.contactCategoryIds.AddRange(catIds);

                if (contactToEdit.firstName.Trim() == "")
                {
                    _userErrorMessage = "Please enter the contact's first name";
                }
                else if (contactToEdit.lastName.Trim() == "")
                {
                    _userErrorMessage = "Please enter the contact's last name";
                }
                else if (contactToEdit.contactCategoryIds.Count < 1)
                {
                    _userErrorMessage = "Please select at least one category for the contact";
                }
                else
                {
                    bool b = contactToEdit.SaveToDatabase();
                    if (!b)
                    {
                        _userErrorMessage = "There was a problem saving the contact to the database";
                    }
                    else
                    {
                        if (editing)
                        {
                            string nameDisplay = getNameDisplayOutput(data, contactToEdit);
                            _userMessage = "The changes to \"" + nameDisplay + "\" have been saved.";
                        }
                        else
                        {
                            string nameDisplay = getNameDisplayOutput(data, contactToEdit);
                            _userMessage  = "The contact \"" + nameDisplay + "\" has been added.";
                            contactToEdit = new ContactData(); // remove all previously submitted values
                            editing       = false;
                        }
                    }
                }
            } // if process

            StringBuilder html = new StringBuilder();

            if (editing)
            {
                string nameDisplay = getNameDisplayOutput(data, contactToEdit);
                html.Append("<h2>Edit contact \"" + nameDisplay + "\":</h2>");
            }
            else
            {
                html.Append("<h2>Add a new contact:</h2>");
            }

            if (_userErrorMessage != "")
            {
                html.Append("<p style=\"color: red\">Error: " + _userErrorMessage + "</p>");
            }
            if (_userMessage != "")
            {
                html.Append("<p style=\"color: green\">" + _userMessage + "</p>");
            }

            if (!_showContactDetails)
            {
                return(html.ToString());
            }

            string formId = "editContact";

            html.Append(page.getFormStartHtml(formId));
            html.Append("<table border=\"0\">");

            string dividerLineHtml = getDividerLineHtml(4);

            html.Append(dividerLineHtml);

            html.Append("<tr>");
            html.Append("<td>First Name:</td>");
            html.Append("<td>" + PageUtils.getInputTextHtml(ControlId + "firstName", ControlId + "firstName", contactToEdit.firstName, 20, 255) + "</td>");


            html.Append("<td>Last Name:</td>");
            html.Append("<td>" + PageUtils.getInputTextHtml(ControlId + "lastName", ControlId + "lastName", contactToEdit.lastName, 20, 255) + "</td>");
            html.Append("</tr>");

            html.Append(dividerLineHtml);

            string colspan = "3";

            html.Append("<td>Categories:</td>");
            ContactDataCategory[] allCategories = ContactDataCategory.getAllContactCategories();
            html.Append("<td colspan=\"" + colspan + "\">");
            int cbid = 0;

            foreach (ContactDataCategory cat in allCategories)
            {
                bool   check = (contactToEdit.contactCategoryIds.IndexOf(cat.CategoryId) > -1);
                string cb    = PageUtils.getCheckboxHtml(cat.Title, ControlId + "category", ControlId + "category" + cbid.ToString(), cat.CategoryId.ToString(), check);
                html.Append(cb + "<br />");
                cbid++;
            }  // foreach
            html.Append("</td>");

            html.Append(dividerLineHtml);

            html.Append("<tr>");
            html.Append("<td>Title:</td>");
            html.Append("<td colspan=\"" + colspan + "\">" + PageUtils.getInputTextHtml(ControlId + "title", ControlId + "title", contactToEdit.title, 40, 255) + "</td>");
            html.Append("</tr>");

            html.Append("<tr>");
            html.Append("<td>Organization:</td>");
            html.Append("<td colspan=\"" + colspan + "\">" + PageUtils.getInputTextHtml(ControlId + "organizationName", ControlId + "organizationName", contactToEdit.organizationName, 40, 255) + "</td>");
            html.Append("</tr>");

            html.Append(dividerLineHtml);

            html.Append("<tr>");
            html.Append("<td>Address 1:</td>");
            html.Append("<td colspan=\"" + colspan + "\">" + PageUtils.getInputTextHtml(ControlId + "address1", ControlId + "address1", contactToEdit.address1, 40, 255) + "</td>");
            html.Append("</tr>");

            html.Append("<tr>");
            html.Append("<td>Address 2:</td>");
            html.Append("<td colspan=\"" + colspan + "\">" + PageUtils.getInputTextHtml(ControlId + "address2", ControlId + "address2", contactToEdit.address2, 40, 255) + "</td>");
            html.Append("</tr>");

            html.Append("<tr>");
            html.Append("<td>City:</td>");
            html.Append("<td colspan=\"" + colspan + "\">" + PageUtils.getInputTextHtml(ControlId + "city", ControlId + "city", contactToEdit.city, 40, 255) + "</td>");
            html.Append("</tr>");

            html.Append("<tr>");
            html.Append("<td>Province/State:</td>");
            html.Append("<td colspan=\"" + colspan + "\">" + PageUtils.getInputTextHtml(ControlId + "provinceState", ControlId + "provinceState", contactToEdit.provinceState, 20, 255) + "</td>");
            html.Append("</tr>");

            html.Append("<tr>");
            html.Append("<td>Postal/Zip Code:</td>");
            html.Append("<td colspan=\"" + colspan + "\">" + PageUtils.getInputTextHtml(ControlId + "postalZipCode", ControlId + "postalZipCode", contactToEdit.postalZipCode, 10, 255) + "</td>");
            html.Append("</tr>");

            html.Append(dividerLineHtml);

            html.Append("<tr>");
            html.Append("<td>Phone Number 1:</td>");
            html.Append("<td colspan=\"" + colspan + "\">" + PageUtils.getInputTextHtml(ControlId + "phoneNumber1", ControlId + "phoneNumber1", contactToEdit.phoneNumber1, 20, 255) + "</td>");
            html.Append("</tr>");

            html.Append("<tr>");
            html.Append("<td>Phone Number 2:</td>");
            html.Append("<td colspan=\"" + colspan + "\">" + PageUtils.getInputTextHtml(ControlId + "phoneNumber2", ControlId + "phoneNumber2", contactToEdit.phoneNumber2, 20, 255) + "</td>");
            html.Append("</tr>");

            html.Append("<tr>");
            html.Append("<td>Fax Number:</td>");
            html.Append("<td colspan=\"" + colspan + "\">" + PageUtils.getInputTextHtml(ControlId + "faxNumber", ControlId + "faxNumber", contactToEdit.faxNumber, 20, 255) + "</td>");
            html.Append("</tr>");

            html.Append("<tr>");
            html.Append("<td>Mobile Number:</td>");
            html.Append("<td colspan=\"" + colspan + "\">" + PageUtils.getInputTextHtml(ControlId + "mobileNumber", ControlId + "mobileNumber", contactToEdit.mobileNumber, 20, 255) + "</td>");
            html.Append("</tr>");

            html.Append(dividerLineHtml);

            html.Append("<tr>");
            html.Append("<td>Email Address:</td>");
            html.Append("<td colspan=\"" + colspan + "\">" + PageUtils.getInputTextHtml(ControlId + "emailAddress", ControlId + "emailAddress", contactToEdit.emailAddress, 40, 255) + "</td>");
            html.Append("</tr>");

            html.Append("</table>");

            html.Append(PageUtils.getHiddenInputHtml(ControlId + "action", "addNewContact"));


            if (editing)
            {
                html.Append(PageUtils.getHiddenInputHtml(CurrentContactIdFormName, contactToEdit.contactId.ToString()));
                html.Append("<input type=\"submit\" value=\"save changes\">");
            }
            else
            {
                html.Append("<input type=\"submit\" value=\"add contact\">");
            }


            html.Append(page.getFormCloseHtml(formId));

            if (editing)
            {
                formId = formId + "_Delete";
                html.Append(page.getFormStartHtml(formId));
                html.Append("<p align=\"right\">Delete:");
                html.Append(PageUtils.getHiddenInputHtml(CurrentContactIdFormName, contactToEdit.contactId.ToString()));
                html.Append(PageUtils.getHiddenInputHtml(ControlId + "action", "deleteContact"));
                html.Append("<input type=\"submit\" value=\"delete contact\">");
                html.Append("</p>");
                html.Append(page.getFormCloseHtml(formId));
            }

            return(html.ToString());
        } // getAddEditContactForm
Exemplo n.º 5
0
        private void RenderViewIndividual(HtmlTextWriter writer, CmsPage page, int identifier, CmsLanguage langToRenderFor, string[] paramList)
        {
            ContactsDb             db   = new ContactsDb();
            ContactPlaceholderData data = db.getContactPlaceholderData(page, identifier, true);

            int contactId = PageUtils.getFromForm(CurrentContactIdFormName, -1);

            ContactData contactToView = ContactData.getContact(contactId);

            bool canEdit = page.currentUserCanWrite;

            string backUrl = page.Url;

            writer.Write("<p><a href=\"" + backUrl + "\">&#171; back to contact listing</a></p>");
            // -- begin output
            if (canEdit)
            {
                writer.Write(getAddEditContactForm(data, contactToView, page, identifier, langToRenderFor));
            }
            else
            {
                StringBuilder html = new StringBuilder();
                html.Append("<table border=\"0\">");

                string dividerLineHtml = getDividerLineHtml(2);

                html.Append(dividerLineHtml);

                html.Append("<tr>");
                html.Append("<td colspan=\"2\" align=\"center\"><h2>" + StringUtils.JoinNonBlanks(" ", new string[] { contactToView.firstName, contactToView.lastName }) + "</h2></td>");

                html.Append(dividerLineHtml);

                string colspan = "1";

                html.Append("<td>Categories:</td>");
                ContactDataCategory[] allCategories = ContactDataCategory.getAllContactCategories();
                html.Append("<td colspan=\"" + colspan + "\">");
                int cbid = 0;
                foreach (ContactDataCategory cat in allCategories)
                {
                    bool   check = (contactToView.contactCategoryIds.IndexOf(cat.CategoryId) > -1);
                    string cb    = PageUtils.getCheckboxHtml(cat.Title, "category", "category" + cbid.ToString(), cat.CategoryId.ToString(), check);
                    html.Append(cb + "<br />");
                    cbid++;
                } // foreach
                html.Append("</td>");

                html.Append(dividerLineHtml);

                html.Append("<tr>");
                html.Append("<td>Title:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.title + "</td>");
                html.Append("</tr>");

                html.Append("<tr>");
                html.Append("<td>Organization:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.organizationName + "</td>");
                html.Append("</tr>");

                html.Append(dividerLineHtml);

                html.Append("<tr>");
                html.Append("<td>Address 1:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.address1 + "</td>");
                html.Append("</tr>");

                html.Append("<tr>");
                html.Append("<td>Address 2:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.address2 + "</td>");
                html.Append("</tr>");

                html.Append("<tr>");
                html.Append("<td>City:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.city + "</td>");
                html.Append("</tr>");

                html.Append("<tr>");
                html.Append("<td>Province/State:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.provinceState + "</td>");
                html.Append("</tr>");

                html.Append("<tr>");
                html.Append("<td>Postal/Zip Code:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.postalZipCode + "</td>");
                html.Append("</tr>");

                html.Append(dividerLineHtml);

                html.Append("<tr>");
                html.Append("<td>Phone Number 1:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.phoneNumber1 + "</td>");
                html.Append("</tr>");

                html.Append("<tr>");
                html.Append("<td>Phone Number 2:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.phoneNumber2 + "</td>");
                html.Append("</tr>");

                html.Append("<tr>");
                html.Append("<td>Fax Number:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.faxNumber + "</td>");
                html.Append("</tr>");

                html.Append("<tr>");
                html.Append("<td>Mobile Number:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.mobileNumber + "</td>");
                html.Append("</tr>");

                html.Append(dividerLineHtml);

                string emailDisplay = "";
                if (contactToView.emailAddress.Trim() != "")
                {
                    emailDisplay = "<a href=\"mailto:" + contactToView.SpamEncodedEmailAddress + "\">" + contactToView.SpamEncodedEmailAddress + "</a>";
                }

                html.Append("<tr>");
                html.Append("<td>Email Address:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + emailDisplay + "</td>");
                html.Append("</tr>");

                html.Append("</table>");

                writer.Write(html.ToString());
            }
        }
Exemplo n.º 6
0
        private string getContactDetailsSummaryDisplay(ContactData contact)
        {
            List <string> lines = new List <string>();

            if (contact.title.Trim() != "")
            {
                lines.Add(contact.title);
            }

            if (contact.organizationName.Trim() != "")
            {
                lines.Add(contact.organizationName);
            }

            if (contact.address1.Trim() != "")
            {
                lines.Add(contact.address1);
            }
            if (contact.address2.Trim() != "")
            {
                lines.Add(contact.address2);
            }

            string cityLine = "";

            if (contact.city.Trim() != "")
            {
                cityLine = contact.city + ", ";
            }
            if (contact.provinceState.Trim() != "")
            {
                cityLine += contact.provinceState + " ";
            }
            if (contact.postalZipCode.Trim() != "")
            {
                cityLine += contact.postalZipCode;
            }
            if (cityLine.Trim() != "")
            {
                lines.Add(cityLine);
            }

            if (contact.phoneNumber1.Trim() != "")
            {
                lines.Add("Phone: " + contact.phoneNumber1);
            }
            if (contact.phoneNumber2.Trim() != "")
            {
                lines.Add("Phone: " + contact.phoneNumber2);
            }
            if (contact.mobileNumber.Trim() != "")
            {
                lines.Add("Mobile: " + contact.mobileNumber);
            }
            if (contact.faxNumber.Trim() != "")
            {
                lines.Add("Fax: " + contact.faxNumber);
            }
            if (contact.emailAddress.Trim() != "")
            {
                lines.Add("E-mail: <a href=\"mailto:" + contact.SpamEncodedEmailAddress + "\">" + contact.SpamEncodedEmailAddress + "</a>");
            }

            string ret = String.Join("<br />", lines.ToArray());

            return(ret);
        }
Exemplo n.º 7
0
        public string getSummaryDisplayFilterForm(ContactPlaceholderData data, ContactData[] contacts, CmsPage page, int identifier)
        {
            if (!data.allowFilterByCategory && !data.allowFilterByCompany)
            {
                return("");
            }

            string ControlId = "Contacts_" + page.ID.ToString() + "_" + identifier.ToString();

            string[] allOrganizations           = ContactData.getAllOrganizationNames(contacts);
            ContactDataCategory[] allCategories = ContactDataCategory.getAllContactCategories();
            if (allOrganizations.Length < 1 && allCategories.Length < 1)
            {
                return("");
            }

            StringBuilder html = new StringBuilder();
            int           cbid = 0;

            html.Append("<div class=\"ContactsFilterForm\">");
            string formId = ControlId + "filterContacts";

            html.Append(page.getFormStartHtml(formId));

            html.Append("<strong>Filter contacts</strong><br />");
            if (data.allowFilterByCategory)
            {
                if (allCategories.Length > 1)
                {
                    html.Append(" <em> by category:</em><br />");

                    int[] catsChecked = getCategoryIdsToDisplay(data);

                    foreach (ContactDataCategory cat in allCategories)
                    {
                        bool   check      = (catsChecked.Length == 0 || (Array.IndexOf(catsChecked, cat.CategoryId) > -1));
                        string displayUrl = getContactSummaryDisplayUrl(page, new int[] { cat.CategoryId }, new string[0]);
                        string display    = cat.Title;
                        // string link = " <a title=\"view only contacts in '" + cat.Title + "'\" href=\"" + displayUrl + "\">(view)</a>";
                        string cb = PageUtils.getCheckboxHtml(display, "contactCat", ControlId + "category" + cbid.ToString(), cat.CategoryId.ToString(), check);
                        html.Append(cb + "<br />");
                        cbid++;
                    } // foreach
                }
            }

            if (data.allowFilterByCompany)
            {
                if (allOrganizations.Length > 1)
                {
                    html.Append(" <em> by organization:</em><br />");

                    string[] orgsChecked = getOrgNamesToDisplay();

                    foreach (string org in allOrganizations)
                    {
                        bool   check      = (orgsChecked.Length == 0 || (Array.IndexOf(orgsChecked, org) > -1));
                        string displayUrl = getContactSummaryDisplayUrl(page, new int[0], new string[] { org });
                        string display    = org;
                        // string link = " <a title=\"view only contacts belonging to '" + org + "'\" href=\"" + displayUrl + "\">(view)</a>";

                        string cb = PageUtils.getCheckboxHtml(display, "contactOrg", ControlId + "orgName" + cbid.ToString(), org, check);
                        html.Append(cb + "<br />");
                        cbid++;
                    } // foreach
                }
            }
            if (cbid > 0)
            {
                html.Append("<input type=\"submit\" value=\"filter\">");

                string checkAllFnName  = ControlId + "Check";
                string checkNoneFnName = ControlId + "CheckNone";

                StringBuilder js = new StringBuilder();
                js.Append("function " + checkAllFnName + "() {" + Environment.NewLine);
                js.Append(" $('#" + formId + " input[type=checkbox]:not(:checked)' ).attr('checked', true);" + Environment.NewLine);
                js.Append("} " + Environment.NewLine);

                js.Append("function " + checkNoneFnName + "() {" + Environment.NewLine);
                js.Append(" $('#" + formId + " input[type=checkbox]:checked' ).attr('checked', false);" + Environment.NewLine);
                js.Append("} " + Environment.NewLine);

                page.HeadSection.AddJSStatements(js.ToString());
                page.HeadSection.AddJavascriptFile(JavascriptGroup.Library, "js/_system/jquery/jquery-1.4.1.min.js");

                html.Append("<br>Check: <a href=\"#\" onclick=\"" + checkAllFnName + "(); return false;\">all</a> | <a href=\"#\" onclick=\"" + checkNoneFnName + "(); return false;\">none</a>");
            }
            html.Append(page.getFormCloseHtml(formId));
            html.Append("</div>");
            return(html.ToString());
        }