Update contact for their table schema
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 29 Jul 2014 17:36:04 +0000 (13:36 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 29 Jul 2014 17:36:04 +0000 (13:36 -0400)
They have different schema for contact table.
some updates needed to search correctly.

Toolkit/Contacts/config.ini
admin/Contact/contact_setup.inc
admin/Contact/index.phtml
admin/Contact/query_contact.phtml

index 9f64955..94d4e6f 100644 (file)
@@ -8,7 +8,7 @@ primarykey = "id"
 sequence = "contact_id_seq"
 
 [contact_types]
-1 = "Web Contact"
+;1 = "Web Contact"
 2 = "E-News"
 ;3 = "Travel Planner"
 ;4 = "Visitor Guide"
index c59784f..b3b704b 100755 (executable)
 <?php
 
 /**
-* contact_setup.phtml
-*
-* Config setting for the admin contact application
-*
-* PHP versions 4 and 5
-*
-* @category  Toolkit
-* @package   Contacts
-* @author    Steve Sutton <steve@gaslightmedia.com>
-* @copyright 2009 Steve Sutton
-* @license   Gaslight Media
-* @version   CVS: $Id: contact_setup.inc,v 1.7 2010/05/13 17:05:53 matrix Exp $
-* @link      <>
-*/
+ * contact_setup.phtml
+ *
+ * Config setting for the admin contact application
+ *
+ * PHP versions 4 and 5
+ *
+ * @category  Toolkit
+ * @package   Contacts
+ * @author    Steve Sutton <steve@gaslightmedia.com>
+ * @copyright 2009 Steve Sutton
+ * @license   Gaslight Media
+ * @version   CVS: $Id: contact_setup.inc,v 1.7 2010/05/13 17:05:53 matrix Exp $
+ * @link      <>
+ */
 extract($_REQUEST);
 // The Contact Type array is now is one location and is used by the
 // Toolkit_Contacts_Admin_EditContact class
-$conf = new Config;
-$contactRoot =& $conf->parseConfig(
-    BASE . 'Toolkit/Contacts/config.ini',
-    'IniFile'
+$conf        = new Config;
+$contactRoot = & $conf->parseConfig(
+        BASE . 'Toolkit/Contacts/config.ini', 'IniFile'
 );
 if (!defined("ENTRIES_PER_PAGE")) {
 
     /**
-    * how many per page on list contacts
-    */
+     * how many per page on list contacts
+     */
     define("ENTRIES_PER_PAGE", 10);    // Entries per Page in list_contact.phtml
 }
 
 /**
-* define for customer table
-*/
+ * define for customer table
+ */
 define("CUSTOMER_TABLE", "customer");    // name of customer table
 
 /**
-* define for contact table
-*/
+ * define for contact table
+ */
 define("CONTACT_TABLE", "contact");        // name of contact table
 
 $table = $contactRoot->getItem('section', 'conf')
     ->getItem('directive', 'table')
     ->getContent();
 /**
-* Table to user in db
-*/
+ * Table to user in db
+ */
 define("TABLE", $table);            // which table to use
 
 /**
-* postgres date formate
-*/
+ * postgres date formate
+ */
 define("DATEFORMAT", "US");                // date format (for edit_contact.phmtl)
 
 /**
-* template for the newsletter
-*/
+ * template for the newsletter
+ */
 define("NEWSLETTER_PROTOTYPE", "newsletter_template.html");                // date format (for edit_contact.phmtl)
 
 /**
-* class_template needed for GLM_TEMPLATE::get_seo_url()
-*/
-require_once BASE.'classes/class_template.inc';
+ * class_template needed for GLM_TEMPLATE::get_seo_url()
+ */
+require_once BASE . 'classes/class_template.inc';
 $DB = new GLM_DB();
 if (!defined("HTML_EMAIL")) {
 
     /**
-    * HTML_EMAIL = ON or OFF
-    */
+     * HTML_EMAIL = ON or OFF
+     */
     define("HTML_EMAIL", "ON");
 }
 if (!defined("PRODUCTION_MODE")) {
 
     /**
-    * PRODUCTION_MODE off/on  mail sent
-    */
+     * PRODUCTION_MODE off/on  mail sent
+     */
     define("PRODUCTION_MODE", "ON");
 }
 if (!defined("NEWSLETTER")) {
 
     /**
-    * NEWSLETTER 1 or true will allow newsletters
-    */
+     * NEWSLETTER 1 or true will allow newsletters
+     */
     define("NEWSLETTER", 1); //bool- does the contact database mail out a newsletter?
 }
 
 if (!function_exists("template_read")) {
 
     /**
-    * Short description for function
-    *
-    * Long description (if any) ...
-    *
-    * @param unknown $template Parameter description (if any) ...
-    *
-    * @return string  Return description (if any) ...
-    */
+     * Short description for function
+     *
+     * Long description (if any) ...
+     *
+     * @param unknown $template Parameter description (if any) ...
+     *
+     * @return string  Return description (if any) ...
+     */
     function template_read($template)
     {
         $fp       = fopen($template, "r");
@@ -108,21 +107,21 @@ if (!function_exists("template_read")) {
             return "";
         }
     }
+
 }
 // {{{ array_insert()
 
-
 /**
-* insert an array into another array after position.
-* You can specify an associative array key or index key
-* to dictact the positioning of the new array
-*
-* @param array   &$array       array to be used
-* @param unknown $position     position to add array
-* @param unknown $insert_array array to be inserted
-*
-* @return void
-*/
+ * insert an array into another array after position.
+ * You can specify an associative array key or index key
+ * to dictact the positioning of the new array
+ *
+ * @param array   &$array       array to be used
+ * @param unknown $position     position to add array
+ * @param unknown $insert_array array to be inserted
+ *
+ * @return void
+ */
 function array_insert(&$array, $position, $insert_array)
 {
     if (!is_int($position)) {
@@ -136,85 +135,89 @@ function array_insert(&$array, $position, $insert_array)
         }
     }
     $first_array = array_splice($array, 0, $position);
-    $array = array_merge($first_array, $insert_array, $array);
+    $array       = array_merge($first_array, $insert_array, $array);
 }
+
 // }}}
 // {{{ explode_template()
 if (!function_exists("explode_template")) {
 
     /**
-    * Short description for function
-    *
-    * Long description (if any) ...
-    *
-    * @param unknown $template Parameter description (if any) ...
-    * @param unknown $data     Parameter description (if any) ...
-    *
-    * @return unknown Return description (if any) ...
-    */
+     * Short description for function
+     *
+     * Long description (if any) ...
+     *
+     * @param unknown $template Parameter description (if any) ...
+     * @param unknown $data     Parameter description (if any) ...
+     *
+     * @return unknown Return description (if any) ...
+     */
     function explode_template($template, $data)
     {
         $template = template_read($template);
         $output   = template_replacement($template, $data);
         $output   = wordwrap($output, 72);
         return $output;
-
     }
+
 }
 // }}}
 // {{{ template_replacement($template, $fieldarr)
 if (!function_exists("template_replacement")) {
 
     /**
-    * Short description for function
-    *
-    * Long description (if any) ...
-    *
-    * @param unknown $template Parameter description (if any) ...
-    * @param array   $fieldarr Parameter description (if any) ...
-    *
-    * @return unknown Return description (if any) ...
-    */
+     * Short description for function
+     *
+     * Long description (if any) ...
+     *
+     * @param unknown $template Parameter description (if any) ...
+     * @param array   $fieldarr Parameter description (if any) ...
+     *
+     * @return unknown Return description (if any) ...
+     */
     function template_replacement($template, $fieldarr)
     {
         if (is_array($fieldarr)) {
             foreach ($fieldarr as $key => $value) {
-                $template = str_replace("<!-- ".$key." -->", $value, $template);
+                $template = str_replace("<!-- " . $key . " -->", $value,
+                                        $template);
             }
         }
         return $template;
     }
+
 }
 // }}}
 // {{{ add_image($image, $align)
 if (!function_exists("add_image")) {
 
     /**
-    * Short description for function
-    *
-    * Long description (if any) ...
-    *
-    * @param string $image Parameter description (if any) ...
-    * @param string $align Parameter description (if any) ...
-    *
-    * @return string Return description (if any) ...
-    */
+     * Short description for function
+     *
+     * Long description (if any) ...
+     *
+     * @param string $image Parameter description (if any) ...
+     * @param string $align Parameter description (if any) ...
+     *
+     * @return string Return description (if any) ...
+     */
     function add_image($image, $align)
     {
         if ($image != "") {
-            return '<div style="margin:5px;float:'.$align.';"><img src="'.MIDSIZED.$image.'"></div>';
+            return '<div style="margin:5px;float:' . $align . ';"><img src="' . MIDSIZED . $image . '"></div>';
         }
     }
+
 }
 // }}}
 // {{{ Navigation array
 $nav      = array(
-    "Report Builder"         => "index.phtml",
-    "Add Contact"            => "edit_contact.php",
-    "List Contacts"          => "list_contact.phtml",
-    "Contact Inquiry Fields" => "contact_inquiry.phtml",
-    "HTML Emails"            => "emails.php",
-    "Saved Reports"          => "list_query.phtml",
+    "Report Builder"   => "index.phtml",
+    "Add Contact"      => "edit_contact.php",
+    "List Contacts"    => "list_contact.phtml",
+    "Discovery Fields" => "contact_inquiry.phtml",
+    "HTML Emails"      => "emails.php",
+    "Saved Reports"    => "list_query.phtml",
 );
 // }}}
 $discover = array('' => "Don't Care");
@@ -223,94 +226,114 @@ $query    = "select * from contact_inq order by pos;";
 $cData    = $DB->db_auto_get_data($query);
 if (is_array($cData)) {
     foreach ($cData as $key => $value) {
-        $int_array[$value['id']] = $value['header'];
+        $int_array[$value['id']]    = $value['header'];
         $discover[$value['header']] = $value['header'];
     }
 }
-$contactTypesSetup =
-    $contactRoot->getItem('section', 'contact_types')
+$contactTypesSetup = $contactRoot->getItem('section', 'contact_types')
     ->toArray();
-$cType = $contactTypesSetup['contact_types'];
+$cType             = $contactTypesSetup['contact_types'];
 // {{{ search_where($name, $search_where)
 
 /**
-* Short description for function
-*
-* Long description (if any) ...
-*
-* @param string $name         Parameter description (if any) ...
-* @param string $search_where Parameter description (if any) ...
-*
-* @return string Return description (if any) ...
-*/
+ * Short description for function
+ *
+ * Long description (if any) ...
+ *
+ * @param string $name         Parameter description (if any) ...
+ * @param string $search_where Parameter description (if any) ...
+ *
+ * @return string Return description (if any) ...
+ */
 function search_where($name, $search_where)
 {
     $out = '
-    <select name="'.$name.'">
-        <option value="1" '.( ( !isset( $search_type ) || $search_type == "0" ) ? 'selected' : '' ).'>Anywhere
-        <option value="2" '.( ( $search_where == '1' ) ? 'selected' : '' ).'>Begining
-        <option value="3" '.( ( $search_where == '2' ) ? 'selected' : '' ).'>Ending
+    <select name="' . $name . '">
+        <option value="1" ' . ( (!isset($search_type) || $search_type == "0" )
+            ? 'selected'
+            : '' ) . '>Anywhere
+        <option value="2" ' . ( ( $search_where == '1' )
+            ? 'selected'
+            : '' ) . '>Begining
+        <option value="3" ' . ( ( $search_where == '2' )
+            ? 'selected'
+            : '' ) . '>Ending
     </select>';
     return $out;
 }
+
 // }}}
 // {{{ search_type($name, $search_type)
 
 /**
-* Short description for function
-*
-* Long description (if any) ...
-*
-* @param string $name        Parameter description (if any) ...
-* @param string $search_type Parameter description (if any) ...
-*
-* @return string Return description (if any) ...
-*/
+ * Short description for function
+ *
+ * Long description (if any) ...
+ *
+ * @param string $name        Parameter description (if any) ...
+ * @param string $search_type Parameter description (if any) ...
+ *
+ * @return string Return description (if any) ...
+ */
 function search_type($name, $search_type)
 {
     $out = '
-    <select name="'.$name.'">
-        <option value="2" '.( ( !isset( $search_type ) || $search_type == '2' ) ? 'selected' : '' ).'>And
-        <option value="3" '.( ( $search_type == '3' ) ? 'selected' : '' ).'>Or
-        <option value="4" '.( ( $search_type == '4' ) ? 'selected' : '' ).'>Not
+    <select name="' . $name . '">
+        <option value="2" ' . ( (!isset($search_type) || $search_type == '2' )
+            ? 'selected'
+            : '' ) . '>And
+        <option value="3" ' . ( ( $search_type == '3' )
+            ? 'selected'
+            : '' ) . '>Or
+        <option value="4" ' . ( ( $search_type == '4' )
+            ? 'selected'
+            : '' ) . '>Not
     </select>';
     return $out;
 }
+
 // }}}
 // {{{ search_bool($name, $search_type)
 
 /**
-* Short description for function
-*
-* Long description (if any) ...
-*
-* @param string $name        Parameter description (if any) ...
-* @param string $search_type Parameter description (if any) ...
-*
-* @return string Return description (if any) ...
-*/
+ * Short description for function
+ *
+ * Long description (if any) ...
+ *
+ * @param string $name        Parameter description (if any) ...
+ * @param string $search_type Parameter description (if any) ...
+ *
+ * @return string Return description (if any) ...
+ */
 function search_bool($name, $search_type)
 {
     $out = '
-    <select name="'.$name.'">
-        <option value="n" '.( !isset( $search_type ) ? 'selected' : '' ).'>Don\'t Care
-        <option value="1" '.( ( $search_type == '1' ) ? 'selected' : '' ).'>Yes
-        <option value="0" '.( ( $search_type == '0' ) ? 'selected' : '' ).'>No
+    <select name="' . $name . '">
+        <option value="n" ' . (!isset($search_type)
+            ? 'selected'
+            : '' ) . '>Don\'t Care
+        <option value="1" ' . ( ( $search_type == '1' )
+            ? 'selected'
+            : '' ) . '>Yes
+        <option value="0" ' . ( ( $search_type == '0' )
+            ? 'selected'
+            : '' ) . '>No
     </select>';
     return( $out );
 }
+
 // }}}
 // {{{ interest($field)
 
 /**
-* Short description for function
-*
-* Long description (if any) ...
-*
-* @param unknown $field Parameter description (if any) ...
-*
-* @return boolean Return description (if any) ...
-*/
+ * Short description for function
+ *
+ * Long description (if any) ...
+ *
+ * @param unknown $field Parameter description (if any) ...
+ *
+ * @return boolean Return description (if any) ...
+ */
 function interest($field)
 {
     if (!is_array($GLOBALS['int_array'])) {
@@ -319,41 +342,43 @@ function interest($field)
     echo "<table><tr>";
     $count = 0;
     foreach ($GLOBALS['int_array'] as $key => $value) {
-        if ($count==0) {
+        if ($count == 0) {
             echo "<td>";
         }
         echo "<input type=\"checkbox\" name=\"interest[]\" value=\"$key\"";
-        if (strstr($field, ":".$key.":")) {
+        if (strstr($field, ":" . $key . ":")) {
             echo " checked";
         }
         echo ">$value<br>";
-        if ($count==5) {
+        if ($count == 5) {
             echo "</td><td>";
         }
-        if ($count==11) {
+        if ($count == 11) {
             echo "</td>";
         }
         $count++;
     }
     echo "</tr></table>";
 }
+
 /**
-* Get a group of select elements to represent a date
-*
-* @param string $M Name attribute of the month select list
-* @param string $D Name attribute of the day select list
-* @param string $Y Name attribute of the year select list
-* @param string $m Selected value of the month select list
-* @param string $d Selected value of the day select list
-* @param string $y Selected value of the year select list
-*
-* @return string Html string of group select lists
-* @access public
-*/
-function dateSelector($M, $D, $Y, array $m = null, array $d = null, array $y = null)
+ * Get a group of select elements to represent a date
+ *
+ * @param string $M Name attribute of the month select list
+ * @param string $D Name attribute of the day select list
+ * @param string $Y Name attribute of the year select list
+ * @param string $m Selected value of the month select list
+ * @param string $d Selected value of the day select list
+ * @param string $y Selected value of the year select list
+ *
+ * @return string Html string of group select lists
+ * @access public
+ */
+function dateSelector($M, $D, $Y, array $m = null, array $d = null,
+                      array $y = null)
 {
     //  Get a Select element
-    $month = new HTML_Select($M);
+    $month      = new HTML_Select($M);
     //  Get a Range of months jan-dec
     $monthArray = array_flip(range(1, 12));
     //  Make the keys and values the same
@@ -368,7 +393,7 @@ function dateSelector($M, $D, $Y, array $m = null, array $d = null, array $y = n
     }
 
     //  Get a Select element
-    $day = new HTML_Select($D);
+    $day      = new HTML_Select($D);
     //  Get a Range of months jan-dec
     $dayArray = array_flip(range(1, 31));
     //  Make the keys and values the same
@@ -383,7 +408,7 @@ function dateSelector($M, $D, $Y, array $m = null, array $d = null, array $y = n
     }
 
     //  Get a Select element
-    $year = new HTML_Select($Y);
+    $year      = new HTML_Select($Y);
     //  Get a Range of months jan-dec
     $yearArray = array_flip(range(CONTACTS_FIRST_YEAR, date('Y')));
     //  Make the keys and values the same
@@ -402,8 +427,10 @@ function dateSelector($M, $D, $Y, array $m = null, array $d = null, array $y = n
 
 // }}}
 // default query on create_date
-$c_date_from  = GLM_TOOLBOX::contact_date_entry("", "", "", "fc_month", "fc_day", "fc_year");
-$c_date_to    = GLM_TOOLBOX::contact_date_entry("", "", "", "tc_month", "tc_day", "tc_year");
+$c_date_from = GLM_TOOLBOX::contact_date_entry("", "", "", "fc_month", "fc_day",
+                                               "fc_year");
+$c_date_to   = GLM_TOOLBOX::contact_date_entry("", "", "", "tc_month", "tc_day",
+                                               "tc_year");
 
 // The Following $DB_fields array is no longer used for the edit contact page
 // You must alter the class Toolkit_Contacts_Admin_EditContact
@@ -413,84 +440,73 @@ $primaryKey = $contactRoot->getItem('section', 'conf')
     ->getItem('directive', 'primarykey')
     ->getContent();
 /**
-* Description for define
-*/
+ * Description for define
+ */
 define("ID", $primaryKey);
 
 /**
-* Description for define
-*/
+ * Description for define
+ */
 define("MAILOK", "mail_ok");
 
 $sequence = $contactRoot->getItem('section', 'conf')
     ->getItem('directive', 'sequence')
     ->getContent();
 /**
-* Description for define
-*/
+ * Description for define
+ */
 define("SEQUENCE", $sequence);
 
 /**
-* Description for define
-*/
-define("WHERE", ID." IS NOT NULL");
+ * Description for define
+ */
+define("WHERE", ID . " IS NOT NULL");
 // $DB_fields are used for edit and updating contacts
-$DB_fields[] = array("name" => "id",            "title" => "id",            "type" => "hide");
-$DB_fields[] = array("name" => "create_date",   "title" => "Create Date",   "type" => "static");
-$DB_fields[] = array("name" => "fname",         "title" => "First Name",    "type" => "text");
-$DB_fields[] = array("name" => "lname",         "title" => "Last Name",     "type" => "text");
+$DB_fields[] = array("name" => "id", "title" => "id", "type" => "hide");
+$DB_fields[] = array("name" => "create_date", "title" => "Create Date", "type" => "static");
+$DB_fields[] = array("name" => "fname", "title" => "First Name", "type" => "text");
+$DB_fields[] = array("name" => "lname", "title" => "Last Name", "type" => "text");
 if (TABLE == 'customer') {
-    $DB_fields[] = array("name" => "add1",       "title" => "Address",       "type" => "text");
-    $DB_fields[] = array("name" => "add2",      "title" => "Address 2",     "type" => "text");
+    $DB_fields[] = array("name" => "add1", "title" => "Address", "type" => "text");
+    $DB_fields[] = array("name" => "add2", "title" => "Address 2", "type" => "text");
 } else {
-    $DB_fields[] = array("name" => "company",       "title" => "Company Name",  "type" => "text");
-    $DB_fields[] = array("name" => "address",       "title" => "Address",       "type" => "text");
-    $DB_fields[] = array("name" => "address2",      "title" => "Address 2",     "type" => "text");
+    $DB_fields[] = array("name" => "company", "title" => "Company Name", "type" => "text");
+    $DB_fields[] = array("name" => "address", "title" => "Address", "type" => "text");
+    $DB_fields[] = array("name" => "address2", "title" => "Address 2", "type" => "text");
 }
-$lodging = array(
-    '' => "Don't Care",
-    'Trout Creek Condominiums' => 'Trout Creek Condominiums',
+$lodging     = array(
+    ''                            => "Don't Care",
+    'Trout Creek Condominiums'    => 'Trout Creek Condominiums',
     'Hamlet Village Condominiums' => 'Hamlet Village Condominiums'
 );
-$DB_fields[] = array("name" => "city",          "title" => "City",          "type" => "text");
-$DB_fields[] = array("name" => "state",         "title" => "State",         "type" => "state");
-$DB_fields[] = array("name" => "zip",           "title" => "Zip",           "type" => "text");
-$DB_fields[] = array("name" => "phone",         "title" => "Phone",         "type" => "text");
-$DB_fields[] = array( 'name' => "alt_phone",       'title' => "Alternate Phone",   'type' => "text");
-$DB_fields[] = array("name" => "fax",           "title" => "Fax",           "type" => "text");
-$DB_fields[] = array("name" => "email",         "title" => "Email",         "type" => "text");
-$DB_fields[] = array("name" => "mail_ok",       "title" => "Mail Ok?",      "type" => "radio");
-//$DB_fields[] = array( 'name' => "arrival",         'title' => "Arrival",           'type' => "text");
-//$DB_fields[] = array( 'name' => "departure",       'title' => "Departure",         'type' => "text");
-//$DB_fields[] = array( 'name' => "golfers",         'title' => "Golfers",           'type' => "text");
-//$DB_fields[] = array( 'name' => "nongolfers",      'title' => "Non Golfers",       'type' => "text");
-//$DB_fields[] = array( 'name' => "pquote",          'title' => "From Price Quote",  'type' => "radio");
-//$DB_fields[] = array( 'name' => "lodging",         'title' => "Lodging",           'type' => "drop",   'drop' => $lodging);
-//$DB_fields[] = array( 'name' => "couples",         'title' => "Couples",           'type' => "text");
-//$DB_fields[] = array( 'name' => "singles",         'title' => "Singles",           'type' => "text");
-//$DB_fields[] = array( 'name' => "bathrooms",       'title' => "Bathrooms",         'type' => "text");
-//$DB_fields[] = array( 'name' => "rooms",           'title' => "Rooms",             'type' => "text");
-//$DB_fields[] = array( 'name' => "beds",            'title' => "Beds",              'type' => "text");
-//$DB_fields[] = array( 'name' => "twinok",          'title' => "Twin Ok",           'type' => "radio");
-//$DB_fields[] = array( 'name' => "sleepersofaok",   'title' => "Sleeper Sofa Ok",   'type' => "radio");
-$DB_fields[] = array( 'name' => "comments",        'title' => "Comments",          'type' => "textarea");
-$DB_fields[] = array( 'name' => "discover",        'title' => "Discover Big Fore", 'type' => "drop",   'drop' => $discover);
-
+$DB_fields[] = array("name" => "city", "title" => "City", "type" => "text");
+$DB_fields[] = array("name" => "state", "title" => "State", "type" => "state");
+$DB_fields[] = array("name" => "zip", "title" => "Zip", "type" => "text");
+$DB_fields[] = array("name" => "phone", "title" => "Phone", "type" => "text");
+$DB_fields[] = array('name' => "alt_phone", 'title' => "Alternate Phone", 'type' => "text");
+$DB_fields[] = array("name" => "fax", "title" => "Fax", "type" => "text");
+$DB_fields[] = array("name" => "email", "title" => "Email", "type" => "text");
+$DB_fields[] = array("name" => "mail_ok", "title" => "Mail Ok?", "type" => "radio");
+$DB_fields[] = array('name' => "comments", 'title' => "Comments", 'type' => "textarea");
+$DB_fields[] = array('name' => "discover", 'title' => "Discover Big Fore", 'type' => "drop", 'drop' => $discover);
+$DB_fields[] = array("name" => "contact_type", "title" => "Contact Type", "type" => "drop2", "drop" => $cType);
 // $fields are used for building the query page
-foreach ($DB_fields as $key=>$value) {
+foreach ($DB_fields as $key => $value) {
     if ($value['type'] == "text" || $value['type'] == "state") {
         $fields[$value['name']] = $value['title'];
-    } elseif ( $value['type'] == "radio") {
+    } elseif ($value['type'] == "radio") {
         $boolean[$value['name']] = $value['title'];
-    } elseif ( $value['type'] == "drop") {
+    } elseif ($value['type'] == "drop") {
         $dropdowns[$value['name']] = array('title' => $value['title'], 'drop' => $value['drop']);
+    } elseif ($value['type'] == "drop2") {
+        $dropdowns2[$value['name']] = array('title' => $value['title'], 'drop' => $value['drop']);
     }
 }
 
 $data['bailout'] .= "You are receiving this message because you have expressed an interest in ";
-$data['bailout'] .= "receiving specials and information from ".SITENAME.". If you do not ";
+$data['bailout'] .= "receiving specials and information from " . SITENAME . ". If you do not ";
 $data['bailout'] .= "wish to receive future items of this nature, please reply to this e-mail ";
 $data['bailout'] .= "with the word \"CANCEL\" on the subject line. You will then be removed ";
 $data['bailout'] .= "from future mailings.<br>";
-$data['bailout'] .= "<a href=\"mailto:".OWNER_EMAIL."?subject=CANCEL\">".OWNER_EMAIL."</a><br>";
+$data['bailout'] .= "<a href=\"mailto:" . OWNER_EMAIL . "?subject=CANCEL\">" . OWNER_EMAIL . "</a><br>";
 ?>
index 58924fa..92c5e7c 100755 (executable)
@@ -13,292 +13,327 @@ if (isset($_SESSION['sess_vars'])) {
     //session_unregister("sess_vars");
 }
 $qs = "SELECT   count(*) as total
-       FROM     ".TABLE;
+       FROM     " . TABLE;
 if (TABLE == CUSTOMER_TABLE) {
     $qs .= " WHERE (fname != '-Guest-' OR fname is null)";
 }
-$res = $DB->db_auto_get_data($qs);
+$res   = $DB->db_auto_get_data($qs);
 $total = $res[0]['total'];
-GLM_TOOLBOX::top("Contact Database","help/contact.phtml?key=search","SteveContactsDatabase_1.0");
-GLM_TOOLBOX::html_nav_table($nav,$navWidth);
+GLM_TOOLBOX::top("Contact Database", "help/contact.phtml?key=search",
+                 "SteveContactsDatabase_1.0");
+GLM_TOOLBOX::html_nav_table($nav, $navWidth);
 ?>
 <table id="admin-list-table">
-  <tr>
-    <td colspan=4>
-    There
-    <?php
-    if ($total < 1 ) {
-        echo " No records";
-    } elseif ($total > 1) {
-        echo "are $total contacts";
-    } else {
-        echo "is $total contact";
-    }
-    ?> in the database.
-    </td>
-  </tr>
-  <tr>
-    <th colspan=4 class="theader">
-    Search:
-    </th>
-  </tr>
-  <tr>
-    <td colspan=4>
-    <b>Search records for:</b><br>
-    </td>
-  </tr>
-  <tr>
-  <td colspan=4>
-  <form name="search" action="query_contact.phtml" method="POST" onSubmit="
-    var msg = '';
-    var errors = '';
-    var ping = 0;
-    var all = 0;
-    this.fvalue.value = '';
-    this.rfvalue.value = '';
-    this.rdvalue.value = '';
-
-    if(this.search.value == '') {
-        all++;
-    }
-
-    for(var i = 0;i<4;i++) {
-        if(this.search_type.options[i].selected){
-            ping++;
-        }
-    }
+    <tr>
+        <td colspan=4>
+            There
+            <?php
+            if ($total < 1) {
+                echo " No records";
+            } elseif ($total > 1) {
+                echo "are $total contacts";
+            } else {
+                echo "is $total contact";
+            }
+            ?> in the database.
+        </td>
+    </tr>
+    <tr>
+        <th colspan=4 class="theader">
+            Search:
+        </th>
+    </tr>
+    <tr>
+        <td colspan=4>
+            <b>Search records for:</b><br>
+        </td>
+    </tr>
+    <tr>
+        <td colspan=4>
+            <form name="search" action="query_contact.phtml" method="POST" onSubmit="
+                    var msg = '';
+                    var errors = '';
+                    var ping = 0;
+                    var all = 0;
+                    this.fvalue.value = '';
+                    this.rfvalue.value = '';
+                    this.rdvalue.value = '';
 
-    if(all == 0) {
-        if(ping == 0) {
-            errors += '-You must select a search type\n';
-        }
-    }
+                    if (this.search.value == '') {
+                        all++;
+                    }
 
-    for(var i=0;i<<?php echo count($fields)?>;i++) {
-        if(this.ifields.options[i].selected) {
-            this.fvalue.value += ':' + this.ifields.options[i].value;
-        }
-    }
+                    for (var i = 0; i < 4; i++) {
+                        if (this.search_type.options[i].selected) {
+                            ping++;
+                        }
+                    }
 
-    for(var i=0;i<<?php echo count($fields)?>;i++) {
-        if(this.return_fields.options[i].selected) {
-            this.rfvalue.value += ':' + this.return_fields.options[i].value;
-        }
-    }
+                    if (all == 0) {
+                        if (ping == 0) {
+                            errors += '-You must select a search type\n';
+                        }
+                    }
 
-    for(var i=0;i<1;i++) {
-        if(this.dates.options[i].selected) {
-            this.rdvalue.value += ':' + this.dates.options[i].value;
-        }
-    }
+                    for (var i = 0; i <<?php echo count($fields) ?>; i++) {
+                        if (this.ifields.options[i].selected) {
+                            this.fvalue.value += ':' + this.ifields.options[i].value;
+                        }
+                    }
 
-    if(all == 0) {
-        if(this.fvalue.value == '') {
-            errors += '-You must select at least one field to search in\n';
-        }
-    }
+                    for (var i = 0; i <<?php echo count($fields) ?>; i++) {
+                        if (this.return_fields.options[i].selected) {
+                            this.rfvalue.value += ':' + this.return_fields.options[i].value;
+                        }
+                    }
 
-     if(this.rfvalue.value == '') {
-        errors += '-You must select at least one field for output\n';
-    }
+                    for (var i = 0; i < 1; i++) {
+                        if (this.dates.options[i].selected) {
+                            this.rdvalue.value += ':' + this.dates.options[i].value;
+                        }
+                    }
 
-    if(all == 1) {
-        if(errors == '') {
-            return(true);
-        }
-    }
+                    if (all == 0) {
+                        if (this.fvalue.value == '') {
+                            errors += '-You must select at least one field to search in\n';
+                        }
+                    }
 
-    if(errors == '') {
-        return(true);
-    } else {
-        msg += '_______________________________________\n\n';
-        msg += 'The form was not submitted please check\n';
-        msg += 'the following and resubmit\n\n';
-        msg += errors + '\n\n';
-        msg += '_______________________________________\n\n';
+                    if (this.rfvalue.value == '') {
+                        errors += '-You must select at least one field for output\n';
+                    }
 
-        alert(msg);
-        return(false);
-    }
-  ">
-  <input name="search" value="<?php echo stripslashes($search)?>" size=40>
-  <input type="submit" name="Submit Query">
-  </td>
-  </tr>
-  <tr>
-    <th colspan=4 class="theader">
-    Search Dates Ranges
-    </th>
-  </tr>
-  <tr>
-      <td align="left" colspan=4 nowrap>
-          <div style="float:left;width:240px;height:35px;">Created From:<br> <?php echo $c_date_from?></div>
-          <div style="float:left;width:240px;height:35px;">Created To:<br> <?php echo $c_date_to?></div>
-      </td>
-  </tr>
-  <tr>
-    <td class="small" valign=top>
-    <b>In Fields:</b><br>
-    <select name="ifields" multiple size=8>
-    <?php foreach($fields as $key2=>$value2) {?>
-    <option value="<?php echo $key2?>" <?php echo (strstr($fvalue,$key2))?"selected":""?>><?php echo $value2?>
-    <?php }?>
-    </select>
-    </td>
-    <td valign=top class="small" nowrap>
-      <b>Search Where:</b><br>
-      <select name="alter">
-      <option value="0" <?php echo ($alter=="0")?"selected":""?>>Anywhere
-      <option value="1" <?php echo ($alter=="1")?"selected":""?>>Begining
-      <option value="2" <?php echo ($alter=="2")?"selected":""?>>Ending
-      </select><br>
-    <input type="hidden" name="fvalue">
-    <?php
-    if (is_array($boolean)) {
-        foreach ($boolean as $bool_key => $bool_val) {
-            echo '<br>
-                <b>'.$bool_val.'</b><br>';
-            echo search_bool($bool_key, ${$bool_key});
-        }
-    }
-    if (is_array($dropdowns)) {
-        foreach ($dropdowns as $drop_key => $drop_row) {
-            echo '<br>
-                <b>'.$drop_row['title'].'</b>';
-            echo '<br>';
-            if( is_array( $drop_row['drop'] ) ) {
-                echo GLM_TOOLBOX::build_picklist( $drop_key.'[]', $drop_row['drop'], $_REQUEST[$drop_key], '', 0, null, 5 );
-            }
-        }
-    }
-    echo '</td><td valign=top width=25%>';
-?>
-    <br><b>Search Type:</b><br>
-  <select name="search_type" size=4>
-  <option value="1" <?php echo (!isset($search_type) || $search_type=="1")?"selected":""?>>Exact string
-  <option value="2" <?php echo ($search_type=="2")?"selected":""?>>And
-  <option value="3" <?php echo ($search_type=="3")?"selected":""?>>Or
-  <option value="4" <?php echo ($search_type=="4")?"selected":""?>>Not
-  </select>
-    </td>
-      <td valign=top class=small width=25%>
-      <b>Case Sensitivity:</b><br>
-      <select name="case">
-      <option value="ON" <?php echo ($case == "ON")?"selected":""?>>On
-      <option value="OFF" <?php echo (!isset($case) || $case == "OFF")?"selected":""?>>Off
-      </select><br>
-      </td>
-      </tr>
-      <tr>
-      <td colspan="4"> &nbsp;
-<?php
-    $sql = "
-      SELECT contact_inq.*, inq_group.name as group
-        FROM contact_inq
-             LEFT OUTER JOIN inq_group
-               ON (contact_inq.groupid = inq_group.id)
-       WHERE inq_group.id != 6
-    ORDER BY groupid, pos";
+                    if (all == 1) {
+                        if (errors == '') {
+                            return(true);
+                        }
+                    }
 
-    $interests = array();
-    $intData = $DB->db_auto_get_data($sql);
-    foreach ($intData as $row) {
-        $interests[$row['group']][$row['id']] = $row['header'];
-    }
+                    if (errors == '') {
+                        return(true);
+                    } else {
+                        msg += '_______________________________________\n\n';
+                        msg += 'The form was not submitted please check\n';
+                        msg += 'the following and resubmit\n\n';
+                        msg += errors + '\n\n';
+                        msg += '_______________________________________\n\n';
 
-    foreach ($interests as $i => $j) {
-        echo '<fieldset>';
-        echo '<legend>';
-        echo $i;
-        echo '</legend>';
-        foreach ($j as $k => $v) {
-            echo '<label class="glmCheckBox">';
-            echo '<input type="checkbox" name="cols[]" value="'.$k.'" ';
-            if (   is_array($cols)
-                && in_array($data['id'], $cols)) {
-                echo " checked";
-            }
-            echo '>';
-            echo $v;
-            echo '</label>';
+                        alert(msg);
+                        return(false);
                     }
-        echo '</fieldset>';
-    }
-?>
-      </td>
-    </tr>
-  <tr>
-    <th colspan=4>
-    Output of records:
-    </th>
-  </tr>
-  <tr>
-    <td class="small" valign=top>
-    <b>Output Fields:</b><br>
-    <select name="return_fields" multiple size=8>
-    <?php foreach($fields as $key2=>$value2) {?>
-    <option value="<?php echo $key2?>" <?php echo (strstr($rfvalue,$key2))?"selected":""?>><?php echo $value2?>
-    <?php }?>
-    </select>
-    <br>
-    <input type="hidden" name="rfvalue">
-    <label for="out-all"><input type="radio" id="out-all" name="a" onClick="
-    for(var i=0;i<<?php echo count($fields)?>;i++) {
-        this.form.return_fields.options[i].selected=1;
-    }
-    for(var i=0;i<<?php echo ($p_date_from)?"3":"1";?>;i++) {
-        this.form.dates.options[i].selected=1;
-    }
-    ">All</label>
-    <label for="out-none"><input id="out-none" type="radio" name="a" onClick="
-    for(var i=0;i<<?php echo count($fields)?>;i++) {
-        this.form.return_fields.options[i].selected=0;
-    }
-    for(var i=0;i<<?php echo ($p_date_from)?"3":"1";?>;i++) {
-        this.form.dates.options[i].selected=0;
-    }
-    ">None</label>
-  </td>
-  <td class="small" valign=top>
-    <input type="hidden" name="rdvalue" value="">
-    <b>Output fields (Dates):</b>
-    <select name="dates" multiple size=3>
-    <option value="create_date" <?php echo (strstr($dates,"create_date"))?"selected":""?>>Created Date
-    <?php if($p_date_from)
-    {?>
-  <option value="purch_date" <?php echo (strstr($dates,"purch_date"))?"selected":""?>>Last Purchase Date
-  <?php }
-  if($a_date_from)
-  {?>
-  <option value="access_date" <?php echo (strstr($dates,"access_date"))?"selected":""?>>Last Access Date
-  <?php }?>
-    </select>
-  </td>
-  <td class="small" valign=top width=25%>
-  <b>File output:</b><br>
-  <select name="file" size=4>
-  <option value="" <?php echo (!isset($file) || $file == "")?"selected":""?>>No File
-  <option value="zip" <?php echo ($file=="zip")?"selected":""?>>zip file
-  <option value="gz" <?php echo ($file=="gz")?"selected":""?>>tar.gz(tar ball)
-  <option value="rpt" <?php echo ($file=="rpt")?"selected":""?>>text file
-  </select>
-  </td>
-  <td valign=top class=small width=25%>
-  <b>Delimiter:</b><br>
-  <select name="delimiter" size=4>
-  <option value="tab" <?php echo ($delimiter=="tab")?"selected":""?>>TAB
-  <option value="comma" <?php echo ($delimiter=="comma")?"selected":""?>>Comma
-  <option value="csv" <?php echo ($delimiter=="csv")?"selected":""?>>CSV
-  <option value="pipe" <?php echo ($delimiter=="pipe")?"selected":""?>>Pipe
-  </select>
-  </td>
-  </tr>
-  <tr>
-    <td colspan="4" align="center">
-    <input type="submit" name="Submit Query">
-    </td>
-  </tr>
-  </table>
+                  ">
+                <input name="search" value="<?php echo stripslashes($search) ?>" size=40>
+                <input type="submit" name="Submit Query">
+                </td>
+                </tr>
+                <tr>
+                    <th colspan=4 class="theader">
+                        Search Dates Ranges
+                    </th>
+                </tr>
+                <tr>
+                    <td align="left" colspan=4 nowrap>
+                        <div style="float:left;width:240px;height:35px;">Created From:<br> <?php echo $c_date_from ?></div>
+                        <div style="float:left;width:240px;height:35px;">Created To:<br> <?php echo $c_date_to ?></div>
+                    </td>
+                </tr>
+                <tr>
+                    <td class="small" valign=top>
+                        <b>In Fields:</b><br>
+                        <select name="ifields" multiple size=8>
+                                <?php foreach ($fields as $key2 => $value2) { ?>
+                                <option value="<?php echo $key2 ?>" <?php echo (strstr($fvalue,
+                                                                                    $key2))
+                                    ? "selected"
+                                    : "" ?>><?php echo $value2 ?>
+<?php } ?>
+                        </select>
+                    </td>
+                    <td valign=top class="small" nowrap>
+                        <b>Search Where:</b><br>
+                        <select name="alter">
+                            <option value="0" <?php echo ($alter == "0")
+    ? "selected"
+    : "" ?>>Anywhere
+                            <option value="1" <?php echo ($alter == "1")
+                            ? "selected"
+                            : "" ?>>Begining
+                            <option value="2" <?php echo ($alter == "2")
+                            ? "selected"
+                            : "" ?>>Ending
+                        </select><br>
+                        <input type="hidden" name="fvalue">
+                        <?php
+                        if (is_array($boolean)) {
+                            foreach ($boolean as $bool_key => $bool_val) {
+                                echo '<br>
+                <b>' . $bool_val . '</b><br>';
+                                echo search_bool($bool_key, ${$bool_key});
+                            }
+                        }
+                        if (is_array($dropdowns)) {
+                            foreach ($dropdowns as $drop_key => $drop_row) {
+                                echo '<br>
+                <b>' . $drop_row['title'] . '</b>';
+                                echo '<br>';
+                                if (is_array($drop_row['drop'])) {
+                                    echo GLM_TOOLBOX::build_picklist($drop_key . '[]',
+                                                                     $drop_row['drop'],
+                                                                     $_REQUEST[$drop_key],
+                                                                     '', 0,
+                                                                     null, 5);
+                                }
+                            }
+                        }
+                        if (is_array($dropdowns2)) {
+                            foreach ($dropdowns2 as $drop_key => $drop_row) {
+                                echo '<br>
+                <b>' . $drop_row['title'] . '</b>';
+                                echo '<br>';
+                                if (is_array($drop_row['drop'])) {
+                                    echo GLM_TOOLBOX::build_picklist($drop_key . '[]',
+                                                                     $drop_row['drop'],
+                                                                     ${$drop_key},
+                                                                     'multiple',
+                                                                     0, null, 5);
+                                }
+                            }
+                        }
+                        echo '</td><td valign=top width=25%>';
+                        ?>
+                        <br><b>Search Type:</b><br>
+                        <select name="search_type" size=4>
+                            <option value="1" <?php echo (!isset($search_type) || $search_type == "1")
+                            ? "selected"
+                            : "" ?>>Exact string
+                            <option value="2" <?php echo ($search_type == "2")
+                            ? "selected"
+                            : "" ?>>And
+                            <option value="3" <?php echo ($search_type == "3")
+                                ? "selected"
+                                : "" ?>>Or
+                            <option value="4" <?php echo ($search_type == "4")
+                                ? "selected"
+                                : "" ?>>Not
+                        </select>
+                    </td>
+                    <td valign=top class=small width=25%>
+                        <b>Case Sensitivity:</b><br>
+                        <select name="case">
+                            <option value="ON" <?php echo ($case == "ON")
+                                ? "selected"
+                                : "" ?>>On
+                            <option value="OFF" <?php echo (!isset($case) || $case == "OFF")
+                                ? "selected"
+                                : "" ?>>Off
+                        </select><br>
+                    </td>
+                </tr>
+                <tr>
+                    <th colspan=4>
+                        Output of records:
+                    </th>
+                </tr>
+                <tr>
+                    <td class="small" valign=top>
+                        <b>Output Fields:</b><br>
+                        <select name="return_fields" multiple size=8>
+                                <?php foreach ($fields as $key2 => $value2) { ?>
+                                <option value="<?php echo $key2 ?>" <?php echo (strstr($rfvalue,
+                                                                                    $key2))
+                                    ? "selected"
+                                    : "" ?>><?php echo $value2 ?>
+                                <?php } ?>
+                        </select>
+                        <br>
+                        <input type="hidden" name="rfvalue">
+                        <label for="out-all"><input type="radio" id="out-all" name="a" onClick="
+                                for (var i = 0; i <<?php echo count($fields) ?>; i++) {
+                                    this.form.return_fields.options[i].selected = 1;
+                                }
+                                for (var i = 0; i <<?php echo ($p_date_from)
+                                    ? "3"
+                                    : "1"; ?>; i++) {
+                                    this.form.dates.options[i].selected = 1;
+                                }
+                                                    ">All</label>
+                        <label for="out-none"><input id="out-none" type="radio" name="a" onClick="
+                                for (var i = 0; i <<?php echo count($fields) ?>; i++) {
+                                    this.form.return_fields.options[i].selected = 0;
+                                }
+                                for (var i = 0; i <<?php echo ($p_date_from)
+                                    ? "3"
+                                    : "1"; ?>; i++) {
+                                    this.form.dates.options[i].selected = 0;
+                                }
+                                                     ">None</label>
+                    </td>
+                    <td class="small" valign=top>
+                        <input type="hidden" name="rdvalue" value="">
+                        <b>Output fields (Dates):</b>
+                        <select name="dates" multiple size=3>
+                            <option value="create_date" <?php echo (strstr($dates,
+                                                                            "create_date"))
+                                    ? "selected"
+                                    : "" ?>>Created Date
+<?php if ($p_date_from) {
+    ?>
+                                <option value="purch_date" <?php echo (strstr($dates,
+                                                                           "purch_date"))
+        ? "selected"
+        : "" ?>>Last Purchase Date
+<?php
+}
+if ($a_date_from) {
+    ?>
+                                <option value="access_date" <?php echo (strstr($dates,
+                                                                            "access_date"))
+        ? "selected"
+        : "" ?>>Last Access Date
+<?php } ?>
+                        </select>
+                    </td>
+                    <td class="small" valign=top width=25%>
+                        <b>File output:</b><br>
+                        <select name="file" size=4>
+                            <option value="" <?php echo (!isset($file) || $file == "")
+    ? "selected"
+    : "" ?>>No File
+                            <option value="zip" <?php echo ($file == "zip")
+    ? "selected"
+    : "" ?>>zip file
+                            <option value="gz" <?php echo ($file == "gz")
+    ? "selected"
+    : "" ?>>tar.gz(tar ball)
+                            <option value="rpt" <?php echo ($file == "rpt")
+    ? "selected"
+    : "" ?>>text file
+                        </select>
+                    </td>
+                    <td valign=top class=small width=25%>
+                        <b>Delimiter:</b><br>
+                        <select name="delimiter" size=4>
+                            <option value="tab" <?php echo ($delimiter == "tab")
+    ? "selected"
+    : "" ?>>TAB
+                            <option value="comma" <?php echo ($delimiter == "comma")
+    ? "selected"
+    : "" ?>>Comma
+                            <option value="csv" <?php echo ($delimiter == "csv")
+    ? "selected"
+    : "" ?>>CSV
+                            <option value="pipe" <?php echo ($delimiter == "pipe")
+    ? "selected"
+    : "" ?>>Pipe
+                        </select>
+                    </td>
+                </tr>
+                <tr>
+                    <td colspan="4" align="center">
+                        <input type="submit" name="Submit Query">
+                    </td>
+                </tr>
+</table>
 <?php
 GLM_TOOLBOX::footer();
 ?>
index 66b1a75..7413efc 100755 (executable)
@@ -4,29 +4,32 @@ require_once '../../setup.phtml';
 require_once 'contact_setup.inc';
 /* Includes  */
 extract($_REQUEST);
-function clean_array(&$array){
-    if (is_array($array)){
+
+function clean_array(&$array)
+{
+    if (is_array($array)) {
         $counter = 0;
-        foreach ($array as $key=>$value){
-            if ($value == ""){
+        foreach ($array as $key => $value) {
+            if ($value == "") {
                 unset($array[$counter]);
             }
             $counter++;
         }
     }
 }
-$sess_vars = $_POST;
+
+$sess_vars             = $_POST;
 $_SESSION['sess_vars'] = $sess_vars;
-$query_no = filter_var($_REQUEST['query_no'], FILTER_VALIDATE_INT);
+$query_no              = filter_var($_REQUEST['query_no'], FILTER_VALIDATE_INT);
 if (!$query_no) {
     /* The fields array is sent as a string
-        explode it out using : as delimiter */
-    $fvalue = preg_replace("/^:/","",$fvalue);
-    $fields = explode(":",$fvalue);
-    $rfvalue = preg_replace("/^:/","",$rfvalue);
-    $return_fields = explode(":",$rfvalue);
-    $dates = preg_replace("/^:/","",$rdvalue);
-    $dates = explode(":",$dates);
+      explode it out using : as delimiter */
+    $fvalue        = preg_replace("/^:/", "", $fvalue);
+    $fields        = explode(":", $fvalue);
+    $rfvalue       = preg_replace("/^:/", "", $rfvalue);
+    $return_fields = explode(":", $rfvalue);
+    $dates         = preg_replace("/^:/", "", $rdvalue);
+    $dates         = explode(":", $dates);
 
     clean_array($return_fields);
     clean_array($dates);
@@ -36,78 +39,79 @@ if (!$query_no) {
     /* Chop off whitespaces spaces */
     $search = chop(trim($search));
     $search = preg_replace("/\\\|\"/", "", $search);
-    if (!$search && (count ($fields) == 1 && $fields[0] == '')) {
+    if (!$search && (count($fields) == 1 && $fields[0] == '')) {
         $ALL = TRUE;
     }
 
-    function getKeywords($keywords) {
+    function getKeywords($keywords)
+    {
         /* Replace the whitespace with a , */
-        $keywords = str_replace(" ",",",$keywords);
-        $keywords = str_replace(",,",",",$keywords);
-        $seperated = explode(",",$keywords);
+        $keywords  = str_replace(" ", ",", $keywords);
+        $keywords  = str_replace(",,", ",", $keywords);
+        $seperated = explode(",", $keywords);
         /* Return exploded string */
         return $seperated;
     }
 
-    switch($search_type) {
-    case "1":
-        $keywords = $search;
-        $compare = "OR";
-        break;
+    switch ($search_type) {
+        case "1":
+            $keywords = $search;
+            $compare  = "OR";
+            break;
 
-    case "2":
-        $keywords = getKeywords($search);
-        $compare = "AND";
-        break;
+        case "2":
+            $keywords = getKeywords($search);
+            $compare  = "AND";
+            break;
 
-    case "3":
-        $keywords = getKeywords($search);
-        $compare = "OR";
-        break;
+        case "3":
+            $keywords = getKeywords($search);
+            $compare  = "OR";
+            break;
 
-    case "4":
-        $keywords = getKeywords($search);
-        $compare = "AND";
-        $NOT = TRUE;
-        break;
+        case "4":
+            $keywords = getKeywords($search);
+            $compare  = "AND";
+            $NOT      = TRUE;
+            break;
 
-    default:
-        echo "not valid";
-        break;
+        default:
+            echo "not valid";
+            break;
     }
 
     if (is_array($keywords)) {
-        for ($rip=0;$rip<count($keywords);$rip++) {
+        for ($rip = 0; $rip < count($keywords); $rip++) {
             $keywords[$rip] = trim($keywords[$rip]);
             /* if * is at the begging the replace with .* */
-            $keywords[$rip] = preg_replace("/[\x2a]/",".*",$keywords[$rip]);
-            $keywords[$rip] = preg_replace("/[\x3f]/",".?",$keywords[$rip]);
-            $keywords[$rip] = preg_replace("/[\x2b]/",".+",$keywords[$rip]);
+            $keywords[$rip] = preg_replace("/[\x2a]/", ".*", $keywords[$rip]);
+            $keywords[$rip] = preg_replace("/[\x3f]/", ".?", $keywords[$rip]);
+            $keywords[$rip] = preg_replace("/[\x2b]/", ".+", $keywords[$rip]);
         }
     } else {
         $keywords = trim($keywords);
         /* if * is at the begging the replace with .* */
-        $keywords = preg_replace("/[\x2a]/",".*",$keywords);
-        $keywords = preg_replace("/[\x3f]/",".?",$keywords);
-        $keywords = preg_replace("/[\x2b]/",".+",$keywords);
+        $keywords = preg_replace("/[\x2a]/", ".*", $keywords);
+        $keywords = preg_replace("/[\x3f]/", ".?", $keywords);
+        $keywords = preg_replace("/[\x2b]/", ".+", $keywords);
     }
 
-    switch($alter) {
-    /* $alter defines where to look in fields */
-    case "1":
-        $begin = "^";
-        $end = "";
-        break;
+    switch ($alter) {
+        /* $alter defines where to look in fields */
+        case "1":
+            $begin = "^";
+            $end   = "";
+            break;
 
-    case "2":
-        $begin = "";
-        $end = " *$";
-        break;
+        case "2":
+            $begin = "";
+            $end   = " *$";
+            break;
 
-    default:
-        $begin = "";
-        $end = "";
-        break;
+        default:
+            $begin = "";
+            $end   = "";
+            break;
     }
 
     $operator = " ";
@@ -119,15 +123,15 @@ if (!$query_no) {
     if ($case == "OFF") {
         $operator .= "*";
     }
-    if ($search == "" && ! (count ($fields)  == 1 && $fields[0] == '') )  {
+    if ($search == "" && !(count($fields) == 1 && $fields[0] == '')) {
         $operator = "=";
     }
     $operator .= " ";
 
     /* finally, build the query string from string or array $keywords */
-    $query_string = "SELECT ".ID.",";
-    $totali = count($return_fields)-1;
-    for ($i=0;$i<count($return_fields);$i++) {
+    $query_string = "SELECT " . ID . ",";
+    $totali       = count($return_fields) - 1;
+    for ($i = 0; $i < count($return_fields); $i++) {
         $query_string .= $return_fields[$i];
         if ($i != $totali) {
             $query_string .= ",";
@@ -136,8 +140,8 @@ if (!$query_no) {
             $query_string .= "\n";
         }
     }
-    $totald = count($dates)-1;
-    for ($i=0;$i<count($dates);$i++) {
+    $totald = count($dates) - 1;
+    for ($i = 0; $i < count($dates); $i++) {
         if ($dates[$i] != " " && $dates[$i] != "") {
             if ($i == 0) {
                 $query_string .= ",";
@@ -149,22 +153,22 @@ if (!$query_no) {
         }
     }
     if (!$ALL) {
-        $query_string .= "\nFROM\t".TABLE." \nWHERE\t".WHERE."\nAND\t";
+        $query_string .= "\nFROM\t" . TABLE . " \nWHERE\t" . WHERE . "\nAND\t";
         $query_string .= "(";
-        for ($b=0;$b<count($fields);$b++) {
-            $totalb = count($fields)-1;
+        for ($b = 0; $b < count($fields); $b++) {
+            $totalb = count($fields) - 1;
             if (is_array($keywords)) {
-                for ($c=0;$c<count($keywords);$c++) {
-                    $totalc = count($keywords)-1;
-                    $query_string .= $fields[$b].$operator."'".
-                        $begin.$keywords[$c].$end."'";
+                for ($c = 0; $c < count($keywords); $c++) {
+                    $totalc = count($keywords) - 1;
+                    $query_string .= $fields[$b] . $operator . "'" .
+                        $begin . $keywords[$c] . $end . "'";
                     if ($c != $totalc) {
                         $query_string .= " \n$compare\t";
                     }
                 }
             } else {
-                $query_string .= $fields[$b].$operator."'".
-                    $begin.$keywords.$end."'";
+                $query_string .= $fields[$b] . $operator . "'" .
+                    $begin . $keywords . $end . "'";
             }
             if ($b != $totalb) {
                 $query_string .= " \n$compare\t";
@@ -172,9 +176,9 @@ if (!$query_no) {
         }
         $query_string .= ")";
     } else {
-        $query_string .= "\nFROM\t".TABLE." \nWHERE\t".WHERE."\n";
+        $query_string .= "\nFROM\t" . TABLE . " \nWHERE\t" . WHERE . "\n";
     }
-    if (is_array ($boolean) ) {
+    if (is_array($boolean)) {
         foreach ($boolean as $bool_key => $bool_val) {
             if ($_POST[$bool_key] == "1") {
                 $bstring[] = " $bool_key = 't'";
@@ -183,77 +187,95 @@ if (!$query_no) {
             }
         }
         if (is_array($bstring)) {
-            $query_string .= ' and ('.implode(" $compare ",$bstring) .')  ';
+            $query_string .= ' and (' . implode(" $compare ", $bstring) . ')  ';
+        }
+    }
+    if (is_array($dropdowns)) {
+        foreach ($dropdowns as $drop_key => $drop_val) {
+            if (is_array($_POST[$drop_key])) {
+                foreach ($_POST[$drop_key] as $mdrop_key => $mdrop_val) {
+                    if ($mdrop_val != '') {
+                        $dstring[] = " $drop_key $operator '" . $mdrop_val . "'";
+                    }
+                }
+            } elseif (!is_array($_POST[$drop_key])) {
+                if ($_POST[$drop_key] != '') {
+                    $dstring[] = " $drop_key = '" . $_POST[$drop_key] . "'";
+                }
+            }
+        }
+        if (is_array($dstring)) {
+            $query_string .= ' and (' . implode(" $compare ", $dstring) . ' ) ';
         }
     }
-    if( is_array( $dropdowns ) ) {
-        foreach( $dropdowns as $drop_key => $drop_val ) {
-            if( is_array( $_POST[$drop_key] ) ) {
-                foreach( $_POST[$drop_key] as $mdrop_key => $mdrop_val ){
-                    if( $mdrop_val != '' ){
-                        $dstring[] = " $drop_key $operator ':".$mdrop_val.":'";
+    if (is_array($dropdowns2)) {
+        foreach ($dropdowns2 as $drop_key => $drop_val) {
+            if (is_array($_POST[$drop_key])) {
+                foreach ($_POST[$drop_key] as $mdrop_key => $mdrop_val) {
+                    if ($mdrop_val != '') {
+                        $dstring[] = " $drop_key $operator '" . $mdrop_val . "'";
                     }
                 }
-            }elseif( !is_array( $_POST[$drop_key] ) ) {
-                if( $_POST[$drop_key] != '' ){
-                    $dstring[] = " $drop_key = '".$_POST[$drop_key]."'";
+            } elseif (!is_array($_POST[$drop_key])) {
+                if ($_POST[$drop_key] != '') {
+                    $dstring[] = " $drop_key = '" . $_POST[$drop_key] . "'";
                 }
             }
         }
-        if( is_array($dstring) ) {
-            $query_string .= ' and ('.implode(" $compare ",$dstring).' ) ';
+        if (is_array($dstring)) {
+            $query_string .= ' and (' . implode(" $compare ", $dstring) . ' ) ';
         }
     }
-    if (is_array ($cols) ) {
+    if (is_array($cols)) {
         foreach ($cols as $ikey => $ival) {
             $cstring[] = " interest $operator ':$ival:'";
         }
         if (is_array($cstring)) {
-            $query_string .= ' and ('.implode(" $compare ",$cstring).')  ';
+            $query_string .= ' and (' . implode(" $compare ", $cstring) . ')  ';
         }
     }
     if (isset($fp_month)) {
-        $fp_str = mktime(0,0,0,$fp_month,$fp_day,$fp_year);
-        $tp_str = mktime(0,0,0,$tp_month,$tp_day,$tp_year);
-        $fa_str = mktime(0,0,0,$fa_month,$fa_day,$fa_year);
-        $ta_str = mktime(0,0,0,$ta_month,$ta_day,$ta_year);
+        $fp_str = mktime(0, 0, 0, $fp_month, $fp_day, $fp_year);
+        $tp_str = mktime(0, 0, 0, $tp_month, $tp_day, $tp_year);
+        $fa_str = mktime(0, 0, 0, $fa_month, $fa_day, $fa_year);
+        $ta_str = mktime(0, 0, 0, $ta_month, $ta_day, $ta_year);
 
-        if ($fp_str<$tp_str) {
-            $fp_date = $fp_month."/".$fp_day."/".$fp_year;
-            $tp_date = $tp_month."/".$tp_day."/".$tp_year;
+        if ($fp_str < $tp_str) {
+            $fp_date = $fp_month . "/" . $fp_day . "/" . $fp_year;
+            $tp_date = $tp_month . "/" . $tp_day . "/" . $tp_year;
             $query_string .= " AND purch_date >= '$fp_date'
                                AND purch_date <= '$tp_date'";
         }
-        if ($fa_str<$ta_str) {
-            $fa_date = $fa_month."/".$fa_day."/".$fa_year;
-            $ta_date = $ta_month."/".$ta_day."/".$ta_year;
+        if ($fa_str < $ta_str) {
+            $fa_date = $fa_month . "/" . $fa_day . "/" . $fa_year;
+            $ta_date = $ta_month . "/" . $ta_day . "/" . $ta_year;
             $query_string .= " AND access_date >= '$fa_date'
                                AND access_date <= '$ta_date'";
         }
-        if ($fp_str>$tp_str) {
-            $fp_date = $fp_month."/".$fp_day."/".$fp_year;
-            $tp_date = $tp_month."/".$tp_day."/".$tp_year;
+        if ($fp_str > $tp_str) {
+            $fp_date = $fp_month . "/" . $fp_day . "/" . $fp_year;
+            $tp_date = $tp_month . "/" . $tp_day . "/" . $tp_year;
             $query_string .= " AND purch_date <= '$tp_date'";
         }
-        if ($fa_str>$ta_str) {
-            $fa_date = $fa_month."/".$fa_day."/".$fa_year;
-            $ta_date = $ta_month."/".$ta_day."/".$ta_year;
+        if ($fa_str > $ta_str) {
+            $fa_date = $fa_month . "/" . $fa_day . "/" . $fa_year;
+            $ta_date = $ta_month . "/" . $ta_day . "/" . $ta_year;
             $query_string .= " AND access_date <= '$ta_date'";
         }
     }
     if (isset($fc_month)) {
-        $fc_str = mktime(0,0,0,$fc_month,$fc_day,$fc_year);
-        $tc_str = mktime(0,0,0,$tc_month,$tc_day,$tc_year);
+        $fc_str = mktime(0, 0, 0, $fc_month, $fc_day, $fc_year);
+        $tc_str = mktime(0, 0, 0, $tc_month, $tc_day, $tc_year);
 
-        if ($fc_str<$tc_str) {
-            $fc_date = $fc_month."/".$fc_day."/".$fc_year;
-            $tc_date = $tc_month."/".$tc_day."/".$tc_year;
+        if ($fc_str < $tc_str) {
+            $fc_date = $fc_month . "/" . $fc_day . "/" . $fc_year;
+            $tc_date = $tc_month . "/" . $tc_day . "/" . $tc_year;
             $query_string .= " AND create_date >= '$fc_date'
                                AND create_date <= '$tc_date'";
         }
-        if ($fc_str>$tc_str) {
-            $fc_date = $fc_month."/".$fc_day."/".$fc_year;
-            $tc_date = $tc_month."/".$tc_day."/".$tc_year;
+        if ($fc_str > $tc_str) {
+            $fc_date = $fc_month . "/" . $fc_day . "/" . $fc_year;
+            $tc_date = $tc_month . "/" . $tc_day . "/" . $tc_year;
             $query_string .= " AND create_date <= '$tc_date'";
         }
     }
@@ -272,25 +294,25 @@ if (!$query_no) {
     //exit;
 }
 /* Thought the customer would like to see what's in the query */
-$showq = str_replace("SELECT","Return\n",$query_string);
-$showq = str_replace ("\nFROM\t".TABLE." \nWHERE\t".WHERE."\nAND\t",
-" \nfrom the contact database \nwhere ",$showq);
-$showq = str_replace ("\nFROM\t".TABLE." \nWHERE\t".WHERE."\n",
-" \nfrom the contact database",$showq);
-$showq = str_replace("fname","first name",$showq);
-$showq = str_replace("cust_id,","",$showq);
-$showq = str_replace("lname","last name",$showq);
-$showq = str_replace("!~*","does not contain",$showq);
-$showq = str_replace("!~","does not contain",$showq);
-$showq = str_replace("~*","contains",$showq);
-$showq = str_replace("~","is in",$showq);
-$showq = str_replace("does not contain '^"," does not start with ",$showq);
-$showq = str_replace("contains '^"," starts with ",$showq);
-$showq = str_replace("is in '^"," starts with ",$showq);
-$showq = str_replace("$"," in the ending ",$showq);
-$showq = str_replace("OR","or",$showq);
-$showq = str_replace("AND","and",$showq);
-$showq = str_replace("'","",$showq);
+$showq = str_replace("SELECT", "Return\n", $query_string);
+$showq = str_replace("\nFROM\t" . TABLE . " \nWHERE\t" . WHERE . "\nAND\t",
+                     " \nfrom the contact database \nwhere ", $showq);
+$showq = str_replace("\nFROM\t" . TABLE . " \nWHERE\t" . WHERE . "\n",
+                     " \nfrom the contact database", $showq);
+$showq = str_replace("fname", "first name", $showq);
+$showq = str_replace("cust_id,", "", $showq);
+$showq = str_replace("lname", "last name", $showq);
+$showq = str_replace("!~*", "does not contain", $showq);
+$showq = str_replace("!~", "does not contain", $showq);
+$showq = str_replace("~*", "contains", $showq);
+$showq = str_replace("~", "is in", $showq);
+$showq = str_replace("does not contain '^", " does not start with ", $showq);
+$showq = str_replace("contains '^", " starts with ", $showq);
+$showq = str_replace("is in '^", " starts with ", $showq);
+$showq = str_replace("$", " in the ending ", $showq);
+$showq = str_replace("OR", "or", $showq);
+$showq = str_replace("AND", "and", $showq);
+$showq = str_replace("'", "", $showq);
 if (!$ALL) {
     if ($case == "OFF") {
         $showq .= "\n(case insensitive match)";
@@ -302,64 +324,66 @@ if (isset($file) && $file != "") {
     $showq .= "\noutput 1 file in ";
     if ($file == "rpt") {
         $showq .= "text";
-    }elseif ($file == "gz") {
+    } elseif ($file == "gz") {
         $showq .= "tar ball";
-    }else {
+    } else {
         $showq .= "zip";
     }
     if ($delimiter == "csv") {
-        $showq .= " format using ".$delimiter;
+        $showq .= " format using " . $delimiter;
     } else {
-        $showq .= " format using ".$delimiter." as delimiter";
+        $showq .= " format using " . $delimiter . " as delimiter";
     }
 }
 $showq .= ".";
 $query = $query_string;
 
-GLM_TOOLBOX::top("QUERY BUILDER PAGE","");
-GLM_TOOLBOX::html_nav_table($nav,$navWidth);
+GLM_TOOLBOX::top("QUERY BUILDER PAGE", "");
+GLM_TOOLBOX::html_nav_table($nav, $navWidth);
 ?>
-<script src="<?php echo MEDIA_BASE_URL."admin/wm.js"?>"></script>
-<script src="<?php echo MEDIA_BASE_URL."admin/msg.js"?>"></script>
+<script src="<?php echo MEDIA_BASE_URL . "admin/wm.js" ?>"></script>
+<script src="<?php echo MEDIA_BASE_URL . "admin/msg.js" ?>"></script>
 
 <table id="admin-list-table">
-<tr>
-  <th bgcolor="#2f4f4f" class="theader">
-    Submit Query
-  </th>
-  </tr>
     <tr>
-    <td><a href="index.phtml">Go Back to Query page</a></td>
+        <th bgcolor="#2f4f4f" class="theader">
+            Submit Query
+        </th>
     </tr>
-  <tr>
-  <td>
-    <?php echo nl2br($showq)?>
-    <br>
-    <?php if (isset($query_name)) {
-    echo "Query ".$query_name." Recalled";
-    }?>
+    <tr>
+        <td><a href="index.phtml">Go Back to Query page</a></td>
+    </tr>
+    <tr>
+        <td>
+            <?php echo nl2br($showq) ?>
+            <br>
+<?php
+if (isset($query_name)) {
+    echo "Query " . $query_name . " Recalled";
+}
+?>
 
-    <form action="list_contact.phtml" method="POST">
-    <input type="hidden" name="delimiter" value="<?php echo $delimiter?>">
-    <input type="hidden" name="file" value="<?php echo $file?>">
+            <form action="list_contact.phtml" method="POST">
+                <input type="hidden" name="delimiter" value="<?php echo $delimiter ?>">
+                <input type="hidden" name="file" value="<?php echo $file ?>">
+                <?php
+                if (!$_GET['query_no']) {
+                    ?>
+                    <input type="hidden" name="query_string" value="<?php echo $query_string ?>">
+                    <?php
+                } else {
+                    ?>
+                    <input type="hidden" name="query_no" value="<?php echo $query_no; ?>">
     <?php
-    if (!$_GET['query_no']) {
-    ?>
-    <input type="hidden" name="query_string" value="<?php echo $query_string?>">
-    <?php
-    } else {
-    ?>
-    <input type="hidden" name="query_no" value="<?php echo $query_no;?>">
-    <?php
-    }
-    ?>
-    <input type="hidden" name="Submit" value="Submit Query">
-    <center>
-    <input type="submit" value="Send Query">
-    </form>
-    </center>
-    </td>
-  </tr>
+}
+?>
+                <input type="hidden" name="Submit" value="Submit Query">
+                <center>
+                    <input type="submit" value="Send Query">
+                    </form>
+                </center>
+        </td>
+    </tr>
 </table>
 <script lang="javascript">
     var o_save = new Object();
@@ -369,27 +393,27 @@ GLM_TOOLBOX::html_nav_table($nav,$navWidth);
     o_save.height = 150;
 </script>
 <table>
-  <tr>
-  <th bgcolor="#2f4f4f" class="theader">
-    Do you wish to save this query for future use?
-  </th>
-  </tr>
-  <tr>
-    <td>
-    <a href="#" onClick="
-    glm_open(o_save);
-    return(false);
-    ">Save This Report</a>
-    </td>
-</tr>
+    <tr>
+        <th bgcolor="#2f4f4f" class="theader">
+            Do you wish to save this query for future use?
+        </th>
+    </tr>
+    <tr>
+        <td>
+            <a href="#" onClick="
+                    glm_open(o_save);
+                    return(false);
+               ">Save This Report</a>
+        </td>
+    </tr>
 </table>
 
 <?php
 /* Save the query with (current) as query_name */
-$qs = "SELECT id
+$qs    = "SELECT id
          FROM query_db
         WHERE query_name = '(current)'";
-$res = $DB->dbh->query($qs);
+$res   = $DB->dbh->query($qs);
 if (!$rowId = $res->fetchColumn()) {
     $sql = "
     INSERT INTO query_db